From 0aa33ef5c4982ca9d2476f09a4cfae01e186b9e4 Mon Sep 17 00:00:00 2001 From: Atticus Kuhn <52258164+AtticusKuhn@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:12:32 +0100 Subject: [PATCH] Fix: update test cases for `test/LLVMDialect/InstCombine` (#441) Previously, the test cases inside the folder `test/LLVMDialect/InstCombine` were old and did not work with `mlir-opt` (Tobias said that this was due to the changing syntax of MLIR, I believe). I updated the test cases by downloading the llvm project, and then converting the `*.ll`` files to `*.mlir` files using the following script: ```bash # Source directory SRC_DIR="llvm-project-main/llvm/test/Transforms/InstCombine/" # Destination directory DEST_DIR="lean-mlir/test/LLVMDialect/InstCombine/" # Loop through all .ll files in the source directory for file in "$SRC_DIR"*.ll; do # Get the filename without the path filename=$(basename "$file") # Convert .ll to .mlir output_file="${filename%.ll}.mlir" echo "Converting $filename to $output_file" # Perform the conversion and save to the destination directory mlir-translate -import-llvm "$file" > "$DEST_DIR$output_file" # Check if the conversion was successful if [ $? -eq 0 ]; then echo "Successfully converted $filename to $output_file" else echo "Failed to convert $filename" fi done ``` Note that Lean-Opt can still not handle these test cases, because it needs the operations to be in quotation marks. The primary difference is that before, `mlir-opt` did not work on the test cases, and now it does. --------- Co-authored-by: Atticus Kuhn --- .../2003-05-26-CastMiscompile.ll.mlir | 16 +- .../2003-05-27-ConstExprCrash.ll.mlir | 27 +- .../2003-06-05-BranchInvertInfLoop.ll.mlir | 22 +- .../2003-07-21-ExternalConstant.ll.mlir | 52 +- .../2003-08-12-AllocaNonNull.ll.mlir | 16 + .../2003-09-09-VolatileLoadElim.ll.mlir | 14 +- .../2003-10-29-CallSiteResolve.ll.mlir | 27 +- .../2003-11-03-VarargsCallBug.ll.mlir | 19 +- .../2004-01-13-InstCombineInvokePHI.ll.mlir | 20 + .../2004-02-23-ShiftShiftOverflow.ll.mlir | 31 +- .../2004-03-13-InstCombineInfLoop.ll.mlir | 22 +- ...4-04-InstCombineReplaceAllUsesWith.ll.mlir | 6 + .../2004-05-07-UnsizedCastLoad.ll.mlir | 15 +- .../2004-07-27-ConstantExprMul.ll.mlir | 22 +- .../InstCombine/2004-08-09-RemInfLoop.ll.mlir | 16 +- .../InstCombine/2004-08-10-BoolSetCC.ll.mlir | 16 +- .../2004-09-20-BadLoadCombine.ll.mlir | 15 + .../2004-09-20-BadLoadCombine2.ll.mlir | 36 +- .../2004-09-28-BadShiftAndSetCC.ll.mlir | 24 +- .../2004-11-22-Missed-and-fold.ll.mlir | 20 +- ...1-27-SetCCForCastLargerAndConstant.ll.mlir | 266 + .../2004-12-08-RemInfiniteLoop.ll.mlir | 16 +- .../2005-03-04-ShiftOverflow.ll.mlir | 20 +- .../2005-04-07-UDivSelectCrash.ll.mlir | 9 + .../2005-06-15-DivSelectCrash.ll.mlir | 13 + .../2005-06-15-ShiftSetCCCrash.ll.mlir | 19 +- .../InstCombine/2005-06-16-RangeCrash.ll.mlir | 19 +- .../2005-07-07-DeadPHILoop.ll.mlir | 17 +- .../2006-02-13-DemandedMiscompile.ll.mlir | 18 +- .../InstCombine/2006-02-28-Crash.ll.mlir | 19 +- .../2006-03-30-ExtractElement.ll.mlir | 10 + .../2006-04-28-ShiftShiftLongLong.ll.mlir | 18 +- .../2006-05-04-DemandedBitCrash.ll.mlir | 93 +- .../InstCombine/2006-09-15-CastToBool.ll.mlir | 32 +- ...-19-SignedToUnsignedCastAndConst-2.ll.mlir | 18 +- .../InstCombine/2006-10-20-mask.ll.mlir | 20 +- .../2006-10-26-VectorReassoc.ll.mlir | 193 +- .../2006-11-10-ashr-miscompile.ll.mlir | 18 +- .../2006-12-01-BadFPVectorXform.ll.mlir | 16 +- .../2006-12-05-fp-to-int-ext.ll.mlir | 16 +- .../2006-12-08-Phi-ICmp-Op-Fold.ll.mlir | 79 +- .../2006-12-08-Select-ICmp.ll.mlir | 29 + .../InstCombine/2006-12-15-Range-Test.ll.mlir | 47 + .../2006-12-23-Select-Cmp-Cmp.ll.mlir | 18 + .../2007-01-13-ExtCompareMiscompile.ll.mlir | 18 +- .../2007-01-18-VectorInfLoop.ll.mlir | 18 +- .../2007-02-01-LoadSinkAlloca.ll.mlir | 72 +- .../2007-02-07-PointerCast.ll.mlir | 35 +- .../2007-02-23-PhiFoldInfLoop.ll.mlir | 21 + .../2007-03-13-CompareMerge.ll.mlir | 15 + .../2007-03-19-BadTruncChangePR1261.ll.mlir | 24 +- .../2007-03-21-SignedRangeTest.ll.mlir | 35 +- .../2007-03-25-BadShiftMask.ll.mlir | 50 +- .../2007-03-25-DoubleShift.ll.mlir | 22 +- .../2007-03-26-BadShiftMask.ll.mlir | 60 +- .../2007-04-08-SingleEltVectorCrash.ll.mlir | 7 + .../InstCombine/2007-05-10-icmp-or.ll.mlir | 17 + .../InstCombine/2007-05-14-Crash.ll.mlir | 20 +- .../2007-05-18-CastFoldBug.ll.mlir | 20 +- .../2007-06-06-AshrSignBit.ll.mlir | 36 +- .../2007-06-21-DivCompareMiscomp.ll.mlir | 20 +- .../2007-08-02-InfiniteLoop.ll.mlir | 20 +- .../2007-09-10-AliasConstFold.ll.mlir | 0 .../2007-09-17-AliasConstFold2.ll.mlir | 0 .../2007-10-10-EliminateMemCpy.ll.mlir | 37 +- .../InstCombine/2007-10-12-Crash.ll.mlir | 55 +- .../InstCombine/2007-10-28-stacksave.ll.mlir | 92 +- .../InstCombine/2007-10-31-RangeCrash.ll.mlir | 57 +- .../2007-10-31-StringCrash.ll.mlir | 34 +- .../2007-11-07-OpaqueAlignCrash.ll.mlir | 31 +- .../2007-11-15-CompareMiscomp.ll.mlir | 19 + .../2007-11-25-CompatibleAttributes.ll.mlir | 28 +- .../2007-12-10-ConstFoldCompare.ll.mlir | 10 + .../InstCombine/2007-12-12-GEPScale.ll.mlir | 17 +- .../2007-12-16-AsmNoUnwind.ll.mlir | 0 .../2007-12-18-AddSelCmpSub.ll.mlir | 22 + .../InstCombine/2007-12-28-IcmpSub2.ll.mlir | 90 + .../2008-01-06-BitCastAttributes.ll.mlir | 25 + .../InstCombine/2008-01-06-CastCrash.ll.mlir | 24 +- .../InstCombine/2008-01-06-VoidCast.ll.mlir | 24 +- .../InstCombine/2008-01-13-AndCmpCmp.ll.mlir | 19 + .../2008-01-14-VarArgTrampoline.ll.mlir | 29 - .../InstCombine/2008-01-21-MulTrunc.ll.mlir | 53 + .../2008-01-27-FloatSelect.ll.mlir | 9 + .../InstCombine/2008-02-13-MulURem.ll.mlir | 18 +- .../2008-02-16-SDivOverflow2.ll.mlir | 18 +- .../InstCombine/2008-02-23-MulSub.ll.mlir | 22 +- .../2008-02-28-OrFCmpCrash.ll.mlir | 27 + .../InstCombine/2008-03-13-IntToPtr.ll.mlir | 22 +- .../2008-04-22-ByValBitcast.ll.mlir | 20 +- .../2008-04-28-VolatileStore.ll.mlir | 10 + .../2008-04-29-VolatileLoadDontMerge.ll.mlir | 46 +- .../2008-04-29-VolatileLoadMerge.ll.mlir | 31 +- .../2008-05-08-LiveStoreDelete.ll.mlir | 50 +- .../InstCombine/2008-05-08-StrLenSink.ll.mlir | 52 +- .../2008-05-09-SinkOfInvoke.ll.mlir | 23 + .../InstCombine/2008-05-17-InfLoop.ll.mlir | 22 + .../2008-05-18-FoldIntToPtr.ll.mlir | 18 + .../InstCombine/2008-05-22-IDivVector.ll.mlir | 14 +- .../2008-05-23-CompareFold.ll.mlir | 9 + .../InstCombine/2008-05-31-AddBool.ll.mlir | 14 +- .../InstCombine/2008-05-31-Bools.ll.mlir | 41 +- .../InstCombine/2008-06-05-ashr-crash.ll.mlir | 16 +- .../InstCombine/2008-06-08-ICmpPHI.ll.mlir | 66 +- .../2008-06-13-InfiniteLoopStore.ll.mlir | 38 +- .../2008-06-13-ReadOnlyCallStore.ll.mlir | 31 +- .../InstCombine/2008-06-19-UncondLoad.ll.mlir | 14 + .../2008-06-21-CompareMiscomp.ll.mlir | 19 + .../2008-06-24-StackRestore.ll.mlir | 75 +- .../2008-07-08-ShiftOneAndOne.ll.mlir | 22 +- .../InstCombine/2008-07-08-SubAnd.ll.mlir | 20 +- .../2008-07-08-VolatileLoadMerge.ll.mlir | 46 +- .../2008-07-09-SubAndError.ll.mlir | 20 +- .../2008-07-10-CastSextBool.ll.mlir | 29 +- .../InstCombine/2008-07-11-RemAnd.ll.mlir | 35 +- .../InstCombine/2008-07-13-DivZero.ll.mlir | 12 + .../InstCombine/2008-07-16-fsub.ll.mlir | 14 +- .../InstCombine/2008-08-05-And.ll.mlir | 39 + .../2008-09-02-VectorCrash.ll.mlir | 30 + .../2008-10-11-DivCompareFold.ll.mlir | 20 +- .../2008-10-23-ConstFoldWithoutMask.ll.mlir | 17 +- .../2008-11-01-SRemDemandedBits.ll.mlir | 20 +- .../InstCombine/2008-11-08-FCmp.ll.mlir | 44 + .../InstCombine/2008-11-27-IDivVector.ll.mlir | 27 +- .../2008-11-27-MultiplyIntVec.ll.mlir | 27 +- .../2008-12-17-SRemNegConstVec.ll.mlir | 16 +- .../InstCombine/2009-01-05-i128-crash.ll.mlir | 23 + .../2009-01-08-AlignAlloca.ll.mlir | 44 +- .../2009-01-16-PointerAddrSpace.ll.mlir | 18 +- ...01-19-fmod-constant-float-specials.ll.mlir | 352 + .../2009-01-19-fmod-constant-float.ll.mlir | 141 +- .../2009-01-24-EmptyStruct.ll.mlir | 21 +- .../InstCombine/2009-01-31-InfIterate.ll.mlir | 36 +- .../InstCombine/2009-02-04-FPBitcast.ll.mlir | 25 +- .../2009-02-11-NotInitialized.ll.mlir | 19 +- .../2009-02-20-InstCombine-SROA.ll.mlir | 239 + .../InstCombine/2009-02-21-LoadCST.ll.mlir | 20 +- .../2009-02-25-CrashZeroSizeArray.ll.mlir | 35 + .../2009-03-18-vector-ashr-crash.ll.mlir | 13 + .../InstCombine/2009-03-24-InfLoop.ll.mlir | 24 +- .../2009-04-07-MulPromoteToI96.ll.mlir | 20 +- .../InstCombine/2009-05-23-FCmpToICmp.ll.mlir | 9 + .../2009-06-11-StoreAddrSpace.ll.mlir | 17 +- .../2009-06-16-SRemDemandedBits.ll.mlir | 18 +- .../2009-07-02-MaskedIntVector.ll.mlir | 17 + .../2009-12-17-CmpSelectNull.ll.mlir | 17 + .../2010-01-28-NegativeSRem.ll.mlir | 27 +- .../InstCombine/2010-03-03-ExtElim.ll.mlir | 64 + .../2010-05-30-memcpy-Struct.ll.mlir | 25 +- .../InstCombine/2010-11-01-lshr-mask.ll.mlir | 85 +- .../2010-11-21-SizeZeroTypeGEP.ll.mlir | 27 +- .../2010-11-23-Distributed.ll.mlir | 39 +- .../InstCombine/2011-02-14-InfLoop.ll.mlir | 27 + .../2011-03-08-SRemMinusOneBadOpt.ll.mlir | 22 +- .../2011-05-02-VectorBoolean.ll.mlir | 16 + .../2011-05-13-InBoundsGEP.ll.mlir | 20 + .../InstCombine/2011-05-28-swapmulsub.ll.mlir | 100 +- .../InstCombine/2011-06-13-nsw-alloca.ll.mlir | 104 +- .../InstCombine/2011-09-03-Trampoline.ll.mlir | 77 - .../2011-10-07-AlignPromotion.ll.mlir | 27 +- .../2012-01-11-OpaqueBitcastCrash.ll.mlir | 22 +- .../InstCombine/2012-02-13-FCmp.ll.mlir | 32 + .../InstCombine/2012-02-28-ICmp.ll.mlir | 25 + .../2012-03-10-InstCombine.ll.mlir | 47 + .../InstCombine/2012-04-24-vselect.ll.mlir | 12 + .../InstCombine/2012-04-30-SRem.ll.mlir | 26 +- .../2012-05-28-select-hang.ll.mlir | 83 +- .../InstCombine/2012-06-06-LoadOfPHIs.ll.mlir | 133 + .../InstCombine/2012-07-25-LoadPart.ll.mlir | 25 +- .../2012-07-30-addrsp-bitcast.ll.mlir | 14 + .../InstCombine/2012-08-28-udiv_ashl.ll.mlir | 78 +- .../2012-09-17-ZeroSizedAlloca.ll.mlir | 45 +- .../2012-10-25-vector-of-pointers.ll.mlir | 35 + .../InstCombine/2012-12-14-simp-vgep.ll.mlir | 18 + .../2012-3-15-or-xor-constant.ll.mlir | 17 + .../2012-6-7-vselect-bitcast.ll.mlir | 11 + ...3-05-Combine-BitcastTy-Into-Alloca.ll.mlir | 56 + .../2023-07-13-arm-infiniteloop.ll.mlir | 24 + .../InstCombine/AddOverFlow.ll.mlir | 151 + .../InstCombine/CPP_min_max.ll.mlir | 23 + .../InstCombine/ExtractCast.ll.mlir | 14 + .../InstCombine/InferAlignAttribute.ll.mlir | 32 + .../InstCombine/IntPtrCast.ll.mlir | 16 +- .../InstCombine/JavaCompare.ll.mlir | 13 + .../InstCombine/LandingPadClauses.ll.mlir | 171 + .../OverlappingInsertvalues.ll.mlir | 26 + test/LLVMDialect/InstCombine/PR30597.ll.mlir | 15 + test/LLVMDialect/InstCombine/PR37526.ll.mlir | 11 + .../InstCombine/StoreToNull-DbgCheck.ll.mlir | 7 + test/LLVMDialect/InstCombine/abs-1.ll.mlir | 547 ++ .../InstCombine/abs-intrinsic.ll.mlir | 424 ++ test/LLVMDialect/InstCombine/abs_abs.ll.mlir | 915 +++ .../InstCombine/add-mask-neg.ll.mlir | 83 + test/LLVMDialect/InstCombine/add-mask.ll.mlir | 124 +- .../InstCombine/add-min-max.ll.mlir | 38 + .../LLVMDialect/InstCombine/add-shift.ll.mlir | 46 + .../InstCombine/add-shl-sdiv-to-srem.ll.mlir | 186 + .../InstCombine/add-sitofp.ll.mlir | 153 +- test/LLVMDialect/InstCombine/add.ll.mlir | 0 test/LLVMDialect/InstCombine/add2.ll.mlir | 300 + test/LLVMDialect/InstCombine/add3.ll.mlir | 37 +- test/LLVMDialect/InstCombine/add4.ll.mlir | 297 +- .../InstCombine/add_or_sub.ll.mlir | 126 + .../LLVMDialect/InstCombine/addnegneg.ll.mlir | 22 +- .../InstCombine/addrspacecast.ll.mlir | 125 + .../addsub-constant-folding.ll.mlir | 666 ++ .../InstCombine/adjust-for-minmax.ll.mlir | 272 + .../aggregate-reconstruction.ll.mlir | 166 + .../InstCombine/alias-recursion.ll.mlir | 0 .../InstCombine/align-addr.ll.mlir | 0 .../InstCombine/align-attr.ll.mlir | 28 +- .../InstCombine/align-external.ll.mlir | 29 + .../InstCombine/all-bits-shift.ll.mlir | 77 +- .../InstCombine/alloc-realloc-free.ll.mlir | 13 + .../InstCombine/alloca-big.ll.mlir | 20 +- .../InstCombine/alloca-cast-debuginfo.ll.mlir | 27 + .../alloca-in-non-alloca-as.ll.mlir | 62 +- .../alloca-intptr-not-sizet.ll.mlir | 7 + test/LLVMDialect/InstCombine/alloca.ll.mlir | 118 + .../InstCombine/allocsize-32.ll.mlir | 23 - .../LLVMDialect/InstCombine/allocsize.ll.mlir | 129 - .../InstCombine/allow-checks.ll.mlir | 0 .../InstCombine/and-add-shl.ll.mlir | 37 + .../InstCombine/and-compare.ll.mlir | 105 + test/LLVMDialect/InstCombine/and-fcmp.ll.mlir | 3215 +++++++++ .../InstCombine/and-narrow.ll.mlir | 245 +- .../InstCombine/and-or-and.ll.mlir | 99 +- .../and-or-icmp-const-icmp.ll.mlir | 174 + .../InstCombine/and-or-icmp-min-max.ll.mlir | 1434 ++++ .../InstCombine/and-or-icmp-nullptr.ll.mlir | 452 ++ .../InstCombine/and-or-icmps.ll.mlir | 2112 ++++++ .../and-or-implied-cond-not.ll.mlir | 44 + .../InstCombine/and-or-not.ll.mlir | 478 ++ test/LLVMDialect/InstCombine/and-or.ll.mlir | 444 ++ .../InstCombine/and-xor-merge.ll.mlir | 76 +- .../InstCombine/and-xor-or.ll.mlir | 2613 +++++++ test/LLVMDialect/InstCombine/and.ll.mlir | 1846 +++++ test/LLVMDialect/InstCombine/and2.ll.mlir | 184 + .../InstCombine/annotation-intrinsic.ll.mlir | 26 +- .../InstCombine/annotations.ll.mlir | 70 + .../LLVMDialect/InstCombine/apint-add.ll.mlir | 103 + .../InstCombine/apint-and-compare.ll.mlir | 35 +- .../InstCombine/apint-and-or-and.ll.mlir | 84 +- .../InstCombine/apint-and-xor-merge.ll.mlir | 31 +- .../LLVMDialect/InstCombine/apint-and.ll.mlir | 177 +- .../apint-call-cast-target.ll.mlir | 36 +- .../InstCombine/apint-cast-and-cast.ll.mlir | 35 +- .../apint-cast-cast-to-and.ll.mlir | 16 +- .../InstCombine/apint-cast.ll.mlir | 45 +- .../InstCombine/apint-div1.ll.mlir | 21 + .../InstCombine/apint-div2.ll.mlir | 21 + .../InstCombine/apint-mul1.ll.mlir | 20 + .../InstCombine/apint-mul2.ll.mlir | 28 + .../LLVMDialect/InstCombine/apint-not.ll.mlir | 31 +- test/LLVMDialect/InstCombine/apint-or.ll.mlir | 81 +- .../InstCombine/apint-rem1.ll.mlir | 21 + .../InstCombine/apint-rem2.ll.mlir | 21 + .../InstCombine/apint-select.ll.mlir | 77 + .../InstCombine/apint-shift-simplify.ll.mlir | 44 +- .../InstCombine/apint-shift.ll.mlir | 412 ++ .../InstCombine/apint-shl-trunc.ll.mlir | 38 +- .../LLVMDialect/InstCombine/apint-sub.ll.mlir | 248 +- .../InstCombine/apint-xor1.ll.mlir | 96 +- .../InstCombine/apint-xor2.ll.mlir | 96 +- test/LLVMDialect/InstCombine/array.ll.mlir | 132 + .../InstCombine/ashr-demand.ll.mlir | 73 +- .../ashr-icmp-minmax-idiom-break.ll.mlir | 13 + .../LLVMDialect/InstCombine/ashr-lshr.ll.mlir | 537 ++ .../InstCombine/ashr-or-mul-abs.ll.mlir | 95 + .../InstCombine/assoc-cast-assoc.ll.mlir | 62 + .../InstCombine/assume-align.ll.mlir | 141 +- .../assume-icmp-null-select.ll.mlir | 20 + .../InstCombine/assume-inseltpoison.ll.mlir | 11 + .../InstCombine/assume-loop-align.ll.mlir | 60 +- .../InstCombine/assume-redundant.ll.mlir | 121 +- .../assume-separate_storage.ll.mlir | 29 + test/LLVMDialect/InstCombine/assume.ll.mlir | 0 test/LLVMDialect/InstCombine/assume2.ll.mlir | 234 +- .../InstCombine/assume_inevitable.ll.mlir | 0 test/LLVMDialect/InstCombine/atomic.ll.mlir | 240 + .../LLVMDialect/InstCombine/atomicrmw.ll.mlir | 412 ++ test/LLVMDialect/InstCombine/avg-lsb.ll.mlir | 27 + .../LLVMDialect/InstCombine/badmalloc.ll.mlir | 27 + test/LLVMDialect/InstCombine/bcmp-1.ll.mlir | 199 +- test/LLVMDialect/InstCombine/bcopy.ll.mlir | 28 +- .../InstCombine/binop-and-shifts.ll.mlir | 620 ++ .../InstCombine/binop-cast.ll.mlir | 295 +- .../InstCombine/binop-itofp.ll.mlir | 717 ++ .../binop-of-displaced-shifts.ll.mlir | 273 + .../InstCombine/binop-phi-operands.ll.mlir | 326 + .../binop-select-cast-of-select-cond.ll.mlir | 156 + .../InstCombine/binop-select.ll.mlir | 274 + .../InstCombine/bit-checks.ll.mlir | 991 +++ test/LLVMDialect/InstCombine/bit_ceil.ll.mlir | 204 + .../LLVMDialect/InstCombine/bit_floor.ll.mlir | 103 + .../bitcast-bfloat-half-mixing.ll.mlir | 32 + .../InstCombine/bitcast-bigendian.ll.mlir | 157 +- .../InstCombine/bitcast-bitcast.ll.mlir | 93 +- .../InstCombine/bitcast-function.ll.mlir | 245 +- .../bitcast-inselt-bitcast.ll.mlir | 75 + .../InstCombine/bitcast-inseltpoison.ll.mlir | 0 .../bitcast-phi-uselistorder.ll.mlir | 31 +- .../InstCombine/bitcast-sext-vector.ll.mlir | 18 +- .../InstCombine/bitcast-store.ll.mlir | 32 - .../bitcast-vec-canon-inseltpoison.ll.mlir | 79 + .../InstCombine/bitcast-vec-canon.ll.mlir | 79 + test/LLVMDialect/InstCombine/bitcast.ll.mlir | 0 .../InstCombine/bitreverse-hang.ll.mlir | 47 +- .../InstCombine/bitreverse-known-bits.ll.mlir | 87 +- .../InstCombine/bitreverse.ll.mlir | 392 ++ test/LLVMDialect/InstCombine/bittest.ll.mlir | 29 + .../InstCombine/bitwiselogic-bitmanip.ll.mlir | 104 + test/LLVMDialect/InstCombine/branch.ll.mlir | 150 +- .../broadcast-inseltpoison.ll.mlir | 144 + .../LLVMDialect/InstCombine/broadcast.ll.mlir | 144 + .../InstCombine/bswap-fold.ll.mlir | 575 ++ .../InstCombine/bswap-inseltpoison.ll.mlir | 42 + .../InstCombine/bswap-known-bits.ll.mlir | 85 +- test/LLVMDialect/InstCombine/bswap.ll.mlir | 822 +++ .../builtin-dynamic-object-size.ll.mlir | 0 .../builtin-object-size-custom-dl.ll.mlir | 38 - .../builtin-object-size-offset.ll.mlir | 0 .../builtin-object-size-ptr.ll.mlir | 66 - .../builtin-object-size-strdup-family.ll.mlir | 63 - test/LLVMDialect/InstCombine/byval.ll.mlir | 48 +- .../InstCombine/cabs-array.ll.mlir | 68 +- .../InstCombine/cabs-discrete.ll.mlir | 68 +- .../call-callconv-mismatch.ll.mlir | 23 +- .../InstCombine/call-callconv.ll.mlir | 61 +- .../InstCombine/call-cast-attrs.ll.mlir | 0 .../call-cast-target-inalloca.ll.mlir | 17 + .../call-cast-target-preallocated.ll.mlir | 29 - .../InstCombine/call-cast-target.ll.mlir | 57 + .../InstCombine/call-guard.ll.mlir | 96 - .../InstCombine/call-intrinsics.ll.mlir | 43 +- .../InstCombine/call-returned.ll.mlir | 51 + .../InstCombine/call-undef.ll.mlir | 52 + test/LLVMDialect/InstCombine/call.ll.mlir | 180 + test/LLVMDialect/InstCombine/call2.ll.mlir | 45 +- .../InstCombine/call_nonnull_arg.ll.mlir | 30 + .../InstCombine/calloc-mismatch.ll.mlir | 20 +- ...allsite_nonnull_args_through_casts.ll.mlir | 149 +- .../canonicalize-ashr-shl-to-masking.ll.mlir | 424 ++ ...n-negative-and-positive-thresholds.ll.mlir | 319 + ...etween-zero-and-positive-threshold.ll.mlir | 242 + ...lect-of-constant-threshold-pattern.ll.mlir | 126 + ...w-bit-mask-and-icmp-eq-to-icmp-ule.ll.mlir | 111 + ...w-bit-mask-and-icmp-ne-to-icmp-ugt.ll.mlir | 126 + ...-bit-mask-and-icmp-sge-to-icmp-sle.ll.mlir | 126 + ...-bit-mask-and-icmp-sgt-to-icmp-sgt.ll.mlir | 154 + ...-bit-mask-and-icmp-sle-to-icmp-sle.ll.mlir | 138 + ...-bit-mask-and-icmp-slt-to-icmp-sgt.ll.mlir | 141 + ...-bit-mask-and-icmp-uge-to-icmp-ule.ll.mlir | 111 + ...-bit-mask-and-icmp-ugt-to-icmp-ugt.ll.mlir | 138 + ...-bit-mask-and-icmp-ule-to-icmp-ule.ll.mlir | 122 + ...-bit-mask-and-icmp-ult-to-icmp-ugt.ll.mlir | 126 + .../InstCombine/canonicalize-fcmp-inf.ll.mlir | 147 + .../InstCombine/canonicalize-gep-mul.ll.mlir | 0 ...ze-lack-of-signed-truncation-check.ll.mlir | 142 + ...w-bit-mask-and-icmp-eq-to-icmp-ule.ll.mlir | 89 + ...w-bit-mask-and-icmp-ne-to-icmp-ugt.ll.mlir | 89 + ...it-mask-v2-and-icmp-eq-to-icmp-ule.ll.mlir | 181 + ...it-mask-v2-and-icmp-ne-to-icmp-ugt.ll.mlir | 181 + ...it-mask-v3-and-icmp-eq-to-icmp-ule.ll.mlir | 182 + ...it-mask-v3-and-icmp-ne-to-icmp-ugt.ll.mlir | 182 + ...it-mask-v4-and-icmp-eq-to-icmp-ule.ll.mlir | 129 + ...it-mask-v4-and-icmp-ne-to-icmp-ugt.ll.mlir | 129 + .../canonicalize-lshr-shl-to-masking.ll.mlir | 424 ++ ...canonicalize-or-with-overflow-icmp.ll.mlir | 165 + ...ize-selects-icmp-condition-bittest.ll.mlir | 81 + .../canonicalize-shl-lshr-to-masking.ll.mlir | 304 + ...nonicalize-signed-truncation-check.ll.mlir | 142 + .../canonicalize-vector-extract.ll.mlir | 121 +- .../canonicalize-vector-insert.ll.mlir | 115 +- .../InstCombine/canonicalize.ll.mlir | 0 .../InstCombine/canonicalize_branch.ll.mlir | 262 + .../InstCombine/cast-byval.ll.mlir | 16 + .../cast-call-combine-prof.ll.mlir | 22 + .../InstCombine/cast-call-combine.ll.mlir | 19 + .../cast-callee-deopt-bundles.ll.mlir | 19 +- .../InstCombine/cast-int-fcmp-eq-0.ll.mlir | 339 + .../InstCombine/cast-int-icmp-eq-0.ll.mlir | 477 ++ .../InstCombine/cast-mul-select.ll.mlir | 85 + .../InstCombine/cast-select.ll.mlir | 72 + .../cast-set-preserve-signed-dbg-val.ll.mlir | 0 test/LLVMDialect/InstCombine/cast-set.ll.mlir | 45 + .../cast-unsigned-icmp-eqcmp-0.ll.mlir | 182 + test/LLVMDialect/InstCombine/cast.ll.mlir | 1273 ++++ test/LLVMDialect/InstCombine/cast_phi.ll.mlir | 316 +- test/LLVMDialect/InstCombine/cast_ptr.ll.mlir | 208 + .../InstCombine/catchswitch-phi.ll.mlir | 0 test/LLVMDialect/InstCombine/ceil.ll.mlir | 81 +- .../InstCombine/clamp-to-minmax.ll.mlir | 342 + .../InstCombine/cmp-intrinsic.ll.mlir | 547 ++ .../InstCombine/cmp-x-vs-neg-x.ll.mlir | 209 +- .../combine-is.fpclass-and-fcmp.ll.mlir | 259 + .../commutative-intrinsics.ll.mlir | 0 .../commutative-operation-over-phis.ll.mlir | 234 + ...commutative-operation-over-selects.ll.mlir | 0 .../InstCombine/compare-3way.ll.mlir | 373 + .../InstCombine/compare-alloca.ll.mlir | 192 + .../InstCombine/compare-signs.ll.mlir | 187 + .../InstCombine/compare-udiv.ll.mlir | 224 + .../InstCombine/compare-unescaped.ll.mlir | 239 + .../InstCombine/conditional-negation.ll.mlir | 132 + ...gth-signext-after-high-bit-extract.ll.mlir | 626 ++ .../InstCombine/consecutive-fences.ll.mlir | 0 .../InstCombine/consecutive-ptrmask.ll.mlir | 0 .../constant-expr-datalayout.ll.mlir | 32 + ...onstant-fold-address-space-pointer.ll.mlir | 270 + .../InstCombine/constant-fold-alias.ll.mlir | 0 .../InstCombine/constant-fold-compare.ll.mlir | 21 +- .../InstCombine/constant-fold-gep.ll.mlir | 183 + .../constant-fold-iteration.ll.mlir | 21 +- .../InstCombine/constant-fold-libfunc.ll.mlir | 38 +- .../InstCombine/constant-fold-math.ll.mlir | 111 +- .../InstCombine/constant-fold-shifts.ll.mlir | 33 + .../InstCombine/constrained.ll.mlir | 0 .../InstCombine/convergent.ll.mlir | 0 .../InstCombine/copysign-fneg-fabs.ll.mlir | 181 + test/LLVMDialect/InstCombine/copysign.ll.mlir | 53 + test/LLVMDialect/InstCombine/cos-1.ll.mlir | 229 + test/LLVMDialect/InstCombine/cos-2.ll.mlir | 19 + .../InstCombine/cos-sin-intrinsic.ll.mlir | 100 + test/LLVMDialect/InstCombine/crash.ll.mlir | 0 .../create-class-from-logic-fcmp.ll.mlir | 0 .../InstCombine/ctlz-cttz-bitreverse.ll.mlir | 89 +- .../InstCombine/ctlz-cttz-shifts.ll.mlir | 116 + .../ctpop-bswap-bitreverse.ll.mlir | 61 +- .../InstCombine/ctpop-cttz.ll.mlir | 91 + .../InstCombine/ctpop-pow2.ll.mlir | 90 + test/LLVMDialect/InstCombine/ctpop.ll.mlir | 281 + test/LLVMDialect/InstCombine/cttz-abs.ll.mlir | 152 + .../InstCombine/cttz-negative.ll.mlir | 47 + test/LLVMDialect/InstCombine/cttz.ll.mlir | 235 +- .../dbg-scalable-store-fixed-frag.ll.mlir | 28 + .../dbg-simplify-alloca-size.ll.mlir | 16 + .../InstCombine/dce-iterate.ll.mlir | 48 +- test/LLVMDialect/InstCombine/deadcode.ll.mlir | 54 +- .../InstCombine/debug-line.ll.mlir | 26 +- .../InstCombine/debuginfo-dce.ll.mlir | 67 + .../InstCombine/debuginfo-dce2.ll.mlir | 19 + .../debuginfo-scalable-typesize.ll.mlir | 0 .../InstCombine/debuginfo-sink.ll.mlir | 42 + .../InstCombine/debuginfo-skip.ll.mlir | 19 + .../InstCombine/debuginfo-variables.ll.mlir | 80 + .../LLVMDialect/InstCombine/debuginfo.ll.mlir | 0 .../InstCombine/debuginfo_add.ll.mlir | 55 + .../InstCombine/default-alignment.ll.mlir | 16 +- .../InstCombine/demand_shrink_nsw.ll.mlir | 54 +- .../demorgan-sink-not-into-xor.ll.mlir | 148 +- test/LLVMDialect/InstCombine/demorgan.ll.mlir | 292 + .../InstCombine/dependent-ivs.ll.mlir | 0 .../InstCombine/deref-alloc-fns.ll.mlir | 223 + .../InstCombine/disable-builtin.ll.mlir | 11 + .../disable-simplify-libcalls.ll.mlir | 260 + .../InstCombine/distribute.ll.mlir | 105 +- .../div-by-0-guard-before-smul_ov-not.ll.mlir | 63 + .../div-by-0-guard-before-smul_ov.ll.mlir | 56 + .../div-by-0-guard-before-umul_ov-not.ll.mlir | 63 + .../div-by-0-guard-before-umul_ov.ll.mlir | 56 + test/LLVMDialect/InstCombine/div-i1.ll.mlir | 84 + .../InstCombine/div-shift-crash.ll.mlir | 72 + .../LLVMDialect/InstCombine/div-shift.ll.mlir | 602 ++ test/LLVMDialect/InstCombine/div.ll.mlir | 0 .../InstCombine/dont-distribute-phi.ll.mlir | 40 + .../InstCombine/double-float-shrink-1.ll.mlir | 611 +- .../InstCombine/double-float-shrink-2.ll.mlir | 813 +-- .../early_constfold_changes_IR.ll.mlir | 20 +- .../early_dce_clobbers_callgraph.ll.mlir | 21 +- .../element-atomic-memintrins.ll.mlir | 320 - .../enforce-known-alignment.ll.mlir | 67 +- .../InstCombine/eq-of-parts.ll.mlir | 881 +++ ...rase-dbg-values-at-dead-alloc-site.ll.mlir | 20 + .../InstCombine/err-rep-cold.ll.mlir | 127 +- test/LLVMDialect/InstCombine/exact.ll.mlir | 272 + test/LLVMDialect/InstCombine/exp2-1.ll.mlir | 156 +- test/LLVMDialect/InstCombine/exp2-2.ll.mlir | 19 +- .../InstCombine/exp2-to-ldexp.ll.mlir | 42 + .../InstCombine/extract-select-agg.ll.mlir | 65 + .../extractelement-inseltpoison.ll.mlir | 200 + .../InstCombine/extractelement.ll.mlir | 457 ++ .../InstCombine/extractinsert-tbaa.ll.mlir | 29 + .../InstCombine/extractvalue.ll.mlir | 58 + .../InstCombine/fabs-as-int.ll.mlir | 161 + .../InstCombine/fabs-copysign.ll.mlir | 130 +- .../InstCombine/fabs-fneg-fold.ll.mlir | 92 + .../InstCombine/fabs-libcall.ll.mlir | 26 +- test/LLVMDialect/InstCombine/fabs.ll.mlir | 692 ++ .../InstCombine/fadd-fsub-factor.ll.mlir | 627 +- .../InstCombine/fadd-maximum-minimum.ll.mlir | 44 + test/LLVMDialect/InstCombine/fadd.ll.mlir | 627 ++ .../InstCombine/fast-basictest.ll.mlir | 390 ++ .../LLVMDialect/InstCombine/fast-math.ll.mlir | 459 ++ .../fcmp-denormals-are-zero.ll.mlir | 211 + .../fcmp-range-check-idiom.ll.mlir | 239 + .../InstCombine/fcmp-select.ll.mlir | 152 + .../InstCombine/fcmp-special.ll.mlir | 143 + test/LLVMDialect/InstCombine/fcmp.ll.mlir | 1298 ++++ .../InstCombine/fdiv-cos-sin.ll.mlir | 143 +- .../InstCombine/fdiv-sin-cos.ll.mlir | 126 +- .../LLVMDialect/InstCombine/fdiv-sqrt.ll.mlir | 78 + test/LLVMDialect/InstCombine/fdiv.ll.mlir | 0 test/LLVMDialect/InstCombine/ffs-1.ll.mlir | 161 +- test/LLVMDialect/InstCombine/ffs-i16.ll.mlir | 34 +- .../InstCombine/float-shrink-compare.ll.mlir | 286 + test/LLVMDialect/InstCombine/fls-i16.ll.mlir | 34 +- test/LLVMDialect/InstCombine/fls.ll.mlir | 63 +- test/LLVMDialect/InstCombine/fma.ll.mlir | 556 ++ .../LLVMDialect/InstCombine/fmul-bool.ll.mlir | 18 + test/LLVMDialect/InstCombine/fmul-exp.ll.mlir | 113 +- .../LLVMDialect/InstCombine/fmul-exp2.ll.mlir | 100 +- .../InstCombine/fmul-inseltpoison.ll.mlir | 0 .../InstCombine/fmul-maximum-minimum.ll.mlir | 44 + test/LLVMDialect/InstCombine/fmul-pow.ll.mlir | 229 +- .../LLVMDialect/InstCombine/fmul-sqrt.ll.mlir | 224 +- test/LLVMDialect/InstCombine/fmul.ll.mlir | 0 .../InstCombine/fneg-as-int.ll.mlir | 161 + .../InstCombine/fneg-fabs-as-int.ll.mlir | 169 + .../LLVMDialect/InstCombine/fneg-fabs.ll.mlir | 177 + test/LLVMDialect/InstCombine/fneg.ll.mlir | 0 .../InstCombine/fold-a-or-b-zero.ll.mlir | 82 + .../InstCombine/fold-bin-operand.ll.mlir | 74 + .../InstCombine/fold-calls.ll.mlir | 28 +- .../InstCombine/fold-ctpop-of-not.ll.mlir | 143 + .../InstCombine/fold-ext-eq-c-with-op.ll.mlir | 34 + .../fold-fops-into-selects.ll.mlir | 51 + ...add-of-not-x-and-y-to-sub-x-from-y.ll.mlir | 159 + .../InstCombine/fold-log2-ceil-idiom.ll.mlir | 191 + .../InstCombine/fold-minmax-i1.ll.mlir | 34 + .../fold-phi-load-metadata.ll.mlir | 65 +- test/LLVMDialect/InstCombine/fold-phi.ll.mlir | 47 +- .../fold-select-fmul-if-zero.ll.mlir | 0 .../fold-signbit-test-power2.ll.mlir | 98 + .../InstCombine/fold-sqrt-sqrtf.ll.mlir | 21 +- .../fold-sub-of-not-to-inc-of-add.ll.mlir | 64 + .../InstCombine/fold-vector-select.ll.mlir | 217 + .../fold-vector-zero-inseltpoison.ll.mlir | 41 + .../InstCombine/fold-vector-zero.ll.mlir | 41 + .../InstCombine/force-opaque-ptr.ll.mlir | 36 + .../InstCombine/fortify-folding.ll.mlir | 339 + .../InstCombine/fp-ret-bitcast.ll.mlir | 54 +- test/LLVMDialect/InstCombine/fpcast.ll.mlir | 239 + .../InstCombine/fpclass-check-idioms.ll.mlir | 355 + .../InstCombine/fpclass-from-dom-cond.ll.mlir | 217 + test/LLVMDialect/InstCombine/fpextend.ll.mlir | 235 + .../InstCombine/fpextend_x86.ll.mlir | 80 +- .../LLVMDialect/InstCombine/fprintf-1.ll.mlir | 162 +- .../InstCombine/fprintf-wrong-sig.ll.mlir | 11 + test/LLVMDialect/InstCombine/fptrunc.ll.mlir | 91 + test/LLVMDialect/InstCombine/fputs-1.ll.mlir | 25 + .../InstCombine/fputs-opt-size.ll.mlir | 31 + .../InstCombine/free-inversion.ll.mlir | 438 ++ .../InstCombine/freeze-fp-ops.ll.mlir | 0 .../freeze-integer-intrinsics.ll.mlir | 0 .../InstCombine/freeze-landingpad.ll.mlir | 0 .../InstCombine/freeze-phi.ll.mlir | 123 + test/LLVMDialect/InstCombine/freeze.ll.mlir | 0 test/LLVMDialect/InstCombine/fsh.ll.mlir | 638 ++ test/LLVMDialect/InstCombine/fsub.ll.mlir | 495 ++ test/LLVMDialect/InstCombine/funnel.ll.mlir | 473 ++ test/LLVMDialect/InstCombine/fwrite-1.ll.mlir | 45 + .../InstCombine/gc.relocate-verify.ll.mlir | 21 +- .../InstCombine/gc.relocate.ll.mlir | 0 .../InstCombine/gep-addrspace.ll.mlir | 54 + .../LLVMDialect/InstCombine/gep-alias.ll.mlir | 0 ...replace-gep-idx-with-zero-typesize.ll.mlir | 28 +- .../gep-canonicalize-constant-indices.ll.mlir | 63 + .../gep-combine-loop-invariant.ll.mlir | 325 +- .../InstCombine/gep-custom-dl.ll.mlir | 134 + .../InstCombine/gep-inbounds-null.ll.mlir | 131 + .../gep-merge-constant-indices.ll.mlir | 118 + ...t-size-less-than-or-equal-typesize.ll.mlir | 10 + test/LLVMDialect/InstCombine/gep-sext.ll.mlir | 84 +- .../InstCombine/gep-vector-indices.ll.mlir | 92 + .../InstCombine/gep-vector.ll.mlir | 84 + test/LLVMDialect/InstCombine/gepgep.ll.mlir | 37 +- .../InstCombine/gepofconstgepi8.ll.mlir | 150 + .../LLVMDialect/InstCombine/gepphigep.ll.mlir | 246 +- ...-lowbitmask-upto-and-including-bit.ll.mlir | 203 + .../InstCombine/getelementptr-folding.ll.mlir | 26 +- .../InstCombine/getelementptr.ll.mlir | 0 .../high-bit-signmask-with-trunc.ll.mlir | 109 + .../InstCombine/high-bit-signmask.ll.mlir | 97 + ...-of-bias-calculation-with-constant.ll.mlir | 52 + ...t-negation-out-of-bias-calculation.ll.mlir | 86 + .../hoist-not-from-ashr-operand.ll.mlir | 40 + ...-xor-by-constant-from-xor-by-value.ll.mlir | 80 + .../InstCombine/hoist_instr.ll.mlir | 22 +- test/LLVMDialect/InstCombine/icmp-abs.ll.mlir | 113 + test/LLVMDialect/InstCombine/icmp-add.ll.mlir | 1833 +++++ .../icmp-and-add-sub-xor-p2.ll.mlir | 91 + .../InstCombine/icmp-and-lowbit-mask.ll.mlir | 578 ++ .../InstCombine/icmp-and-shift.ll.mlir | 453 ++ .../icmp-bc-vec-inseltpoison.ll.mlir | 88 + .../InstCombine/icmp-bc-vec.ll.mlir | 88 + .../InstCombine/icmp-binop.ll.mlir | 161 + .../InstCombine/icmp-bitcast-glob.ll.mlir | 23 + .../InstCombine/icmp-constant-phi.ll.mlir | 131 + .../InstCombine/icmp-custom-dl.ll.mlir | 148 + .../InstCombine/icmp-div-constant.ll.mlir | 292 + test/LLVMDialect/InstCombine/icmp-dom.ll.mlir | 263 + .../InstCombine/icmp-equality-rotate.ll.mlir | 81 + .../InstCombine/icmp-equality-xor.ll.mlir | 108 + .../InstCombine/icmp-ext-ext.ll.mlir | 511 +- .../InstCombine/icmp-fold-into-phi.ll.mlir | 40 + test/LLVMDialect/InstCombine/icmp-fsh.ll.mlir | 120 + test/LLVMDialect/InstCombine/icmp-gep.ll.mlir | 0 .../InstCombine/icmp-logical.ll.mlir | 1528 ++++ .../InstCombine/icmp-mul-and.ll.mlir | 245 + .../InstCombine/icmp-mul-zext.ll.mlir | 146 +- test/LLVMDialect/InstCombine/icmp-mul.ll.mlir | 766 +++ .../InstCombine/icmp-ne-pow2.ll.mlir | 311 + .../icmp-not-bool-constant.ll.mlir | 162 + .../InstCombine/icmp-of-and-x.ll.mlir | 168 + .../InstCombine/icmp-of-or-x.ll.mlir | 235 + .../InstCombine/icmp-of-trunc-ext.ll.mlir | 0 .../InstCombine/icmp-of-xor-x.ll.mlir | 258 + test/LLVMDialect/InstCombine/icmp-or.ll.mlir | 547 ++ .../icmp-power2-and-icmp-shifted-mask.ll.mlir | 440 ++ .../InstCombine/icmp-range.ll.mlir | 346 - .../InstCombine/icmp-rotate.ll.mlir | 138 + .../icmp-select-implies-common-op.ll.mlir | 53 + .../InstCombine/icmp-select.ll.mlir | 383 ++ .../InstCombine/icmp-shl-1-overflow.ll.mlir | 117 + .../InstCombine/icmp-shl-nsw.ll.mlir | 218 + .../InstCombine/icmp-shl-nuw.ll.mlir | 140 +- test/LLVMDialect/InstCombine/icmp-shl.ll.mlir | 111 + .../InstCombine/icmp-shr-lt-gt.ll.mlir | 6114 ++++++++--------- test/LLVMDialect/InstCombine/icmp-shr.ll.mlir | 1095 +++ test/LLVMDialect/InstCombine/icmp-sub.ll.mlir | 397 ++ .../InstCombine/icmp-topbitssame.ll.mlir | 292 +- .../InstCombine/icmp-trunc.ll.mlir | 0 .../InstCombine/icmp-uadd-sat.ll.mlir | 146 + ...-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir | 184 + ...-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir | 154 + ...-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir | 76 + ...-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir | 76 + ...-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir | 184 + ...-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir | 154 + .../InstCombine/icmp-usub-sat.ll.mlir | 245 + .../InstCombine/icmp-vec-inseltpoison.ll.mlir | 283 + test/LLVMDialect/InstCombine/icmp-vec.ll.mlir | 0 .../InstCombine/icmp-vscale.ll.mlir | 118 + .../InstCombine/icmp-with-selects.ll.mlir | 77 + .../InstCombine/icmp-xor-signbit.ll.mlir | 200 + test/LLVMDialect/InstCombine/icmp.ll.mlir | 0 .../icmp_sdiv_with_and_without_range.ll.mlir | 39 +- test/LLVMDialect/InstCombine/idioms.ll.mlir | 36 +- test/LLVMDialect/InstCombine/implies.ll.mlir | 229 + .../InstCombine/inbounds-gep.ll.mlir | 58 + .../InstCombine/indexed-gep-compares.ll.mlir | 165 + .../InstCombine/infinite-loop-postdom.ll.mlir | 98 + .../inline-intrinsic-assert.ll.mlir | 37 +- .../inselt-binop-inseltpoison.ll.mlir | 651 ++ .../InstCombine/inselt-binop.ll.mlir | 651 ++ .../insert-const-shuf-inseltpoison.ll.mlir | 154 + .../InstCombine/insert-const-shuf.ll.mlir | 154 + .../InstCombine/insert-ext.ll.mlir | 62 + ...nsert-extract-shuffle-inseltpoison.ll.mlir | 455 ++ .../insert-extract-shuffle.ll.mlir | 498 ++ .../InstCombine/insert-trunc.ll.mlir | 312 + .../insert-val-extract-elem.ll.mlir | 64 + .../InstCombine/insertelement-bitcast.ll.mlir | 49 + .../InstCombine/insertelement.ll.mlir | 48 + .../InstCombine/insertelt-trunc.ll.mlir | 214 + .../InstCombine/int_sideeffect.ll.mlir | 13 - .../integer-round-up-pow2-alignment.ll.mlir | 457 ++ .../InstCombine/intersect-accessgroup.ll.mlir | 86 +- test/LLVMDialect/InstCombine/intptr1.ll.mlir | 111 + test/LLVMDialect/InstCombine/intptr2.ll.mlir | 23 + test/LLVMDialect/InstCombine/intptr3.ll.mlir | 23 + test/LLVMDialect/InstCombine/intptr4.ll.mlir | 28 + test/LLVMDialect/InstCombine/intptr5.ll.mlir | 30 + test/LLVMDialect/InstCombine/intptr6.ll.mlir | 54 + test/LLVMDialect/InstCombine/intptr7.ll.mlir | 95 +- test/LLVMDialect/InstCombine/intptr8.ll.mlir | 0 .../InstCombine/intrinsic-select.ll.mlir | 224 + .../InstCombine/intrinsics.ll.mlir | 0 .../InstCombine/invariant.group.ll.mlir | 0 .../LLVMDialect/InstCombine/invariant.ll.mlir | 54 +- ...riable-mask-in-masked-merge-scalar.ll.mlir | 362 +- ...riable-mask-in-masked-merge-vector.ll.mlir | 305 + test/LLVMDialect/InstCombine/invoke.ll.mlir | 0 .../InstCombine/is_fpclass.ll.mlir | 1912 ++++++ .../LLVMDialect/InstCombine/isascii-1.ll.mlir | 37 +- .../InstCombine/isascii-i16.ll.mlir | 70 +- .../LLVMDialect/InstCombine/isdigit-1.ll.mlir | 57 +- .../InstCombine/isdigit-i16.ll.mlir | 94 +- test/LLVMDialect/InstCombine/ispow2.ll.mlir | 951 +++ .../InstCombine/kcfi-operand-bundles.ll.mlir | 12 + .../InstCombine/known-bits.ll.mlir | 44 - .../known-fpclass-reduce-signbit.ll.mlir | 65 + .../InstCombine/known-never-nan.ll.mlir | 106 + .../InstCombine/known-non-zero.ll.mlir | 145 + .../InstCombine/known-phi-br.ll.mlir | 164 +- .../InstCombine/known-phi-recurse.ll.mlir | 67 + .../InstCombine/known-signbit-shift.ll.mlir | 37 + .../InstCombine/known_align.ll.mlir | 51 + .../LLVMDialect/InstCombine/ldexp-ext.ll.mlir | 0 test/LLVMDialect/InstCombine/ldexp.ll.mlir | 0 .../InstCombine/lifetime-no-null-opt.ll.mlir | 47 + .../InstCombine/lifetime-sanitizer.ll.mlir | 80 +- test/LLVMDialect/InstCombine/lifetime.ll.mlir | 47 + .../InstCombine/load-bitcast-select.ll.mlir | 52 + .../InstCombine/load-bitcast-vec.ll.mlir | 125 +- .../InstCombine/load-bitcast32.ll.mlir | 77 +- .../InstCombine/load-bitcast64.ll.mlir | 77 +- test/LLVMDialect/InstCombine/load-cmp.ll.mlir | 621 ++ .../load-combine-metadata-2.ll.mlir | 22 +- .../load-combine-metadata-3.ll.mlir | 22 +- .../load-combine-metadata-4.ll.mlir | 22 +- .../load-combine-metadata-dominance.ll.mlir | 88 +- .../InstCombine/load-combine-metadata.ll.mlir | 26 +- .../InstCombine/load-gep-overalign.ll.mlir | 41 + .../InstCombine/load-no-aliasing.ll.mlir | 26 +- .../InstCombine/load-select.ll.mlir | 14 + .../InstCombine/load-store-forward.ll.mlir | 316 + .../load-store-masked-constant-array.ll.mlir | 0 test/LLVMDialect/InstCombine/load.ll.mlir | 0 test/LLVMDialect/InstCombine/load3.ll.mlir | 34 + .../InstCombine/load_combine_aa.ll.mlir | 24 +- .../InstCombine/loadstore-alignment.ll.mlir | 148 +- .../InstCombine/loadstore-metadata.ll.mlir | 145 +- .../InstCombine/log-pow-nofastmath.ll.mlir | 35 +- test/LLVMDialect/InstCombine/log-pow.ll.mlir | 192 +- .../logical-select-inseltpoison.ll.mlir | 422 ++ .../InstCombine/logical-select.ll.mlir | 0 .../InstCombine/low-bit-splat.ll.mlir | 121 + .../InstCombine/lower-dbg-declare.ll.mlir | 48 + .../lshr-and-negC-icmpeq-zero.ll.mlir | 206 + .../lshr-and-signbit-icmpeq-zero.ll.mlir | 179 + test/LLVMDialect/InstCombine/lshr-phi.ll.mlir | 58 +- .../lshr-trunc-sext-to-ashr-sext.ll.mlir | 169 + test/LLVMDialect/InstCombine/lshr.ll.mlir | 858 +++ .../InstCombine/malloc-free-addrspace.ll.mlir | 53 + .../malloc-free-delete-dbginvar.ll.mlir | 13 + .../malloc-free-mismatched.ll.mlir | 17 + .../InstCombine/malloc-free.ll.mlir | 0 .../malloc_free_delete_nvptx.ll.mlir | 20 + .../InstCombine/masked-merge-add.ll.mlir | 266 + .../masked-merge-and-of-ors.ll.mlir | 286 + .../InstCombine/masked-merge-or.ll.mlir | 266 + .../InstCombine/masked-merge-xor.ll.mlir | 266 + .../masked_intrinsics-inseltpoison.ll.mlir | 230 + .../InstCombine/masked_intrinsics.ll.mlir | 359 + .../masked_intrinsics_keep_metadata.ll.mlir | 29 + .../InstCombine/math-odd-even-parity.ll.mlir | 24 + .../matrix-multiplication-negation.ll.mlir | 216 + .../InstCombine/max-of-nots.ll.mlir | 326 + .../InstCombine/max_known_bits.ll.mlir | 105 + test/LLVMDialect/InstCombine/maximum.ll.mlir | 270 + test/LLVMDialect/InstCombine/maxnum.ll.mlir | 280 + .../mem-deref-bytes-addrspaces.ll.mlir | 28 +- .../InstCombine/mem-deref-bytes.ll.mlir | 214 +- .../InstCombine/mem-gep-zidx.ll.mlir | 0 .../mem-par-metadata-memcpy.ll.mlir | 44 +- test/LLVMDialect/InstCombine/memccpy.ll.mlir | 484 +- .../LLVMDialect/InstCombine/memchr-10.ll.mlir | 62 + .../LLVMDialect/InstCombine/memchr-11.ll.mlir | 52 + test/LLVMDialect/InstCombine/memchr-2.ll.mlir | 165 +- test/LLVMDialect/InstCombine/memchr-3.ll.mlir | 80 +- test/LLVMDialect/InstCombine/memchr-4.ll.mlir | 79 +- test/LLVMDialect/InstCombine/memchr-5.ll.mlir | 232 +- test/LLVMDialect/InstCombine/memchr-6.ll.mlir | 61 + test/LLVMDialect/InstCombine/memchr-7.ll.mlir | 100 + test/LLVMDialect/InstCombine/memchr-8.ll.mlir | 0 test/LLVMDialect/InstCombine/memchr-9.ll.mlir | 199 + test/LLVMDialect/InstCombine/memchr.ll.mlir | 199 + test/LLVMDialect/InstCombine/memcmp-1.ll.mlir | 199 +- test/LLVMDialect/InstCombine/memcmp-2.ll.mlir | 17 +- test/LLVMDialect/InstCombine/memcmp-3.ll.mlir | 174 +- test/LLVMDialect/InstCombine/memcmp-4.ll.mlir | 85 +- test/LLVMDialect/InstCombine/memcmp-5.ll.mlir | 281 +- test/LLVMDialect/InstCombine/memcmp-6.ll.mlir | 126 +- test/LLVMDialect/InstCombine/memcmp-7.ll.mlir | 102 + test/LLVMDialect/InstCombine/memcmp-8.ll.mlir | 73 +- .../InstCombine/memcmp-constant-fold.ll.mlir | 101 +- test/LLVMDialect/InstCombine/memcpy-1.ll.mlir | 58 +- test/LLVMDialect/InstCombine/memcpy-2.ll.mlir | 17 +- .../InstCombine/memcpy-addrspace.ll.mlir | 117 - .../InstCombine/memcpy-from-global.ll.mlir | 453 ++ .../InstCombine/memcpy-to-load.ll.mlir | 100 +- test/LLVMDialect/InstCombine/memcpy.ll.mlir | 63 +- .../InstCombine/memcpy_alloca.ll.mlir | 126 +- .../InstCombine/memcpy_chk-1.ll.mlir | 175 + .../InstCombine/memcpy_chk-2.ll.mlir | 44 + .../LLVMDialect/InstCombine/memmove-1.ll.mlir | 44 +- .../LLVMDialect/InstCombine/memmove-2.ll.mlir | 17 +- test/LLVMDialect/InstCombine/memmove.ll.mlir | 115 +- .../InstCombine/memmove_chk-1.ll.mlir | 160 + .../InstCombine/memmove_chk-2.ll.mlir | 44 + test/LLVMDialect/InstCombine/mempcpy.ll.mlir | 82 +- .../LLVMDialect/InstCombine/memrchr-2.ll.mlir | 95 +- .../LLVMDialect/InstCombine/memrchr-3.ll.mlir | 434 +- .../LLVMDialect/InstCombine/memrchr-4.ll.mlir | 106 +- .../LLVMDialect/InstCombine/memrchr-5.ll.mlir | 316 +- .../LLVMDialect/InstCombine/memrchr-7.ll.mlir | 62 + .../LLVMDialect/InstCombine/memrchr-8.ll.mlir | 36 + test/LLVMDialect/InstCombine/memrchr.ll.mlir | 59 +- test/LLVMDialect/InstCombine/memset-1.ll.mlir | 117 + test/LLVMDialect/InstCombine/memset-2.ll.mlir | 17 +- test/LLVMDialect/InstCombine/memset.ll.mlir | 113 +- test/LLVMDialect/InstCombine/memset2.ll.mlir | 29 +- .../InstCombine/memset_chk-1.ll.mlir | 0 .../InstCombine/memset_chk-2.ll.mlir | 28 + .../InstCombine/merge-icmp.ll.mlir | 248 + ...ing-multiple-stores-into-successor.ll.mlir | 194 + .../InstCombine/min-positive.ll.mlir | 89 + test/LLVMDialect/InstCombine/minimum.ll.mlir | 288 + .../InstCombine/minmax-demandbits.ll.mlir | 160 + .../InstCombine/minmax-fold.ll.mlir | 929 +++ .../LLVMDialect/InstCombine/minmax-fp.ll.mlir | 250 + .../InstCombine/minmax-intrinsics.ll.mlir | 1518 ++++ .../InstCombine/minmax-of-minmax.ll.mlir | 182 + .../InstCombine/minmax-of-xor-x.ll.mlir | 101 + test/LLVMDialect/InstCombine/minnum.ll.mlir | 290 + .../LLVMDialect/InstCombine/misc-2002.ll.mlir | 61 +- test/LLVMDialect/InstCombine/modulo.ll.mlir | 107 + .../InstCombine/mul-inseltpoison.ll.mlir | 0 .../InstCombine/mul-masked-bits.ll.mlir | 0 .../InstCombine/mul-min-max.ll.mlir | 38 + test/LLVMDialect/InstCombine/mul-pow2.ll.mlir | 83 + test/LLVMDialect/InstCombine/mul.ll.mlir | 0 test/LLVMDialect/InstCombine/mul_fold.ll.mlir | 515 ++ .../InstCombine/mul_full_32.ll.mlir | 56 + .../InstCombine/mul_full_64.ll.mlir | 343 + .../multi-size-address-space-pointer.ll.mlir | 73 + .../InstCombine/multi-use-load-casts.ll.mlir | 63 + .../InstCombine/multi-use-or.ll.mlir | 38 +- .../multiple-uses-load-bitcast-select.ll.mlir | 15 + .../InstCombine/musttail-thunk.ll.mlir | 18 + .../InstCombine/narrow-math.ll.mlir | 751 +- .../InstCombine/narrow-switch.ll.mlir | 175 + test/LLVMDialect/InstCombine/narrow.ll.mlir | 110 + .../InstCombine/neg-alloca.ll.mlir | 28 +- .../InstCombine/negated-bitmask.ll.mlir | 208 + .../InstCombine/nested-select.ll.mlir | 355 + .../InstCombine/new-delete-itanium-32.ll.mlir | 105 +- .../InstCombine/new-delete-itanium.ll.mlir | 0 .../InstCombine/new-delete-msvc.ll.mlir | 23 +- .../InstCombine/no-negzero.ll.mlir | 52 +- .../InstCombine/no-unwind-inline-asm.ll.mlir | 0 .../InstCombine/no_cgscc_assert.ll.mlir | 19 +- .../InstCombine/no_sink_instruction.ll.mlir | 20 +- .../InstCombine/noalias-scope-decl.ll.mlir | 105 + .../InstCombine/non-integral-pointers.ll.mlir | 113 +- .../InstCombine/nonnull-attribute.ll.mlir | 13 + .../InstCombine/nonnull-select.ll.mlir | 54 + test/LLVMDialect/InstCombine/not-add.ll.mlir | 162 + test/LLVMDialect/InstCombine/not.ll.mlir | 652 ++ test/LLVMDialect/InstCombine/nothrow.ll.mlir | 18 +- .../InstCombine/nsw-inseltpoison.ll.mlir | 0 test/LLVMDialect/InstCombine/nsw.ll.mlir | 0 .../InstCombine/obfuscated_splat.ll.mlir | 20 + .../InstCombine/object-size-opaque.ll.mlir | 13 - .../InstCombine/objsize-64.ll.mlir | 0 .../InstCombine/objsize-address-space.ll.mlir | 0 test/LLVMDialect/InstCombine/objsize.ll.mlir | 0 .../InstCombine/odr-linkage.ll.mlir | 49 +- ...o-or-zero-when-comparing-with-zero.ll.mlir | 146 + .../InstCombine/onehot_merge.ll.mlir | 730 ++ .../InstCombine/opaque-ptr.ll.mlir | 0 test/LLVMDialect/InstCombine/opaque.ll.mlir | 37 +- .../InstCombine/operand-complexity.ll.mlir | 114 + .../opts-tuples-extract-intrinsic.ll.mlir | 48 +- .../LLVMDialect/InstCombine/or-concat.ll.mlir | 313 +- test/LLVMDialect/InstCombine/or-fcmp.ll.mlir | 2920 ++++++++ .../InstCombine/or-shifted-masks.ll.mlir | 397 +- .../InstCombine/or-xor-xor.ll.mlir | 75 + test/LLVMDialect/InstCombine/or-xor.ll.mlir | 860 +++ test/LLVMDialect/InstCombine/or.ll.mlir | 1293 ++++ .../InstCombine/oss_fuzz_32759.ll.mlir | 36 +- .../LLVMDialect/InstCombine/osx-names.ll.mlir | 42 +- .../InstCombine/out-of-bounds-indexes.ll.mlir | 28 + ...t-of-tree-allocator-optimizes-away.ll.mlir | 18 + .../InstCombine/overflow-mul.ll.mlir | 176 + test/LLVMDialect/InstCombine/overflow.ll.mlir | 81 + .../InstCombine/overflow_to_sat.ll.mlir | 498 ++ ...masking-after-truncation-variant-a.ll.mlir | 220 + ...masking-after-truncation-variant-b.ll.mlir | 216 + ...masking-after-truncation-variant-c.ll.mlir | 186 + ...masking-after-truncation-variant-d.ll.mlir | 212 + ...masking-after-truncation-variant-e.ll.mlir | 143 + ...left-shift-input-masking-variant-a.ll.mlir | 138 + ...left-shift-input-masking-variant-b.ll.mlir | 116 + ...left-shift-input-masking-variant-c.ll.mlir | 74 + ...left-shift-input-masking-variant-d.ll.mlir | 84 + ...left-shift-input-masking-variant-e.ll.mlir | 73 + ...phi-aware-aggregate-reconstruction.ll.mlir | 232 + test/LLVMDialect/InstCombine/phi-cse.ll.mlir | 177 +- .../phi-equal-incoming-pointers.ll.mlir | 271 + .../InstCombine/phi-extractvalue.ll.mlir | 248 + .../InstCombine/phi-int2ptr-fold.ll.mlir | 128 +- .../phi-known-bits-operand-order.ll.mlir | 68 +- .../InstCombine/phi-load-metadata-2.ll.mlir | 34 +- .../InstCombine/phi-load-metadata-3.ll.mlir | 34 +- .../InstCombine/phi-load-metadata-4.ll.mlir | 30 + .../phi-load-metadata-dominance.ll.mlir | 34 +- .../InstCombine/phi-load-metadata.ll.mlir | 34 +- .../InstCombine/phi-merge-gep.ll.mlir | 84 + .../InstCombine/phi-of-insertvalues.ll.mlir | 133 + .../InstCombine/phi-pointercasts.ll.mlir | 200 + .../InstCombine/phi-preserve-ir-flags.ll.mlir | 77 +- .../InstCombine/phi-select-constant.ll.mlir | 100 + .../InstCombine/phi-shifts.ll.mlir | 30 +- .../InstCombine/phi-timeout.ll.mlir | 41 +- test/LLVMDialect/InstCombine/phi.ll.mlir | 0 test/LLVMDialect/InstCombine/pow-0.ll.mlir | 44 + test/LLVMDialect/InstCombine/pow-1.ll.mlir | 363 + test/LLVMDialect/InstCombine/pow-2.ll.mlir | 19 +- test/LLVMDialect/InstCombine/pow-3.ll.mlir | 62 +- test/LLVMDialect/InstCombine/pow-4.ll.mlir | 220 +- test/LLVMDialect/InstCombine/pow-cbrt.ll.mlir | 147 +- .../InstCombine/pow-exp-nofastmath.ll.mlir | 21 +- test/LLVMDialect/InstCombine/pow-exp.ll.mlir | 567 +- test/LLVMDialect/InstCombine/pow-sqrt.ll.mlir | 331 +- .../InstCombine/pow-to-ldexp.ll.mlir | 0 .../InstCombine/pow-to-sqrt.ll.mlir | 8 + .../InstCombine/pow_fp_int.ll.mlir | 542 +- .../InstCombine/pow_fp_int16.ll.mlir | 506 +- test/LLVMDialect/InstCombine/powi.ll.mlir | 265 + test/LLVMDialect/InstCombine/pr12251.ll.mlir | 22 +- test/LLVMDialect/InstCombine/pr12338.ll.mlir | 17 + test/LLVMDialect/InstCombine/pr14365.ll.mlir | 93 +- test/LLVMDialect/InstCombine/pr17827.ll.mlir | 173 +- test/LLVMDialect/InstCombine/pr20678.ll.mlir | 11 + test/LLVMDialect/InstCombine/pr21199.ll.mlir | 19 + test/LLVMDialect/InstCombine/pr21210.ll.mlir | 38 + test/LLVMDialect/InstCombine/pr21651.ll.mlir | 11 + test/LLVMDialect/InstCombine/pr21891.ll.mlir | 32 +- test/LLVMDialect/InstCombine/pr23751.ll.mlir | 30 +- test/LLVMDialect/InstCombine/pr23809.ll.mlir | 16 + test/LLVMDialect/InstCombine/pr24354.ll.mlir | 35 + test/LLVMDialect/InstCombine/pr24605.ll.mlir | 24 +- test/LLVMDialect/InstCombine/pr25342.ll.mlir | 78 + test/LLVMDialect/InstCombine/pr25745.ll.mlir | 15 + .../InstCombine/pr2645-0-inseltpoison.ll.mlir | 30 + test/LLVMDialect/InstCombine/pr2645-0.ll.mlir | 29 + test/LLVMDialect/InstCombine/pr26992.ll.mlir | 0 test/LLVMDialect/InstCombine/pr26993.ll.mlir | 31 +- test/LLVMDialect/InstCombine/pr27236.ll.mlir | 13 + test/LLVMDialect/InstCombine/pr27332.ll.mlir | 16 + test/LLVMDialect/InstCombine/pr27343.ll.mlir | 45 +- test/LLVMDialect/InstCombine/pr27703.ll.mlir | 27 +- test/LLVMDialect/InstCombine/pr27996.ll.mlir | 84 +- test/LLVMDialect/InstCombine/pr28143.ll.mlir | 16 +- test/LLVMDialect/InstCombine/pr28725.ll.mlir | 27 + test/LLVMDialect/InstCombine/pr2996.ll.mlir | 12 + test/LLVMDialect/InstCombine/pr30929.ll.mlir | 18 +- .../InstCombine/pr31990_wrong_memcpy.ll.mlir | 38 +- test/LLVMDialect/InstCombine/pr32686.ll.mlir | 21 + test/LLVMDialect/InstCombine/pr33453.ll.mlir | 17 + .../InstCombine/pr33689_same_bitwidth.ll.mlir | 29 + test/LLVMDialect/InstCombine/pr34349.ll.mlir | 36 +- test/LLVMDialect/InstCombine/pr34627.ll.mlir | 21 +- test/LLVMDialect/InstCombine/pr35515.ll.mlir | 33 + test/LLVMDialect/InstCombine/pr36362.ll.mlir | 10 + test/LLVMDialect/InstCombine/pr38677.ll.mlir | 24 + test/LLVMDialect/InstCombine/pr38897.ll.mlir | 17 + test/LLVMDialect/InstCombine/pr38915.ll.mlir | 15 + .../InstCombine/pr38984-inseltpoison.ll.mlir | 32 + test/LLVMDialect/InstCombine/pr38984.ll.mlir | 32 + test/LLVMDialect/InstCombine/pr39177.ll.mlir | 30 + test/LLVMDialect/InstCombine/pr39908.ll.mlir | 29 + test/LLVMDialect/InstCombine/pr41164.ll.mlir | 52 +- test/LLVMDialect/InstCombine/pr43081.ll.mlir | 27 +- ...ictnessPredicateAndConstant-assert.ll.mlir | 38 +- test/LLVMDialect/InstCombine/pr43893.ll.mlir | 37 + test/LLVMDialect/InstCombine/pr44242.ll.mlir | 91 + test/LLVMDialect/InstCombine/pr44245.ll.mlir | 121 +- test/LLVMDialect/InstCombine/pr44541.ll.mlir | 13 + test/LLVMDialect/InstCombine/pr44552.ll.mlir | 64 + test/LLVMDialect/InstCombine/pr44835.ll.mlir | 11 + test/LLVMDialect/InstCombine/pr46680.ll.mlir | 104 +- test/LLVMDialect/InstCombine/pr49688.ll.mlir | 23 + test/LLVMDialect/InstCombine/pr51824.ll.mlir | 45 + test/LLVMDialect/InstCombine/pr53357.ll.mlir | 73 + test/LLVMDialect/InstCombine/pr55228.ll.mlir | 22 + test/LLVMDialect/InstCombine/pr56424.ll.mlir | 28 +- test/LLVMDialect/InstCombine/pr58901.ll.mlir | 15 + test/LLVMDialect/InstCombine/pr59613.ll.mlir | 30 + test/LLVMDialect/InstCombine/pr63791.ll.mlir | 42 + test/LLVMDialect/InstCombine/pr69059.ll.mlir | 8 + test/LLVMDialect/InstCombine/pr71330.ll.mlir | 50 + test/LLVMDialect/InstCombine/pr72433.ll.mlir | 17 + test/LLVMDialect/InstCombine/pr75129.ll.mlir | 14 + test/LLVMDialect/InstCombine/pr75369.ll.mlir | 28 + test/LLVMDialect/InstCombine/pr77064.ll.mlir | 12 + test/LLVMDialect/InstCombine/pr80597.ll.mlir | 22 + test/LLVMDialect/InstCombine/pr80941.ll.mlir | 14 + test/LLVMDialect/InstCombine/pr82877.ll.mlir | 19 + test/LLVMDialect/InstCombine/pr83931.ll.mlir | 0 test/LLVMDialect/InstCombine/pr83947.ll.mlir | 129 + .../InstCombine/prefetch-load.ll.mlir | 41 +- .../InstCombine/preserve-sminmax.ll.mlir | 18 + .../InstCombine/preserved-analyses.ll.mlir | 20 +- .../InstCombine/prevent-cmp-merge.ll.mlir | 49 + test/LLVMDialect/InstCombine/printf-1.ll.mlir | 82 + test/LLVMDialect/InstCombine/printf-2.ll.mlir | 71 + test/LLVMDialect/InstCombine/printf-3.ll.mlir | 0 .../InstCombine/printf-i16.ll.mlir | 100 +- .../InstCombine/ptr-int-cast.ll.mlir | 79 +- .../InstCombine/ptr-int-ptr-icmp.ll.mlir | 0 .../InstCombine/ptr-replace-alloca.ll.mlir | 301 + .../InstCombine/ptrauth-intrinsics.ll.mlir | 0 test/LLVMDialect/InstCombine/ptrmask.ll.mlir | 0 .../InstCombine/ptrtoint-nullgep.ll.mlir | 465 +- .../pull-binop-through-shift.ll.mlir | 365 +- ...ll-conditional-binop-through-shift.ll.mlir | 194 + test/LLVMDialect/InstCombine/puts-1.ll.mlir | 18 + test/LLVMDialect/InstCombine/puts-i16.ll.mlir | 12 + .../InstCombine/range-check.ll.mlir | 245 + .../InstCombine/readnone-maythrow.ll.mlir | 46 +- .../InstCombine/realloc-free.ll.mlir | 10 + test/LLVMDialect/InstCombine/realloc.ll.mlir | 15 + .../InstCombine/reassociate-nuw.ll.mlir | 235 +- .../InstCombine/recurrence.ll.mlir | 120 +- .../reduction-add-sext-zext-i1.ll.mlir | 46 + .../reduction-and-sext-zext-i1.ll.mlir | 78 + .../reduction-mul-sext-zext-i1.ll.mlir | 46 + .../reduction-or-sext-zext-i1.ll.mlir | 78 + .../reduction-shufflevector.ll.mlir | 144 + .../reduction-smax-sext-zext-i1.ll.mlir | 46 + .../reduction-smin-sext-zext-i1.ll.mlir | 46 + .../reduction-umax-sext-zext-i1.ll.mlir | 46 + .../reduction-umin-sext-zext-i1.ll.mlir | 46 + .../reduction-xor-sext-zext-i1.ll.mlir | 46 + ...masking-after-truncation-variant-a.ll.mlir | 155 + ...masking-after-truncation-variant-b.ll.mlir | 154 + ...masking-after-truncation-variant-c.ll.mlir | 160 + ...masking-after-truncation-variant-d.ll.mlir | 170 + ...masking-after-truncation-variant-e.ll.mlir | 119 + ...masking-after-truncation-variant-f.ll.mlir | 132 + ...t-left-shift-input-masking-pr49778.ll.mlir | 24 +- ...left-shift-input-masking-variant-a.ll.mlir | 265 + ...left-shift-input-masking-variant-b.ll.mlir | 232 + ...left-shift-input-masking-variant-c.ll.mlir | 156 + ...left-shift-input-masking-variant-d.ll.mlir | 195 + ...left-shift-input-masking-variant-e.ll.mlir | 114 + ...left-shift-input-masking-variant-f.ll.mlir | 124 + ...edundant-right-shift-input-masking.ll.mlir | 129 + .../InstCombine/rem-mul-shl.ll.mlir | 0 test/LLVMDialect/InstCombine/rem.ll.mlir | 611 ++ .../remove-loop-phi-multiply-by-zero.ll.mlir | 204 + ...ative-is-non-zero-and-no-underflow.ll.mlir | 261 + ...-zero-is-non-zero-and-no-underflow.ll.mlir | 183 + ...f-usub-is-non-zero-and-no-overflow.ll.mlir | 461 ++ ...reuse-constant-from-select-in-icmp.ll.mlir | 237 + test/LLVMDialect/InstCombine/rotate.ll.mlir | 712 ++ .../InstCombine/sadd-with-overflow.ll.mlir | 105 + test/LLVMDialect/InstCombine/sadd_sat.ll.mlir | 555 ++ test/LLVMDialect/InstCombine/saddo.ll.mlir | 55 + .../InstCombine/salvage-dbg-declare.ll.mlir | 19 + .../InstCombine/saturating-add-sub.ll.mlir | 1324 ++++ .../scalable-bitcast-inseltpoison.ll.mlir | 9 + .../InstCombine/scalable-bitcast.ll.mlir | 9 + .../scalable-cast-of-alloc.ll.mlir | 186 + .../scalable-const-fp-splat.ll.mlir | 14 + .../InstCombine/scalable-select.ll.mlir | 0 .../InstCombine/scalable-trunc.ll.mlir | 19 - .../InstCombine/scalable-vector-array.ll.mlir | 14 + .../scalable-vector-struct.ll.mlir | 14 + .../scalarization-inseltpoison.ll.mlir | 220 + .../InstCombine/scalarization.ll.mlir | 241 + test/LLVMDialect/InstCombine/scmp.ll.mlir | 0 test/LLVMDialect/InstCombine/sdiv-1.ll.mlir | 48 +- test/LLVMDialect/InstCombine/sdiv-2.ll.mlir | 26 + .../InstCombine/sdiv-canonicalize.ll.mlir | 74 + ...div-exact-by-negative-power-of-two.ll.mlir | 72 + .../sdiv-exact-by-power-of-two.ll.mlir | 96 + .../InstCombine/sdiv-guard.ll.mlir | 0 .../LLVMDialect/InstCombine/sdiv-icmp.ll.mlir | 66 + ...-negative-by-negative-power-of-two.ll.mlir | 58 +- test/LLVMDialect/InstCombine/select-2.ll.mlir | 67 + .../InstCombine/select-and-or.ll.mlir | 739 ++ .../InstCombine/select-binop-cmp.ll.mlir | 795 +++ ...lect-binop-foldable-floating-point.ll.mlir | 127 + .../select-bitext-bitwise-ops.ll.mlir | 74 + .../InstCombine/select-bitext.ll.mlir | 362 + .../InstCombine/select-cmp-br.ll.mlir | 118 + .../InstCombine/select-cmp-cttz-ctlz.ll.mlir | 0 .../InstCombine/select-cmp-eq-op-fold.ll.mlir | 95 + .../InstCombine/select-cmp.ll.mlir | 246 + .../InstCombine/select-cmpxchg.ll.mlir | 24 + .../InstCombine/select-crash.ll.mlir | 26 + .../InstCombine/select-ctlz-to-cttz.ll.mlir | 222 + .../InstCombine/select-divrem.ll.mlir | 201 + ...select-extractelement-inseltpoison.ll.mlir | 124 + .../InstCombine/select-extractelement.ll.mlir | 150 + .../InstCombine/select-factorize.ll.mlir | 605 ++ .../InstCombine/select-gep.ll.mlir | 0 .../select-icmp-and-zero-shl.ll.mlir | 129 + .../InstCombine/select-icmp-and.ll.mlir | 435 ++ .../InstCombine/select-imm-canon.ll.mlir | 79 + .../InstCombine/select-load-call.ll.mlir | 13 + .../InstCombine/select-masked_gather.ll.mlir | 0 .../InstCombine/select-masked_load.ll.mlir | 91 + .../InstCombine/select-min-max.ll.mlir | 182 + .../InstCombine/select-obo-peo-ops.ll.mlir | 786 +++ .../InstCombine/select-of-bittest.ll.mlir | 504 ++ .../InstCombine/select-pr39595.ll.mlir | 10 + .../select-safe-bool-transforms.ll.mlir | 328 + ...select-safe-impliedcond-transforms.ll.mlir | 129 + .../select-safe-transforms.ll.mlir | 563 ++ .../InstCombine/select-select.ll.mlir | 367 + .../select-with-bitwise-ops.ll.mlir | 1143 +++ test/LLVMDialect/InstCombine/select.ll.mlir | 0 .../InstCombine/select_arithmetic.ll.mlir | 97 + .../InstCombine/select_meta.ll.mlir | 231 + .../set-lowbits-mask-canonicalize.ll.mlir | 207 + test/LLVMDialect/InstCombine/set.ll.mlir | 358 + .../InstCombine/setcc-strength-reduce.ll.mlir | 60 +- .../InstCombine/sext-of-trunc-nsw.ll.mlir | 274 +- test/LLVMDialect/InstCombine/sext.ll.mlir | 253 + .../shift-add-inseltpoison.ll.mlir | 90 + .../LLVMDialect/InstCombine/shift-add.ll.mlir | 511 ++ ...on-in-bittest-with-truncation-lshr.ll.mlir | 333 + ...ion-in-bittest-with-truncation-shl.ll.mlir | 259 + ...ft-amount-reassociation-in-bittest.ll.mlir | 516 ++ ...reassociation-with-truncation-ashr.ll.mlir | 149 + ...reassociation-with-truncation-lshr.ll.mlir | 149 + ...-reassociation-with-truncation-shl.ll.mlir | 197 + .../shift-amount-reassociation.ll.mlir | 255 + .../InstCombine/shift-by-signext.ll.mlir | 175 +- .../InstCombine/shift-cttz-ctlz.ll.mlir | 34 + .../shift-direction-in-bit-test.ll.mlir | 149 + .../InstCombine/shift-flags.ll.mlir | 74 + .../InstCombine/shift-logic.ll.mlir | 424 ++ .../InstCombine/shift-shift.ll.mlir | 484 ++ .../LLVMDialect/InstCombine/shift-sra.ll.mlir | 220 +- test/LLVMDialect/InstCombine/shift.ll.mlir | 0 .../shl-and-negC-icmpeq-zero.ll.mlir | 180 + .../shl-and-signbit-icmpeq-zero.ll.mlir | 180 + test/LLVMDialect/InstCombine/shl-bo.ll.mlir | 444 ++ .../InstCombine/shl-demand.ll.mlir | 209 +- .../InstCombine/shl-factor.ll.mlir | 284 +- test/LLVMDialect/InstCombine/shl-sub.ll.mlir | 169 + .../shl-unsigned-cmp-const.ll.mlir | 175 + .../InstCombine/should-change-type.ll.mlir | 65 +- .../InstCombine/shuffle-binop.ll.mlir | 0 .../InstCombine/shuffle-cast-dist.ll.mlir | 70 + .../shuffle-cast-inseltpoison.ll.mlir | 54 + .../InstCombine/shuffle-cast.ll.mlir | 54 + ...shuffle-select-narrow-inseltpoison.ll.mlir | 83 + .../InstCombine/shuffle-select-narrow.ll.mlir | 83 + .../shuffle_select-inseltpoison.ll.mlir | 895 +++ .../InstCombine/shuffle_select.ll.mlir | 1066 +++ .../shufflevec-bitcast-inseltpoison.ll.mlir | 94 + .../InstCombine/shufflevec-bitcast.ll.mlir | 136 + .../shufflevec-constant-inseltpoison.ll.mlir | 16 + .../InstCombine/shufflevec-constant.ll.mlir | 0 ...shufflevector-div-rem-inseltpoison.ll.mlir | 99 + .../InstCombine/shufflevector-div-rem.ll.mlir | 99 + .../shufflevector_freezepoison.ll.mlir | 59 + ...-via-right-shifting-all-other-bits.ll.mlir | 448 +- .../InstCombine/sign-test-and-or.ll.mlir | 254 + .../signbit-lshr-and-icmpeq-zero.ll.mlir | 182 + .../signbit-shl-and-icmpeq-zero.ll.mlir | 182 + .../InstCombine/signed-comparison.ll.mlir | 31 +- ...ack-of-overflow-check-via-mul-sdiv.ll.mlir | 168 +- ...ed-mul-overflow-check-via-mul-sdiv.ll.mlir | 168 +- .../signed-truncation-check.ll.mlir | 792 +++ test/LLVMDialect/InstCombine/signext.ll.mlir | 277 +- ...signmask-of-sext-vs-of-shl-of-zext.ll.mlir | 140 + .../InstCombine/simple_phi_condition.ll.mlir | 306 + .../simplify-demanded-bits-pointer.ll.mlir | 54 + .../simplify-demanded-fpclass.ll.mlir | 0 .../simplify-libcalls-erased.ll.mlir | 12 + .../InstCombine/simplify-libcalls-i16.ll.mlir | 173 + .../simplify-libcalls-inreg.ll.mlir | 39 + .../InstCombine/simplify-libcalls-new.ll.mlir | 211 + .../InstCombine/simplify-libcalls.ll.mlir | 171 + test/LLVMDialect/InstCombine/sincospi.ll.mlir | 120 +- .../InstCombine/sink-alloca.ll.mlir | 46 +- ...ntroduces-unnecessary-poison-value.ll.mlir | 38 + .../InstCombine/sink-into-catchswitch.ll.mlir | 0 .../InstCombine/sink-into-ncd.ll.mlir | 40 + .../sink-into-resume-block.ll.mlir | 29 + .../InstCombine/sink-not-into-and.ll.mlir | 110 + .../sink-not-into-another-hand-of-and.ll.mlir | 58 + ...t-into-another-hand-of-logical-and.ll.mlir | 84 + ...ot-into-another-hand-of-logical-or.ll.mlir | 76 + .../sink-not-into-another-hand-of-or.ll.mlir | 58 + .../sink-not-into-logical-and.ll.mlir | 135 + .../sink-not-into-logical-or.ll.mlir | 110 + .../InstCombine/sink-not-into-or.ll.mlir | 110 + .../InstCombine/sink_instruction.ll.mlir | 112 + .../sink_sideeffecting_instruction.ll.mlir | 217 + .../InstCombine/sink_to_unreachable.ll.mlir | 0 test/LLVMDialect/InstCombine/sitofp.ll.mlir | 208 + .../LLVMDialect/InstCombine/smax-icmp.ll.mlir | 426 ++ .../LLVMDialect/InstCombine/smin-icmp.ll.mlir | 665 ++ test/LLVMDialect/InstCombine/smulo.ll.mlir | 101 + .../InstCombine/snprintf-2.ll.mlir | 78 + .../InstCombine/snprintf-3.ll.mlir | 83 + .../InstCombine/snprintf-4.ll.mlir | 85 + test/LLVMDialect/InstCombine/snprintf.ll.mlir | 146 + .../LLVMDialect/InstCombine/sprintf-1.ll.mlir | 87 + .../LLVMDialect/InstCombine/sprintf-2.ll.mlir | 94 + .../LLVMDialect/InstCombine/sprintf-3.ll.mlir | 24 +- .../InstCombine/sprintf-void.ll.mlir | 25 +- .../InstCombine/sqrt-nofast.ll.mlir | 46 +- test/LLVMDialect/InstCombine/sqrt.ll.mlir | 103 + .../InstCombine/srem-canonicalize.ll.mlir | 36 + .../InstCombine/srem-simplify-bug.ll.mlir | 22 +- .../InstCombine/srem-via-sdiv-mul-sub.ll.mlir | 108 +- test/LLVMDialect/InstCombine/srem1.ll.mlir | 42 +- .../InstCombine/ssub-with-overflow.ll.mlir | 110 + test/LLVMDialect/InstCombine/ssubo.ll.mlir | 92 + .../InstCombine/stack-overalign.ll.mlir | 15 + .../InstCombine/stacksave-debuginfo.ll.mlir | 0 .../InstCombine/stacksaverestore.ll.mlir | 90 + .../InstCombine/statepoint-cleanup.ll.mlir | 0 .../InstCombine/statepoint-iter.ll.mlir | 0 .../InstCombine/statepoint.ll.mlir | 0 .../InstCombine/stdio-custom-dl.ll.mlir | 18 + .../InstCombine/stdiocall-bad-sig.ll.mlir | 37 + .../store-load-unaliased-gep.ll.mlir | 29 +- test/LLVMDialect/InstCombine/store.ll.mlir | 391 +- .../InstCombine/storemerge-dbg.ll.mlir | 35 +- test/LLVMDialect/InstCombine/stpcpy-1.ll.mlir | 50 + test/LLVMDialect/InstCombine/stpcpy-2.ll.mlir | 14 + .../InstCombine/stpcpy_chk-1.ll.mlir | 0 .../InstCombine/stpcpy_chk-2.ll.mlir | 15 + .../LLVMDialect/InstCombine/stpncpy-1.ll.mlir | 346 +- .../LLVMDialect/InstCombine/str-int-2.ll.mlir | 254 +- .../LLVMDialect/InstCombine/str-int-3.ll.mlir | 314 + .../LLVMDialect/InstCombine/str-int-4.ll.mlir | 276 + .../LLVMDialect/InstCombine/str-int-5.ll.mlir | 503 +- test/LLVMDialect/InstCombine/str-int.ll.mlir | 258 +- .../InstCombine/strcall-bad-sig.ll.mlir | 101 + .../InstCombine/strcall-no-nul.ll.mlir | 539 +- test/LLVMDialect/InstCombine/strcat-1.ll.mlir | 25 + test/LLVMDialect/InstCombine/strcat-2.ll.mlir | 24 + test/LLVMDialect/InstCombine/strcat-3.ll.mlir | 15 + test/LLVMDialect/InstCombine/strchr-1.ll.mlir | 84 + test/LLVMDialect/InstCombine/strchr-2.ll.mlir | 34 +- test/LLVMDialect/InstCombine/strchr-3.ll.mlir | 55 + test/LLVMDialect/InstCombine/strchr-4.ll.mlir | 35 + test/LLVMDialect/InstCombine/strcmp-1.ll.mlir | 66 + test/LLVMDialect/InstCombine/strcmp-2.ll.mlir | 31 +- test/LLVMDialect/InstCombine/strcmp-3.ll.mlir | 159 + test/LLVMDialect/InstCombine/strcmp-4.ll.mlir | 16 + .../InstCombine/strcmp-memcmp.ll.mlir | 352 + test/LLVMDialect/InstCombine/strcpy-1.ll.mlir | 49 + test/LLVMDialect/InstCombine/strcpy-2.ll.mlir | 14 + .../InstCombine/strcpy-nonzero-as.ll.mlir | 89 +- .../InstCombine/strcpy_chk-1.ll.mlir | 0 .../InstCombine/strcpy_chk-2.ll.mlir | 15 + .../InstCombine/strcpy_chk-64.ll.mlir | 49 +- .../LLVMDialect/InstCombine/strcspn-1.ll.mlir | 32 + .../LLVMDialect/InstCombine/strcspn-2.ll.mlir | 11 + ...heck-to-comparison-of-sub-operands.ll.mlir | 125 +- .../LLVMDialect/InstCombine/strlcpy-1.ll.mlir | 281 +- test/LLVMDialect/InstCombine/strlen-1.ll.mlir | 192 + test/LLVMDialect/InstCombine/strlen-2.ll.mlir | 26 +- test/LLVMDialect/InstCombine/strlen-3.ll.mlir | 16 +- test/LLVMDialect/InstCombine/strlen-4.ll.mlir | 119 + test/LLVMDialect/InstCombine/strlen-5.ll.mlir | 403 ++ test/LLVMDialect/InstCombine/strlen-6.ll.mlir | 324 + test/LLVMDialect/InstCombine/strlen-7.ll.mlir | 167 + test/LLVMDialect/InstCombine/strlen-8.ll.mlir | 111 + test/LLVMDialect/InstCombine/strlen-9.ll.mlir | 53 + .../InstCombine/strlen_chk.ll.mlir | 84 +- .../LLVMDialect/InstCombine/strncat-1.ll.mlir | 27 + .../LLVMDialect/InstCombine/strncat-2.ll.mlir | 71 + .../LLVMDialect/InstCombine/strncat-3.ll.mlir | 16 + .../LLVMDialect/InstCombine/strncmp-1.ll.mlir | 83 + .../LLVMDialect/InstCombine/strncmp-2.ll.mlir | 33 +- .../LLVMDialect/InstCombine/strncmp-3.ll.mlir | 92 +- .../LLVMDialect/InstCombine/strncmp-4.ll.mlir | 104 + .../LLVMDialect/InstCombine/strncmp-5.ll.mlir | 404 +- .../LLVMDialect/InstCombine/strncmp-6.ll.mlir | 126 +- .../strncmp-wrong-datalayout.ll.mlir | 19 +- .../LLVMDialect/InstCombine/strncpy-1.ll.mlir | 146 + .../LLVMDialect/InstCombine/strncpy-2.ll.mlir | 15 + .../LLVMDialect/InstCombine/strncpy-3.ll.mlir | 97 +- .../LLVMDialect/InstCombine/strncpy-4.ll.mlir | 142 +- .../InstCombine/strncpy_chk-1.ll.mlir | 58 + .../InstCombine/strncpy_chk-2.ll.mlir | 16 + test/LLVMDialect/InstCombine/strndup.ll.mlir | 47 + .../LLVMDialect/InstCombine/strnlen-1.ll.mlir | 214 +- .../LLVMDialect/InstCombine/strnlen-2.ll.mlir | 119 + .../LLVMDialect/InstCombine/strnlen-3.ll.mlir | 271 +- .../LLVMDialect/InstCombine/strnlen-4.ll.mlir | 48 + .../LLVMDialect/InstCombine/strnlen-5.ll.mlir | 248 +- .../LLVMDialect/InstCombine/strnlen-6.ll.mlir | 55 +- .../LLVMDialect/InstCombine/strpbrk-1.ll.mlir | 38 + .../LLVMDialect/InstCombine/strpbrk-2.ll.mlir | 31 +- .../LLVMDialect/InstCombine/strrchr-1.ll.mlir | 67 + .../LLVMDialect/InstCombine/strrchr-2.ll.mlir | 34 +- .../LLVMDialect/InstCombine/strrchr-3.ll.mlir | 83 +- test/LLVMDialect/InstCombine/strspn-1.ll.mlir | 32 + test/LLVMDialect/InstCombine/strstr-1.ll.mlir | 45 + test/LLVMDialect/InstCombine/strstr-2.ll.mlir | 11 + test/LLVMDialect/InstCombine/strto-1.ll.mlir | 122 +- .../struct-assign-tbaa-new.ll.mlir | 27 - .../InstCombine/struct-assign-tbaa.ll.mlir | 58 +- .../InstCombine/sub-and-or-neg-xor.ll.mlir | 122 +- .../sub-ashr-and-to-icmp-select.ll.mlir | 120 + .../sub-ashr-or-to-icmp-select.ll.mlir | 204 + .../InstCombine/sub-from-sub.ll.mlir | 297 +- test/LLVMDialect/InstCombine/sub-gep.ll.mlir | 321 + .../sub-lshr-or-to-icmp-select.ll.mlir | 58 + .../InstCombine/sub-minmax.ll.mlir | 561 ++ test/LLVMDialect/InstCombine/sub-not.ll.mlir | 103 + .../sub-of-negatible-inseltpoison.ll.mlir | 808 +++ .../InstCombine/sub-of-negatible.ll.mlir | 869 +++ .../InstCombine/sub-or-and-xor.ll.mlir | 118 +- .../InstCombine/sub-xor-cmp.ll.mlir | 92 + .../InstCombine/sub-xor-or-neg-and.ll.mlir | 122 +- test/LLVMDialect/InstCombine/sub-xor.ll.mlir | 119 + test/LLVMDialect/InstCombine/sub.ll.mlir | 0 .../subtract-from-one-hand-of-select.ll.mlir | 29 + .../subtract-of-one-hand-of-select.ll.mlir | 29 + .../swifterror-argument-bitcast-fold.ll.mlir | 19 +- .../InstCombine/switch-constant-expr.ll.mlir | 33 + .../InstCombine/switch-select.ll.mlir | 89 + .../InstCombine/switch-shl.ll.mlir | 95 + .../InstCombine/switch-sub.ll.mlir | 46 + .../InstCombine/switch-truncate-crash.ll.mlir | 10 + .../InstCombine/switch-zext-sext.ll.mlir | 52 + .../InstCombine/tan-nofastmath.ll.mlir | 13 - test/LLVMDialect/InstCombine/tan.ll.mlir | 19 - .../InstCombine/tbaa-store-to-load.ll.mlir | 21 +- .../InstCombine/threadlocal_address.ll.mlir | 35 + .../InstCombine/tmp-alloca-bypass.ll.mlir | 33 + .../LLVMDialect/InstCombine/toascii-1.ll.mlir | 77 +- test/LLVMDialect/InstCombine/token.ll.mlir | 0 test/LLVMDialect/InstCombine/trig.ll.mlir | 65 + .../InstCombine/trivial-dse-calls.ll.mlir | 302 +- .../InstCombine/trunc-binop-ext.ll.mlir | 460 +- .../InstCombine/trunc-demand.ll.mlir | 97 + .../trunc-extractelement-inseltpoison.ll.mlir | 80 + .../InstCombine/trunc-extractelement.ll.mlir | 80 + .../InstCombine/trunc-fp-to-int.ll.mlir | 119 + .../InstCombine/trunc-inseltpoison.ll.mlir | 620 ++ .../InstCombine/trunc-load.ll.mlir | 98 +- .../InstCombine/trunc-shift-trunc.ll.mlir | 121 + .../InstCombine/trunc-shl-zext.ll.mlir | 16 + test/LLVMDialect/InstCombine/trunc.ll.mlir | 0 .../InstCombine/truncating-saturate.ll.mlir | 463 ++ .../InstCombine/type_pun-inseltpoison.ll.mlir | 68 + test/LLVMDialect/InstCombine/type_pun.ll.mlir | 68 + .../InstCombine/uadd-with-overflow.ll.mlir | 98 + test/LLVMDialect/InstCombine/uaddo.ll.mlir | 96 + test/LLVMDialect/InstCombine/uaddo2.ll.mlir | 55 + test/LLVMDialect/InstCombine/ucmp.ll.mlir | 0 .../udiv-pow2-vscale-inseltpoison.ll.mlir | 0 .../InstCombine/udiv-pow2-vscale.ll.mlir | 0 .../InstCombine/udiv-simplify.ll.mlir | 83 - .../udiv_select_to_select_shift.ll.mlir | 25 + .../InstCombine/udivrem-change-width.ll.mlir | 411 +- .../LLVMDialect/InstCombine/umax-icmp.ll.mlir | 405 ++ .../LLVMDialect/InstCombine/umin-icmp.ll.mlir | 405 ++ .../InstCombine/umul-sign-check.ll.mlir | 189 + .../InstCombine/umulo-square.ll.mlir | 30 + test/LLVMDialect/InstCombine/umulo.ll.mlir | 101 + .../InstCombine/unavailable-debug.ll.mlir | 52 + ...asked-merge-with-const-mask-scalar.ll.mlir | 322 +- ...asked-merge-with-const-mask-vector.ll.mlir | 264 + .../unordered-compare-and-ordered.ll.mlir | 268 + .../InstCombine/unordered-fcmp-select.ll.mlir | 65 + .../InstCombine/unpack-fca.ll.mlir | 160 + .../InstCombine/unreachable-code.ll.mlir | 292 + .../unreachable-dbg-info-modified.ll.mlir | 18 + .../unrecognized_three-way-comparison.ll.mlir | 430 ++ ...add-lack-of-overflow-check-via-add.ll.mlir | 227 +- ...add-lack-of-overflow-check-via-xor.ll.mlir | 209 +- ...nsigned-add-lack-of-overflow-check.ll.mlir | 179 + ...nsigned-add-overflow-check-via-add.ll.mlir | 224 +- ...nsigned-add-overflow-check-via-xor.ll.mlir | 209 +- .../unsigned-add-overflow-check.ll.mlir | 193 +- ...ack-of-overflow-check-via-mul-udiv.ll.mlir | 168 +- ...overflow-check-via-udiv-of-allones.ll.mlir | 62 + ...ed-mul-overflow-check-via-mul-udiv.ll.mlir | 168 +- ...overflow-check-via-udiv-of-allones.ll.mlir | 62 + ...nsigned-sub-lack-of-overflow-check.ll.mlir | 153 +- .../unsigned-sub-overflow-check.ll.mlir | 153 +- .../unsigned_saturated_sub.ll.mlir | 338 + .../InstCombine/unused-nonnull.ll.mlir | 23 + .../InstCombine/unwind-inline-asm.ll.mlir | 0 .../InstCombine/update-bpi.ll.mlir | 13 + .../InstCombine/urem-simplify-bug.ll.mlir | 33 + .../InstCombine/urem-via-cmp-select.ll.mlir | 85 + .../InstCombine/urem-via-udiv-mul-sub.ll.mlir | 108 +- ...sub-overflow-known-by-implied-cond.ll.mlir | 238 + test/LLVMDialect/InstCombine/usubo.ll.mlir | 92 + test/LLVMDialect/InstCombine/vararg.ll.mlir | 17 + ...xt-of-variable-high-bit-extraction.ll.mlir | 345 + .../vec-binop-select-inseltpoison.ll.mlir | 0 .../InstCombine/vec-binop-select.ll.mlir | 0 .../vec_demanded_elts-inseltpoison.ll.mlir | 633 ++ .../InstCombine/vec_demanded_elts.ll.mlir | 854 +++ .../InstCombine/vec_extract_2elts.ll.mlir | 10 + .../vec_extract_var_elt-inseltpoison.ll.mlir | 24 + .../InstCombine/vec_extract_var_elt.ll.mlir | 24 + .../vec_gep_scalar_arg-inseltpoison.ll.mlir | 13 + .../InstCombine/vec_gep_scalar_arg.ll.mlir | 13 + .../vec_phi_extract-inseltpoison.ll.mlir | 93 + .../InstCombine/vec_phi_extract.ll.mlir | 93 + test/LLVMDialect/InstCombine/vec_sext.ll.mlir | 56 + .../vec_shuffle-inseltpoison.ll.mlir | 0 .../InstCombine/vec_shuffle.ll.mlir | 0 .../InstCombine/vec_udiv_to_shift.ll.mlir | 27 +- .../vector-casts-inseltpoison.ll.mlir | 251 + .../InstCombine/vector-casts.ll.mlir | 318 + .../vector-concat-binop-inseltpoison.ll.mlir | 124 + .../InstCombine/vector-concat-binop.ll.mlir | 124 + .../vector-logical-reductions.ll.mlir | 17 - .../InstCombine/vector-mul.ll.mlir | 214 + .../vector-reduce-min-max-known.ll.mlir | 186 + .../InstCombine/vector-reductions.ll.mlir | 82 - .../InstCombine/vector-reverse.ll.mlir | 0 .../InstCombine/vector-trunc.ll.mlir | 26 + .../InstCombine/vector-type.ll.mlir | 13 + .../InstCombine/vector-udiv.ll.mlir | 65 + .../InstCombine/vector-urem.ll.mlir | 76 + .../InstCombine/vector-xor.ll.mlir | 300 + .../vector_gep1-inseltpoison.ll.mlir | 0 .../InstCombine/vector_gep1.ll.mlir | 0 .../InstCombine/vector_gep2.ll.mlir | 43 +- ...tor_insertelt_shuffle-inseltpoison.ll.mlir | 91 + .../vector_insertelt_shuffle.ll.mlir | 90 + .../InstCombine/volatile_load_cast.ll.mlir | 60 +- .../InstCombine/volatile_store.ll.mlir | 21 + test/LLVMDialect/InstCombine/vscale.ll.mlir | 21 + .../InstCombine/vscale_alloca.ll.mlir | 52 +- .../InstCombine/vscale_cmp.ll.mlir | 0 ...vscale_extractelement-inseltpoison.ll.mlir | 129 + .../InstCombine/vscale_extractelement.ll.mlir | 0 .../InstCombine/vscale_gep.ll.mlir | 70 + .../vscale_insertelement-inseltpoison.ll.mlir | 53 + .../InstCombine/vscale_insertelement.ll.mlir | 53 + .../InstCombine/vscale_load.ll.mlir | 80 + .../InstCombine/vscale_sext_and_zext.ll.mlir | 37 + .../InstCombine/vscale_trunc.ll.mlir | 17 + .../InstCombine/vscale_zero.ll.mlir | 14 + test/LLVMDialect/InstCombine/wcslen-1.ll.mlir | 170 + test/LLVMDialect/InstCombine/wcslen-2.ll.mlir | 26 +- test/LLVMDialect/InstCombine/wcslen-3.ll.mlir | 123 + test/LLVMDialect/InstCombine/wcslen-4.ll.mlir | 24 +- test/LLVMDialect/InstCombine/wcslen-5.ll.mlir | 86 + test/LLVMDialect/InstCombine/wcslen-6.ll.mlir | 44 + .../InstCombine/weak-symbols.ll.mlir | 49 +- .../InstCombine/widenable-conditions.ll.mlir | 0 test/LLVMDialect/InstCombine/win-math.ll.mlir | 365 +- .../InstCombine/with_overflow.ll.mlir | 673 ++ .../InstCombine/xor-and-or.ll.mlir | 178 + test/LLVMDialect/InstCombine/xor-ashr.ll.mlir | 113 + .../LLVMDialect/InstCombine/xor-icmps.ll.mlir | 204 + .../xor-of-icmps-with-extra-uses.ll.mlir | 95 + .../LLVMDialect/InstCombine/xor-of-or.ll.mlir | 160 + .../LLVMDialect/InstCombine/xor-undef.ll.mlir | 15 +- test/LLVMDialect/InstCombine/xor.ll.mlir | 866 +++ test/LLVMDialect/InstCombine/xor2.ll.mlir | 704 +- .../InstCombine/zero-point-zero-add.ll.mlir | 34 +- .../InstCombine/zeroext-and-reduce.ll.mlir | 18 +- .../InstCombine/zext-bool-add-sub.ll.mlir | 240 + .../zext-ctlz-trunc-to-ctlz-add.ll.mlir | 127 +- .../LLVMDialect/InstCombine/zext-fold.ll.mlir | 10 + .../InstCombine/zext-or-icmp.ll.mlir | 161 + test/LLVMDialect/InstCombine/zext-phi.ll.mlir | 20 +- test/LLVMDialect/InstCombine/zext.ll.mlir | 480 ++ 1465 files changed, 186974 insertions(+), 28979 deletions(-) create mode 100644 test/LLVMDialect/InstCombine/2003-08-12-AllocaNonNull.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2004-01-13-InstCombineInvokePHI.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2004-04-04-InstCombineReplaceAllUsesWith.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2004-09-20-BadLoadCombine.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2005-04-07-UDivSelectCrash.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2005-06-15-DivSelectCrash.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2006-03-30-ExtractElement.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2006-12-08-Select-ICmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2006-12-15-Range-Test.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2006-12-23-Select-Cmp-Cmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2007-02-23-PhiFoldInfLoop.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2007-03-13-CompareMerge.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2007-04-08-SingleEltVectorCrash.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2007-05-10-icmp-or.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2007-09-10-AliasConstFold.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2007-09-17-AliasConstFold2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2007-11-15-CompareMiscomp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2007-12-10-ConstFoldCompare.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2007-12-16-AsmNoUnwind.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2007-12-18-AddSelCmpSub.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2007-12-28-IcmpSub2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-01-06-BitCastAttributes.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-01-13-AndCmpCmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-01-21-MulTrunc.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-01-27-FloatSelect.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-02-28-OrFCmpCrash.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-04-28-VolatileStore.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-05-09-SinkOfInvoke.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-05-17-InfLoop.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-05-18-FoldIntToPtr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-05-23-CompareFold.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-06-19-UncondLoad.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-06-21-CompareMiscomp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-07-13-DivZero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-08-05-And.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-09-02-VectorCrash.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2008-11-08-FCmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2009-01-05-i128-crash.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2009-01-19-fmod-constant-float-specials.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2009-02-20-InstCombine-SROA.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2009-02-25-CrashZeroSizeArray.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2009-03-18-vector-ashr-crash.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2009-05-23-FCmpToICmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2009-07-02-MaskedIntVector.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2009-12-17-CmpSelectNull.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2010-03-03-ExtElim.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2011-02-14-InfLoop.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2011-05-02-VectorBoolean.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2011-05-13-InBoundsGEP.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2012-02-13-FCmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2012-02-28-ICmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2012-03-10-InstCombine.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2012-04-24-vselect.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2012-06-06-LoadOfPHIs.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2012-07-30-addrsp-bitcast.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2012-10-25-vector-of-pointers.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2012-12-14-simp-vgep.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2012-3-15-or-xor-constant.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2012-6-7-vselect-bitcast.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2013-03-05-Combine-BitcastTy-Into-Alloca.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/2023-07-13-arm-infiniteloop.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/AddOverFlow.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/CPP_min_max.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ExtractCast.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/InferAlignAttribute.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/JavaCompare.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/LandingPadClauses.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/OverlappingInsertvalues.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/PR30597.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/PR37526.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/StoreToNull-DbgCheck.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/abs-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/abs-intrinsic.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/abs_abs.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/add-mask-neg.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/add-min-max.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/add-shift.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/add-shl-sdiv-to-srem.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/add.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/add2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/add_or_sub.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/addrspacecast.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/addsub-constant-folding.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/adjust-for-minmax.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/aggregate-reconstruction.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/alias-recursion.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/align-addr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/align-external.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/alloc-realloc-free.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/alloca-cast-debuginfo.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/alloca-intptr-not-sizet.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/alloca.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/allow-checks.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/and-add-shl.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/and-compare.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/and-fcmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/and-or-icmp-const-icmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/and-or-icmp-min-max.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/and-or-icmp-nullptr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/and-or-icmps.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/and-or-implied-cond-not.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/and-or-not.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/and-or.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/and-xor-or.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/and.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/and2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/annotations.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/apint-add.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/apint-div1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/apint-div2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/apint-mul1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/apint-mul2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/apint-rem1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/apint-rem2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/apint-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/apint-shift.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/array.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ashr-icmp-minmax-idiom-break.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ashr-lshr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ashr-or-mul-abs.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/assoc-cast-assoc.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/assume-icmp-null-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/assume-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/assume-separate_storage.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/assume.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/assume_inevitable.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/atomic.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/atomicrmw.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/avg-lsb.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/badmalloc.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/binop-and-shifts.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/binop-itofp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/binop-of-displaced-shifts.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/binop-phi-operands.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/binop-select-cast-of-select-cond.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/binop-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bit-checks.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bit_ceil.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bit_floor.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bitcast-bfloat-half-mixing.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bitcast-inselt-bitcast.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bitcast-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bitcast-vec-canon-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bitcast-vec-canon.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bitcast.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bitreverse.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bittest.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bitwiselogic-bitmanip.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/broadcast-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/broadcast.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bswap-fold.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bswap-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/bswap.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/builtin-dynamic-object-size.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/builtin-object-size-offset.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/call-cast-attrs.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/call-cast-target-inalloca.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/call-cast-target.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/call-returned.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/call-undef.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/call.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/call_nonnull_arg.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-ashr-shl-to-masking.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-clamp-like-pattern-between-negative-and-positive-thresholds.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-clamp-like-pattern-between-zero-and-positive-threshold.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-clamp-with-select-of-constant-threshold-pattern.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-eq-to-icmp-ule.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sge-to-icmp-sle.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sgt-to-icmp-sgt.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sle-to-icmp-sle.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-slt-to-icmp-sgt.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-uge-to-icmp-ule.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ugt-to-icmp-ugt.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ule-to-icmp-ule.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ult-to-icmp-ugt.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-fcmp-inf.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-gep-mul.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-lack-of-signed-truncation-check.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-and-icmp-eq-to-icmp-ule.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v2-and-icmp-eq-to-icmp-ule.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v2-and-icmp-ne-to-icmp-ugt.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v3-and-icmp-eq-to-icmp-ule.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v3-and-icmp-ne-to-icmp-ugt.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v4-and-icmp-eq-to-icmp-ule.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v4-and-icmp-ne-to-icmp-ugt.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-lshr-shl-to-masking.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-or-with-overflow-icmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-selects-icmp-condition-bittest.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-shl-lshr-to-masking.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize-signed-truncation-check.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/canonicalize_branch.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cast-byval.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cast-call-combine-prof.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cast-call-combine.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cast-int-fcmp-eq-0.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cast-int-icmp-eq-0.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cast-mul-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cast-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cast-set-preserve-signed-dbg-val.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cast-set.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cast-unsigned-icmp-eqcmp-0.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cast.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cast_ptr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/catchswitch-phi.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/clamp-to-minmax.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cmp-intrinsic.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/combine-is.fpclass-and-fcmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/commutative-intrinsics.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/commutative-operation-over-phis.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/commutative-operation-over-selects.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/compare-3way.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/compare-alloca.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/compare-signs.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/compare-udiv.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/compare-unescaped.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/conditional-negation.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/conditional-variable-length-signext-after-high-bit-extract.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/consecutive-fences.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/consecutive-ptrmask.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/constant-expr-datalayout.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/constant-fold-address-space-pointer.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/constant-fold-alias.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/constant-fold-gep.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/constant-fold-shifts.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/constrained.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/convergent.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/copysign-fneg-fabs.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/copysign.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cos-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cos-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cos-sin-intrinsic.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/crash.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/create-class-from-logic-fcmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ctlz-cttz-shifts.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ctpop-cttz.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ctpop-pow2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ctpop.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cttz-abs.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/cttz-negative.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/dbg-scalable-store-fixed-frag.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/dbg-simplify-alloca-size.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/debuginfo-dce.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/debuginfo-dce2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/debuginfo-scalable-typesize.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/debuginfo-sink.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/debuginfo-skip.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/debuginfo-variables.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/debuginfo.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/debuginfo_add.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/demorgan.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/dependent-ivs.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/deref-alloc-fns.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/disable-builtin.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/disable-simplify-libcalls.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/div-by-0-guard-before-smul_ov-not.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/div-by-0-guard-before-smul_ov.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/div-by-0-guard-before-umul_ov-not.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/div-by-0-guard-before-umul_ov.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/div-i1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/div-shift-crash.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/div-shift.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/div.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/dont-distribute-phi.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/eq-of-parts.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/erase-dbg-values-at-dead-alloc-site.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/exact.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/exp2-to-ldexp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/extract-select-agg.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/extractelement-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/extractelement.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/extractinsert-tbaa.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/extractvalue.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fabs-as-int.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fabs-fneg-fold.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fabs.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fadd-maximum-minimum.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fadd.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fast-basictest.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fast-math.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fcmp-denormals-are-zero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fcmp-range-check-idiom.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fcmp-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fcmp-special.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fcmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fdiv-sqrt.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fdiv.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/float-shrink-compare.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fma.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fmul-bool.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fmul-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fmul-maximum-minimum.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fmul.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fneg-as-int.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fneg-fabs-as-int.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fneg-fabs.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fneg.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fold-a-or-b-zero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fold-bin-operand.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fold-ctpop-of-not.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fold-ext-eq-c-with-op.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fold-fops-into-selects.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fold-inc-of-add-of-not-x-and-y-to-sub-x-from-y.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fold-log2-ceil-idiom.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fold-minmax-i1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fold-select-fmul-if-zero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fold-signbit-test-power2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fold-sub-of-not-to-inc-of-add.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fold-vector-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fold-vector-zero-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fold-vector-zero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/force-opaque-ptr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fortify-folding.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fpcast.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fpclass-check-idioms.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fpclass-from-dom-cond.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fpextend.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fprintf-wrong-sig.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fptrunc.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fputs-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fputs-opt-size.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/free-inversion.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/freeze-fp-ops.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/freeze-integer-intrinsics.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/freeze-landingpad.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/freeze-phi.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/freeze.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fsh.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fsub.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/funnel.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/fwrite-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/gc.relocate.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/gep-addrspace.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/gep-alias.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/gep-canonicalize-constant-indices.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/gep-custom-dl.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/gep-inbounds-null.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/gep-merge-constant-indices.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/gep-object-size-less-than-or-equal-typesize.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/gep-vector-indices.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/gep-vector.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/gepofconstgepi8.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/get-lowbitmask-upto-and-including-bit.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/getelementptr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/high-bit-signmask-with-trunc.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/high-bit-signmask.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/hoist-negation-out-of-bias-calculation-with-constant.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/hoist-negation-out-of-bias-calculation.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/hoist-not-from-ashr-operand.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-abs.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-add.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-and-add-sub-xor-p2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-and-lowbit-mask.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-and-shift.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-bc-vec-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-bc-vec.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-binop.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-bitcast-glob.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-constant-phi.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-custom-dl.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-div-constant.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-dom.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-equality-rotate.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-equality-xor.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-fold-into-phi.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-fsh.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-gep.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-logical.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-mul-and.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-mul.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-ne-pow2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-not-bool-constant.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-of-and-x.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-of-or-x.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-of-trunc-ext.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-of-xor-x.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-or.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-power2-and-icmp-shifted-mask.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-rotate.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-select-implies-common-op.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-shl-1-overflow.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-shl-nsw.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-shl.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-shr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-sub.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-trunc.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-uadd-sat.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-uge-of-add-of-shl-one-by-bits-to-allones-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-uge-of-not-of-shl-allones-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-ugt-of-shl-1-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-ule-of-shl-1-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-ult-of-add-of-shl-one-by-bits-to-allones-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-ult-of-not-of-shl-allones-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-usub-sat.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-vec-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-vec.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-vscale.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-with-selects.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp-xor-signbit.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/icmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/implies.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/inbounds-gep.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/indexed-gep-compares.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/infinite-loop-postdom.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/inselt-binop-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/inselt-binop.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/insert-const-shuf-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/insert-const-shuf.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/insert-ext.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/insert-extract-shuffle-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/insert-extract-shuffle.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/insert-trunc.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/insert-val-extract-elem.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/insertelement-bitcast.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/insertelement.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/insertelt-trunc.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/integer-round-up-pow2-alignment.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/intptr1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/intptr2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/intptr3.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/intptr4.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/intptr5.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/intptr6.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/intptr8.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/intrinsic-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/intrinsics.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/invariant.group.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/invert-variable-mask-in-masked-merge-vector.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/invoke.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/is_fpclass.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ispow2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/kcfi-operand-bundles.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/known-fpclass-reduce-signbit.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/known-never-nan.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/known-non-zero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/known-phi-recurse.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/known-signbit-shift.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/known_align.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ldexp-ext.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ldexp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/lifetime-no-null-opt.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/lifetime.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/load-bitcast-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/load-cmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/load-gep-overalign.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/load-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/load-store-forward.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/load-store-masked-constant-array.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/load.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/load3.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/logical-select-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/logical-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/low-bit-splat.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/lower-dbg-declare.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/lshr-and-negC-icmpeq-zero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/lshr-and-signbit-icmpeq-zero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/lshr-trunc-sext-to-ashr-sext.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/lshr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/malloc-free-addrspace.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/malloc-free-delete-dbginvar.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/malloc-free-mismatched.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/malloc-free.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/malloc_free_delete_nvptx.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/masked-merge-add.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/masked-merge-and-of-ors.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/masked-merge-or.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/masked-merge-xor.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/masked_intrinsics-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/masked_intrinsics.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/masked_intrinsics_keep_metadata.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/math-odd-even-parity.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/matrix-multiplication-negation.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/max-of-nots.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/max_known_bits.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/maximum.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/maxnum.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/mem-gep-zidx.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memchr-10.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memchr-11.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memchr-6.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memchr-7.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memchr-8.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memchr-9.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memchr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memcmp-7.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memcpy-from-global.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memcpy_chk-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memcpy_chk-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memmove_chk-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memmove_chk-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memrchr-7.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memrchr-8.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memset-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memset_chk-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/memset_chk-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/merge-icmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/merging-multiple-stores-into-successor.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/min-positive.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/minimum.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/minmax-demandbits.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/minmax-fold.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/minmax-fp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/minmax-intrinsics.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/minmax-of-minmax.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/minmax-of-xor-x.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/minnum.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/modulo.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/mul-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/mul-masked-bits.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/mul-min-max.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/mul-pow2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/mul.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/mul_fold.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/mul_full_32.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/mul_full_64.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/multi-size-address-space-pointer.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/multi-use-load-casts.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/multiple-uses-load-bitcast-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/musttail-thunk.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/narrow-switch.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/narrow.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/negated-bitmask.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/nested-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/new-delete-itanium.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/no-unwind-inline-asm.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/noalias-scope-decl.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/nonnull-attribute.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/nonnull-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/not-add.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/not.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/nsw-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/nsw.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/obfuscated_splat.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/objsize-64.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/objsize-address-space.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/objsize.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/omit-urem-of-power-of-two-or-zero-when-comparing-with-zero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/onehot_merge.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/opaque-ptr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/operand-complexity.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/or-fcmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/or-xor-xor.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/or-xor.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/or.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/out-of-bounds-indexes.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/out-of-tree-allocator-optimizes-away.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/overflow-mul.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/overflow.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/overflow_to_sat.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-a.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-b.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-c.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-d.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-e.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-a.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-b.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-c.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-d.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-e.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/phi-aware-aggregate-reconstruction.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/phi-equal-incoming-pointers.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/phi-extractvalue.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/phi-load-metadata-4.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/phi-merge-gep.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/phi-of-insertvalues.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/phi-pointercasts.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/phi-select-constant.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/phi.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pow-0.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pow-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pow-to-ldexp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pow-to-sqrt.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/powi.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr12338.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr20678.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr21199.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr21210.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr21651.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr23809.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr24354.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr25342.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr25745.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr2645-0-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr2645-0.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr26992.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr27236.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr27332.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr28725.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr2996.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr32686.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr33453.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr33689_same_bitwidth.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr35515.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr36362.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr38677.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr38897.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr38915.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr38984-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr38984.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr39177.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr39908.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr43893.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr44242.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr44541.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr44552.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr44835.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr49688.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr51824.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr53357.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr55228.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr58901.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr59613.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr63791.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr69059.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr71330.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr72433.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr75129.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr75369.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr77064.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr80597.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr80941.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr82877.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr83931.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pr83947.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/preserve-sminmax.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/prevent-cmp-merge.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/printf-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/printf-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/printf-3.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ptr-int-ptr-icmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ptr-replace-alloca.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ptrauth-intrinsics.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ptrmask.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/pull-conditional-binop-through-shift.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/puts-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/puts-i16.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/range-check.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/realloc-free.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/realloc.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/reduction-add-sext-zext-i1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/reduction-and-sext-zext-i1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/reduction-mul-sext-zext-i1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/reduction-or-sext-zext-i1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/reduction-shufflevector.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/reduction-smax-sext-zext-i1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/reduction-smin-sext-zext-i1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/reduction-umax-sext-zext-i1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/reduction-umin-sext-zext-i1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/reduction-xor-sext-zext-i1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-a.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-b.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-c.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-d.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-e.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-f.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-a.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-b.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-c.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-d.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-e.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-f.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/redundant-right-shift-input-masking.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/rem-mul-shl.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/rem.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/remove-loop-phi-multiply-by-zero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/result-of-add-of-negative-is-non-zero-and-no-underflow.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/result-of-add-of-negative-or-zero-is-non-zero-and-no-underflow.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/result-of-usub-is-non-zero-and-no-overflow.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/reuse-constant-from-select-in-icmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/rotate.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sadd-with-overflow.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sadd_sat.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/saddo.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/salvage-dbg-declare.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/saturating-add-sub.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/scalable-bitcast-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/scalable-bitcast.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/scalable-cast-of-alloc.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/scalable-const-fp-splat.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/scalable-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/scalable-vector-array.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/scalable-vector-struct.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/scalarization-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/scalarization.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/scmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sdiv-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sdiv-canonicalize.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sdiv-exact-by-negative-power-of-two.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sdiv-exact-by-power-of-two.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sdiv-guard.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sdiv-icmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-and-or.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-binop-cmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-binop-foldable-floating-point.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-bitext-bitwise-ops.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-bitext.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-cmp-br.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-cmp-cttz-ctlz.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-cmp-eq-op-fold.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-cmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-cmpxchg.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-crash.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-ctlz-to-cttz.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-divrem.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-extractelement-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-extractelement.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-factorize.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-gep.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-icmp-and-zero-shl.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-icmp-and.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-imm-canon.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-load-call.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-masked_gather.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-masked_load.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-min-max.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-obo-peo-ops.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-of-bittest.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-pr39595.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-safe-bool-transforms.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-safe-impliedcond-transforms.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-safe-transforms.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select-with-bitwise-ops.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select_arithmetic.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/select_meta.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/set-lowbits-mask-canonicalize.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/set.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sext.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift-add-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift-add.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift-amount-reassociation-in-bittest-with-truncation-lshr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift-amount-reassociation-in-bittest-with-truncation-shl.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift-amount-reassociation-in-bittest.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift-amount-reassociation-with-truncation-ashr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift-amount-reassociation-with-truncation-lshr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift-amount-reassociation-with-truncation-shl.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift-amount-reassociation.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift-cttz-ctlz.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift-direction-in-bit-test.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift-flags.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift-logic.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift-shift.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shift.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shl-and-negC-icmpeq-zero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shl-and-signbit-icmpeq-zero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shl-bo.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shl-sub.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shl-unsigned-cmp-const.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shuffle-binop.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shuffle-cast-dist.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shuffle-cast-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shuffle-cast.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shuffle-select-narrow-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shuffle-select-narrow.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shuffle_select-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shuffle_select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shufflevec-bitcast-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shufflevec-bitcast.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shufflevec-constant-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shufflevec-constant.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shufflevector-div-rem-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shufflevector-div-rem.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/shufflevector_freezepoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sign-test-and-or.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/signbit-lshr-and-icmpeq-zero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/signbit-shl-and-icmpeq-zero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/signed-truncation-check.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/signmask-of-sext-vs-of-shl-of-zext.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/simple_phi_condition.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/simplify-demanded-bits-pointer.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/simplify-demanded-fpclass.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/simplify-libcalls-erased.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/simplify-libcalls-i16.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/simplify-libcalls-inreg.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/simplify-libcalls-new.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/simplify-libcalls.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink-instruction-introduces-unnecessary-poison-value.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink-into-catchswitch.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink-into-ncd.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink-into-resume-block.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink-not-into-and.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-and.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-logical-and.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-logical-or.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-or.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink-not-into-logical-and.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink-not-into-logical-or.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink-not-into-or.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink_instruction.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink_sideeffecting_instruction.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sink_to_unreachable.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sitofp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/smax-icmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/smin-icmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/smulo.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/snprintf-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/snprintf-3.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/snprintf-4.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/snprintf.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sprintf-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sprintf-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sqrt.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/srem-canonicalize.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ssub-with-overflow.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ssubo.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/stack-overalign.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/stacksave-debuginfo.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/stacksaverestore.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/statepoint-cleanup.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/statepoint-iter.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/statepoint.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/stdio-custom-dl.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/stdiocall-bad-sig.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/stpcpy-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/stpcpy-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/stpcpy_chk-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/stpcpy_chk-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/str-int-3.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/str-int-4.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strcall-bad-sig.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strcat-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strcat-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strcat-3.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strchr-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strchr-3.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strchr-4.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strcmp-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strcmp-3.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strcmp-4.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strcmp-memcmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strcpy-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strcpy-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strcpy_chk-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strcpy_chk-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strcspn-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strcspn-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strlen-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strlen-4.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strlen-5.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strlen-6.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strlen-7.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strlen-8.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strlen-9.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strncat-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strncat-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strncat-3.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strncmp-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strncmp-4.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strncpy-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strncpy-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strncpy_chk-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strncpy_chk-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strndup.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strnlen-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strnlen-4.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strpbrk-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strrchr-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strspn-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strstr-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/strstr-2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sub-ashr-and-to-icmp-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sub-ashr-or-to-icmp-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sub-gep.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sub-lshr-or-to-icmp-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sub-minmax.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sub-not.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sub-of-negatible-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sub-of-negatible.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sub-xor-cmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sub-xor.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/sub.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/subtract-from-one-hand-of-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/subtract-of-one-hand-of-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/switch-constant-expr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/switch-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/switch-shl.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/switch-sub.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/switch-truncate-crash.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/switch-zext-sext.ll.mlir delete mode 100644 test/LLVMDialect/InstCombine/tan-nofastmath.ll.mlir delete mode 100644 test/LLVMDialect/InstCombine/tan.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/threadlocal_address.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/tmp-alloca-bypass.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/token.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/trig.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/trunc-demand.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/trunc-extractelement-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/trunc-extractelement.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/trunc-fp-to-int.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/trunc-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/trunc-shift-trunc.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/trunc-shl-zext.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/trunc.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/truncating-saturate.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/type_pun-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/type_pun.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/uadd-with-overflow.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/uaddo.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/uaddo2.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/ucmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/udiv-pow2-vscale-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/udiv-pow2-vscale.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/udiv_select_to_select_shift.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/umax-icmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/umin-icmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/umul-sign-check.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/umulo-square.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/umulo.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/unavailable-debug.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/unfold-masked-merge-with-const-mask-vector.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/unordered-compare-and-ordered.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/unordered-fcmp-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/unpack-fca.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/unreachable-code.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/unreachable-dbg-info-modified.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/unrecognized_three-way-comparison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/unsigned-add-lack-of-overflow-check.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/unsigned-mul-lack-of-overflow-check-via-udiv-of-allones.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/unsigned-mul-overflow-check-via-udiv-of-allones.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/unsigned_saturated_sub.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/unused-nonnull.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/unwind-inline-asm.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/update-bpi.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/urem-simplify-bug.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/urem-via-cmp-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/usub-overflow-known-by-implied-cond.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/usubo.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vararg.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/variable-signext-of-variable-high-bit-extraction.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vec-binop-select-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vec-binop-select.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vec_demanded_elts-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vec_demanded_elts.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vec_extract_2elts.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vec_extract_var_elt-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vec_extract_var_elt.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vec_gep_scalar_arg-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vec_gep_scalar_arg.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vec_phi_extract-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vec_phi_extract.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vec_sext.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vec_shuffle-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vec_shuffle.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector-casts-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector-casts.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector-concat-binop-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector-concat-binop.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector-mul.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector-reduce-min-max-known.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector-reverse.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector-trunc.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector-type.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector-udiv.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector-urem.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector-xor.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector_gep1-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector_gep1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector_insertelt_shuffle-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vector_insertelt_shuffle.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/volatile_store.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vscale.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vscale_cmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vscale_extractelement-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vscale_extractelement.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vscale_gep.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vscale_insertelement-inseltpoison.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vscale_insertelement.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vscale_load.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vscale_sext_and_zext.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vscale_trunc.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/vscale_zero.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/wcslen-1.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/wcslen-3.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/wcslen-5.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/wcslen-6.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/widenable-conditions.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/with_overflow.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/xor-and-or.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/xor-ashr.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/xor-icmps.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/xor-of-icmps-with-extra-uses.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/xor-of-or.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/xor.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/zext-bool-add-sub.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/zext-fold.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/zext-or-icmp.ll.mlir create mode 100644 test/LLVMDialect/InstCombine/zext.ll.mlir diff --git a/test/LLVMDialect/InstCombine/2003-05-26-CastMiscompile.ll.mlir b/test/LLVMDialect/InstCombine/2003-05-26-CastMiscompile.ll.mlir index ae08ff459..d6a112997 100644 --- a/test/LLVMDialect/InstCombine/2003-05-26-CastMiscompile.ll.mlir +++ b/test/LLVMDialect/InstCombine/2003-05-26-CastMiscompile.ll.mlir @@ -1,9 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.trunc"(%arg0) : (i64) -> i32 - %1 = "llvm.zext"(%0) : (i32) -> i64 - "llvm.return"(%1) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i64) -> i64 { + %0 = llvm.trunc %arg0 : i64 to i32 + %1 = llvm.zext %0 : i32 to i64 + llvm.return %1 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/2003-05-27-ConstExprCrash.ll.mlir b/test/LLVMDialect/InstCombine/2003-05-27-ConstExprCrash.ll.mlir index 2f3c46fec..40ed89824 100644 --- a/test/LLVMDialect/InstCombine/2003-05-27-ConstExprCrash.ll.mlir +++ b/test/LLVMDialect/InstCombine/2003-05-27-ConstExprCrash.ll.mlir @@ -1,14 +1,13 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "X", type = i32, value = 5 : i32} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @X} : () -> !llvm.ptr - %1 = "llvm.ptrtoint"(%0) : (!llvm.ptr) -> i64 - %2 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %4 = "llvm.add"(%3, %2) : (i64, i64) -> i64 - %5 = "llvm.add"(%1, %4) : (i64, i64) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @X(5 : i32) {addr_space = 0 : i32} : i32 + llvm.func @test() -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.mlir.constant(5 : i32) : i32 + %3 = llvm.mlir.addressof @X : !llvm.ptr + %4 = llvm.ptrtoint %3 : !llvm.ptr to i64 + %5 = llvm.add %0, %1 : i64 + %6 = llvm.add %4, %5 : i64 + llvm.return %6 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/2003-06-05-BranchInvertInfLoop.ll.mlir b/test/LLVMDialect/InstCombine/2003-06-05-BranchInvertInfLoop.ll.mlir index 56d0bae95..c5db6a9a1 100644 --- a/test/LLVMDialect/InstCombine/2003-06-05-BranchInvertInfLoop.ll.mlir +++ b/test/LLVMDialect/InstCombine/2003-06-05-BranchInvertInfLoop.ll.mlir @@ -1,14 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = true} : () -> i1 - "llvm.cond_br"(%2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test19(%arg0: i1) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(1 : i8) : i8 + llvm.cond_br %0, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.return"(%1) : (i8) -> () + llvm.return %2 : i8 ^bb2: // pred: ^bb0 - "llvm.return"(%0) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "test19", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %1 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/2003-07-21-ExternalConstant.ll.mlir b/test/LLVMDialect/InstCombine/2003-07-21-ExternalConstant.ll.mlir index d9c72576d..9116bef92 100644 --- a/test/LLVMDialect/InstCombine/2003-07-21-ExternalConstant.ll.mlir +++ b/test/LLVMDialect/InstCombine/2003-07-21-ExternalConstant.ll.mlir @@ -1,31 +1,23 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "silly", type = i32} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bzero", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bcopy", type = !llvm.func, ptr, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bcmp", type = !llvm.func, ptr, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fputs", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fputs_unlocked", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @silly} : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - %3 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - "llvm.store"(%arg0, %2) : (i32, !llvm.ptr) -> () - %4 = "llvm.load"(%2) : (!llvm.ptr) -> i32 - %5 = "llvm.load"(%0) : (!llvm.ptr) -> i32 - %6 = "llvm.add"(%4, %5) : (i32, i32) -> i32 - "llvm.store"(%6, %3) : (i32, !llvm.ptr) -> () - "llvm.br"()[^bb1] : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @silly() {addr_space = 0 : i32} : i32 + llvm.func @bzero(!llvm.ptr, i32) + llvm.func @bcopy(!llvm.ptr, !llvm.ptr, i32) + llvm.func @bcmp(!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.func @fputs(!llvm.ptr, !llvm.ptr) -> i32 + llvm.func @fputs_unlocked(!llvm.ptr, !llvm.ptr) -> i32 + llvm.func @function(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.addressof @silly : !llvm.ptr + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %5 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + %6 = llvm.add %4, %5 : i32 + llvm.store %6, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb1 ^bb1: // pred: ^bb0 - %7 = "llvm.load"(%3) : (!llvm.ptr) -> i32 - "llvm.return"(%7) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "function", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %7 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2003-08-12-AllocaNonNull.ll.mlir b/test/LLVMDialect/InstCombine/2003-08-12-AllocaNonNull.ll.mlir new file mode 100644 index 000000000..72c2db822 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2003-08-12-AllocaNonNull.ll.mlir @@ -0,0 +1,16 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bitmap_clear(...) -> i32 + llvm.func @oof() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %4 = llvm.icmp "ne" %3, %1 : !llvm.ptr + llvm.cond_br %4, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %5 = llvm.call @bitmap_clear(%3) vararg(!llvm.func) : (!llvm.ptr) -> i32 + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2003-09-09-VolatileLoadElim.ll.mlir b/test/LLVMDialect/InstCombine/2003-09-09-VolatileLoadElim.ll.mlir index d99fcc766..4b3c1285a 100644 --- a/test/LLVMDialect/InstCombine/2003-09-09-VolatileLoadElim.ll.mlir +++ b/test/LLVMDialect/InstCombine/2003-09-09-VolatileLoadElim.ll.mlir @@ -1,8 +1,6 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: !llvm.ptr) { + %0 = llvm.load volatile %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2003-10-29-CallSiteResolve.ll.mlir b/test/LLVMDialect/InstCombine/2003-10-29-CallSiteResolve.ll.mlir index faaad2071..73d7f30c2 100644 --- a/test/LLVMDialect/InstCombine/2003-10-29-CallSiteResolve.ll.mlir +++ b/test/LLVMDialect/InstCombine/2003-10-29-CallSiteResolve.ll.mlir @@ -1,18 +1,13 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.addressof"() {global_name = @bar} : () -> !llvm.ptr ()>> - %2 = "llvm.bitcast"(%1) : (!llvm.ptr ()>>) -> !llvm.ptr ()>> - %3 = "llvm.invoke"(%2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (!llvm.ptr ()>>) -> !llvm.ptr +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bar() -> !llvm.ptr + llvm.func @foo() -> !llvm.ptr attributes {personality = @__gxx_personality_v0} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.invoke @bar() to ^bb1 unwind ^bb2 : () -> !llvm.ptr ^bb1: // pred: ^bb0 - "llvm.return"(%3) : (!llvm.ptr) -> () + llvm.return %1 : !llvm.ptr ^bb2: // pred: ^bb0 - %4 = "llvm.landingpad"() {cleanup} : () -> !llvm.struct<(ptr, i32)> - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, personality = @__gxx_personality_v0, sym_name = "foo", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "__gxx_personality_v0", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %2 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)> + llvm.return %0 : !llvm.ptr + } + llvm.func @__gxx_personality_v0(...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/2003-11-03-VarargsCallBug.ll.mlir b/test/LLVMDialect/InstCombine/2003-11-03-VarargsCallBug.ll.mlir index 9748f2e32..c05abff2b 100644 --- a/test/LLVMDialect/InstCombine/2003-11-03-VarargsCallBug.ll.mlir +++ b/test/LLVMDialect/InstCombine/2003-11-03-VarargsCallBug.ll.mlir @@ -1,11 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.inttoptr"(%arg0) : (i64) -> !llvm.ptr - "llvm.call"(%0) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(...) + llvm.func @test(%arg0: i64) { + %0 = llvm.inttoptr %arg0 : i64 to !llvm.ptr + llvm.call @foo(%0) vararg(!llvm.func) : (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2004-01-13-InstCombineInvokePHI.ll.mlir b/test/LLVMDialect/InstCombine/2004-01-13-InstCombineInvokePHI.ll.mlir new file mode 100644 index 000000000..fbf6dbcf3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2004-01-13-InstCombineInvokePHI.ll.mlir @@ -0,0 +1,20 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test() -> !llvm.ptr + llvm.func @foo() -> i32 attributes {personality = @__gxx_personality_v0} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(0 : i32) : i32 + llvm.cond_br %1, ^bb3(%0 : !llvm.ptr), ^bb1 + ^bb1: // pred: ^bb0 + %3 = llvm.invoke @test() to ^bb2 unwind ^bb4 : () -> !llvm.ptr + ^bb2: // pred: ^bb1 + llvm.br ^bb3(%3 : !llvm.ptr) + ^bb3(%4: !llvm.ptr): // 2 preds: ^bb0, ^bb2 + %5 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %5 : i32 + ^bb4: // pred: ^bb1 + %6 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)> + llvm.return %2 : i32 + } + llvm.func @__gxx_personality_v0(...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/2004-02-23-ShiftShiftOverflow.ll.mlir b/test/LLVMDialect/InstCombine/2004-02-23-ShiftShiftOverflow.ll.mlir index 24ba5034c..fbecffd19 100644 --- a/test/LLVMDialect/InstCombine/2004-02-23-ShiftShiftOverflow.ll.mlir +++ b/test/LLVMDialect/InstCombine/2004-02-23-ShiftShiftOverflow.ll.mlir @@ -1,17 +1,14 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 17 : i32} : () -> i32 - %1 = "llvm.ashr"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.ashr"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 17 : i32} : () -> i32 - %1 = "llvm.shl"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.shl"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(17 : i32) : i32 + %1 = llvm.ashr %arg0, %0 : i32 + %2 = llvm.ashr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @test2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(17 : i32) : i32 + %1 = llvm.shl %arg0, %0 : i32 + %2 = llvm.shl %1, %0 : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2004-03-13-InstCombineInfLoop.ll.mlir b/test/LLVMDialect/InstCombine/2004-03-13-InstCombineInfLoop.ll.mlir index 5687a1ab5..194394fb0 100644 --- a/test/LLVMDialect/InstCombine/2004-03-13-InstCombineInfLoop.ll.mlir +++ b/test/LLVMDialect/InstCombine/2004-03-13-InstCombineInfLoop.ll.mlir @@ -1,12 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.sub"(%0, %arg0) : (i32, i32) -> i32 - %2 = "llvm.bitcast"(%1) : (i32) -> i32 - %3 = "llvm.sub"(%0, %arg1) : (i32, i32) -> i32 - %4 = "llvm.icmp"(%2, %3) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.bitcast %1 : i32 to i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.icmp "eq" %2, %3 : i32 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2004-04-04-InstCombineReplaceAllUsesWith.ll.mlir b/test/LLVMDialect/InstCombine/2004-04-04-InstCombineReplaceAllUsesWith.ll.mlir new file mode 100644 index 000000000..c2120a519 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2004-04-04-InstCombineReplaceAllUsesWith.ll.mlir @@ -0,0 +1,6 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2004-05-07-UnsizedCastLoad.ll.mlir b/test/LLVMDialect/InstCombine/2004-05-07-UnsizedCastLoad.ll.mlir index 4f1a1221b..3f7d28461 100644 --- a/test/LLVMDialect/InstCombine/2004-05-07-UnsizedCastLoad.ll.mlir +++ b/test/LLVMDialect/InstCombine/2004-05-07-UnsizedCastLoad.ll.mlir @@ -1,9 +1,6 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2004-07-27-ConstantExprMul.ll.mlir b/test/LLVMDialect/InstCombine/2004-07-27-ConstantExprMul.ll.mlir index 38cbd53bd..3bd269cfb 100644 --- a/test/LLVMDialect/InstCombine/2004-07-27-ConstantExprMul.ll.mlir +++ b/test/LLVMDialect/InstCombine/2004-07-27-ConstantExprMul.ll.mlir @@ -1,12 +1,10 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 4 : i64, sym_name = "p", type = i32, value = 0 : i32} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @p} : () -> !llvm.ptr - %1 = "llvm.ptrtoint"(%0) : (!llvm.ptr) -> i32 - %2 = "llvm.mul"(%arg0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global weak @p(0 : i32) {addr_space = 0 : i32} : i32 + llvm.func @test(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @p : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.mul %arg0, %2 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2004-08-09-RemInfLoop.ll.mlir b/test/LLVMDialect/InstCombine/2004-08-09-RemInfLoop.ll.mlir index 24dd42a6a..f5440d863 100644 --- a/test/LLVMDialect/InstCombine/2004-08-09-RemInfLoop.ll.mlir +++ b/test/LLVMDialect/InstCombine/2004-08-09-RemInfLoop.ll.mlir @@ -1,9 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.srem"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.srem %arg0, %0 : i32 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2004-08-10-BoolSetCC.ll.mlir b/test/LLVMDialect/InstCombine/2004-08-10-BoolSetCC.ll.mlir index 8b85d898b..e280a85bb 100644 --- a/test/LLVMDialect/InstCombine/2004-08-10-BoolSetCC.ll.mlir +++ b/test/LLVMDialect/InstCombine/2004-08-10-BoolSetCC.ll.mlir @@ -1,9 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 6 : i64} : (i1, i1) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.icmp "ult" %arg0, %0 : i1 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2004-09-20-BadLoadCombine.ll.mlir b/test/LLVMDialect/InstCombine/2004-09-20-BadLoadCombine.ll.mlir new file mode 100644 index 000000000..290e6ad78 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2004-09-20-BadLoadCombine.ll.mlir @@ -0,0 +1,15 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %0, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %1, %4 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.select %arg0, %3, %4 : i1, !llvm.ptr + llvm.store %2, %3 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2004-09-20-BadLoadCombine2.ll.mlir b/test/LLVMDialect/InstCombine/2004-09-20-BadLoadCombine2.ll.mlir index 31a27d609..696b37c73 100644 --- a/test/LLVMDialect/InstCombine/2004-09-20-BadLoadCombine2.ll.mlir +++ b/test/LLVMDialect/InstCombine/2004-09-20-BadLoadCombine2.ll.mlir @@ -1,20 +1,18 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %4 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - "llvm.store"(%2, %3) : (i32, !llvm.ptr) -> () - "llvm.store"(%1, %4) : (i32, !llvm.ptr) -> () - "llvm.cond_br"(%arg0, %4)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, !llvm.ptr) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %0, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %1, %4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2(%4 : !llvm.ptr) ^bb1: // pred: ^bb0 - "llvm.br"(%3)[^bb2] : (!llvm.ptr) -> () - ^bb2(%5: !llvm.ptr): // 2 preds: ^bb0, ^bb1 - "llvm.store"(%0, %3) : (i32, !llvm.ptr) -> () - %6 = "llvm.load"(%5) : (!llvm.ptr) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.br ^bb2(%3 : !llvm.ptr) + ^bb2(%5: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + llvm.store %2, %3 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2004-09-28-BadShiftAndSetCC.ll.mlir b/test/LLVMDialect/InstCombine/2004-09-28-BadShiftAndSetCC.ll.mlir index 185239951..4ba89fbb7 100644 --- a/test/LLVMDialect/InstCombine/2004-09-28-BadShiftAndSetCC.ll.mlir +++ b/test/LLVMDialect/InstCombine/2004-09-28-BadShiftAndSetCC.ll.mlir @@ -1,13 +1,11 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 167772160 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -16777216 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %3 = "llvm.shl"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.and"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.icmp"(%4, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(-16777216 : i32) : i32 + %2 = llvm.mlir.constant(167772160 : i32) : i32 + %3 = llvm.shl %arg0, %0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2004-11-22-Missed-and-fold.ll.mlir b/test/LLVMDialect/InstCombine/2004-11-22-Missed-and-fold.ll.mlir index 0bf98d120..31060cb98 100644 --- a/test/LLVMDialect/InstCombine/2004-11-22-Missed-and-fold.ll.mlir +++ b/test/LLVMDialect/InstCombine/2004-11-22-Missed-and-fold.ll.mlir @@ -1,11 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.and"(%2, %0) : (i8, i8) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "test21", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test21(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll.mlir b/test/LLVMDialect/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll.mlir new file mode 100644 index 000000000..18fe42a95 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll.mlir @@ -0,0 +1,266 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @a() {addr_space = 0 : i32} : !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.mlir.global common @b(dense<0> : tensor<1xi32>) {addr_space = 0 : i32} : !llvm.array<1 x i32> + llvm.func @lt_signed_to_large_unsigned(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1024 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.icmp "ult" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @PR28011(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi32>) : !llvm.array<1 x i32> + %2 = llvm.mlir.addressof @b : !llvm.ptr + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.mlir.addressof @a : !llvm.ptr + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.sext %arg0 : i16 to i32 + %7 = llvm.icmp "ne" %2, %4 : !llvm.ptr + %8 = llvm.zext %7 : i1 to i32 + %9 = llvm.or %8, %5 : i32 + %10 = llvm.icmp "ne" %6, %9 : i32 + llvm.return %10 : i1 + } + llvm.func @lt_signed_to_large_unsigned_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1024, 2]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @lt_signed_to_large_signed(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1024 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @lt_signed_to_large_negative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1024 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @lt_signed_to_small_unsigned(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(17 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.icmp "ult" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @lt_signed_to_small_signed(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(17 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @lt_signed_to_small_negative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @lt_unsigned_to_large_unsigned(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1024 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.icmp "ult" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @lt_unsigned_to_large_signed(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1024 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @lt_unsigned_to_large_negative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1024 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @lt_unsigned_to_small_unsigned(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(17 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.icmp "ult" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @lt_unsigned_to_small_signed(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(17 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @lt_unsigned_to_small_negative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @gt_signed_to_large_unsigned(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1024 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @gt_signed_to_large_signed(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1024 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @gt_signed_to_large_negative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1024 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @gt_signed_to_small_unsigned(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(17 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @gt_signed_to_small_signed(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(17 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @gt_signed_to_small_negative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @gt_unsigned_to_large_unsigned(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1024 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @gt_unsigned_to_large_signed(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1024 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @gt_unsigned_to_large_negative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1024 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @gt_unsigned_to_small_unsigned(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(17 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @gt_unsigned_to_small_signed(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(17 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @gt_unsigned_to_small_negative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @different_size_zext_zext_ugt(%arg0: i7, %arg1: i4) -> i1 { + %0 = llvm.zext %arg0 : i7 to i25 + %1 = llvm.zext %arg1 : i4 to i25 + %2 = llvm.icmp "ugt" %0, %1 : i25 + llvm.return %2 : i1 + } + llvm.func @different_size_zext_zext_ugt_commute(%arg0: vector<2xi4>, %arg1: vector<2xi7>) -> vector<2xi1> { + %0 = llvm.zext %arg0 : vector<2xi4> to vector<2xi25> + %1 = llvm.zext %arg1 : vector<2xi7> to vector<2xi25> + %2 = llvm.icmp "ugt" %0, %1 : vector<2xi25> + llvm.return %2 : vector<2xi1> + } + llvm.func @different_size_zext_zext_ult(%arg0: i4, %arg1: i7) -> i1 { + %0 = llvm.zext %arg0 : i4 to i25 + %1 = llvm.zext %arg1 : i7 to i25 + %2 = llvm.icmp "ult" %0, %1 : i25 + llvm.return %2 : i1 + } + llvm.func @different_size_zext_zext_eq(%arg0: i4, %arg1: i7) -> i1 { + %0 = llvm.zext %arg0 : i4 to i25 + %1 = llvm.zext %arg1 : i7 to i25 + %2 = llvm.icmp "eq" %0, %1 : i25 + llvm.return %2 : i1 + } + llvm.func @different_size_zext_zext_ne_commute(%arg0: i7, %arg1: i4) -> i1 { + %0 = llvm.zext %arg0 : i7 to i25 + %1 = llvm.zext %arg1 : i4 to i25 + %2 = llvm.icmp "ne" %0, %1 : i25 + llvm.return %2 : i1 + } + llvm.func @different_size_zext_zext_slt(%arg0: i7, %arg1: i4) -> i1 { + %0 = llvm.zext %arg0 : i7 to i25 + %1 = llvm.zext %arg1 : i4 to i25 + %2 = llvm.icmp "slt" %0, %1 : i25 + llvm.return %2 : i1 + } + llvm.func @different_size_zext_zext_sgt(%arg0: i7, %arg1: i4) -> i1 { + %0 = llvm.zext %arg0 : i7 to i25 + %1 = llvm.zext %arg1 : i4 to i25 + %2 = llvm.icmp "sgt" %0, %1 : i25 + llvm.return %2 : i1 + } + llvm.func @different_size_sext_sext_sgt(%arg0: i7, %arg1: i4) -> i1 { + %0 = llvm.sext %arg0 : i7 to i25 + %1 = llvm.sext %arg1 : i4 to i25 + %2 = llvm.icmp "sgt" %0, %1 : i25 + llvm.return %2 : i1 + } + llvm.func @different_size_sext_sext_sle(%arg0: i7, %arg1: i4) -> i1 { + %0 = llvm.sext %arg0 : i7 to i25 + %1 = llvm.sext %arg1 : i4 to i25 + %2 = llvm.icmp "sle" %0, %1 : i25 + llvm.return %2 : i1 + } + llvm.func @different_size_sext_sext_eq(%arg0: i7, %arg1: i4) -> i1 { + %0 = llvm.sext %arg0 : i7 to i25 + %1 = llvm.sext %arg1 : i4 to i25 + %2 = llvm.icmp "eq" %0, %1 : i25 + llvm.return %2 : i1 + } + llvm.func @different_size_sext_sext_ule(%arg0: i7, %arg1: i4) -> i1 { + %0 = llvm.sext %arg0 : i7 to i25 + %1 = llvm.sext %arg1 : i4 to i25 + %2 = llvm.icmp "ule" %0, %1 : i25 + llvm.return %2 : i1 + } + llvm.func @different_size_sext_zext_ne(%arg0: i7, %arg1: i4) -> i1 { + %0 = llvm.sext %arg0 : i7 to i25 + %1 = llvm.zext %arg1 : i4 to i25 + %2 = llvm.icmp "ne" %0, %1 : i25 + llvm.return %2 : i1 + } + llvm.func @use(i25) + llvm.func @different_size_sext_sext_ule_extra_use1(%arg0: i7, %arg1: i4) -> i1 { + %0 = llvm.sext %arg0 : i7 to i25 + %1 = llvm.sext %arg1 : i4 to i25 + llvm.call @use(%1) : (i25) -> () + %2 = llvm.icmp "ule" %0, %1 : i25 + llvm.return %2 : i1 + } + llvm.func @different_size_sext_sext_ule_extra_use2(%arg0: i7, %arg1: i4) -> i1 { + %0 = llvm.sext %arg0 : i7 to i25 + llvm.call @use(%0) : (i25) -> () + %1 = llvm.sext %arg1 : i4 to i25 + %2 = llvm.icmp "ule" %0, %1 : i25 + llvm.return %2 : i1 + } + llvm.func @different_size_sext_sext_ule_extra_use3(%arg0: i7, %arg1: i4) -> i1 { + %0 = llvm.sext %arg0 : i7 to i25 + llvm.call @use(%0) : (i25) -> () + %1 = llvm.sext %arg1 : i4 to i25 + llvm.call @use(%1) : (i25) -> () + %2 = llvm.icmp "ule" %0, %1 : i25 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2004-12-08-RemInfiniteLoop.ll.mlir b/test/LLVMDialect/InstCombine/2004-12-08-RemInfiniteLoop.ll.mlir index d2f1f0dfd..900ba7593 100644 --- a/test/LLVMDialect/InstCombine/2004-12-08-RemInfiniteLoop.ll.mlir +++ b/test/LLVMDialect/InstCombine/2004-12-08-RemInfiniteLoop.ll.mlir @@ -1,9 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.undef"() : () -> i32 - %1 = "llvm.srem"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.undef : i32 + %1 = llvm.srem %arg0, %0 : i32 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2005-03-04-ShiftOverflow.ll.mlir b/test/LLVMDialect/InstCombine/2005-03-04-ShiftOverflow.ll.mlir index 5053ea4b6..3477d6ef2 100644 --- a/test/LLVMDialect/InstCombine/2005-03-04-ShiftOverflow.ll.mlir +++ b/test/LLVMDialect/InstCombine/2005-03-04-ShiftOverflow.ll.mlir @@ -1,11 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.lshr"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i64, i64) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.icmp "ugt" %2, %1 : i64 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2005-04-07-UDivSelectCrash.ll.mlir b/test/LLVMDialect/InstCombine/2005-04-07-UDivSelectCrash.ll.mlir new file mode 100644 index 000000000..debf57d27 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2005-04-07-UDivSelectCrash.ll.mlir @@ -0,0 +1,9 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.select %arg0, %0, %1 : i1, i32 + %3 = llvm.udiv %arg1, %2 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2005-06-15-DivSelectCrash.ll.mlir b/test/LLVMDialect/InstCombine/2005-06-15-DivSelectCrash.ll.mlir new file mode 100644 index 000000000..143893769 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2005-06-15-DivSelectCrash.ll.mlir @@ -0,0 +1,13 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @_Z13func_31585107li(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(-1621308501 : i32) : i32 + %4 = llvm.select %0, %1, %2 : i1, i32 + %5 = llvm.udiv %2, %4 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + %7 = llvm.select %6, %arg1, %3 : i1, i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2005-06-15-ShiftSetCCCrash.ll.mlir b/test/LLVMDialect/InstCombine/2005-06-15-ShiftSetCCCrash.ll.mlir index f1e92f625..bfa12147f 100644 --- a/test/LLVMDialect/InstCombine/2005-06-15-ShiftSetCCCrash.ll.mlir +++ b/test/LLVMDialect/InstCombine/2005-06-15-ShiftSetCCCrash.ll.mlir @@ -1,10 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 41 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.shl"(%1, %0) : (i32, i32) -> i32 - %3 = "llvm.icmp"(%2, %1) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test() -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(41 : i32) : i32 + %2 = llvm.shl %0, %1 : i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2005-06-16-RangeCrash.ll.mlir b/test/LLVMDialect/InstCombine/2005-06-16-RangeCrash.ll.mlir index 9cd877750..b0e278875 100644 --- a/test/LLVMDialect/InstCombine/2005-06-16-RangeCrash.ll.mlir +++ b/test/LLVMDialect/InstCombine/2005-06-16-RangeCrash.ll.mlir @@ -1,10 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = -2147483648 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.sdiv"(%1, %0) : (i32, i32) -> i32 - %3 = "llvm.icmp"(%2, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test() -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.sdiv %0, %1 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2005-07-07-DeadPHILoop.ll.mlir b/test/LLVMDialect/InstCombine/2005-07-07-DeadPHILoop.ll.mlir index c9013225d..87277c1ad 100644 --- a/test/LLVMDialect/InstCombine/2005-07-07-DeadPHILoop.ll.mlir +++ b/test/LLVMDialect/InstCombine/2005-07-07-DeadPHILoop.ll.mlir @@ -1,12 +1,5 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - "llvm.return"() : () -> () - ^bb1(%1: i32): // pred: ^bb1 - %2 = "llvm.sdiv"(%1, %0) : (i32, i32) -> i32 - "llvm.store"(%2, %arg0) : (i32, !llvm.ptr) -> () - "llvm.br"(%2)[^bb1] : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: !llvm.ptr) { + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2006-02-13-DemandedMiscompile.ll.mlir b/test/LLVMDialect/InstCombine/2006-02-13-DemandedMiscompile.ll.mlir index d9d2b4a2a..7bed088e5 100644 --- a/test/LLVMDialect/InstCombine/2006-02-13-DemandedMiscompile.ll.mlir +++ b/test/LLVMDialect/InstCombine/2006-02-13-DemandedMiscompile.ll.mlir @@ -1,10 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.sext"(%arg0) : (i8) -> i32 - %2 = "llvm.ashr"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.ashr %1, %0 : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2006-02-28-Crash.ll.mlir b/test/LLVMDialect/InstCombine/2006-02-28-Crash.ll.mlir index 9579d93d6..c5138e959 100644 --- a/test/LLVMDialect/InstCombine/2006-02-28-Crash.ll.mlir +++ b/test/LLVMDialect/InstCombine/2006-02-28-Crash.ll.mlir @@ -1,10 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - %3 = "llvm.zext"(%2) : (i1) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.icmp "eq" %0, %1 : i32 + %3 = llvm.zext %2 : i1 to i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2006-03-30-ExtractElement.ll.mlir b/test/LLVMDialect/InstCombine/2006-03-30-ExtractElement.ll.mlir new file mode 100644 index 000000000..173aca4f5 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2006-03-30-ExtractElement.ll.mlir @@ -0,0 +1,10 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: vector<4xf32>) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + %4 = llvm.extractelement %3[%2 : i32] : vector<4xf32> + llvm.return %4 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/2006-04-28-ShiftShiftLongLong.ll.mlir b/test/LLVMDialect/InstCombine/2006-04-28-ShiftShiftLongLong.ll.mlir index 45df2a068..c297dccbf 100644 --- a/test/LLVMDialect/InstCombine/2006-04-28-ShiftShiftLongLong.ll.mlir +++ b/test/LLVMDialect/InstCombine/2006-04-28-ShiftShiftLongLong.ll.mlir @@ -1,10 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %1 = "llvm.shl"(%arg0, %0) : (i64, i64) -> i64 - %2 = "llvm.ashr"(%1, %0) : (i64, i64) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.ashr %1, %0 : i64 + llvm.return %2 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/2006-05-04-DemandedBitCrash.ll.mlir b/test/LLVMDialect/InstCombine/2006-05-04-DemandedBitCrash.ll.mlir index 6f97e37c0..23e4543bd 100644 --- a/test/LLVMDialect/InstCombine/2006-05-04-DemandedBitCrash.ll.mlir +++ b/test/LLVMDialect/InstCombine/2006-05-04-DemandedBitCrash.ll.mlir @@ -1,54 +1,53 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 15 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 63 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = false} : () -> i1 - %7 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %8 = "llvm.mlir.constant"() {value = 29 : i32} : () -> i32 - %9 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %10 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %11 = "llvm.mlir.constant"() {value = 123814269237067777 : i64} : () -> i64 - %12 = "llvm.bitcast"(%11) : (i64) -> i64 - %13 = "llvm.bitcast"(%10) : (i32) -> i32 - %14 = "llvm.lshr"(%12, %9) : (i64, i64) -> i64 - %15 = "llvm.trunc"(%14) : (i64) -> i32 - %16 = "llvm.lshr"(%15, %8) : (i32, i32) -> i32 - %17 = "llvm.and"(%16, %10) : (i32, i32) -> i32 - %18 = "llvm.lshr"(%15, %7) : (i32, i32) -> i32 - %19 = "llvm.trunc"(%18) : (i32) -> i8 - "llvm.cond_br"(%6)[^bb6, ^bb1] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test() { + %0 = llvm.mlir.constant(123814269237067777 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(16 : i64) : i64 + %3 = llvm.mlir.constant(29 : i32) : i32 + %4 = llvm.mlir.constant(31 : i32) : i32 + %5 = llvm.mlir.constant(false) : i1 + %6 = llvm.mlir.constant(10 : i32) : i32 + %7 = llvm.mlir.constant(4 : i32) : i32 + %8 = llvm.mlir.constant(63 : i32) : i32 + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.mlir.constant(15 : i32) : i32 + %11 = llvm.mlir.constant(0 : i8) : i8 + %12 = llvm.bitcast %0 : i64 to i64 + %13 = llvm.bitcast %1 : i32 to i32 + %14 = llvm.lshr %12, %2 : i64 + %15 = llvm.trunc %14 : i64 to i32 + %16 = llvm.lshr %15, %3 : i32 + %17 = llvm.and %16, %1 : i32 + %18 = llvm.lshr %15, %4 : i32 + %19 = llvm.trunc %18 : i32 to i8 + llvm.cond_br %5, ^bb6, ^bb1 ^bb1: // pred: ^bb0 - "llvm.cond_br"(%6)[^bb2, ^bb6] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.cond_br %5, ^bb2, ^bb6 ^bb2: // pred: ^bb1 - %20 = "llvm.lshr"(%13, %5) : (i32, i32) -> i32 - %21 = "llvm.lshr"(%13, %4) : (i32, i32) -> i32 - %22 = "llvm.and"(%21, %3) : (i32, i32) -> i32 - %23 = "llvm.icmp"(%22, %4) {predicate = 6 : i64} : (i32, i32) -> i1 - %24 = "llvm.icmp"(%17, %2) {predicate = 0 : i64} : (i32, i32) -> i1 - %25 = "llvm.or"(%23, %6) : (i1, i1) -> i1 - %26 = "llvm.or"(%25, %6) : (i1, i1) -> i1 - %27 = "llvm.or"(%26, %6) : (i1, i1) -> i1 - %28 = "llvm.or"(%27, %24) : (i1, i1) -> i1 - "llvm.cond_br"(%6, %18)[^bb3, ^bb5] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i32) -> () + %20 = llvm.lshr %13, %6 : i32 + %21 = llvm.lshr %13, %7 : i32 + %22 = llvm.and %21, %8 : i32 + %23 = llvm.icmp "ult" %22, %7 : i32 + %24 = llvm.icmp "eq" %17, %9 : i32 + %25 = llvm.or %23, %5 : i1 + %26 = llvm.or %25, %5 : i1 + %27 = llvm.or %26, %5 : i1 + %28 = llvm.or %27, %24 : i1 + llvm.cond_br %5, ^bb3, ^bb5(%18 : i32) ^bb3: // pred: ^bb2 - "llvm.cond_br"(%6, %2)[^bb4, ^bb5] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i32) -> () + llvm.cond_br %5, ^bb4, ^bb5(%9 : i32) ^bb4: // pred: ^bb3 - "llvm.br"()[^bb7] : () -> () + llvm.br ^bb7 ^bb5(%29: i32): // 2 preds: ^bb2, ^bb3 - %30 = "llvm.and"(%20, %1) : (i32, i32) -> i32 - "llvm.br"()[^bb7] : () -> () + %30 = llvm.and %20, %10 : i32 + llvm.br ^bb7 ^bb6: // 2 preds: ^bb0, ^bb1 - %31 = "llvm.icmp"(%17, %2) {predicate = 0 : i64} : (i32, i32) -> i1 - %32 = "llvm.icmp"(%19, %0) {predicate = 0 : i64} : (i8, i8) -> i1 - %33 = "llvm.or"(%31, %32) : (i1, i1) -> i1 - %34 = "llvm.or"(%33, %6) : (i1, i1) -> i1 - "llvm.br"()[^bb7] : () -> () + %31 = llvm.icmp "eq" %17, %9 : i32 + %32 = llvm.icmp "eq" %19, %11 : i8 + %33 = llvm.or %31, %32 : i1 + %34 = llvm.or %33, %5 : i1 + llvm.br ^bb7 ^bb7: // 3 preds: ^bb4, ^bb5, ^bb6 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2006-09-15-CastToBool.ll.mlir b/test/LLVMDialect/InstCombine/2006-09-15-CastToBool.ll.mlir index abecf55c3..266fefcd8 100644 --- a/test/LLVMDialect/InstCombine/2006-09-15-CastToBool.ll.mlir +++ b/test/LLVMDialect/InstCombine/2006-09-15-CastToBool.ll.mlir @@ -1,17 +1,15 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %3 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %4 = "llvm.bitcast"(%3) : (i32) -> i32 - %5 = "llvm.lshr"(%4, %2) : (i32, i32) -> i32 - %6 = "llvm.bitcast"(%5) : (i32) -> i32 - %7 = "llvm.and"(%6, %1) : (i32, i32) -> i32 - %8 = "llvm.icmp"(%7, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - %9 = "llvm.zext"(%8) : (i1) -> i32 - "llvm.return"(%9) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.bitcast %3 : i32 to i32 + %5 = llvm.lshr %4, %0 : i32 + %6 = llvm.bitcast %5 : i32 to i32 + %7 = llvm.and %6, %1 : i32 + %8 = llvm.icmp "ne" %7, %2 : i32 + %9 = llvm.zext %8 : i1 to i32 + llvm.return %9 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll.mlir b/test/LLVMDialect/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll.mlir index 5690bca00..c21521e50 100644 --- a/test/LLVMDialect/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll.mlir @@ -1,10 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 17 : i32} : () -> i32 - %1 = "llvm.sext"(%arg0) : (i8) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "eq_signed_to_small_unsigned", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @eq_signed_to_small_unsigned(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(17 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2006-10-20-mask.ll.mlir b/test/LLVMDialect/InstCombine/2006-10-20-mask.ll.mlir index 3c6e20273..5103eee4e 100644 --- a/test/LLVMDialect/InstCombine/2006-10-20-mask.ll.mlir +++ b/test/LLVMDialect/InstCombine/2006-10-20-mask.ll.mlir @@ -1,11 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - %0 = "llvm.trunc"(%arg0) : (i64) -> i32 - %1 = "llvm.trunc"(%arg1) : (i64) -> i32 - %2 = "llvm.and"(%0, %1) : (i32, i32) -> i32 - %3 = "llvm.zext"(%2) : (i32) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.trunc %arg0 : i64 to i32 + %1 = llvm.trunc %arg1 : i64 to i32 + %2 = llvm.and %0, %1 : i32 + %3 = llvm.zext %2 : i32 to i64 + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/2006-10-26-VectorReassoc.ll.mlir b/test/LLVMDialect/InstCombine/2006-10-26-VectorReassoc.ll.mlir index efea69601..3236686c3 100644 --- a/test/LLVMDialect/InstCombine/2006-10-26-VectorReassoc.ll.mlir +++ b/test/LLVMDialect/InstCombine/2006-10-26-VectorReassoc.ll.mlir @@ -1,103 +1,90 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+05, -3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %2 = "llvm.fmul"(%arg0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %3 = "llvm.fmul"(%2, %0) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%3) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_fmul", type = !llvm.func (vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+05, -3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %2 = "llvm.fmul"(%arg0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %3 = "llvm.fmul"(%2, %0) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%3) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_fmul_fast", type = !llvm.func (vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+05, -3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %2 = "llvm.fmul"(%arg0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %3 = "llvm.fmul"(%2, %0) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%3) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_fmul_reassoc_nsz", type = !llvm.func (vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+05, -3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %2 = "llvm.fmul"(%arg0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %3 = "llvm.fmul"(%2, %0) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%3) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_fmul_reassoc", type = !llvm.func (vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, -3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %2 = "llvm.fadd"(%arg0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %3 = "llvm.fadd"(%2, %0) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%3) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_fadd", type = !llvm.func (vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, -3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %2 = "llvm.fadd"(%arg0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %3 = "llvm.fadd"(%2, %0) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%3) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_fadd_fast", type = !llvm.func (vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, -3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %2 = "llvm.fadd"(%arg0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %3 = "llvm.fadd"(%2, %0) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%3) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_fadd_reassoc_nsz", type = !llvm.func (vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, -3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %2 = "llvm.fadd"(%arg0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %3 = "llvm.fadd"(%2, %0) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%3) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_fadd_reassoc", type = !llvm.func (vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>, %arg1: vector<4xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[-1.000000e+00, -2.000000e+00, -3.000000e+00, -4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %2 = "llvm.fadd"(%arg0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %3 = "llvm.fadd"(%arg1, %0) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %4 = "llvm.fadd"(%2, %3) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%4) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_fadds_cancel_", type = !llvm.func (vector<4xf32>, vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>, %arg1: vector<4xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[-1.000000e+00, -2.000000e+00, -3.000000e+00, -4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %2 = "llvm.fadd"(%arg0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %3 = "llvm.fadd"(%arg1, %0) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %4 = "llvm.fadd"(%2, %3) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%4) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_fadds_cancel_fast", type = !llvm.func (vector<4xf32>, vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>, %arg1: vector<4xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[-1.000000e+00, -2.000000e+00, -3.000000e+00, -4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %2 = "llvm.fadd"(%arg0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %3 = "llvm.fadd"(%arg1, %0) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %4 = "llvm.fadd"(%2, %3) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%4) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_fadds_cancel_reassoc_nsz", type = !llvm.func (vector<4xf32>, vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>, %arg1: vector<4xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[-1.000000e+00, -2.000000e+00, -3.000000e+00, -4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %2 = "llvm.fadd"(%arg0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %3 = "llvm.fadd"(%arg1, %0) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %4 = "llvm.fadd"(%2, %3) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%4) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_fadds_cancel_reassoc", type = !llvm.func (vector<4xf32>, vector<4xf32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_fmul(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+05, -3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fmul %arg0, %0 : vector<4xf32> + %3 = llvm.fmul %2, %1 : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @test_fmul_fast(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+05, -3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.fmul %2, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @test_fmul_reassoc_nsz(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+05, -3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.fmul %2, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @test_fmul_reassoc(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+05, -3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.fmul %2, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @test_fadd(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, -3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fadd %arg0, %0 : vector<4xf32> + %3 = llvm.fadd %2, %1 : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @test_fadd_fast(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, -3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @test_fadd_reassoc_nsz(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, -3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @test_fadd_reassoc(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, -3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @test_fadds_cancel_(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[-1.000000e+00, -2.000000e+00, -3.000000e+00, -4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fadd %arg0, %0 : vector<4xf32> + %3 = llvm.fadd %arg1, %1 : vector<4xf32> + %4 = llvm.fadd %2, %3 : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @test_fadds_cancel_fast(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[-1.000000e+00, -2.000000e+00, -3.000000e+00, -4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.fadd %arg1, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @test_fadds_cancel_reassoc_nsz(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[-1.000000e+00, -2.000000e+00, -3.000000e+00, -4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.fadd %arg1, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @test_fadds_cancel_reassoc(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[-1.000000e+00, -2.000000e+00, -3.000000e+00, -4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.fadd %arg1, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %4 : vector<4xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/2006-11-10-ashr-miscompile.ll.mlir b/test/LLVMDialect/InstCombine/2006-11-10-ashr-miscompile.ll.mlir index 8f9255412..07532c3ce 100644 --- a/test/LLVMDialect/InstCombine/2006-11-10-ashr-miscompile.ll.mlir +++ b/test/LLVMDialect/InstCombine/2006-11-10-ashr-miscompile.ll.mlir @@ -1,10 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i8) -> i32 - %2 = "llvm.lshr"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.lshr %0, %1 : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2006-12-01-BadFPVectorXform.ll.mlir b/test/LLVMDialect/InstCombine/2006-12-01-BadFPVectorXform.ll.mlir index 052117933..c29ee71bf 100644 --- a/test/LLVMDialect/InstCombine/2006-12-01-BadFPVectorXform.ll.mlir +++ b/test/LLVMDialect/InstCombine/2006-12-01-BadFPVectorXform.ll.mlir @@ -1,9 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>, %arg1: vector<4xf32>): // no predecessors - %0 = "llvm.fadd"(%arg0, %arg1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %1 = "llvm.fsub"(%0, %arg1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%1) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func (vector<4xf32>, vector<4xf32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.fadd %arg0, %arg1 : vector<4xf32> + %1 = llvm.fsub %0, %arg1 : vector<4xf32> + llvm.return %1 : vector<4xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/2006-12-05-fp-to-int-ext.ll.mlir b/test/LLVMDialect/InstCombine/2006-12-05-fp-to-int-ext.ll.mlir index b6c375d4c..29f766e84 100644 --- a/test/LLVMDialect/InstCombine/2006-12-05-fp-to-int-ext.ll.mlir +++ b/test/LLVMDialect/InstCombine/2006-12-05-fp-to-int-ext.ll.mlir @@ -1,9 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.fptoui"(%arg0) : (f64) -> i32 - %1 = "llvm.zext"(%0) : (i32) -> i64 - "llvm.return"(%1) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: f64) -> i64 { + %0 = llvm.fptoui %arg0 : f64 to i32 + %1 = llvm.zext %0 : i32 to i64 + llvm.return %1 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/2006-12-08-Phi-ICmp-Op-Fold.ll.mlir b/test/LLVMDialect/InstCombine/2006-12-08-Phi-ICmp-Op-Fold.ll.mlir index 38f6e02d8..2604fb051 100644 --- a/test/LLVMDialect/InstCombine/2006-12-08-Phi-ICmp-Op-Fold.ll.mlir +++ b/test/LLVMDialect/InstCombine/2006-12-08-Phi-ICmp-Op-Fold.ll.mlir @@ -1,46 +1,37 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i64, %arg2: i64, %arg3: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr> - %4 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr> - %5 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr> - %6 = "llvm.bitcast"(%1) : (i32) -> i32 - %7 = "llvm.bitcast"(%3) : (!llvm.ptr>) -> !llvm.ptr> - %8 = "llvm.getelementptr"(%7, %0, %1) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - "llvm.store"(%arg1, %8) : (i64, !llvm.ptr) -> () - %9 = "llvm.bitcast"(%4) : (!llvm.ptr>) -> !llvm.ptr> - %10 = "llvm.getelementptr"(%9, %0, %1) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - "llvm.store"(%arg2, %10) : (i64, !llvm.ptr) -> () - %11 = "llvm.bitcast"(%5) : (!llvm.ptr>) -> !llvm.ptr> - %12 = "llvm.getelementptr"(%11, %0, %1) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - "llvm.store"(%arg3, %12) : (i64, !llvm.ptr) -> () - %13 = "llvm.icmp"(%arg0, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - %14 = "llvm.bitcast"(%3) : (!llvm.ptr>) -> !llvm.ptr> - %15 = "llvm.getelementptr"(%14, %0, %1) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - %16 = "llvm.load"(%15) : (!llvm.ptr) -> i64 - %17 = "llvm.bitcast"(%4) : (!llvm.ptr>) -> !llvm.ptr> - %18 = "llvm.getelementptr"(%17, %0, %1) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - %19 = "llvm.load"(%18) : (!llvm.ptr) -> i64 - %20 = "llvm.bitcast"(%5) : (!llvm.ptr>) -> !llvm.ptr> - %21 = "llvm.getelementptr"(%20, %0, %1) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - %22 = "llvm.load"(%21) : (!llvm.ptr) -> i64 - %23 = "llvm.call"(%16, %19, %22) {callee = @determinant, fastmathFlags = #llvm.fastmath<>} : (i64, i64, i64) -> i32 - "llvm.cond_br"(%13)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @visible(%arg0: i32, %arg1: i64, %arg2: i64, %arg3: i64) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.alloca %0 x !llvm.struct<"struct.point", (i32, i32)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x !llvm.struct<"struct.point", (i32, i32)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %5 = llvm.alloca %0 x !llvm.struct<"struct.point", (i32, i32)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %6 = llvm.bitcast %1 : i32 to i32 + %7 = llvm.getelementptr %3[%2, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64)> + llvm.store %arg1, %7 {alignment = 4 : i64} : i64, !llvm.ptr + %8 = llvm.getelementptr %4[%2, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64)> + llvm.store %arg2, %8 {alignment = 4 : i64} : i64, !llvm.ptr + %9 = llvm.getelementptr %5[%2, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64)> + llvm.store %arg3, %9 {alignment = 4 : i64} : i64, !llvm.ptr + %10 = llvm.icmp "eq" %arg0, %1 : i32 + %11 = llvm.getelementptr %3[%2, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64)> + %12 = llvm.load %11 {alignment = 4 : i64} : !llvm.ptr -> i64 + %13 = llvm.getelementptr %4[%2, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64)> + %14 = llvm.load %13 {alignment = 4 : i64} : !llvm.ptr -> i64 + %15 = llvm.getelementptr %5[%2, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64)> + %16 = llvm.load %15 {alignment = 4 : i64} : !llvm.ptr -> i64 + %17 = llvm.call @determinant(%12, %14, %16) : (i64, i64, i64) -> i32 + llvm.cond_br %10, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %24 = "llvm.icmp"(%23, %1) {predicate = 2 : i64} : (i32, i32) -> i1 - %25 = "llvm.zext"(%24) : (i1) -> i32 - "llvm.br"(%25)[^bb3] : (i32) -> () + %18 = llvm.icmp "slt" %17, %1 : i32 + %19 = llvm.zext %18 : i1 to i32 + llvm.br ^bb3(%19 : i32) ^bb2: // pred: ^bb0 - %26 = "llvm.icmp"(%23, %1) {predicate = 4 : i64} : (i32, i32) -> i1 - %27 = "llvm.zext"(%26) : (i1) -> i32 - "llvm.br"(%27)[^bb3] : (i32) -> () - ^bb3(%28: i32): // 2 preds: ^bb1, ^bb2 - "llvm.return"(%28) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "visible", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "determinant", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %20 = llvm.icmp "sgt" %17, %1 : i32 + %21 = llvm.zext %20 : i1 to i32 + llvm.br ^bb3(%21 : i32) + ^bb3(%22: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %22 : i32 + } + llvm.func @determinant(i64, i64, i64) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/2006-12-08-Select-ICmp.ll.mlir b/test/LLVMDialect/InstCombine/2006-12-08-Select-ICmp.ll.mlir new file mode 100644 index 000000000..94d0c503d --- /dev/null +++ b/test/LLVMDialect/InstCombine/2006-12-08-Select-ICmp.ll.mlir @@ -0,0 +1,29 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @visible(%arg0: i32, %arg1: i64, %arg2: i64, %arg3: i64) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x !llvm.struct<"struct.point", (i32, i32)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %3 = llvm.alloca %0 x !llvm.struct<"struct.point", (i32, i32)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x !llvm.struct<"struct.point", (i32, i32)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %5 = llvm.getelementptr %2[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i64)> + llvm.store %arg1, %5 {alignment = 4 : i64} : i64, !llvm.ptr + %6 = llvm.getelementptr %3[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i64)> + llvm.store %arg2, %6 {alignment = 4 : i64} : i64, !llvm.ptr + %7 = llvm.getelementptr %4[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i64)> + llvm.store %arg3, %7 {alignment = 4 : i64} : i64, !llvm.ptr + %8 = llvm.icmp "eq" %arg0, %1 : i32 + %9 = llvm.getelementptr %2[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i64)> + %10 = llvm.load %9 {alignment = 4 : i64} : !llvm.ptr -> i64 + %11 = llvm.getelementptr %3[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i64)> + %12 = llvm.load %11 {alignment = 4 : i64} : !llvm.ptr -> i64 + %13 = llvm.getelementptr %4[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i64)> + %14 = llvm.load %13 {alignment = 4 : i64} : !llvm.ptr -> i64 + %15 = llvm.call @determinant(%10, %12, %14) : (i64, i64, i64) -> i32 + %16 = llvm.icmp "slt" %15, %1 : i32 + %17 = llvm.icmp "sgt" %15, %1 : i32 + %18 = llvm.select %8, %16, %17 : i1, i1 + %19 = llvm.zext %18 : i1 to i32 + llvm.return %19 : i32 + } + llvm.func @determinant(i64, i64, i64) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/2006-12-15-Range-Test.ll.mlir b/test/LLVMDialect/InstCombine/2006-12-15-Range-Test.ll.mlir new file mode 100644 index 000000000..788fbf41c --- /dev/null +++ b/test/LLVMDialect/InstCombine/2006-12-15-Range-Test.ll.mlir @@ -0,0 +1,47 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @r() {addr_space = 0 : i32} : !llvm.array<17 x i32> + llvm.func @print_pgm_cond_true(%arg0: i32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.addressof @r : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-31 : i32) : i32 + %3 = llvm.mlir.constant(31 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(true) : i1 + llvm.br ^bb3 + ^bb1: // pred: ^bb3 + llvm.store %7, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %5 : i1 + ^bb2: // pred: ^bb3 + llvm.store %7, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %4 : i1 + ^bb3: // pred: ^bb0 + %6 = llvm.getelementptr %0[%1, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<17 x i32> + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + %8 = llvm.icmp "slt" %7, %2 : i32 + %9 = llvm.icmp "sgt" %7, %3 : i32 + %10 = llvm.or %8, %9 : i1 + llvm.cond_br %10, ^bb1, ^bb2 + } + llvm.func @print_pgm_cond_true_logical(%arg0: i32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.addressof @r : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-31 : i32) : i32 + %3 = llvm.mlir.constant(31 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.mlir.constant(false) : i1 + llvm.br ^bb3 + ^bb1: // pred: ^bb3 + llvm.store %7, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %4 : i1 + ^bb2: // pred: ^bb3 + llvm.store %7, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %5 : i1 + ^bb3: // pred: ^bb0 + %6 = llvm.getelementptr %0[%1, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<17 x i32> + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + %8 = llvm.icmp "slt" %7, %2 : i32 + %9 = llvm.icmp "sgt" %7, %3 : i32 + %10 = llvm.select %8, %4, %9 : i1, i1 + llvm.cond_br %10, ^bb1, ^bb2 + } +} diff --git a/test/LLVMDialect/InstCombine/2006-12-23-Select-Cmp-Cmp.ll.mlir b/test/LLVMDialect/InstCombine/2006-12-23-Select-Cmp-Cmp.ll.mlir new file mode 100644 index 000000000..68cebf258 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2006-12-23-Select-Cmp-Cmp.ll.mlir @@ -0,0 +1,18 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @mng_write_basi(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(8 : i8) : i8 + %1 = llvm.mlir.constant(255 : i16) : i16 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %4 = llvm.icmp "ugt" %3, %0 : i8 + %5 = llvm.load %arg1 {alignment = 2 : i64} : !llvm.ptr -> i16 + %6 = llvm.icmp "eq" %5, %1 : i16 + %7 = llvm.icmp "eq" %5, %2 : i16 + %8 = llvm.select %4, %7, %6 : i1, i1 + llvm.cond_br %8, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2007-01-13-ExtCompareMiscompile.ll.mlir b/test/LLVMDialect/InstCombine/2007-01-13-ExtCompareMiscompile.ll.mlir index b20a3e566..5ac3a3d53 100644 --- a/test/LLVMDialect/InstCombine/2007-01-13-ExtCompareMiscompile.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-01-13-ExtCompareMiscompile.ll.mlir @@ -1,10 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.icmp "sgt" %0, %1 : i32 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-01-18-VectorInfLoop.ll.mlir b/test/LLVMDialect/InstCombine/2007-01-18-VectorInfLoop.ll.mlir index 7f743c4b5..086fc28c0 100644 --- a/test/LLVMDialect/InstCombine/2007-01-18-VectorInfLoop.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-01-18-VectorInfLoop.ll.mlir @@ -1,10 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-1> : vector<4xi32>} : () -> vector<4xi32> - %1 = "llvm.xor"(%arg0, %0) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - %2 = "llvm.and"(%1, %0) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - "llvm.return"(%2) : (vector<4xi32>) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func (vector<4xi32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.xor %arg0, %0 : vector<4xi32> + %2 = llvm.and %1, %0 : vector<4xi32> + llvm.return %2 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/2007-02-01-LoadSinkAlloca.ll.mlir b/test/LLVMDialect/InstCombine/2007-02-01-LoadSinkAlloca.ll.mlir index 3633a5606..97d4090a4 100644 --- a/test/LLVMDialect/InstCombine/2007-02-01-LoadSinkAlloca.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-02-01-LoadSinkAlloca.ll.mlir @@ -1,40 +1,36 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 123 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %4 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %5 = "llvm.call"(%3) {callee = @bar, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - %6 = "llvm.load"(%3) : (!llvm.ptr) -> i32 - %7 = "llvm.icmp"(%arg0, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%7, %6)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(123 : i32) : i32 + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %5 = llvm.call @bar(%3) vararg(!llvm.func) : (!llvm.ptr) -> i32 + %6 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + %7 = llvm.icmp "eq" %arg0, %1 : i32 + llvm.cond_br %7, ^bb2(%6 : i32), ^bb1 ^bb1: // pred: ^bb0 - "llvm.store"(%0, %4) : (i32, !llvm.ptr) -> () - %8 = "llvm.call"(%0) {callee = @test2, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %9 = "llvm.load"(%4) : (!llvm.ptr) -> i32 - "llvm.br"(%9)[^bb2] : (i32) -> () + llvm.store %2, %4 {alignment = 4 : i64} : i32, !llvm.ptr + %8 = llvm.call @test2(%2) : (i32) -> i32 + %9 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb2(%9 : i32) ^bb2(%10: i32): // 2 preds: ^bb0, ^bb1 - %11 = "llvm.call"() {callee = @baq, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %12 = "llvm.call"() {callee = @baq, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %13 = "llvm.call"() {callee = @baq, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %14 = "llvm.call"() {callee = @baq, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %15 = "llvm.call"() {callee = @baq, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %16 = "llvm.call"() {callee = @baq, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %17 = "llvm.call"() {callee = @baq, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %18 = "llvm.call"() {callee = @baq, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %19 = "llvm.call"() {callee = @baq, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %20 = "llvm.call"() {callee = @baq, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %21 = "llvm.call"() {callee = @baq, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %22 = "llvm.call"() {callee = @baq, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %23 = "llvm.call"() {callee = @baq, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %24 = "llvm.call"() {callee = @baq, fastmathFlags = #llvm.fastmath<>} : () -> i32 - "llvm.return"(%10) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "baq", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %11 = llvm.call @baq() vararg(!llvm.func) : () -> i32 + %12 = llvm.call @baq() vararg(!llvm.func) : () -> i32 + %13 = llvm.call @baq() vararg(!llvm.func) : () -> i32 + %14 = llvm.call @baq() vararg(!llvm.func) : () -> i32 + %15 = llvm.call @baq() vararg(!llvm.func) : () -> i32 + %16 = llvm.call @baq() vararg(!llvm.func) : () -> i32 + %17 = llvm.call @baq() vararg(!llvm.func) : () -> i32 + %18 = llvm.call @baq() vararg(!llvm.func) : () -> i32 + %19 = llvm.call @baq() vararg(!llvm.func) : () -> i32 + %20 = llvm.call @baq() vararg(!llvm.func) : () -> i32 + %21 = llvm.call @baq() vararg(!llvm.func) : () -> i32 + %22 = llvm.call @baq() vararg(!llvm.func) : () -> i32 + %23 = llvm.call @baq() vararg(!llvm.func) : () -> i32 + %24 = llvm.call @baq() vararg(!llvm.func) : () -> i32 + llvm.return %10 : i32 + } + llvm.func @bar(...) -> i32 + llvm.func @baq(...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/2007-02-07-PointerCast.ll.mlir b/test/LLVMDialect/InstCombine/2007-02-07-PointerCast.ll.mlir index e06980a91..4e38ffe67 100644 --- a/test/LLVMDialect/InstCombine/2007-02-07-PointerCast.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-02-07-PointerCast.ll.mlir @@ -1,19 +1,16 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 1 : i64, sym_name = "str", type = !llvm.array<6 x i8>, value = "%llx\0A\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "printf", type = !llvm.func, ...)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @str} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %0) : (!llvm.ptr>, i32, i64) -> !llvm.ptr - %4 = "llvm.load"(%arg1) : (!llvm.ptr>) -> !llvm.ptr - %5 = "llvm.ptrtoint"(%4) : (!llvm.ptr) -> i32 - %6 = "llvm.zext"(%5) : (i32) -> i64 - %7 = "llvm.call"(%3, %6) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "main", type = !llvm.func>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal constant @str("%llx\0A\00") {addr_space = 0 : i32, dso_local} + llvm.func @printf(!llvm.ptr, ...) -> i32 + llvm.func @main(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant("%llx\0A\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @str : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i64) -> !llvm.ptr, !llvm.array<6 x i8> + %5 = llvm.load %arg1 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %6 = llvm.ptrtoint %5 : !llvm.ptr to i32 + %7 = llvm.zext %6 : i32 to i64 + %8 = llvm.call @printf(%4, %7) vararg(!llvm.func) : (!llvm.ptr, i64) -> i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-02-23-PhiFoldInfLoop.ll.mlir b/test/LLVMDialect/InstCombine/2007-02-23-PhiFoldInfLoop.ll.mlir new file mode 100644 index 000000000..830203c84 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2007-02-23-PhiFoldInfLoop.ll.mlir @@ -0,0 +1,21 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @ggenorien() { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.icmp "eq" %0, %0 : !llvm.ptr + llvm.cond_br %4, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.cond_br %2, ^bb5(%1 : i32), ^bb3 + ^bb3: // pred: ^bb2 + llvm.br ^bb4(%1 : i32) + ^bb4(%5: i32): // 2 preds: ^bb3, ^bb5 + %6 = llvm.add %5, %3 : i32 + llvm.br ^bb5(%6 : i32) + ^bb5(%7: i32): // 2 preds: ^bb2, ^bb4 + llvm.br ^bb4(%7 : i32) + } +} diff --git a/test/LLVMDialect/InstCombine/2007-03-13-CompareMerge.ll.mlir b/test/LLVMDialect/InstCombine/2007-03-13-CompareMerge.ll.mlir new file mode 100644 index 000000000..da96dd6d1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2007-03-13-CompareMerge.ll.mlir @@ -0,0 +1,15 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "slt" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg0, %arg1 : i32 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-03-19-BadTruncChangePR1261.ll.mlir b/test/LLVMDialect/InstCombine/2007-03-19-BadTruncChangePR1261.ll.mlir index 967f8ffdd..e1929dc3d 100644 --- a/test/LLVMDialect/InstCombine/2007-03-19-BadTruncChangePR1261.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-03-19-BadTruncChangePR1261.ll.mlir @@ -1,13 +1,11 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i31): // no predecessors - %0 = "llvm.mlir.constant"() {value = 15 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 16384 : i32} : () -> i32 - %2 = "llvm.sext"(%arg0) : (i31) -> i32 - %3 = "llvm.add"(%2, %1) : (i32, i32) -> i32 - %4 = "llvm.lshr"(%3, %0) : (i32, i32) -> i32 - %5 = "llvm.trunc"(%4) : (i32) -> i16 - "llvm.return"(%5) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i31) -> i16 { + %0 = llvm.mlir.constant(16384 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.sext %arg0 : i31 to i32 + %3 = llvm.add %2, %0 : i32 + %4 = llvm.lshr %3, %1 : i32 + %5 = llvm.trunc %4 : i32 to i16 + llvm.return %5 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-03-21-SignedRangeTest.ll.mlir b/test/LLVMDialect/InstCombine/2007-03-21-SignedRangeTest.ll.mlir index ea46b7af4..39417385e 100644 --- a/test/LLVMDialect/InstCombine/2007-03-21-SignedRangeTest.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-03-21-SignedRangeTest.ll.mlir @@ -1,19 +1,16 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 12 : i32} : () -> i32 - %2 = "llvm.sdiv"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-6> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.mlir.constant"() {value = dense<12> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.sdiv"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (vector<2xi32>, vector<2xi32>) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(-6 : i32) : i32 + %2 = llvm.sdiv %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<12> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-6> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sdiv %arg0, %0 : vector<2xi32> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/2007-03-25-BadShiftMask.ll.mlir b/test/LLVMDialect/InstCombine/2007-03-25-BadShiftMask.ll.mlir index 12ce73749..aaf4fba9b 100644 --- a/test/LLVMDialect/InstCombine/2007-03-25-BadShiftMask.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-03-25-BadShiftMask.ll.mlir @@ -1,29 +1,25 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 2047 : i16} : () -> i16 - %2 = "llvm.mlir.constant"() {value = 21 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 0x7FF0000000000000 : f64} : () -> f64 - %4 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %6 = "llvm.alloca"(%5) : (i32) -> !llvm.ptr> - %7 = "llvm.getelementptr"(%6, %4, %4) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - "llvm.store"(%3, %7) : (f64, !llvm.ptr) -> () - %8 = "llvm.getelementptr"(%6, %4, %4) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %9 = "llvm.bitcast"(%8) : (!llvm.ptr) -> !llvm.ptr> - %10 = "llvm.getelementptr"(%9, %4, %5) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %11 = "llvm.load"(%10) : (!llvm.ptr) -> i32 - %12 = "llvm.shl"(%11, %5) : (i32, i32) -> i32 - %13 = "llvm.lshr"(%12, %2) : (i32, i32) -> i32 - %14 = "llvm.trunc"(%13) : (i32) -> i16 - %15 = "llvm.icmp"(%14, %1) {predicate = 1 : i64} : (i16, i16) -> i1 - %16 = "llvm.zext"(%15) : (i1) -> i8 - %17 = "llvm.icmp"(%16, %0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.cond_br"(%17)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @main() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0x7FF0000000000000 : f64) : f64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(21 : i32) : i32 + %4 = llvm.mlir.constant(2047 : i16) : i16 + %5 = llvm.mlir.constant(0 : i8) : i8 + %6 = llvm.alloca %0 x !llvm.struct<"struct..1anon", (f64)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %6 {alignment = 8 : i64} : f64, !llvm.ptr + %7 = llvm.getelementptr %6[%2, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct..0anon", (i32, i32)> + %8 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + %9 = llvm.shl %8, %0 : i32 + %10 = llvm.lshr %9, %3 : i32 + %11 = llvm.trunc %10 : i32 to i16 + %12 = llvm.icmp "ne" %11, %4 : i16 + %13 = llvm.zext %12 : i1 to i8 + %14 = llvm.icmp "ne" %13, %5 : i8 + llvm.cond_br %14, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.return"(%4) : (i32) -> () + llvm.return %2 : i32 ^bb2: // pred: ^bb0 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "main", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-03-25-DoubleShift.ll.mlir b/test/LLVMDialect/InstCombine/2007-03-25-DoubleShift.ll.mlir index 59dedf8df..737d17950 100644 --- a/test/LLVMDialect/InstCombine/2007-03-25-DoubleShift.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-03-25-DoubleShift.ll.mlir @@ -1,12 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 12 : i32} : () -> i32 - %2 = "llvm.shl"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.lshr"(%2, %1) : (i32, i32) -> i32 - %4 = "llvm.icmp"(%3, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.lshr %2, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-03-26-BadShiftMask.ll.mlir b/test/LLVMDialect/InstCombine/2007-03-26-BadShiftMask.ll.mlir index b6fe74be2..edf9f9eb0 100644 --- a/test/LLVMDialect/InstCombine/2007-03-26-BadShiftMask.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-03-26-BadShiftMask.ll.mlir @@ -1,33 +1,31 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32, %arg3: i32, %arg4: !llvm.ptr, %arg5: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = true} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %7 = "llvm.and"(%arg2, %6) : (i32, i32) -> i32 - %8 = "llvm.shl"(%7, %5) : (i32, i32) -> i32 - %9 = "llvm.ashr"(%arg2, %6) : (i32, i32) -> i32 - %10 = "llvm.shl"(%9, %5) : (i32, i32) -> i32 - %11 = "llvm.ashr"(%8, %4) : (i32, i32) -> i32 - "llvm.store"(%11, %arg0) : (i32, !llvm.ptr) -> () - %12 = "llvm.ashr"(%10, %4) : (i32, i32) -> i32 - "llvm.store"(%12, %arg1) : (i32, !llvm.ptr) -> () - %13 = "llvm.icmp"(%arg3, %3) {predicate = 0 : i64} : (i32, i32) -> i1 - %14 = "llvm.zext"(%13) : (i1) -> i8 - %15 = "llvm.icmp"(%14, %2) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.cond_br"(%15)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32, %arg3: i32, %arg4: !llvm.ptr, %arg5: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(0 : i8) : i8 + %5 = llvm.mlir.constant(false) : i1 + %6 = llvm.mlir.constant(true) : i1 + %7 = llvm.and %arg2, %0 : i32 + %8 = llvm.shl %7, %1 : i32 + %9 = llvm.ashr %arg2, %0 : i32 + %10 = llvm.shl %9, %1 : i32 + %11 = llvm.ashr %8, %2 : i32 + llvm.store %11, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %12 = llvm.ashr %10, %2 : i32 + llvm.store %12, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %13 = llvm.icmp "eq" %arg3, %3 : i32 + %14 = llvm.zext %13 : i1 to i8 + %15 = llvm.icmp "ne" %14, %4 : i8 + llvm.cond_br %15, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.store"(%8, %arg4) : (i32, !llvm.ptr) -> () - "llvm.store"(%10, %arg5) : (i32, !llvm.ptr) -> () - "llvm.return"(%1) : (i1) -> () + llvm.store %8, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %10, %arg5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %6 : i1 ^bb2: // pred: ^bb0 - "llvm.store"(%8, %arg4) : (i32, !llvm.ptr) -> () - "llvm.store"(%10, %arg5) : (i32, !llvm.ptr) -> () - "llvm.return"(%0) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func, ptr, i32, i32, ptr, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.store %8, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %10, %arg5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-04-08-SingleEltVectorCrash.ll.mlir b/test/LLVMDialect/InstCombine/2007-04-08-SingleEltVectorCrash.ll.mlir new file mode 100644 index 000000000..2e5281960 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2007-04-08-SingleEltVectorCrash.ll.mlir @@ -0,0 +1,7 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bork(%arg0: vector<1xi64>) -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.extractelement %arg0[%0 : i32] : vector<1xi64> + llvm.return %1 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-05-10-icmp-or.ll.mlir b/test/LLVMDialect/InstCombine/2007-05-10-icmp-or.ll.mlir new file mode 100644 index 000000000..7728c03df --- /dev/null +++ b/test/LLVMDialect/InstCombine/2007-05-10-icmp-or.ll.mlir @@ -0,0 +1,17 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.icmp "ugt" %arg0, %0 : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @test_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ugt" %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-05-14-Crash.ll.mlir b/test/LLVMDialect/InstCombine/2007-05-14-Crash.ll.mlir index 678c7184f..b0bf0a3db 100644 --- a/test/LLVMDialect/InstCombine/2007-05-14-Crash.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-05-14-Crash.ll.mlir @@ -1,12 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr)>>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr>, struct<"struct.abc", (i32, array<32 x i8>)>)>> - %3 = "llvm.getelementptr"(%2, %1, %0) : (!llvm.ptr>, struct<"struct.abc", (i32, array<32 x i8>)>)>>, i32, i32) -> !llvm.ptr)>> - %4 = "llvm.bitcast"(%3) : (!llvm.ptr)>>) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func (ptr>, ptr)>>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "big">>} { + llvm.func @foo(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.getelementptr %arg0[%0, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.def", (ptr, struct<"struct.abc", (i32, array<32 x i8>)>)> + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/2007-05-18-CastFoldBug.ll.mlir b/test/LLVMDialect/InstCombine/2007-05-18-CastFoldBug.ll.mlir index 2de6c6bfb..e298530aa 100644 --- a/test/LLVMDialect/InstCombine/2007-05-18-CastFoldBug.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-05-18-CastFoldBug.ll.mlir @@ -1,12 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @objc_msgSend_stret} : () -> !llvm.ptr (ptr, ptr, ...)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr (ptr, ptr, ...)>>) -> !llvm.ptr)>> - "llvm.call"(%1, %arg0) : (!llvm.ptr)>>, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "blah", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "objc_msgSend_stret", type = !llvm.func (ptr, ptr, ...)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @blah(%arg0: !llvm.ptr) { + %0 = llvm.mlir.addressof @objc_msgSend_stret : !llvm.ptr + llvm.call %0(%arg0) : !llvm.ptr, (!llvm.ptr) -> () + llvm.return + } + llvm.func @objc_msgSend_stret(!llvm.ptr, !llvm.ptr, ...) -> !llvm.ptr +} diff --git a/test/LLVMDialect/InstCombine/2007-06-06-AshrSignBit.ll.mlir b/test/LLVMDialect/InstCombine/2007-06-06-AshrSignBit.ll.mlir index 35d909eba..9b575be24 100644 --- a/test/LLVMDialect/InstCombine/2007-06-06-AshrSignBit.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-06-06-AshrSignBit.ll.mlir @@ -1,21 +1,19 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 63 : i32} : () -> i32 - "llvm.br"()[^bb2] : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @av_cmp_q_cond_true(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(63 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + llvm.br ^bb2 ^bb1: // pred: ^bb2 - "llvm.return"() : () -> () + llvm.return ^bb2: // pred: ^bb0 - %2 = "llvm.load"(%arg2) : (!llvm.ptr) -> i64 - %3 = "llvm.zext"(%1) : (i32) -> i64 - %4 = "llvm.ashr"(%2, %3) : (i64, i64) -> i64 - %5 = "llvm.trunc"(%4) : (i64) -> i32 - %6 = "llvm.or"(%5, %0) : (i32, i32) -> i32 - "llvm.store"(%6, %arg1) : (i32, !llvm.ptr) -> () - %7 = "llvm.load"(%arg1) : (!llvm.ptr) -> i32 - "llvm.store"(%7, %arg0) : (i32, !llvm.ptr) -> () - "llvm.br"()[^bb1] : () -> () - }) {linkage = 10 : i64, sym_name = "av_cmp_q_cond_true", type = !llvm.func, ptr, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %2 = llvm.load %arg2 {alignment = 4 : i64} : !llvm.ptr -> i64 + %3 = llvm.zext %0 : i32 to i64 + %4 = llvm.ashr %2, %3 : i64 + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.or %5, %1 : i32 + llvm.store %6, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %7 = llvm.load %arg1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %7, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb1 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-06-21-DivCompareMiscomp.ll.mlir b/test/LLVMDialect/InstCombine/2007-06-21-DivCompareMiscomp.ll.mlir index 5e1fd9600..0c2843154 100644 --- a/test/LLVMDialect/InstCombine/2007-06-21-DivCompareMiscomp.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-06-21-DivCompareMiscomp.ll.mlir @@ -1,11 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1073741824 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.udiv"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i32, i32) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(1073741824 : i32) : i32 + %2 = llvm.udiv %arg0, %0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-08-02-InfiniteLoop.ll.mlir b/test/LLVMDialect/InstCombine/2007-08-02-InfiniteLoop.ll.mlir index 4596f2acd..db423a3b2 100644 --- a/test/LLVMDialect/InstCombine/2007-08-02-InfiniteLoop.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-08-02-InfiniteLoop.ll.mlir @@ -1,11 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i16): // no predecessors - %0 = "llvm.sext"(%arg0) : (i16) -> i32 - %1 = "llvm.sext"(%arg1) : (i16) -> i32 - %2 = "llvm.add"(%0, %1) : (i32, i32) -> i32 - %3 = "llvm.sext"(%2) : (i32) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i16, %arg1: i16) -> i64 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.sext %arg1 : i16 to i32 + %2 = llvm.add %0, %1 : i32 + %3 = llvm.sext %2 : i32 to i64 + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-09-10-AliasConstFold.ll.mlir b/test/LLVMDialect/InstCombine/2007-09-10-AliasConstFold.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/2007-09-17-AliasConstFold2.ll.mlir b/test/LLVMDialect/InstCombine/2007-09-17-AliasConstFold2.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/2007-10-10-EliminateMemCpy.ll.mlir b/test/LLVMDialect/InstCombine/2007-10-10-EliminateMemCpy.ll.mlir index 361a99433..471fa3e7b 100644 --- a/test/LLVMDialect/InstCombine/2007-10-10-EliminateMemCpy.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-10-10-EliminateMemCpy.ll.mlir @@ -1,23 +1,16 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 1 : i64, sym_name = ".str", type = !llvm.array<4 x i8>, value = "xyz\00"} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.alloca"(%4) : (i32) -> !llvm.ptr> - "llvm.store"(%arg0, %5) : (!llvm.ptr, !llvm.ptr>) -> () - %6 = "llvm.load"(%5) : (!llvm.ptr>) -> !llvm.ptr - %7 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - "llvm.call"(%6, %7, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.br"()[^bb1] : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "big">>} { + llvm.mlir.global internal constant @".str"("xyz\00") {addr_space = 0 : i32, dso_local} + llvm.func @foo(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant("xyz\00") : !llvm.array<4 x i8> + %2 = llvm.mlir.addressof @".str" : !llvm.ptr + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %4 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %5 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + "llvm.intr.memcpy"(%5, %2, %3) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.br ^bb1 ^bb1: // pred: ^bb0 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memcpy.p0i8.p0i8.i32", type = !llvm.func, ptr, i32, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2007-10-12-Crash.ll.mlir b/test/LLVMDialect/InstCombine/2007-10-12-Crash.ll.mlir index 29064c253..2f934fcb7 100644 --- a/test/LLVMDialect/InstCombine/2007-10-12-Crash.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-10-12-Crash.ll.mlir @@ -1,36 +1,31 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_Z9ray_traceRK3VecRK3RayRK5Scene", type = !llvm.func>, ptr, struct<"struct.Vec", (f64, f64, f64)>)>>, ptr>>)>>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr>>)>> - %2 = "llvm.mlir.null"() : () -> !llvm.ptr> - %3 = "llvm.mlir.constant"() {value = 0.000000e+00 : f64} : () -> f64 - %4 = "llvm.mlir.constant"() {value = 512 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %7 = "llvm.alloca"(%6) : (i32) -> !llvm.ptr, struct<"struct.Vec", (f64, f64, f64)>)>> - %8 = "llvm.icmp"(%5, %4) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%8)[^bb4, ^bb6] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @_Z9ray_traceRK3VecRK3RayRK5Scene(!llvm.ptr, !llvm.ptr, !llvm.ptr) -> f64 + llvm.func @main(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(512 : i32) : i32 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %5 = llvm.mlir.zero : !llvm.ptr + %6 = llvm.alloca %0 x !llvm.struct<"struct.Ray", (struct<"struct.Vec", (f64, f64, f64)>, struct<"struct.Vec", (f64, f64, f64)>)> {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.icmp "slt" %1, %2 : i32 + llvm.cond_br %7, ^bb4, ^bb6 ^bb1: // pred: ^bb2 - %9 = "llvm.bitcast"(%7) : (!llvm.ptr, struct<"struct.Vec", (f64, f64, f64)>)>>) -> !llvm.ptr> - %10 = "llvm.getelementptr"(%9, %5, %5) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - "llvm.store"(%3, %10) : (f64, !llvm.ptr) -> () - %11 = "llvm.call"(%2, %7, %1) {callee = @_Z9ray_traceRK3VecRK3RayRK5Scene, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>, !llvm.ptr, struct<"struct.Vec", (f64, f64, f64)>)>>, !llvm.ptr>>)>>) -> f64 - "llvm.br"()[^bb2] : () -> () + %8 = llvm.getelementptr %6[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.Vec", (f64, f64, f64)> + llvm.store %4, %8 {alignment = 8 : i64} : f64, !llvm.ptr + %9 = llvm.call @_Z9ray_traceRK3VecRK3RayRK5Scene(%5, %6, %5) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> f64 + llvm.br ^bb2 ^bb2: // 2 preds: ^bb1, ^bb4 - %12 = "llvm.icmp"(%5, %0) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%12)[^bb1, ^bb3] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %10 = llvm.icmp "slt" %1, %3 : i32 + llvm.cond_br %10, ^bb1, ^bb3 ^bb3: // pred: ^bb2 - "llvm.return"(%5) : (i32) -> () + llvm.return %1 : i32 ^bb4: // pred: ^bb0 - %13 = "llvm.icmp"(%5, %0) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%13)[^bb2, ^bb5] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %11 = llvm.icmp "slt" %1, %3 : i32 + llvm.cond_br %11, ^bb2, ^bb5 ^bb5: // pred: ^bb4 - "llvm.return"(%5) : (i32) -> () + llvm.return %1 : i32 ^bb6: // pred: ^bb0 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "main", type = !llvm.func>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-10-28-stacksave.ll.mlir b/test/LLVMDialect/InstCombine/2007-10-28-stacksave.ll.mlir index 402eaf9dd..92f1f91a3 100644 --- a/test/LLVMDialect/InstCombine/2007-10-28-stacksave.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-10-28-stacksave.ll.mlir @@ -1,51 +1,45 @@ -"module"() ( { - "llvm.mlir.global"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 4 : i64, sym_name = "p", type = !llvm.ptr} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 999999 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @p} : () -> !llvm.ptr> - %3 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 47 : i32} : () -> i32 - %7 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %8 = "llvm.bitcast"(%7) : (i32) -> i32 - "llvm.br"(%7)[^bb1] : (i32) -> () - ^bb1(%9: i32): // 2 preds: ^bb0, ^bb3 - %10 = "llvm.call"() {callee = @llvm.stacksave, fastmathFlags = #llvm.fastmath<>} : () -> !llvm.ptr - %11 = "llvm.srem"(%9, %6) : (i32, i32) -> i32 - %12 = "llvm.add"(%11, %5) : (i32, i32) -> i32 - %13 = "llvm.sub"(%12, %5) : (i32, i32) -> i32 - %14 = "llvm.zext"(%12) : (i32) -> i64 - %15 = "llvm.mul"(%14, %4) : (i64, i64) -> i64 - %16 = "llvm.mul"(%12, %3) : (i32, i32) -> i32 - %17 = "llvm.zext"(%12) : (i32) -> i64 - %18 = "llvm.mul"(%17, %4) : (i64, i64) -> i64 - %19 = "llvm.mul"(%12, %3) : (i32, i32) -> i32 - %20 = "llvm.alloca"(%19) : (i32) -> !llvm.ptr - %21 = "llvm.bitcast"(%20) : (!llvm.ptr) -> !llvm.ptr - %22 = "llvm.getelementptr"(%21, %7) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%5, %22) : (i32, !llvm.ptr) -> () - %23 = "llvm.bitcast"(%21) : (!llvm.ptr) -> !llvm.ptr - "llvm.store"(%23, %2) : (!llvm.ptr, !llvm.ptr>) -> () - %24 = "llvm.add"(%9, %5) : (i32, i32) -> i32 - %25 = "llvm.icmp"(%24, %1) {predicate = 3 : i64} : (i32, i32) -> i1 - %26 = "llvm.zext"(%25) : (i1) -> i8 - %27 = "llvm.icmp"(%26, %0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.cond_br"(%27)[^bb3, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global weak @p() {addr_space = 0 : i32} : !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @main() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(47 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(32 : i64) : i64 + %4 = llvm.mlir.constant(4 : i32) : i32 + %5 = llvm.mlir.zero : !llvm.ptr + %6 = llvm.mlir.addressof @p : !llvm.ptr + %7 = llvm.mlir.constant(999999 : i32) : i32 + %8 = llvm.mlir.constant(0 : i8) : i8 + %9 = llvm.bitcast %0 : i32 to i32 + llvm.br ^bb1(%0 : i32) + ^bb1(%10: i32): // 2 preds: ^bb0, ^bb3 + %11 = llvm.intr.stacksave : !llvm.ptr + %12 = llvm.srem %10, %1 : i32 + %13 = llvm.add %12, %2 : i32 + %14 = llvm.sub %13, %2 : i32 + %15 = llvm.zext %13 : i32 to i64 + %16 = llvm.mul %15, %3 : i64 + %17 = llvm.mul %13, %4 : i32 + %18 = llvm.zext %13 : i32 to i64 + %19 = llvm.mul %18, %3 : i64 + %20 = llvm.mul %13, %4 : i32 + %21 = llvm.alloca %20 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %22 = llvm.getelementptr %21[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %2, %22 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store volatile %21, %6 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + %23 = llvm.add %10, %2 : i32 + %24 = llvm.icmp "sle" %23, %7 : i32 + %25 = llvm.zext %24 : i1 to i8 + %26 = llvm.icmp "ne" %25, %8 : i8 + llvm.cond_br %26, ^bb3, ^bb2 ^bb2: // pred: ^bb1 - "llvm.call"(%10) {callee = @llvm.stackrestore, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"(%7) : (i32) -> () + llvm.intr.stackrestore %11 : !llvm.ptr + llvm.return %0 : i32 ^bb3: // pred: ^bb1 - "llvm.call"(%10) {callee = @llvm.stackrestore, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.br"(%24)[^bb1] : (i32) -> () - }) {linkage = 10 : i64, sym_name = "main", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.stacksave", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.stackrestore", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.intr.stackrestore %11 : !llvm.ptr + llvm.br ^bb1(%23 : i32) + } +} diff --git a/test/LLVMDialect/InstCombine/2007-10-31-RangeCrash.ll.mlir b/test/LLVMDialect/InstCombine/2007-10-31-RangeCrash.ll.mlir index 5d62cce6e..f8b5321ae 100644 --- a/test/LLVMDialect/InstCombine/2007-10-31-RangeCrash.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-10-31-RangeCrash.ll.mlir @@ -1,34 +1,33 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.undef"() : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = -1 : i16} : () -> i16 - %4 = "llvm.mlir.constant"() {value = 1 : i16} : () -> i16 - %5 = "llvm.mlir.null"() : () -> !llvm.ptr - %6 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %7 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %8 = "llvm.icmp"(%7, %6) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%8)[^bb1, ^bb5] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "big">>} { + llvm.func @test() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.undef : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.mlir.constant(1 : i16) : i16 + %5 = llvm.mlir.constant(-1 : i16) : i16 + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.icmp "slt" %0, %1 : i32 + llvm.cond_br %8, ^bb1, ^bb5 ^bb1: // pred: ^bb0 - "llvm.br"(%7, %7)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%0, %0 : i32, i32) ^bb2: // pred: ^bb3 - %9 = "llvm.load"(%5) : (!llvm.ptr) -> i16 - %10 = "llvm.icmp"(%9, %4) {predicate = 6 : i64} : (i16, i16) -> i1 - %11 = "llvm.icmp"(%9, %3) {predicate = 8 : i64} : (i16, i16) -> i1 - %12 = "llvm.or"(%10, %11) : (i1, i1) -> i1 - %13 = "llvm.zext"(%12) : (i1) -> i32 - %14 = "llvm.xor"(%13, %2) : (i32, i32) -> i32 - %15 = "llvm.add"(%17, %14) : (i32, i32) -> i32 - %16 = "llvm.add"(%18, %1) : (i32, i32) -> i32 - "llvm.br"(%15, %16)[^bb3] : (i32, i32) -> () + %9 = llvm.load %3 {alignment = 2 : i64} : !llvm.ptr -> i16 + %10 = llvm.icmp "ult" %9, %4 : i16 + %11 = llvm.icmp "ugt" %9, %5 : i16 + %12 = llvm.or %10, %11 : i1 + %13 = llvm.zext %12 : i1 to i32 + %14 = llvm.xor %13, %6 : i32 + %15 = llvm.add %17, %14 : i32 + %16 = llvm.add %18, %7 : i32 + llvm.br ^bb3(%15, %16 : i32, i32) ^bb3(%17: i32, %18: i32): // 2 preds: ^bb1, ^bb2 - %19 = "llvm.icmp"(%18, %7) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%19)[^bb2, ^bb4] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %19 = llvm.icmp "slt" %18, %0 : i32 + llvm.cond_br %19, ^bb2, ^bb4 ^bb4: // pred: ^bb3 - "llvm.return"(%7) : (i32) -> () + llvm.return %0 : i32 ^bb5: // pred: ^bb0 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-10-31-StringCrash.ll.mlir b/test/LLVMDialect/InstCombine/2007-10-31-StringCrash.ll.mlir index 1ab1e2418..7d1ae3a6d 100644 --- a/test/LLVMDialect/InstCombine/2007-10-31-StringCrash.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-10-31-StringCrash.ll.mlir @@ -1,21 +1,17 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "__darwin_gcc3_preregister_frame_info", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr>, %arg2: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @__darwin_gcc3_preregister_frame_info} : () -> !llvm.ptr> - %3 = "llvm.bitcast"(%2) : (!llvm.ptr>) -> !llvm.ptr - %4 = "llvm.load"(%3) : (!llvm.ptr) -> i32 - %5 = "llvm.icmp"(%4, %1) {predicate = 1 : i64} : (i32, i32) -> i1 - %6 = "llvm.zext"(%5) : (i1) -> i8 - %7 = "llvm.icmp"(%6, %0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.cond_br"(%7)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @__darwin_gcc3_preregister_frame_info() + llvm.func @_start(%arg0: i32, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.addressof @__darwin_gcc3_preregister_frame_info : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.load %0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.zext %4 : i1 to i8 + %6 = llvm.icmp "ne" %5, %2 : i8 + llvm.cond_br %6, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.return"() : () -> () + llvm.return ^bb2: // pred: ^bb0 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "_start", type = !llvm.func>, ptr>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2007-11-07-OpaqueAlignCrash.ll.mlir b/test/LLVMDialect/InstCombine/2007-11-07-OpaqueAlignCrash.ll.mlir index db87794b6..354948346 100644 --- a/test/LLVMDialect/InstCombine/2007-11-07-OpaqueAlignCrash.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-11-07-OpaqueAlignCrash.ll.mlir @@ -1,18 +1,13 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "g", type = !llvm.struct<"opaque_t", opaque>} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "h", type = !llvm.struct<"op_ts", (struct<"opaque2", opaque>, i32)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @h} : () -> !llvm.ptr, i32)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr, i32)>>) -> !llvm.ptr - %2 = "llvm.mlir.addressof"() {global_name = @g} : () -> !llvm.ptr> - %3 = "llvm.bitcast"(%2) : (!llvm.ptr>) -> !llvm.ptr - %4 = "llvm.load"(%3) : (!llvm.ptr) -> i8 - %5 = "llvm.load"(%1) : (!llvm.ptr) -> i32 - %6 = "llvm.zext"(%4) : (i8) -> i32 - %7 = "llvm.add"(%5, %6) : (i32, i32) -> i32 - "llvm.return"(%7) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g() {addr_space = 0 : i32} : !llvm.struct<"opaque_t", opaque> + llvm.mlir.global external @h() {addr_space = 0 : i32} : !llvm.struct<"op_ts", (struct<"opaque2", opaque>, i32)> + llvm.func @foo() -> i32 { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.mlir.addressof @h : !llvm.ptr + %2 = llvm.load %0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %3 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.zext %2 : i8 to i32 + %5 = llvm.add %3, %4 : i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-11-15-CompareMiscomp.ll.mlir b/test/LLVMDialect/InstCombine/2007-11-15-CompareMiscomp.ll.mlir new file mode 100644 index 000000000..752e41744 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2007-11-15-CompareMiscomp.ll.mlir @@ -0,0 +1,19 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "eq" %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-11-25-CompatibleAttributes.ll.mlir b/test/LLVMDialect/InstCombine/2007-11-25-CompatibleAttributes.ll.mlir index c3f185d27..b66ca4b7e 100644 --- a/test/LLVMDialect/InstCombine/2007-11-25-CompatibleAttributes.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-11-25-CompatibleAttributes.ll.mlir @@ -1,16 +1,12 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 1 : i64, sym_name = ".str", type = !llvm.array<4 x i8>, value = "%d\0A\00"} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.undef"() : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %1) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "main", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "printf", type = !llvm.func, ...)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal constant @".str"("%d\0A\00") {addr_space = 0 : i32, dso_local} + llvm.func @main(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant("%d\0A\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.undef : i32 + %4 = llvm.call @printf(%1, %2) vararg(!llvm.func) : (!llvm.ptr, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @printf(!llvm.ptr, ...) -> i32 attributes {passthrough = ["nounwind"]} +} diff --git a/test/LLVMDialect/InstCombine/2007-12-10-ConstFoldCompare.ll.mlir b/test/LLVMDialect/InstCombine/2007-12-10-ConstFoldCompare.ll.mlir new file mode 100644 index 000000000..727855ce6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2007-12-10-ConstFoldCompare.ll.mlir @@ -0,0 +1,10 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test() -> i1 { + %0 = llvm.mlir.constant(4294967297 : i64) : i64 + %1 = llvm.inttoptr %0 : i64 to !llvm.ptr + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.inttoptr %2 : i64 to !llvm.ptr + %4 = llvm.icmp "ule" %1, %3 : !llvm.ptr + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-12-12-GEPScale.ll.mlir b/test/LLVMDialect/InstCombine/2007-12-12-GEPScale.ll.mlir index 548425832..7a3ccf2ea 100644 --- a/test/LLVMDialect/InstCombine/2007-12-12-GEPScale.ll.mlir +++ b/test/LLVMDialect/InstCombine/2007-12-12-GEPScale.ll.mlir @@ -1,10 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>>): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i32} : () -> i32 - %1 = "llvm.bitcast"(%arg0) : (!llvm.ptr>>) -> !llvm.ptr - %2 = "llvm.getelementptr"(%1, %0) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func (ptr>>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i32) : i32 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + llvm.return %1 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/2007-12-16-AsmNoUnwind.ll.mlir b/test/LLVMDialect/InstCombine/2007-12-16-AsmNoUnwind.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/2007-12-18-AddSelCmpSub.ll.mlir b/test/LLVMDialect/InstCombine/2007-12-18-AddSelCmpSub.ll.mlir new file mode 100644 index 000000000..39c8753f3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2007-12-18-AddSelCmpSub.ll.mlir @@ -0,0 +1,22 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(99 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.sub %0, %arg0 : i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + %6 = llvm.add %5, %arg0 : i32 + %7 = llvm.add %6, %2 : i32 + llvm.return %7 : i32 + } + llvm.func @bar(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(99 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %1, %2 : i1, i32 + %5 = llvm.add %4, %arg0 : i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2007-12-28-IcmpSub2.ll.mlir b/test/LLVMDialect/InstCombine/2007-12-28-IcmpSub2.ll.mlir new file mode 100644 index 000000000..aaeeb2037 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2007-12-28-IcmpSub2.ll.mlir @@ -0,0 +1,90 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.sub %3, %0 : i32 + %5 = llvm.icmp "ule" %4, %1 : i32 + %6 = llvm.select %5, %1, %0 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test2() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.sub %3, %0 : i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + %6 = llvm.select %5, %0, %1 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test3() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.sub %3, %0 : i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.select %5, %0, %1 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test4() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.sub %3, %0 : i32 + %5 = llvm.icmp "sle" %4, %1 : i32 + %6 = llvm.select %5, %0, %1 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test5() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.sub %3, %0 : i32 + %5 = llvm.icmp "sge" %4, %1 : i32 + %6 = llvm.select %5, %1, %0 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test6() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.sub %3, %0 : i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.select %5, %1, %0 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test7() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.sub %3, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.select %5, %1, %0 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test8() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.sub %3, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.select %5, %0, %1 : i1, i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-01-06-BitCastAttributes.ll.mlir b/test/LLVMDialect/InstCombine/2008-01-06-BitCastAttributes.ll.mlir new file mode 100644 index 000000000..79d032d42 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-01-06-BitCastAttributes.ll.mlir @@ -0,0 +1,25 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a() { + llvm.return + } + llvm.func @b(%arg0: !llvm.ptr {llvm.inreg}) -> (i32 {llvm.signext}) { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.return %0 : i32 + } + llvm.func @c(...) { + llvm.return + } + llvm.func @g(%arg0: !llvm.ptr) { + %0 = llvm.mlir.addressof @b : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.mlir.addressof @c : !llvm.ptr + %5 = llvm.call %0(%1) : !llvm.ptr, (i32) -> i64 + llvm.call %2(%arg0) : !llvm.ptr, (!llvm.ptr) -> () + %6 = llvm.call %0(%3) : !llvm.ptr, (!llvm.ptr) -> vector<2xi32> + llvm.call %4(%1) : !llvm.ptr, (i32) -> () + llvm.call %4(%1) : !llvm.ptr, (i32) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2008-01-06-CastCrash.ll.mlir b/test/LLVMDialect/InstCombine/2008-01-06-CastCrash.ll.mlir index 0f079383a..c335c3af9 100644 --- a/test/LLVMDialect/InstCombine/2008-01-06-CastCrash.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-01-06-CastCrash.ll.mlir @@ -1,13 +1,11 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.undef"() : () -> vector<2xi32> - "llvm.return"(%0) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @f} : () -> !llvm.ptr ()>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr ()>>) -> !llvm.ptr> - %2 = "llvm.call"(%1) : (!llvm.ptr>) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "g", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f() -> vector<2xi32> { + %0 = llvm.mlir.undef : vector<2xi32> + llvm.return %0 : vector<2xi32> + } + llvm.func @g() -> i32 { + %0 = llvm.mlir.addressof @f : !llvm.ptr + %1 = llvm.call %0() : !llvm.ptr, () -> i32 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-01-06-VoidCast.ll.mlir b/test/LLVMDialect/InstCombine/2008-01-06-VoidCast.ll.mlir index ca29310d9..e9997a009 100644 --- a/test/LLVMDialect/InstCombine/2008-01-06-VoidCast.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-01-06-VoidCast.ll.mlir @@ -1,14 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @f} : () -> !llvm.ptr> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>) -> !llvm.ptr> - %2 = "llvm.call"(%1, %arg0) : (!llvm.ptr>, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "g", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f(%arg0: i16) { + llvm.return + } + llvm.func @g(%arg0: i32) -> i32 { + %0 = llvm.mlir.addressof @f : !llvm.ptr + %1 = llvm.call %0(%arg0) : !llvm.ptr, (i32) -> i32 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-01-13-AndCmpCmp.ll.mlir b/test/LLVMDialect/InstCombine/2008-01-13-AndCmpCmp.ll.mlir new file mode 100644 index 000000000..ed0d7c214 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-01-13-AndCmpCmp.ll.mlir @@ -0,0 +1,19 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(34 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(34 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "ne" %arg0, %0 : i32 + %4 = llvm.icmp "sgt" %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-01-14-VarArgTrampoline.ll.mlir b/test/LLVMDialect/InstCombine/2008-01-14-VarArgTrampoline.ll.mlir index 01f9cb771..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/2008-01-14-VarArgTrampoline.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-01-14-VarArgTrampoline.ll.mlir @@ -1,29 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.init.trampoline", type = !llvm.func, ptr, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.adjust.trampoline", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func>)>>, ...)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @f} : () -> !llvm.ptr>)>>, ...)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>)>>, ...)>>) -> !llvm.ptr - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr>)>> - %5 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr> - %6 = "llvm.getelementptr"(%5, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %7 = "llvm.getelementptr"(%4, %2, %2) : (!llvm.ptr>)>>, i32, i32) -> !llvm.ptr - "llvm.store"(%arg0, %7) : (i32, !llvm.ptr) -> () - %8 = "llvm.bitcast"(%4) : (!llvm.ptr>)>>) -> !llvm.ptr - "llvm.call"(%6, %1, %8) {callee = @llvm.init.trampoline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> () - %9 = "llvm.call"(%6) {callee = @llvm.adjust.trampoline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> !llvm.ptr - %10 = "llvm.getelementptr"(%4, %2, %3) : (!llvm.ptr>)>>, i32, i32) -> !llvm.ptr>> - %11 = "llvm.bitcast"(%9) : (!llvm.ptr) -> !llvm.ptr> - "llvm.store"(%11, %10) : (!llvm.ptr>, !llvm.ptr>>) -> () - %12 = "llvm.call"(%11, %2) : (!llvm.ptr>, i32) -> i32 - "llvm.return"(%12) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "nest", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/2008-01-21-MulTrunc.ll.mlir b/test/LLVMDialect/InstCombine/2008-01-21-MulTrunc.ll.mlir new file mode 100644 index 000000000..742b57411 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-01-21-MulTrunc.ll.mlir @@ -0,0 +1,53 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.zext %arg0 : i16 to i32 + %3 = llvm.lshr %2, %0 : i32 + %4 = llvm.mul %2, %1 : i32 + %5 = llvm.or %3, %4 : i32 + %6 = llvm.trunc %5 : i32 to i16 + llvm.return %6 : i16 + } + llvm.func @test1_vec(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.lshr %2, %0 : vector<2xi32> + %4 = llvm.mul %2, %1 : vector<2xi32> + %5 = llvm.or %3, %4 : vector<2xi32> + %6 = llvm.trunc %5 : vector<2xi32> to vector<2xi16> + llvm.return %6 : vector<2xi16> + } + llvm.func @test1_vec_nonuniform(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[8, 9]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[5, 6]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.lshr %2, %0 : vector<2xi32> + %4 = llvm.mul %2, %1 : vector<2xi32> + %5 = llvm.or %3, %4 : vector<2xi32> + %6 = llvm.trunc %5 : vector<2xi32> to vector<2xi16> + llvm.return %6 : vector<2xi16> + } + llvm.func @test1_vec_undef(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(5 : i32) : i32 + %8 = llvm.mlir.undef : vector<2xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi32> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi32> + %13 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %14 = llvm.lshr %13, %6 : vector<2xi32> + %15 = llvm.mul %13, %12 : vector<2xi32> + %16 = llvm.or %14, %15 : vector<2xi32> + %17 = llvm.trunc %16 : vector<2xi32> to vector<2xi16> + llvm.return %17 : vector<2xi16> + } +} diff --git a/test/LLVMDialect/InstCombine/2008-01-27-FloatSelect.ll.mlir b/test/LLVMDialect/InstCombine/2008-01-27-FloatSelect.ll.mlir new file mode 100644 index 000000000..2fc24e0d2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-01-27-FloatSelect.ll.mlir @@ -0,0 +1,9 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fold(%arg0: i1, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %2 = llvm.select %arg0, %0, %1 : i1, f64 + %3 = llvm.fdiv %arg1, %2 : f64 + llvm.return %3 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-02-13-MulURem.ll.mlir b/test/LLVMDialect/InstCombine/2008-02-13-MulURem.ll.mlir index 5e5566b3b..18f46b9e0 100644 --- a/test/LLVMDialect/InstCombine/2008-02-13-MulURem.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-02-13-MulURem.ll.mlir @@ -1,10 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mul"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.urem"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "fold", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fold(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.urem %1, %0 : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-02-16-SDivOverflow2.ll.mlir b/test/LLVMDialect/InstCombine/2008-02-16-SDivOverflow2.ll.mlir index c71168303..fc83201ad 100644 --- a/test/LLVMDialect/InstCombine/2008-02-16-SDivOverflow2.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-02-16-SDivOverflow2.ll.mlir @@ -1,10 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i8} : () -> i8 - %1 = "llvm.sdiv"(%arg0, %0) : (i8, i8) -> i8 - %2 = "llvm.sdiv"(%1, %0) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "i", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @i(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-3 : i8) : i8 + %1 = llvm.sdiv %arg0, %0 : i8 + %2 = llvm.sdiv %1, %0 : i8 + llvm.return %2 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-02-23-MulSub.ll.mlir b/test/LLVMDialect/InstCombine/2008-02-23-MulSub.ll.mlir index 357d6b586..a02d8c2ea 100644 --- a/test/LLVMDialect/InstCombine/2008-02-23-MulSub.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-02-23-MulSub.ll.mlir @@ -1,12 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i26): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2884 : i26} : () -> i26 - %1 = "llvm.mlir.constant"() {value = 2885 : i26} : () -> i26 - %2 = "llvm.mul"(%arg0, %1) : (i26, i26) -> i26 - %3 = "llvm.mul"(%arg0, %0) : (i26, i26) -> i26 - %4 = "llvm.sub"(%2, %3) : (i26, i26) -> i26 - "llvm.return"(%4) : (i26) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i26) -> i26 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(2885 : i26) : i26 + %1 = llvm.mlir.constant(2884 : i26) : i26 + %2 = llvm.mul %arg0, %0 : i26 + %3 = llvm.mul %arg0, %1 : i26 + %4 = llvm.sub %2, %3 : i26 + llvm.return %4 : i26 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-02-28-OrFCmpCrash.ll.mlir b/test/LLVMDialect/InstCombine/2008-02-28-OrFCmpCrash.ll.mlir new file mode 100644 index 000000000..cf217a1d0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-02-28-OrFCmpCrash.ll.mlir @@ -0,0 +1,27 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: f32, %arg1: f80) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0.000000e+00 : f80) : f80 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "uno" %arg1, %0 : f80 + %3 = llvm.fcmp "uno" %arg0, %1 : f32 + %4 = llvm.or %2, %3 : i1 + llvm.cond_br %4, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : f32 + ^bb2: // pred: ^bb0 + llvm.return %1 : f32 + } + llvm.func @test_logical(%arg0: f32, %arg1: f80) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0.000000e+00 : f80) : f80 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.fcmp "uno" %arg1, %0 : f80 + %4 = llvm.fcmp "uno" %arg0, %1 : f32 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : f32 + ^bb2: // pred: ^bb0 + llvm.return %1 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-03-13-IntToPtr.ll.mlir b/test/LLVMDialect/InstCombine/2008-03-13-IntToPtr.ll.mlir index 439523a01..1a6a70939 100644 --- a/test/LLVMDialect/InstCombine/2008-03-13-IntToPtr.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-03-13-IntToPtr.ll.mlir @@ -1,12 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i32 - %3 = "llvm.add"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.inttoptr"(%3) : (i32) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "bork", type = !llvm.func (ptr>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bork(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.add %2, %0 : i32 + %4 = llvm.inttoptr %3 : i32 to !llvm.ptr + llvm.return %4 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/2008-04-22-ByValBitcast.ll.mlir b/test/LLVMDialect/InstCombine/2008-04-22-ByValBitcast.ll.mlir index 9f02b12d4..a3aaa246d 100644 --- a/test/LLVMDialect/InstCombine/2008-04-22-ByValBitcast.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-04-22-ByValBitcast.ll.mlir @@ -1,12 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr)>> - "llvm.call"(%0, %1) {callee = @bar, fastmathFlags = #llvm.fastmath<>} : (i32, !llvm.ptr)>>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: !llvm.ptr) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(3 : i32) : i32 + llvm.call @bar(%0, %arg0) vararg(!llvm.func) : (i32, !llvm.ptr) -> () + llvm.return + } + llvm.func @bar(i32, ...) +} diff --git a/test/LLVMDialect/InstCombine/2008-04-28-VolatileStore.ll.mlir b/test/LLVMDialect/InstCombine/2008-04-28-VolatileStore.ll.mlir new file mode 100644 index 000000000..072fddbb2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-04-28-VolatileStore.ll.mlir @@ -0,0 +1,10 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %3 = llvm.alloca %0 x vector<4xf32> {alignment = 16 : i64} : (i32) -> !llvm.ptr + llvm.store volatile %2, %3 {alignment = 16 : i64} : vector<4xf32>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2008-04-29-VolatileLoadDontMerge.ll.mlir b/test/LLVMDialect/InstCombine/2008-04-29-VolatileLoadDontMerge.ll.mlir index 6fe4d5d93..816d9a96e 100644 --- a/test/LLVMDialect/InstCombine/2008-04-29-VolatileLoadDontMerge.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-04-29-VolatileLoadDontMerge.ll.mlir @@ -1,26 +1,22 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 1 : i64, sym_name = "g_1", type = i32, value = 0 : i32} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @g_1} : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @g_1} : () -> !llvm.ptr - %3 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %4 = "llvm.mlir.addressof"() {global_name = @g_1} : () -> !llvm.ptr - %5 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %7 = "llvm.icmp"(%6, %5) {predicate = 2 : i64} : (i32, i32) -> i1 - %8 = "llvm.load"(%4) : (!llvm.ptr) -> i32 - "llvm.br"(%6, %8)[^bb1] : (i32, i32) -> () - ^bb1(%9: i32, %10: i32): // 2 preds: ^bb0, ^bb1 - %11 = "llvm.add"(%10, %3) : (i32, i32) -> i32 - "llvm.store"(%11, %2) : (i32, !llvm.ptr) -> () - %12 = "llvm.add"(%9, %1) : (i32, i32) -> i32 - %13 = "llvm.icmp"(%12, %5) {predicate = 2 : i64} : (i32, i32) -> i1 - %14 = "llvm.load"(%0) : (!llvm.ptr) -> i32 - "llvm.cond_br"(%13, %12, %14)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 2, 0]> : vector<3xi32>} : (i1, i32, i32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal @g_1(0 : i32) {addr_space = 0 : i32, dso_local} : i32 + llvm.func @main() -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.addressof @g_1 : !llvm.ptr + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.icmp "slt" %0, %1 : i32 + %6 = llvm.load volatile %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb1(%0, %6 : i32, i32) + ^bb1(%7: i32, %8: i32): // 2 preds: ^bb0, ^bb1 + %9 = llvm.add %8, %3 : i32 + llvm.store volatile %9, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %10 = llvm.add %7, %4 : i32 + %11 = llvm.icmp "slt" %10, %1 : i32 + %12 = llvm.load volatile %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.cond_br %11, ^bb1(%10, %12 : i32, i32), ^bb2 ^bb2: // pred: ^bb1 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "main", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-04-29-VolatileLoadMerge.ll.mlir b/test/LLVMDialect/InstCombine/2008-04-29-VolatileLoadMerge.ll.mlir index c21e91ed7..56a648d68 100644 --- a/test/LLVMDialect/InstCombine/2008-04-29-VolatileLoadMerge.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-04-29-VolatileLoadMerge.ll.mlir @@ -1,19 +1,16 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 1 : i64, sym_name = "g_1", type = i32, value = 0 : i32} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @g_1} : () -> !llvm.ptr - %1 = "llvm.mlir.addressof"() {global_name = @g_1} : () -> !llvm.ptr - %2 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %3 = "llvm.icmp"(%arg0, %2) {predicate = 2 : i64} : (i32, i32) -> i1 - %4 = "llvm.load"(%1) : (!llvm.ptr) -> i32 - "llvm.cond_br"(%3, %4)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal @g_1(0 : i32) {addr_space = 0 : i32, dso_local} : i32 + llvm.func @main(%arg0: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @g_1 : !llvm.ptr + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.load volatile %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.cond_br %3, ^bb2(%4 : i32), ^bb1 ^bb1: // pred: ^bb0 - %5 = "llvm.load"(%0) : (!llvm.ptr) -> i32 - "llvm.br"(%5)[^bb2] : (i32) -> () + %5 = llvm.load volatile %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb2(%5 : i32) ^bb2(%6: i32): // 2 preds: ^bb0, ^bb1 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "main", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-05-08-LiveStoreDelete.ll.mlir b/test/LLVMDialect/InstCombine/2008-05-08-LiveStoreDelete.ll.mlir index a2cec0a07..fd0919194 100644 --- a/test/LLVMDialect/InstCombine/2008-05-08-LiveStoreDelete.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-05-08-LiveStoreDelete.ll.mlir @@ -1,27 +1,23 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %5 = "llvm.bitcast"(%4) : (i32) -> i32 - %6 = "llvm.call"(%3) {callee = @malloc, fastmathFlags = #llvm.fastmath<>} : (i32) -> !llvm.ptr - %7 = "llvm.getelementptr"(%6, %2) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%1, %7) : (i8, !llvm.ptr) -> () - %8 = "llvm.getelementptr"(%6, %4) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%0, %8) : (i8, !llvm.ptr) -> () - %9 = "llvm.call"(%6) {callee = @strlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - %10 = "llvm.getelementptr"(%6, %4) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%1, %10) : (i8, !llvm.ptr) -> () - %11 = "llvm.call"(%6) {callee = @b, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - "llvm.return"(%9) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "a", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "malloc", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strlen", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "b", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a() -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.mlir.constant(1 : i8) : i8 + %5 = llvm.bitcast %0 : i32 to i32 + %6 = llvm.call @malloc(%1) : (i32) -> !llvm.ptr + %7 = llvm.getelementptr %6[%2] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + llvm.store %3, %7 {alignment = 1 : i64} : i8, !llvm.ptr + %8 = llvm.getelementptr %6[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + llvm.store %4, %8 {alignment = 1 : i64} : i8, !llvm.ptr + %9 = llvm.call @strlen(%6) : (!llvm.ptr) -> i32 + %10 = llvm.getelementptr %6[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + llvm.store %3, %10 {alignment = 1 : i64} : i8, !llvm.ptr + %11 = llvm.call @b(%6) vararg(!llvm.func) : (!llvm.ptr) -> i32 + llvm.return %9 : i32 + } + llvm.func @malloc(i32) -> !llvm.ptr attributes {passthrough = ["nounwind"]} + llvm.func @strlen(!llvm.ptr) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @b(...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/2008-05-08-StrLenSink.ll.mlir b/test/LLVMDialect/InstCombine/2008-05-08-StrLenSink.ll.mlir index bdabe6bf9..519d1b1f3 100644 --- a/test/LLVMDialect/InstCombine/2008-05-08-StrLenSink.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-05-08-StrLenSink.ll.mlir @@ -1,29 +1,25 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %5 = "llvm.bitcast"(%4) : (i32) -> i32 - %6 = "llvm.call"(%3) {callee = @malloc, fastmathFlags = #llvm.fastmath<>} : (i32) -> !llvm.ptr - %7 = "llvm.getelementptr"(%6, %2) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%1, %7) : (i8, !llvm.ptr) -> () - %8 = "llvm.getelementptr"(%6, %4) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%0, %8) : (i8, !llvm.ptr) -> () - %9 = "llvm.call"(%6) {callee = @strlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - %10 = "llvm.getelementptr"(%6, %4) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%1, %10) : (i8, !llvm.ptr) -> () - %11 = "llvm.call"(%6) {callee = @b, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - "llvm.br"()[^bb1] : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a() -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.mlir.constant(1 : i8) : i8 + %5 = llvm.bitcast %0 : i32 to i32 + %6 = llvm.call @malloc(%1) : (i32) -> !llvm.ptr + %7 = llvm.getelementptr %6[%2] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + llvm.store %3, %7 {alignment = 1 : i64} : i8, !llvm.ptr + %8 = llvm.getelementptr %6[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + llvm.store %4, %8 {alignment = 1 : i64} : i8, !llvm.ptr + %9 = llvm.call @strlen(%6) : (!llvm.ptr) -> i32 + %10 = llvm.getelementptr %6[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + llvm.store %3, %10 {alignment = 1 : i64} : i8, !llvm.ptr + %11 = llvm.call @b(%6) vararg(!llvm.func) : (!llvm.ptr) -> i32 + llvm.br ^bb1 ^bb1: // pred: ^bb0 - "llvm.return"(%9) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "a", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "malloc", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strlen", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "b", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %9 : i32 + } + llvm.func @malloc(i32) -> !llvm.ptr attributes {passthrough = ["nounwind"]} + llvm.func @strlen(!llvm.ptr) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @b(...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/2008-05-09-SinkOfInvoke.ll.mlir b/test/LLVMDialect/InstCombine/2008-05-09-SinkOfInvoke.ll.mlir new file mode 100644 index 000000000..6e7464b50 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-05-09-SinkOfInvoke.ll.mlir @@ -0,0 +1,23 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @_ZNSt6locale5facet15_S_get_c_localeEv() -> !llvm.ptr + llvm.func @__ctype_toupper_loc() -> !llvm.ptr attributes {memory = #llvm.memory_effects} + llvm.func @__ctype_tolower_loc() -> !llvm.ptr attributes {memory = #llvm.memory_effects} + llvm.func @_ZNSt5ctypeIcEC2EPiPKtbm(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: i8 {llvm.zeroext}, %arg4: i64) attributes {personality = @__gxx_personality_v0} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.invoke @_ZNSt6locale5facet15_S_get_c_localeEv() to ^bb1 unwind ^bb4 : () -> !llvm.ptr + ^bb1: // pred: ^bb0 + %3 = llvm.invoke @__ctype_toupper_loc() to ^bb2 unwind ^bb4 : () -> !llvm.ptr + ^bb2: // pred: ^bb1 + %4 = llvm.invoke @__ctype_tolower_loc() to ^bb3 unwind ^bb4 : () -> !llvm.ptr + ^bb3: // pred: ^bb2 + %5 = llvm.load %4 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %6 = llvm.getelementptr %arg0[%0, 4] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.std::ctype", (struct<"struct.std::locale::facet", (ptr, i32)>, ptr, i8, ptr, ptr, ptr, i8, array<256 x i8>, array<256 x i8>, i8)> + llvm.store %5, %6 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + ^bb4: // 3 preds: ^bb0, ^bb1, ^bb2 + %7 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)> + llvm.unreachable + } + llvm.func @__gxx_personality_v0(...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/2008-05-17-InfLoop.ll.mlir b/test/LLVMDialect/InstCombine/2008-05-17-InfLoop.ll.mlir new file mode 100644 index 000000000..f0ba84e9c --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-05-17-InfLoop.ll.mlir @@ -0,0 +1,22 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @BZALLOC(i32) + llvm.func @f(%arg0: i32) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.getelementptr %2[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %4 = llvm.ptrtoint %3 : !llvm.ptr to i32 + %5 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %5 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %7, %6 {alignment = 4 : i64} : i32, !llvm.ptr + %8 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + %9 = llvm.add %8, %1 : i32 + %10 = llvm.mul %9, %4 : i32 + llvm.call @BZALLOC(%10) : (i32) -> () + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2008-05-18-FoldIntToPtr.ll.mlir b/test/LLVMDialect/InstCombine/2008-05-18-FoldIntToPtr.ll.mlir new file mode 100644 index 000000000..31ff9d89c --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-05-18-FoldIntToPtr.ll.mlir @@ -0,0 +1,18 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f1() -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.inttoptr %0 : i32 to !llvm.ptr + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.inttoptr %2 : i32 to !llvm.ptr + %4 = llvm.icmp "eq" %1, %3 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @f2() -> i1 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.inttoptr %0 : i16 to !llvm.ptr + %2 = llvm.mlir.constant(2 : i16) : i16 + %3 = llvm.inttoptr %2 : i16 to !llvm.ptr + %4 = llvm.icmp "eq" %1, %3 : !llvm.ptr + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-05-22-IDivVector.ll.mlir b/test/LLVMDialect/InstCombine/2008-05-22-IDivVector.ll.mlir index 880c4f6f7..feafdafdf 100644 --- a/test/LLVMDialect/InstCombine/2008-05-22-IDivVector.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-05-22-IDivVector.ll.mlir @@ -1,8 +1,6 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: vector<3xi8>): // no predecessors - %0 = "llvm.sdiv"(%arg0, %arg0) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> - "llvm.return"(%0) : (vector<3xi8>) -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func (vector<3xi8>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.sdiv %arg0, %arg0 : vector<3xi8> + llvm.return %0 : vector<3xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/2008-05-23-CompareFold.ll.mlir b/test/LLVMDialect/InstCombine/2008-05-23-CompareFold.ll.mlir new file mode 100644 index 000000000..49085f172 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-05-23-CompareFold.ll.mlir @@ -0,0 +1,9 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(3.40282347E+38 : f32) : f32 + %1 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %2 = llvm.sitofp %1 : i8 to f32 + %3 = llvm.fcmp "ugt" %2, %0 : f32 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-05-31-AddBool.ll.mlir b/test/LLVMDialect/InstCombine/2008-05-31-AddBool.ll.mlir index bffd534a0..1c30fe478 100644 --- a/test/LLVMDialect/InstCombine/2008-05-31-AddBool.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-05-31-AddBool.ll.mlir @@ -1,8 +1,6 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i1): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i1, i1) -> i1 - "llvm.return"(%0) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.add %arg0, %arg1 : i1 + llvm.return %0 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-05-31-Bools.ll.mlir b/test/LLVMDialect/InstCombine/2008-05-31-Bools.ll.mlir index 1df756dd2..6778d3e4d 100644 --- a/test/LLVMDialect/InstCombine/2008-05-31-Bools.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-05-31-Bools.ll.mlir @@ -1,23 +1,18 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i1): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i1, i1) -> i1 - "llvm.return"(%0) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "foo1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i1): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i1, i1) -> i1 - "llvm.return"(%0) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "foo2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i1): // no predecessors - %0 = "llvm.udiv"(%arg0, %arg1) : (i1, i1) -> i1 - "llvm.return"(%0) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "foo3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i1): // no predecessors - %0 = "llvm.sdiv"(%arg0, %arg1) : (i1, i1) -> i1 - "llvm.return"(%0) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "foo4", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i1 + llvm.return %0 : i1 + } + llvm.func @foo2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i1 + llvm.return %0 : i1 + } + llvm.func @foo3(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.udiv %arg0, %arg1 : i1 + llvm.return %0 : i1 + } + llvm.func @foo4(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.sdiv %arg0, %arg1 : i1 + llvm.return %0 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-06-05-ashr-crash.ll.mlir b/test/LLVMDialect/InstCombine/2008-06-05-ashr-crash.ll.mlir index 205ba592e..b3aca0ab7 100644 --- a/test/LLVMDialect/InstCombine/2008-06-05-ashr-crash.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-06-05-ashr-crash.ll.mlir @@ -1,9 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i65): // no predecessors - %0 = "llvm.mlir.constant"() {value = 65 : i65} : () -> i65 - %1 = "llvm.ashr"(%arg0, %0) : (i65, i65) -> i65 - "llvm.return"(%1) : (i65) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i65) -> i65 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(65 : i65) : i65 + %1 = llvm.ashr %arg0, %0 : i65 + llvm.return %1 : i65 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-06-08-ICmpPHI.ll.mlir b/test/LLVMDialect/InstCombine/2008-06-08-ICmpPHI.ll.mlir index 17f6b8077..e0baf92d9 100644 --- a/test/LLVMDialect/InstCombine/2008-06-08-ICmpPHI.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-06-08-ICmpPHI.ll.mlir @@ -1,42 +1,38 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 37 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.br"(%3, %2)[^bb1] : (i32, i32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(37 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + llvm.br ^bb1(%0, %1 : i32, i32) ^bb1(%4: i32, %5: i32): // 2 preds: ^bb0, ^bb6 - %6 = "llvm.call"() {callee = @bork, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %7 = "llvm.call"() {callee = @bork, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %8 = "llvm.call"() {callee = @bork, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %9 = "llvm.icmp"(%8, %3) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%9)[^bb3, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %6 = llvm.call @bork() vararg(!llvm.func) : () -> i32 + %7 = llvm.call @bork() vararg(!llvm.func) : () -> i32 + %8 = llvm.call @bork() vararg(!llvm.func) : () -> i32 + %9 = llvm.icmp "eq" %8, %0 : i32 + llvm.cond_br %9, ^bb3, ^bb2 ^bb2: // pred: ^bb1 - %10 = "llvm.call"() {callee = @bork, fastmathFlags = #llvm.fastmath<>} : () -> i32 - "llvm.br"()[^bb3] : () -> () + %10 = llvm.call @bork() vararg(!llvm.func) : () -> i32 + llvm.br ^bb3 ^bb3: // 2 preds: ^bb1, ^bb2 - %11 = "llvm.call"() {callee = @bork, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %12 = "llvm.call"() {callee = @bork, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %13 = "llvm.icmp"(%5, %2) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%13)[^bb4, ^bb5] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %11 = llvm.call @bork() vararg(!llvm.func) : () -> i32 + %12 = llvm.call @bork() vararg(!llvm.func) : () -> i32 + %13 = llvm.icmp "eq" %5, %1 : i32 + llvm.cond_br %13, ^bb4, ^bb5 ^bb4: // pred: ^bb3 - %14 = "llvm.call"() {callee = @bar, fastmathFlags = #llvm.fastmath<>} : () -> i32 - "llvm.br"()[^bb5] : () -> () + %14 = llvm.call @bar() vararg(!llvm.func) : () -> i32 + llvm.br ^bb5 ^bb5: // 2 preds: ^bb3, ^bb4 - %15 = "llvm.call"() {callee = @zap, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %16 = "llvm.add"(%4, %1) : (i32, i32) -> i32 - %17 = "llvm.icmp"(%16, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%17)[^bb7, ^bb6] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %15 = llvm.call @zap() vararg(!llvm.func) : () -> i32 + %16 = llvm.add %4, %2 : i32 + %17 = llvm.icmp "eq" %16, %3 : i32 + llvm.cond_br %17, ^bb7, ^bb6 ^bb6: // pred: ^bb5 - "llvm.br"(%16, %15)[^bb1] : (i32, i32) -> () + llvm.br ^bb1(%16, %15 : i32, i32) ^bb7: // pred: ^bb5 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bork", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "zap", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } + llvm.func @bork(...) -> i32 + llvm.func @bar(...) -> i32 + llvm.func @zap(...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/2008-06-13-InfiniteLoopStore.ll.mlir b/test/LLVMDialect/InstCombine/2008-06-13-InfiniteLoopStore.ll.mlir index f66f89c27..b8c1ef0c1 100644 --- a/test/LLVMDialect/InstCombine/2008-06-13-InfiniteLoopStore.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-06-13-InfiniteLoopStore.ll.mlir @@ -1,23 +1,19 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "g_139", type = i32, value = 0 : i32} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @g_139} : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @g_139} : () -> !llvm.ptr - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - "llvm.store"(%4, %3) : (i32, !llvm.ptr) -> () - %5 = "llvm.icmp"(%arg0, %2) {predicate = 1 : i64} : (i32, i32) -> i1 - %6 = "llvm.zext"(%5) : (i1) -> i8 - %7 = "llvm.icmp"(%6, %1) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.cond_br"(%7)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g_139(0 : i32) {addr_space = 0 : i32} : i32 + llvm.func @func_56(%arg0: i32) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @g_139 : !llvm.ptr + %3 = llvm.mlir.constant(0 : i8) : i8 + llvm.store %0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.zext %4 : i1 to i8 + %6 = llvm.icmp "ne" %5, %3 : i8 + llvm.cond_br %6, ^bb1, ^bb2 ^bb1: // 2 preds: ^bb0, ^bb1 - "llvm.store"(%4, %0) : (i32, !llvm.ptr) -> () - "llvm.br"()[^bb1] : () -> () + llvm.store %0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb1 ^bb2: // pred: ^bb0 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "func_56", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2008-06-13-ReadOnlyCallStore.ll.mlir b/test/LLVMDialect/InstCombine/2008-06-13-ReadOnlyCallStore.ll.mlir index bcd095d30..dc77355a7 100644 --- a/test/LLVMDialect/InstCombine/2008-06-13-ReadOnlyCallStore.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-06-13-ReadOnlyCallStore.ll.mlir @@ -1,19 +1,16 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - "llvm.store"(%1, %arg0) : (i8, !llvm.ptr) -> () - %2 = "llvm.call"(%arg0) {callee = @strlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%3)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a(%arg0: !llvm.ptr) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i32) : i32 + llvm.store %0, %arg0 {alignment = 1 : i64} : i8, !llvm.ptr + %2 = llvm.call @strlen(%arg0) : (!llvm.ptr) -> i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.cond_br %3, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.store"(%1, %arg0) : (i8, !llvm.ptr) -> () - "llvm.br"()[^bb2] : () -> () + llvm.store %0, %arg0 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.br ^bb2 ^bb2: // 2 preds: ^bb0, ^bb1 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "a", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strlen", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %2 : i32 + } + llvm.func @strlen(!llvm.ptr) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} +} diff --git a/test/LLVMDialect/InstCombine/2008-06-19-UncondLoad.ll.mlir b/test/LLVMDialect/InstCombine/2008-06-19-UncondLoad.ll.mlir new file mode 100644 index 000000000..72e992d6c --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-06-19-UncondLoad.ll.mlir @@ -0,0 +1,14 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @x(!llvm.ptr) -> i32 + llvm.func @b(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %2 = llvm.load %arg1 {alignment = 4 : i64} : !llvm.ptr -> i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.call @x(%arg0) : (!llvm.ptr) -> i32 + %5 = llvm.icmp "ne" %3, %0 : i32 + %6 = llvm.select %5, %arg1, %arg0 : i1, !llvm.ptr + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-06-21-CompareMiscomp.ll.mlir b/test/LLVMDialect/InstCombine/2008-06-21-CompareMiscomp.ll.mlir new file mode 100644 index 000000000..826551957 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-06-21-CompareMiscomp.ll.mlir @@ -0,0 +1,19 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(13 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %0 : i32 + %3 = llvm.icmp "eq" %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(13 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-06-24-StackRestore.ll.mlir b/test/LLVMDialect/InstCombine/2008-06-24-StackRestore.ll.mlir index b6de5cd06..00f50d74f 100644 --- a/test/LLVMDialect/InstCombine/2008-06-24-StackRestore.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-06-24-StackRestore.ll.mlir @@ -1,42 +1,35 @@ -"module"() ( { - "llvm.mlir.global"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 4 : i64, sym_name = "p", type = !llvm.ptr} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 999999 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @p} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 1000 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.addressof"() {global_name = @p} : () -> !llvm.ptr> - %5 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %7 = "llvm.call"() {callee = @llvm.stacksave, fastmathFlags = #llvm.fastmath<>} : () -> !llvm.ptr - %8 = "llvm.alloca"(%6) : (i32) -> !llvm.ptr - %9 = "llvm.bitcast"(%8) : (!llvm.ptr) -> !llvm.ptr - "llvm.store"(%5, %8) : (i32, !llvm.ptr) -> () - "llvm.store"(%9, %4) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.br"(%3, %7)[^bb2] : (i32, !llvm.ptr) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global weak @p() {addr_space = 0 : i32} : !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @main() -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.addressof @p : !llvm.ptr + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(1000 : i32) : i32 + %6 = llvm.mlir.constant(999999 : i32) : i32 + %7 = llvm.intr.stacksave : !llvm.ptr + %8 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %8 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store volatile %8, %3 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.br ^bb2(%4, %7 : i32, !llvm.ptr) ^bb1: // pred: ^bb2 - "llvm.return"(%3) : (i32) -> () - ^bb2(%10: i32, %11: !llvm.ptr): // 2 preds: ^bb0, ^bb2 - %12 = "llvm.add"(%10, %6) : (i32, i32) -> i32 - "llvm.call"(%11) {callee = @llvm.stackrestore, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - %13 = "llvm.call"() {callee = @llvm.stacksave, fastmathFlags = #llvm.fastmath<>} : () -> !llvm.ptr - %14 = "llvm.srem"(%12, %2) : (i32, i32) -> i32 - %15 = "llvm.add"(%14, %6) : (i32, i32) -> i32 - %16 = "llvm.alloca"(%15) : (i32) -> !llvm.ptr - %17 = "llvm.bitcast"(%16) : (!llvm.ptr) -> !llvm.ptr - "llvm.store"(%6, %16) : (i32, !llvm.ptr) -> () - %18 = "llvm.getelementptr"(%16, %14) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%5, %18) : (i32, !llvm.ptr) -> () - "llvm.store"(%17, %1) : (!llvm.ptr, !llvm.ptr>) -> () - %19 = "llvm.icmp"(%12, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%19, %12, %13)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 2]> : vector<3xi32>} : (i1, i32, !llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "main", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.stacksave", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.stackrestore", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %4 : i32 + ^bb2(%9: i32, %10: !llvm.ptr): // 2 preds: ^bb0, ^bb2 + %11 = llvm.add %9, %0 : i32 + llvm.intr.stackrestore %10 : !llvm.ptr + %12 = llvm.intr.stacksave : !llvm.ptr + %13 = llvm.srem %11, %5 : i32 + %14 = llvm.add %13, %0 : i32 + %15 = llvm.alloca %14 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %0, %15 {alignment = 4 : i64} : i32, !llvm.ptr + %16 = llvm.getelementptr %15[%13] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %1, %16 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store volatile %15, %3 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + %17 = llvm.icmp "eq" %11, %6 : i32 + llvm.cond_br %17, ^bb1, ^bb2(%11, %12 : i32, !llvm.ptr) + } +} diff --git a/test/LLVMDialect/InstCombine/2008-07-08-ShiftOneAndOne.ll.mlir b/test/LLVMDialect/InstCombine/2008-07-08-ShiftOneAndOne.ll.mlir index 705105e02..c2523fd91 100644 --- a/test/LLVMDialect/InstCombine/2008-07-08-ShiftOneAndOne.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-07-08-ShiftOneAndOne.ll.mlir @@ -1,12 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.shl"(%1, %arg0) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %1) : (i32, i32) -> i32 - %4 = "llvm.icmp"(%3, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "PR2330", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @PR2330(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-07-08-SubAnd.ll.mlir b/test/LLVMDialect/InstCombine/2008-07-08-SubAnd.ll.mlir index 464561b77..a0ebb9cf3 100644 --- a/test/LLVMDialect/InstCombine/2008-07-08-SubAnd.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-07-08-SubAnd.ll.mlir @@ -1,11 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.sub"(%1, %arg0) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "a", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a(%arg0: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-07-08-VolatileLoadMerge.ll.mlir b/test/LLVMDialect/InstCombine/2008-07-08-VolatileLoadMerge.ll.mlir index 6fe4d5d93..2ed024e2c 100644 --- a/test/LLVMDialect/InstCombine/2008-07-08-VolatileLoadMerge.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-07-08-VolatileLoadMerge.ll.mlir @@ -1,26 +1,22 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 1 : i64, sym_name = "g_1", type = i32, value = 0 : i32} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @g_1} : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @g_1} : () -> !llvm.ptr - %3 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %4 = "llvm.mlir.addressof"() {global_name = @g_1} : () -> !llvm.ptr - %5 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %7 = "llvm.icmp"(%6, %5) {predicate = 2 : i64} : (i32, i32) -> i1 - %8 = "llvm.load"(%4) : (!llvm.ptr) -> i32 - "llvm.br"(%6, %8)[^bb1] : (i32, i32) -> () - ^bb1(%9: i32, %10: i32): // 2 preds: ^bb0, ^bb1 - %11 = "llvm.add"(%10, %3) : (i32, i32) -> i32 - "llvm.store"(%11, %2) : (i32, !llvm.ptr) -> () - %12 = "llvm.add"(%9, %1) : (i32, i32) -> i32 - %13 = "llvm.icmp"(%12, %5) {predicate = 2 : i64} : (i32, i32) -> i1 - %14 = "llvm.load"(%0) : (!llvm.ptr) -> i32 - "llvm.cond_br"(%13, %12, %14)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 2, 0]> : vector<3xi32>} : (i1, i32, i32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal @g_1(0 : i32) {addr_space = 0 : i32, dso_local} : i32 + llvm.func @main() -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.addressof @g_1 : !llvm.ptr + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.icmp "slt" %0, %1 : i32 + %6 = llvm.load volatile %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb1(%0, %6 : i32, i32) + ^bb1(%7: i32, %8: i32): // 2 preds: ^bb0, ^bb1 + %9 = llvm.add %8, %3 : i32 + llvm.store volatile %9, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %10 = llvm.add %7, %4 : i32 + %11 = llvm.icmp "slt" %10, %1 : i32 + %12 = llvm.load volatile %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.cond_br %11, ^bb1(%10, %12 : i32, i32), ^bb2 ^bb2: // pred: ^bb1 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "main", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-07-09-SubAndError.ll.mlir b/test/LLVMDialect/InstCombine/2008-07-09-SubAndError.ll.mlir index c545247ad..35e5acdbc 100644 --- a/test/LLVMDialect/InstCombine/2008-07-09-SubAndError.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-07-09-SubAndError.ll.mlir @@ -1,11 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.sub"(%1, %arg0) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-07-10-CastSextBool.ll.mlir b/test/LLVMDialect/InstCombine/2008-07-10-CastSextBool.ll.mlir index 6b3e9f2ea..e0e5dfdb5 100644 --- a/test/LLVMDialect/InstCombine/2008-07-10-CastSextBool.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-07-10-CastSextBool.ll.mlir @@ -1,16 +1,13 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i1) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "PR2539_A", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 2 : i64} : (i1, i1) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "PR2539_B", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @PR2539_A(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @PR2539_B(%arg0: i1 {llvm.zeroext}) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "slt" %arg0, %0 : i1 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-07-11-RemAnd.ll.mlir b/test/LLVMDialect/InstCombine/2008-07-11-RemAnd.ll.mlir index 215c11fbe..724d518b0 100644 --- a/test/LLVMDialect/InstCombine/2008-07-11-RemAnd.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-07-11-RemAnd.ll.mlir @@ -1,19 +1,16 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.srem"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "a", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.mlir.constant"() {value = dense<8> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.srem"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.and"(%2, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%3) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "a_vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a(%arg0: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @a_vec(%arg0: vector<2xi32>) -> vector<2xi32> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.srem %arg0, %0 : vector<2xi32> + %3 = llvm.and %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/2008-07-13-DivZero.ll.mlir b/test/LLVMDialect/InstCombine/2008-07-13-DivZero.ll.mlir new file mode 100644 index 000000000..0d160a2e8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-07-13-DivZero.ll.mlir @@ -0,0 +1,12 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.icmp "ne" %arg1, %0 : i32 + %3 = llvm.select %2, %1, %0 : i1, i32 + %4 = llvm.call @b(%3) : (i32) -> i32 + %5 = llvm.udiv %arg0, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @b(i32) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/2008-07-16-fsub.ll.mlir b/test/LLVMDialect/InstCombine/2008-07-16-fsub.ll.mlir index 0e0bf085f..f19231534 100644 --- a/test/LLVMDialect/InstCombine/2008-07-16-fsub.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-07-16-fsub.ll.mlir @@ -1,8 +1,6 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.fsub"(%arg0, %arg0) : (f64, f64) -> f64 - "llvm.return"(%0) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: f64) -> f64 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fsub %arg0, %arg0 : f64 + llvm.return %0 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-08-05-And.ll.mlir b/test/LLVMDialect/InstCombine/2008-08-05-And.ll.mlir new file mode 100644 index 000000000..36259eb4d --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-08-05-And.ll.mlir @@ -0,0 +1,39 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f(%arg0: !llvm.ptr) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(10 : i8) : i8 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + %3 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %4 = llvm.sub %3, %0 : i8 + %5 = llvm.icmp "ugt" %4, %1 : i8 + %6 = llvm.sub %3, %2 : i8 + %7 = llvm.icmp "ugt" %6, %1 : i8 + %8 = llvm.and %5, %7 : i1 + llvm.cond_br %8, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return + ^bb3: // pred: ^bb1 + llvm.return + } + llvm.func @f_logical(%arg0: !llvm.ptr) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(10 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + %4 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %5 = llvm.sub %4, %0 : i8 + %6 = llvm.icmp "ugt" %5, %1 : i8 + %7 = llvm.sub %4, %2 : i8 + %8 = llvm.icmp "ugt" %7, %1 : i8 + %9 = llvm.select %6, %8, %3 : i1, i1 + llvm.cond_br %9, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return + ^bb3: // pred: ^bb1 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2008-09-02-VectorCrash.ll.mlir b/test/LLVMDialect/InstCombine/2008-09-02-VectorCrash.ll.mlir new file mode 100644 index 000000000..2036ed375 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-09-02-VectorCrash.ll.mlir @@ -0,0 +1,30 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @entry(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.mlir.zero : !llvm.ptr + llvm.br ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb3 + %7 = llvm.icmp "slt" %0, %arg4 : i32 + llvm.cond_br %7, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return + ^bb3: // 2 preds: ^bb1, ^bb4 + %8 = llvm.icmp "slt" %0, %arg2 : i32 + llvm.cond_br %8, ^bb4, ^bb1 + ^bb4: // pred: ^bb3 + %9 = llvm.srem %1, %1 : vector<2xi32> + %10 = llvm.extractelement %9[%2 : i32] : vector<2xi32> + %11 = llvm.select %3, %0, %10 : i1, i32 + %12 = llvm.insertelement %11, %1[%2 : i32] : vector<2xi32> + %13 = llvm.extractelement %12[%2 : i32] : vector<2xi32> + %14 = llvm.insertelement %13, %4[%5 : i32] : vector<4xi32> + %15 = llvm.sitofp %14 : vector<4xi32> to vector<4xf32> + llvm.store %15, %6 {alignment = 16 : i64} : vector<4xf32>, !llvm.ptr + llvm.br ^bb3 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-10-11-DivCompareFold.ll.mlir b/test/LLVMDialect/InstCombine/2008-10-11-DivCompareFold.ll.mlir index 7149aef63..3197245bd 100644 --- a/test/LLVMDialect/InstCombine/2008-10-11-DivCompareFold.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-10-11-DivCompareFold.ll.mlir @@ -1,11 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -65536 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 65536 : i32} : () -> i32 - %2 = "llvm.sdiv"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "x", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @x(%arg0: i32) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.mlir.constant(-65536 : i32) : i32 + %2 = llvm.sdiv %arg0, %0 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-10-23-ConstFoldWithoutMask.ll.mlir b/test/LLVMDialect/InstCombine/2008-10-23-ConstFoldWithoutMask.ll.mlir index cc1b87c98..c3d7f5efd 100644 --- a/test/LLVMDialect/InstCombine/2008-10-23-ConstFoldWithoutMask.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-10-23-ConstFoldWithoutMask.ll.mlir @@ -1,9 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.inttoptr"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "tstid", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @tstid() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.inttoptr %0 : i32 to !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-11-01-SRemDemandedBits.ll.mlir b/test/LLVMDialect/InstCombine/2008-11-01-SRemDemandedBits.ll.mlir index cd192eb9a..ae184e7e0 100644 --- a/test/LLVMDialect/InstCombine/2008-11-01-SRemDemandedBits.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-11-01-SRemDemandedBits.ll.mlir @@ -1,11 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %2 = "llvm.srem"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.icmp"(%2, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-11-08-FCmp.ll.mlir b/test/LLVMDialect/InstCombine/2008-11-08-FCmp.ll.mlir new file mode 100644 index 000000000..40bfeb4d0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2008-11-08-FCmp.ll.mlir @@ -0,0 +1,44 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.uitofp %arg0 : i32 to f64 + %2 = llvm.fcmp "ole" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @test2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.uitofp %arg0 : i32 to f64 + %2 = llvm.fcmp "olt" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @test3(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.uitofp %arg0 : i32 to f64 + %2 = llvm.fcmp "oge" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @test4(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.uitofp %arg0 : i32 to f64 + %2 = llvm.fcmp "ogt" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @test5(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-4.400000e+00 : f64) : f64 + %1 = llvm.uitofp %arg0 : i32 to f64 + %2 = llvm.fcmp "ogt" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @test6(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-4.400000e+00 : f64) : f64 + %1 = llvm.uitofp %arg0 : i32 to f64 + %2 = llvm.fcmp "olt" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @test7(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3.200000e+00 : f64) : f64 + %1 = llvm.uitofp %arg0 : i32 to f64 + %2 = llvm.fcmp "oge" %1, %0 : f64 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2008-11-27-IDivVector.ll.mlir b/test/LLVMDialect/InstCombine/2008-11-27-IDivVector.ll.mlir index 313b35d9a..5b3cda018 100644 --- a/test/LLVMDialect/InstCombine/2008-11-27-IDivVector.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-11-27-IDivVector.ll.mlir @@ -1,15 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.udiv"(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.return"(%1) : (vector<2xi8>) -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.sdiv"(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.return"(%1) : (vector<2xi8>) -> () - }) {linkage = 10 : i64, sym_name = "g", type = !llvm.func (vector<2xi8>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.udiv %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @g(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sdiv %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/2008-11-27-MultiplyIntVec.ll.mlir b/test/LLVMDialect/InstCombine/2008-11-27-MultiplyIntVec.ll.mlir index 1a0d3ef07..da4b779b4 100644 --- a/test/LLVMDialect/InstCombine/2008-11-27-MultiplyIntVec.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-11-27-MultiplyIntVec.ll.mlir @@ -1,15 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.mul"(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.return"(%1) : (vector<2xi8>) -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-1> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.mul"(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.return"(%1) : (vector<2xi8>) -> () - }) {linkage = 10 : i64, sym_name = "g", type = !llvm.func (vector<2xi8>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mul %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @g(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mul %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/2008-12-17-SRemNegConstVec.ll.mlir b/test/LLVMDialect/InstCombine/2008-12-17-SRemNegConstVec.ll.mlir index 61a68783d..1b3a29c55 100644 --- a/test/LLVMDialect/InstCombine/2008-12-17-SRemNegConstVec.ll.mlir +++ b/test/LLVMDialect/InstCombine/2008-12-17-SRemNegConstVec.ll.mlir @@ -1,9 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[2, -2]> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.srem"(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.return"(%1) : (vector<2xi8>) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func (vector<2xi8>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[2, -2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.srem %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/2009-01-05-i128-crash.ll.mlir b/test/LLVMDialect/InstCombine/2009-01-05-i128-crash.ll.mlir new file mode 100644 index 000000000..005325091 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2009-01-05-i128-crash.ll.mlir @@ -0,0 +1,23 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func hidden @"\01_gfortrani_max_value"(%arg0: i32, %arg1: i32) -> i128 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(18446744073709551615 : i128) : i128 + %2 = llvm.mlir.constant(9223372036854775807 : i128) : i128 + %3 = llvm.mlir.constant(0 : i128) : i128 + llvm.switch %arg0 : i32, ^bb3 [ + 1: ^bb4, + 4: ^bb2, + 8: ^bb1 + ] + ^bb1: // pred: ^bb0 + %4 = llvm.icmp "eq" %arg1, %0 : i32 + %5 = llvm.select %4, %1, %2 : i1, i128 + llvm.return %5 : i128 + ^bb2: // pred: ^bb0 + llvm.return %3 : i128 + ^bb3: // pred: ^bb0 + llvm.return %3 : i128 + ^bb4: // pred: ^bb0 + llvm.return %3 : i128 + } +} diff --git a/test/LLVMDialect/InstCombine/2009-01-08-AlignAlloca.ll.mlir b/test/LLVMDialect/InstCombine/2009-01-08-AlignAlloca.ll.mlir index 258727437..d4a504905 100644 --- a/test/LLVMDialect/InstCombine/2009-01-08-AlignAlloca.ll.mlir +++ b/test/LLVMDialect/InstCombine/2009-01-08-AlignAlloca.ll.mlir @@ -1,24 +1,20 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr)>> - %3 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - %4 = "llvm.bitcast"(%0) : (i32) -> i32 - %5 = "llvm.getelementptr"(%2, %0, %0) : (!llvm.ptr)>>, i32, i32) -> !llvm.ptr> - %6 = "llvm.getelementptr"(%5, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - "llvm.store"(%0, %6) : (i32, !llvm.ptr) -> () - %7 = "llvm.getelementptr"(%5, %0, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - "llvm.store"(%0, %7) : (i32, !llvm.ptr) -> () - %8 = "llvm.getelementptr"(%2, %0, %0) : (!llvm.ptr)>>, i32, i32) -> !llvm.ptr> - %9 = "llvm.bitcast"(%8) : (!llvm.ptr>) -> !llvm.ptr - "llvm.store"(%arg0, %9) : (i64, !llvm.ptr) -> () - %10 = "llvm.call"(%2, %3) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr)>>, !llvm.ptr) -> i32 - %11 = "llvm.load"(%3) : (!llvm.ptr) -> i32 - "llvm.return"(%11) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bar(%arg0: i64) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x !llvm.struct<"struct.Key", (struct<(i32, i32)>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %4 = llvm.bitcast %1 : i32 to i32 + %5 = llvm.getelementptr %2[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.Key", (struct<(i32, i32)>)> + %6 = llvm.getelementptr %5[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i32, i32)> + llvm.store %1, %6 {alignment = 4 : i64} : i32, !llvm.ptr + %7 = llvm.getelementptr %5[%1, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i32, i32)> + llvm.store %1, %7 {alignment = 4 : i64} : i32, !llvm.ptr + %8 = llvm.getelementptr %2[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.Key", (struct<(i32, i32)>)> + llvm.store %arg0, %8 {alignment = 4 : i64} : i64, !llvm.ptr + %9 = llvm.call @foo(%2, %3) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + %10 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %10 : i32 + } + llvm.func @foo(...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/2009-01-16-PointerAddrSpace.ll.mlir b/test/LLVMDialect/InstCombine/2009-01-16-PointerAddrSpace.ll.mlir index ea43c43cc..33f9467ee 100644 --- a/test/LLVMDialect/InstCombine/2009-01-16-PointerAddrSpace.ll.mlir +++ b/test/LLVMDialect/InstCombine/2009-01-16-PointerAddrSpace.ll.mlir @@ -1,10 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.addrspacecast"(%arg0) : (!llvm.ptr) -> !llvm.ptr - "llvm.store"(%0, %1) : (i32, !llvm.ptr) -> () - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: !llvm.ptr) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.addrspacecast %arg0 : !llvm.ptr to !llvm.ptr<1> + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr<1> + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2009-01-19-fmod-constant-float-specials.ll.mlir b/test/LLVMDialect/InstCombine/2009-01-19-fmod-constant-float-specials.ll.mlir new file mode 100644 index 000000000..6224425c0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2009-01-19-fmod-constant-float-specials.ll.mlir @@ -0,0 +1,352 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal constant @"\01LC"("%f\0A\00") {addr_space = 0 : i32, dso_local} + llvm.func @foo1() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %3 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %4 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %8 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %7 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %3, %6 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %10 = llvm.fpext %9 : f32 to f64 + %11 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %12 = llvm.fpext %11 : f32 to f64 + %13 = llvm.frem %12, %10 : f64 + %14 = llvm.call @printf(%5, %13) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @printf(!llvm.ptr, ...) -> i32 attributes {passthrough = ["nounwind"]} + llvm.func @foo2() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %3 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %4 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %8 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %7 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %3, %6 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %10 = llvm.fpext %9 : f32 to f64 + %11 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %12 = llvm.fpext %11 : f32 to f64 + %13 = llvm.frem %12, %10 : f64 + %14 = llvm.call @printf(%5, %13) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @foo3() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %3 = llvm.mlir.constant(3.500000e+00 : f32) : f32 + %4 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %8 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %7 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %3, %6 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %10 = llvm.fpext %9 : f32 to f64 + %11 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %12 = llvm.fpext %11 : f32 to f64 + %13 = llvm.frem %12, %10 : f64 + %14 = llvm.call @printf(%5, %13) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @foo4() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %3 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %5 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %6 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %2, %5 {alignment = 4 : i64} : f32, !llvm.ptr + %8 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> f32 + %9 = llvm.fpext %8 : f32 to f64 + %10 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %11 = llvm.fpext %10 : f32 to f64 + %12 = llvm.frem %11, %9 : f64 + %13 = llvm.call @printf(%4, %12) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @foo5() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %3 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %4 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %8 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %7 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %3, %6 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %10 = llvm.fpext %9 : f32 to f64 + %11 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %12 = llvm.fpext %11 : f32 to f64 + %13 = llvm.frem %12, %10 : f64 + %14 = llvm.call @printf(%5, %13) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @foo6() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %3 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %4 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %8 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %7 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %3, %6 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %10 = llvm.fpext %9 : f32 to f64 + %11 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %12 = llvm.fpext %11 : f32 to f64 + %13 = llvm.frem %12, %10 : f64 + %14 = llvm.call @printf(%5, %13) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @foo7() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %3 = llvm.mlir.constant(3.500000e+00 : f32) : f32 + %4 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %8 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %7 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %3, %6 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %10 = llvm.fpext %9 : f32 to f64 + %11 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %12 = llvm.fpext %11 : f32 to f64 + %13 = llvm.frem %12, %10 : f64 + %14 = llvm.call @printf(%5, %13) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @foo8() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %3 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %5 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %6 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %2, %5 {alignment = 4 : i64} : f32, !llvm.ptr + %8 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> f32 + %9 = llvm.fpext %8 : f32 to f64 + %10 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %11 = llvm.fpext %10 : f32 to f64 + %12 = llvm.frem %11, %9 : f64 + %13 = llvm.call @printf(%4, %12) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @foo9() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %4 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %8 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %7 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %3, %6 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %10 = llvm.fpext %9 : f32 to f64 + %11 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %12 = llvm.fpext %11 : f32 to f64 + %13 = llvm.frem %12, %10 : f64 + %14 = llvm.call @printf(%5, %13) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @foo10() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %4 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %8 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %7 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %3, %6 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %10 = llvm.fpext %9 : f32 to f64 + %11 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %12 = llvm.fpext %11 : f32 to f64 + %13 = llvm.frem %12, %10 : f64 + %14 = llvm.call @printf(%5, %13) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @foo11() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %5 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %6 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %2, %5 {alignment = 4 : i64} : f32, !llvm.ptr + %8 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> f32 + %9 = llvm.fpext %8 : f32 to f64 + %10 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %11 = llvm.fpext %10 : f32 to f64 + %12 = llvm.frem %11, %9 : f64 + %13 = llvm.call @printf(%4, %12) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @foo12() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(3.500000e+00 : f32) : f32 + %4 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %8 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %7 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %3, %6 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %10 = llvm.fpext %9 : f32 to f64 + %11 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %12 = llvm.fpext %11 : f32 to f64 + %13 = llvm.frem %12, %10 : f64 + %14 = llvm.call @printf(%5, %13) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @foo13() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3.500000e+00 : f32) : f32 + %3 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %4 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %8 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %7 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %3, %6 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %10 = llvm.fpext %9 : f32 to f64 + %11 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %12 = llvm.fpext %11 : f32 to f64 + %13 = llvm.frem %12, %10 : f64 + %14 = llvm.call @printf(%5, %13) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @foo14() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3.500000e+00 : f32) : f32 + %3 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %4 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %8 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %7 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %3, %6 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %10 = llvm.fpext %9 : f32 to f64 + %11 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %12 = llvm.fpext %11 : f32 to f64 + %13 = llvm.frem %12, %10 : f64 + %14 = llvm.call @printf(%5, %13) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @foo15() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3.500000e+00 : f32) : f32 + %3 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %4 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %8 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %7 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %3, %6 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %10 = llvm.fpext %9 : f32 to f64 + %11 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %12 = llvm.fpext %11 : f32 to f64 + %13 = llvm.frem %12, %10 : f64 + %14 = llvm.call @printf(%5, %13) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @foo16() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3.500000e+00 : f32) : f32 + %3 = llvm.mlir.constant("%f\0A\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.addressof @"\01LC" : !llvm.ptr + %5 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %6 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %6 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %2, %5 {alignment = 4 : i64} : f32, !llvm.ptr + %8 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> f32 + %9 = llvm.fpext %8 : f32 to f64 + %10 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %11 = llvm.fpext %10 : f32 to f64 + %12 = llvm.frem %11, %9 : f64 + %13 = llvm.call @printf(%4, %12) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2009-01-19-fmod-constant-float.ll.mlir b/test/LLVMDialect/InstCombine/2009-01-19-fmod-constant-float.ll.mlir index 5d4989c14..a00e58b76 100644 --- a/test/LLVMDialect/InstCombine/2009-01-19-fmod-constant-float.ll.mlir +++ b/test/LLVMDialect/InstCombine/2009-01-19-fmod-constant-float.ll.mlir @@ -1,75 +1,74 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.mlir.constant"() {value = 1.000000e-01 : f64} : () -> f64 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr - %5 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr - %6 = "llvm.bitcast"(%2) : (i32) -> i32 - %7 = "llvm.frem"(%1, %0) : (f64, f64) -> f64 - %8 = "llvm.fptrunc"(%7) : (f64) -> f32 - "llvm.store"(%8, %5) : (f32, !llvm.ptr) -> () - %9 = "llvm.load"(%5) : (!llvm.ptr) -> f32 - "llvm.store"(%9, %4) : (f32, !llvm.ptr) -> () - "llvm.br"()[^bb1] : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1() -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1.000000e-01 : f64) : f64 + %3 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %4 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %5 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %6 = llvm.bitcast %1 : i32 to i32 + %7 = llvm.frem %2, %3 : f64 + %8 = llvm.fptrunc %7 : f64 to f32 + llvm.store %8, %5 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.store %9, %4 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.br ^bb1 ^bb1: // pred: ^bb0 - %10 = "llvm.load"(%4) : (!llvm.ptr) -> f32 - "llvm.return"(%10) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.mlir.constant"() {value = -1.000000e-01 : f64} : () -> f64 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr - %5 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr - %6 = "llvm.bitcast"(%2) : (i32) -> i32 - %7 = "llvm.frem"(%1, %0) : (f64, f64) -> f64 - %8 = "llvm.fptrunc"(%7) : (f64) -> f32 - "llvm.store"(%8, %5) : (f32, !llvm.ptr) -> () - %9 = "llvm.load"(%5) : (!llvm.ptr) -> f32 - "llvm.store"(%9, %4) : (f32, !llvm.ptr) -> () - "llvm.br"()[^bb1] : () -> () + %10 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.return %10 : f32 + } + llvm.func @test2() -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1.000000e-01 : f64) : f64 + %3 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %4 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %5 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %6 = llvm.bitcast %1 : i32 to i32 + %7 = llvm.frem %2, %3 : f64 + %8 = llvm.fptrunc %7 : f64 to f32 + llvm.store %8, %5 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.store %9, %4 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.br ^bb1 ^bb1: // pred: ^bb0 - %10 = "llvm.load"(%4) : (!llvm.ptr) -> f32 - "llvm.return"(%10) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = -1.000000e+00 : f64} : () -> f64 - %1 = "llvm.mlir.constant"() {value = 1.000000e-01 : f64} : () -> f64 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr - %5 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr - %6 = "llvm.bitcast"(%2) : (i32) -> i32 - %7 = "llvm.frem"(%1, %0) : (f64, f64) -> f64 - %8 = "llvm.fptrunc"(%7) : (f64) -> f32 - "llvm.store"(%8, %5) : (f32, !llvm.ptr) -> () - %9 = "llvm.load"(%5) : (!llvm.ptr) -> f32 - "llvm.store"(%9, %4) : (f32, !llvm.ptr) -> () - "llvm.br"()[^bb1] : () -> () + %10 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.return %10 : f32 + } + llvm.func @test3() -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1.000000e-01 : f64) : f64 + %3 = llvm.mlir.constant(-1.000000e+00 : f64) : f64 + %4 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %5 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %6 = llvm.bitcast %1 : i32 to i32 + %7 = llvm.frem %2, %3 : f64 + %8 = llvm.fptrunc %7 : f64 to f32 + llvm.store %8, %5 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.store %9, %4 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.br ^bb1 ^bb1: // pred: ^bb0 - %10 = "llvm.load"(%4) : (!llvm.ptr) -> f32 - "llvm.return"(%10) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = -1.000000e+00 : f64} : () -> f64 - %1 = "llvm.mlir.constant"() {value = -1.000000e-01 : f64} : () -> f64 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr - %5 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr - %6 = "llvm.bitcast"(%2) : (i32) -> i32 - %7 = "llvm.frem"(%1, %0) : (f64, f64) -> f64 - %8 = "llvm.fptrunc"(%7) : (f64) -> f32 - "llvm.store"(%8, %5) : (f32, !llvm.ptr) -> () - %9 = "llvm.load"(%5) : (!llvm.ptr) -> f32 - "llvm.store"(%9, %4) : (f32, !llvm.ptr) -> () - "llvm.br"()[^bb1] : () -> () + %10 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.return %10 : f32 + } + llvm.func @test4() -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1.000000e-01 : f64) : f64 + %3 = llvm.mlir.constant(-1.000000e+00 : f64) : f64 + %4 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %5 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %6 = llvm.bitcast %1 : i32 to i32 + %7 = llvm.frem %2, %3 : f64 + %8 = llvm.fptrunc %7 : f64 to f32 + llvm.store %8, %5 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.store %9, %4 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.br ^bb1 ^bb1: // pred: ^bb0 - %10 = "llvm.load"(%4) : (!llvm.ptr) -> f32 - "llvm.return"(%10) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %10 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.return %10 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/2009-01-24-EmptyStruct.ll.mlir b/test/LLVMDialect/InstCombine/2009-01-24-EmptyStruct.ll.mlir index 5b33f04fa..587477e32 100644 --- a/test/LLVMDialect/InstCombine/2009-01-24-EmptyStruct.ll.mlir +++ b/test/LLVMDialect/InstCombine/2009-01-24-EmptyStruct.ll.mlir @@ -1,12 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, struct<"struct.rwlock_t", (struct<"struct.lock_class_key", ()>)>, struct<"struct.list_head", (ptr>, ptr>)>)>)>>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -1 : i64} : () -> i64 - %2 = "llvm.getelementptr"(%arg0, %1, %0, %0) : (!llvm.ptr, struct<"struct.rwlock_t", (struct<"struct.lock_class_key", ()>)>, struct<"struct.list_head", (ptr>, ptr>)>)>)>>, i64, i32, i32) -> !llvm.ptr)>> - %3 = "llvm.bitcast"(%2) : (!llvm.ptr)>>) -> !llvm.ptr - "llvm.store"(%0, %3) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "handle_event", type = !llvm.func, struct<"struct.rwlock_t", (struct<"struct.lock_class_key", ()>)>, struct<"struct.list_head", (ptr>, ptr>)>)>)>>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @handle_event(%arg0: !llvm.ptr) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.getelementptr %arg0[%0, 1, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct.inode", (i32, struct<"struct.mutex", (struct<"struct.atomic_t", (i32)>, struct<"struct.rwlock_t", (struct<"struct.lock_class_key", ()>)>, struct<"struct.list_head", (ptr, ptr)>)>)> + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2009-01-31-InfIterate.ll.mlir b/test/LLVMDialect/InstCombine/2009-01-31-InfIterate.ll.mlir index 6d3b20d6e..0bc790389 100644 --- a/test/LLVMDialect/InstCombine/2009-01-31-InfIterate.ll.mlir +++ b/test/LLVMDialect/InstCombine/2009-01-31-InfIterate.ll.mlir @@ -1,20 +1,16 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64, %arg2: i1, %arg3: i128, %arg4: i128, %arg5: !llvm.ptr, %arg6: !llvm.ptr): // no predecessors - %0 = "llvm.trunc"(%arg3) : (i128) -> i64 - %1 = "llvm.trunc"(%arg4) : (i128) -> i64 - "llvm.store"(%0, %arg5) : (i64, !llvm.ptr) -> () - "llvm.store"(%1, %arg6) : (i64, !llvm.ptr) -> () - %2 = "llvm.sub"(%0, %1) : (i64, i64) -> i64 - %3 = "llvm.sub"(%0, %1) : (i64, i64) -> i64 - %4 = "llvm.zext"(%arg2) : (i1) -> i64 - %5 = "llvm.sub"(%3, %4) : (i64, i64) -> i64 - "llvm.br"(%5)[^bb1] : (i64) -> () - ^bb1(%6: i64): // 2 preds: ^bb0, ^bb2 - %7 = "llvm.zext"(%6) : (i64) -> i128 - "llvm.return"(%7) : (i128) -> () - ^bb2: // no predecessors - "llvm.br"(%0)[^bb1] : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i64, %arg1: i64, %arg2: i1, %arg3: i128, %arg4: i128, %arg5: !llvm.ptr, %arg6: !llvm.ptr) -> i128 { + %0 = llvm.trunc %arg3 : i128 to i64 + %1 = llvm.trunc %arg4 : i128 to i64 + llvm.store %0, %arg5 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.store %1, %arg6 {alignment = 4 : i64} : i64, !llvm.ptr + %2 = llvm.sub %0, %1 : i64 + %3 = llvm.sub %0, %1 : i64 + %4 = llvm.zext %arg2 : i1 to i64 + %5 = llvm.sub %3, %4 : i64 + llvm.br ^bb1(%5 : i64) + ^bb1(%6: i64): // pred: ^bb0 + %7 = llvm.zext %6 : i64 to i128 + llvm.return %7 : i128 + } +} diff --git a/test/LLVMDialect/InstCombine/2009-02-04-FPBitcast.ll.mlir b/test/LLVMDialect/InstCombine/2009-02-04-FPBitcast.ll.mlir index 78e7843e6..1ef411b66 100644 --- a/test/LLVMDialect/InstCombine/2009-02-04-FPBitcast.ll.mlir +++ b/test/LLVMDialect/InstCombine/2009-02-04-FPBitcast.ll.mlir @@ -1,13 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i80} : () -> i80 - %1 = "llvm.bitcast"(%0) : (i80) -> f80 - "llvm.return"(%1) : (f80) -> () - }) {linkage = 10 : i64, sym_name = "cast", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0.000000e+00 : f32} : () -> f80 - %1 = "llvm.bitcast"(%0) : (f80) -> i80 - "llvm.return"(%1) : (i80) -> () - }) {linkage = 10 : i64, sym_name = "invcast", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @cast() -> f80 { + %0 = llvm.mlir.constant(0 : i80) : i80 + %1 = llvm.bitcast %0 : i80 to f80 + llvm.return %1 : f80 + } + llvm.func @invcast() -> i80 { + %0 = llvm.mlir.constant(0.000000e+00 : f80) : f80 + %1 = llvm.bitcast %0 : f80 to i80 + llvm.return %1 : i80 + } +} diff --git a/test/LLVMDialect/InstCombine/2009-02-11-NotInitialized.ll.mlir b/test/LLVMDialect/InstCombine/2009-02-11-NotInitialized.ll.mlir index 23444741d..af077da05 100644 --- a/test/LLVMDialect/InstCombine/2009-02-11-NotInitialized.ll.mlir +++ b/test/LLVMDialect/InstCombine/2009-02-11-NotInitialized.ll.mlir @@ -1,11 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @strlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i64 - %1 = "llvm.trunc"(%0) : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strlen", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(%arg0: !llvm.ptr) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.call @strlen(%arg0) : (!llvm.ptr) -> i64 + %1 = llvm.trunc %0 : i64 to i32 + llvm.return %1 : i32 + } + llvm.func @strlen(!llvm.ptr) -> i64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} +} diff --git a/test/LLVMDialect/InstCombine/2009-02-20-InstCombine-SROA.ll.mlir b/test/LLVMDialect/InstCombine/2009-02-20-InstCombine-SROA.ll.mlir new file mode 100644 index 000000000..b9a6aacca --- /dev/null +++ b/test/LLVMDialect/InstCombine/2009-02-20-InstCombine-SROA.ll.mlir @@ -0,0 +1,239 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @_Z3fooRSt6vectorIiSaIiEE(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.mlir.constant(1 : i64) : i64 + %5 = llvm.mlir.constant(2 : i32) : i32 + %6 = llvm.alloca %0 x !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %8 = llvm.alloca %0 x !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %9 = llvm.alloca %0 x !llvm.struct<"struct.std::bidirectional_iterator_tag", packed (i8)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %10 = llvm.alloca %0 x !llvm.struct<"struct.std::bidirectional_iterator_tag", packed (i8)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %11 = llvm.alloca %0 x !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %12 = llvm.alloca %0 x !llvm.struct<"struct.std::bidirectional_iterator_tag", packed (i8)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %13 = llvm.alloca %0 x !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %14 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %15 = llvm.bitcast %1 : i32 to i32 + llvm.store %2, %14 {alignment = 4 : i64} : i32, !llvm.ptr + %16 = llvm.getelementptr %arg0[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.std::vector >", (struct<"struct.std::_Vector_base >", (struct<"struct.std::_Vector_base >::_Vector_impl", (ptr, ptr, ptr)>)>)> + %17 = llvm.getelementptr %16[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.std::_Vector_base >", (struct<"struct.std::_Vector_base >::_Vector_impl", (ptr, ptr, ptr)>)> + %18 = llvm.getelementptr %17[%1, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.std::_Vector_base >::_Vector_impl", (ptr, ptr, ptr)> + %19 = llvm.load %18 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %20 = llvm.getelementptr %13[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + llvm.store %19, %20 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + %21 = llvm.getelementptr %13[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %22 = llvm.load %21 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %23 = llvm.ptrtoint %22 : !llvm.ptr to i32 + %24 = llvm.inttoptr %23 : i32 to !llvm.ptr + %25 = llvm.ptrtoint %24 : !llvm.ptr to i32 + %26 = llvm.inttoptr %25 : i32 to !llvm.ptr + %27 = llvm.getelementptr %arg0[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.std::vector >", (struct<"struct.std::_Vector_base >", (struct<"struct.std::_Vector_base >::_Vector_impl", (ptr, ptr, ptr)>)>)> + %28 = llvm.getelementptr %27[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.std::_Vector_base >", (struct<"struct.std::_Vector_base >::_Vector_impl", (ptr, ptr, ptr)>)> + %29 = llvm.getelementptr %28[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.std::_Vector_base >::_Vector_impl", (ptr, ptr, ptr)> + %30 = llvm.load %29 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %31 = llvm.getelementptr %6[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + llvm.store %30, %31 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + %32 = llvm.getelementptr %6[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %33 = llvm.load %32 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %34 = llvm.ptrtoint %33 : !llvm.ptr to i32 + %35 = llvm.inttoptr %34 : i32 to !llvm.ptr + %36 = llvm.ptrtoint %35 : !llvm.ptr to i32 + %37 = llvm.inttoptr %36 : i32 to !llvm.ptr + %38 = llvm.getelementptr %11[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + llvm.store %37, %38 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + %39 = llvm.load %10 {alignment = 1 : i64} : !llvm.ptr -> i8 + %40 = llvm.or %39, %3 : i8 + %41 = llvm.or %40, %3 : i8 + %42 = llvm.or %41, %3 : i8 + llvm.store %3, %12 {alignment = 1 : i64} : i8, !llvm.ptr + %43 = llvm.getelementptr %11[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %44 = llvm.load %43 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + "llvm.intr.memcpy"(%9, %12, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + %45 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + llvm.store %44, %45 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + %46 = llvm.getelementptr %8[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + llvm.store %26, %46 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + %47 = llvm.getelementptr %8[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %48 = llvm.load %47 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %49 = llvm.ptrtoint %48 : !llvm.ptr to i32 + %50 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %51 = llvm.load %50 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %52 = llvm.ptrtoint %51 : !llvm.ptr to i32 + %53 = llvm.sub %49, %52 : i32 + %54 = llvm.ashr %53, %5 : i32 + %55 = llvm.ashr %54, %5 : i32 + llvm.br ^bb10(%55 : i32) + ^bb1: // pred: ^bb10 + %56 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %57 = llvm.load %56 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %58 = llvm.load %57 {alignment = 4 : i64} : !llvm.ptr -> i32 + %59 = llvm.load %14 {alignment = 4 : i64} : !llvm.ptr -> i32 + %60 = llvm.icmp "eq" %58, %59 : i32 + %61 = llvm.zext %60 : i1 to i8 + %62 = llvm.icmp "ne" %61, %3 : i8 + llvm.cond_br %62, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %63 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %64 = llvm.load %63 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb22(%64 : !llvm.ptr) + ^bb3: // pred: ^bb1 + %65 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %66 = llvm.load %65 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %67 = llvm.getelementptr %66[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %68 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + llvm.store %67, %68 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + %69 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %70 = llvm.load %69 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %71 = llvm.load %70 {alignment = 4 : i64} : !llvm.ptr -> i32 + %72 = llvm.load %14 {alignment = 4 : i64} : !llvm.ptr -> i32 + %73 = llvm.icmp "eq" %71, %72 : i32 + %74 = llvm.zext %73 : i1 to i8 + %75 = llvm.icmp "ne" %74, %3 : i8 + llvm.cond_br %75, ^bb4, ^bb5 + ^bb4: // pred: ^bb3 + %76 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %77 = llvm.load %76 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb22(%77 : !llvm.ptr) + ^bb5: // pred: ^bb3 + %78 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %79 = llvm.load %78 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %80 = llvm.getelementptr %79[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %81 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + llvm.store %80, %81 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + %82 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %83 = llvm.load %82 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %84 = llvm.load %83 {alignment = 4 : i64} : !llvm.ptr -> i32 + %85 = llvm.load %14 {alignment = 4 : i64} : !llvm.ptr -> i32 + %86 = llvm.icmp "eq" %84, %85 : i32 + %87 = llvm.zext %86 : i1 to i8 + %88 = llvm.icmp "ne" %87, %3 : i8 + llvm.cond_br %88, ^bb6, ^bb7 + ^bb6: // pred: ^bb5 + %89 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %90 = llvm.load %89 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb22(%90 : !llvm.ptr) + ^bb7: // pred: ^bb5 + %91 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %92 = llvm.load %91 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %93 = llvm.getelementptr %92[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %94 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + llvm.store %93, %94 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + %95 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %96 = llvm.load %95 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %97 = llvm.load %96 {alignment = 4 : i64} : !llvm.ptr -> i32 + %98 = llvm.load %14 {alignment = 4 : i64} : !llvm.ptr -> i32 + %99 = llvm.icmp "eq" %97, %98 : i32 + %100 = llvm.zext %99 : i1 to i8 + %101 = llvm.icmp "ne" %100, %3 : i8 + llvm.cond_br %101, ^bb8, ^bb9 + ^bb8: // pred: ^bb7 + %102 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %103 = llvm.load %102 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb22(%103 : !llvm.ptr) + ^bb9: // pred: ^bb7 + %104 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %105 = llvm.load %104 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %106 = llvm.getelementptr %105[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %107 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + llvm.store %106, %107 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + %108 = llvm.sub %109, %0 : i32 + llvm.br ^bb10(%108 : i32) + ^bb10(%109: i32): // 2 preds: ^bb0, ^bb9 + %110 = llvm.icmp "sgt" %109, %1 : i32 + llvm.cond_br %110, ^bb1, ^bb11 + ^bb11: // pred: ^bb10 + %111 = llvm.getelementptr %8[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %112 = llvm.load %111 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %113 = llvm.ptrtoint %112 : !llvm.ptr to i32 + %114 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %115 = llvm.load %114 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %116 = llvm.ptrtoint %115 : !llvm.ptr to i32 + %117 = llvm.sub %113, %116 : i32 + %118 = llvm.ashr %117, %5 : i32 + llvm.switch %118 : i32, ^bb21 [ + 1: ^bb18, + 2: ^bb15, + 3: ^bb12 + ] + ^bb12: // pred: ^bb11 + %119 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %120 = llvm.load %119 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %121 = llvm.load %120 {alignment = 4 : i64} : !llvm.ptr -> i32 + %122 = llvm.load %14 {alignment = 4 : i64} : !llvm.ptr -> i32 + %123 = llvm.icmp "eq" %121, %122 : i32 + %124 = llvm.zext %123 : i1 to i8 + %125 = llvm.icmp "ne" %124, %3 : i8 + llvm.cond_br %125, ^bb13, ^bb14 + ^bb13: // pred: ^bb12 + %126 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %127 = llvm.load %126 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb22(%127 : !llvm.ptr) + ^bb14: // pred: ^bb12 + %128 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %129 = llvm.load %128 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %130 = llvm.getelementptr %129[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %131 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + llvm.store %130, %131 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.br ^bb15 + ^bb15: // 2 preds: ^bb11, ^bb14 + %132 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %133 = llvm.load %132 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %134 = llvm.load %133 {alignment = 4 : i64} : !llvm.ptr -> i32 + %135 = llvm.load %14 {alignment = 4 : i64} : !llvm.ptr -> i32 + %136 = llvm.icmp "eq" %134, %135 : i32 + %137 = llvm.zext %136 : i1 to i8 + %138 = llvm.icmp "ne" %137, %3 : i8 + llvm.cond_br %138, ^bb16, ^bb17 + ^bb16: // pred: ^bb15 + %139 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %140 = llvm.load %139 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb22(%140 : !llvm.ptr) + ^bb17: // pred: ^bb15 + %141 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %142 = llvm.load %141 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %143 = llvm.getelementptr %142[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %144 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + llvm.store %143, %144 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.br ^bb18 + ^bb18: // 2 preds: ^bb11, ^bb17 + %145 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %146 = llvm.load %145 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %147 = llvm.load %146 {alignment = 4 : i64} : !llvm.ptr -> i32 + %148 = llvm.load %14 {alignment = 4 : i64} : !llvm.ptr -> i32 + %149 = llvm.icmp "eq" %147, %148 : i32 + %150 = llvm.zext %149 : i1 to i8 + %151 = llvm.icmp "ne" %150, %3 : i8 + llvm.cond_br %151, ^bb19, ^bb20 + ^bb19: // pred: ^bb18 + %152 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %153 = llvm.load %152 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb22(%153 : !llvm.ptr) + ^bb20: // pred: ^bb18 + %154 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %155 = llvm.load %154 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %156 = llvm.getelementptr %155[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %157 = llvm.getelementptr %7[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + llvm.store %156, %157 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.br ^bb21 + ^bb21: // 2 preds: ^bb11, ^bb20 + %158 = llvm.getelementptr %8[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.__gnu_cxx::__normal_iterator > >", (ptr)> + %159 = llvm.load %158 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb22(%159 : !llvm.ptr) + ^bb22(%160: !llvm.ptr): // 8 preds: ^bb2, ^bb4, ^bb6, ^bb8, ^bb13, ^bb16, ^bb19, ^bb21 + %161 = llvm.ptrtoint %160 : !llvm.ptr to i32 + %162 = llvm.inttoptr %161 : i32 to !llvm.ptr + %163 = llvm.ptrtoint %162 : !llvm.ptr to i32 + %164 = llvm.inttoptr %163 : i32 to !llvm.ptr + %165 = llvm.ptrtoint %164 : !llvm.ptr to i32 + %166 = llvm.inttoptr %165 : i32 to !llvm.ptr + %167 = llvm.ptrtoint %166 : !llvm.ptr to i32 + %168 = llvm.inttoptr %167 : i32 to !llvm.ptr + %169 = llvm.ptrtoint %168 : !llvm.ptr to i32 + llvm.br ^bb23 + ^bb23: // pred: ^bb22 + %170 = llvm.inttoptr %169 : i32 to !llvm.ptr + llvm.return %170 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/2009-02-21-LoadCST.ll.mlir b/test/LLVMDialect/InstCombine/2009-02-21-LoadCST.ll.mlir index 9e5849dc2..4459644a2 100644 --- a/test/LLVMDialect/InstCombine/2009-02-21-LoadCST.ll.mlir +++ b/test/LLVMDialect/InstCombine/2009-02-21-LoadCST.ll.mlir @@ -1,11 +1,9 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 1 : i64, sym_name = ".str1", type = !llvm.array<4 x i8>, value = "\B5%8\00"} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @".str1"} : () -> !llvm.ptr> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.load"(%1) : (!llvm.ptr) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal constant @".str1"("\B5%8\00") {addr_space = 0 : i32, dso_local} + llvm.func @test() -> i32 { + %0 = llvm.mlir.constant("\B5%8\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @".str1" : !llvm.ptr + %2 = llvm.load %1 {alignment = 1 : i64} : !llvm.ptr -> i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2009-02-25-CrashZeroSizeArray.ll.mlir b/test/LLVMDialect/InstCombine/2009-02-25-CrashZeroSizeArray.ll.mlir new file mode 100644 index 000000000..7cf137abe --- /dev/null +++ b/test/LLVMDialect/InstCombine/2009-02-25-CrashZeroSizeArray.ll.mlir @@ -0,0 +1,35 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @_ada_c32001b(%arg0: i32, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.mlir.constant(0 : i8) : i8 + %7 = llvm.select %0, %arg0, %1 : i1, i32 + %8 = llvm.mul %7, %2 : i32 + %9 = llvm.alloca %1 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %10 = llvm.load %arg1 {alignment = 1 : i64} : !llvm.ptr -> i32 + %11 = llvm.icmp "eq" %10, %3 : i32 + %12 = llvm.zext %11 : i1 to i8 + %13 = llvm.ashr %8, %4 : i32 + %14 = llvm.mul %13, %2 : i32 + %15 = llvm.mul %5, %14 : i32 + %16 = llvm.getelementptr %9[%15] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %17 = llvm.getelementptr %16[%1] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %18 = llvm.load %17 {alignment = 1 : i64} : !llvm.ptr -> i32 + %19 = llvm.icmp "eq" %18, %2 : i32 + %20 = llvm.zext %19 : i1 to i8 + %21 = llvm.icmp "ne" %12, %6 : i8 + %22 = llvm.icmp "ne" %20, %6 : i8 + %23 = llvm.and %21, %22 : i1 + %24 = llvm.zext %23 : i1 to i8 + %25 = llvm.icmp "ne" %24, %6 : i8 + llvm.cond_br %25, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2009-03-18-vector-ashr-crash.ll.mlir b/test/LLVMDialect/InstCombine/2009-03-18-vector-ashr-crash.ll.mlir new file mode 100644 index 000000000..4886d109d --- /dev/null +++ b/test/LLVMDialect/InstCombine/2009-03-18-vector-ashr-crash.ll.mlir @@ -0,0 +1,13 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @<>(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.constant(dense<5> : vector<4xi16>) : vector<4xi16> + %3 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.load %1 {alignment = 1 : i64} : !llvm.ptr -> vector<4xi16> + %5 = llvm.ashr %4, %2 : vector<4xi16> + %6 = llvm.load %3 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store %5, %6 {alignment = 1 : i64} : vector<4xi16>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2009-03-24-InfLoop.ll.mlir b/test/LLVMDialect/InstCombine/2009-03-24-InfLoop.ll.mlir index ed784bfab..2694a23c2 100644 --- a/test/LLVMDialect/InstCombine/2009-03-24-InfLoop.ll.mlir +++ b/test/LLVMDialect/InstCombine/2009-03-24-InfLoop.ll.mlir @@ -1,13 +1,11 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 3968 : i32} : () -> i32 - %3 = "llvm.lshr"(%2, %arg0) : (i32, i32) -> i32 - %4 = "llvm.and"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.icmp"(%4, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3968 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2009-04-07-MulPromoteToI96.ll.mlir b/test/LLVMDialect/InstCombine/2009-04-07-MulPromoteToI96.ll.mlir index 87ffada51..78ff644eb 100644 --- a/test/LLVMDialect/InstCombine/2009-04-07-MulPromoteToI96.ll.mlir +++ b/test/LLVMDialect/InstCombine/2009-04-07-MulPromoteToI96.ll.mlir @@ -1,11 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i96, %arg1: i96): // no predecessors - %0 = "llvm.trunc"(%arg0) : (i96) -> i64 - %1 = "llvm.trunc"(%arg1) : (i96) -> i64 - %2 = "llvm.mul"(%0, %1) : (i64, i64) -> i64 - %3 = "llvm.zext"(%2) : (i64) -> i96 - "llvm.return"(%3) : (i96) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i96, %arg1: i96) -> i96 { + %0 = llvm.trunc %arg0 : i96 to i64 + %1 = llvm.trunc %arg1 : i96 to i64 + %2 = llvm.mul %0, %1 : i64 + %3 = llvm.zext %2 : i64 to i96 + llvm.return %3 : i96 + } +} diff --git a/test/LLVMDialect/InstCombine/2009-05-23-FCmpToICmp.ll.mlir b/test/LLVMDialect/InstCombine/2009-05-23-FCmpToICmp.ll.mlir new file mode 100644 index 000000000..ab42b68ad --- /dev/null +++ b/test/LLVMDialect/InstCombine/2009-05-23-FCmpToICmp.ll.mlir @@ -0,0 +1,9 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f0(%arg0: !llvm.ptr) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0x41EFFFFFFFE00000 : f64) : f64 + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %2 = llvm.uitofp %1 : i32 to f64 + %3 = llvm.fcmp "ogt" %2, %0 : f64 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2009-06-11-StoreAddrSpace.ll.mlir b/test/LLVMDialect/InstCombine/2009-06-11-StoreAddrSpace.ll.mlir index f0c25aee7..c4f1018f4 100644 --- a/test/LLVMDialect/InstCombine/2009-06-11-StoreAddrSpace.ll.mlir +++ b/test/LLVMDialect/InstCombine/2009-06-11-StoreAddrSpace.ll.mlir @@ -1,9 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.store"(%1, %0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "a", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr<1> + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr<1> + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2009-06-16-SRemDemandedBits.ll.mlir b/test/LLVMDialect/InstCombine/2009-06-16-SRemDemandedBits.ll.mlir index f92bd6407..d37a416f4 100644 --- a/test/LLVMDialect/InstCombine/2009-06-16-SRemDemandedBits.ll.mlir +++ b/test/LLVMDialect/InstCombine/2009-06-16-SRemDemandedBits.ll.mlir @@ -1,10 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.srem"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.and"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "a", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a(%arg0: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.srem %arg0, %0 : i32 + %2 = llvm.and %1, %0 : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2009-07-02-MaskedIntVector.ll.mlir b/test/LLVMDialect/InstCombine/2009-07-02-MaskedIntVector.ll.mlir new file mode 100644 index 000000000..0721f71ee --- /dev/null +++ b/test/LLVMDialect/InstCombine/2009-07-02-MaskedIntVector.ll.mlir @@ -0,0 +1,17 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i64) -> i32 { + %0 = llvm.mlir.undef : vector<4xi32> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<16xi8>) : vector<16xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.bitcast %0 : vector<4xi32> to vector<16xi8> + %5 = llvm.shufflevector %4, %2 [0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] : vector<16xi8> + %6 = llvm.bitcast %5 : vector<16xi8> to vector<2xi64> + %7 = llvm.extractelement %6[%3 : i32] : vector<2xi64> + %8 = llvm.bitcast %7 : i64 to vector<2xi32> + %9 = llvm.bitcast %arg0 : i64 to vector<2xi32> + %10 = llvm.xor %8, %9 : vector<2xi32> + %11 = llvm.extractelement %10[%3 : i32] : vector<2xi32> + llvm.return %11 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2009-12-17-CmpSelectNull.ll.mlir b/test/LLVMDialect/InstCombine/2009-12-17-CmpSelectNull.ll.mlir new file mode 100644 index 000000000..1f223372c --- /dev/null +++ b/test/LLVMDialect/InstCombine/2009-12-17-CmpSelectNull.ll.mlir @@ -0,0 +1,17 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal constant @".str254"(".\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global internal constant @".str557"("::\00") {addr_space = 0 : i32, dso_local} + llvm.func @demangle_qualified(%arg0: i32) -> !llvm.ptr attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(".\00") : !llvm.array<2 x i8> + %2 = llvm.mlir.addressof @".str254" : !llvm.ptr + %3 = llvm.mlir.constant("::\00") : !llvm.array<3 x i8> + %4 = llvm.mlir.addressof @".str557" : !llvm.ptr + %5 = llvm.mlir.zero : !llvm.ptr + %6 = llvm.icmp "ne" %arg0, %0 : i32 + %7 = llvm.select %6, %2, %4 : i1, !llvm.ptr + %8 = llvm.icmp "eq" %7, %5 : !llvm.ptr + %9 = llvm.getelementptr %7[%8] : (!llvm.ptr, i1) -> !llvm.ptr, i8 + llvm.return %9 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/2010-01-28-NegativeSRem.ll.mlir b/test/LLVMDialect/InstCombine/2010-01-28-NegativeSRem.ll.mlir index df7a39334..086f8c7e5 100644 --- a/test/LLVMDialect/InstCombine/2010-01-28-NegativeSRem.ll.mlir +++ b/test/LLVMDialect/InstCombine/2010-01-28-NegativeSRem.ll.mlir @@ -1,16 +1,15 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = -29 : i32} : () -> i32 - "llvm.br"(%3)[^bb1] : (i32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f() -> i32 { + %0 = llvm.mlir.constant(-29 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + llvm.br ^bb1(%0 : i32) ^bb1(%4: i32): // 2 preds: ^bb0, ^bb1 - %5 = "llvm.srem"(%4, %2) : (i32, i32) -> i32 - %6 = "llvm.icmp"(%5, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%6, %0)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i32) -> () + %5 = llvm.srem %4, %1 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.cond_br %6, ^bb2, ^bb1(%3 : i32) ^bb2: // pred: ^bb1 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2010-03-03-ExtElim.ll.mlir b/test/LLVMDialect/InstCombine/2010-03-03-ExtElim.ll.mlir new file mode 100644 index 000000000..7fb6f3ec4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2010-03-03-ExtElim.ll.mlir @@ -0,0 +1,64 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @g_92() {addr_space = 0 : i32, alignment = 4 : i64} : !llvm.array<2 x ptr> { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.undef : !llvm.array<2 x ptr> + %2 = llvm.insertvalue %0, %1[0] : !llvm.array<2 x ptr> + %3 = llvm.insertvalue %0, %2[1] : !llvm.array<2 x ptr> + llvm.return %3 : !llvm.array<2 x ptr> + } + llvm.mlir.global external constant @g_177() {addr_space = 0 : i32, alignment = 4 : i64} : !llvm.ptr { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.array<2 x ptr> + %3 = llvm.insertvalue %1, %2[0] : !llvm.array<2 x ptr> + %4 = llvm.insertvalue %1, %3[1] : !llvm.array<2 x ptr> + %5 = llvm.mlir.addressof @g_92 : !llvm.ptr + %6 = llvm.getelementptr %5[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.return %6 : !llvm.ptr + } + llvm.mlir.global external @d(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.mlir.global external @a(dense<0> : tensor<1xi32>) {addr_space = 0 : i32, alignment = 4 : i64} : !llvm.array<1 x i32> + llvm.func @PR6486() -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.array<2 x ptr> + %3 = llvm.insertvalue %1, %2[0] : !llvm.array<2 x ptr> + %4 = llvm.insertvalue %1, %3[1] : !llvm.array<2 x ptr> + %5 = llvm.mlir.addressof @g_92 : !llvm.ptr + %6 = llvm.getelementptr %5[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %7 = llvm.mlir.addressof @g_177 : !llvm.ptr + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %10 = llvm.icmp "ne" %1, %9 : !llvm.ptr + %11 = llvm.zext %10 : i1 to i32 + %12 = llvm.icmp "sle" %8, %11 : i32 + llvm.return %12 : i1 + } + llvm.func @PR16462_1() -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi32>) : !llvm.array<1 x i32> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @d : !llvm.ptr + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.mlir.constant(65535 : i32) : i32 + %6 = llvm.icmp "eq" %2, %3 : !llvm.ptr + %7 = llvm.select %6, %0, %4 : i1, i32 + %8 = llvm.trunc %7 : i32 to i16 + %9 = llvm.sext %8 : i16 to i32 + %10 = llvm.icmp "sgt" %9, %5 : i32 + llvm.return %10 : i1 + } + llvm.func @PR16462_2() -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi32>) : !llvm.array<1 x i32> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @d : !llvm.ptr + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.mlir.constant(42 : i16) : i16 + %6 = llvm.icmp "eq" %2, %3 : !llvm.ptr + %7 = llvm.select %6, %0, %4 : i1, i32 + %8 = llvm.trunc %7 : i32 to i16 + %9 = llvm.icmp "sgt" %8, %5 : i16 + llvm.return %9 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2010-05-30-memcpy-Struct.ll.mlir b/test/LLVMDialect/InstCombine/2010-05-30-memcpy-Struct.ll.mlir index 4638de8c7..42903aa00 100644 --- a/test/LLVMDialect/InstCombine/2010-05-30-memcpy-Struct.ll.mlir +++ b/test/LLVMDialect/InstCombine/2010-05-30-memcpy-Struct.ll.mlir @@ -1,15 +1,10 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str", type = !llvm.array<3 x i8>, value = "%s\00"} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr)>>, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%arg1, %2, %arg0) {callee = @sprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, !llvm.ptr)>>) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "CopyEventArg", type = !llvm.func)>>, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sprintf", type = !llvm.func, ptr, ...)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private constant @".str"("%s\00") {addr_space = 0 : i32, dso_local} + llvm.func @CopyEventArg(%arg0: !llvm.ptr, %arg1: !llvm.ptr) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.call @sprintf(%arg1, %1, %arg0) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @sprintf(!llvm.ptr, !llvm.ptr, ...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/2010-11-01-lshr-mask.ll.mlir b/test/LLVMDialect/InstCombine/2010-11-01-lshr-mask.ll.mlir index 02f0dee45..08ac61b76 100644 --- a/test/LLVMDialect/InstCombine/2010-11-01-lshr-mask.ll.mlir +++ b/test/LLVMDialect/InstCombine/2010-11-01-lshr-mask.ll.mlir @@ -1,44 +1,41 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 64 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 6 : i8} : () -> i8 - %3 = "llvm.mlir.constant"() {value = 122 : i8} : () -> i8 - %4 = "llvm.mlir.constant"() {value = -17 : i8} : () -> i8 - %5 = "llvm.trunc"(%arg0) : (i32) -> i8 - %6 = "llvm.or"(%5, %4) : (i8, i8) -> i8 - %7 = "llvm.and"(%5, %3) : (i8, i8) -> i8 - %8 = "llvm.xor"(%7, %4) : (i8, i8) -> i8 - %9 = "llvm.shl"(%8, %2) : (i8, i8) -> i8 - %10 = "llvm.xor"(%9, %8) : (i8, i8) -> i8 - %11 = "llvm.xor"(%6, %10) : (i8, i8) -> i8 - %12 = "llvm.lshr"(%11, %1) : (i8, i8) -> i8 - %13 = "llvm.mul"(%12, %0) : (i8, i8) -> i8 - %14 = "llvm.zext"(%13) : (i8) -> i32 - "llvm.return"(%14) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "main", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = -88 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 33 : i8} : () -> i8 - %3 = "llvm.mlir.constant"() {value = -118 : i8} : () -> i8 - %4 = "llvm.mlir.constant"() {value = 84 : i8} : () -> i8 - %5 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %6 = "llvm.shl"(%arg0, %5) : (i8, i8) -> i8 - %7 = "llvm.and"(%arg1, %4) : (i8, i8) -> i8 - %8 = "llvm.and"(%arg1, %3) : (i8, i8) -> i8 - %9 = "llvm.and"(%arg1, %2) : (i8, i8) -> i8 - %10 = "llvm.sub"(%1, %7) : (i8, i8) -> i8 - %11 = "llvm.and"(%10, %4) : (i8, i8) -> i8 - %12 = "llvm.or"(%9, %11) : (i8, i8) -> i8 - %13 = "llvm.xor"(%6, %8) : (i8, i8) -> i8 - %14 = "llvm.or"(%12, %13) : (i8, i8) -> i8 - %15 = "llvm.lshr"(%13, %5) : (i8, i8) -> i8 - %16 = "llvm.shl"(%15, %0) : (i8, i8) -> i8 - %17 = "llvm.xor"(%16, %14) : (i8, i8) -> i8 - "llvm.return"(%17) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @main(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-17 : i8) : i8 + %1 = llvm.mlir.constant(122 : i8) : i8 + %2 = llvm.mlir.constant(6 : i8) : i8 + %3 = llvm.mlir.constant(7 : i8) : i8 + %4 = llvm.mlir.constant(64 : i8) : i8 + %5 = llvm.trunc %arg0 : i32 to i8 + %6 = llvm.or %5, %0 : i8 + %7 = llvm.and %5, %1 : i8 + %8 = llvm.xor %7, %0 : i8 + %9 = llvm.shl %8, %2 : i8 + %10 = llvm.xor %9, %8 : i8 + %11 = llvm.xor %6, %10 : i8 + %12 = llvm.lshr %11, %3 : i8 + %13 = llvm.mul %12, %4 : i8 + %14 = llvm.zext %13 : i8 to i32 + llvm.return %14 : i32 + } + llvm.func @foo(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(84 : i8) : i8 + %2 = llvm.mlir.constant(-118 : i8) : i8 + %3 = llvm.mlir.constant(33 : i8) : i8 + %4 = llvm.mlir.constant(-88 : i8) : i8 + %5 = llvm.mlir.constant(5 : i8) : i8 + %6 = llvm.shl %arg0, %0 : i8 + %7 = llvm.and %arg1, %1 : i8 + %8 = llvm.and %arg1, %2 : i8 + %9 = llvm.and %arg1, %3 : i8 + %10 = llvm.sub %4, %7 : i8 + %11 = llvm.and %10, %1 : i8 + %12 = llvm.or %9, %11 : i8 + %13 = llvm.xor %6, %8 : i8 + %14 = llvm.or %12, %13 : i8 + %15 = llvm.lshr %13, %0 : i8 + %16 = llvm.shl %15, %5 : i8 + %17 = llvm.xor %16, %14 : i8 + llvm.return %17 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/2010-11-21-SizeZeroTypeGEP.ll.mlir b/test/LLVMDialect/InstCombine/2010-11-21-SizeZeroTypeGEP.ll.mlir index 93b999888..2168e949b 100644 --- a/test/LLVMDialect/InstCombine/2010-11-21-SizeZeroTypeGEP.ll.mlir +++ b/test/LLVMDialect/InstCombine/2010-11-21-SizeZeroTypeGEP.ll.mlir @@ -1,15 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: i32): // no predecessors - %0 = "llvm.getelementptr"(%arg0, %arg1) : (!llvm.ptr>, i32) -> !llvm.ptr> - "llvm.return"(%0) : (!llvm.ptr>) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func> (ptr>, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: !llvm.ptr, array<0 x struct<(array<0 x i8>)>>)>>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.getelementptr"(%arg1, %arg0, %1, %arg0, %0, %arg0) : (!llvm.ptr, array<0 x struct<(array<0 x i8>)>>)>>, i64, i32, i64, i32, i64) -> !llvm.ptr - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func (i64, ptr, array<0 x struct<(array<0 x i8>)>>)>>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<()> + llvm.return %0 : !llvm.ptr + } + llvm.func @bar(%arg0: i64, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.getelementptr %arg1[%arg0, 1, %arg0, 0, %arg0] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.struct<(struct<()>, array<0 x struct<(array<0 x i8>)>>)> + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/2010-11-23-Distributed.ll.mlir b/test/LLVMDialect/InstCombine/2010-11-23-Distributed.ll.mlir index 707d378a6..49d5b5891 100644 --- a/test/LLVMDialect/InstCombine/2010-11-23-Distributed.ll.mlir +++ b/test/LLVMDialect/InstCombine/2010-11-23-Distributed.ll.mlir @@ -1,21 +1,18 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.add"(%arg1, %arg0) : (i32, i32) -> i32 - %1 = "llvm.mul"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.mul"(%arg1, %arg1) : (i32, i32) -> i32 - %3 = "llvm.sub"(%1, %2) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = -1 : i64} : () -> i64 - %2 = "llvm.and"(%arg1, %arg0) : (i64, i64) -> i64 - %3 = "llvm.xor"(%2, %1) : (i64, i64) -> i64 - %4 = "llvm.and"(%arg1, %3) : (i64, i64) -> i64 - %5 = "llvm.icmp"(%4, %0) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.add %arg1, %arg0 overflow : i32 + %1 = llvm.mul %0, %arg1 overflow : i32 + %2 = llvm.mul %arg1, %arg1 overflow : i32 + %3 = llvm.sub %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @bar(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.and %arg1, %arg0 : i64 + %3 = llvm.xor %2, %0 : i64 + %4 = llvm.and %arg1, %3 : i64 + %5 = llvm.icmp "eq" %4, %1 : i64 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2011-02-14-InfLoop.ll.mlir b/test/LLVMDialect/InstCombine/2011-02-14-InfLoop.ll.mlir new file mode 100644 index 000000000..4694126ae --- /dev/null +++ b/test/LLVMDialect/InstCombine/2011-02-14-InfLoop.ll.mlir @@ -0,0 +1,27 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @m_387(%arg0: !llvm.ptr {llvm.noalias, llvm.nocapture}, %arg1: !llvm.ptr {llvm.nocapture}, %arg2: vector<4xi1>) -> vector<4xf32> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.undef : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %2, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %14 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %15 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %16 = llvm.sext %arg2 : vector<4xi1> to vector<4xi32> + %17 = llvm.xor %16, %0 : vector<4xi32> + %18 = llvm.and %17, %11 : vector<4xi32> + %19 = llvm.or %18, %13 : vector<4xi32> + %20 = llvm.bitcast %19 : vector<4xi32> to vector<4xf32> + %21 = llvm.shufflevector %15, %20 [0, 1, 2, 7] : vector<4xf32> + llvm.return %21 : vector<4xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/2011-03-08-SRemMinusOneBadOpt.ll.mlir b/test/LLVMDialect/InstCombine/2011-03-08-SRemMinusOneBadOpt.ll.mlir index 4a131b73e..3c3648a07 100644 --- a/test/LLVMDialect/InstCombine/2011-03-08-SRemMinusOneBadOpt.ll.mlir +++ b/test/LLVMDialect/InstCombine/2011-03-08-SRemMinusOneBadOpt.ll.mlir @@ -1,12 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4294967294 : i64} : () -> i64 - %2 = "llvm.or"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.trunc"(%2) : (i64) -> i32 - %4 = "llvm.srem"(%3, %0) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i64) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(4294967294 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.or %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.srem %3, %1 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2011-05-02-VectorBoolean.ll.mlir b/test/LLVMDialect/InstCombine/2011-05-02-VectorBoolean.ll.mlir new file mode 100644 index 000000000..aef7410bb --- /dev/null +++ b/test/LLVMDialect/InstCombine/2011-05-02-VectorBoolean.ll.mlir @@ -0,0 +1,16 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @entry(%arg0: vector<2xi16>) -> vector<2xi16> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.mlir.constant(dense<0> : vector<2xi16>) : vector<2xi16> + %3 = llvm.alloca %0 x vector<2xi16> {alignment = 4 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x vector<2xi16> {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %3 {alignment = 4 : i64} : vector<2xi16>, !llvm.ptr + %5 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> vector<2xi16> + llvm.store %2, %4 {alignment = 4 : i64} : vector<2xi16>, !llvm.ptr + %6 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> vector<2xi16> + %7 = llvm.icmp "uge" %5, %6 : vector<2xi16> + %8 = llvm.sext %7 : vector<2xi1> to vector<2xi16> + llvm.return %8 : vector<2xi16> + } +} diff --git a/test/LLVMDialect/InstCombine/2011-05-13-InBoundsGEP.ll.mlir b/test/LLVMDialect/InstCombine/2011-05-13-InBoundsGEP.ll.mlir new file mode 100644 index 000000000..11c934e99 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2011-05-13-InBoundsGEP.ll.mlir @@ -0,0 +1,20 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @main(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(1879048192 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(-1 : i32) : i32 + %5 = llvm.add %arg0, %0 : i32 + %6 = llvm.add %arg0, %1 : i32 + %7 = llvm.alloca %2 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %8 = llvm.getelementptr %7[%5] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %9 = llvm.getelementptr %7[%6] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %10 = llvm.icmp "ult" %8, %9 : !llvm.ptr + llvm.cond_br %10, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %4 : i32 + ^bb2: // pred: ^bb0 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2011-05-28-swapmulsub.ll.mlir b/test/LLVMDialect/InstCombine/2011-05-28-swapmulsub.ll.mlir index 9919c6de8..69d444ec9 100644 --- a/test/LLVMDialect/InstCombine/2011-05-28-swapmulsub.ll.mlir +++ b/test/LLVMDialect/InstCombine/2011-05-28-swapmulsub.ll.mlir @@ -1,52 +1,48 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - %3 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - "llvm.store"(%arg0, %2) : (i32, !llvm.ptr) -> () - %4 = "llvm.load"(%2) : (!llvm.ptr) -> i32 - %5 = "llvm.sub"(%1, %4) : (i32, i32) -> i32 - %6 = "llvm.mul"(%5, %0) : (i32, i32) -> i32 - "llvm.store"(%6, %3) : (i32, !llvm.ptr) -> () - %7 = "llvm.load"(%3) : (!llvm.ptr) -> i32 - %8 = "llvm.trunc"(%7) : (i32) -> i16 - "llvm.return"(%8) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "foo1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - %3 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - %4 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - "llvm.store"(%arg0, %2) : (i32, !llvm.ptr) -> () - "llvm.store"(%arg1, %3) : (i32, !llvm.ptr) -> () - %5 = "llvm.load"(%3) : (!llvm.ptr) -> i32 - %6 = "llvm.load"(%2) : (!llvm.ptr) -> i32 - %7 = "llvm.sub"(%5, %6) : (i32, i32) -> i32 - %8 = "llvm.mul"(%7, %0) : (i32, i32) -> i32 - "llvm.store"(%8, %4) : (i32, !llvm.ptr) -> () - %9 = "llvm.load"(%4) : (!llvm.ptr) -> i32 - %10 = "llvm.trunc"(%9) : (i32) -> i16 - "llvm.return"(%10) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "foo2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %4 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - "llvm.store"(%arg0, %3) : (i32, !llvm.ptr) -> () - %5 = "llvm.load"(%3) : (!llvm.ptr) -> i32 - %6 = "llvm.sub"(%1, %5) : (i32, i32) -> i32 - %7 = "llvm.mul"(%6, %0) : (i32, i32) -> i32 - "llvm.store"(%7, %4) : (i32, !llvm.ptr) -> () - %8 = "llvm.load"(%4) : (!llvm.ptr) -> i32 - %9 = "llvm.trunc"(%8) : (i32) -> i16 - "llvm.return"(%9) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "foo3", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo1(%arg0: i32) -> (i16 {llvm.zeroext}) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %5 = llvm.sub %0, %4 : i32 + %6 = llvm.mul %5, %1 : i32 + llvm.store %6, %3 {alignment = 4 : i64} : i32, !llvm.ptr + %7 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + %8 = llvm.trunc %7 : i32 to i16 + llvm.return %8 : i16 + } + llvm.func @foo2(%arg0: i32, %arg1: i32) -> (i16 {llvm.zeroext}) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-4 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %arg1, %3 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + %6 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %7 = llvm.sub %5, %6 : i32 + %8 = llvm.mul %7, %1 : i32 + llvm.store %8, %4 {alignment = 4 : i64} : i32, !llvm.ptr + %9 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> i32 + %10 = llvm.trunc %9 : i32 to i16 + llvm.return %10 : i16 + } + llvm.func @foo3(%arg0: i32) -> (i16 {llvm.zeroext}) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.mlir.constant(-4 : i32) : i32 + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %3 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + %6 = llvm.sub %1, %5 : i32 + %7 = llvm.mul %6, %2 : i32 + llvm.store %7, %4 {alignment = 4 : i64} : i32, !llvm.ptr + %8 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> i32 + %9 = llvm.trunc %8 : i32 to i16 + llvm.return %9 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/2011-06-13-nsw-alloca.ll.mlir b/test/LLVMDialect/InstCombine/2011-06-13-nsw-alloca.ll.mlir index 72a508281..fa07f1a47 100644 --- a/test/LLVMDialect/InstCombine/2011-06-13-nsw-alloca.ll.mlir +++ b/test/LLVMDialect/InstCombine/2011-06-13-nsw-alloca.ll.mlir @@ -1,59 +1,53 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2048 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.null"() : () -> !llvm.ptr - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.alloca"(%4) : (i32) -> !llvm.ptr - %6 = "llvm.alloca"(%4) : (i32) -> !llvm.ptr> - "llvm.store"(%arg0, %5) : (i32, !llvm.ptr) -> () - "llvm.store"(%3, %6) : (!llvm.ptr, !llvm.ptr>) -> () - %7 = "llvm.load"(%5) : (!llvm.ptr) -> i32 - %8 = "llvm.icmp"(%7, %2) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%8)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fu1(%arg0: i32) attributes {passthrough = ["nounwind", "ssp"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.constant(2048 : i32) : i32 + %5 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %6 = llvm.alloca %0 x !llvm.ptr {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %1, %6 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + %7 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + %8 = llvm.icmp "ne" %7, %2 : i32 + llvm.cond_br %8, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %9 = "llvm.load"(%5) : (!llvm.ptr) -> i32 - %10 = "llvm.shl"(%9, %1) : (i32, i32) -> i32 - %11 = "llvm.add"(%10, %0) : (i32, i32) -> i32 - %12 = "llvm.alloca"(%11) : (i32) -> !llvm.ptr - %13 = "llvm.bitcast"(%12) : (!llvm.ptr) -> !llvm.ptr - "llvm.store"(%13, %6) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.br"()[^bb2] : () -> () + %9 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + %10 = llvm.shl %9, %3 overflow : i32 + %11 = llvm.add %10, %4 overflow : i32 + %12 = llvm.alloca %11 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.store %12, %6 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.br ^bb2 ^bb2: // 2 preds: ^bb0, ^bb1 - %14 = "llvm.load"(%6) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%14) {callee = @bar, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fu1", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2048 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.null"() : () -> !llvm.ptr - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.alloca"(%4) : (i32) -> !llvm.ptr - %6 = "llvm.alloca"(%4) : (i32) -> !llvm.ptr> - "llvm.store"(%arg0, %5) : (i32, !llvm.ptr) -> () - "llvm.store"(%3, %6) : (!llvm.ptr, !llvm.ptr>) -> () - %7 = "llvm.load"(%5) : (!llvm.ptr) -> i32 - %8 = "llvm.icmp"(%7, %2) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%8)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %13 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + llvm.call @bar(%13) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @bar(!llvm.ptr) + llvm.func @fu2(%arg0: i32) attributes {passthrough = ["nounwind", "ssp"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(2048 : i32) : i32 + %5 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %6 = llvm.alloca %0 x !llvm.ptr {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %1, %6 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + %7 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + %8 = llvm.icmp "ne" %7, %2 : i32 + llvm.cond_br %8, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %9 = "llvm.load"(%5) : (!llvm.ptr) -> i32 - %10 = "llvm.mul"(%9, %1) : (i32, i32) -> i32 - %11 = "llvm.add"(%10, %0) : (i32, i32) -> i32 - %12 = "llvm.alloca"(%11) : (i32) -> !llvm.ptr - %13 = "llvm.bitcast"(%12) : (!llvm.ptr) -> !llvm.ptr - "llvm.store"(%13, %6) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.br"()[^bb2] : () -> () + %9 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + %10 = llvm.mul %9, %3 overflow : i32 + %11 = llvm.add %10, %4 : i32 + %12 = llvm.alloca %11 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.store %12, %6 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.br ^bb2 ^bb2: // 2 preds: ^bb0, ^bb1 - %14 = "llvm.load"(%6) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%14) {callee = @bar, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fu2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %13 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + llvm.call @bar(%13) : (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2011-09-03-Trampoline.ll.mlir b/test/LLVMDialect/InstCombine/2011-09-03-Trampoline.ll.mlir index 77025cb4e..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/2011-09-03-Trampoline.ll.mlir +++ b/test/LLVMDialect/InstCombine/2011-09-03-Trampoline.ll.mlir @@ -1,77 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.init.trampoline", type = !llvm.func, ptr, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.adjust.trampoline", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.addressof"() {global_name = @f} : () -> !llvm.ptr, i32)>> - %2 = "llvm.bitcast"(%1) : (!llvm.ptr, i32)>>) -> !llvm.ptr - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.alloca"(%4) : (i32) -> !llvm.ptr> - %6 = "llvm.getelementptr"(%5, %3, %3) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - "llvm.call"(%6, %2, %0) {callee = @llvm.init.trampoline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> () - %7 = "llvm.call"(%6) {callee = @llvm.adjust.trampoline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> !llvm.ptr - %8 = "llvm.bitcast"(%7) : (!llvm.ptr) -> !llvm.ptr> - %9 = "llvm.call"(%8, %arg0) : (!llvm.ptr>, i32) -> i32 - "llvm.return"(%9) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.addressof"() {global_name = @f} : () -> !llvm.ptr, i32)>> - %2 = "llvm.bitcast"(%1) : (!llvm.ptr, i32)>>) -> !llvm.ptr - "llvm.call"(%arg1, %2, %0) {callee = @llvm.init.trampoline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> () - %3 = "llvm.call"(%arg1) {callee = @llvm.adjust.trampoline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> !llvm.ptr - %4 = "llvm.bitcast"(%3) : (!llvm.ptr) -> !llvm.ptr> - %5 = "llvm.call"(%4, %arg0) : (!llvm.ptr>, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.call"(%arg1) {callee = @llvm.adjust.trampoline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> !llvm.ptr - %1 = "llvm.bitcast"(%0) : (!llvm.ptr) -> !llvm.ptr> - %2 = "llvm.call"(%1, %arg0) : (!llvm.ptr>, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.addressof"() {global_name = @f} : () -> !llvm.ptr, i32)>> - %2 = "llvm.bitcast"(%1) : (!llvm.ptr, i32)>>) -> !llvm.ptr - "llvm.call"(%arg1, %2, %0) {callee = @llvm.init.trampoline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> () - %3 = "llvm.call"(%arg1) {callee = @llvm.adjust.trampoline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> !llvm.ptr - %4 = "llvm.bitcast"(%3) : (!llvm.ptr) -> !llvm.ptr> - %5 = "llvm.call"(%4, %arg0) : (!llvm.ptr>, i32) -> i32 - %6 = "llvm.call"(%arg1) {callee = @llvm.adjust.trampoline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> !llvm.ptr - %7 = "llvm.bitcast"(%6) : (!llvm.ptr) -> !llvm.ptr> - %8 = "llvm.call"(%7, %arg0) : (!llvm.ptr>, i32) -> i32 - "llvm.return"(%8) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.addressof"() {global_name = @f} : () -> !llvm.ptr, i32)>> - %2 = "llvm.bitcast"(%1) : (!llvm.ptr, i32)>>) -> !llvm.ptr - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.alloca"(%4) : (i32) -> !llvm.ptr> - %6 = "llvm.getelementptr"(%5, %3, %3) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - "llvm.call"(%6, %2, %0) {callee = @llvm.init.trampoline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> () - %7 = "llvm.call"(%6) {callee = @llvm.adjust.trampoline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> !llvm.ptr - %8 = "llvm.bitcast"(%7) : (!llvm.ptr) -> !llvm.ptr> - %9 = "llvm.call"(%8, %arg0) : (!llvm.ptr>, i32) -> i32 - %10 = "llvm.call"(%6) {callee = @llvm.adjust.trampoline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> !llvm.ptr - %11 = "llvm.bitcast"(%7) : (!llvm.ptr) -> !llvm.ptr> - %12 = "llvm.call"(%11, %arg0) : (!llvm.ptr>, i32) -> i32 - %13 = "llvm.call"(%6) {callee = @llvm.adjust.trampoline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> !llvm.ptr - %14 = "llvm.bitcast"(%13) : (!llvm.ptr) -> !llvm.ptr> - %15 = "llvm.call"(%14, %arg0) : (!llvm.ptr>, i32) -> i32 - "llvm.return"(%15) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/2011-10-07-AlignPromotion.ll.mlir b/test/LLVMDialect/InstCombine/2011-10-07-AlignPromotion.ll.mlir index 4ead3ca1f..1880f6b00 100644 --- a/test/LLVMDialect/InstCombine/2011-10-07-AlignPromotion.ll.mlir +++ b/test/LLVMDialect/InstCombine/2011-10-07-AlignPromotion.ll.mlir @@ -1,16 +1,11 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr> - %2 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %3 = "llvm.bitcast"(%1) : (!llvm.ptr>) -> !llvm.ptr - %4 = "llvm.load"(%2) : (!llvm.ptr) -> i64 - "llvm.store"(%4, %3) : (i64, !llvm.ptr) -> () - "llvm.call"(%3) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "t", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 32 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t(%arg0: !llvm.ptr) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.struct<"struct.CGPoint", (f32, f32)> {alignment = 4 : i64} : (i32) -> !llvm.ptr + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i64 + llvm.store %2, %1 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.call @foo(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @foo(!llvm.ptr) +} diff --git a/test/LLVMDialect/InstCombine/2012-01-11-OpaqueBitcastCrash.ll.mlir b/test/LLVMDialect/InstCombine/2012-01-11-OpaqueBitcastCrash.ll.mlir index 89f236e0a..ca80d0e66 100644 --- a/test/LLVMDialect/InstCombine/2012-01-11-OpaqueBitcastCrash.ll.mlir +++ b/test/LLVMDialect/InstCombine/2012-01-11-OpaqueBitcastCrash.ll.mlir @@ -1,13 +1,9 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "G", type = !llvm.array<0 x struct<"opaque_struct", opaque>>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @G} : () -> !llvm.ptr>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>>) -> !llvm.ptr> - "llvm.call"(%1) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @G() {addr_space = 0 : i32} : !llvm.array<0 x struct<"opaque_struct", opaque>> + llvm.func @foo(!llvm.ptr) + llvm.func @bar() { + %0 = llvm.mlir.addressof @G : !llvm.ptr + llvm.call @foo(%0) : (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2012-02-13-FCmp.ll.mlir b/test/LLVMDialect/InstCombine/2012-02-13-FCmp.ll.mlir new file mode 100644 index 000000000..bd95d713f --- /dev/null +++ b/test/LLVMDialect/InstCombine/2012-02-13-FCmp.ll.mlir @@ -0,0 +1,32 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private unnamed_addr constant @".str"("\0Ain_range input (should be 0): %f\0A\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global external hidden unnamed_addr constant @".str1"() {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : !llvm.array<35 x i8> + llvm.func @printf(!llvm.ptr, ...) -> i32 + llvm.func @_Z8tempCastj(%arg0: i32) -> i64 attributes {passthrough = ["ssp", ["uwtable", "2"]]} { + %0 = llvm.mlir.addressof @".str1" : !llvm.ptr + %1 = llvm.mlir.constant("\0Ain_range input (should be 0): %f\0A\00") : !llvm.array<35 x i8> + %2 = llvm.mlir.addressof @".str" : !llvm.ptr + %3 = llvm.mlir.constant(-1.000000e+00 : f64) : f64 + %4 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %5 = llvm.mlir.constant(-1 : i64) : i64 + %6 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %7 = llvm.call @printf(%0, %arg0) vararg(!llvm.func) : (!llvm.ptr, i32) -> i32 + %8 = llvm.uitofp %arg0 : i32 to f64 + %9 = llvm.call @printf(%2, %8) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + %10 = llvm.fcmp "oge" %8, %3 : f64 + llvm.cond_br %10, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %11 = llvm.fcmp "olt" %8, %4 : f64 + llvm.cond_br %11, ^bb2, ^bb4 + ^bb2: // pred: ^bb1 + %12 = llvm.fadd %8, %6 : f64 + %13 = llvm.fptosi %12 : f64 to i64 + llvm.br ^bb5(%13 : i64) + ^bb3: // pred: ^bb0 + llvm.br ^bb4 + ^bb4: // 2 preds: ^bb1, ^bb3 + llvm.br ^bb5(%5 : i64) + ^bb5(%14: i64): // 2 preds: ^bb2, ^bb4 + llvm.return %14 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/2012-02-28-ICmp.ll.mlir b/test/LLVMDialect/InstCombine/2012-02-28-ICmp.ll.mlir new file mode 100644 index 000000000..3b803730e --- /dev/null +++ b/test/LLVMDialect/InstCombine/2012-02-28-ICmp.ll.mlir @@ -0,0 +1,25 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16711680 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.trunc %arg0 : i32 to i8 + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.and %arg0, %1 : i32 + %6 = llvm.icmp "ne" %5, %2 : i32 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @f1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16711680 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.trunc %arg0 : i32 to i8 + %5 = llvm.icmp "ne" %4, %0 : i8 + %6 = llvm.and %arg0, %1 : i32 + %7 = llvm.icmp "ne" %6, %2 : i32 + %8 = llvm.select %5, %7, %3 : i1, i1 + llvm.return %8 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/2012-03-10-InstCombine.ll.mlir b/test/LLVMDialect/InstCombine/2012-03-10-InstCombine.ll.mlir new file mode 100644 index 000000000..7c6476129 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2012-03-10-InstCombine.ll.mlir @@ -0,0 +1,47 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @func(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["noinline", "nounwind", "ssp", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %2 {alignment = 1 : i64} : i8, !llvm.ptr + %3 = llvm.icmp "ugt" %2, %arg0 : !llvm.ptr + llvm.cond_br %3, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + %4 = llvm.icmp "ule" %2, %arg1 : !llvm.ptr + %5 = llvm.icmp "uge" %arg0, %arg1 : !llvm.ptr + %6 = llvm.and %4, %5 : i1 + %7 = llvm.zext %6 : i1 to i32 + llvm.br ^bb3(%7 : i32) + ^bb2: // pred: ^bb0 + %8 = llvm.icmp "uge" %2, %arg1 : !llvm.ptr + %9 = llvm.icmp "ule" %arg0, %arg1 : !llvm.ptr + %10 = llvm.and %8, %9 : i1 + %11 = llvm.zext %10 : i1 to i32 + llvm.br ^bb3(%11 : i32) + ^bb3(%12: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %12 : i32 + } + llvm.func @func_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["noinline", "nounwind", "ssp", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %3 {alignment = 1 : i64} : i8, !llvm.ptr + %4 = llvm.icmp "ugt" %3, %arg0 : !llvm.ptr + llvm.cond_br %4, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + %5 = llvm.icmp "ule" %3, %arg1 : !llvm.ptr + %6 = llvm.icmp "uge" %arg0, %arg1 : !llvm.ptr + %7 = llvm.select %5, %6, %2 : i1, i1 + %8 = llvm.zext %7 : i1 to i32 + llvm.br ^bb3(%8 : i32) + ^bb2: // pred: ^bb0 + %9 = llvm.icmp "uge" %3, %arg1 : !llvm.ptr + %10 = llvm.icmp "ule" %arg0, %arg1 : !llvm.ptr + %11 = llvm.select %9, %10, %2 : i1, i1 + %12 = llvm.zext %11 : i1 to i32 + llvm.br ^bb3(%12 : i32) + ^bb3(%13: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %13 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2012-04-24-vselect.ll.mlir b/test/LLVMDialect/InstCombine/2012-04-24-vselect.ll.mlir new file mode 100644 index 000000000..886e7e153 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2012-04-24-vselect.ll.mlir @@ -0,0 +1,12 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo() -> vector<8xi32> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(dense<[true, false, false, false, false, false, false, false]> : vector<8xi1>) : vector<8xi1> + %3 = llvm.mlir.constant(dense<1> : vector<8xi32>) : vector<8xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(dense<0> : vector<8xi32>) : vector<8xi32> + %6 = llvm.select %2, %3, %5 : vector<8xi1>, vector<8xi32> + llvm.return %6 : vector<8xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/2012-04-30-SRem.ll.mlir b/test/LLVMDialect/InstCombine/2012-04-30-SRem.ll.mlir index 86cb49853..1324b1605 100644 --- a/test/LLVMDialect/InstCombine/2012-04-30-SRem.ll.mlir +++ b/test/LLVMDialect/InstCombine/2012-04-30-SRem.ll.mlir @@ -1,14 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 24 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1656690544 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %3 = "llvm.xor"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.srem"(%1, %3) : (i32, i32) -> i32 - %5 = "llvm.shl"(%4, %0) : (i32, i32) -> i32 - %6 = "llvm.ashr"(%5, %0) : (i32, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1656690544 : i32) : i32 + %2 = llvm.mlir.constant(24 : i32) : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.srem %1, %3 : i32 + %5 = llvm.shl %4, %2 : i32 + %6 = llvm.ashr %5, %2 : i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2012-05-28-select-hang.ll.mlir b/test/LLVMDialect/InstCombine/2012-05-28-select-hang.ll.mlir index 65c47531e..b7145b65b 100644 --- a/test/LLVMDialect/InstCombine/2012-05-28-select-hang.ll.mlir +++ b/test/LLVMDialect/InstCombine/2012-05-28-select-hang.ll.mlir @@ -1,45 +1,40 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 5 : i64, sym_name = "c", type = i8, value = 0 : i8} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 5 : i64, sym_name = "a", type = i8, value = 0 : i8} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 5 : i64, sym_name = "b", type = i8, value = 0 : i8} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = false} : () -> i1 - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr - %5 = "llvm.mlir.addressof"() {global_name = @b} : () -> !llvm.ptr - %6 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %7 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr - %8 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %9 = "llvm.mlir.addressof"() {global_name = @c} : () -> !llvm.ptr - %10 = "llvm.load"(%9) : (!llvm.ptr) -> i8 - %11 = "llvm.zext"(%10) : (i8) -> i32 - %12 = "llvm.or"(%11, %8) : (i32, i32) -> i32 - %13 = "llvm.trunc"(%12) : (i32) -> i8 - "llvm.store"(%13, %7) : (i8, !llvm.ptr) -> () - %14 = "llvm.zext"(%13) : (i8) -> i32 - %15 = "llvm.xor"(%14, %6) : (i32, i32) -> i32 - %16 = "llvm.and"(%8, %15) : (i32, i32) -> i32 - %17 = "llvm.trunc"(%16) : (i32) -> i8 - "llvm.store"(%17, %5) : (i8, !llvm.ptr) -> () - %18 = "llvm.load"(%4) : (!llvm.ptr) -> i8 - %19 = "llvm.zext"(%18) : (i8) -> i32 - %20 = "llvm.zext"(%17) : (i8) -> i32 - %21 = "llvm.icmp"(%19, %3) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%21, %2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @c(0 : i8) {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.mlir.global common @a(0 : i8) {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.mlir.global common @b(0 : i8) {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.func @func() attributes {passthrough = ["nounwind", "ssp", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.addressof @c : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.addressof @a : !llvm.ptr + %4 = llvm.mlir.constant(-1 : i32) : i32 + %5 = llvm.mlir.addressof @b : !llvm.ptr + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.mlir.constant(false) : i1 + %8 = llvm.mlir.constant(3 : i32) : i32 + %9 = llvm.load %1 {alignment = 1 : i64} : !llvm.ptr -> i8 + %10 = llvm.zext %9 : i8 to i32 + %11 = llvm.or %10, %2 : i32 + %12 = llvm.trunc %11 : i32 to i8 + llvm.store %12, %3 {alignment = 1 : i64} : i8, !llvm.ptr + %13 = llvm.zext %12 : i8 to i32 + %14 = llvm.xor %13, %4 : i32 + %15 = llvm.and %2, %14 : i32 + %16 = llvm.trunc %15 : i32 to i8 + llvm.store %16, %5 {alignment = 1 : i64} : i8, !llvm.ptr + %17 = llvm.load %3 {alignment = 1 : i64} : !llvm.ptr -> i8 + %18 = llvm.zext %17 : i8 to i32 + %19 = llvm.zext %16 : i8 to i32 + %20 = llvm.icmp "ne" %18, %6 : i32 + llvm.cond_br %20, ^bb1, ^bb2(%7 : i1) ^bb1: // pred: ^bb0 - %22 = "llvm.icmp"(%20, %3) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.br"(%22)[^bb2] : (i1) -> () - ^bb2(%23: i1): // 2 preds: ^bb0, ^bb1 - %24 = "llvm.zext"(%23) : (i1) -> i32 - %25 = "llvm.mul"(%1, %24) : (i32, i32) -> i32 - %26 = "llvm.trunc"(%25) : (i32) -> i8 - "llvm.store"(%26, %0) : (i8, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "func", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %21 = llvm.icmp "ne" %19, %6 : i32 + llvm.br ^bb2(%21 : i1) + ^bb2(%22: i1): // 2 preds: ^bb0, ^bb1 + %23 = llvm.zext %22 : i1 to i32 + %24 = llvm.mul %8, %23 overflow : i32 + %25 = llvm.trunc %24 : i32 to i8 + llvm.store %25, %3 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2012-06-06-LoadOfPHIs.ll.mlir b/test/LLVMDialect/InstCombine/2012-06-06-LoadOfPHIs.ll.mlir new file mode 100644 index 000000000..d66c5bbb8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2012-06-06-LoadOfPHIs.ll.mlir @@ -0,0 +1,133 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @func(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr) attributes {passthrough = ["nounwind", "ssp", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %3 = llvm.mlir.constant(4.000000e+00 : f64) : f64 + %4 = llvm.mlir.constant(6.000000e+00 : f64) : f64 + %5 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %6 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %7 = llvm.alloca %0 x f64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %8 = llvm.alloca %0 x f64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %9 = llvm.alloca %0 x f64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %7 {alignment = 8 : i64} : f64, !llvm.ptr + llvm.store %arg1, %8 {alignment = 8 : i64} : f64, !llvm.ptr + llvm.store %arg2, %9 {alignment = 8 : i64} : f64, !llvm.ptr + %10 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + llvm.cond_br %10, ^bb1, ^bb4 + ^bb1: // pred: ^bb0 + %11 = llvm.fcmp "ogt" %arg0, %arg2 : f64 + llvm.cond_br %11, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.br ^bb7(%7 : !llvm.ptr) + ^bb3: // pred: ^bb1 + llvm.br ^bb7(%9 : !llvm.ptr) + ^bb4: // pred: ^bb0 + %12 = llvm.fcmp "ogt" %arg1, %arg2 : f64 + llvm.cond_br %12, ^bb5, ^bb6 + ^bb5: // pred: ^bb4 + llvm.br ^bb7(%8 : !llvm.ptr) + ^bb6: // pred: ^bb4 + llvm.br ^bb7(%9 : !llvm.ptr) + ^bb7(%13: !llvm.ptr): // 4 preds: ^bb2, ^bb3, ^bb5, ^bb6 + %14 = llvm.load %7 {alignment = 8 : i64} : !llvm.ptr -> f64 + %15 = llvm.load %8 {alignment = 8 : i64} : !llvm.ptr -> f64 + %16 = llvm.fcmp "olt" %14, %15 : f64 + llvm.cond_br %16, ^bb8, ^bb11 + ^bb8: // pred: ^bb7 + %17 = llvm.load %9 {alignment = 8 : i64} : !llvm.ptr -> f64 + %18 = llvm.fcmp "olt" %14, %17 : f64 + llvm.cond_br %18, ^bb9, ^bb10 + ^bb9: // pred: ^bb8 + llvm.br ^bb14(%7 : !llvm.ptr) + ^bb10: // pred: ^bb8 + llvm.br ^bb14(%9 : !llvm.ptr) + ^bb11: // pred: ^bb7 + %19 = llvm.load %9 {alignment = 8 : i64} : !llvm.ptr -> f64 + %20 = llvm.fcmp "olt" %15, %19 : f64 + llvm.cond_br %20, ^bb12, ^bb13 + ^bb12: // pred: ^bb11 + llvm.br ^bb14(%8 : !llvm.ptr) + ^bb13: // pred: ^bb11 + llvm.br ^bb14(%9 : !llvm.ptr) + ^bb14(%21: !llvm.ptr): // 4 preds: ^bb9, ^bb10, ^bb12, ^bb13 + %22 = llvm.load %21 {alignment = 8 : i64} : !llvm.ptr -> f64 + %23 = llvm.load %13 {alignment = 8 : i64} : !llvm.ptr -> f64 + %24 = llvm.fadd %22, %23 : f64 + %25 = llvm.fdiv %24, %1 : f64 + llvm.store %25, %arg5 {alignment = 8 : i64} : f64, !llvm.ptr + %26 = llvm.load %21 {alignment = 8 : i64} : !llvm.ptr -> f64 + %27 = llvm.load %13 {alignment = 8 : i64} : !llvm.ptr -> f64 + %28 = llvm.fcmp "oeq" %26, %27 : f64 + llvm.cond_br %28, ^bb15, ^bb16 + ^bb15: // pred: ^bb14 + llvm.store %5, %arg4 {alignment = 8 : i64} : f64, !llvm.ptr + llvm.store %5, %arg3 {alignment = 8 : i64} : f64, !llvm.ptr + llvm.br ^bb26 + ^bb16: // pred: ^bb14 + %29 = llvm.fcmp "olt" %25, %2 : f64 + %30 = llvm.fsub %27, %26 : f64 + llvm.cond_br %29, ^bb17, ^bb18 + ^bb17: // pred: ^bb16 + %31 = llvm.fadd %27, %26 : f64 + %32 = llvm.fdiv %30, %31 : f64 + llvm.store %32, %arg4 {alignment = 8 : i64} : f64, !llvm.ptr + llvm.br ^bb19 + ^bb18: // pred: ^bb16 + %33 = llvm.fsub %1, %27 : f64 + %34 = llvm.fsub %33, %26 : f64 + %35 = llvm.fdiv %30, %34 : f64 + llvm.store %35, %arg4 {alignment = 8 : i64} : f64, !llvm.ptr + llvm.br ^bb19 + ^bb19: // 2 preds: ^bb17, ^bb18 + %36 = llvm.icmp "eq" %13, %7 : !llvm.ptr + llvm.cond_br %36, ^bb20, ^bb21 + ^bb20: // pred: ^bb19 + %37 = llvm.load %8 {alignment = 8 : i64} : !llvm.ptr -> f64 + %38 = llvm.load %9 {alignment = 8 : i64} : !llvm.ptr -> f64 + %39 = llvm.fsub %37, %38 : f64 + %40 = llvm.load %13 {alignment = 8 : i64} : !llvm.ptr -> f64 + %41 = llvm.load %21 {alignment = 8 : i64} : !llvm.ptr -> f64 + %42 = llvm.fsub %40, %41 : f64 + %43 = llvm.fdiv %39, %42 : f64 + llvm.store %43, %arg3 {alignment = 8 : i64} : f64, !llvm.ptr + llvm.br ^bb24 + ^bb21: // pred: ^bb19 + %44 = llvm.icmp "eq" %13, %8 : !llvm.ptr + llvm.cond_br %44, ^bb22, ^bb23 + ^bb22: // pred: ^bb21 + %45 = llvm.load %9 {alignment = 8 : i64} : !llvm.ptr -> f64 + %46 = llvm.load %7 {alignment = 8 : i64} : !llvm.ptr -> f64 + %47 = llvm.fsub %45, %46 : f64 + %48 = llvm.load %13 {alignment = 8 : i64} : !llvm.ptr -> f64 + %49 = llvm.load %21 {alignment = 8 : i64} : !llvm.ptr -> f64 + %50 = llvm.fsub %48, %49 : f64 + %51 = llvm.fdiv %47, %50 : f64 + %52 = llvm.fadd %1, %51 : f64 + llvm.store %52, %arg3 {alignment = 8 : i64} : f64, !llvm.ptr + llvm.br ^bb24 + ^bb23: // pred: ^bb21 + %53 = llvm.load %7 {alignment = 8 : i64} : !llvm.ptr -> f64 + %54 = llvm.load %8 {alignment = 8 : i64} : !llvm.ptr -> f64 + %55 = llvm.fsub %53, %54 : f64 + %56 = llvm.load %13 {alignment = 8 : i64} : !llvm.ptr -> f64 + %57 = llvm.load %21 {alignment = 8 : i64} : !llvm.ptr -> f64 + %58 = llvm.fsub %56, %57 : f64 + %59 = llvm.fdiv %55, %58 : f64 + %60 = llvm.fadd %3, %59 : f64 + llvm.store %60, %arg3 {alignment = 8 : i64} : f64, !llvm.ptr + llvm.br ^bb24 + ^bb24: // 3 preds: ^bb20, ^bb22, ^bb23 + %61 = llvm.load %arg3 {alignment = 8 : i64} : !llvm.ptr -> f64 + %62 = llvm.fdiv %61, %4 : f64 + llvm.store %62, %arg3 {alignment = 8 : i64} : f64, !llvm.ptr + %63 = llvm.fcmp "olt" %62, %5 : f64 + llvm.cond_br %63, ^bb25, ^bb26 + ^bb25: // pred: ^bb24 + %64 = llvm.fadd %62, %6 : f64 + llvm.store %64, %arg3 {alignment = 8 : i64} : f64, !llvm.ptr + llvm.br ^bb26 + ^bb26: // 3 preds: ^bb15, ^bb24, ^bb25 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2012-07-25-LoadPart.ll.mlir b/test/LLVMDialect/InstCombine/2012-07-25-LoadPart.ll.mlir index 68c90a47a..fbc977f17 100644 --- a/test/LLVMDialect/InstCombine/2012-07-25-LoadPart.ll.mlir +++ b/test/LLVMDialect/InstCombine/2012-07-25-LoadPart.ll.mlir @@ -1,14 +1,11 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "test", type = !llvm.array<4 x i32>, value = dense<[1, 2, 3, 4]> : tensor<4xi32>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @test} : () -> !llvm.ptr> - %2 = "llvm.bitcast"(%1) : (!llvm.ptr>) -> !llvm.ptr - %3 = "llvm.getelementptr"(%2, %0) : (!llvm.ptr, i64) -> !llvm.ptr - %4 = "llvm.bitcast"(%3) : (!llvm.ptr) -> !llvm.ptr - %5 = "llvm.load"(%4) : (!llvm.ptr) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @test(dense<[1, 2, 3, 4]> : tensor<4xi32>) {addr_space = 0 : i32} : !llvm.array<4 x i32> + llvm.func @foo() -> i64 { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : tensor<4xi32>) : !llvm.array<4 x i32> + %2 = llvm.mlir.addressof @test : !llvm.ptr + %3 = llvm.getelementptr %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.load %3 {alignment = 1 : i64} : !llvm.ptr -> i64 + llvm.return %4 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/2012-07-30-addrsp-bitcast.ll.mlir b/test/LLVMDialect/InstCombine/2012-07-30-addrsp-bitcast.ll.mlir new file mode 100644 index 000000000..225666888 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2012-07-30-addrsp-bitcast.ll.mlir @@ -0,0 +1,14 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal unnamed_addr @base(dense<0> : tensor<16xi32>) {addr_space = 3 : i32, alignment = 16 : i64, dso_local} : !llvm.array<16 x i32> + llvm.func @foo(!llvm.ptr) + llvm.func @test() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : tensor<16xi32>) : !llvm.array<16 x i32> + %3 = llvm.mlir.addressof @base : !llvm.ptr<3> + %4 = llvm.addrspacecast %3 : !llvm.ptr<3> to !llvm.ptr + %5 = llvm.getelementptr %4[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.call @foo(%5) : (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2012-08-28-udiv_ashl.ll.mlir b/test/LLVMDialect/InstCombine/2012-08-28-udiv_ashl.ll.mlir index 3e51e3d80..0dad3e95d 100644 --- a/test/LLVMDialect/InstCombine/2012-08-28-udiv_ashl.ll.mlir +++ b/test/LLVMDialect/InstCombine/2012-08-28-udiv_ashl.ll.mlir @@ -1,42 +1,36 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.udiv"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "udiv400", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.udiv"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "udiv400_no", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.sdiv"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sdiv400_yes", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i80): // no predecessors - %0 = "llvm.mlir.constant"() {value = 100 : i80} : () -> i80 - %1 = "llvm.mlir.constant"() {value = 2 : i80} : () -> i80 - %2 = "llvm.lshr"(%arg0, %1) : (i80, i80) -> i80 - %3 = "llvm.udiv"(%2, %0) : (i80, i80) -> i80 - "llvm.return"(%3) : (i80) -> () - }) {linkage = 10 : i64, sym_name = "udiv_i80", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %1 = "llvm.lshr"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.udiv"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "no_crash_notconst_udiv", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @udiv400(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(100 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.udiv %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @udiv400_no(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(100 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.udiv %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @sdiv400_yes(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(100 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.sdiv %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @udiv_i80(%arg0: i80) -> i80 { + %0 = llvm.mlir.constant(2 : i80) : i80 + %1 = llvm.mlir.constant(100 : i80) : i80 + %2 = llvm.lshr %arg0, %0 : i80 + %3 = llvm.udiv %2, %1 : i80 + llvm.return %3 : i80 + } + llvm.func @no_crash_notconst_udiv(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.lshr %arg0, %arg1 : i32 + %2 = llvm.udiv %1, %0 : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2012-09-17-ZeroSizedAlloca.ll.mlir b/test/LLVMDialect/InstCombine/2012-09-17-ZeroSizedAlloca.ll.mlir index ccfdc9998..53b25c65c 100644 --- a/test/LLVMDialect/InstCombine/2012-09-17-ZeroSizedAlloca.ll.mlir +++ b/test/LLVMDialect/InstCombine/2012-09-17-ZeroSizedAlloca.ll.mlir @@ -1,24 +1,21 @@ -"module"() ( { - "llvm.mlir.global"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "x", type = !llvm.ptr} : () -> () - "llvm.mlir.global"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "y", type = !llvm.ptr} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @y} : () -> !llvm.ptr> - %1 = "llvm.mlir.addressof"() {global_name = @x} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr> - %5 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr> - %6 = "llvm.getelementptr"(%4, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %7 = "llvm.getelementptr"(%5, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - "llvm.store"(%6, %1) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.store"(%7, %0) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.mlir.global external @x() {addr_space = 0 : i32, alignment = 8 : i64} : !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.mlir.global external @y() {addr_space = 0 : i32, alignment = 8 : i64} : !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @f() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @x : !llvm.ptr + %3 = llvm.mlir.addressof @y : !llvm.ptr + %4 = llvm.alloca %0 x !llvm.array<0 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + %5 = llvm.alloca %0 x !llvm.array<0 x i8> {alignment = 1024 : i64} : (i32) -> !llvm.ptr + llvm.store %4, %2 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.store %5, %3 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2012-10-25-vector-of-pointers.ll.mlir b/test/LLVMDialect/InstCombine/2012-10-25-vector-of-pointers.ll.mlir new file mode 100644 index 000000000..3eb555a29 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2012-10-25-vector-of-pointers.ll.mlir @@ -0,0 +1,35 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @widget(%arg0: !llvm.ptr {llvm.nocapture}, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1, %arg5: i1) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.constant(dense<3> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + llvm.cond_br %arg1, ^bb1, ^bb10 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg2, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.br ^bb10 + ^bb3: // pred: ^bb1 + %4 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.vec<2 x ptr> + %5 = llvm.ptrtoint %4 : !llvm.vec<2 x ptr> to vector<2xi64> + %6 = llvm.sub %1, %5 : vector<2xi64> + %7 = llvm.ashr %6, %2 : vector<2xi64> + %8 = llvm.extractelement %7[%3 : i32] : vector<2xi64> + %9 = llvm.add %0, %8 overflow : i64 + llvm.cond_br %arg5, ^bb4, ^bb5 + ^bb4: // pred: ^bb3 + llvm.br ^bb6 + ^bb5: // pred: ^bb3 + llvm.br ^bb6 + ^bb6: // 2 preds: ^bb4, ^bb5 + llvm.cond_br %arg3, ^bb9, ^bb7 + ^bb7: // pred: ^bb6 + llvm.cond_br %arg4, ^bb9, ^bb8 + ^bb8: // pred: ^bb7 + llvm.br ^bb9 + ^bb9: // 3 preds: ^bb6, ^bb7, ^bb8 + llvm.unreachable + ^bb10: // 2 preds: ^bb0, ^bb2 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2012-12-14-simp-vgep.ll.mlir b/test/LLVMDialect/InstCombine/2012-12-14-simp-vgep.ll.mlir new file mode 100644 index 000000000..7293d5f07 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2012-12-14-simp-vgep.ll.mlir @@ -0,0 +1,18 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: !llvm.ptr) -> vector<4xi32> { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.undef : !llvm.vec<4 x ptr> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec<4 x ptr> + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec<4 x ptr> + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.insertelement %0, %5[%6 : i32] : !llvm.vec<4 x ptr> + %8 = llvm.mlir.constant(3 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : !llvm.vec<4 x ptr> + %10 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.vec<4 x ptr> + %11 = llvm.icmp "eq" %10, %9 : !llvm.vec<4 x ptr> + %12 = llvm.zext %11 : vector<4xi1> to vector<4xi32> + llvm.return %12 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/2012-3-15-or-xor-constant.ll.mlir b/test/LLVMDialect/InstCombine/2012-3-15-or-xor-constant.ll.mlir new file mode 100644 index 000000000..670c9ee65 --- /dev/null +++ b/test/LLVMDialect/InstCombine/2012-3-15-or-xor-constant.ll.mlir @@ -0,0 +1,17 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global extern_weak @g() {addr_space = 0 : i32} : i32 + llvm.func @function(%arg0: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.inttoptr %1 : i64 to !llvm.ptr + %3 = llvm.mlir.addressof @g : !llvm.ptr + %4 = llvm.mlir.zero : !llvm.ptr + %5 = llvm.xor %arg0, %0 : i32 + llvm.store volatile %5, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.icmp "eq" %3, %4 : !llvm.ptr + %7 = llvm.zext %6 : i1 to i32 + %8 = llvm.or %7, %0 : i32 + %9 = llvm.or %8, %5 : i32 + llvm.return %9 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/2012-6-7-vselect-bitcast.ll.mlir b/test/LLVMDialect/InstCombine/2012-6-7-vselect-bitcast.ll.mlir new file mode 100644 index 000000000..2104b093c --- /dev/null +++ b/test/LLVMDialect/InstCombine/2012-6-7-vselect-bitcast.ll.mlir @@ -0,0 +1,11 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: vector<16xi8>, %arg1: vector<16xi8>, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %2 = llvm.bitcast %arg0 : vector<16xi8> to vector<4xi32> + %3 = llvm.bitcast %arg1 : vector<16xi8> to vector<4xi32> + %4 = llvm.select %1, %2, %3 : vector<4xi1>, vector<4xi32> + llvm.store %4, %arg2 {alignment = 4 : i64} : vector<4xi32>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/2013-03-05-Combine-BitcastTy-Into-Alloca.ll.mlir b/test/LLVMDialect/InstCombine/2013-03-05-Combine-BitcastTy-Into-Alloca.ll.mlir new file mode 100644 index 000000000..a8e81349c --- /dev/null +++ b/test/LLVMDialect/InstCombine/2013-03-05-Combine-BitcastTy-Into-Alloca.ll.mlir @@ -0,0 +1,56 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @initval() {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.struct<"struct._my_struct", packed (array<12 x i8>, array<4 x i8>)> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant(dense<0> : tensor<12xi8>) : !llvm.array<12 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct._my_struct", packed (array<12 x i8>, array<4 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct._my_struct", packed (array<12 x i8>, array<4 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct._my_struct", packed (array<12 x i8>, array<4 x i8>)> + llvm.return %5 : !llvm.struct<"struct._my_struct", packed (array<12 x i8>, array<4 x i8>)> + } + llvm.func @function(%arg0: i32, %arg1: i32, %arg2: i32) -> !llvm.struct<(i64, i64)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %3 = llvm.mlir.constant(dense<0> : tensor<12xi8>) : !llvm.array<12 x i8> + %4 = llvm.mlir.undef : !llvm.struct<"struct._my_struct", packed (array<12 x i8>, array<4 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct._my_struct", packed (array<12 x i8>, array<4 x i8>)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"struct._my_struct", packed (array<12 x i8>, array<4 x i8>)> + %7 = llvm.mlir.addressof @initval : !llvm.ptr + %8 = llvm.mlir.constant(0 : i64) : i64 + %9 = llvm.getelementptr inbounds %7[%8, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct._my_struct", packed (array<12 x i8>, array<4 x i8>)> + %10 = llvm.mlir.constant(6 : i96) : i96 + %11 = llvm.mlir.constant(-288230376151711744 : i96) : i96 + %12 = llvm.mlir.constant(32 : i96) : i96 + %13 = llvm.mlir.constant(288230371856744448 : i96) : i96 + %14 = llvm.mlir.constant(4294967232 : i96) : i96 + %15 = llvm.mlir.constant(63 : i96) : i96 + %16 = llvm.mlir.undef : !llvm.struct<(i64, i64)> + %17 = llvm.mlir.constant(0 : i32) : i32 + %18 = llvm.mlir.constant(8 : i64) : i64 + %19 = llvm.alloca %0 x !llvm.struct<"struct._my_struct", packed (array<12 x i8>, array<4 x i8>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %20 = llvm.load %7 {alignment = 1 : i64} : !llvm.ptr -> i96 + %21 = llvm.load %9 {alignment = 1 : i64} : !llvm.ptr -> i32 + %22 = llvm.zext %arg0 : i32 to i96 + %23 = llvm.shl %22, %10 overflow : i96 + %24 = llvm.and %20, %11 : i96 + %25 = llvm.zext %arg1 : i32 to i96 + %26 = llvm.shl %25, %12 overflow : i96 + %27 = llvm.and %26, %13 : i96 + %28 = llvm.and %23, %14 : i96 + %29 = llvm.zext %arg2 : i32 to i96 + %30 = llvm.and %29, %15 : i96 + %31 = llvm.or %27, %28 : i96 + %32 = llvm.or %31, %30 : i96 + %33 = llvm.or %32, %24 : i96 + llvm.store %33, %19 {alignment = 8 : i64} : i96, !llvm.ptr + %34 = llvm.getelementptr inbounds %19[%8, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct._my_struct", packed (array<12 x i8>, array<4 x i8>)> + llvm.store %21, %34 {alignment = 4 : i64} : i32, !llvm.ptr + %35 = llvm.trunc %33 : i96 to i64 + %36 = llvm.insertvalue %35, %16[0] : !llvm.struct<(i64, i64)> + %37 = llvm.getelementptr inbounds %19[%8, 0, %18] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.struct<"struct._my_struct", packed (array<12 x i8>, array<4 x i8>)> + %38 = llvm.load %37 {alignment = 8 : i64} : !llvm.ptr -> i64 + %39 = llvm.insertvalue %38, %36[1] : !llvm.struct<(i64, i64)> + llvm.return %39 : !llvm.struct<(i64, i64)> + } +} diff --git a/test/LLVMDialect/InstCombine/2023-07-13-arm-infiniteloop.ll.mlir b/test/LLVMDialect/InstCombine/2023-07-13-arm-infiniteloop.ll.mlir new file mode 100644 index 000000000..87ccc5bab --- /dev/null +++ b/test/LLVMDialect/InstCombine/2023-07-13-arm-infiniteloop.ll.mlir @@ -0,0 +1,24 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: !llvm.ptr, %arg1: i32) { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(16 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.zext %arg1 : i32 to i64 + %6 = llvm.lshr %5, %0 : i64 + %7 = llvm.trunc %6 : i64 to i32 + %8 = "llvm.intr.is.constant"(%7) : (i32) -> i1 + llvm.cond_br %8, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + %9 = llvm.load volatile %1 {alignment = 2147483648 : i64} : !llvm.ptr -> i32 + llvm.br ^bb3(%9 : i32) + ^bb2: // pred: ^bb0 + %10 = llvm.intr.fshl(%7, %2, %3) : (i32, i32, i32) -> i32 + llvm.br ^bb3(%10 : i32) + ^bb3(%11: i32): // 2 preds: ^bb1, ^bb2 + %12 = llvm.lshr %11, %4 : i32 + llvm.store %12, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/AddOverFlow.ll.mlir b/test/LLVMDialect/InstCombine/AddOverFlow.ll.mlir new file mode 100644 index 000000000..48410dacc --- /dev/null +++ b/test/LLVMDialect/InstCombine/AddOverFlow.ll.mlir @@ -0,0 +1,151 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @oppositesign(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(-32768 : i16) : i16 + %1 = llvm.mlir.constant(32767 : i16) : i16 + %2 = llvm.or %arg0, %0 : i16 + %3 = llvm.and %arg1, %1 : i16 + %4 = llvm.add %2, %3 : i16 + llvm.return %4 : i16 + } + llvm.func @zero_sign_bit(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(32767 : i16) : i16 + %1 = llvm.mlir.constant(512 : i16) : i16 + %2 = llvm.and %arg0, %0 : i16 + %3 = llvm.add %2, %1 : i16 + llvm.return %3 : i16 + } + llvm.func @zero_sign_bit2(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32767 : i16) : i16 + %1 = llvm.and %arg0, %0 : i16 + %2 = llvm.and %arg1, %0 : i16 + %3 = llvm.add %1, %2 : i16 + llvm.return %3 : i16 + } + llvm.func @bounded(i16) -> i16 + llvm.func @__gxx_personality_v0(...) -> i32 + llvm.func @add_bounded_values(%arg0: i16, %arg1: i16) -> i16 attributes {personality = @__gxx_personality_v0} { + %0 = llvm.mlir.undef : !llvm.array<0 x ptr> + %1 = llvm.mlir.constant(42 : i16) : i16 + %2 = llvm.call @bounded(%arg0) : (i16) -> i16 + %3 = llvm.invoke @bounded(%arg1) to ^bb1 unwind ^bb2 : (i16) -> i16 + ^bb1: // pred: ^bb0 + %4 = llvm.add %2, %3 : i16 + llvm.return %4 : i16 + ^bb2: // pred: ^bb0 + %5 = llvm.landingpad (filter %0 : !llvm.array<0 x ptr>) : !llvm.struct<(ptr, i32)> + llvm.return %1 : i16 + } + llvm.func @add_bounded_values_2(%arg0: i16, %arg1: i16) -> i16 attributes {personality = @__gxx_personality_v0} { + %0 = llvm.mlir.undef : !llvm.array<0 x ptr> + %1 = llvm.mlir.constant(42 : i16) : i16 + %2 = llvm.call @bounded(%arg0) : (i16) -> i16 + %3 = llvm.invoke @bounded(%arg1) to ^bb1 unwind ^bb2 : (i16) -> i16 + ^bb1: // pred: ^bb0 + %4 = llvm.add %2, %3 : i16 + llvm.return %4 : i16 + ^bb2: // pred: ^bb0 + %5 = llvm.landingpad (filter %0 : !llvm.array<0 x ptr>) : !llvm.struct<(ptr, i32)> + llvm.return %1 : i16 + } + llvm.func @ripple_nsw1(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.constant(-16385 : i16) : i16 + %2 = llvm.and %arg1, %0 : i16 + %3 = llvm.and %arg0, %1 : i16 + %4 = llvm.add %2, %3 : i16 + llvm.return %4 : i16 + } + llvm.func @ripple_nsw2(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.constant(-16385 : i16) : i16 + %2 = llvm.and %arg1, %0 : i16 + %3 = llvm.and %arg0, %1 : i16 + %4 = llvm.add %3, %2 : i16 + llvm.return %4 : i16 + } + llvm.func @ripple_nsw3(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(-21845 : i16) : i16 + %1 = llvm.mlir.constant(21843 : i16) : i16 + %2 = llvm.and %arg1, %0 : i16 + %3 = llvm.and %arg0, %1 : i16 + %4 = llvm.add %2, %3 : i16 + llvm.return %4 : i16 + } + llvm.func @ripple_nsw4(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(-21845 : i16) : i16 + %1 = llvm.mlir.constant(21843 : i16) : i16 + %2 = llvm.and %arg1, %0 : i16 + %3 = llvm.and %arg0, %1 : i16 + %4 = llvm.add %3, %2 : i16 + llvm.return %4 : i16 + } + llvm.func @ripple_nsw5(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(-21845 : i16) : i16 + %1 = llvm.mlir.constant(-10923 : i16) : i16 + %2 = llvm.or %arg1, %0 : i16 + %3 = llvm.or %arg0, %1 : i16 + %4 = llvm.add %2, %3 : i16 + llvm.return %4 : i16 + } + llvm.func @ripple_nsw6(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(-21845 : i16) : i16 + %1 = llvm.mlir.constant(-10923 : i16) : i16 + %2 = llvm.or %arg1, %0 : i16 + %3 = llvm.or %arg0, %1 : i16 + %4 = llvm.add %3, %2 : i16 + llvm.return %4 : i16 + } + llvm.func @ripple_no_nsw1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.and %arg1, %0 : i32 + %2 = llvm.add %1, %arg0 : i32 + llvm.return %2 : i32 + } + llvm.func @ripple_no_nsw2(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.constant(32767 : i16) : i16 + %2 = llvm.and %arg1, %0 : i16 + %3 = llvm.and %arg0, %1 : i16 + %4 = llvm.add %2, %3 : i16 + llvm.return %4 : i16 + } + llvm.func @ripple_no_nsw3(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(-21845 : i16) : i16 + %1 = llvm.mlir.constant(21845 : i16) : i16 + %2 = llvm.and %arg1, %0 : i16 + %3 = llvm.and %arg0, %1 : i16 + %4 = llvm.add %2, %3 : i16 + llvm.return %4 : i16 + } + llvm.func @ripple_no_nsw4(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(-21845 : i16) : i16 + %1 = llvm.mlir.constant(21845 : i16) : i16 + %2 = llvm.and %arg1, %0 : i16 + %3 = llvm.and %arg0, %1 : i16 + %4 = llvm.add %3, %2 : i16 + llvm.return %4 : i16 + } + llvm.func @ripple_no_nsw5(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(-21847 : i16) : i16 + %1 = llvm.mlir.constant(-10923 : i16) : i16 + %2 = llvm.or %arg1, %0 : i16 + %3 = llvm.or %arg0, %1 : i16 + %4 = llvm.add %2, %3 : i16 + llvm.return %4 : i16 + } + llvm.func @ripple_no_nsw6(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(-21847 : i16) : i16 + %1 = llvm.mlir.constant(-10923 : i16) : i16 + %2 = llvm.or %arg1, %0 : i16 + %3 = llvm.or %arg0, %1 : i16 + %4 = llvm.add %3, %2 : i16 + llvm.return %4 : i16 + } + llvm.func @PR38021(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(-63 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.add %2, %1 : i8 + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/CPP_min_max.ll.mlir b/test/LLVMDialect/InstCombine/CPP_min_max.ll.mlir new file mode 100644 index 000000000..5934a44ab --- /dev/null +++ b/test/LLVMDialect/InstCombine/CPP_min_max.ll.mlir @@ -0,0 +1,23 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @_Z5test1RiS_(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.load %arg1 {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %2 = llvm.icmp "slt" %0, %1 : i32 + %3 = llvm.select %2, %arg1, %arg0 : i1, !llvm.ptr + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %4, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @_Z5test2RiS_(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %2, %1 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.load %arg1 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.icmp "slt" %2, %3 : i32 + %5 = llvm.select %4, %arg1, %1 : i1, !llvm.ptr + %6 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %6, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/ExtractCast.ll.mlir b/test/LLVMDialect/InstCombine/ExtractCast.ll.mlir new file mode 100644 index 000000000..a7d81e2c9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/ExtractCast.ll.mlir @@ -0,0 +1,14 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a(%arg0: vector<4xi64>) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.trunc %arg0 : vector<4xi64> to vector<4xi32> + %2 = llvm.extractelement %1[%0 : i32] : vector<4xi32> + llvm.return %2 : i32 + } + llvm.func @b(%arg0: vector<4xf32>) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.fptosi %arg0 : vector<4xf32> to vector<4xi32> + %2 = llvm.extractelement %1[%0 : i32] : vector<4xi32> + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/InferAlignAttribute.ll.mlir b/test/LLVMDialect/InstCombine/InferAlignAttribute.ll.mlir new file mode 100644 index 000000000..29e39d343 --- /dev/null +++ b/test/LLVMDialect/InstCombine/InferAlignAttribute.ll.mlir @@ -0,0 +1,32 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @widen_align_from_allocalign_callsite() -> !llvm.ptr { + %0 = llvm.mlir.constant(320 : i32) : i32 + %1 = llvm.mlir.constant(64 : i32) : i32 + %2 = llvm.call @my_aligned_alloc_2(%0, %1) : (i32, i32) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @widen_align_from_allocalign() -> !llvm.ptr { + %0 = llvm.mlir.constant(320 : i32) : i32 + %1 = llvm.mlir.constant(64 : i32) : i32 + %2 = llvm.call @my_aligned_alloc(%0, %1) : (i32, i32) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @dont_narrow_align_from_allocalign() -> !llvm.ptr { + %0 = llvm.mlir.constant(320 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.call @my_aligned_alloc(%0, %1) : (i32, i32) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @my_aligned_alloc_3(%arg0: i32 {llvm.noundef}, %arg1: i32 {llvm.allocalign}) -> !llvm.ptr { + %0 = llvm.call @my_aligned_alloc_2(%arg0, %arg1) : (i32, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @allocalign_disappears() -> !llvm.ptr { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.call @my_aligned_alloc_3(%0, %1) : (i32, i32) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @my_aligned_alloc(i32 {llvm.noundef}, i32 {llvm.allocalign, llvm.noundef}) -> !llvm.ptr + llvm.func @my_aligned_alloc_2(i32 {llvm.noundef}, i32 {llvm.noundef}) -> !llvm.ptr +} diff --git a/test/LLVMDialect/InstCombine/IntPtrCast.ll.mlir b/test/LLVMDialect/InstCombine/IntPtrCast.ll.mlir index ee72cedcd..596481fa1 100644 --- a/test/LLVMDialect/InstCombine/IntPtrCast.ll.mlir +++ b/test/LLVMDialect/InstCombine/IntPtrCast.ll.mlir @@ -1,9 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.ptrtoint"(%arg0) : (!llvm.ptr) -> i32 - %1 = "llvm.inttoptr"(%0) : (i32) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func (ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.ptrtoint %arg0 : !llvm.ptr to i32 + %1 = llvm.inttoptr %0 : i32 to !llvm.ptr + llvm.return %1 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/JavaCompare.ll.mlir b/test/LLVMDialect/InstCombine/JavaCompare.ll.mlir new file mode 100644 index 000000000..1ccf299c5 --- /dev/null +++ b/test/LLVMDialect/InstCombine/JavaCompare.ll.mlir @@ -0,0 +1,13 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @le(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i32 + %5 = llvm.icmp "slt" %arg0, %arg1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i32 + %7 = llvm.icmp "sle" %6, %1 : i32 + llvm.return %7 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/LandingPadClauses.ll.mlir b/test/LLVMDialect/InstCombine/LandingPadClauses.ll.mlir new file mode 100644 index 000000000..ec6a2366a --- /dev/null +++ b/test/LLVMDialect/InstCombine/LandingPadClauses.ll.mlir @@ -0,0 +1,171 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @T1() {addr_space = 0 : i32} : i32 + llvm.mlir.global external constant @T2() {addr_space = 0 : i32} : i32 + llvm.mlir.global external constant @T3() {addr_space = 0 : i32} : i32 + llvm.func @generic_personality(i32, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.func @__gxx_personality_v0(i32, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.func @__objc_personality_v0(i32, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.func @__C_specific_handler(...) -> i32 + llvm.func @bar() + llvm.func @foo_generic() attributes {personality = @generic_personality} { + %0 = llvm.mlir.addressof @T1 : !llvm.ptr + %1 = llvm.mlir.addressof @T2 : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.array<0 x ptr> + %3 = llvm.mlir.undef : !llvm.array<1 x ptr> + %4 = llvm.insertvalue %0, %3[0] : !llvm.array<1 x ptr> + %5 = llvm.mlir.zero : !llvm.ptr + %6 = llvm.mlir.undef : !llvm.array<3 x ptr> + %7 = llvm.insertvalue %5, %6[0] : !llvm.array<3 x ptr> + %8 = llvm.insertvalue %5, %7[1] : !llvm.array<3 x ptr> + %9 = llvm.insertvalue %5, %8[2] : !llvm.array<3 x ptr> + %10 = llvm.mlir.undef : !llvm.array<3 x ptr> + %11 = llvm.insertvalue %0, %10[0] : !llvm.array<3 x ptr> + %12 = llvm.insertvalue %1, %11[1] : !llvm.array<3 x ptr> + %13 = llvm.insertvalue %1, %12[2] : !llvm.array<3 x ptr> + %14 = llvm.mlir.undef : !llvm.array<2 x ptr> + %15 = llvm.insertvalue %1, %14[0] : !llvm.array<2 x ptr> + %16 = llvm.insertvalue %0, %15[1] : !llvm.array<2 x ptr> + %17 = llvm.mlir.addressof @T3 : !llvm.ptr + %18 = llvm.mlir.undef : !llvm.array<2 x ptr> + %19 = llvm.insertvalue %0, %18[0] : !llvm.array<2 x ptr> + %20 = llvm.insertvalue %5, %19[1] : !llvm.array<2 x ptr> + %21 = llvm.mlir.undef : !llvm.array<1 x ptr> + %22 = llvm.insertvalue %5, %21[0] : !llvm.array<1 x ptr> + llvm.invoke @bar() to ^bb1 unwind ^bb10 : () -> () + ^bb1: // pred: ^bb0 + llvm.invoke @bar() to ^bb2 unwind ^bb11 : () -> () + ^bb2: // pred: ^bb1 + llvm.invoke @bar() to ^bb3 unwind ^bb12 : () -> () + ^bb3: // pred: ^bb2 + llvm.invoke @bar() to ^bb4 unwind ^bb13 : () -> () + ^bb4: // pred: ^bb3 + llvm.invoke @bar() to ^bb5 unwind ^bb14 : () -> () + ^bb5: // pred: ^bb4 + llvm.invoke @bar() to ^bb6 unwind ^bb15 : () -> () + ^bb6: // pred: ^bb5 + llvm.invoke @bar() to ^bb7 unwind ^bb16 : () -> () + ^bb7: // pred: ^bb6 + llvm.invoke @bar() to ^bb8 unwind ^bb17 : () -> () + ^bb8: // pred: ^bb7 + llvm.invoke @bar() to ^bb9 unwind ^bb18 : () -> () + ^bb9: // pred: ^bb8 + llvm.return + ^bb10: // pred: ^bb0 + %23 = llvm.landingpad (catch %0 : !llvm.ptr) (catch %1 : !llvm.ptr) (catch %0 : !llvm.ptr) (catch %1 : !llvm.ptr) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb11: // pred: ^bb1 + %24 = llvm.landingpad (filter %2 : !llvm.array<0 x ptr>) (catch %0 : !llvm.ptr) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb12: // pred: ^bb2 + %25 = llvm.landingpad (catch %0 : !llvm.ptr) (filter %4 : !llvm.array<1 x ptr>) (catch %1 : !llvm.ptr) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb13: // pred: ^bb3 + %26 = llvm.landingpad (filter %9 : !llvm.array<3 x ptr>) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb14: // pred: ^bb4 + %27 = llvm.landingpad (catch %0 : !llvm.ptr) (filter %13 : !llvm.array<3 x ptr>) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb15: // pred: ^bb5 + %28 = llvm.landingpad (filter %16 : !llvm.array<2 x ptr>) (filter %4 : !llvm.array<1 x ptr>) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb16: // pred: ^bb6 + %29 = llvm.landingpad (filter %4 : !llvm.array<1 x ptr>) (catch %17 : !llvm.ptr) (filter %16 : !llvm.array<2 x ptr>) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb17: // pred: ^bb7 + %30 = llvm.landingpad (filter %20 : !llvm.array<2 x ptr>) (filter %22 : !llvm.array<1 x ptr>) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb18: // pred: ^bb8 + %31 = llvm.landingpad cleanup (filter %2 : !llvm.array<0 x ptr>) : !llvm.struct<(ptr, i32)> + llvm.unreachable + } + llvm.func @foo_cxx() attributes {personality = @__gxx_personality_v0} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.addressof @T1 : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.array<1 x ptr> + %3 = llvm.insertvalue %0, %2[0] : !llvm.array<1 x ptr> + %4 = llvm.mlir.undef : !llvm.array<2 x ptr> + %5 = llvm.insertvalue %1, %4[0] : !llvm.array<2 x ptr> + %6 = llvm.insertvalue %0, %5[1] : !llvm.array<2 x ptr> + llvm.invoke @bar() to ^bb1 unwind ^bb5 : () -> () + ^bb1: // pred: ^bb0 + llvm.invoke @bar() to ^bb2 unwind ^bb6 : () -> () + ^bb2: // pred: ^bb1 + llvm.invoke @bar() to ^bb3 unwind ^bb7 : () -> () + ^bb3: // pred: ^bb2 + llvm.invoke @bar() to ^bb4 unwind ^bb8 : () -> () + ^bb4: // pred: ^bb3 + llvm.return + ^bb5: // pred: ^bb0 + %7 = llvm.landingpad (catch %0 : !llvm.ptr) (catch %1 : !llvm.ptr) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb6: // pred: ^bb1 + %8 = llvm.landingpad (filter %3 : !llvm.array<1 x ptr>) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb7: // pred: ^bb2 + %9 = llvm.landingpad (filter %6 : !llvm.array<2 x ptr>) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb8: // pred: ^bb3 + %10 = llvm.landingpad cleanup (catch %0 : !llvm.ptr) : !llvm.struct<(ptr, i32)> + llvm.unreachable + } + llvm.func @foo_objc() attributes {personality = @__objc_personality_v0} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.addressof @T1 : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.array<1 x ptr> + %3 = llvm.insertvalue %0, %2[0] : !llvm.array<1 x ptr> + %4 = llvm.mlir.undef : !llvm.array<2 x ptr> + %5 = llvm.insertvalue %1, %4[0] : !llvm.array<2 x ptr> + %6 = llvm.insertvalue %0, %5[1] : !llvm.array<2 x ptr> + llvm.invoke @bar() to ^bb1 unwind ^bb5 : () -> () + ^bb1: // pred: ^bb0 + llvm.invoke @bar() to ^bb2 unwind ^bb6 : () -> () + ^bb2: // pred: ^bb1 + llvm.invoke @bar() to ^bb3 unwind ^bb7 : () -> () + ^bb3: // pred: ^bb2 + llvm.invoke @bar() to ^bb4 unwind ^bb8 : () -> () + ^bb4: // pred: ^bb3 + llvm.return + ^bb5: // pred: ^bb0 + %7 = llvm.landingpad (catch %0 : !llvm.ptr) (catch %1 : !llvm.ptr) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb6: // pred: ^bb1 + %8 = llvm.landingpad (filter %3 : !llvm.array<1 x ptr>) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb7: // pred: ^bb2 + %9 = llvm.landingpad (filter %6 : !llvm.array<2 x ptr>) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb8: // pred: ^bb3 + %10 = llvm.landingpad cleanup (catch %0 : !llvm.ptr) : !llvm.struct<(ptr, i32)> + llvm.unreachable + } + llvm.func @foo_seh() attributes {personality = @__C_specific_handler} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.addressof @T1 : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.array<1 x ptr> + %3 = llvm.insertvalue %0, %2[0] : !llvm.array<1 x ptr> + %4 = llvm.mlir.undef : !llvm.array<2 x ptr> + %5 = llvm.insertvalue %1, %4[0] : !llvm.array<2 x ptr> + %6 = llvm.insertvalue %0, %5[1] : !llvm.array<2 x ptr> + llvm.invoke @bar() to ^bb1 unwind ^bb5 : () -> () + ^bb1: // pred: ^bb0 + llvm.invoke @bar() to ^bb2 unwind ^bb6 : () -> () + ^bb2: // pred: ^bb1 + llvm.invoke @bar() to ^bb3 unwind ^bb7 : () -> () + ^bb3: // pred: ^bb2 + llvm.invoke @bar() to ^bb4 unwind ^bb8 : () -> () + ^bb4: // pred: ^bb3 + llvm.return + ^bb5: // pred: ^bb0 + %7 = llvm.landingpad (catch %0 : !llvm.ptr) (catch %1 : !llvm.ptr) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb6: // pred: ^bb1 + %8 = llvm.landingpad (filter %3 : !llvm.array<1 x ptr>) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb7: // pred: ^bb2 + %9 = llvm.landingpad (filter %6 : !llvm.array<2 x ptr>) : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb8: // pred: ^bb3 + %10 = llvm.landingpad cleanup (catch %0 : !llvm.ptr) : !llvm.struct<(ptr, i32)> + llvm.unreachable + } +} diff --git a/test/LLVMDialect/InstCombine/OverlappingInsertvalues.ll.mlir b/test/LLVMDialect/InstCombine/OverlappingInsertvalues.ll.mlir new file mode 100644 index 000000000..a0edd1453 --- /dev/null +++ b/test/LLVMDialect/InstCombine/OverlappingInsertvalues.ll.mlir @@ -0,0 +1,26 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @foo_simple(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> !llvm.struct<(ptr, i64, i32)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.undef : !llvm.struct<(ptr, i64, i32)> + %1 = llvm.insertvalue %arg0, %0[0] : !llvm.struct<(ptr, i64, i32)> + %2 = llvm.insertvalue %arg1, %1[0] : !llvm.struct<(ptr, i64, i32)> + llvm.return %2 : !llvm.struct<(ptr, i64, i32)> + } + llvm.func @foo_ovwrt_chain(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.struct<(ptr, i64, i32)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.undef : !llvm.struct<(ptr, i64, i32)> + %1 = llvm.mlir.constant(555 : i32) : i32 + %2 = llvm.mlir.constant(777 : i32) : i32 + %3 = llvm.insertvalue %arg0, %0[0] : !llvm.struct<(ptr, i64, i32)> + %4 = llvm.insertvalue %arg1, %3[1] : !llvm.struct<(ptr, i64, i32)> + %5 = llvm.insertvalue %1, %4[2] : !llvm.struct<(ptr, i64, i32)> + %6 = llvm.insertvalue %arg2, %5[1] : !llvm.struct<(ptr, i64, i32)> + %7 = llvm.insertvalue %2, %6[2] : !llvm.struct<(ptr, i64, i32)> + llvm.return %7 : !llvm.struct<(ptr, i64, i32)> + } + llvm.func @foo_use_as_second_operand(%arg0: i16) -> !llvm.struct<(i8, struct<(i16, i32)>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.undef : !llvm.struct<(i16, i32)> + %1 = llvm.mlir.undef : !llvm.struct<(i8, struct<(i16, i32)>)> + %2 = llvm.insertvalue %arg0, %0[0] : !llvm.struct<(i16, i32)> + %3 = llvm.insertvalue %2, %1[1] : !llvm.struct<(i8, struct<(i16, i32)>)> + llvm.return %3 : !llvm.struct<(i8, struct<(i16, i32)>)> + } +} diff --git a/test/LLVMDialect/InstCombine/PR30597.ll.mlir b/test/LLVMDialect/InstCombine/PR30597.ll.mlir new file mode 100644 index 000000000..939e6fc08 --- /dev/null +++ b/test/LLVMDialect/InstCombine/PR30597.ll.mlir @@ -0,0 +1,15 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @dot_ref_s(%arg0: !llvm.ptr {llvm.dereferenceable = 8 : i64, llvm.noalias, llvm.nocapture, llvm.readonly}) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %3 = llvm.inttoptr %2 : i64 to !llvm.ptr + %4 = llvm.icmp "eq" %3, %0 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @function(%arg0: !llvm.ptr {llvm.dereferenceable = 8 : i64, llvm.noalias, llvm.nocapture, llvm.readonly}) -> !llvm.ptr { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + %1 = llvm.inttoptr %0 : i64 to !llvm.ptr + llvm.return %1 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/PR37526.ll.mlir b/test/LLVMDialect/InstCombine/PR37526.ll.mlir new file mode 100644 index 000000000..a55ead803 --- /dev/null +++ b/test/LLVMDialect/InstCombine/PR37526.ll.mlir @@ -0,0 +1,11 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @PR37526(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.load %arg2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.load %arg1 {alignment = 4 : i64} : !llvm.ptr -> i32 + %2 = llvm.icmp "slt" %0, %1 : i32 + %3 = llvm.select %2, %arg1, %arg2 : i1, !llvm.ptr + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i64 + llvm.store %4, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/StoreToNull-DbgCheck.ll.mlir b/test/LLVMDialect/InstCombine/StoreToNull-DbgCheck.ll.mlir new file mode 100644 index 000000000..081f5b5b4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/StoreToNull-DbgCheck.ll.mlir @@ -0,0 +1,7 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @_Z3foov() { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.call %0() : !llvm.ptr, () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/abs-1.ll.mlir b/test/LLVMDialect/InstCombine/abs-1.ll.mlir new file mode 100644 index 000000000..a2807821e --- /dev/null +++ b/test/LLVMDialect/InstCombine/abs-1.ll.mlir @@ -0,0 +1,547 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g() {addr_space = 0 : i32} : i64 + llvm.func @abs(i32) -> i32 + llvm.func @labs(i64) -> i64 + llvm.func @llabs(i64) -> i64 + llvm.func @test_abs(%arg0: i32) -> i32 { + %0 = llvm.call @abs(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } + llvm.func @test_labs(%arg0: i64) -> i64 { + %0 = llvm.call @labs(%arg0) : (i64) -> i64 + llvm.return %0 : i64 + } + llvm.func @test_llabs(%arg0: i64) -> i64 { + %0 = llvm.call @llabs(%arg0) : (i64) -> i64 + llvm.return %0 : i64 + } + llvm.func @abs_canonical_1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "sgt" %arg0, %0 : i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.select %1, %arg0, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @abs_canonical_2(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.icmp "sgt" %arg0, %0 : vector<2xi8> + %4 = llvm.sub %2, %arg0 : vector<2xi8> + %5 = llvm.select %3, %arg0, %4 : vector<2xi1>, vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @abs_canonical_2_vec_poison_elts(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(0 : i8) : i8 + %8 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %9 = llvm.icmp "sgt" %arg0, %6 : vector<2xi8> + %10 = llvm.sub %8, %arg0 : vector<2xi8> + %11 = llvm.select %9, %arg0, %10 : vector<2xi1>, vector<2xi8> + llvm.return %11 : vector<2xi8> + } + llvm.func @abs_canonical_3(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + %2 = llvm.sub %0, %arg0 overflow : i8 + %3 = llvm.select %1, %2, %arg0 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @abs_canonical_4(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + %3 = llvm.sub %1, %arg0 : i8 + %4 = llvm.select %2, %3, %arg0 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @abs_canonical_5(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i8 + %3 = llvm.sext %arg0 : i8 to i32 + %4 = llvm.sub %1, %3 : i32 + %5 = llvm.select %2, %3, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @abs_canonical_6(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sub %arg0, %arg1 : i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + %3 = llvm.sub %arg1, %arg0 : i32 + %4 = llvm.select %2, %1, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @abs_canonical_7(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sub %arg0, %arg1 : vector<2xi8> + %2 = llvm.icmp "sgt" %1, %0 : vector<2xi8> + %3 = llvm.sub %arg1, %arg0 : vector<2xi8> + %4 = llvm.select %2, %1, %3 : vector<2xi1>, vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @abs_canonical_8(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + %3 = llvm.select %2, %arg0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @abs_canonical_9(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sub %arg0, %arg1 : i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + %3 = llvm.sub %arg1, %arg0 : i32 + %4 = llvm.select %2, %1, %3 : i1, i32 + %5 = llvm.add %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @abs_canonical_10(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 : i32 + %2 = llvm.sub %arg0, %arg1 : i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @nabs_canonical_1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "sgt" %arg0, %0 : i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.select %1, %2, %arg0 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @nabs_canonical_2(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.icmp "sgt" %arg0, %0 : vector<2xi8> + %4 = llvm.sub %2, %arg0 : vector<2xi8> + %5 = llvm.select %3, %4, %arg0 : vector<2xi1>, vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @nabs_canonical_2_vec_poison_elts(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(0 : i8) : i8 + %8 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %9 = llvm.icmp "sgt" %arg0, %6 : vector<2xi8> + %10 = llvm.sub %8, %arg0 : vector<2xi8> + %11 = llvm.select %9, %10, %arg0 : vector<2xi1>, vector<2xi8> + llvm.return %11 : vector<2xi8> + } + llvm.func @nabs_canonical_3(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + %2 = llvm.sub %0, %arg0 overflow : i8 + %3 = llvm.select %1, %arg0, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @nabs_canonical_4(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + %3 = llvm.sub %1, %arg0 : i8 + %4 = llvm.select %2, %arg0, %3 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @nabs_canonical_5(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i8 + %3 = llvm.sext %arg0 : i8 to i32 + %4 = llvm.sub %1, %3 : i32 + %5 = llvm.select %2, %4, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @nabs_canonical_6(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sub %arg0, %arg1 : i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + %3 = llvm.sub %arg1, %arg0 : i32 + %4 = llvm.select %2, %3, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @nabs_canonical_7(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sub %arg0, %arg1 : vector<2xi8> + %2 = llvm.icmp "sgt" %1, %0 : vector<2xi8> + %3 = llvm.sub %arg1, %arg0 : vector<2xi8> + %4 = llvm.select %2, %3, %1 : vector<2xi1>, vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @nabs_canonical_8(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + %3 = llvm.select %2, %1, %arg0 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @nabs_canonical_9(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sub %arg0, %arg1 : i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + %3 = llvm.sub %arg1, %arg0 : i32 + %4 = llvm.select %2, %3, %1 : i1, i32 + %5 = llvm.add %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @nabs_canonical_10(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 : i32 + %2 = llvm.sub %arg0, %arg1 : i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @shifty_abs_commute0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.add %1, %arg0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @shifty_abs_commute0_nsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.add %1, %arg0 overflow : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @shifty_abs_commute0_nuw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.add %1, %arg0 overflow : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @shifty_abs_commute1(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %1 = llvm.ashr %arg0, %0 : vector<2xi8> + %2 = llvm.add %1, %arg0 : vector<2xi8> + %3 = llvm.xor %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @shifty_abs_commute2(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mul %arg0, %0 : vector<2xi8> + %3 = llvm.ashr %2, %1 : vector<2xi8> + %4 = llvm.add %2, %3 : vector<2xi8> + %5 = llvm.xor %3, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @shifty_abs_commute3(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mul %arg0, %0 : i8 + %3 = llvm.ashr %2, %1 : i8 + %4 = llvm.add %2, %3 : i8 + %5 = llvm.xor %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @extra_use(i8) + llvm.func @extra_use_i1(i1) + llvm.func @shifty_abs_too_many_uses(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.add %arg0, %1 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.call @extra_use(%1) : (i8) -> () + llvm.return %3 : i8 + } + llvm.func @shifty_sub(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.xor %arg0, %1 : i8 + %3 = llvm.sub %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @shifty_sub_nsw_commute(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.xor %1, %arg0 : i8 + %3 = llvm.sub %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @shifty_sub_nuw_vec_commute(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %1 = llvm.ashr %arg0, %0 : vector<4xi32> + %2 = llvm.xor %1, %arg0 : vector<4xi32> + %3 = llvm.sub %2, %1 overflow : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @shifty_sub_nsw_nuw(%arg0: i12) -> i12 { + %0 = llvm.mlir.constant(11 : i12) : i12 + %1 = llvm.ashr %arg0, %0 : i12 + %2 = llvm.xor %arg0, %1 : i12 + %3 = llvm.sub %2, %1 overflow : i12 + llvm.return %3 : i12 + } + llvm.func @negate_abs(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + %3 = llvm.select %2, %1, %arg0 : i1, i8 + %4 = llvm.sub %0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_nabs(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.sub %1, %arg0 : vector<2xi8> + %3 = llvm.icmp "slt" %arg0, %1 : vector<2xi8> + %4 = llvm.select %3, %arg0, %2 : vector<2xi1>, vector<2xi8> + %5 = llvm.sub %1, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @abs_must_be_positive(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 overflow : i32 + %2 = llvm.icmp "sge" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %1 : i1, i32 + %4 = llvm.icmp "sge" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @abs_swapped(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + llvm.call @extra_use(%1) : (i8) -> () + %2 = llvm.icmp "sgt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @nabs_swapped(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + llvm.call @extra_use(%1) : (i8) -> () + %2 = llvm.icmp "sgt" %arg0, %0 : i8 + %3 = llvm.select %2, %1, %arg0 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @abs_different_constants(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + llvm.call @extra_use(%2) : (i8) -> () + %3 = llvm.icmp "sgt" %arg0, %1 : i8 + %4 = llvm.select %3, %arg0, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @nabs_different_constants(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + llvm.call @extra_use(%2) : (i8) -> () + %3 = llvm.icmp "sgt" %arg0, %1 : i8 + %4 = llvm.select %3, %2, %arg0 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @infinite_loop_constant_expression_abs(%arg0: i64) -> i64 { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.sub %1, %arg0 : i64 + %4 = llvm.icmp "slt" %3, %2 : i64 + %5 = llvm.sub %2, %3 overflow : i64 + %6 = llvm.select %4, %5, %3 : i1, i64 + llvm.return %6 : i64 + } + llvm.func @abs_extra_use_icmp(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + llvm.call @extra_use_i1(%1) : (i1) -> () + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.select %1, %2, %arg0 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @abs_extra_use_sub(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + %2 = llvm.sub %0, %arg0 : i8 + llvm.call @extra_use(%2) : (i8) -> () + %3 = llvm.select %1, %2, %arg0 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @abs_extra_use_icmp_sub(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + llvm.call @extra_use_i1(%1) : (i1) -> () + %2 = llvm.sub %0, %arg0 : i8 + llvm.call @extra_use(%2) : (i8) -> () + %3 = llvm.select %1, %2, %arg0 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @nabs_extra_use_icmp(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + llvm.call @extra_use_i1(%1) : (i1) -> () + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.select %1, %arg0, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @nabs_extra_use_sub(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + %2 = llvm.sub %0, %arg0 : i8 + llvm.call @extra_use(%2) : (i8) -> () + %3 = llvm.select %1, %arg0, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @nabs_extra_use_icmp_sub(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + llvm.call @extra_use_i1(%1) : (i1) -> () + %2 = llvm.sub %0, %arg0 : i8 + llvm.call @extra_use(%2) : (i8) -> () + %3 = llvm.select %1, %arg0, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @nabs_diff_signed_slt(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = llvm.select %0, %2, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @nabs_diff_signed_sle(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.icmp "sle" %arg0, %arg1 : vector<2xi8> + %1 = llvm.sub %arg1, %arg0 overflow : vector<2xi8> + %2 = llvm.sub %arg0, %arg1 overflow : vector<2xi8> + %3 = llvm.select %0, %2, %1 : vector<2xi1>, vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @abs_diff_signed_sgt(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + %2 = llvm.sub %arg0, %arg1 overflow : i8 + llvm.call @extra_use(%2) : (i8) -> () + %3 = llvm.select %0, %2, %1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @abs_diff_signed_sge(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.icmp "sge" %arg0, %arg1 : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + llvm.call @extra_use(%1) : (i8) -> () + %2 = llvm.sub %arg0, %arg1 overflow : i8 + llvm.call @extra_use(%2) : (i8) -> () + %3 = llvm.select %0, %2, %1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @abs_diff_signed_slt_no_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.sub %arg1, %arg0 : i32 + %2 = llvm.sub %arg0, %arg1 : i32 + %3 = llvm.select %0, %2, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @abs_diff_signed_sgt_nsw_nuw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + %2 = llvm.sub %arg0, %arg1 overflow : i8 + %3 = llvm.select %0, %2, %1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @abs_diff_signed_sgt_nuw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + %2 = llvm.sub %arg0, %arg1 overflow : i8 + %3 = llvm.select %0, %2, %1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @abs_diff_signed_sgt_nuw_extra_use1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + llvm.call @extra_use(%1) : (i8) -> () + %2 = llvm.sub %arg0, %arg1 overflow : i8 + %3 = llvm.select %0, %2, %1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @abs_diff_signed_sgt_nuw_extra_use2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + %2 = llvm.sub %arg0, %arg1 overflow : i8 + llvm.call @extra_use(%2) : (i8) -> () + %3 = llvm.select %0, %2, %1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @abs_diff_signed_sgt_nuw_extra_use3(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + llvm.call @extra_use(%1) : (i8) -> () + %2 = llvm.sub %arg0, %arg1 overflow : i8 + llvm.call @extra_use(%2) : (i8) -> () + %3 = llvm.select %0, %2, %1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @abs_diff_signed_slt_swap_wrong_pred1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "eq" %arg0, %arg1 : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = llvm.select %0, %1, %2 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @abs_diff_signed_slt_swap_wrong_pred2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = llvm.select %0, %1, %2 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @abs_diff_signed_slt_swap_wrong_op(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.icmp "eq" %arg0, %arg1 : i32 + %1 = llvm.sub %arg1, %arg2 overflow : i32 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = llvm.select %0, %1, %2 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @abs_diff_signed_slt_swap(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = llvm.select %0, %1, %2 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @abs_diff_signed_sle_swap(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.icmp "sle" %arg0, %arg1 : vector<2xi8> + %1 = llvm.sub %arg1, %arg0 overflow : vector<2xi8> + %2 = llvm.sub %arg0, %arg1 overflow : vector<2xi8> + %3 = llvm.select %0, %1, %2 : vector<2xi1>, vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @nabs_diff_signed_sgt_swap(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + llvm.call @extra_use(%1) : (i8) -> () + %2 = llvm.sub %arg0, %arg1 overflow : i8 + %3 = llvm.select %0, %1, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @nabs_diff_signed_sge_swap(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.icmp "sge" %arg0, %arg1 : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + llvm.call @extra_use(%1) : (i8) -> () + %2 = llvm.sub %arg0, %arg1 overflow : i8 + llvm.call @extra_use(%2) : (i8) -> () + %3 = llvm.select %0, %1, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @abs_diff_signed_slt_no_nsw_swap(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.sub %arg0, %arg1 : i32 + %3 = llvm.select %0, %1, %2 : i1, i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/abs-intrinsic.ll.mlir b/test/LLVMDialect/InstCombine/abs-intrinsic.ll.mlir new file mode 100644 index 000000000..466e0ad37 --- /dev/null +++ b/test/LLVMDialect/InstCombine/abs-intrinsic.ll.mlir @@ -0,0 +1,424 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @test_abs_abs_a_mul_b_i8(%arg0: i8, %arg1: i8) -> i8 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i8) -> i8 + %1 = llvm.mul %0, %arg1 : i8 + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = true}> : (i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @test_abs_a_mul_abs_b_i8(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.urem %0, %arg0 : i8 + %2 = "llvm.intr.abs"(%arg1) <{is_int_min_poison = true}> : (i8) -> i8 + %3 = llvm.mul %1, %2 : i8 + %4 = "llvm.intr.abs"(%3) <{is_int_min_poison = true}> : (i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @test_abs_abs_a_mul_b_i32(%arg0: i32, %arg1: i32) -> i32 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i32) -> i32 + %1 = llvm.mul %0, %arg1 : i32 + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @test_abs_abs_a_mul_b_i32_abs_false_true(%arg0: i32, %arg1: i32) -> i32 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i32) -> i32 + %1 = llvm.mul %0, %arg1 : i32 + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @test_abs_abs_a_mul_b_i32_abs_true_false(%arg0: i32, %arg1: i32) -> i32 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i32) -> i32 + %1 = llvm.mul %0, %arg1 : i32 + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = false}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @test_abs_abs_a_mul_b_i32_abs_false_false(%arg0: i32, %arg1: i32) -> i32 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i32) -> i32 + %1 = llvm.mul %0, %arg1 : i32 + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = false}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @test_nsw_with_true(%arg0: i8, %arg1: i8) -> i8 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i8) -> i8 + %1 = llvm.mul %0, %arg1 overflow : i8 + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = true}> : (i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @test_nsw_with_false(%arg0: i8, %arg1: i8) -> i8 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i8) -> i8 + %1 = llvm.mul %0, %arg1 overflow : i8 + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = false}> : (i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @test_abs_abs_a_mul_b_more_one_use(%arg0: i32, %arg1: i32) -> i32 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i32) -> i32 + %1 = llvm.mul %0, %arg1 : i32 + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = false}> : (i32) -> i32 + llvm.call @use(%1) : (i32) -> () + llvm.return %2 : i32 + } + llvm.func @test_abs_abs_a_mul_b_vector_i8(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (vector<2xi8>) -> vector<2xi8> + %1 = llvm.mul %0, %arg1 : vector<2xi8> + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = true}> : (vector<2xi8>) -> vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @abs_trailing_zeros(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-4 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = false}> : (i32) -> i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @abs_trailing_zeros_vec(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[-4, -8, -16, -32]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.and %arg0, %0 : vector<4xi32> + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = false}> : (vector<4xi32>) -> vector<4xi32> + %4 = llvm.and %3, %1 : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @abs_trailing_zeros_negative(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(-4 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = false}> : (i32) -> i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @abs_trailing_zeros_negative_vec(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-2> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-4> : vector<4xi32>) : vector<4xi32> + %2 = llvm.and %arg0, %0 : vector<4xi32> + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = false}> : (vector<4xi32>) -> vector<4xi32> + %4 = llvm.and %3, %1 : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @abs_signbits(%arg0: i30) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sext %arg0 : i30 to i32 + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = false}> : (i32) -> i32 + %3 = llvm.add %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @abs_signbits_vec(%arg0: vector<4xi30>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sext %arg0 : vector<4xi30> to vector<4xi32> + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = false}> : (vector<4xi32>) -> vector<4xi32> + %3 = llvm.add %2, %0 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @abs_of_neg(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = false}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @abs_of_neg_vec(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %1, %arg0 overflow : vector<4xi32> + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = false}> : (vector<4xi32>) -> vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @abs_of_select_neg_true_val(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.select %arg0, %1, %arg1 : i1, i32 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @abs_of_select_neg_false_val(%arg0: vector<4xi1>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %1, %arg1 : vector<4xi32> + %3 = llvm.select %arg0, %arg1, %2 : vector<4xi1>, vector<4xi32> + %4 = "llvm.intr.abs"(%3) <{is_int_min_poison = false}> : (vector<4xi32>) -> vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @abs_dom_cond_nopoison(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sge" %arg0, %0 : i32 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i32) -> i32 + llvm.return %2 : i32 + ^bb2: // pred: ^bb0 + %3 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @abs_dom_cond_poison(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sge" %arg0, %0 : i32 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.return %2 : i32 + ^bb2: // pred: ^bb0 + %3 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @zext_abs(%arg0: i31) -> i32 { + %0 = llvm.zext %arg0 : i31 to i32 + %1 = "llvm.intr.abs"(%0) <{is_int_min_poison = false}> : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @lshr_abs(%arg0: vector<3xi82>) -> vector<3xi82> { + %0 = llvm.mlir.constant(1 : i82) : i82 + %1 = llvm.mlir.constant(dense<1> : vector<3xi82>) : vector<3xi82> + %2 = llvm.lshr %arg0, %1 : vector<3xi82> + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = true}> : (vector<3xi82>) -> vector<3xi82> + llvm.return %3 : vector<3xi82> + } + llvm.func @and_abs(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147483644 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @select_abs(%arg0: vector<3xi1>) -> vector<3xi82> { + %0 = llvm.mlir.constant(0 : i82) : i82 + %1 = llvm.mlir.constant(dense<0> : vector<3xi82>) : vector<3xi82> + %2 = llvm.mlir.constant(1 : i82) : i82 + %3 = llvm.mlir.constant(42 : i82) : i82 + %4 = llvm.mlir.constant(2147483647 : i82) : i82 + %5 = llvm.mlir.constant(dense<[2147483647, 42, 1]> : vector<3xi82>) : vector<3xi82> + %6 = llvm.select %arg0, %1, %5 : vector<3xi1>, vector<3xi82> + %7 = "llvm.intr.abs"(%6) <{is_int_min_poison = false}> : (vector<3xi82>) -> vector<3xi82> + llvm.return %7 : vector<3xi82> + } + llvm.func @assume_abs(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sge" %arg0, %0 : i32 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @abs_assume_neg(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @abs_known_neg(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.sub %0, %1 overflow : i32 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = false}> : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @abs_eq_int_min_poison(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i8) -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @abs_ne_int_min_poison(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i8) -> i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @abs_eq_int_min_nopoison(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i8) -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @abs_ne_int_min_nopoison(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i8) -> i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @abs_sext(%arg0: i8) -> i32 { + %0 = llvm.sext %arg0 : i8 to i32 + %1 = "llvm.intr.abs"(%0) <{is_int_min_poison = false}> : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @abs_nsw_sext(%arg0: vector<3xi7>) -> vector<3xi82> { + %0 = llvm.sext %arg0 : vector<3xi7> to vector<3xi82> + %1 = "llvm.intr.abs"(%0) <{is_int_min_poison = true}> : (vector<3xi82>) -> vector<3xi82> + llvm.return %1 : vector<3xi82> + } + llvm.func @abs_sext_extra_use(%arg0: i8, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.sext %arg0 : i8 to i32 + llvm.store %0, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %1 = "llvm.intr.abs"(%0) <{is_int_min_poison = false}> : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @trunc_abs_sext(%arg0: i8) -> i8 { + %0 = llvm.sext %arg0 : i8 to i32 + %1 = "llvm.intr.abs"(%0) <{is_int_min_poison = true}> : (i32) -> i32 + %2 = llvm.trunc %1 : i32 to i8 + llvm.return %2 : i8 + } + llvm.func @trunc_abs_sext_vec(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.sext %arg0 : vector<4xi8> to vector<4xi32> + %1 = "llvm.intr.abs"(%0) <{is_int_min_poison = true}> : (vector<4xi32>) -> vector<4xi32> + %2 = llvm.trunc %1 : vector<4xi32> to vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @demand_low_bit(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i32) -> i32 + %2 = llvm.and %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @demand_low_bit_int_min_is_poison(%arg0: vector<3xi82>) -> vector<3xi82> { + %0 = llvm.mlir.constant(81 : i82) : i82 + %1 = llvm.mlir.constant(dense<81> : vector<3xi82>) : vector<3xi82> + %2 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (vector<3xi82>) -> vector<3xi82> + %3 = llvm.shl %2, %1 : vector<3xi82> + llvm.return %3 : vector<3xi82> + } + llvm.func @demand_low_bits(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i32) -> i32 + %2 = llvm.and %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @srem_by_2_int_min_is_poison(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.srem %arg0, %0 : i32 + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @srem_by_2(%arg0: vector<3xi82>, %arg1: !llvm.ptr) -> vector<3xi82> { + %0 = llvm.mlir.constant(2 : i82) : i82 + %1 = llvm.mlir.constant(dense<2> : vector<3xi82>) : vector<3xi82> + %2 = llvm.srem %arg0, %1 : vector<3xi82> + llvm.store %2, %arg1 {alignment = 32 : i64} : vector<3xi82>, !llvm.ptr + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = false}> : (vector<3xi82>) -> vector<3xi82> + llvm.return %3 : vector<3xi82> + } + llvm.func @srem_by_3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.srem %arg0, %0 : i32 + %2 = "llvm.intr.abs"(%1) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @sub_abs_gt(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.br ^bb2(%3 : i32) + ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @sub_abs_sgeT(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sge" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.br ^bb2(%3 : i32) + ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @sub_abs_sgeT_swap(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sge" %arg1, %arg0 : i32 + llvm.cond_br %1, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.br ^bb2(%3 : i32) + ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @sub_abs_sgeT_false(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sge" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb2(%0 : i32), ^bb1 + ^bb1: // pred: ^bb0 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.br ^bb2(%3 : i32) + ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @sub_abs_lt(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.br ^bb2(%3 : i32) + ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @sub_abs_sle(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sle" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.br ^bb2(%3 : i32) + ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @sub_abs_sleF(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "sle" %arg0, %arg1 : i8 + llvm.cond_br %1, ^bb1, ^bb2(%0 : i8) + ^bb1: // pred: ^bb0 + %2 = llvm.sub %arg0, %arg1 overflow : i8 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = false}> : (i8) -> i8 + llvm.br ^bb2(%3 : i8) + ^bb2(%4: i8): // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i8 + } + llvm.func @sub_abs_sleT(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "sle" %arg0, %arg1 : i8 + llvm.cond_br %1, ^bb1, ^bb2(%0 : i8) + ^bb1: // pred: ^bb0 + %2 = llvm.sub %arg0, %arg1 overflow : i8 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = true}> : (i8) -> i8 + llvm.br ^bb2(%3 : i8) + ^bb2(%4: i8): // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i8 + } + llvm.func @sub_abs_lt_min_not_poison(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = false}> : (i32) -> i32 + llvm.br ^bb2(%3 : i32) + ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @sub_abs_wrong_pred(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.br ^bb2(%3 : i32) + ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @sub_abs_no_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %2 = llvm.sub %arg0, %arg1 : i32 + %3 = "llvm.intr.abs"(%2) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.br ^bb2(%3 : i32) + ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/abs_abs.ll.mlir b/test/LLVMDialect/InstCombine/abs_abs.ll.mlir new file mode 100644 index 000000000..fa28ea71a --- /dev/null +++ b/test/LLVMDialect/InstCombine/abs_abs.ll.mlir @@ -0,0 +1,915 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @abs_abs_x01(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "sgt" %4, %0 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_abs_x01_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %4 = llvm.sub %2, %arg0 overflow : vector<2xi32> + %5 = llvm.select %3, %arg0, %4 : vector<2xi1>, vector<2xi32> + %6 = llvm.icmp "sgt" %5, %0 : vector<2xi32> + %7 = llvm.sub %2, %5 overflow : vector<2xi32> + %8 = llvm.select %6, %5, %7 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @abs_abs_x02(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_abs_x03(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_abs_x04(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.sub %1, %arg0 overflow : i32 + %5 = llvm.select %3, %4, %arg0 : i1, i32 + %6 = llvm.icmp "sgt" %5, %2 : i32 + %7 = llvm.sub %1, %5 overflow : i32 + %8 = llvm.select %6, %5, %7 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @abs_abs_x04_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %4 = llvm.icmp "slt" %arg0, %0 : vector<2xi32> + %5 = llvm.sub %2, %arg0 overflow : vector<2xi32> + %6 = llvm.select %4, %5, %arg0 : vector<2xi1>, vector<2xi32> + %7 = llvm.icmp "sgt" %6, %3 : vector<2xi32> + %8 = llvm.sub %2, %6 overflow : vector<2xi32> + %9 = llvm.select %7, %6, %8 : vector<2xi1>, vector<2xi32> + llvm.return %9 : vector<2xi32> + } + llvm.func @abs_abs_x05(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_abs_x06(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %arg0, %2 : i1, i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %3, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @abs_abs_x07(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %2, %arg0 : i1, i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %3, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @abs_abs_x08(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_abs_x09(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_abs_x10(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %arg0, %2 : i1, i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %5, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @abs_abs_x11(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %2, %arg0 : i1, i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %5, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @abs_abs_x12(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_abs_x13(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.sub %1, %arg0 overflow : i32 + %5 = llvm.select %3, %arg0, %4 : i1, i32 + %6 = llvm.icmp "slt" %5, %2 : i32 + %7 = llvm.sub %1, %5 overflow : i32 + %8 = llvm.select %6, %7, %5 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @abs_abs_x14(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_abs_x15(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_abs_x16(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "slt" %4, %0 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_abs_x17(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + %4 = llvm.select %3, %2, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_abs_x18(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = llvm.sub %arg1, %arg0 overflow : i32 + %4 = llvm.icmp "sgt" %2, %0 : i32 + %5 = llvm.select %4, %2, %3 : i1, i32 + %6 = llvm.icmp "sgt" %5, %0 : i32 + %7 = llvm.sub %1, %5 overflow : i32 + %8 = llvm.select %6, %5, %7 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @abs_abs_x02_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.sub %1, %arg0 overflow : vector<2xi32> + %4 = llvm.icmp "sgt" %3, %2 : vector<2xi32> + %5 = llvm.select %4, %3, %arg0 : vector<2xi1>, vector<2xi32> + %6 = llvm.icmp "sgt" %5, %2 : vector<2xi32> + %7 = llvm.sub %1, %5 overflow : vector<2xi32> + %8 = llvm.select %6, %5, %7 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @abs_abs_x03_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.sub %arg0, %arg1 overflow : vector<2xi32> + %4 = llvm.sub %arg1, %arg0 overflow : vector<2xi32> + %5 = llvm.icmp "sgt" %3, %0 : vector<2xi32> + %6 = llvm.select %5, %3, %4 : vector<2xi1>, vector<2xi32> + %7 = llvm.icmp "sgt" %6, %0 : vector<2xi32> + %8 = llvm.sub %2, %6 overflow : vector<2xi32> + %9 = llvm.select %7, %6, %8 : vector<2xi1>, vector<2xi32> + llvm.return %9 : vector<2xi32> + } + llvm.func @nabs_nabs_x01(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %0 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_nabs_x02(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_nabs_x03(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_nabs_x04(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.sub %1, %arg0 overflow : i32 + %5 = llvm.select %3, %arg0, %4 : i1, i32 + %6 = llvm.icmp "sgt" %5, %2 : i32 + %7 = llvm.sub %1, %5 overflow : i32 + %8 = llvm.select %6, %7, %5 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @nabs_nabs_x05(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_nabs_x06(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %2, %arg0 : i1, i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %5, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @nabs_nabs_x07(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %arg0, %2 : i1, i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %5, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @nabs_nabs_x08(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_nabs_x09(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_nabs_x10(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %2, %arg0 : i1, i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %3, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @nabs_nabs_x11(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %arg0, %2 : i1, i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %3, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @nabs_nabs_x12(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_nabs_x13(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.sub %1, %arg0 overflow : i32 + %5 = llvm.select %3, %4, %arg0 : i1, i32 + %6 = llvm.icmp "slt" %5, %2 : i32 + %7 = llvm.sub %1, %5 overflow : i32 + %8 = llvm.select %6, %5, %7 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @nabs_nabs_x14(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_nabs_x15(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_nabs_x16(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "slt" %4, %0 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_nabs_x17(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + %4 = llvm.select %3, %arg0, %2 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_nabs_x18(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = llvm.sub %arg1, %arg0 overflow : i32 + %4 = llvm.icmp "sgt" %2, %0 : i32 + %5 = llvm.select %4, %3, %2 : i1, i32 + %6 = llvm.icmp "sgt" %5, %0 : i32 + %7 = llvm.sub %1, %5 overflow : i32 + %8 = llvm.select %6, %7, %5 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @nabs_nabs_x01_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.sub %1, %arg0 overflow : vector<2xi32> + %4 = llvm.icmp "sgt" %3, %2 : vector<2xi32> + %5 = llvm.select %4, %arg0, %3 : vector<2xi1>, vector<2xi32> + %6 = llvm.icmp "sgt" %5, %2 : vector<2xi32> + %7 = llvm.sub %1, %5 overflow : vector<2xi32> + %8 = llvm.select %6, %7, %5 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @nabs_nabs_x02_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.sub %arg0, %arg1 overflow : vector<2xi32> + %4 = llvm.sub %arg1, %arg0 overflow : vector<2xi32> + %5 = llvm.icmp "sgt" %3, %0 : vector<2xi32> + %6 = llvm.select %5, %4, %3 : vector<2xi1>, vector<2xi32> + %7 = llvm.icmp "sgt" %6, %0 : vector<2xi32> + %8 = llvm.sub %2, %6 overflow : vector<2xi32> + %9 = llvm.select %7, %8, %6 : vector<2xi1>, vector<2xi32> + llvm.return %9 : vector<2xi32> + } + llvm.func @abs_nabs_x01(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %0 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_nabs_x02(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_nabs_x03(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_nabs_x04(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.sub %1, %arg0 overflow : i32 + %5 = llvm.select %3, %arg0, %4 : i1, i32 + %6 = llvm.icmp "sgt" %5, %2 : i32 + %7 = llvm.sub %1, %5 overflow : i32 + %8 = llvm.select %6, %5, %7 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @abs_nabs_x05(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_nabs_x06(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %2, %arg0 : i1, i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %3, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @abs_nabs_x07(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %arg0, %2 : i1, i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %3, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @abs_nabs_x08(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_nabs_x09(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_nabs_x10(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %2, %arg0 : i1, i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %5, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @abs_nabs_x11(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %arg0, %2 : i1, i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %5, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @abs_nabs_x12(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_nabs_x13(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.sub %1, %arg0 overflow : i32 + %5 = llvm.select %3, %4, %arg0 : i1, i32 + %6 = llvm.icmp "slt" %5, %2 : i32 + %7 = llvm.sub %1, %5 overflow : i32 + %8 = llvm.select %6, %7, %5 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @abs_nabs_x14(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_nabs_x15(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_nabs_x16(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "slt" %4, %0 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_nabs_x17(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + %4 = llvm.select %3, %arg0, %2 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_nabs_x18(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = llvm.sub %arg1, %arg0 overflow : i32 + %4 = llvm.icmp "sgt" %2, %0 : i32 + %5 = llvm.select %4, %3, %2 : i1, i32 + %6 = llvm.icmp "sgt" %5, %0 : i32 + %7 = llvm.sub %1, %5 overflow : i32 + %8 = llvm.select %6, %5, %7 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @abs_nabs_x01_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.sub %1, %arg0 overflow : vector<2xi32> + %4 = llvm.icmp "sgt" %3, %2 : vector<2xi32> + %5 = llvm.select %4, %arg0, %3 : vector<2xi1>, vector<2xi32> + %6 = llvm.icmp "sgt" %5, %2 : vector<2xi32> + %7 = llvm.sub %1, %5 overflow : vector<2xi32> + %8 = llvm.select %6, %5, %7 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @abs_nabs_x02_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.sub %arg0, %arg1 overflow : vector<2xi32> + %4 = llvm.sub %arg1, %arg0 overflow : vector<2xi32> + %5 = llvm.icmp "sgt" %3, %0 : vector<2xi32> + %6 = llvm.select %5, %4, %3 : vector<2xi1>, vector<2xi32> + %7 = llvm.icmp "sgt" %6, %0 : vector<2xi32> + %8 = llvm.sub %2, %6 overflow : vector<2xi32> + %9 = llvm.select %7, %6, %8 : vector<2xi1>, vector<2xi32> + llvm.return %9 : vector<2xi32> + } + llvm.func @nabs_abs_x01(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "sgt" %4, %0 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_abs_x02(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_abs_x03(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_abs_x04(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.sub %1, %arg0 overflow : i32 + %5 = llvm.select %3, %4, %arg0 : i1, i32 + %6 = llvm.icmp "sgt" %5, %2 : i32 + %7 = llvm.sub %1, %5 overflow : i32 + %8 = llvm.select %6, %7, %5 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @nabs_abs_x05(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_abs_x06(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %arg0, %2 : i1, i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %5, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @nabs_abs_x07(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %2, %arg0 : i1, i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %5, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @nabs_abs_x08(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_abs_x09(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_abs_x10(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %arg0, %2 : i1, i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %3, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @nabs_abs_x11(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.select %1, %2, %arg0 : i1, i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %3, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @nabs_abs_x12(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_abs_x13(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.sub %1, %arg0 overflow : i32 + %5 = llvm.select %3, %arg0, %4 : i1, i32 + %6 = llvm.icmp "slt" %5, %2 : i32 + %7 = llvm.sub %1, %5 overflow : i32 + %8 = llvm.select %6, %5, %7 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @nabs_abs_x14(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_abs_x15(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_abs_x16(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "slt" %4, %0 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_abs_x17(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + %4 = llvm.select %3, %2, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.sub %0, %4 overflow : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @nabs_abs_x18(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = llvm.sub %arg1, %arg0 overflow : i32 + %4 = llvm.icmp "sgt" %2, %0 : i32 + %5 = llvm.select %4, %2, %3 : i1, i32 + %6 = llvm.icmp "sgt" %5, %0 : i32 + %7 = llvm.sub %1, %5 overflow : i32 + %8 = llvm.select %6, %7, %5 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @nabs_abs_x01_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.sub %1, %arg0 overflow : vector<2xi32> + %4 = llvm.icmp "sgt" %3, %2 : vector<2xi32> + %5 = llvm.select %4, %3, %arg0 : vector<2xi1>, vector<2xi32> + %6 = llvm.icmp "sgt" %5, %2 : vector<2xi32> + %7 = llvm.sub %1, %5 overflow : vector<2xi32> + %8 = llvm.select %6, %7, %5 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @nabs_abs_x02_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.sub %arg0, %arg1 overflow : vector<2xi32> + %4 = llvm.sub %arg1, %arg0 overflow : vector<2xi32> + %5 = llvm.icmp "sgt" %3, %0 : vector<2xi32> + %6 = llvm.select %5, %3, %4 : vector<2xi1>, vector<2xi32> + %7 = llvm.icmp "sgt" %6, %0 : vector<2xi32> + %8 = llvm.sub %2, %6 overflow : vector<2xi32> + %9 = llvm.select %7, %8, %6 : vector<2xi1>, vector<2xi32> + llvm.return %9 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/add-mask-neg.ll.mlir b/test/LLVMDialect/InstCombine/add-mask-neg.ll.mlir new file mode 100644 index 000000000..94415c8ec --- /dev/null +++ b/test/LLVMDialect/InstCombine/add-mask-neg.ll.mlir @@ -0,0 +1,83 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @dec_mask_neg_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @dec_mask_commute_neg_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sdiv %0, %arg0 : i32 + %4 = llvm.sub %1, %3 : i32 + %5 = llvm.and %3, %4 : i32 + %6 = llvm.add %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @dec_commute_mask_neg_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.add %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @dec_mask_neg_multiuse_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.add %3, %1 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @dec_mask_multiuse_neg_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.add %3, %1 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @dec_mask_neg_v2i32(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.sub %1, %arg0 : vector<2xi32> + %4 = llvm.and %3, %arg0 : vector<2xi32> + %5 = llvm.add %4, %2 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @dec_mask_neg_v2i32_poison(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.constant(-1 : i32) : i32 + %4 = llvm.mlir.undef : vector<2xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi32> + %9 = llvm.sub %1, %arg0 : vector<2xi32> + %10 = llvm.and %9, %arg0 : vector<2xi32> + %11 = llvm.add %10, %8 : vector<2xi32> + llvm.return %11 : vector<2xi32> + } + llvm.func @dec_mask_multiuse_neg_multiuse_v2i32(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.sub %1, %arg0 : vector<2xi32> + %4 = llvm.and %3, %arg0 : vector<2xi32> + %5 = llvm.add %4, %2 : vector<2xi32> + llvm.call @usev(%3) : (vector<2xi32>) -> () + llvm.call @usev(%4) : (vector<2xi32>) -> () + llvm.return %5 : vector<2xi32> + } + llvm.func @use(i32) + llvm.func @usev(vector<2xi32>) +} diff --git a/test/LLVMDialect/InstCombine/add-mask.ll.mlir b/test/LLVMDialect/InstCombine/add-mask.ll.mlir index 829dfc54c..b3397938f 100644 --- a/test/LLVMDialect/InstCombine/add-mask.ll.mlir +++ b/test/LLVMDialect/InstCombine/add-mask.ll.mlir @@ -1,66 +1,58 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.add"(%3, %2) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "add_mask_sign_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.add"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "add_mask_sign_commute_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<8> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.mlir.constant"() {value = dense<31> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.and"(%2, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.add"(%3, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%4) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "add_mask_sign_v2i32", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[8, 16]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.mlir.constant"() {value = dense<[30, 31]> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.and"(%2, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.add"(%3, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%4) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "add_mask_sign_v2i32_nonuniform", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 28 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.add"(%3, %2) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "add_mask_ashr28_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 28 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.add"(%3, %2) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "add_mask_ashr28_non_pow2_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 27 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.add"(%3, %2) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "add_mask_ashr27_i32", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @add_mask_sign_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.add %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @add_mask_sign_commute_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @add_mask_sign_v2i32(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.and %2, %1 : vector<2xi32> + %4 = llvm.add %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @add_mask_sign_v2i32_nonuniform(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[30, 31]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[8, 16]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.and %2, %1 : vector<2xi32> + %4 = llvm.add %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @add_mask_ashr28_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(28 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.add %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @add_mask_ashr28_non_pow2_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(28 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.add %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @add_mask_ashr27_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(27 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.add %3, %2 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/add-min-max.ll.mlir b/test/LLVMDialect/InstCombine/add-min-max.ll.mlir new file mode 100644 index 000000000..9991f4cfe --- /dev/null +++ b/test/LLVMDialect/InstCombine/add-min-max.ll.mlir @@ -0,0 +1,38 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @uadd_min_max(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.umax(%arg0, %arg1) : (i32, i32) -> i32 + %1 = llvm.intr.umin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.add %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @uadd_min_max_comm(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.umax(%arg1, %arg0) : (i32, i32) -> i32 + %1 = llvm.intr.umin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.add %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @uadd_min_max_nuw_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.umax(%arg0, %arg1) : (i32, i32) -> i32 + %1 = llvm.intr.umin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.add %1, %0 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @sadd_min_max(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.smax(%arg0, %arg1) : (i32, i32) -> i32 + %1 = llvm.intr.smin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.add %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @sadd_min_max_comm(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.smax(%arg1, %arg0) : (i32, i32) -> i32 + %1 = llvm.intr.smin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.add %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @sadd_min_max_nuw_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.smax(%arg0, %arg1) : (i32, i32) -> i32 + %1 = llvm.intr.smin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.add %1, %0 overflow : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/add-shift.ll.mlir b/test/LLVMDialect/InstCombine/add-shift.ll.mlir new file mode 100644 index 000000000..d77d30d8b --- /dev/null +++ b/test/LLVMDialect/InstCombine/add-shift.ll.mlir @@ -0,0 +1,46 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @flip_add_of_shift_neg(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.shl %1, %arg1 overflow : i8 + %3 = llvm.add %2, %arg2 : i8 + llvm.return %3 : i8 + } + llvm.func @flip_add_of_shift_neg_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mul %arg2, %arg2 : vector<2xi8> + %3 = llvm.sub %1, %arg0 : vector<2xi8> + %4 = llvm.shl %3, %arg1 : vector<2xi8> + %5 = llvm.add %2, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @flip_add_of_shift_neg_fail_shr(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.lshr %1, %arg1 : i8 + %3 = llvm.add %2, %arg2 : i8 + llvm.return %3 : i8 + } + llvm.func @use.v2i8(vector<2xi8>) + llvm.func @flip_add_of_shift_neg_vec_fail_multiuse_neg(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mul %arg2, %arg2 : vector<2xi8> + %3 = llvm.sub %1, %arg0 : vector<2xi8> + %4 = llvm.shl %3, %arg1 : vector<2xi8> + llvm.call @use.v2i8(%3) : (vector<2xi8>) -> () + %5 = llvm.add %2, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @flip_add_of_shift_neg_vec_fail_multiuse_shift(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mul %arg2, %arg2 : vector<2xi8> + %3 = llvm.sub %1, %arg0 : vector<2xi8> + %4 = llvm.shl %3, %arg1 : vector<2xi8> + llvm.call @use.v2i8(%4) : (vector<2xi8>) -> () + %5 = llvm.add %2, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/add-shl-sdiv-to-srem.ll.mlir b/test/LLVMDialect/InstCombine/add-shl-sdiv-to-srem.ll.mlir new file mode 100644 index 000000000..74e889d8b --- /dev/null +++ b/test/LLVMDialect/InstCombine/add-shl-sdiv-to-srem.ll.mlir @@ -0,0 +1,186 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @"add-shl-sdiv-scalar0"(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-4 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.sdiv %arg0, %0 : i8 + %3 = llvm.shl %2, %1 : i8 + %4 = llvm.add %3, %arg0 : i8 + llvm.return %4 : i8 + } + llvm.func @"add-shl-sdiv-scalar1"(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.sdiv %arg0, %0 : i8 + %3 = llvm.shl %2, %1 : i8 + %4 = llvm.add %3, %arg0 : i8 + llvm.return %4 : i8 + } + llvm.func @"add-shl-sdiv-scalar2"(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1073741824 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.sdiv %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + %4 = llvm.add %3, %arg0 : i32 + llvm.return %4 : i32 + } + llvm.func @"add-shl-sdiv-splat0"(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<-4> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(dense<2> : vector<3xi8>) : vector<3xi8> + %2 = llvm.sdiv %arg0, %0 : vector<3xi8> + %3 = llvm.shl %2, %1 : vector<3xi8> + %4 = llvm.add %3, %arg0 : vector<3xi8> + llvm.return %4 : vector<3xi8> + } + llvm.func @"add-shl-sdiv-splat1"(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1073741824> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<30> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.shl %2, %1 : vector<4xi32> + %4 = llvm.add %3, %arg0 : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @"add-shl-sdiv-splat2"(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-32> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<5> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sdiv %arg0, %0 : vector<2xi64> + %3 = llvm.shl %2, %1 : vector<2xi64> + %4 = llvm.add %3, %arg0 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @use32(i32) + llvm.func @"add-shl-sdiv-i32-4-use0"(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-16 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + llvm.call @use32(%arg0) : (i32) -> () + %2 = llvm.sdiv %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + %4 = llvm.add %3, %arg0 : i32 + llvm.return %4 : i32 + } + llvm.func @"add-shl-sdiv-i32-use1"(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-16 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.sdiv %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %2, %1 : i32 + %4 = llvm.add %3, %arg0 : i32 + llvm.return %4 : i32 + } + llvm.func @"add-shl-sdiv-i32-use2"(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-16 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.sdiv %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.add %3, %arg0 : i32 + llvm.return %4 : i32 + } + llvm.func @"add-shl-sdiv-i32-use3"(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-16 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.sdiv %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %2, %1 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.add %3, %arg0 : i32 + llvm.return %4 : i32 + } + llvm.func @use3xi8(vector<3xi8>) + llvm.func @"add-shl-sdiv-use4"(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<-4> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(dense<2> : vector<3xi8>) : vector<3xi8> + %2 = llvm.sdiv %arg0, %0 : vector<3xi8> + llvm.call @use3xi8(%2) : (vector<3xi8>) -> () + %3 = llvm.shl %2, %1 : vector<3xi8> + %4 = llvm.add %3, %arg0 : vector<3xi8> + llvm.return %4 : vector<3xi8> + } + llvm.func @"add-shl-sdiv-negative0"(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.sdiv %arg0, %0 : i8 + %3 = llvm.shl %2, %1 : i8 + %4 = llvm.add %3, %arg0 : i8 + llvm.return %4 : i8 + } + llvm.func @"add-shl-sdiv-negative1"(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.sdiv %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + %4 = llvm.add %3, %arg0 : i32 + llvm.return %4 : i32 + } + llvm.func @"add-shl-sdiv-negative2"(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sdiv %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + %4 = llvm.add %3, %arg0 : i32 + llvm.return %4 : i32 + } + llvm.func @"add-shl-sdiv-negative3"(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<-5> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(dense<2> : vector<3xi8>) : vector<3xi8> + %2 = llvm.sdiv %arg0, %0 : vector<3xi8> + %3 = llvm.shl %2, %1 : vector<3xi8> + %4 = llvm.add %3, %arg0 : vector<3xi8> + llvm.return %4 : vector<3xi8> + } + llvm.func @"add-shl-sdiv-negative4"(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<-5> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sdiv %arg0, %0 : vector<2xi64> + %3 = llvm.shl %2, %1 : vector<2xi64> + %4 = llvm.add %3, %arg0 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @"add-shl-sdiv-3xi8-undef0"(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(-4 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<2> : vector<3xi8>) : vector<3xi8> + %10 = llvm.sdiv %arg0, %8 : vector<3xi8> + %11 = llvm.shl %10, %9 : vector<3xi8> + %12 = llvm.add %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi8> + } + llvm.func @"add-shl-sdiv-3xi8-undef1"(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<-4> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.sdiv %arg0, %0 : vector<3xi8> + %11 = llvm.shl %10, %9 : vector<3xi8> + %12 = llvm.add %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi8> + } + llvm.func @"add-shl-sdiv-nonsplat0"(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[-32, -64]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<[5, 6]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sdiv %arg0, %0 : vector<2xi64> + %3 = llvm.shl %2, %1 : vector<2xi64> + %4 = llvm.add %3, %arg0 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @"add-shl-sdiv-nonsplat1"(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<-4> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(dense<[2, 2, 3]> : vector<3xi8>) : vector<3xi8> + %2 = llvm.sdiv %arg0, %0 : vector<3xi8> + %3 = llvm.shl %2, %1 : vector<3xi8> + %4 = llvm.add %3, %arg0 : vector<3xi8> + llvm.return %4 : vector<3xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/add-sitofp.ll.mlir b/test/LLVMDialect/InstCombine/add-sitofp.ll.mlir index b749156c8..2ecaff2ee 100644 --- a/test/LLVMDialect/InstCombine/add-sitofp.ll.mlir +++ b/test/LLVMDialect/InstCombine/add-sitofp.ll.mlir @@ -1,81 +1,72 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.mlir.constant"() {value = 24 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.sitofp"(%3) : (i32) -> f64 - %5 = "llvm.fadd"(%4, %0) : (f64, f64) -> f64 - "llvm.return"(%5) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "x", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.mlir.constant"() {value = 1073741823 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.sitofp"(%2) : (i32) -> f64 - %4 = "llvm.fadd"(%3, %0) : (f64, f64) -> f64 - "llvm.return"(%4) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f32} : () -> f32 - %1 = "llvm.mlir.constant"() {value = 1073741823 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.sitofp"(%2) : (i32) -> f32 - %4 = "llvm.fadd"(%3, %0) : (f32, f32) -> f32 - "llvm.return"(%4) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_neg", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1073741823 : i32} : () -> i32 - %1 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.and"(%arg1, %0) : (i32, i32) -> i32 - %3 = "llvm.sitofp"(%1) : (i32) -> f64 - %4 = "llvm.sitofp"(%2) : (i32) -> f64 - %5 = "llvm.fadd"(%3, %4) : (f64, f64) -> f64 - "llvm.return"(%5) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1073741823 : i32} : () -> i32 - %1 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.and"(%arg1, %0) : (i32, i32) -> i32 - %3 = "llvm.sitofp"(%1) : (i32) -> f32 - %4 = "llvm.sitofp"(%2) : (i32) -> f32 - %5 = "llvm.fadd"(%3, %4) : (f32, f32) -> f32 - "llvm.return"(%5) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_2_neg", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f32} : () -> f32 - %1 = "llvm.mlir.constant"() {value = 24 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.sitofp"(%3) : (i32) -> f32 - %5 = "llvm.fadd"(%4, %0) : (f32, f32) -> f32 - "llvm.return"(%5) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi32>, %arg1: vector<4xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1073741823> : vector<4xi32>} : () -> vector<4xi32> - %1 = "llvm.and"(%arg0, %0) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - %2 = "llvm.and"(%arg1, %0) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - %3 = "llvm.sitofp"(%1) : (vector<4xi32>) -> vector<4xf64> - %4 = "llvm.sitofp"(%2) : (vector<4xi32>) -> vector<4xf64> - %5 = "llvm.fadd"(%3, %4) : (vector<4xf64>, vector<4xf64>) -> vector<4xf64> - "llvm.return"(%5) : (vector<4xf64>) -> () - }) {linkage = 10 : i64, sym_name = "test_4", type = !llvm.func (vector<4xi32>, vector<4xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi32>, %arg1: vector<4xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1073741823> : vector<4xi32>} : () -> vector<4xi32> - %1 = "llvm.and"(%arg0, %0) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - %2 = "llvm.and"(%arg1, %0) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - %3 = "llvm.sitofp"(%1) : (vector<4xi32>) -> vector<4xf32> - %4 = "llvm.sitofp"(%2) : (vector<4xi32>) -> vector<4xf32> - %5 = "llvm.fadd"(%3, %4) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%5) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_4_neg", type = !llvm.func (vector<4xi32>, vector<4xi32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @x(%arg0: i32, %arg1: i32) -> f64 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.sitofp %3 : i32 to f64 + %5 = llvm.fadd %4, %1 : f64 + llvm.return %5 : f64 + } + llvm.func @test(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.sitofp %2 : i32 to f64 + %4 = llvm.fadd %3, %1 : f64 + llvm.return %4 : f64 + } + llvm.func @test_neg(%arg0: i32) -> f32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.sitofp %2 : i32 to f32 + %4 = llvm.fadd %3, %1 : f32 + llvm.return %4 : f32 + } + llvm.func @test_2(%arg0: i32, %arg1: i32) -> f64 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.sitofp %1 : i32 to f64 + %4 = llvm.sitofp %2 : i32 to f64 + %5 = llvm.fadd %3, %4 : f64 + llvm.return %5 : f64 + } + llvm.func @test_2_neg(%arg0: i32, %arg1: i32) -> f32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.sitofp %1 : i32 to f32 + %4 = llvm.sitofp %2 : i32 to f32 + %5 = llvm.fadd %3, %4 : f32 + llvm.return %5 : f32 + } + llvm.func @test_3(%arg0: i32, %arg1: i32) -> f32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.sitofp %3 : i32 to f32 + %5 = llvm.fadd %4, %1 : f32 + llvm.return %5 : f32 + } + llvm.func @test_4(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<1073741823> : vector<4xi32>) : vector<4xi32> + %1 = llvm.and %arg0, %0 : vector<4xi32> + %2 = llvm.and %arg1, %0 : vector<4xi32> + %3 = llvm.sitofp %1 : vector<4xi32> to vector<4xf64> + %4 = llvm.sitofp %2 : vector<4xi32> to vector<4xf64> + %5 = llvm.fadd %3, %4 : vector<4xf64> + llvm.return %5 : vector<4xf64> + } + llvm.func @test_4_neg(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<1073741823> : vector<4xi32>) : vector<4xi32> + %1 = llvm.and %arg0, %0 : vector<4xi32> + %2 = llvm.and %arg1, %0 : vector<4xi32> + %3 = llvm.sitofp %1 : vector<4xi32> to vector<4xf32> + %4 = llvm.sitofp %2 : vector<4xi32> to vector<4xf32> + %5 = llvm.fadd %3, %4 : vector<4xf32> + llvm.return %5 : vector<4xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/add.ll.mlir b/test/LLVMDialect/InstCombine/add.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/add2.ll.mlir b/test/LLVMDialect/InstCombine/add2.ll.mlir new file mode 100644 index 000000000..1448cda62 --- /dev/null +++ b/test/LLVMDialect/InstCombine/add2.ll.mlir @@ -0,0 +1,300 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i64, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(123 : i64) : i64 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.shl %2, %0 : i64 + %4 = llvm.add %3, %arg0 : i64 + %5 = llvm.and %4, %1 : i64 + llvm.return %5 : i64 + } + llvm.func @test2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.lshr %arg0, %1 : i32 + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test4(%arg0: i32) -> i32 { + %0 = llvm.add %arg0, %arg0 overflow : i32 + llvm.return %0 : i32 + } + llvm.func @test5(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.add %arg0, %arg1 : vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test6(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[2, 3]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.shl %arg0, %0 : vector<2xi64> + %2 = llvm.add %1, %arg0 : vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @test7(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[2, 3]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<[3, 4]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.shl %arg0, %0 : vector<2xi64> + %3 = llvm.mul %arg0, %1 : vector<2xi64> + %4 = llvm.add %2, %3 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test9(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(2 : i16) : i16 + %1 = llvm.mlir.constant(32767 : i16) : i16 + %2 = llvm.mul %arg0, %0 : i16 + %3 = llvm.mul %arg0, %1 : i16 + %4 = llvm.add %2, %3 : i16 + llvm.return %4 : i16 + } + llvm.func @test10(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(-1431655766 : i32) : i32 + %2 = llvm.mlir.constant(1431655765 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.ashr %arg0, %0 : i32 + %5 = llvm.or %4, %1 : i32 + %6 = llvm.xor %5, %2 : i32 + %7 = llvm.add %arg1, %3 : i32 + %8 = llvm.add %7, %6 : i32 + llvm.return %8 : i32 + } + llvm.func @test11(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1431655766 : i32) : i32 + %1 = llvm.mlir.constant(1431655765 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.or %arg0, %0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.add %arg1, %2 : i32 + %6 = llvm.add %5, %4 : i32 + llvm.return %6 : i32 + } + llvm.func @test12(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1431655766 : i32) : i32 + %2 = llvm.mlir.constant(1431655765 : i32) : i32 + %3 = llvm.add %arg1, %0 overflow : i32 + %4 = llvm.or %arg0, %1 : i32 + %5 = llvm.xor %4, %2 : i32 + %6 = llvm.add %3, %5 overflow : i32 + llvm.return %6 : i32 + } + llvm.func @test13(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1431655767 : i32) : i32 + %1 = llvm.mlir.constant(1431655766 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.or %arg0, %0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.add %arg1, %2 : i32 + %6 = llvm.add %5, %4 : i32 + llvm.return %6 : i32 + } + llvm.func @test14(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1431655767 : i32) : i32 + %2 = llvm.mlir.constant(1431655766 : i32) : i32 + %3 = llvm.add %arg1, %0 overflow : i32 + %4 = llvm.or %arg0, %1 : i32 + %5 = llvm.xor %4, %2 : i32 + %6 = llvm.add %3, %5 overflow : i32 + llvm.return %6 : i32 + } + llvm.func @test15(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1431655767 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.add %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @test16(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1431655767 : i32) : i32 + %2 = llvm.add %arg1, %0 overflow : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.add %2, %4 overflow : i32 + llvm.return %5 : i32 + } + llvm.func @test17(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1431655766 : i32) : i32 + %1 = llvm.mlir.constant(-1431655765 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.xor %2, %1 : i32 + %4 = llvm.add %3, %arg1 overflow : i32 + llvm.return %4 : i32 + } + llvm.func @test18(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1431655766 : i32) : i32 + %2 = llvm.add %arg1, %0 overflow : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.add %2, %4 overflow : i32 + llvm.return %5 : i32 + } + llvm.func @add_nsw_mul_nsw(%arg0: i16) -> i16 { + %0 = llvm.add %arg0, %arg0 overflow : i16 + %1 = llvm.add %0, %arg0 overflow : i16 + llvm.return %1 : i16 + } + llvm.func @mul_add_to_mul_1(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mul %arg0, %0 overflow : i16 + %2 = llvm.add %arg0, %1 overflow : i16 + llvm.return %2 : i16 + } + llvm.func @mul_add_to_mul_2(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mul %arg0, %0 overflow : i16 + %2 = llvm.add %1, %arg0 overflow : i16 + llvm.return %2 : i16 + } + llvm.func @mul_add_to_mul_3(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(2 : i16) : i16 + %1 = llvm.mlir.constant(3 : i16) : i16 + %2 = llvm.mul %arg0, %0 : i16 + %3 = llvm.mul %arg0, %1 : i16 + %4 = llvm.add %2, %3 overflow : i16 + llvm.return %4 : i16 + } + llvm.func @mul_add_to_mul_4(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(2 : i16) : i16 + %1 = llvm.mlir.constant(7 : i16) : i16 + %2 = llvm.mul %arg0, %0 overflow : i16 + %3 = llvm.mul %arg0, %1 overflow : i16 + %4 = llvm.add %2, %3 overflow : i16 + llvm.return %4 : i16 + } + llvm.func @mul_add_to_mul_5(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(3 : i16) : i16 + %1 = llvm.mlir.constant(7 : i16) : i16 + %2 = llvm.mul %arg0, %0 overflow : i16 + %3 = llvm.mul %arg0, %1 overflow : i16 + %4 = llvm.add %2, %3 overflow : i16 + llvm.return %4 : i16 + } + llvm.func @mul_add_to_mul_6(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mul %arg0, %arg1 overflow : i32 + %2 = llvm.mul %1, %0 overflow : i32 + %3 = llvm.add %1, %2 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @mul_add_to_mul_7(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(32767 : i16) : i16 + %1 = llvm.mul %arg0, %0 overflow : i16 + %2 = llvm.add %arg0, %1 overflow : i16 + llvm.return %2 : i16 + } + llvm.func @mul_add_to_mul_8(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(16383 : i16) : i16 + %1 = llvm.mlir.constant(16384 : i16) : i16 + %2 = llvm.mul %arg0, %0 overflow : i16 + %3 = llvm.mul %arg0, %1 overflow : i16 + %4 = llvm.add %2, %3 overflow : i16 + llvm.return %4 : i16 + } + llvm.func @mul_add_to_mul_9(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(16384 : i16) : i16 + %1 = llvm.mul %arg0, %0 overflow : i16 + %2 = llvm.mul %arg0, %0 overflow : i16 + %3 = llvm.add %1, %2 overflow : i16 + llvm.return %3 : i16 + } + llvm.func @add_cttz(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(-8 : i16) : i16 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = true}> : (i16) -> i16 + %2 = llvm.add %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @add_cttz_2(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(-16 : i16) : i16 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = true}> : (i16) -> i16 + %2 = llvm.add %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @add_or_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.add %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @add_or_and_commutative(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.add %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @add_and_or(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.add %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @add_and_or_commutative(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.add %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @add_nsw_or_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.add %0, %1 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @add_nuw_or_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.add %0, %1 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @add_nuw_nsw_or_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.add %0, %1 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @add_of_mul(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mul %arg0, %arg1 overflow : i8 + %1 = llvm.mul %arg0, %arg2 overflow : i8 + %2 = llvm.add %0, %1 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @add_of_selects(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.select %arg0, %arg1, %2 : i1, i32 + %5 = llvm.add %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @add_undemanded_low_bits(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(1616 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.or %arg0, %0 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.lshr %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @sub_undemanded_low_bits(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(1616 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.or %arg0, %0 : i32 + %4 = llvm.sub %3, %1 : i32 + %5 = llvm.lshr %4, %2 : i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/add3.ll.mlir b/test/LLVMDialect/InstCombine/add3.ll.mlir index 09008f6c5..7e9422869 100644 --- a/test/LLVMDialect/InstCombine/add3.ll.mlir +++ b/test/LLVMDialect/InstCombine/add3.ll.mlir @@ -1,20 +1,17 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = -12 : i32} : () -> i32 - %3 = "llvm.add"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.inttoptr"(%3) : (i32) -> !llvm.ptr - "llvm.store"(%1, %4) : (i32, !llvm.ptr) -> () - %5 = "llvm.add"(%arg0, %0) : (i32, i32) -> i32 - %6 = "llvm.inttoptr"(%5) : (i32) -> !llvm.ptr - %7 = "llvm.getelementptr"(%6, %1) : (!llvm.ptr, i32) -> !llvm.ptr - %8 = "llvm.load"(%7) : (!llvm.ptr) -> i32 - %9 = "llvm.call"(%8) {callee = @callee, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "callee", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test2(%arg0: i32) { + %0 = llvm.mlir.constant(-12 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-16 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = llvm.inttoptr %3 : i32 to !llvm.ptr + llvm.store %1, %4 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.add %arg0, %2 : i32 + %6 = llvm.inttoptr %5 : i32 to !llvm.ptr + %7 = llvm.getelementptr %6[%1] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %8 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + %9 = llvm.call @callee(%8) : (i32) -> i32 + llvm.return + } + llvm.func @callee(i32) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/add4.ll.mlir b/test/LLVMDialect/InstCombine/add4.ll.mlir index 02add9dee..c41fe2a62 100644 --- a/test/LLVMDialect/InstCombine/add4.ll.mlir +++ b/test/LLVMDialect/InstCombine/add4.ll.mlir @@ -1,105 +1,192 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 64 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 299 : i64} : () -> i64 - %2 = "llvm.urem"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.udiv"(%arg0, %1) : (i64, i64) -> i64 - %4 = "llvm.urem"(%3, %0) : (i64, i64) -> i64 - %5 = "llvm.mul"(%4, %1) : (i64, i64) -> i64 - %6 = "llvm.add"(%2, %5) : (i64, i64) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "match_unsigned", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<64> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<299> : vector<2xi64>} : () -> vector<2xi64> - %2 = "llvm.urem"(%arg0, %1) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %3 = "llvm.udiv"(%arg0, %1) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %4 = "llvm.urem"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %5 = "llvm.mul"(%4, %1) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %6 = "llvm.add"(%2, %5) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%6) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "match_unsigned_vector", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 63 : i64} : () -> i64 - %3 = "llvm.and"(%arg0, %2) : (i64, i64) -> i64 - %4 = "llvm.lshr"(%arg0, %1) : (i64, i64) -> i64 - %5 = "llvm.urem"(%4, %0) : (i64, i64) -> i64 - %6 = "llvm.shl"(%5, %1) : (i64, i64) -> i64 - %7 = "llvm.add"(%3, %6) : (i64, i64) -> i64 - "llvm.return"(%7) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "match_andAsRem_lshrAsDiv_shlAsMul", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 19136 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 64 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 299 : i64} : () -> i64 - %4 = "llvm.srem"(%arg0, %3) : (i64, i64) -> i64 - %5 = "llvm.sdiv"(%arg0, %3) : (i64, i64) -> i64 - %6 = "llvm.srem"(%5, %2) : (i64, i64) -> i64 - %7 = "llvm.sdiv"(%arg0, %1) : (i64, i64) -> i64 - %8 = "llvm.srem"(%7, %0) : (i64, i64) -> i64 - %9 = "llvm.mul"(%6, %3) : (i64, i64) -> i64 - %10 = "llvm.add"(%4, %9) : (i64, i64) -> i64 - %11 = "llvm.mul"(%8, %1) : (i64, i64) -> i64 - %12 = "llvm.add"(%10, %11) : (i64, i64) -> i64 - "llvm.return"(%12) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "match_signed", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<9> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<19136> : vector<2xi64>} : () -> vector<2xi64> - %2 = "llvm.mlir.constant"() {value = dense<64> : vector<2xi64>} : () -> vector<2xi64> - %3 = "llvm.mlir.constant"() {value = dense<299> : vector<2xi64>} : () -> vector<2xi64> - %4 = "llvm.srem"(%arg0, %3) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %5 = "llvm.sdiv"(%arg0, %3) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %6 = "llvm.srem"(%5, %2) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %7 = "llvm.sdiv"(%arg0, %1) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %8 = "llvm.srem"(%7, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %9 = "llvm.mul"(%6, %3) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %10 = "llvm.add"(%4, %9) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %11 = "llvm.mul"(%8, %1) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %12 = "llvm.add"(%10, %11) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%12) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "match_signed_vector", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 64 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 299 : i64} : () -> i64 - %2 = "llvm.urem"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.sdiv"(%arg0, %1) : (i64, i64) -> i64 - %4 = "llvm.urem"(%3, %0) : (i64, i64) -> i64 - %5 = "llvm.mul"(%4, %1) : (i64, i64) -> i64 - %6 = "llvm.add"(%2, %5) : (i64, i64) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "not_match_inconsistent_signs", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 64 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 29 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 299 : i64} : () -> i64 - %3 = "llvm.urem"(%arg0, %2) : (i64, i64) -> i64 - %4 = "llvm.udiv"(%arg0, %1) : (i64, i64) -> i64 - %5 = "llvm.urem"(%4, %0) : (i64, i64) -> i64 - %6 = "llvm.mul"(%5, %2) : (i64, i64) -> i64 - %7 = "llvm.add"(%3, %6) : (i64, i64) -> i64 - "llvm.return"(%7) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "not_match_inconsistent_values", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 147483647 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 299 : i32} : () -> i32 - %2 = "llvm.urem"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.udiv"(%arg0, %1) : (i32, i32) -> i32 - %4 = "llvm.urem"(%3, %0) : (i32, i32) -> i32 - %5 = "llvm.mul"(%4, %1) : (i32, i32) -> i32 - %6 = "llvm.add"(%2, %5) : (i32, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "not_match_overflow", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @match_unsigned(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(299 : i64) : i64 + %1 = llvm.mlir.constant(64 : i64) : i64 + %2 = llvm.urem %arg0, %0 : i64 + %3 = llvm.udiv %arg0, %0 : i64 + %4 = llvm.urem %3, %1 : i64 + %5 = llvm.mul %4, %0 : i64 + %6 = llvm.add %2, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @match_unsigned_vector(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<299> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<64> : vector<2xi64>) : vector<2xi64> + %2 = llvm.urem %arg0, %0 : vector<2xi64> + %3 = llvm.udiv %arg0, %0 : vector<2xi64> + %4 = llvm.urem %3, %1 : vector<2xi64> + %5 = llvm.mul %4, %0 : vector<2xi64> + %6 = llvm.add %2, %5 : vector<2xi64> + llvm.return %6 : vector<2xi64> + } + llvm.func @match_andAsRem_lshrAsDiv_shlAsMul(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(6 : i64) : i64 + %2 = llvm.mlir.constant(9 : i64) : i64 + %3 = llvm.and %arg0, %0 : i64 + %4 = llvm.lshr %arg0, %1 : i64 + %5 = llvm.urem %4, %2 : i64 + %6 = llvm.shl %5, %1 : i64 + %7 = llvm.add %3, %6 : i64 + llvm.return %7 : i64 + } + llvm.func @match_signed(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(299 : i64) : i64 + %1 = llvm.mlir.constant(64 : i64) : i64 + %2 = llvm.mlir.constant(19136 : i64) : i64 + %3 = llvm.mlir.constant(9 : i64) : i64 + %4 = llvm.srem %arg0, %0 : i64 + %5 = llvm.sdiv %arg0, %0 : i64 + %6 = llvm.srem %5, %1 : i64 + %7 = llvm.sdiv %arg0, %2 : i64 + %8 = llvm.srem %7, %3 : i64 + %9 = llvm.mul %6, %0 : i64 + %10 = llvm.add %4, %9 : i64 + %11 = llvm.mul %8, %2 : i64 + %12 = llvm.add %10, %11 : i64 + llvm.return %12 : i64 + } + llvm.func @match_signed_vector(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<299> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<64> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.constant(dense<19136> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mlir.constant(dense<9> : vector<2xi64>) : vector<2xi64> + %4 = llvm.srem %arg0, %0 : vector<2xi64> + %5 = llvm.sdiv %arg0, %0 : vector<2xi64> + %6 = llvm.srem %5, %1 : vector<2xi64> + %7 = llvm.sdiv %arg0, %2 : vector<2xi64> + %8 = llvm.srem %7, %3 : vector<2xi64> + %9 = llvm.mul %6, %0 : vector<2xi64> + %10 = llvm.add %4, %9 : vector<2xi64> + %11 = llvm.mul %8, %2 : vector<2xi64> + %12 = llvm.add %10, %11 : vector<2xi64> + llvm.return %12 : vector<2xi64> + } + llvm.func @not_match_inconsistent_signs(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(299 : i64) : i64 + %1 = llvm.mlir.constant(64 : i64) : i64 + %2 = llvm.urem %arg0, %0 : i64 + %3 = llvm.sdiv %arg0, %0 : i64 + %4 = llvm.urem %3, %1 : i64 + %5 = llvm.mul %4, %0 : i64 + %6 = llvm.add %2, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @not_match_inconsistent_values(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(299 : i64) : i64 + %1 = llvm.mlir.constant(29 : i64) : i64 + %2 = llvm.mlir.constant(64 : i64) : i64 + %3 = llvm.urem %arg0, %0 : i64 + %4 = llvm.udiv %arg0, %1 : i64 + %5 = llvm.urem %4, %2 : i64 + %6 = llvm.mul %5, %0 : i64 + %7 = llvm.add %3, %6 : i64 + llvm.return %7 : i64 + } + llvm.func @not_match_overflow(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(299 : i32) : i32 + %1 = llvm.mlir.constant(147483647 : i32) : i32 + %2 = llvm.urem %arg0, %0 : i32 + %3 = llvm.udiv %arg0, %0 : i32 + %4 = llvm.urem %3, %1 : i32 + %5 = llvm.mul %4, %0 : i32 + %6 = llvm.add %2, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @fold_add_udiv_urem(%arg0: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.udiv %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + %4 = llvm.urem %arg0, %0 : i32 + %5 = llvm.add %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @fold_add_sdiv_srem(%arg0: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.sdiv %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + %4 = llvm.srem %arg0, %0 : i32 + %5 = llvm.add %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @fold_add_udiv_urem_to_mul(%arg0: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(21 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.udiv %arg0, %0 : i32 + %4 = llvm.mul %3, %1 : i32 + %5 = llvm.urem %arg0, %0 : i32 + %6 = llvm.mul %5, %2 : i32 + %7 = llvm.add %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @fold_add_udiv_urem_to_mul_multiuse(%arg0: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(21 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.udiv %arg0, %0 : i32 + %4 = llvm.mul %3, %1 : i32 + %5 = llvm.urem %arg0, %0 : i32 + llvm.call @use(%5) : (i32) -> () + %6 = llvm.mul %5, %2 : i32 + %7 = llvm.add %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @fold_add_udiv_urem_commuted(%arg0: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.udiv %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + %4 = llvm.urem %arg0, %0 : i32 + %5 = llvm.add %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @fold_add_udiv_urem_or_disjoint(%arg0: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.udiv %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + %4 = llvm.urem %arg0, %0 : i32 + %5 = llvm.or %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @fold_add_udiv_urem_without_noundef(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.udiv %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + %4 = llvm.urem %arg0, %0 : i32 + %5 = llvm.add %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @fold_add_udiv_urem_multiuse_mul(%arg0: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.udiv %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.urem %arg0, %0 : i32 + %5 = llvm.add %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @fold_add_udiv_srem(%arg0: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.udiv %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + %4 = llvm.srem %arg0, %0 : i32 + %5 = llvm.add %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @fold_add_udiv_urem_non_constant(%arg0: i32 {llvm.noundef}, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.udiv %arg0, %arg1 : i32 + %2 = llvm.shl %1, %0 : i32 + %3 = llvm.urem %arg0, %arg1 : i32 + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/add_or_sub.ll.mlir b/test/LLVMDialect/InstCombine/add_or_sub.ll.mlir new file mode 100644 index 000000000..27c25d341 --- /dev/null +++ b/test/LLVMDialect/InstCombine/add_or_sub.ll.mlir @@ -0,0 +1,126 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use19(i19) + llvm.func @use12(i12) + llvm.func @use2(i2) + llvm.func @add_or_sub_comb_i32_commuted1_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.add %2, %arg0 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @add_or_sub_comb_i8_commuted2_nsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mul %arg0, %arg0 : i8 + %2 = llvm.sub %0, %1 : i8 + %3 = llvm.or %2, %1 : i8 + %4 = llvm.add %1, %3 overflow : i8 + llvm.return %4 : i8 + } + llvm.func @add_or_sub_comb_i128_commuted3_nuw_nsw(%arg0: i128) -> i128 { + %0 = llvm.mlir.constant(0 : i128) : i128 + %1 = llvm.mul %arg0, %arg0 : i128 + %2 = llvm.sub %0, %1 : i128 + %3 = llvm.or %1, %2 : i128 + %4 = llvm.add %3, %1 overflow : i128 + llvm.return %4 : i128 + } + llvm.func @add_or_sub_comb_i64_commuted4(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mul %arg0, %arg0 : i64 + %2 = llvm.sub %0, %1 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.add %1, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @add_or_sub_comb_i32vec(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<3xi32>) : vector<3xi32> + %2 = llvm.mul %arg0, %arg0 : vector<3xi32> + %3 = llvm.sub %1, %2 : vector<3xi32> + %4 = llvm.or %3, %2 : vector<3xi32> + %5 = llvm.add %4, %2 : vector<3xi32> + llvm.return %5 : vector<3xi32> + } + llvm.func @add_or_sub_comb_i32vec_poison(%arg0: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<4xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi16> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi16> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi16> + %11 = llvm.mul %arg0, %arg0 : vector<4xi16> + %12 = llvm.sub %10, %11 : vector<4xi16> + %13 = llvm.or %12, %11 : vector<4xi16> + %14 = llvm.add %13, %11 : vector<4xi16> + llvm.return %14 : vector<4xi16> + } + llvm.func @add_or_sub_comb_i12_multiuse_only_sub(%arg0: i12) -> i12 { + %0 = llvm.mlir.constant(0 : i12) : i12 + %1 = llvm.mul %arg0, %arg0 : i12 + %2 = llvm.sub %0, %1 : i12 + llvm.call @use12(%2) : (i12) -> () + %3 = llvm.or %2, %1 : i12 + %4 = llvm.add %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @add_or_sub_comb_i8_negative_y_sub(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + %2 = llvm.or %1, %arg0 : i8 + %3 = llvm.add %2, %arg0 : i8 + llvm.return %3 : i8 + } + llvm.func @add_or_sub_comb_i8_negative_y_or(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.or %1, %arg1 : i8 + %3 = llvm.add %2, %arg0 : i8 + llvm.return %3 : i8 + } + llvm.func @add_or_sub_comb_i8_negative_y_add(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.or %1, %arg0 : i8 + %3 = llvm.add %2, %arg1 : i8 + llvm.return %3 : i8 + } + llvm.func @add_or_sub_comb_i8_negative_xor_instead_or(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.xor %1, %arg0 : i8 + %3 = llvm.add %2, %arg0 : i8 + llvm.return %3 : i8 + } + llvm.func @add_or_sub_comb_i16_negative_sub_no_negate(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.sub %0, %arg0 : i16 + %2 = llvm.or %1, %arg0 : i16 + %3 = llvm.add %2, %arg0 : i16 + llvm.return %3 : i16 + } + llvm.func @add_or_sub_comb_i2_negative_multiuse_only_or(%arg0: i2) -> i2 { + %0 = llvm.mlir.constant(0 : i2) : i2 + %1 = llvm.mul %arg0, %arg0 : i2 + %2 = llvm.sub %0, %1 : i2 + %3 = llvm.or %2, %1 : i2 + llvm.call @use2(%3) : (i2) -> () + %4 = llvm.add %3, %1 : i2 + llvm.return %4 : i2 + } + llvm.func @add_or_sub_comb_i19_negative_multiuse_both(%arg0: i19) -> i19 { + %0 = llvm.mlir.constant(0 : i19) : i19 + %1 = llvm.mul %arg0, %arg0 : i19 + %2 = llvm.sub %0, %1 : i19 + llvm.call @use19(%2) : (i19) -> () + %3 = llvm.or %2, %1 : i19 + llvm.call @use19(%3) : (i19) -> () + %4 = llvm.add %3, %1 : i19 + llvm.return %4 : i19 + } +} diff --git a/test/LLVMDialect/InstCombine/addnegneg.ll.mlir b/test/LLVMDialect/InstCombine/addnegneg.ll.mlir index 3c05a4e8f..d98fdc900 100644 --- a/test/LLVMDialect/InstCombine/addnegneg.ll.mlir +++ b/test/LLVMDialect/InstCombine/addnegneg.ll.mlir @@ -1,12 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.sub"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.sub"(%0, %arg2) : (i32, i32) -> i32 - %3 = "llvm.add"(%2, %1) : (i32, i32) -> i32 - %4 = "llvm.add"(%3, %arg3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "l", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @l(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.sub %0, %arg2 : i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.add %3, %arg3 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/addrspacecast.ll.mlir b/test/LLVMDialect/InstCombine/addrspacecast.ll.mlir new file mode 100644 index 000000000..a393a9870 --- /dev/null +++ b/test/LLVMDialect/InstCombine/addrspacecast.ll.mlir @@ -0,0 +1,125 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<16> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @const_array("\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16") {addr_space = 2 : i32} + llvm.func @combine_redundant_addrspacecast(%arg0: !llvm.ptr<1>) -> !llvm.ptr attributes {passthrough = ["nounwind"]} { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr<1> to !llvm.ptr<3> + %1 = llvm.addrspacecast %0 : !llvm.ptr<3> to !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @combine_redundant_addrspacecast_vector(%arg0: !llvm.vec<4 x ptr<1>>) -> !llvm.vec<4 x ptr> attributes {passthrough = ["nounwind"]} { + %0 = llvm.addrspacecast %arg0 : !llvm.vec<4 x ptr<1>> to !llvm.vec<4 x ptr<3>> + %1 = llvm.addrspacecast %0 : !llvm.vec<4 x ptr<3>> to !llvm.vec<4 x ptr> + llvm.return %1 : !llvm.vec<4 x ptr> + } + llvm.func @combine_redundant_addrspacecast_types(%arg0: !llvm.ptr<1>) -> !llvm.ptr attributes {passthrough = ["nounwind"]} { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr<1> to !llvm.ptr<3> + %1 = llvm.addrspacecast %0 : !llvm.ptr<3> to !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @combine_redundant_addrspacecast_types_vector(%arg0: !llvm.vec<4 x ptr<1>>) -> !llvm.vec<4 x ptr> attributes {passthrough = ["nounwind"]} { + %0 = llvm.addrspacecast %arg0 : !llvm.vec<4 x ptr<1>> to !llvm.vec<4 x ptr<3>> + %1 = llvm.addrspacecast %0 : !llvm.vec<4 x ptr<3>> to !llvm.vec<4 x ptr> + llvm.return %1 : !llvm.vec<4 x ptr> + } + llvm.func @combine_addrspacecast_bitcast_1(%arg0: !llvm.ptr<1>) -> !llvm.ptr<2> attributes {passthrough = ["nounwind"]} { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr<1> to !llvm.ptr<2> + llvm.return %0 : !llvm.ptr<2> + } + llvm.func @combine_addrspacecast_bitcast_2(%arg0: !llvm.ptr<1>) -> !llvm.ptr<2> attributes {passthrough = ["nounwind"]} { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr<1> to !llvm.ptr<2> + llvm.return %0 : !llvm.ptr<2> + } + llvm.func @combine_bitcast_addrspacecast_1(%arg0: !llvm.ptr<1>) -> !llvm.ptr<2> attributes {passthrough = ["nounwind"]} { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr<1> to !llvm.ptr<2> + llvm.return %0 : !llvm.ptr<2> + } + llvm.func @combine_bitcast_addrspacecast_2(%arg0: !llvm.ptr<1>) -> !llvm.ptr<2> attributes {passthrough = ["nounwind"]} { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr<1> to !llvm.ptr<2> + llvm.return %0 : !llvm.ptr<2> + } + llvm.func @combine_addrspacecast_types(%arg0: !llvm.ptr<1>) -> !llvm.ptr<2> attributes {passthrough = ["nounwind"]} { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr<1> to !llvm.ptr<2> + llvm.return %0 : !llvm.ptr<2> + } + llvm.func @combine_addrspacecast_types_vector(%arg0: !llvm.vec<4 x ptr<1>>) -> !llvm.vec<4 x ptr<2>> attributes {passthrough = ["nounwind"]} { + %0 = llvm.addrspacecast %arg0 : !llvm.vec<4 x ptr<1>> to !llvm.vec<4 x ptr<2>> + llvm.return %0 : !llvm.vec<4 x ptr<2>> + } + llvm.func @combine_addrspacecast_types_scalevector(%arg0: !llvm.vec>) -> !llvm.vec> attributes {passthrough = ["nounwind"]} { + %0 = llvm.addrspacecast %arg0 : !llvm.vec> to !llvm.vec> + llvm.return %0 : !llvm.vec> + } + llvm.func @canonicalize_addrspacecast(%arg0: !llvm.ptr<1>) -> i32 { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr<1> to !llvm.ptr + %1 = llvm.load %0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %1 : i32 + } + llvm.func @foo(!llvm.ptr) attributes {passthrough = ["nounwind"]} + llvm.func @memcpy_addrspacecast() -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(48 : i32) : i32 + %1 = llvm.mlir.constant(4 : i16) : i16 + %2 = llvm.mlir.constant(0 : i16) : i16 + %3 = llvm.mlir.constant("\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16\02\09\04\16") : !llvm.array<60 x i8> + %4 = llvm.mlir.addressof @const_array : !llvm.ptr<2> + %5 = llvm.getelementptr inbounds %4[%2, %1] : (!llvm.ptr<2>, i16, i16) -> !llvm.ptr<2>, !llvm.array<60 x i8> + %6 = llvm.addrspacecast %5 : !llvm.ptr<2> to !llvm.ptr<1> + %7 = llvm.mlir.constant(0 : i32) : i32 + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%9, %6, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr<1>, i32) -> () + llvm.br ^bb1(%7, %7 : i32, i32) + ^bb1(%10: i32, %11: i32): // 2 preds: ^bb0, ^bb1 + %12 = llvm.getelementptr %9[%10] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %13 = llvm.load %12 {alignment = 1 : i64} : !llvm.ptr -> i8 + %14 = llvm.zext %13 : i8 to i32 + %15 = llvm.add %11, %14 : i32 + %16 = llvm.add %10, %8 : i32 + %17 = llvm.icmp "ne" %10, %0 : i32 + llvm.cond_br %17, ^bb1(%16, %15 : i32, i32), ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %15 : i32 + } + llvm.func @constant_fold_null() { + %0 = llvm.mlir.zero : !llvm.ptr<3> + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.addrspacecast %0 : !llvm.ptr<3> to !llvm.ptr<4> + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr<4> + llvm.return + } + llvm.func @constant_fold_undef() -> !llvm.ptr<4> { + %0 = llvm.mlir.undef : !llvm.ptr<3> + %1 = llvm.addrspacecast %0 : !llvm.ptr<3> to !llvm.ptr<4> + llvm.return %1 : !llvm.ptr<4> + } + llvm.func @constant_fold_null_vector() -> !llvm.vec<4 x ptr<4>> { + %0 = llvm.mlir.zero : !llvm.ptr<3> + %1 = llvm.mlir.undef : !llvm.vec<4 x ptr<3>> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec<4 x ptr<3>> + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec<4 x ptr<3>> + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.insertelement %0, %5[%6 : i32] : !llvm.vec<4 x ptr<3>> + %8 = llvm.mlir.constant(3 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : !llvm.vec<4 x ptr<3>> + %10 = llvm.addrspacecast %9 : !llvm.vec<4 x ptr<3>> to !llvm.vec<4 x ptr<4>> + llvm.return %10 : !llvm.vec<4 x ptr<4>> + } + llvm.func @constant_fold_inttoptr() { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.inttoptr %0 : i32 to !llvm.ptr<3> + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.addrspacecast %1 : !llvm.ptr<3> to !llvm.ptr<4> + llvm.store %2, %3 {alignment = 4 : i64} : i32, !llvm.ptr<4> + llvm.return + } + llvm.func @constant_fold_gep_inttoptr() { + %0 = llvm.mlir.constant(1234 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.inttoptr %0 : i32 to !llvm.ptr<3> + %4 = llvm.getelementptr %3[%1] : (!llvm.ptr<3>, i32) -> !llvm.ptr<3>, i32 + %5 = llvm.addrspacecast %4 : !llvm.ptr<3> to !llvm.ptr<4> + llvm.store %2, %5 {alignment = 4 : i64} : i32, !llvm.ptr<4> + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/addsub-constant-folding.ll.mlir b/test/LLVMDialect/InstCombine/addsub-constant-folding.ll.mlir new file mode 100644 index 000000000..edff7e3ab --- /dev/null +++ b/test/LLVMDialect/InstCombine/addsub-constant-folding.ll.mlir @@ -0,0 +1,666 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @vec_use(vector<4xi32>) + llvm.func @add_const_add_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.add %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @add_const_add_const_extrause(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.add %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @vec_add_const_add_const(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 : vector<4xi32> + %3 = llvm.add %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_add_const_add_const_extrause(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 : vector<4xi32> + llvm.call @vec_use(%2) : (vector<4xi32>) -> () + %3 = llvm.add %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_add_const_add_const_nonsplat(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(21 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(2 : i32) : i32 + %13 = llvm.mlir.constant(3 : i32) : i32 + %14 = llvm.mlir.undef : vector<4xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %12, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %13, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.insertelement %12, %20[%21 : i32] : vector<4xi32> + %23 = llvm.add %arg0, %11 : vector<4xi32> + %24 = llvm.add %23, %22 : vector<4xi32> + llvm.return %24 : vector<4xi32> + } + llvm.func @add_const_sub_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.sub %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @add_const_sub_const_extrause(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.sub %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @vec_add_const_sub_const(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 : vector<4xi32> + %3 = llvm.sub %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_add_const_sub_const_extrause(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 : vector<4xi32> + llvm.call @vec_use(%2) : (vector<4xi32>) -> () + %3 = llvm.sub %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_add_const_sub_const_nonsplat(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(21 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(2 : i32) : i32 + %13 = llvm.mlir.constant(3 : i32) : i32 + %14 = llvm.mlir.undef : vector<4xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %12, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %13, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.insertelement %12, %20[%21 : i32] : vector<4xi32> + %23 = llvm.add %arg0, %11 : vector<4xi32> + %24 = llvm.sub %23, %22 : vector<4xi32> + llvm.return %24 : vector<4xi32> + } + llvm.func @add_const_const_sub(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.sub %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @add_nsw_const_const_sub_nsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.sub %1, %2 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @add_nsw_const_const_sub(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @add_const_const_sub_nsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.sub %1, %2 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @add_nsw_const_const_sub_nsw_ov(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.sub %1, %2 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @add_nuw_const_const_sub_nuw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.sub %1, %2 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @add_nuw_const_const_sub(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @add_const_const_sub_nuw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.sub %1, %2 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @non_splat_vec_add_nsw_const_const_sub_nsw_not_ov1(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[2, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-125, -126]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = llvm.sub %1, %2 overflow : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @non_splat_vec_add_nsw_const_const_sub_nsw_not_ov2(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-125, -126]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = llvm.sub %1, %2 overflow : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @non_splat_vec_add_nsw_const_const_sub_nsw_not_ov3(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-120, -126]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = llvm.sub %1, %2 overflow : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @non_splat_vec_add_nsw_const_const_sub_nsw_ov(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-126, -127]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = llvm.sub %1, %2 overflow : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @add_const_const_sub_extrause(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.sub %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @vec_add_const_const_sub(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 : vector<4xi32> + %3 = llvm.sub %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_add_const_const_sub_extrause(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 : vector<4xi32> + llvm.call @vec_use(%2) : (vector<4xi32>) -> () + %3 = llvm.sub %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_add_const_const_sub_nonsplat(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(21 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(2 : i32) : i32 + %13 = llvm.mlir.constant(3 : i32) : i32 + %14 = llvm.mlir.undef : vector<4xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %12, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %13, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.insertelement %12, %20[%21 : i32] : vector<4xi32> + %23 = llvm.add %arg0, %11 : vector<4xi32> + %24 = llvm.sub %22, %23 : vector<4xi32> + llvm.return %24 : vector<4xi32> + } + llvm.func @sub_const_add_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %arg0, %0 : i32 + %3 = llvm.add %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @sub_const_add_const_extrause(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.add %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @vec_sub_const_add_const(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %arg0, %0 : vector<4xi32> + %3 = llvm.add %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_sub_const_add_const_extrause(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %arg0, %0 : vector<4xi32> + llvm.call @vec_use(%2) : (vector<4xi32>) -> () + %3 = llvm.add %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_sub_const_add_const_nonsplat(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(21 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(2 : i32) : i32 + %13 = llvm.mlir.constant(3 : i32) : i32 + %14 = llvm.mlir.undef : vector<4xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %12, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %13, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.insertelement %12, %20[%21 : i32] : vector<4xi32> + %23 = llvm.sub %arg0, %11 : vector<4xi32> + %24 = llvm.add %23, %22 : vector<4xi32> + llvm.return %24 : vector<4xi32> + } + llvm.func @sub_const_sub_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %arg0, %0 : i32 + %3 = llvm.sub %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @sub_const_sub_const_extrause(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.sub %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @vec_sub_const_sub_const(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %arg0, %0 : vector<4xi32> + %3 = llvm.sub %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_sub_const_sub_const_extrause(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %arg0, %0 : vector<4xi32> + llvm.call @vec_use(%2) : (vector<4xi32>) -> () + %3 = llvm.sub %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_sub_const_sub_const_nonsplat(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(21 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(2 : i32) : i32 + %13 = llvm.mlir.constant(3 : i32) : i32 + %14 = llvm.mlir.undef : vector<4xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %12, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %13, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.insertelement %12, %20[%21 : i32] : vector<4xi32> + %23 = llvm.sub %arg0, %11 : vector<4xi32> + %24 = llvm.sub %23, %22 : vector<4xi32> + llvm.return %24 : vector<4xi32> + } + llvm.func @sub_const_const_sub(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %arg0, %0 : i32 + %3 = llvm.sub %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @sub_const_const_sub_extrause(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.sub %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @vec_sub_const_const_sub(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %arg0, %0 : vector<4xi32> + %3 = llvm.sub %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_sub_const_const_sub_extrause(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %arg0, %0 : vector<4xi32> + llvm.call @vec_use(%2) : (vector<4xi32>) -> () + %3 = llvm.sub %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_sub_const_const_sub_nonsplat(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(21 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(2 : i32) : i32 + %13 = llvm.mlir.constant(3 : i32) : i32 + %14 = llvm.mlir.undef : vector<4xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %12, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %13, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.insertelement %12, %20[%21 : i32] : vector<4xi32> + %23 = llvm.sub %arg0, %11 : vector<4xi32> + %24 = llvm.sub %22, %23 : vector<4xi32> + llvm.return %24 : vector<4xi32> + } + llvm.func @const_sub_add_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.add %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @const_sub_add_const_extrause(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.add %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @vec_const_sub_add_const(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.add %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_const_sub_add_const_extrause(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + llvm.call @vec_use(%2) : (vector<4xi32>) -> () + %3 = llvm.add %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_const_sub_add_const_nonsplat(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(21 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(2 : i32) : i32 + %13 = llvm.mlir.constant(3 : i32) : i32 + %14 = llvm.mlir.undef : vector<4xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %12, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %13, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.insertelement %12, %20[%21 : i32] : vector<4xi32> + %23 = llvm.sub %11, %arg0 : vector<4xi32> + %24 = llvm.add %23, %22 : vector<4xi32> + llvm.return %24 : vector<4xi32> + } + llvm.func @const_sub_sub_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.sub %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @const_sub_sub_const_extrause(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.sub %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @vec_const_sub_sub_const(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.sub %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_const_sub_sub_const_extrause(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + llvm.call @vec_use(%2) : (vector<4xi32>) -> () + %3 = llvm.sub %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_const_sub_sub_const_nonsplat(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(21 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(2 : i32) : i32 + %13 = llvm.mlir.constant(3 : i32) : i32 + %14 = llvm.mlir.undef : vector<4xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %12, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %13, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.insertelement %12, %20[%21 : i32] : vector<4xi32> + %23 = llvm.sub %11, %arg0 : vector<4xi32> + %24 = llvm.sub %23, %22 : vector<4xi32> + llvm.return %24 : vector<4xi32> + } + llvm.func @const_sub_const_sub(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.sub %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @const_sub_const_sub_extrause(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.sub %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @vec_const_sub_const_sub(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.sub %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_const_sub_const_sub_extrause(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + llvm.call @vec_use(%2) : (vector<4xi32>) -> () + %3 = llvm.sub %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vec_const_sub_const_sub_nonsplat(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(21 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(2 : i32) : i32 + %13 = llvm.mlir.constant(3 : i32) : i32 + %14 = llvm.mlir.undef : vector<4xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %12, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %13, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.insertelement %12, %20[%21 : i32] : vector<4xi32> + %23 = llvm.sub %11, %arg0 : vector<4xi32> + %24 = llvm.sub %22, %23 : vector<4xi32> + llvm.return %24 : vector<4xi32> + } + llvm.func @addsub_combine_constants(%arg0: i7, %arg1: i7) -> i7 { + %0 = llvm.mlir.constant(42 : i7) : i7 + %1 = llvm.mlir.constant(10 : i7) : i7 + %2 = llvm.add %arg0, %0 : i7 + %3 = llvm.sub %1, %arg1 : i7 + %4 = llvm.add %2, %3 overflow : i7 + llvm.return %4 : i7 + } + llvm.func @addsub_combine_constants_use1(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[42, -7, 0, -1]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[-100, 1, -1, 42]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 : vector<4xi32> + llvm.call @vec_use(%2) : (vector<4xi32>) -> () + %3 = llvm.sub %1, %arg1 : vector<4xi32> + %4 = llvm.add %3, %2 overflow : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @addsub_combine_constants_use2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(100 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.sub %1, %arg1 : i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @addsub_combine_constants_use3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(100 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.sub %1, %arg1 : i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @sub_from_constant(%arg0: i5, %arg1: i5) -> i5 { + %0 = llvm.mlir.constant(10 : i5) : i5 + %1 = llvm.sub %0, %arg0 : i5 + %2 = llvm.add %1, %arg1 : i5 + llvm.return %2 : i5 + } + llvm.func @sub_from_constant_commute(%arg0: i5, %arg1: i5) -> i5 { + %0 = llvm.mlir.constant(10 : i5) : i5 + %1 = llvm.mul %arg1, %arg1 : i5 + %2 = llvm.sub %0, %arg0 overflow : i5 + %3 = llvm.add %1, %2 overflow : i5 + llvm.return %3 : i5 + } + llvm.func @sub_from_constant_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[2, -42]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sub %0, %arg0 overflow : vector<2xi8> + %2 = llvm.add %1, %arg1 overflow : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @sub_from_constant_extra_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.addressof @use : !llvm.ptr + %2 = llvm.sub %0, %arg0 : i8 + llvm.call %1(%2) : !llvm.ptr, (i8) -> () + %3 = llvm.add %2, %arg1 : i8 + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/adjust-for-minmax.ll.mlir b/test/LLVMDialect/InstCombine/adjust-for-minmax.ll.mlir new file mode 100644 index 000000000..e8025342c --- /dev/null +++ b/test/LLVMDialect/InstCombine/adjust-for-minmax.ll.mlir @@ -0,0 +1,272 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @smax1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.select %1, %arg0, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @smin1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.select %1, %arg0, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @smax2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sge" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @smin2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sle" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @smax3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @smax3_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %4 = llvm.select %3, %arg0, %2 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @smin3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @smin3_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.icmp "slt" %arg0, %0 : vector<2xi32> + %4 = llvm.select %3, %arg0, %2 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @umax3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @umax3_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "ugt" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %arg0, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @umin3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @umin3_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<6> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %arg0, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @smax4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sge" %arg0, %0 : i32 + %2 = llvm.select %1, %arg0, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @smax4_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "sge" %arg0, %1 : vector<2xi32> + %3 = llvm.select %2, %arg0, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @smin4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sle" %arg0, %0 : i32 + %2 = llvm.select %1, %arg0, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @smin4_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "sle" %arg0, %1 : vector<2xi32> + %3 = llvm.select %2, %arg0, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @umax4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.icmp "uge" %arg0, %0 : i32 + %2 = llvm.select %1, %arg0, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @umax4_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "uge" %arg0, %0 : vector<2xi32> + %2 = llvm.select %1, %arg0, %0 : vector<2xi1>, vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @umin4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.icmp "ule" %arg0, %0 : i32 + %2 = llvm.select %1, %arg0, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @umin4_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<9> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "ule" %arg0, %0 : vector<2xi32> + %2 = llvm.select %1, %arg0, %0 : vector<2xi1>, vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @smax_sext(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.select %3, %2, %1 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @smax_sext_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.sext %arg0 : vector<2xi32> to vector<2xi64> + %4 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %5 = llvm.select %4, %3, %2 : vector<2xi1>, vector<2xi64> + llvm.return %5 : vector<2xi64> + } + llvm.func @smin_sext(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %3, %2, %1 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @smin_sext_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.sext %arg0 : vector<2xi32> to vector<2xi64> + %4 = llvm.icmp "slt" %arg0, %0 : vector<2xi32> + %5 = llvm.select %4, %3, %2 : vector<2xi1>, vector<2xi64> + llvm.return %5 : vector<2xi64> + } + llvm.func @umax_sext(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.select %3, %2, %1 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @umax_sext_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<3> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sext %arg0 : vector<2xi32> to vector<2xi64> + %3 = llvm.icmp "ugt" %arg0, %0 : vector<2xi32> + %4 = llvm.select %3, %2, %1 : vector<2xi1>, vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @umin_sext(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.select %3, %2, %1 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @umin_sext_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<2> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sext %arg0 : vector<2xi32> to vector<2xi64> + %3 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %4 = llvm.select %3, %2, %1 : vector<2xi1>, vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @umax_sext2(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.select %3, %1, %2 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @umax_sext2_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<2> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sext %arg0 : vector<2xi32> to vector<2xi64> + %3 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %4 = llvm.select %3, %1, %2 : vector<2xi1>, vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @umin_sext2(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.select %3, %1, %2 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @umin_sext2_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<3> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sext %arg0 : vector<2xi32> to vector<2xi64> + %3 = llvm.icmp "ugt" %arg0, %0 : vector<2xi32> + %4 = llvm.select %3, %1, %2 : vector<2xi1>, vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @umax_zext(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.zext %arg0 : i32 to i64 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.select %3, %2, %1 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @umax_zext_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<3> : vector<2xi64>) : vector<2xi64> + %2 = llvm.zext %arg0 : vector<2xi32> to vector<2xi64> + %3 = llvm.icmp "ugt" %arg0, %0 : vector<2xi32> + %4 = llvm.select %3, %2, %1 : vector<2xi1>, vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @umin_zext(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.zext %arg0 : i32 to i64 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.select %3, %2, %1 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @umin_zext_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<2> : vector<2xi64>) : vector<2xi64> + %2 = llvm.zext %arg0 : vector<2xi32> to vector<2xi64> + %3 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %4 = llvm.select %3, %2, %1 : vector<2xi1>, vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @scalar_select_of_vectors(%arg0: vector<2xi16>, %arg1: vector<2xi16>, %arg2: i8) -> vector<2xi16> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg2, %0 : i8 + %2 = llvm.select %1, %arg0, %arg1 : i1, vector<2xi16> + llvm.return %2 : vector<2xi16> + } +} diff --git a/test/LLVMDialect/InstCombine/aggregate-reconstruction.ll.mlir b/test/LLVMDialect/InstCombine/aggregate-reconstruction.ll.mlir new file mode 100644 index 000000000..b9ddd7313 --- /dev/null +++ b/test/LLVMDialect/InstCombine/aggregate-reconstruction.ll.mlir @@ -0,0 +1,166 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo() + llvm.func @bar() + llvm.func @baz() + llvm.func @usei32(i32) + llvm.func @usei32i32agg(!llvm.struct<(i32, i32)>) + llvm.func @test0(%arg0: !llvm.struct<(i32, i32)>) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %1, %0[0] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %2, %3[1] : !llvm.struct<(i32, i32)> + llvm.return %4 : !llvm.struct<(i32, i32)> + } + llvm.func @test1(%arg0: !llvm.array<2 x i32>) -> !llvm.array<2 x i32> { + %0 = llvm.mlir.undef : !llvm.array<2 x i32> + %1 = llvm.extractvalue %arg0[0] : !llvm.array<2 x i32> + %2 = llvm.extractvalue %arg0[1] : !llvm.array<2 x i32> + %3 = llvm.insertvalue %1, %0[0] : !llvm.array<2 x i32> + %4 = llvm.insertvalue %2, %3[1] : !llvm.array<2 x i32> + llvm.return %4 : !llvm.array<2 x i32> + } + llvm.func @test2(%arg0: !llvm.array<3 x i32>) -> !llvm.array<3 x i32> { + %0 = llvm.mlir.undef : !llvm.array<3 x i32> + %1 = llvm.extractvalue %arg0[0] : !llvm.array<3 x i32> + %2 = llvm.extractvalue %arg0[1] : !llvm.array<3 x i32> + %3 = llvm.extractvalue %arg0[2] : !llvm.array<3 x i32> + %4 = llvm.insertvalue %1, %0[0] : !llvm.array<3 x i32> + %5 = llvm.insertvalue %2, %4[1] : !llvm.array<3 x i32> + %6 = llvm.insertvalue %3, %5[2] : !llvm.array<3 x i32> + llvm.return %6 : !llvm.array<3 x i32> + } + llvm.func @test3(%arg0: !llvm.struct<(struct<(i32, i32)>)>) -> !llvm.struct<(struct<(i32, i32)>)> { + %0 = llvm.mlir.undef : !llvm.struct<(struct<(i32, i32)>)> + %1 = llvm.extractvalue %arg0[0, 0] : !llvm.struct<(struct<(i32, i32)>)> + %2 = llvm.extractvalue %arg0[0, 1] : !llvm.struct<(struct<(i32, i32)>)> + %3 = llvm.insertvalue %1, %0[0, 0] : !llvm.struct<(struct<(i32, i32)>)> + %4 = llvm.insertvalue %2, %3[0, 1] : !llvm.struct<(struct<(i32, i32)>)> + llvm.return %4 : !llvm.struct<(struct<(i32, i32)>)> + } + llvm.func @test4(%arg0: !llvm.struct<(i32, struct<(i32)>)>) -> !llvm.struct<(i32, struct<(i32)>)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, struct<(i32)>)> + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, struct<(i32)>)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, struct<(i32)>)> + %3 = llvm.insertvalue %1, %0[0] : !llvm.struct<(i32, struct<(i32)>)> + %4 = llvm.insertvalue %2, %3[1] : !llvm.struct<(i32, struct<(i32)>)> + llvm.return %4 : !llvm.struct<(i32, struct<(i32)>)> + } + llvm.func @negative_test5(%arg0: !llvm.struct<(i32, i32)>, %arg1: i32) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.insertvalue %1, %0[0] : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %arg1, %2[1] : !llvm.struct<(i32, i32)> + llvm.return %3 : !llvm.struct<(i32, i32)> + } + llvm.func @negative_test6(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>) -> !llvm.struct<(i32, i32)> { + %0 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %1 = llvm.insertvalue %0, %arg1[0] : !llvm.struct<(i32, i32)> + llvm.return %1 : !llvm.struct<(i32, i32)> + } + llvm.func @negative_test7(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %arg1[1] : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %1, %0[0] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %2, %3[1] : !llvm.struct<(i32, i32)> + llvm.return %4 : !llvm.struct<(i32, i32)> + } + llvm.func @negative_test8(%arg0: !llvm.struct<(i32, i32)>) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %1, %0[1] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<(i32, i32)> + llvm.return %4 : !llvm.struct<(i32, i32)> + } + llvm.func @negative_test9(%arg0: !llvm.struct<(i32, i32)>) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.insertvalue %1, %0[0] : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %1, %2[1] : !llvm.struct<(i32, i32)> + llvm.return %3 : !llvm.struct<(i32, i32)> + } + llvm.func @negative_test10(%arg0: !llvm.struct<(i32, i32)>) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.insertvalue %1, %0[0] : !llvm.struct<(i32, i32)> + llvm.return %2 : !llvm.struct<(i32, i32)> + } + llvm.func @negative_test11(%arg0: !llvm.struct<(i32, i32)>) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.mlir.undef : i32 + %2 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %2, %0[0] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %1, %3[1] : !llvm.struct<(i32, i32)> + llvm.return %4 : !llvm.struct<(i32, i32)> + } + llvm.func @test12(%arg0: !llvm.struct<(i32, i32)>) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + llvm.call @usei32(%1) : (i32) -> () + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + llvm.call @usei32(%2) : (i32) -> () + %3 = llvm.insertvalue %1, %0[0] : !llvm.struct<(i32, i32)> + llvm.call @usei32i32agg(%3) : (!llvm.struct<(i32, i32)>) -> () + %4 = llvm.insertvalue %2, %3[1] : !llvm.struct<(i32, i32)> + llvm.return %4 : !llvm.struct<(i32, i32)> + } + llvm.func @test13(%arg0: !llvm.struct<(i32, i32)>) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %2, %0[0] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %1, %3[0] : !llvm.struct<(i32, i32)> + %5 = llvm.insertvalue %2, %4[1] : !llvm.struct<(i32, i32)> + llvm.return %5 : !llvm.struct<(i32, i32)> + } + llvm.func @negative_test14(%arg0: !llvm.struct<(i32, i32, i32)>) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32, i32)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32, i32)> + %3 = llvm.insertvalue %1, %0[0] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %2, %3[1] : !llvm.struct<(i32, i32)> + llvm.return %4 : !llvm.struct<(i32, i32)> + } + llvm.func @negative_test15(%arg0: !llvm.struct<(i32, struct<(i32)>)>) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, struct<(i32)>)> + %2 = llvm.extractvalue %arg0[1, 0] : !llvm.struct<(i32, struct<(i32)>)> + %3 = llvm.insertvalue %1, %0[0] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %2, %3[1] : !llvm.struct<(i32, i32)> + llvm.return %4 : !llvm.struct<(i32, i32)> + } + llvm.func @test16(%arg0: !llvm.struct<(i32, i32)>) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %1, %0[0] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %2, %3[1] : !llvm.struct<(i32, i32)> + llvm.return %4 : !llvm.struct<(i32, i32)> + } + llvm.func @test17(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + llvm.cond_br %arg2, ^bb1, ^bb2(%arg0 : !llvm.struct<(i32, i32)>) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1 : !llvm.struct<(i32, i32)>) + ^bb2(%1: !llvm.struct<(i32, i32)>): // 2 preds: ^bb0, ^bb1 + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i32, i32)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %2, %0[0] : !llvm.struct<(i32, i32)> + %5 = llvm.insertvalue %3, %4[1] : !llvm.struct<(i32, i32)> + llvm.return %5 : !llvm.struct<(i32, i32)> + } + llvm.func @poison_base(%arg0: !llvm.array<3 x i32>) -> !llvm.array<3 x i32> { + %0 = llvm.mlir.poison : !llvm.array<3 x i32> + %1 = llvm.extractvalue %arg0[0] : !llvm.array<3 x i32> + %2 = llvm.extractvalue %arg0[1] : !llvm.array<3 x i32> + %3 = llvm.extractvalue %arg0[2] : !llvm.array<3 x i32> + %4 = llvm.insertvalue %1, %0[0] : !llvm.array<3 x i32> + %5 = llvm.insertvalue %2, %4[1] : !llvm.array<3 x i32> + %6 = llvm.insertvalue %3, %5[2] : !llvm.array<3 x i32> + llvm.return %6 : !llvm.array<3 x i32> + } +} diff --git a/test/LLVMDialect/InstCombine/alias-recursion.ll.mlir b/test/LLVMDialect/InstCombine/alias-recursion.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/align-addr.ll.mlir b/test/LLVMDialect/InstCombine/align-addr.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/align-attr.ll.mlir b/test/LLVMDialect/InstCombine/align-attr.ll.mlir index c6c779b24..19e17e8f7 100644 --- a/test/LLVMDialect/InstCombine/align-attr.ll.mlir +++ b/test/LLVMDialect/InstCombine/align-attr.ll.mlir @@ -1,16 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @func1, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "func1", type = !llvm.func (ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @foo1(%arg0: !llvm.ptr {llvm.align = 32 : i64}) -> i32 { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %0 : i32 + } + llvm.func @foo2(%arg0: !llvm.ptr {llvm.align = 32 : i64}) -> i32 { + %0 = llvm.call @func1(%arg0) : (!llvm.ptr) -> !llvm.ptr + %1 = llvm.load %0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %1 : i32 + } + llvm.func @func1(!llvm.ptr {llvm.returned}) -> !llvm.ptr attributes {passthrough = ["nounwind"]} +} diff --git a/test/LLVMDialect/InstCombine/align-external.ll.mlir b/test/LLVMDialect/InstCombine/align-external.ll.mlir new file mode 100644 index 000000000..b80d6eef0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/align-external.ll.mlir @@ -0,0 +1,29 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @A() {addr_space = 0 : i32} : i32 + llvm.mlir.global weak_odr @B(0 : i32) {addr_space = 0 : i32} : i32 + llvm.mlir.global available_externally @C(dense<0> : vector<4xi32>) {addr_space = 0 : i32, alignment = 4 : i64} : vector<4xi32> + llvm.func @foo(%arg0: i64) -> i64 { + %0 = llvm.mlir.addressof @A : !llvm.ptr + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %4 = llvm.shl %arg0, %1 : i64 + %5 = llvm.or %3, %4 : i64 + %6 = llvm.add %5, %2 : i64 + llvm.return %6 : i64 + } + llvm.func @bar() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @B : !llvm.ptr + %2 = llvm.load %1 {alignment = 1 : i64} : !llvm.ptr -> i32 + llvm.return %2 : i32 + } + llvm.func @vec_store() { + %0 = llvm.mlir.constant(dense<[0, 1, 2, 3]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %3 = llvm.mlir.addressof @C : !llvm.ptr + llvm.store %0, %3 {alignment = 4 : i64} : vector<4xi32>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/all-bits-shift.ll.mlir b/test/LLVMDialect/InstCombine/all-bits-shift.ll.mlir index 7e539bc23..588b6efb4 100644 --- a/test/LLVMDialect/InstCombine/all-bits-shift.ll.mlir +++ b/test/LLVMDialect/InstCombine/all-bits-shift.ll.mlir @@ -1,39 +1,38 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "d", type = i32, value = 15 : i32} : () -> () - "llvm.mlir.global"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @d} : () -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "b", type = !llvm.ptr} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 5 : i64, sym_name = "a", type = i32, value = 0 : i32} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2072 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %5 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr - %6 = "llvm.mlir.addressof"() {global_name = @b} : () -> !llvm.ptr> - %7 = "llvm.load"(%6) : (!llvm.ptr>) -> !llvm.ptr - %8 = "llvm.load"(%5) : (!llvm.ptr) -> i32 - %9 = "llvm.icmp"(%8, %4) {predicate = 0 : i64} : (i32, i32) -> i1 - %10 = "llvm.zext"(%9) : (i1) -> i32 - %11 = "llvm.lshr"(%3, %10) : (i32, i32) -> i32 - %12 = "llvm.lshr"(%11, %2) : (i32, i32) -> i32 - %13 = "llvm.and"(%12, %1) : (i32, i32) -> i32 - %14 = "llvm.load"(%7) : (!llvm.ptr) -> i32 - %15 = "llvm.or"(%13, %14) : (i32, i32) -> i32 - "llvm.store"(%15, %7) : (i32, !llvm.ptr) -> () - %16 = "llvm.load"(%0) : (!llvm.ptr) -> i32 - %17 = "llvm.icmp"(%16, %4) {predicate = 0 : i64} : (i32, i32) -> i1 - %18 = "llvm.zext"(%17) : (i1) -> i32 - %19 = "llvm.lshr"(%3, %18) : (i32, i32) -> i32 - %20 = "llvm.lshr"(%19, %2) : (i32, i32) -> i32 - %21 = "llvm.and"(%20, %1) : (i32, i32) -> i32 - %22 = "llvm.or"(%21, %15) : (i32, i32) -> i32 - "llvm.store"(%22, %7) : (i32, !llvm.ptr) -> () - "llvm.return"(%22) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "main", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "big">>} { + llvm.mlir.global external @d(15 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.mlir.global external @b() {addr_space = 0 : i32, alignment = 8 : i64} : !llvm.ptr { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.addressof @d : !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.mlir.global common @a(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.func @main() -> (i32 {llvm.signext}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.addressof @d : !llvm.ptr + %2 = llvm.mlir.addressof @b : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.addressof @a : !llvm.ptr + %5 = llvm.mlir.constant(2072 : i32) : i32 + %6 = llvm.mlir.constant(7 : i32) : i32 + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %9 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> i32 + %10 = llvm.icmp "eq" %9, %3 : i32 + %11 = llvm.zext %10 : i1 to i32 + %12 = llvm.lshr %5, %11 : i32 + %13 = llvm.lshr %12, %6 : i32 + %14 = llvm.and %13, %7 : i32 + %15 = llvm.load %8 {alignment = 4 : i64} : !llvm.ptr -> i32 + %16 = llvm.or %14, %15 : i32 + llvm.store %16, %8 {alignment = 4 : i64} : i32, !llvm.ptr + %17 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> i32 + %18 = llvm.icmp "eq" %17, %3 : i32 + %19 = llvm.zext %18 : i1 to i32 + %20 = llvm.lshr %5, %19 : i32 + %21 = llvm.lshr %20, %6 : i32 + %22 = llvm.and %21, %7 : i32 + %23 = llvm.or %22, %16 : i32 + llvm.store %23, %8 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %23 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/alloc-realloc-free.ll.mlir b/test/LLVMDialect/InstCombine/alloc-realloc-free.ll.mlir new file mode 100644 index 000000000..3b0ab5276 --- /dev/null +++ b/test/LLVMDialect/InstCombine/alloc-realloc-free.ll.mlir @@ -0,0 +1,13 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func local_unnamed_addr @test() attributes {passthrough = ["mustprogress", "nounwind", "willreturn", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(6 : i64) : i64 + %2 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %3 = llvm.call @realloc(%2, %1) : (!llvm.ptr, i64) -> !llvm.ptr + llvm.call @free(%3) : (!llvm.ptr) -> () + llvm.return + } + llvm.func local_unnamed_addr @malloc(i64 {llvm.noundef}) -> (!llvm.ptr {llvm.noalias, llvm.noundef}) attributes {memory = #llvm.memory_effects, passthrough = ["mustprogress", "nofree", "nounwind", "willreturn", ["allockind", "9"], ["alloc-family", "malloc"]]} + llvm.func local_unnamed_addr @realloc(!llvm.ptr {llvm.allocptr, llvm.nocapture}, i64 {llvm.noundef}) -> (!llvm.ptr {llvm.noalias, llvm.noundef}) attributes {memory = #llvm.memory_effects, passthrough = ["mustprogress", "nounwind", "willreturn", ["allockind", "2"], ["alloc-family", "malloc"]]} + llvm.func local_unnamed_addr @free(!llvm.ptr {llvm.allocptr, llvm.nocapture, llvm.noundef}) attributes {memory = #llvm.memory_effects, passthrough = ["nofree", "nosync", "nounwind", "speculatable", "willreturn", ["allockind", "4"], ["alloc-family", "malloc"]]} +} diff --git a/test/LLVMDialect/InstCombine/alloca-big.ll.mlir b/test/LLVMDialect/InstCombine/alloca-big.ll.mlir index 9428c6340..9d785212f 100644 --- a/test/LLVMDialect/InstCombine/alloca-big.ll.mlir +++ b/test/LLVMDialect/InstCombine/alloca-big.ll.mlir @@ -1,12 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = -4294967296 : i864} : () -> i864 - %2 = "llvm.alloca"(%1) : (i864) -> !llvm.ptr - %3 = "llvm.getelementptr"(%2, %0) : (!llvm.ptr, i1) -> !llvm.ptr - "llvm.store"(%3, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_bigalloc", type = !llvm.func>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_bigalloc(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(-4294967296 : i864) : i864 + %1 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i864) -> !llvm.ptr + llvm.store %1, %arg0 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/alloca-cast-debuginfo.ll.mlir b/test/LLVMDialect/InstCombine/alloca-cast-debuginfo.ll.mlir new file mode 100644 index 000000000..04c58b0a7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/alloca-cast-debuginfo.ll.mlir @@ -0,0 +1,27 @@ +#di_basic_type = #llvm.di_basic_type +#di_file = #llvm.di_file<"t.c" in "C:\\src\\llvm-project\\build"> +#di_null_type = #llvm.di_null_type +#tbaa_root = #llvm.tbaa_root +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C99, file = #di_file, producer = "clang version 6.0.0 ", isOptimized = true, emissionKind = Full> +#di_derived_type = #llvm.di_derived_type +#di_derived_type1 = #llvm.di_derived_type +#di_composite_type = #llvm.di_composite_type +#tbaa_type_desc = #llvm.tbaa_type_desc}> +#di_derived_type2 = #llvm.di_derived_type +#di_subroutine_type = #llvm.di_subroutine_type +#tbaa_type_desc1 = #llvm.tbaa_type_desc}> +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "f", file = #di_file, line = 5, scopeLine = 5, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#tbaa_tag = #llvm.tbaa_tag +#di_local_variable = #llvm.di_local_variable +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.struct<"struct.Foo", (i32, i32)> {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.dbg.declare #di_local_variable = %1 : !llvm.ptr + %2 = llvm.load %arg0 {alignment = 8 : i64, tbaa = [#tbaa_tag]} : !llvm.ptr -> i64 + llvm.store %2, %1 {alignment = 4 : i64, tbaa = [#tbaa_tag]} : i64, !llvm.ptr + llvm.call @escape(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @escape(!llvm.ptr) +} diff --git a/test/LLVMDialect/InstCombine/alloca-in-non-alloca-as.ll.mlir b/test/LLVMDialect/InstCombine/alloca-in-non-alloca-as.ll.mlir index 27e8d921b..24a554be4 100644 --- a/test/LLVMDialect/InstCombine/alloca-in-non-alloca-as.ll.mlir +++ b/test/LLVMDialect/InstCombine/alloca-in-non-alloca-as.ll.mlir @@ -1,26 +1,36 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.undef"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %2 = "llvm.alloca"(%1) : (i64) -> !llvm.ptr - %3 = "llvm.bitcast"(%2) : (!llvm.ptr) -> !llvm.ptr> - "llvm.store"(%0, %3) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.call"(%2, %3) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 4 : i64, sym_name = "__omp_offloading_802_ea0109_main_l8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr)>>> - %3 = "llvm.getelementptr"(%2, %0, %0) : (!llvm.ptr)>>>, i64, i64) -> !llvm.ptr)>> - "llvm.call"(%3) {callee = @zot, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr)>>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "spam", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "zot", type = !llvm.func)>>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<[160, 256, 256, 32]> : vector<4xi64>>, #dlti.dl_entry, dense<128> : vector<4xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry, dense<64> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<64> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 32 : i64>, #dlti.dl_entry<"dlti.alloca_memory_space", 5 : ui64>, #dlti.dl_entry<"dlti.global_memory_space", 1 : ui64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(!llvm.ptr) + llvm.func @use2(!llvm.ptr, !llvm.ptr) + llvm.func weak amdgpu_kernelcc @__omp_offloading_802_ea0109_main_l8(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.undef : !llvm.ptr + %2 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i64) -> !llvm.ptr + llvm.store %1, %2 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.call @use2(%2, %2) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @spam(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.array<30 x struct<"struct.widget", (array<8 x i8>)>> {alignment = 16 : i64} : (i32) -> !llvm.ptr + llvm.call @zot(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @alloca_addrspace_0_nonnull() -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.call @use(%2) : (!llvm.ptr) -> () + %3 = llvm.icmp "ne" %2, %1 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @alloca_addrspace_5_nonnull() -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.addressof @use : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr<5> + %3 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr<5> + llvm.call %1(%3) : !llvm.ptr, (!llvm.ptr<5>) -> () + %4 = llvm.icmp "ne" %3, %2 : !llvm.ptr<5> + llvm.return %4 : i1 + } + llvm.func hidden @zot(!llvm.ptr) +} diff --git a/test/LLVMDialect/InstCombine/alloca-intptr-not-sizet.ll.mlir b/test/LLVMDialect/InstCombine/alloca-intptr-not-sizet.ll.mlir new file mode 100644 index 000000000..09b1b114b --- /dev/null +++ b/test/LLVMDialect/InstCombine/alloca-intptr-not-sizet.ll.mlir @@ -0,0 +1,7 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<[128, 128, 128, 32]> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.alloca_memory_space", 7 : ui64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_array_alloca_intptr_not_sizet(%arg0: i64, %arg1: !llvm.ptr) { + %0 = llvm.alloca %arg0 x i8 {alignment = 1 : i64} : (i64) -> !llvm.ptr<7> + llvm.store %0, %arg1 {alignment = 16 : i64} : !llvm.ptr<7>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/alloca.ll.mlir b/test/LLVMDialect/InstCombine/alloca.ll.mlir new file mode 100644 index 000000000..086be683a --- /dev/null +++ b/test/LLVMDialect/InstCombine/alloca.ll.mlir @@ -0,0 +1,118 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @int(0 : i32) {addr_space = 0 : i32} : i32 + llvm.mlir.global external constant @opaque_global() {addr_space = 0 : i32, alignment = 4 : i64} : !llvm.struct<"opaque_type", opaque> + llvm.func @use(...) + llvm.func @test() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @int : !llvm.ptr + %3 = llvm.alloca %0 x !llvm.array<0 x i32> {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @use(%3) vararg(!llvm.func) : (!llvm.ptr) -> () + %4 = llvm.alloca %1 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @use(%4) vararg(!llvm.func) : (!llvm.ptr) -> () + %5 = llvm.alloca %0 x !llvm.struct<()> {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.call @use(%5) vararg(!llvm.func) : (!llvm.ptr) -> () + %6 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %7 = llvm.alloca %6 x !llvm.struct<(struct<()>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.call @use(%7) vararg(!llvm.func) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test2() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(123 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test3() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(123 : i32) : i32 + %3 = llvm.alloca %0 x !llvm.struct<(i32)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.getelementptr %3[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i32)> + llvm.store %2, %4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test4(%arg0: i32) -> !llvm.ptr { + %0 = llvm.alloca %arg0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test5() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(123 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.constant(4 : i32) : i32 + %5 = llvm.alloca %0 x !llvm.struct<(i32)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %6 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %5, %6 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.store %1, %6 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %2, %5 atomic unordered {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %3, %5 atomic release {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %4, %5 atomic seq_cst {alignment = 4 : i64} : i32, !llvm.ptr + %8 = llvm.addrspacecast %7 : !llvm.ptr to !llvm.ptr<1> + llvm.store %1, %8 {alignment = 4 : i64} : i32, !llvm.ptr<1> + llvm.return + } + llvm.func @f(!llvm.ptr) + llvm.func @test6() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(123 : i32) : i32 + %2 = llvm.alloca %0 x !llvm.struct<(i32)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store volatile %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.call @f(%3) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test7() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.addressof @opaque_global : !llvm.ptr + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.alloca %0 x !llvm.struct<"real_type", (struct<(i32, ptr)>)> {alignment = 4 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%3, %1, %2) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @test8() { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @use(%1) vararg(!llvm.func) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test9_aux(!llvm.ptr {llvm.inalloca = !llvm.struct)>}) + llvm.func @test9(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.intr.stacksave : !llvm.ptr + %3 = llvm.alloca inalloca %0 x !llvm.struct)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%3, %arg0, %1) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.call @test9_aux(%3) : (!llvm.ptr) -> () + llvm.intr.stackrestore %2 : !llvm.ptr + llvm.return + } + llvm.func @test10() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(1 : i33) : i33 + %3 = llvm.alloca %0 x i1 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %1 x i1 {alignment = 8 : i64} : (i64) -> !llvm.ptr + %5 = llvm.alloca %2 x i1 {alignment = 8 : i64} : (i33) -> !llvm.ptr + llvm.call @use(%3, %4, %5) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @test11() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @int : !llvm.ptr + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @use(%2) vararg(!llvm.func) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test_inalloca_with_element_count(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.alloca inalloca %0 x !llvm.struct<"struct_type", (i32, i32)> {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @test9_aux(%1) : (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/allocsize-32.ll.mlir b/test/LLVMDialect/InstCombine/allocsize-32.ll.mlir index 45205f05b..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/allocsize-32.ll.mlir +++ b/test/LLVMDialect/InstCombine/allocsize-32.ll.mlir @@ -1,23 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "my_malloc", type = !llvm.func (ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5000000000 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 100 : i64} : () -> i64 - %3 = "llvm.mlir.null"() : () -> !llvm.ptr - %4 = "llvm.call"(%3, %2) {callee = @my_malloc, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%4, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - %5 = "llvm.call"(%4, %1, %1, %1) {callee = @llvm.objectsize.i32.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i32 - "llvm.store"(%5, %arg1) : (i32, !llvm.ptr) -> () - %6 = "llvm.call"(%3, %0) {callee = @my_malloc, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%6, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - %7 = "llvm.call"(%6, %1, %1, %1) {callee = @llvm.objectsize.i32.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i32 - "llvm.store"(%7, %arg1) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_malloc", type = !llvm.func>, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.objectsize.i32.p0i8", type = !llvm.func, i1, i1, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/allocsize.ll.mlir b/test/LLVMDialect/InstCombine/allocsize.ll.mlir index 5bf60f7aa..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/allocsize.ll.mlir +++ b/test/LLVMDialect/InstCombine/allocsize.ll.mlir @@ -1,129 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "my_malloc", type = !llvm.func (ptr, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "my_calloc", type = !llvm.func (ptr, ptr, i32, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %2 = "llvm.mlir.null"() : () -> !llvm.ptr - %3 = "llvm.call"(%2, %1) {callee = @my_malloc, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%3, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - %4 = "llvm.call"(%3, %0, %0, %0) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.store"(%4, %arg1) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_malloc", type = !llvm.func>, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %3 = "llvm.mlir.null"() : () -> !llvm.ptr - %4 = "llvm.call"(%3, %3, %2, %1) {callee = @my_calloc, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> !llvm.ptr - "llvm.store"(%4, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - %5 = "llvm.call"(%4, %0, %0, %0) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.store"(%5, %arg1) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_calloc", type = !llvm.func>, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr - %2 = "llvm.call"(%1, %arg2) {callee = @my_malloc, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%2, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - %3 = "llvm.call"(%2, %0, %0, %0) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.store"(%3, %arg1) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_malloc_fails", type = !llvm.func>, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %3 = "llvm.mlir.null"() : () -> !llvm.ptr - %4 = "llvm.call"(%3, %3, %arg2, %2) {callee = @my_calloc, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> !llvm.ptr - "llvm.store"(%4, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - %5 = "llvm.call"(%4, %1, %1, %1) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.store"(%5, %arg1) : (i64, !llvm.ptr) -> () - %6 = "llvm.call"(%3, %3, %0, %arg2) {callee = @my_calloc, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> !llvm.ptr - "llvm.store"(%6, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - %7 = "llvm.call"(%6, %1, %1, %1) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.store"(%7, %arg1) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_calloc_fails", type = !llvm.func>, ptr, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "my_malloc_outofline", type = !llvm.func (ptr, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "my_calloc_outofline", type = !llvm.func (ptr, ptr, i32, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %3 = "llvm.mlir.null"() : () -> !llvm.ptr - %4 = "llvm.call"(%3, %2) {callee = @my_malloc_outofline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%4, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - %5 = "llvm.call"(%4, %1, %1, %1) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.store"(%5, %arg1) : (i64, !llvm.ptr) -> () - %6 = "llvm.call"(%3, %3, %2, %0) {callee = @my_calloc_outofline, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> !llvm.ptr - "llvm.store"(%6, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - %7 = "llvm.call"(%6, %1, %1, %1) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.store"(%7, %arg1) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_outofline", type = !llvm.func>, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "my_malloc_i64", type = !llvm.func (ptr, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "my_tiny_calloc", type = !llvm.func (ptr, ptr, i8, i8)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "my_varied_calloc", type = !llvm.func (ptr, ptr, i32, i8)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 1000 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 8589934592 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 4 : i8} : () -> i8 - %4 = "llvm.mlir.constant"() {value = 127 : i8} : () -> i8 - %5 = "llvm.mlir.constant"() {value = false} : () -> i1 - %6 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %7 = "llvm.mlir.constant"() {value = -2147483647 : i32} : () -> i32 - %8 = "llvm.mlir.null"() : () -> !llvm.ptr - %9 = "llvm.bitcast"(%arg1) : (!llvm.ptr) -> !llvm.ptr - %10 = "llvm.call"(%8, %8, %7, %6) {callee = @my_calloc, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> !llvm.ptr - "llvm.store"(%10, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - %11 = "llvm.call"(%10, %5, %5, %5) {callee = @llvm.objectsize.i32.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i32 - "llvm.store"(%11, %arg1) : (i32, !llvm.ptr) -> () - %12 = "llvm.call"(%8, %8, %4, %3) {callee = @my_tiny_calloc, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i8, i8) -> !llvm.ptr - "llvm.store"(%12, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - %13 = "llvm.call"(%12, %5, %5, %5) {callee = @llvm.objectsize.i32.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i32 - "llvm.store"(%13, %arg1) : (i32, !llvm.ptr) -> () - %14 = "llvm.call"(%8, %2) {callee = @my_malloc_i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%14, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - %15 = "llvm.call"(%14, %5, %5, %5) {callee = @llvm.objectsize.i32.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i32 - "llvm.store"(%15, %arg1) : (i32, !llvm.ptr) -> () - %16 = "llvm.call"(%14, %5, %5, %5) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.store"(%16, %9) : (i64, !llvm.ptr) -> () - %17 = "llvm.call"(%8, %8, %1, %0) {callee = @my_varied_calloc, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i8) -> !llvm.ptr - "llvm.store"(%17, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - %18 = "llvm.call"(%17, %5, %5, %5) {callee = @llvm.objectsize.i32.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i32 - "llvm.store"(%18, %arg1) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_overflow", type = !llvm.func>, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %2 = "llvm.mlir.null"() : () -> !llvm.ptr - %3 = "llvm.call"(%2, %1) {callee = @my_malloc, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%3, %arg0) : (!llvm.ptr, !llvm.ptr>) -> () - %4 = "llvm.call"(%3, %0, %0, %0) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.store"(%4, %arg1) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_nobuiltin", type = !llvm.func>, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.objectsize.i32.p0i8", type = !llvm.func, i1, i1, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.objectsize.i64.p0i8", type = !llvm.func, i1, i1, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/allow-checks.ll.mlir b/test/LLVMDialect/InstCombine/allow-checks.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/and-add-shl.ll.mlir b/test/LLVMDialect/InstCombine/and-add-shl.ll.mlir new file mode 100644 index 000000000..1463c0757 --- /dev/null +++ b/test/LLVMDialect/InstCombine/and-add-shl.ll.mlir @@ -0,0 +1,37 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @and_add_shl(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.mlir.constant(32 : i8) : i8 + %4 = llvm.icmp "ule" %arg0, %0 : i8 + "llvm.intr.assume"(%4) : (i1) -> () + %5 = llvm.shl %1, %arg0 : i8 + %6 = llvm.add %5, %2 : i8 + %7 = llvm.and %6, %3 : i8 + llvm.return %7 : i8 + } + llvm.func @and_not_shl(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(32 : i8) : i8 + %3 = llvm.icmp "ule" %arg0, %0 : i8 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.shl %1, %arg0 : i8 + %5 = llvm.xor %4, %1 : i8 + %6 = llvm.and %5, %2 : i8 + llvm.return %6 : i8 + } + llvm.func @and_add_shl_overlap(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.mlir.constant(32 : i8) : i8 + %4 = llvm.icmp "ule" %arg0, %0 : i8 + "llvm.intr.assume"(%4) : (i1) -> () + %5 = llvm.shl %1, %arg0 : i8 + %6 = llvm.add %5, %2 : i8 + %7 = llvm.and %6, %3 : i8 + llvm.return %7 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/and-compare.ll.mlir b/test/LLVMDialect/InstCombine/and-compare.ll.mlir new file mode 100644 index 000000000..cda7e5ff5 --- /dev/null +++ b/test/LLVMDialect/InstCombine/and-compare.ll.mlir @@ -0,0 +1,105 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @use.i8(i8) + llvm.func @test1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.icmp "ne" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @test1vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<65280> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg0, %0 : vector<2xi32> + %2 = llvm.and %arg1, %0 : vector<2xi32> + %3 = llvm.icmp "ne" %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test2(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(128 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.icmp "eq" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @test2vec(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<128> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.and %arg0, %0 : vector<2xi64> + %4 = llvm.icmp "eq" %3, %2 : vector<2xi64> + llvm.return %4 : vector<2xi1> + } + llvm.func @test3(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(128 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.icmp "ne" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @test3vec(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<128> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.and %arg0, %0 : vector<2xi64> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi64> + llvm.return %4 : vector<2xi1> + } + llvm.func @test_ne_cp2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-16 : i8) : i8 + %1 = llvm.mlir.constant(16 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg0, %1 : i8 + llvm.call @use.i8(%2) : (i8) -> () + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @test_ne_cp2_2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-4 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg0, %1 : i8 + llvm.call @use.i8(%2) : (i8) -> () + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.icmp "eq" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @test_ne_cp2_other_okay_all_ones(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i8) : i8 + %1 = llvm.mlir.constant(16 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg0, %1 : i8 + llvm.call @use.i8(%2) : (i8) -> () + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @test_ne_cp2_other_fail2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-16 : i8) : i8 + %1 = llvm.mlir.constant(17 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg0, %1 : i8 + llvm.call @use.i8(%2) : (i8) -> () + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @test_ne_cp2_other_okay(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i8) : i8 + %1 = llvm.mlir.constant(16 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg0, %1 : i8 + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @test_ne_cp2_other_okay2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i8) : i8 + %1 = llvm.mlir.constant(16 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg0, %1 : i8 + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %2 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/and-fcmp.ll.mlir b/test/LLVMDialect/InstCombine/and-fcmp.ll.mlir new file mode 100644 index 000000000..de9297fc2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/and-fcmp.ll.mlir @@ -0,0 +1,3215 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @PR1738(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ord" %arg0, %0 : f64 + %2 = llvm.fcmp "ord" %arg1, %0 : f64 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @PR1738_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.fcmp "ord" %arg0, %0 : f64 + %3 = llvm.fcmp "ord" %arg1, %0 : f64 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @PR1738_logical_noundef(%arg0: f64, %arg1: f64 {llvm.noundef}) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.fcmp "ord" %arg0, %0 : f64 + %3 = llvm.fcmp "ord" %arg1, %0 : f64 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @PR1738_vec_undef(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.undef : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.mlir.undef : vector<2xf64> + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<2xf64> + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<2xf64> + %12 = llvm.fcmp "ord" %arg0, %6 : vector<2xf64> + %13 = llvm.fcmp "ord" %arg1, %11 : vector<2xf64> + %14 = llvm.and %12, %13 : vector<2xi1> + llvm.return %14 : vector<2xi1> + } + llvm.func @PR1738_vec_poison(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.poison : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.mlir.undef : vector<2xf64> + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<2xf64> + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<2xf64> + %12 = llvm.fcmp "ord" %arg0, %6 : vector<2xf64> + %13 = llvm.fcmp "ord" %arg1, %11 : vector<2xf64> + %14 = llvm.and %12, %13 : vector<2xi1> + llvm.return %14 : vector<2xi1> + } + llvm.func @PR41069(%arg0: i1, %arg1: f32, %arg2: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ord" %arg1, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.and %1, %arg0 : i1 + %3 = llvm.fcmp "ord" %arg2, %0 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @PR41069_logical(%arg0: i1, %arg1: f32, %arg2: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.fcmp "ord" %arg1, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %1 : i1, i1 + %4 = llvm.fcmp "ord" %arg2, %0 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.select %3, %4, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @PR41069_commute(%arg0: i1, %arg1: f32, %arg2: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ord" %arg1, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.and %1, %arg0 : i1 + %3 = llvm.fcmp "ord" %arg2, %0 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.and %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @PR41069_commute_logical(%arg0: i1, %arg1: f32, %arg2: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.fcmp "ord" %arg1, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %1 : i1, i1 + %4 = llvm.fcmp "ord" %arg2, %0 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.select %4, %3, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @PR41069_vec(%arg0: vector<2xf64>, %arg1: vector<2xf64>, %arg2: vector<2xf64>, %arg3: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.undef : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %8 = llvm.fcmp "ord" %arg0, %arg1 : vector<2xf64> + %9 = llvm.fcmp "ord" %arg2, %6 : vector<2xf64> + %10 = llvm.and %8, %9 : vector<2xi1> + %11 = llvm.fcmp "ord" %arg3, %7 : vector<2xf64> + %12 = llvm.and %10, %11 : vector<2xi1> + llvm.return %12 : vector<2xi1> + } + llvm.func @PR41069_vec_commute(%arg0: vector<2xf64>, %arg1: vector<2xf64>, %arg2: vector<2xf64>, %arg3: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.undef : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %8 = llvm.fcmp "ord" %arg0, %arg1 : vector<2xf64> + %9 = llvm.fcmp "ord" %arg2, %6 : vector<2xf64> + %10 = llvm.and %8, %9 : vector<2xi1> + %11 = llvm.fcmp "ord" %arg3, %7 : vector<2xf64> + %12 = llvm.and %11, %10 : vector<2xi1> + llvm.return %12 : vector<2xi1> + } + llvm.func @PR15737(%arg0: f32, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.fcmp "ord" %arg0, %0 : f32 + %3 = llvm.fcmp "ord" %arg1, %1 : f64 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @PR15737_logical(%arg0: f32, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.fcmp "ord" %arg0, %0 : f32 + %4 = llvm.fcmp "ord" %arg1, %1 : f64 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t9(%arg0: vector<2xf32>, %arg1: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %3 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %4 = llvm.fcmp "ord" %arg0, %1 : vector<2xf32> + %5 = llvm.fcmp "ord" %arg1, %3 : vector<2xf64> + %6 = llvm.and %4, %5 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @fcmp_ord_nonzero(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ord" %arg0, %0 : f32 + %3 = llvm.fcmp "ord" %arg1, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @fcmp_ord_nonzero_logical(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.fcmp "ord" %arg0, %0 : f32 + %4 = llvm.fcmp "ord" %arg1, %1 : f32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @fcmp_ord_nonzero_vec(%arg0: vector<3xf32>, %arg1: vector<3xf32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.constant(dense<[3.000000e+00, 2.000000e+00, 1.000000e+00]> : vector<3xf32>) : vector<3xf32> + %2 = llvm.fcmp "ord" %arg0, %0 : vector<3xf32> + %3 = llvm.fcmp "ord" %arg1, %1 : vector<3xf32> + %4 = llvm.and %2, %3 : vector<3xi1> + llvm.return %4 : vector<3xi1> + } + llvm.func @auto_gen_0(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_0_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_0_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_1(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_1_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_1_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_2(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_2_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_2_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_3(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_3_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_3_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_4(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_4_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_4_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_5(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_5_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_5_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_6(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_6_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_6_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_7(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_7_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_7_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_8(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_8_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_8_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_9(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_9_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_9_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_10(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_10_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_10_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_11(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_11_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_11_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_12(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_12_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_12_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_13(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_13_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_13_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_14(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_14_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_14_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_15(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_15_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_15_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_16(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_16_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_16_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_17(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_17_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_17_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_18(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_18_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_18_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_19(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_19_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_19_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_20(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_20_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_20_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_21(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "one" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_21_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_21_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_22(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "one" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_22_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_22_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_23(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "one" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_23_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_23_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_24(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "one" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_24_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_24_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_25(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "one" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_25_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_25_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_26(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "one" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_26_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_26_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_27(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "one" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_27_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_27_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_28(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_28_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_28_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_29(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_29_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_29_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_30(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_30_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_30_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_31(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_31_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_31_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_32(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_32_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_32_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_33(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_33_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_33_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_34(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_34_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_34_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_35(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_35_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_35_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_36(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_36_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_36_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_37(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_37_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_37_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_38(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_38_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_38_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_39(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_39_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_39_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_40(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_40_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_40_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_41(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_41_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_41_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_42(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_42_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_42_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_43(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_43_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_43_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_44(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_44_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_44_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_45(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_45_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_45_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_46(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_46_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_46_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_47(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_47_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_47_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_48(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_48_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_48_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_49(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_49_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_49_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_50(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_50_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_50_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_51(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_51_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_51_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_52(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_52_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_52_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_53(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_53_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_53_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_54(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_54_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_54_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_55(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_55_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_55_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_56(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_56_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_56_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_57(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_57_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_57_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_58(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_58_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_58_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_59(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_59_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_59_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_60(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_60_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_60_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_61(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_61_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_61_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_62(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_62_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_62_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_63(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_63_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_63_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_64(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_64_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_64_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_65(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_65_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_65_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_66(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_66_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_66_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_67(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_67_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_67_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_68(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_68_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_68_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_69(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_69_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_69_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_70(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_70_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_70_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_71(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_71_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_71_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_72(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_72_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_72_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_73(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_73_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_73_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_74(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_74_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_74_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_75(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_75_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_75_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_76(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_76_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_76_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_77(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_77_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_77_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_78(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_78_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_78_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_79(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_79_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_79_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_80(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_80_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_80_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_81(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_81_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_81_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_82(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_82_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_82_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_83(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_83_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_83_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_84(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_84_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_84_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_85(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_85_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_85_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_86(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_86_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_86_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_87(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_87_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_87_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_88(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_88_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_88_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_89(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_89_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_89_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_90(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_90_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_90_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_91(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_91_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_91_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_92(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_92_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_92_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_93(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_93_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_93_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_94(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_94_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_94_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_95(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_95_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_95_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_96(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_96_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_96_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_97(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_97_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_97_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_98(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_98_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_98_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_99(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_99_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_99_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_100(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_100_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_100_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_101(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_101_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_101_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_102(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_102_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_102_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_103(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_103_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_103_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_104(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_104_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "une" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_104_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_105(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_105_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_105_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_106(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_106_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_106_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_107(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_107_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_107_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_108(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_108_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_108_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_109(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_109_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_109_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_110(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_110_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_110_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_111(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_111_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_111_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_112(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_112_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_112_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_113(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_113_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_113_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_114(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_114_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_114_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_115(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_115_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_115_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_116(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_116_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_116_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_117(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_117_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_117_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_118(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_118_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "une" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_118_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_119(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_119_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_119_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_120(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_120_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_120_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_121(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_121_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_121_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_122(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_122_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_122_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_123(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_123_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_123_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_124(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_124_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_124_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_125(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_125_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_125_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_126(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_126_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_126_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_127(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_127_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_127_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_128(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_128_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_128_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_129(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_129_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_129_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_130(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_130_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_130_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_131(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_131_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_131_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_132(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_132_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_132_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_133(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_133_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "une" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_133_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_134(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_134_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_134_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_135(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_135_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_135_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @intersect_fmf_1(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @intersect_fmf_2(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @intersect_fmf_3(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @intersect_fmf_4(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "uge" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_vector(%arg0: vector<2xf16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf16>) : vector<2xf16> + %2 = llvm.mlir.constant(dense<0x7C00> : vector<2xf16>) : vector<2xf16> + %3 = llvm.intr.fabs(%arg0) : (vector<2xf16>) -> vector<2xf16> + %4 = llvm.fcmp "ord" %3, %1 : vector<2xf16> + %5 = llvm.fcmp "uge" %3, %2 : vector<2xf16> + %6 = llvm.and %4, %5 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @clang_builtin_isnormal_inf_check_commute(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "uge" %2, %1 : f16 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_commute_nsz_rhs(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 {fastmathFlags = #llvm.fastmath} : f16 + %4 = llvm.fcmp "uge" %2, %1 : f16 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_commute_nsz_lhs(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "uge" %2, %1 {fastmathFlags = #llvm.fastmath} : f16 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_commute_nofabs_ueq(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.fcmp "ord" %arg0, %0 : f16 + %3 = llvm.fcmp "ueq" %arg0, %1 : f16 + %4 = llvm.and %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_commute_nsz(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 {fastmathFlags = #llvm.fastmath} : f16 + %4 = llvm.fcmp "uge" %2, %1 {fastmathFlags = #llvm.fastmath} : f16 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_ugt(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "ugt" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_ult(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "ult" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_ule(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "ule" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_ueq(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "ueq" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_une(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "une" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_uno(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "uno" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_ord(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "ord" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_oge(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "oge" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_olt(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "olt" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_ole(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "ole" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_oeq(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "oeq" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_unnececcary_fabs(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %arg0, %0 : f16 + %4 = llvm.fcmp "uge" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_not_ord(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "uno" %2, %0 : f16 + %4 = llvm.fcmp "uge" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_missing_fabs(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %arg0, %0 : f16 + %4 = llvm.fcmp "uge" %arg0, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_neg_inf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0xFC00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "uge" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_not_inf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(6.550400e+04 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "uge" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_nsz_lhs(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 {fastmathFlags = #llvm.fastmath} : f16 + %4 = llvm.fcmp "uge" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_nsz_rhs(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "uge" %2, %1 {fastmathFlags = #llvm.fastmath} : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_nsz(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %3 = llvm.fcmp "ord" %2, %0 {fastmathFlags = #llvm.fastmath} : f16 + %4 = llvm.fcmp "uge" %2, %1 {fastmathFlags = #llvm.fastmath} : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_fneg(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.fneg %arg0 : f16 + %3 = llvm.fcmp "ord" %2, %0 : f16 + %4 = llvm.fcmp "uge" %arg0, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @clang_builtin_isnormal_inf_check_copysign(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.intr.copysign(%arg0, %arg1) : (f16, f16) -> f16 + %3 = llvm.fcmp "ord" %arg0, %0 : f16 + %4 = llvm.fcmp "uge" %2, %1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @isnormal_logical_select_0(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %4 = llvm.fcmp "ord" %3, %0 : f16 + %5 = llvm.fcmp "uge" %3, %1 : f16 + %6 = llvm.select %4, %5, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @isnormal_logical_select_1(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %4 = llvm.fcmp "ord" %3, %0 : f16 + %5 = llvm.fcmp "uge" %3, %1 : f16 + %6 = llvm.select %5, %4, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @isnormal_logical_select_0_fmf0(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %4 = llvm.fcmp "ord" %3, %0 {fastmathFlags = #llvm.fastmath} : f16 + %5 = llvm.fcmp "uge" %3, %1 {fastmathFlags = #llvm.fastmath} : f16 + %6 = llvm.select %4, %5, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @isnormal_logical_select_0_fmf1(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0x7C00 : f16) : f16 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %4 = llvm.fcmp "ord" %3, %0 : f16 + %5 = llvm.fcmp "uge" %3, %1 {fastmathFlags = #llvm.fastmath} : f16 + %6 = llvm.select %4, %5, %2 : i1, i1 + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/and-narrow.ll.mlir b/test/LLVMDialect/InstCombine/and-narrow.ll.mlir index a2a19e96c..3a7aa28d1 100644 --- a/test/LLVMDialect/InstCombine/and-narrow.ll.mlir +++ b/test/LLVMDialect/InstCombine/and-narrow.ll.mlir @@ -1,131 +1,114 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 44 : i16} : () -> i16 - %1 = "llvm.zext"(%arg0) : (i8) -> i16 - %2 = "llvm.add"(%1, %0) : (i16, i16) -> i16 - %3 = "llvm.and"(%2, %1) : (i16, i16) -> i16 - "llvm.return"(%3) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "zext_add", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i16} : () -> i16 - %1 = "llvm.zext"(%arg0) : (i8) -> i16 - %2 = "llvm.sub"(%0, %1) : (i16, i16) -> i16 - %3 = "llvm.and"(%2, %1) : (i16, i16) -> i16 - "llvm.return"(%3) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "zext_sub", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i16} : () -> i16 - %1 = "llvm.zext"(%arg0) : (i8) -> i16 - %2 = "llvm.mul"(%1, %0) : (i16, i16) -> i16 - %3 = "llvm.and"(%2, %1) : (i16, i16) -> i16 - "llvm.return"(%3) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "zext_mul", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i16} : () -> i16 - %1 = "llvm.zext"(%arg0) : (i8) -> i16 - %2 = "llvm.lshr"(%1, %0) : (i16, i16) -> i16 - %3 = "llvm.and"(%2, %1) : (i16, i16) -> i16 - "llvm.return"(%3) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "zext_lshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i16} : () -> i16 - %1 = "llvm.zext"(%arg0) : (i8) -> i16 - %2 = "llvm.ashr"(%1, %0) : (i16, i16) -> i16 - %3 = "llvm.and"(%2, %1) : (i16, i16) -> i16 - "llvm.return"(%3) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "zext_ashr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i16} : () -> i16 - %1 = "llvm.zext"(%arg0) : (i8) -> i16 - %2 = "llvm.shl"(%1, %0) : (i16, i16) -> i16 - %3 = "llvm.and"(%2, %1) : (i16, i16) -> i16 - "llvm.return"(%3) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "zext_shl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[44, 42]> : vector<2xi16>} : () -> vector<2xi16> - %1 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi16> - %2 = "llvm.add"(%1, %0) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - %3 = "llvm.and"(%2, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - "llvm.return"(%3) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "zext_add_vec", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[-5, -4]> : vector<2xi16>} : () -> vector<2xi16> - %1 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi16> - %2 = "llvm.sub"(%0, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - %3 = "llvm.and"(%2, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - "llvm.return"(%3) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "zext_sub_vec", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[3, -2]> : vector<2xi16>} : () -> vector<2xi16> - %1 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi16> - %2 = "llvm.mul"(%1, %0) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - %3 = "llvm.and"(%2, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - "llvm.return"(%3) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "zext_mul_vec", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[4, 2]> : vector<2xi16>} : () -> vector<2xi16> - %1 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi16> - %2 = "llvm.lshr"(%1, %0) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - %3 = "llvm.and"(%2, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - "llvm.return"(%3) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "zext_lshr_vec", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[2, 3]> : vector<2xi16>} : () -> vector<2xi16> - %1 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi16> - %2 = "llvm.ashr"(%1, %0) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - %3 = "llvm.and"(%2, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - "llvm.return"(%3) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "zext_ashr_vec", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[3, 2]> : vector<2xi16>} : () -> vector<2xi16> - %1 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi16> - %2 = "llvm.shl"(%1, %0) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - %3 = "llvm.and"(%2, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - "llvm.return"(%3) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "zext_shl_vec", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[4, 8]> : vector<2xi16>} : () -> vector<2xi16> - %1 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi16> - %2 = "llvm.lshr"(%1, %0) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - %3 = "llvm.and"(%2, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - "llvm.return"(%3) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "zext_lshr_vec_overshift", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.undef"() : () -> vector<2xi16> - %1 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi16> - %2 = "llvm.lshr"(%1, %0) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - %3 = "llvm.and"(%2, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - "llvm.return"(%3) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "zext_lshr_vec_undef", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[8, 2]> : vector<2xi16>} : () -> vector<2xi16> - %1 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi16> - %2 = "llvm.shl"(%1, %0) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - %3 = "llvm.and"(%2, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - "llvm.return"(%3) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "zext_shl_vec_overshift", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.undef"() : () -> vector<2xi16> - %1 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi16> - %2 = "llvm.shl"(%1, %0) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - %3 = "llvm.and"(%2, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - "llvm.return"(%3) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "zext_shl_vec_undef", type = !llvm.func (vector<2xi8>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @zext_add(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(44 : i16) : i16 + %1 = llvm.zext %arg0 : i8 to i16 + %2 = llvm.add %1, %0 : i16 + %3 = llvm.and %2, %1 : i16 + llvm.return %3 : i16 + } + llvm.func @zext_sub(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(-5 : i16) : i16 + %1 = llvm.zext %arg0 : i8 to i16 + %2 = llvm.sub %0, %1 : i16 + %3 = llvm.and %2, %1 : i16 + llvm.return %3 : i16 + } + llvm.func @zext_mul(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(3 : i16) : i16 + %1 = llvm.zext %arg0 : i8 to i16 + %2 = llvm.mul %1, %0 : i16 + %3 = llvm.and %2, %1 : i16 + llvm.return %3 : i16 + } + llvm.func @zext_lshr(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = llvm.zext %arg0 : i8 to i16 + %2 = llvm.lshr %1, %0 : i16 + %3 = llvm.and %2, %1 : i16 + llvm.return %3 : i16 + } + llvm.func @zext_ashr(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(2 : i16) : i16 + %1 = llvm.zext %arg0 : i8 to i16 + %2 = llvm.ashr %1, %0 : i16 + %3 = llvm.and %2, %1 : i16 + llvm.return %3 : i16 + } + llvm.func @zext_shl(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(3 : i16) : i16 + %1 = llvm.zext %arg0 : i8 to i16 + %2 = llvm.shl %1, %0 : i16 + %3 = llvm.and %2, %1 : i16 + llvm.return %3 : i16 + } + llvm.func @zext_add_vec(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[44, 42]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi16> + %2 = llvm.add %1, %0 : vector<2xi16> + %3 = llvm.and %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @zext_sub_vec(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[-5, -4]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi16> + %2 = llvm.sub %0, %1 : vector<2xi16> + %3 = llvm.and %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @zext_mul_vec(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[3, -2]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi16> + %2 = llvm.mul %1, %0 : vector<2xi16> + %3 = llvm.and %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @zext_lshr_vec(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[4, 2]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi16> + %2 = llvm.lshr %1, %0 : vector<2xi16> + %3 = llvm.and %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @zext_ashr_vec(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[2, 3]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi16> + %2 = llvm.ashr %1, %0 : vector<2xi16> + %3 = llvm.and %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @zext_shl_vec(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[3, 2]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi16> + %2 = llvm.shl %1, %0 : vector<2xi16> + %3 = llvm.and %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @zext_lshr_vec_overshift(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[4, 8]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi16> + %2 = llvm.lshr %1, %0 : vector<2xi16> + %3 = llvm.and %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @zext_lshr_vec_undef(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.undef : vector<2xi16> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi16> + %2 = llvm.lshr %1, %0 : vector<2xi16> + %3 = llvm.and %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @zext_shl_vec_overshift(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[8, 2]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi16> + %2 = llvm.shl %1, %0 : vector<2xi16> + %3 = llvm.and %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @zext_shl_vec_undef(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.undef : vector<2xi16> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi16> + %2 = llvm.shl %1, %0 : vector<2xi16> + %3 = llvm.and %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi16> + } +} diff --git a/test/LLVMDialect/InstCombine/and-or-and.ll.mlir b/test/LLVMDialect/InstCombine/and-or-and.ll.mlir index 75cd8cb90..f52644799 100644 --- a/test/LLVMDialect/InstCombine/and-or-and.ll.mlir +++ b/test/LLVMDialect/InstCombine/and-or-and.ll.mlir @@ -1,53 +1,46 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.and"(%arg1, %0) : (i32, i32) -> i32 - %4 = "llvm.or"(%2, %3) : (i32, i32) -> i32 - %5 = "llvm.and"(%4, %1) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 65536 : i32} : () -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.shl"(%arg1, %0) : (i32, i32) -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg1, %1) : (i32, i32) -> i32 - %3 = "llvm.or"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.and"(%3, %0) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.or"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "or_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -128 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %2 = "llvm.shl"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.or"(%2, %0) : (i8, i8) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "or_test2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.or %2, %3 : i32 + %5 = llvm.and %4, %0 : i32 + llvm.return %5 : i32 + } + llvm.func @test2(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.or %arg0, %1 : i32 + %3 = llvm.and %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @test3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %arg1, %0 : i32 + %2 = llvm.or %arg0, %1 : i32 + %3 = llvm.and %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @test4(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.lshr %arg1, %0 : i32 + %3 = llvm.or %arg0, %2 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @or_test1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.or %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @or_test2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i8 + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/and-or-icmp-const-icmp.ll.mlir b/test/LLVMDialect/InstCombine/and-or-icmp-const-icmp.ll.mlir new file mode 100644 index 000000000..b74cde90d --- /dev/null +++ b/test/LLVMDialect/InstCombine/and-or-icmp-const-icmp.ll.mlir @@ -0,0 +1,174 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @eq_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ne_basic_equal_5(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-5 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "ne" %arg0, %1 : i8 + %4 = llvm.icmp "ule" %2, %arg1 : i8 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @eq_basic_equal_minus_1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "eq" %arg0, %1 : i8 + %4 = llvm.icmp "ugt" %2, %arg1 : i8 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @ne_basic_equal_minus_7(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-7 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "ne" %arg0, %1 : i8 + %4 = llvm.icmp "ule" %2, %arg1 : i8 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @eq_basic_unequal(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-5 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "eq" %arg0, %1 : i8 + %4 = llvm.icmp "ugt" %2, %arg1 : i8 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @ne_basic_unequal(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-4 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "ne" %arg0, %1 : i8 + %4 = llvm.icmp "ule" %2, %arg1 : i8 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @eq_multi_c1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.call @use(%1) : (i1) -> () + llvm.return %3 : i1 + } + llvm.func @ne_multi_c2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ne" %arg0, %0 : i8 + %2 = llvm.icmp "ule" %arg0, %arg1 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.call @use(%2) : (i1) -> () + llvm.return %3 : i1 + } + llvm.func @eq_vector(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.icmp "eq" %arg0, %1 : vector<2xi8> + %3 = llvm.icmp "ugt" %arg0, %arg1 : vector<2xi8> + %4 = llvm.or %2, %3 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @ne_vector_equal_5(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "ne" %arg0, %1 : vector<2xi8> + %4 = llvm.icmp "ule" %2, %arg1 : vector<2xi8> + %5 = llvm.and %3, %4 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @eq_vector_equal_minus_1(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "eq" %arg0, %1 : vector<2xi8> + %4 = llvm.icmp "ugt" %2, %arg1 : vector<2xi8> + %5 = llvm.or %3, %4 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @ne_vector_equal_minus_7(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-7> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "ne" %arg0, %1 : vector<2xi8> + %4 = llvm.icmp "ule" %2, %arg1 : vector<2xi8> + %5 = llvm.and %3, %4 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @eq_vector_unequal1(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "eq" %arg0, %1 : vector<2xi8> + %4 = llvm.icmp "ugt" %2, %arg1 : vector<2xi8> + %5 = llvm.or %3, %4 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @ne_vector_unequal2(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-3> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "ne" %arg0, %1 : vector<2xi8> + %4 = llvm.icmp "ule" %2, %arg1 : vector<2xi8> + %5 = llvm.and %3, %4 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @eq_vector_poison_icmp(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(5 : i8) : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.add %arg0, %0 : vector<2xi8> + %9 = llvm.icmp "eq" %arg0, %7 : vector<2xi8> + %10 = llvm.icmp "ugt" %8, %arg1 : vector<2xi8> + %11 = llvm.or %9, %10 : vector<2xi1> + llvm.return %11 : vector<2xi1> + } + llvm.func @eq_vector_poison_add(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-5 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %8 = llvm.add %arg0, %6 : vector<2xi8> + %9 = llvm.icmp "eq" %arg0, %7 : vector<2xi8> + %10 = llvm.icmp "ugt" %8, %arg1 : vector<2xi8> + %11 = llvm.or %9, %10 : vector<2xi1> + llvm.return %11 : vector<2xi1> + } + llvm.func @eq_commuted(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(43 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.sdiv %0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %1 : i8 + %4 = llvm.icmp "ult" %2, %arg0 : i8 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @ne_commuted_equal_minus_1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.sdiv %0, %arg1 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.icmp "ne" %arg0, %2 : i8 + %6 = llvm.icmp "uge" %3, %4 : i8 + %7 = llvm.and %5, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @use(i1) +} diff --git a/test/LLVMDialect/InstCombine/and-or-icmp-min-max.ll.mlir b/test/LLVMDialect/InstCombine/and-or-icmp-min-max.ll.mlir new file mode 100644 index 000000000..31a6871a9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/and-or-icmp-min-max.ll.mlir @@ -0,0 +1,1434 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @slt_and_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_and_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @slt_and_max_commute(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.icmp "slt" %arg0, %arg1 : vector<2xi8> + %2 = llvm.icmp "eq" %arg0, %0 : vector<2xi8> + %3 = llvm.and %2, %1 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @slt_swap_and_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sgt" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_swap_and_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sgt" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @slt_swap_and_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sgt" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_swap_and_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sgt" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ult_and_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ult" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ult_and_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ult" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ult_and_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ult" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ult_and_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ult" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ult_swap_and_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ult_swap_and_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ult_swap_and_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ult_swap_and_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_and_min(%arg0: i9, %arg1: i9) -> i1 { + %0 = llvm.mlir.constant(-256 : i9) : i9 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i9 + %2 = llvm.icmp "eq" %arg0, %0 : i9 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_and_min_logical(%arg0: i9, %arg1: i9) -> i1 { + %0 = llvm.mlir.constant(-256 : i9) : i9 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i9 + %3 = llvm.icmp "eq" %arg0, %0 : i9 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_and_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_and_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_swap_and_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "slt" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_swap_and_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_swap_and_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "slt" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_swap_and_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_and_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_and_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_and_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_and_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_swap_and_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ult" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_swap_and_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ult" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_swap_and_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ult" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_swap_and_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ult" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sge_or_not_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sge" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sge_or_not_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sge" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sge_or_not_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sge" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sge_or_not_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sge" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sge_swap_or_not_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sle" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sge_swap_or_not_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sle" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sge_swap_or_not_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sle" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sge_swap_or_not_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sle" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @uge_or_not_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "uge" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @uge_or_not_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "uge" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @uge_or_not_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "uge" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @uge_or_not_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "uge" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @uge_swap_or_not_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ule" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @uge_swap_or_not_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ule" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @uge_swap_or_not_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ule" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @uge_swap_or_not_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ule" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sle_or_not_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sle" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sle_or_not_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sle" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sle_or_not_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sle" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sle_or_not_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sle" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sle_swap_or_not_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sge" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sle_swap_or_not_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sge" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sle_swap_or_not_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sge" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sle_swap_or_not_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sge" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_or_not_min(%arg0: i427, %arg1: i427) -> i1 { + %0 = llvm.mlir.constant(0 : i427) : i427 + %1 = llvm.icmp "ule" %arg0, %arg1 : i427 + %2 = llvm.icmp "ne" %arg0, %0 : i427 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_or_not_min_logical(%arg0: i427, %arg1: i427) -> i1 { + %0 = llvm.mlir.constant(0 : i427) : i427 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ule" %arg0, %arg1 : i427 + %3 = llvm.icmp "ne" %arg0, %0 : i427 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_or_not_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ule" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_or_not_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ule" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_swap_or_not_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "uge" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_swap_or_not_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "uge" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_swap_or_not_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "uge" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_swap_or_not_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "uge" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sge_and_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sge" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sge_and_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sge" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sge_and_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sge" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sge_and_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sge" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sge_swap_and_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sle" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sge_swap_and_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sle" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sge_swap_and_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sle" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sge_swap_and_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sle" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @uge_and_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "uge" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @uge_and_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "uge" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @uge_and_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "uge" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @uge_and_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "uge" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @uge_swap_and_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ule" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @uge_swap_and_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ule" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @uge_swap_and_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ule" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @uge_swap_and_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ule" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sle_and_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sle" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sle_and_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sle" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sle_and_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sle" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sle_and_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sle" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sle_swap_and_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sge" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sle_swap_and_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sge" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sle_swap_and_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sge" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sle_swap_and_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sge" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_and_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ule" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_and_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ule" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_and_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ule" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_and_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ule" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_swap_and_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "uge" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_swap_and_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "uge" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_swap_and_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "uge" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_swap_and_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "uge" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sge_or_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sge" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sge_or_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sge" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sge_or_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sge" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sge_or_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sge" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sge_swap_or_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sle" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sge_swap_or_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sle" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sge_swap_or_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sle" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sge_swap_or_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sle" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @uge_or_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "uge" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @uge_or_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "uge" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @uge_or_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "uge" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @uge_or_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "uge" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @uge_swap_or_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ule" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @uge_swap_or_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ule" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @uge_swap_or_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ule" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @uge_swap_or_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ule" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sle_or_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sle" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sle_or_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sle" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sle_or_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sle" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sle_or_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sle" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sle_swap_or_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sge" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sle_swap_or_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sge" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sle_swap_or_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sge" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sle_swap_or_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sge" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_or_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ule" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_or_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ule" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_or_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ule" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_or_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ule" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_swap_or_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "uge" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_swap_or_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "uge" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_swap_or_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "uge" %arg1, %arg0 : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_swap_or_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "uge" %arg1, %arg0 : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @slt_and_not_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_and_not_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @slt_and_not_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_and_not_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @slt_swap_and_not_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sgt" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_swap_and_not_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sgt" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @slt_swap_and_not_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sgt" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_swap_and_not_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sgt" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ult_and_not_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ult" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ult_and_not_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ult" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ult_and_not_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ult" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ult_and_not_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ult" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ult_swap_and_not_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ult_swap_and_not_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ult_swap_and_not_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ult_swap_and_not_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_and_not_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_and_not_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_and_not_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_and_not_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_swap_and_not_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "slt" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_swap_and_not_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_swap_and_not_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "slt" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_swap_and_not_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_and_not_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_and_not_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_and_not_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_and_not_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_swap_and_not_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ult" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_swap_and_not_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ult" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_swap_and_not_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ult" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_swap_and_not_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ult" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @slt_or_not_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_or_not_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "slt" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @slt_or_not_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_or_not_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "slt" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @slt_swap_or_not_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sgt" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_swap_or_not_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sgt" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @slt_swap_or_not_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "sgt" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_swap_or_not_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sgt" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ult_or_not_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ult" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ult_or_not_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ult" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ult_or_not_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ult" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ult_or_not_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ult" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ult_swap_or_not_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ult_swap_or_not_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ult_swap_or_not_max_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ult_swap_or_not_max_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_or_not_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_or_not_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_or_not_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_or_not_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_swap_or_not_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "slt" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_swap_or_not_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "slt" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_swap_or_not_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "slt" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_swap_or_not_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "slt" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_or_not_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_or_not_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_or_not_min_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_or_not_min_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_swap_or_not_min(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ult" %arg1, %arg0 : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_swap_or_not_min_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ult" %arg1, %arg0 : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_swap_or_not_min_commute(%arg0: i823, %arg1: i823) -> i1 { + %0 = llvm.mlir.constant(0 : i823) : i823 + %1 = llvm.icmp "ult" %arg1, %arg0 : i823 + %2 = llvm.icmp "ne" %arg0, %0 : i823 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_swap_or_not_min_commute_logical(%arg0: i823, %arg1: i823) -> i1 { + %0 = llvm.mlir.constant(0 : i823) : i823 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ult" %arg1, %arg0 : i823 + %3 = llvm.icmp "ne" %arg0, %0 : i823 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/and-or-icmp-nullptr.ll.mlir b/test/LLVMDialect/InstCombine/and-or-icmp-nullptr.ll.mlir new file mode 100644 index 000000000..f9a02a175 --- /dev/null +++ b/test/LLVMDialect/InstCombine/and-or-icmp-nullptr.ll.mlir @@ -0,0 +1,452 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @ugt_and_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ugt" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_and_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ugt" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_and_min_commute(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ugt" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_and_min_commute_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ugt" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_swap_and_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ult" %arg1, %arg0 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_swap_and_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ult" %arg1, %arg0 : !llvm.ptr + %3 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_swap_and_min_commute(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ult" %arg1, %arg0 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_swap_and_min_commute_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ult" %arg1, %arg0 : !llvm.ptr + %3 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_or_not_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ule" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_or_not_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ule" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_or_not_min_commute(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ule" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_or_not_min_commute_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ule" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_swap_or_not_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "uge" %arg1, %arg0 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_swap_or_not_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "uge" %arg1, %arg0 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_swap_or_not_min_commute(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "uge" %arg1, %arg0 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_swap_or_not_min_commute_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "uge" %arg1, %arg0 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_and_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ule" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_and_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ule" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_and_min_commute(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ule" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_and_min_commute_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ule" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_swap_and_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "uge" %arg1, %arg0 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_swap_and_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "uge" %arg1, %arg0 : !llvm.ptr + %3 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_swap_and_min_commute(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "uge" %arg1, %arg0 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_swap_and_min_commute_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "uge" %arg1, %arg0 : !llvm.ptr + %3 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_or_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ule" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_or_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ule" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_or_min_commute(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ule" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_or_min_commute_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ule" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_swap_or_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "uge" %arg1, %arg0 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_swap_or_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "uge" %arg1, %arg0 : !llvm.ptr + %3 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ule_swap_or_min_commute(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "uge" %arg1, %arg0 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ule_swap_or_min_commute_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "uge" %arg1, %arg0 : !llvm.ptr + %3 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_and_not_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ugt" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_and_not_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ugt" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_and_not_min_commute(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ugt" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_and_not_min_commute_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ugt" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_swap_and_not_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ult" %arg1, %arg0 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_swap_and_not_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ult" %arg1, %arg0 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_swap_and_not_min_commute(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ult" %arg1, %arg0 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_swap_and_not_min_commute_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ult" %arg1, %arg0 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_or_not_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ugt" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_or_not_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ugt" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_or_not_min_commute(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ugt" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_or_not_min_commute_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ugt" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_swap_or_not_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ult" %arg1, %arg0 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_swap_or_not_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ult" %arg1, %arg0 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @ugt_swap_or_not_min_commute(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ult" %arg1, %arg0 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @ugt_swap_or_not_min_commute_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ult" %arg1, %arg0 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_and_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "sgt" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_and_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sgt" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sle_or_not_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "sle" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sle_or_not_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sle" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sle_and_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "sle" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sle_and_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sle" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_and_not_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "sgt" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_and_not_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sgt" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sgt_or_not_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "sgt" %arg0, %arg1 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_or_not_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sgt" %arg0, %arg1 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @slt_and_min(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %2 = llvm.icmp "slt" %arg0, %arg1 : !llvm.ptr + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_and_min_logical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %3 = llvm.icmp "slt" %arg0, %arg1 : !llvm.ptr + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/and-or-icmps.ll.mlir b/test/LLVMDialect/InstCombine/and-or-icmps.ll.mlir new file mode 100644 index 000000000..4d09de858 --- /dev/null +++ b/test/LLVMDialect/InstCombine/and-or-icmps.ll.mlir @@ -0,0 +1,2112 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i1) + llvm.func @use32(i32) + llvm.func @PR1817_1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @PR1817_1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @PR1817_2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @PR1817_2_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @PR2330(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.icmp "ult" %arg0, %0 : i32 + %2 = llvm.icmp "ult" %arg1, %0 : i32 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @PR2330_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.icmp "ult" %arg1, %0 : i32 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @or_eq_with_one_bit_diff_constants1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(50 : i32) : i32 + %1 = llvm.mlir.constant(51 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.icmp "eq" %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @or_eq_with_one_bit_diff_constants1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(50 : i32) : i32 + %1 = llvm.mlir.constant(51 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @and_ne_with_one_bit_diff_constants1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(51 : i32) : i32 + %1 = llvm.mlir.constant(50 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + %3 = llvm.icmp "ne" %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @and_ne_with_one_bit_diff_constants1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(51 : i32) : i32 + %1 = llvm.mlir.constant(50 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "ne" %arg0, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @or_eq_with_one_bit_diff_constants2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(97 : i32) : i32 + %1 = llvm.mlir.constant(65 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.icmp "eq" %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @or_eq_with_one_bit_diff_constants2_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(97 : i32) : i32 + %1 = llvm.mlir.constant(65 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @and_ne_with_one_bit_diff_constants2(%arg0: i19) -> i1 { + %0 = llvm.mlir.constant(65 : i19) : i19 + %1 = llvm.mlir.constant(193 : i19) : i19 + %2 = llvm.icmp "ne" %arg0, %0 : i19 + %3 = llvm.icmp "ne" %arg0, %1 : i19 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @and_ne_with_one_bit_diff_constants2_logical(%arg0: i19) -> i1 { + %0 = llvm.mlir.constant(65 : i19) : i19 + %1 = llvm.mlir.constant(193 : i19) : i19 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "ne" %arg0, %0 : i19 + %4 = llvm.icmp "ne" %arg0, %1 : i19 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @or_eq_with_one_bit_diff_constants3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(126 : i8) : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.icmp "eq" %arg0, %1 : i8 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @or_eq_with_one_bit_diff_constants3_logical(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(126 : i8) : i8 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.icmp "eq" %arg0, %1 : i8 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @and_ne_with_one_bit_diff_constants3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(65 : i8) : i8 + %1 = llvm.mlir.constant(-63 : i8) : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.icmp "ne" %arg0, %1 : i8 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @and_ne_with_one_bit_diff_constants3_logical(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(65 : i8) : i8 + %1 = llvm.mlir.constant(-63 : i8) : i8 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + %4 = llvm.icmp "ne" %arg0, %1 : i8 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @or_eq_with_diff_one(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(13 : i8) : i8 + %1 = llvm.mlir.constant(14 : i8) : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.icmp "eq" %arg0, %1 : i8 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @or_eq_with_diff_one_logical(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(13 : i8) : i8 + %1 = llvm.mlir.constant(14 : i8) : i8 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.icmp "eq" %arg0, %1 : i8 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @and_ne_with_diff_one(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(40 : i32) : i32 + %1 = llvm.mlir.constant(39 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + %3 = llvm.icmp "ne" %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @and_ne_with_diff_one_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(40 : i32) : i32 + %1 = llvm.mlir.constant(39 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "ne" %arg0, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @or_eq_with_diff_one_signed(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.icmp "eq" %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @or_eq_with_diff_one_signed_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @and_ne_with_diff_one_signed(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.icmp "ne" %arg0, %0 : i64 + %3 = llvm.icmp "ne" %arg0, %1 : i64 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @and_ne_with_diff_one_signed_logical(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "ne" %arg0, %0 : i64 + %4 = llvm.icmp "ne" %arg0, %1 : i64 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @or_eq_with_one_bit_diff_constants2_splatvec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<97> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<65> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "eq" %arg0, %0 : vector<2xi32> + %3 = llvm.icmp "eq" %arg0, %1 : vector<2xi32> + %4 = llvm.or %2, %3 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @and_ne_with_diff_one_splatvec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<40> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<39> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "ne" %arg0, %0 : vector<2xi32> + %3 = llvm.icmp "ne" %arg0, %1 : vector<2xi32> + %4 = llvm.and %2, %3 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @simplify_before_foldAndOfICmps(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.mlir.undef : i16 + %6 = llvm.mlir.zero : !llvm.ptr + %7 = llvm.alloca %0 x i16 {alignment = 2 : i64} : (i32) -> !llvm.ptr + %8 = llvm.load %7 {alignment = 2 : i64} : !llvm.ptr -> i16 + %9 = llvm.getelementptr %7[%1] : (!llvm.ptr, i8) -> !llvm.ptr, i16 + %10 = llvm.udiv %8, %2 : i16 + %11 = llvm.getelementptr %7[%10] : (!llvm.ptr, i16) -> !llvm.ptr, i16 + %12 = llvm.load %11 {alignment = 2 : i64} : !llvm.ptr -> i16 + %13 = llvm.load %11 {alignment = 2 : i64} : !llvm.ptr -> i16 + %14 = llvm.mul %10, %10 : i16 + %15 = llvm.load %7 {alignment = 2 : i64} : !llvm.ptr -> i16 + %16 = llvm.sdiv %8, %15 : i16 + %17 = llvm.sub %3, %16 : i16 + %18 = llvm.mul %14, %17 : i16 + %19 = llvm.icmp "ugt" %13, %10 : i16 + %20 = llvm.and %8, %12 : i16 + %21 = llvm.mul %19, %4 : i1 + %22 = llvm.icmp "sle" %16, %13 : i16 + %23 = llvm.icmp "ule" %16, %13 : i16 + %24 = llvm.icmp "slt" %20, %3 : i16 + %25 = llvm.srem %15, %18 : i16 + %26 = llvm.add %24, %19 : i1 + %27 = llvm.add %23, %26 : i1 + %28 = llvm.icmp "sge" %23, %27 : i1 + %29 = llvm.or %25, %15 : i16 + %30 = llvm.icmp "uge" %22, %21 : i1 + %31 = llvm.icmp "ult" %30, %28 : i1 + llvm.store %5, %9 {alignment = 2 : i64} : i16, !llvm.ptr + %32 = llvm.icmp "ule" %19, %24 : i1 + %33 = llvm.getelementptr %6[%31] : (!llvm.ptr, i1) -> !llvm.ptr, i1 + llvm.store %29, %arg0 {alignment = 2 : i64} : i16, !llvm.ptr + llvm.store %32, %arg0 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.store %33, %arg0 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @PR42691_1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.icmp "eq" %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @PR42691_1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @PR42691_2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.icmp "eq" %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @PR42691_2_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @PR42691_3(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.icmp "sge" %arg0, %0 : i32 + %3 = llvm.icmp "eq" %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @PR42691_3_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "sge" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @PR42691_4(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "uge" %arg0, %0 : i32 + %3 = llvm.icmp "eq" %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @PR42691_4_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "uge" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @PR42691_5(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.icmp "eq" %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @PR42691_5_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @PR42691_6(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483647 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.icmp "eq" %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @PR42691_6_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483647 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @PR42691_7(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "uge" %arg0, %0 : i32 + %3 = llvm.icmp "eq" %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @PR42691_7_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "uge" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @PR42691_8(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.icmp "ne" %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @PR42691_8_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @PR42691_9(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(13 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "ne" %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @PR42691_9_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(13 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @PR42691_10(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(13 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %0 : i32 + %3 = llvm.icmp "ne" %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @PR42691_10_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(13 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @substitute_constant_and_eq_eq(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.icmp "eq" %arg0, %arg1 : i8 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @substitute_constant_and_eq_eq_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.icmp "eq" %arg0, %arg1 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @substitute_constant_and_eq_eq_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.icmp "eq" %arg0, %arg1 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @substitute_constant_and_eq_eq_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.icmp "eq" %arg0, %arg1 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @substitute_constant_and_eq_ugt_swap(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @substitute_constant_and_eq_ugt_swap_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @substitute_constant_and_eq_ne_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[42, 97]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.icmp "eq" %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "ne" %arg0, %arg1 : vector<2xi8> + %3 = llvm.and %1, %2 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @substitute_constant_and_eq_ne_vec_logical(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[42, 97]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %3 = llvm.icmp "eq" %arg0, %0 : vector<2xi8> + %4 = llvm.icmp "ne" %arg0, %arg1 : vector<2xi8> + %5 = llvm.select %3, %4, %2 : vector<2xi1>, vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @substitute_constant_and_eq_sgt_use(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @substitute_constant_and_eq_sgt_use_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @substitute_constant_and_eq_sgt_use2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i8 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @substitute_constant_and_eq_sgt_use2_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %arg0, %arg1 : i8 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @slt_and_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.icmp "slt" %arg0, %arg1 : i8 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_and_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.icmp "slt" %arg0, %arg1 : i8 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @sge_and_max(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.icmp "sge" %arg0, %arg1 : i8 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @sge_and_max_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.icmp "sge" %arg0, %arg1 : i8 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @substitute_constant_and_ne_ugt_swap(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.icmp "ne" %arg0, %0 : i8 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @substitute_constant_and_ne_ugt_swap_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.icmp "ugt" %arg1, %arg0 : i8 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @substitute_constant_or_ne_swap_sle(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.icmp "ne" %arg0, %0 : i8 + %2 = llvm.icmp "sle" %arg1, %arg0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @substitute_constant_or_ne_swap_sle_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.icmp "sle" %arg1, %arg0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @substitute_constant_or_ne_uge_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.icmp "ne" %arg0, %0 : i8 + %2 = llvm.icmp "uge" %arg0, %arg1 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @substitute_constant_or_ne_uge_commute_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.icmp "uge" %arg0, %arg1 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @substitute_constant_or_ne_slt_swap_vec_undef(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.undef : i8 + %1 = llvm.mlir.constant(42 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.icmp "ne" %arg0, %6 : vector<2xi8> + %8 = llvm.icmp "slt" %arg1, %arg0 : vector<2xi8> + %9 = llvm.or %7, %8 : vector<2xi1> + llvm.return %9 : vector<2xi1> + } + llvm.func @substitute_constant_or_ne_slt_swap_vec_poison(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(42 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.icmp "ne" %arg0, %6 : vector<2xi8> + %8 = llvm.icmp "slt" %arg1, %arg0 : vector<2xi8> + %9 = llvm.or %7, %8 : vector<2xi1> + llvm.return %9 : vector<2xi1> + } + llvm.func @substitute_constant_or_ne_slt_swap_vec_logical(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(42 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(true) : i1 + %8 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %9 = llvm.icmp "ne" %arg0, %6 : vector<2xi8> + %10 = llvm.icmp "slt" %arg1, %arg0 : vector<2xi8> + %11 = llvm.select %9, %8, %10 : vector<2xi1>, vector<2xi1> + llvm.return %11 : vector<2xi1> + } + llvm.func @substitute_constant_or_eq_swap_ne(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.icmp "ne" %arg1, %arg0 : i8 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @substitute_constant_or_eq_swap_ne_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.icmp "ne" %arg1, %arg0 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @substitute_constant_or_ne_sge_use(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.icmp "ne" %arg0, %0 : i8 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.icmp "sge" %arg0, %arg1 : i8 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @substitute_constant_or_ne_sge_use_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sge" %arg0, %arg1 : i8 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @substitute_constant_or_ne_ule_use2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.icmp "ne" %arg0, %0 : i8 + %2 = llvm.icmp "ule" %arg0, %arg1 : i8 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @substitute_constant_or_ne_ule_use2_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.icmp "ule" %arg0, %arg1 : i8 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @or_ranges_overlap(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.mlir.constant(20 : i8) : i8 + %3 = llvm.icmp "uge" %arg0, %0 : i8 + %4 = llvm.icmp "ule" %arg0, %1 : i8 + %5 = llvm.and %3, %4 : i1 + %6 = llvm.icmp "uge" %arg0, %1 : i8 + %7 = llvm.icmp "ule" %arg0, %2 : i8 + %8 = llvm.and %6, %7 : i1 + %9 = llvm.or %5, %8 : i1 + llvm.return %9 : i1 + } + llvm.func @or_ranges_adjacent(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.mlir.constant(11 : i8) : i8 + %3 = llvm.mlir.constant(20 : i8) : i8 + %4 = llvm.icmp "uge" %arg0, %0 : i8 + %5 = llvm.icmp "ule" %arg0, %1 : i8 + %6 = llvm.and %4, %5 : i1 + %7 = llvm.icmp "uge" %arg0, %2 : i8 + %8 = llvm.icmp "ule" %arg0, %3 : i8 + %9 = llvm.and %7, %8 : i1 + %10 = llvm.or %6, %9 : i1 + llvm.return %10 : i1 + } + llvm.func @or_ranges_separated(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.mlir.constant(12 : i8) : i8 + %3 = llvm.mlir.constant(20 : i8) : i8 + %4 = llvm.icmp "uge" %arg0, %0 : i8 + %5 = llvm.icmp "ule" %arg0, %1 : i8 + %6 = llvm.and %4, %5 : i1 + %7 = llvm.icmp "uge" %arg0, %2 : i8 + %8 = llvm.icmp "ule" %arg0, %3 : i8 + %9 = llvm.and %7, %8 : i1 + %10 = llvm.or %6, %9 : i1 + llvm.return %10 : i1 + } + llvm.func @or_ranges_single_elem_right(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.mlir.constant(11 : i8) : i8 + %3 = llvm.icmp "uge" %arg0, %0 : i8 + %4 = llvm.icmp "ule" %arg0, %1 : i8 + %5 = llvm.and %3, %4 : i1 + %6 = llvm.icmp "eq" %arg0, %2 : i8 + %7 = llvm.or %5, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_ranges_single_elem_left(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.mlir.constant(4 : i8) : i8 + %3 = llvm.icmp "uge" %arg0, %0 : i8 + %4 = llvm.icmp "ule" %arg0, %1 : i8 + %5 = llvm.and %3, %4 : i1 + %6 = llvm.icmp "eq" %arg0, %2 : i8 + %7 = llvm.or %5, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @and_ranges_overlap(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.mlir.constant(20 : i8) : i8 + %4 = llvm.icmp "uge" %arg0, %0 : i8 + %5 = llvm.icmp "ule" %arg0, %1 : i8 + %6 = llvm.and %4, %5 : i1 + %7 = llvm.icmp "uge" %arg0, %2 : i8 + %8 = llvm.icmp "ule" %arg0, %3 : i8 + %9 = llvm.and %7, %8 : i1 + %10 = llvm.and %6, %9 : i1 + llvm.return %10 : i1 + } + llvm.func @and_ranges_overlap_single(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.mlir.constant(20 : i8) : i8 + %3 = llvm.icmp "uge" %arg0, %0 : i8 + %4 = llvm.icmp "ule" %arg0, %1 : i8 + %5 = llvm.and %3, %4 : i1 + %6 = llvm.icmp "uge" %arg0, %1 : i8 + %7 = llvm.icmp "ule" %arg0, %2 : i8 + %8 = llvm.and %6, %7 : i1 + %9 = llvm.and %5, %8 : i1 + llvm.return %9 : i1 + } + llvm.func @and_ranges_no_overlap(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.mlir.constant(11 : i8) : i8 + %3 = llvm.mlir.constant(20 : i8) : i8 + %4 = llvm.icmp "uge" %arg0, %0 : i8 + %5 = llvm.icmp "ule" %arg0, %1 : i8 + %6 = llvm.and %4, %5 : i1 + %7 = llvm.icmp "uge" %arg0, %2 : i8 + %8 = llvm.icmp "ule" %arg0, %3 : i8 + %9 = llvm.and %7, %8 : i1 + %10 = llvm.and %6, %9 : i1 + llvm.return %10 : i1 + } + llvm.func @and_ranges_signed_pred(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(127 : i64) : i64 + %1 = llvm.mlir.constant(1024 : i64) : i64 + %2 = llvm.mlir.constant(128 : i64) : i64 + %3 = llvm.mlir.constant(256 : i64) : i64 + %4 = llvm.add %arg0, %0 : i64 + %5 = llvm.icmp "slt" %4, %1 : i64 + %6 = llvm.add %arg0, %2 : i64 + %7 = llvm.icmp "slt" %6, %3 : i64 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @and_two_ranges_to_mask_and_range(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-97 : i8) : i8 + %1 = llvm.mlir.constant(25 : i8) : i8 + %2 = llvm.mlir.constant(-65 : i8) : i8 + %3 = llvm.add %arg0, %0 : i8 + %4 = llvm.icmp "ugt" %3, %1 : i8 + %5 = llvm.add %arg0, %2 : i8 + %6 = llvm.icmp "ugt" %5, %1 : i8 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @and_two_ranges_to_mask_and_range_not_pow2_diff(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-97 : i8) : i8 + %1 = llvm.mlir.constant(25 : i8) : i8 + %2 = llvm.mlir.constant(-64 : i8) : i8 + %3 = llvm.add %arg0, %0 : i8 + %4 = llvm.icmp "ugt" %3, %1 : i8 + %5 = llvm.add %arg0, %2 : i8 + %6 = llvm.icmp "ugt" %5, %1 : i8 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @and_two_ranges_to_mask_and_range_different_sizes(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-97 : i8) : i8 + %1 = llvm.mlir.constant(25 : i8) : i8 + %2 = llvm.mlir.constant(-65 : i8) : i8 + %3 = llvm.mlir.constant(24 : i8) : i8 + %4 = llvm.add %arg0, %0 : i8 + %5 = llvm.icmp "ugt" %4, %1 : i8 + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.icmp "ugt" %6, %3 : i8 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @and_two_ranges_to_mask_and_range_no_add_on_one_range(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(12 : i16) : i16 + %1 = llvm.mlir.constant(16 : i16) : i16 + %2 = llvm.mlir.constant(28 : i16) : i16 + %3 = llvm.icmp "uge" %arg0, %0 : i16 + %4 = llvm.icmp "ult" %arg0, %1 : i16 + %5 = llvm.icmp "uge" %arg0, %2 : i16 + %6 = llvm.or %4, %5 : i1 + %7 = llvm.and %3, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @is_ascii_alphabetic(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-65 : i32) : i32 + %1 = llvm.mlir.constant(26 : i32) : i32 + %2 = llvm.mlir.constant(-97 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.add %arg0, %0 overflow : i32 + %5 = llvm.icmp "ult" %4, %1 : i32 + %6 = llvm.add %arg0, %2 overflow : i32 + %7 = llvm.icmp "ult" %6, %1 : i32 + %8 = llvm.select %5, %3, %7 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @is_ascii_alphabetic_inverted(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-91 : i32) : i32 + %1 = llvm.mlir.constant(-26 : i32) : i32 + %2 = llvm.mlir.constant(-123 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.add %arg0, %0 overflow : i32 + %5 = llvm.icmp "ult" %4, %1 : i32 + %6 = llvm.add %arg0, %2 overflow : i32 + %7 = llvm.icmp "ult" %6, %1 : i32 + %8 = llvm.select %5, %7, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @bitwise_and_bitwise_and_icmps(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "eq" %arg1, %0 : i8 + %4 = llvm.and %arg0, %1 : i8 + %5 = llvm.shl %1, %arg2 : i8 + %6 = llvm.and %arg0, %5 : i8 + %7 = llvm.icmp "ne" %4, %2 : i8 + %8 = llvm.icmp "ne" %6, %2 : i8 + %9 = llvm.and %3, %7 : i1 + %10 = llvm.and %9, %8 : i1 + llvm.return %10 : i1 + } + llvm.func @bitwise_and_bitwise_and_icmps_comm1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "eq" %arg1, %0 : i8 + %4 = llvm.and %arg0, %1 : i8 + %5 = llvm.shl %1, %arg2 : i8 + %6 = llvm.and %arg0, %5 : i8 + %7 = llvm.icmp "ne" %4, %2 : i8 + %8 = llvm.icmp "ne" %6, %2 : i8 + %9 = llvm.and %3, %7 : i1 + %10 = llvm.and %8, %9 : i1 + llvm.return %10 : i1 + } + llvm.func @bitwise_and_bitwise_and_icmps_comm2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "eq" %arg1, %0 : i8 + %4 = llvm.and %arg0, %1 : i8 + %5 = llvm.shl %1, %arg2 : i8 + %6 = llvm.and %arg0, %5 : i8 + %7 = llvm.icmp "ne" %4, %2 : i8 + %8 = llvm.icmp "ne" %6, %2 : i8 + %9 = llvm.and %7, %3 : i1 + %10 = llvm.and %9, %8 : i1 + llvm.return %10 : i1 + } + llvm.func @bitwise_and_bitwise_and_icmps_comm3(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "eq" %arg1, %0 : i8 + %4 = llvm.and %arg0, %1 : i8 + %5 = llvm.shl %1, %arg2 : i8 + %6 = llvm.and %arg0, %5 : i8 + %7 = llvm.icmp "ne" %4, %2 : i8 + %8 = llvm.icmp "ne" %6, %2 : i8 + %9 = llvm.and %7, %3 : i1 + %10 = llvm.and %8, %9 : i1 + llvm.return %10 : i1 + } + llvm.func @bitwise_and_logical_and_icmps(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "ne" %5, %2 : i8 + %9 = llvm.icmp "ne" %7, %2 : i8 + %10 = llvm.select %4, %8, %3 : i1, i1 + %11 = llvm.and %10, %9 : i1 + llvm.return %11 : i1 + } + llvm.func @bitwise_and_logical_and_icmps_comm1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "ne" %5, %2 : i8 + %9 = llvm.icmp "ne" %7, %2 : i8 + %10 = llvm.select %4, %8, %3 : i1, i1 + %11 = llvm.and %9, %10 : i1 + llvm.return %11 : i1 + } + llvm.func @bitwise_and_logical_and_icmps_comm2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "ne" %5, %2 : i8 + %9 = llvm.icmp "ne" %7, %2 : i8 + %10 = llvm.select %8, %4, %3 : i1, i1 + %11 = llvm.and %10, %9 : i1 + llvm.return %11 : i1 + } + llvm.func @bitwise_and_logical_and_icmps_comm3(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "ne" %5, %2 : i8 + %9 = llvm.icmp "ne" %7, %2 : i8 + %10 = llvm.select %8, %4, %3 : i1, i1 + %11 = llvm.and %9, %10 : i1 + llvm.return %11 : i1 + } + llvm.func @logical_and_bitwise_and_icmps(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "ne" %5, %2 : i8 + %9 = llvm.icmp "ne" %7, %2 : i8 + %10 = llvm.and %4, %8 : i1 + %11 = llvm.select %10, %9, %3 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @logical_and_bitwise_and_icmps_comm1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "ne" %5, %2 : i8 + %9 = llvm.icmp "ne" %7, %2 : i8 + %10 = llvm.and %4, %8 : i1 + %11 = llvm.select %9, %10, %3 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @logical_and_bitwise_and_icmps_comm2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "ne" %5, %2 : i8 + %9 = llvm.icmp "ne" %7, %2 : i8 + %10 = llvm.and %8, %4 : i1 + %11 = llvm.select %10, %9, %3 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @logical_and_bitwise_and_icmps_comm3(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "ne" %5, %2 : i8 + %9 = llvm.icmp "ne" %7, %2 : i8 + %10 = llvm.and %8, %4 : i1 + %11 = llvm.select %9, %10, %3 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @logical_and_logical_and_icmps(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "ne" %5, %2 : i8 + %9 = llvm.icmp "ne" %7, %2 : i8 + %10 = llvm.select %4, %8, %3 : i1, i1 + %11 = llvm.select %10, %9, %3 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @logical_and_logical_and_icmps_comm1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "ne" %5, %2 : i8 + %9 = llvm.icmp "ne" %7, %2 : i8 + %10 = llvm.select %4, %8, %3 : i1, i1 + %11 = llvm.select %9, %10, %3 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @logical_and_logical_and_icmps_comm2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "ne" %5, %2 : i8 + %9 = llvm.icmp "ne" %7, %2 : i8 + %10 = llvm.select %8, %4, %3 : i1, i1 + %11 = llvm.select %10, %9, %3 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @logical_and_logical_and_icmps_comm3(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "ne" %5, %2 : i8 + %9 = llvm.icmp "ne" %7, %2 : i8 + %10 = llvm.select %8, %4, %3 : i1, i1 + %11 = llvm.select %9, %10, %3 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @bitwise_or_bitwise_or_icmps(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "eq" %arg1, %0 : i8 + %4 = llvm.and %arg0, %1 : i8 + %5 = llvm.shl %1, %arg2 : i8 + %6 = llvm.and %arg0, %5 : i8 + %7 = llvm.icmp "eq" %4, %2 : i8 + %8 = llvm.icmp "eq" %6, %2 : i8 + %9 = llvm.or %3, %7 : i1 + %10 = llvm.or %9, %8 : i1 + llvm.return %10 : i1 + } + llvm.func @bitwise_or_bitwise_or_icmps_comm1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "eq" %arg1, %0 : i8 + %4 = llvm.and %arg0, %1 : i8 + %5 = llvm.shl %1, %arg2 : i8 + %6 = llvm.and %arg0, %5 : i8 + %7 = llvm.icmp "eq" %4, %2 : i8 + %8 = llvm.icmp "eq" %6, %2 : i8 + %9 = llvm.or %3, %7 : i1 + %10 = llvm.or %8, %9 : i1 + llvm.return %10 : i1 + } + llvm.func @bitwise_or_bitwise_or_icmps_comm2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "eq" %arg1, %0 : i8 + %4 = llvm.and %arg0, %1 : i8 + %5 = llvm.shl %1, %arg2 : i8 + %6 = llvm.and %arg0, %5 : i8 + %7 = llvm.icmp "eq" %4, %2 : i8 + %8 = llvm.icmp "eq" %6, %2 : i8 + %9 = llvm.or %7, %3 : i1 + %10 = llvm.or %9, %8 : i1 + llvm.return %10 : i1 + } + llvm.func @bitwise_or_bitwise_or_icmps_comm3(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "eq" %arg1, %0 : i8 + %4 = llvm.and %arg0, %1 : i8 + %5 = llvm.shl %1, %arg2 : i8 + %6 = llvm.and %arg0, %5 : i8 + %7 = llvm.icmp "eq" %4, %2 : i8 + %8 = llvm.icmp "eq" %6, %2 : i8 + %9 = llvm.or %7, %3 : i1 + %10 = llvm.or %8, %9 : i1 + llvm.return %10 : i1 + } + llvm.func @bitwise_or_logical_or_icmps(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "eq" %5, %2 : i8 + %9 = llvm.icmp "eq" %7, %2 : i8 + %10 = llvm.select %4, %3, %8 : i1, i1 + %11 = llvm.or %10, %9 : i1 + llvm.return %11 : i1 + } + llvm.func @bitwise_or_logical_or_icmps_comm1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "eq" %5, %2 : i8 + %9 = llvm.icmp "eq" %7, %2 : i8 + %10 = llvm.select %4, %3, %8 : i1, i1 + %11 = llvm.or %9, %10 : i1 + llvm.return %11 : i1 + } + llvm.func @bitwise_or_logical_or_icmps_comm2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "eq" %5, %2 : i8 + %9 = llvm.icmp "eq" %7, %2 : i8 + %10 = llvm.select %8, %3, %4 : i1, i1 + %11 = llvm.or %10, %9 : i1 + llvm.return %11 : i1 + } + llvm.func @bitwise_or_logical_or_icmps_comm3(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "eq" %5, %2 : i8 + %9 = llvm.icmp "eq" %7, %2 : i8 + %10 = llvm.select %8, %3, %4 : i1, i1 + %11 = llvm.or %9, %10 : i1 + llvm.return %11 : i1 + } + llvm.func @logical_or_bitwise_or_icmps(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "eq" %5, %2 : i8 + %9 = llvm.icmp "eq" %7, %2 : i8 + %10 = llvm.or %4, %8 : i1 + %11 = llvm.select %10, %3, %9 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @logical_or_bitwise_or_icmps_comm1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "eq" %5, %2 : i8 + %9 = llvm.icmp "eq" %7, %2 : i8 + %10 = llvm.or %4, %8 : i1 + %11 = llvm.select %9, %3, %10 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @logical_or_bitwise_or_icmps_comm2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "eq" %5, %2 : i8 + %9 = llvm.icmp "eq" %7, %2 : i8 + %10 = llvm.or %8, %4 : i1 + %11 = llvm.select %10, %3, %9 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @logical_or_bitwise_or_icmps_comm3(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "eq" %5, %2 : i8 + %9 = llvm.icmp "eq" %7, %2 : i8 + %10 = llvm.or %8, %4 : i1 + %11 = llvm.select %9, %3, %10 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @logical_or_logical_or_icmps(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "eq" %5, %2 : i8 + %9 = llvm.icmp "eq" %7, %2 : i8 + %10 = llvm.select %4, %3, %8 : i1, i1 + %11 = llvm.select %10, %3, %9 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @logical_or_logical_or_icmps_comm1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "eq" %5, %2 : i8 + %9 = llvm.icmp "eq" %7, %2 : i8 + %10 = llvm.select %4, %3, %8 : i1, i1 + %11 = llvm.select %9, %3, %10 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @logical_or_logical_or_icmps_comm2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "eq" %5, %2 : i8 + %9 = llvm.icmp "eq" %7, %2 : i8 + %10 = llvm.select %8, %3, %4 : i1, i1 + %11 = llvm.select %10, %3, %9 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @logical_or_logical_or_icmps_comm3(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.icmp "eq" %arg1, %0 : i8 + %5 = llvm.and %arg0, %1 : i8 + %6 = llvm.shl %1, %arg2 : i8 + %7 = llvm.and %arg0, %6 : i8 + %8 = llvm.icmp "eq" %5, %2 : i8 + %9 = llvm.icmp "eq" %7, %2 : i8 + %10 = llvm.select %8, %3, %4 : i1, i1 + %11 = llvm.select %9, %3, %10 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @bitwise_and_logical_and_masked_icmp_asymmetric(%arg0: i1, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(11 : i32) : i32 + %4 = llvm.and %arg1, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.select %5, %arg0, %2 : i1, i1 + %7 = llvm.and %arg1, %3 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.and %6, %8 : i1 + llvm.return %9 : i1 + } + llvm.func @bitwise_and_logical_and_masked_icmp_allzeros(%arg0: i1, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(7 : i32) : i32 + %4 = llvm.and %arg1, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.select %5, %arg0, %2 : i1, i1 + %7 = llvm.and %arg1, %3 : i32 + %8 = llvm.icmp "eq" %7, %1 : i32 + %9 = llvm.and %6, %8 : i1 + llvm.return %9 : i1 + } + llvm.func @bitwise_and_logical_and_masked_icmp_allzeros_poison1(%arg0: i1, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.and %arg1, %arg2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + %5 = llvm.select %4, %arg0, %1 : i1, i1 + %6 = llvm.and %arg1, %2 : i32 + %7 = llvm.icmp "eq" %6, %0 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @bitwise_and_logical_and_masked_icmp_allzeros_poison2(%arg0: i1, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.select %4, %arg0, %2 : i1, i1 + %6 = llvm.and %arg1, %arg2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @bitwise_and_logical_and_masked_icmp_allones(%arg0: i1, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + %5 = llvm.select %4, %arg0, %1 : i1, i1 + %6 = llvm.and %arg1, %2 : i32 + %7 = llvm.icmp "eq" %6, %2 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @bitwise_and_logical_and_masked_icmp_allones_poison1(%arg0: i1, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.and %arg1, %arg2 : i32 + %3 = llvm.icmp "eq" %2, %arg2 : i32 + %4 = llvm.select %3, %arg0, %0 : i1, i1 + %5 = llvm.and %arg1, %1 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @bitwise_and_logical_and_masked_icmp_allones_poison2(%arg0: i1, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.select %3, %arg0, %1 : i1, i1 + %5 = llvm.and %arg1, %arg2 : i32 + %6 = llvm.icmp "eq" %5, %arg2 : i32 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @samesign(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + %4 = llvm.or %arg0, %arg1 : i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_different_sign_bittest1(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg0, %arg1 : vector<2xi32> + %2 = llvm.icmp "sle" %1, %0 : vector<2xi32> + %3 = llvm.or %arg0, %arg1 : vector<2xi32> + %4 = llvm.icmp "sgt" %3, %0 : vector<2xi32> + %5 = llvm.or %2, %4 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @samesign_different_sign_bittest2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + %3 = llvm.or %arg0, %arg1 : i32 + %4 = llvm.icmp "sge" %3, %0 : i32 + %5 = llvm.or %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @samesign_commute1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + %4 = llvm.or %arg0, %arg1 : i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.or %5, %3 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_commute2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + %4 = llvm.or %arg1, %arg0 : i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_commute3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + %4 = llvm.or %arg1, %arg0 : i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.or %5, %3 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_violate_constraint1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.or %arg0, %arg1 : i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + %4 = llvm.or %arg0, %arg1 : i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_violate_constraint2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + %4 = llvm.or %arg0, %arg1 : i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_mult_use(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.icmp "slt" %2, %0 : i32 + %4 = llvm.or %arg0, %arg1 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_mult_use2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + %4 = llvm.or %arg0, %arg1 : i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_mult_use3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.or %arg0, %arg1 : i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_wrong_cmp(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + %4 = llvm.or %arg0, %arg1 : i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_inverted(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + %4 = llvm.or %arg0, %arg1 : i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_inverted_different_sign_bittest1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.icmp "sge" %1, %0 : i32 + %3 = llvm.or %arg0, %arg1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @samesign_inverted_different_sign_bittest2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + %3 = llvm.or %arg0, %arg1 : i32 + %4 = llvm.icmp "sle" %3, %0 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @samesign_inverted_commute1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + %4 = llvm.or %arg0, %arg1 : i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.and %5, %3 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_inverted_commute2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + %4 = llvm.or %arg1, %arg0 : i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_inverted_commute3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + %4 = llvm.or %arg1, %arg0 : i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.and %5, %3 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_inverted_violate_constraint1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.or %arg0, %arg1 : i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + %4 = llvm.and %arg0, %arg1 : i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_inverted_violate_constraint2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + %4 = llvm.or %arg0, %arg1 : i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_inverted_mult_use(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.icmp "sgt" %2, %0 : i32 + %4 = llvm.or %arg0, %arg1 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_inverted_mult_use2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.or %arg0, %arg1 : i32 + %5 = llvm.icmp "slt" %4, %1 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @samesign_inverted_wrong_cmp(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + %3 = llvm.or %arg0, %arg1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_eq_m1_and_eq_m1(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.icmp "eq" %arg0, %6 : vector<2xi8> + %8 = llvm.icmp "eq" %arg1, %6 : vector<2xi8> + %9 = llvm.and %7, %8 : vector<2xi1> + llvm.return %9 : vector<2xi1> + } + llvm.func @icmp_eq_m1_and_eq_poison_m1(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.undef : vector<2xi8> + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<2xi8> + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<2xi8> + %12 = llvm.icmp "eq" %arg0, %6 : vector<2xi8> + %13 = llvm.icmp "eq" %arg1, %11 : vector<2xi8> + %14 = llvm.and %12, %13 : vector<2xi1> + llvm.return %14 : vector<2xi1> + } + llvm.func @icmp_eq_poison_and_eq_m1_m2(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-1, -2]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.icmp "eq" %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "eq" %arg1, %1 : vector<2xi8> + %4 = llvm.and %2, %3 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @icmp_ne_m1_and_ne_m1_fail(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.icmp "ne" %arg0, %6 : vector<2xi8> + %8 = llvm.icmp "ne" %arg1, %6 : vector<2xi8> + %9 = llvm.and %7, %8 : vector<2xi1> + llvm.return %9 : vector<2xi1> + } + llvm.func @icmp_eq_m1_or_eq_m1_fail(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.icmp "eq" %arg0, %6 : vector<2xi8> + %8 = llvm.icmp "eq" %arg1, %6 : vector<2xi8> + %9 = llvm.or %7, %8 : vector<2xi1> + llvm.return %9 : vector<2xi1> + } + llvm.func @icmp_ne_m1_or_ne_m1(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.icmp "ne" %arg0, %0 : vector<2xi8> + %9 = llvm.icmp "ne" %arg1, %7 : vector<2xi8> + %10 = llvm.or %8, %9 : vector<2xi1> + llvm.return %10 : vector<2xi1> + } + llvm.func @icmp_slt_0_or_icmp_sgt_0_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.zext %1 : i1 to i32 + %4 = llvm.zext %2 : i1 to i32 + %5 = llvm.or %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_or_icmp_sgt_0_i64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "slt" %arg0, %0 : i64 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + %3 = llvm.zext %1 : i1 to i64 + %4 = llvm.zext %2 : i1 to i64 + %5 = llvm.or %3, %4 : i64 + llvm.return %5 : i64 + } + llvm.func @icmp_slt_0_or_icmp_sgt_0_i64_fail0(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(63 : i64) : i64 + %2 = llvm.icmp "slt" %arg0, %0 : i64 + %3 = llvm.lshr %arg0, %1 : i64 + %4 = llvm.zext %2 : i1 to i64 + %5 = llvm.or %3, %4 : i64 + llvm.return %5 : i64 + } + llvm.func @icmp_slt_0_or_icmp_sgt_0_i64_fail1(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(63 : i64) : i64 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + %3 = llvm.ashr %arg0, %1 : i64 + %4 = llvm.zext %2 : i1 to i64 + %5 = llvm.or %3, %4 : i64 + llvm.return %5 : i64 + } + llvm.func @icmp_slt_0_or_icmp_sgt_0_i64_fail2(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(62 : i64) : i64 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + %3 = llvm.lshr %arg0, %1 : i64 + %4 = llvm.zext %2 : i1 to i64 + %5 = llvm.or %3, %4 : i64 + llvm.return %5 : i64 + } + llvm.func @icmp_slt_0_or_icmp_sgt_0_i64_fail3(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(62 : i64) : i64 + %2 = llvm.icmp "slt" %arg0, %0 : i64 + %3 = llvm.ashr %arg0, %1 : i64 + %4 = llvm.zext %2 : i1 to i64 + %5 = llvm.or %3, %4 : i64 + llvm.return %5 : i64 + } + llvm.func @icmp_slt_0_or_icmp_sgt_0_i64x2(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.icmp "slt" %arg0, %1 : vector<2xi64> + %3 = llvm.icmp "sgt" %arg0, %1 : vector<2xi64> + %4 = llvm.zext %2 : vector<2xi1> to vector<2xi64> + %5 = llvm.zext %3 : vector<2xi1> to vector<2xi64> + %6 = llvm.or %4, %5 : vector<2xi64> + llvm.return %6 : vector<2xi64> + } + llvm.func @icmp_slt_0_or_icmp_sgt_0_i64x2_fail(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<63> : vector<2xi64>) : vector<2xi64> + %2 = llvm.icmp "sgt" %arg0, %0 : vector<2xi64> + %3 = llvm.lshr %arg0, %1 : vector<2xi64> + %4 = llvm.zext %2 : vector<2xi1> to vector<2xi64> + %5 = llvm.or %3, %4 : vector<2xi64> + llvm.return %5 : vector<2xi64> + } + llvm.func @icmp_slt_0_and_icmp_sge_neg1_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_or_icmp_sge_neg1_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "sge" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.or %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_or_icmp_sge_100_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "sge" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.or %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_and_icmp_sge_neg1_i64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(63 : i64) : i64 + %2 = llvm.icmp "sge" %arg0, %0 : i64 + %3 = llvm.zext %2 : i1 to i64 + %4 = llvm.lshr %arg0, %1 : i64 + %5 = llvm.and %4, %3 : i64 + llvm.return %5 : i64 + } + llvm.func @icmp_slt_0_and_icmp_sge_neg2_i64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(-2 : i64) : i64 + %1 = llvm.mlir.constant(63 : i64) : i64 + %2 = llvm.icmp "sge" %arg0, %0 : i64 + %3 = llvm.zext %2 : i1 to i64 + %4 = llvm.lshr %arg0, %1 : i64 + %5 = llvm.and %4, %3 : i64 + llvm.return %5 : i64 + } + llvm.func @ashr_and_icmp_sge_neg1_i64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(63 : i64) : i64 + %2 = llvm.icmp "sge" %arg0, %0 : i64 + %3 = llvm.zext %2 : i1 to i64 + %4 = llvm.ashr %arg0, %1 : i64 + %5 = llvm.and %4, %3 : i64 + llvm.return %5 : i64 + } + llvm.func @icmp_slt_0_and_icmp_sgt_neg1_i64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(63 : i64) : i64 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + %3 = llvm.zext %2 : i1 to i64 + %4 = llvm.lshr %arg0, %1 : i64 + %5 = llvm.and %4, %3 : i64 + llvm.return %5 : i64 + } + llvm.func @icmp_slt_0_and_icmp_sge_neg1_i64_fail(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(62 : i64) : i64 + %2 = llvm.icmp "sge" %arg0, %0 : i64 + %3 = llvm.zext %2 : i1 to i64 + %4 = llvm.lshr %arg0, %1 : i64 + %5 = llvm.and %4, %3 : i64 + llvm.return %5 : i64 + } + llvm.func @icmp_slt_0_and_icmp_sge_neg1_i32x2(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "sge" %arg0, %0 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi1> to vector<2xi32> + %4 = llvm.lshr %arg0, %1 : vector<2xi32> + %5 = llvm.and %4, %3 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @icmp_slt_0_and_icmp_sge_neg2_i32x2(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "sge" %arg0, %0 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi1> to vector<2xi32> + %4 = llvm.lshr %arg0, %1 : vector<2xi32> + %5 = llvm.and %4, %3 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @icmp_x_slt_0_xor_icmp_y_sgt_neg1_i32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg1, %1 : i32 + %5 = llvm.xor %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_xor_icmp_sgt_neg2_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.xor %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_and_icmp_sge_neg1_i32_multiuse0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "sge" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i32 + llvm.call @use(%2) : (i1) -> () + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_and_icmp_sge_neg2_i32_multiuse1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "sge" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_and_icmp_sge_neg2_i32_multiuse2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "sge" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_and_icmp_sge_neg2_i32_multiuse_fail0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "sge" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_or_icmp_eq_100_i32_multiuse_fail1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.or %4, %3 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @icmp_x_slt_0_and_icmp_y_ne_neg2_i32_multiuse_fail2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg1, %1 : i32 + %5 = llvm.and %4, %3 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_or_icmp_eq_100_i32_multiuse_fail3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.or %4, %3 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_or_icmp_eq_100_i32_fail(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.or %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_and_icmp_ne_neg2_i32_fail(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @icmp_x_slt_0_and_icmp_y_ne_neg2_i32_fail(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg1, %1 : i32 + %5 = llvm.and %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @icmp_x_slt_0_and_icmp_y_sgt_neg1_i32_fail(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg1, %1 : i32 + %5 = llvm.and %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_xor_icmp_sge_neg2_i32_fail(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "sge" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.xor %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @icmp_slt_0_or_icmp_add_1_sge_100_i32_fail(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(100 : i32) : i32 + %2 = llvm.mlir.constant(31 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = llvm.icmp "sge" %3, %1 : i32 + %5 = llvm.zext %4 : i1 to i32 + %6 = llvm.lshr %arg0, %2 : i32 + %7 = llvm.or %6, %5 : i32 + llvm.return %7 : i32 + } + llvm.func @logical_and_icmps1(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(10086 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.select %arg1, %3, %1 : i1, i1 + %5 = llvm.icmp "slt" %arg0, %2 : i32 + %6 = llvm.select %4, %5, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @logical_and_icmps2(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(10086 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %arg1, %3, %1 : i1, i1 + %5 = llvm.icmp "eq" %arg0, %2 : i32 + %6 = llvm.select %4, %5, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @logical_and_icmps_vec1(%arg0: vector<4xi32>, %arg1: vector<4xi1>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %3 = llvm.mlir.constant(dense<10086> : vector<4xi32>) : vector<4xi32> + %4 = llvm.icmp "sgt" %arg0, %0 : vector<4xi32> + %5 = llvm.select %arg1, %4, %2 : vector<4xi1>, vector<4xi1> + %6 = llvm.icmp "slt" %arg0, %3 : vector<4xi32> + %7 = llvm.select %5, %6, %2 : vector<4xi1>, vector<4xi1> + llvm.return %7 : vector<4xi1> + } + llvm.func @logical_and_icmps_fail1(%arg0: i32, %arg1: i32, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %arg2, %2, %1 : i1, i1 + %4 = llvm.icmp "slt" %arg0, %arg1 : i32 + %5 = llvm.select %3, %4, %1 : i1, i1 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/and-or-implied-cond-not.ll.mlir b/test/LLVMDialect/InstCombine/and-or-implied-cond-not.ll.mlir new file mode 100644 index 000000000..ccc688a48 --- /dev/null +++ b/test/LLVMDialect/InstCombine/and-or-implied-cond-not.ll.mlir @@ -0,0 +1,44 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_imply_not1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "slt" %arg0, %1 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.xor %3, %2 : i1 + %6 = llvm.or %4, %5 : i1 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @func1() : () -> () + llvm.unreachable + ^bb2: // pred: ^bb0 + llvm.call @func2() : () -> () + llvm.unreachable + } + llvm.func @test_imply_not2(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.select %3, %arg1, %1 : i1, i1 + %5 = llvm.xor %3, %2 : i1 + %6 = llvm.or %4, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @test_imply_not3(%arg0: i32, %arg1: i32, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %arg1 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "slt" %arg0, %arg1 : i32 + %4 = llvm.xor %2, %0 : i1 + %5 = llvm.select %4, %arg2, %1 : i1, i1 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @func1() + llvm.func @func2() + llvm.func @use(i1) +} diff --git a/test/LLVMDialect/InstCombine/and-or-not.ll.mlir b/test/LLVMDialect/InstCombine/and-or-not.ll.mlir new file mode 100644 index 000000000..0ebd83290 --- /dev/null +++ b/test/LLVMDialect/InstCombine/and-or-not.ll.mlir @@ -0,0 +1,478 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i4) + llvm.func @and_to_xor1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.and %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @and_to_xor2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @and_to_xor3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.and %arg1, %arg0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.and %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @and_to_xor4(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @and_to_xor1_vec(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.or %arg0, %arg1 : vector<4xi32> + %2 = llvm.and %arg0, %arg1 : vector<4xi32> + %3 = llvm.xor %2, %0 : vector<4xi32> + %4 = llvm.and %1, %3 : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @and_to_nxor1(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.or %1, %4 : i32 + %6 = llvm.or %3, %2 : i32 + %7 = llvm.and %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @and_to_nxor2(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.or %1, %4 : i32 + %6 = llvm.or %2, %3 : i32 + %7 = llvm.and %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @and_to_nxor3(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.or %3, %2 : i32 + %6 = llvm.or %1, %4 : i32 + %7 = llvm.and %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @and_to_nxor4(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.or %3, %2 : i32 + %6 = llvm.or %4, %1 : i32 + %7 = llvm.and %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_to_xor1(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.and %1, %4 : i32 + %6 = llvm.and %3, %2 : i32 + %7 = llvm.or %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_to_xor2(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.and %1, %4 : i32 + %6 = llvm.and %2, %3 : i32 + %7 = llvm.or %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_to_xor3(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.and %3, %2 : i32 + %6 = llvm.and %4, %1 : i32 + %7 = llvm.or %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_to_xor4(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.and %3, %2 : i32 + %6 = llvm.and %1, %4 : i32 + %7 = llvm.or %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_to_nxor1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.or %arg0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.or %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @or_to_nxor2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.or %arg1, %arg0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.or %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @or_to_nxor3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.or %arg0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.or %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @or_to_nxor4(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.or %arg0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.or %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @xor_to_xor1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.and %arg0, %arg1 : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_to_xor2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.and %arg0, %arg1 : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_to_xor3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_to_xor4(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_to_xor5(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.or %1, %4 : i32 + %6 = llvm.or %3, %2 : i32 + %7 = llvm.xor %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @xor_to_xor6(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.or %1, %4 : i32 + %6 = llvm.or %2, %3 : i32 + %7 = llvm.xor %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @xor_to_xor7(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.or %1, %4 : i32 + %6 = llvm.or %3, %2 : i32 + %7 = llvm.xor %6, %5 : i32 + llvm.return %7 : i32 + } + llvm.func @xor_to_xor8(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.or %4, %1 : i32 + %6 = llvm.or %3, %2 : i32 + %7 = llvm.xor %6, %5 : i32 + llvm.return %7 : i32 + } + llvm.func @xor_to_xor9(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.and %1, %4 : i32 + %6 = llvm.and %3, %2 : i32 + %7 = llvm.xor %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @xor_to_xor10(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.and %1, %4 : i32 + %6 = llvm.and %2, %3 : i32 + %7 = llvm.xor %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @xor_to_xor11(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.and %1, %4 : i32 + %6 = llvm.and %3, %2 : i32 + %7 = llvm.xor %6, %5 : i32 + llvm.return %7 : i32 + } + llvm.func @xor_to_xor12(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.and %4, %1 : i32 + %6 = llvm.and %3, %2 : i32 + %7 = llvm.xor %6, %5 : i32 + llvm.return %7 : i32 + } + llvm.func @PR32830(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.xor %arg0, %0 : i64 + %2 = llvm.xor %arg1, %0 : i64 + %3 = llvm.or %2, %arg0 : i64 + %4 = llvm.or %1, %arg2 : i64 + %5 = llvm.and %3, %4 : i64 + llvm.return %5 : i64 + } + llvm.func @and_to_nxor_multiuse(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.or %3, %2 : i32 + %6 = llvm.or %4, %1 : i32 + %7 = llvm.and %5, %6 : i32 + %8 = llvm.mul %5, %6 : i32 + %9 = llvm.mul %8, %7 : i32 + llvm.return %9 : i32 + } + llvm.func @or_to_nxor_multiuse(%arg0: i32 {llvm.noundef}, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.or %arg0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.or %1, %3 : i32 + %5 = llvm.mul %1, %3 : i32 + %6 = llvm.mul %5, %4 : i32 + llvm.return %6 : i32 + } + llvm.func @xor_to_xnor1(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.or %1, %2 : i32 + %6 = llvm.or %3, %4 : i32 + %7 = llvm.xor %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @xor_to_xnor2(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.or %1, %2 : i32 + %6 = llvm.or %4, %3 : i32 + %7 = llvm.xor %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @xor_to_xnor3(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.or %3, %4 : i32 + %6 = llvm.or %1, %2 : i32 + %7 = llvm.xor %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @xor_to_xnor4(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.fptosi %arg0 : f32 to i32 + %2 = llvm.fptosi %arg1 : f32 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.or %3, %4 : i32 + %6 = llvm.or %2, %1 : i32 + %7 = llvm.xor %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @simplify_or_common_op_commute0(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.and %arg0, %arg1 : i4 + %2 = llvm.and %1, %arg2 : i4 + %3 = llvm.xor %2, %0 : i4 + %4 = llvm.or %3, %arg0 : i4 + llvm.return %4 : i4 + } + llvm.func @simplify_or_common_op_commute1(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.and %arg1, %arg0 : i4 + %2 = llvm.and %1, %arg2 : i4 + %3 = llvm.xor %2, %0 : i4 + %4 = llvm.or %3, %arg0 : i4 + llvm.return %4 : i4 + } + llvm.func @simplify_or_common_op_commute2(%arg0: i4, %arg1: i4, %arg2: i4, %arg3: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mul %arg2, %arg2 : i4 + %2 = llvm.and %arg0, %arg1 : i4 + %3 = llvm.and %1, %2 : i4 + %4 = llvm.and %3, %arg3 : i4 + %5 = llvm.xor %4, %0 : i4 + %6 = llvm.or %5, %arg0 : i4 + llvm.return %6 : i4 + } + llvm.func @simplify_or_common_op_commute3(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mul %arg2, %arg2 : vector<2xi4> + %3 = llvm.and %arg1, %arg0 : vector<2xi4> + %4 = llvm.and %2, %3 : vector<2xi4> + %5 = llvm.xor %4, %1 : vector<2xi4> + %6 = llvm.or %arg0, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @simplify_and_common_op_commute0(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.or %arg0, %arg1 : i4 + llvm.call @use(%arg0) : (i4) -> () + %2 = llvm.or %1, %arg2 : i4 + %3 = llvm.xor %2, %0 : i4 + %4 = llvm.and %3, %arg0 : i4 + llvm.return %4 : i4 + } + llvm.func @simplify_and_common_op_commute1(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.or %arg1, %arg0 : i4 + %2 = llvm.or %1, %arg2 : i4 + %3 = llvm.xor %2, %0 : i4 + %4 = llvm.and %3, %arg0 : i4 + llvm.return %4 : i4 + } + llvm.func @simplify_and_common_op_commute2(%arg0: i4, %arg1: i4, %arg2: i4, %arg3: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mul %arg2, %arg2 : i4 + %2 = llvm.or %arg0, %arg1 : i4 + %3 = llvm.or %1, %2 : i4 + %4 = llvm.or %3, %arg3 : i4 + %5 = llvm.xor %4, %0 : i4 + %6 = llvm.and %5, %arg0 : i4 + llvm.return %6 : i4 + } + llvm.func @simplify_and_common_op_commute3(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mul %arg2, %arg2 : vector<2xi4> + %3 = llvm.or %arg1, %arg0 : vector<2xi4> + %4 = llvm.or %2, %3 : vector<2xi4> + %5 = llvm.xor %4, %1 : vector<2xi4> + %6 = llvm.and %arg0, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @simplify_and_common_op_use1(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.or %arg0, %arg1 : i4 + llvm.call @use(%arg1) : (i4) -> () + %2 = llvm.or %1, %arg2 : i4 + %3 = llvm.xor %2, %0 : i4 + %4 = llvm.and %3, %arg0 : i4 + llvm.return %4 : i4 + } + llvm.func @simplify_and_common_op_use2(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.or %arg1, %arg0 : i4 + llvm.call @use(%arg1) : (i4) -> () + %2 = llvm.or %1, %arg2 : i4 + %3 = llvm.xor %2, %0 : i4 + %4 = llvm.and %3, %arg0 : i4 + llvm.return %4 : i4 + } + llvm.func @simplify_and_common_op_use3(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.or %arg0, %arg1 : i4 + %2 = llvm.or %1, %arg2 : i4 + llvm.call @use(%arg2) : (i4) -> () + %3 = llvm.xor %2, %0 : i4 + %4 = llvm.and %3, %arg0 : i4 + llvm.return %4 : i4 + } + llvm.func @reduce_xor_common_op_commute0(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.xor %arg0, %arg1 : i4 + %1 = llvm.xor %0, %arg2 : i4 + %2 = llvm.or %1, %arg0 : i4 + llvm.return %2 : i4 + } + llvm.func @reduce_xor_common_op_commute1(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.xor %arg1, %arg0 : i4 + %1 = llvm.xor %0, %arg2 : i4 + %2 = llvm.or %1, %arg0 : i4 + llvm.return %2 : i4 + } + llvm.func @annihilate_xor_common_op_commute2(%arg0: i4, %arg1: i4, %arg2: i4, %arg3: i4) -> i4 { + %0 = llvm.mul %arg2, %arg2 : i4 + %1 = llvm.xor %arg0, %arg1 : i4 + %2 = llvm.xor %0, %1 : i4 + %3 = llvm.xor %2, %arg3 : i4 + %4 = llvm.xor %3, %arg0 : i4 + llvm.return %4 : i4 + } + llvm.func @reduce_xor_common_op_commute3(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mul %arg2, %arg2 : vector<2xi4> + %1 = llvm.xor %arg1, %arg0 : vector<2xi4> + %2 = llvm.xor %0, %1 : vector<2xi4> + %3 = llvm.or %arg0, %2 : vector<2xi4> + llvm.return %3 : vector<2xi4> + } +} diff --git a/test/LLVMDialect/InstCombine/and-or.ll.mlir b/test/LLVMDialect/InstCombine/and-or.ll.mlir new file mode 100644 index 000000000..1ee3846de --- /dev/null +++ b/test/LLVMDialect/InstCombine/and-or.ll.mlir @@ -0,0 +1,444 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g() {addr_space = 0 : i32} : i32 + llvm.func @use(i8) + llvm.func @use_vec(vector<2xi8>) + llvm.func @or_and_not_constant_commute0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.or %arg1, %arg0 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.and %arg1, %1 : i32 + %5 = llvm.or %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @or_and_not_constant_commute1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.or %arg0, %arg1 : i32 + %3 = llvm.and %0, %2 : i32 + %4 = llvm.and %1, %arg1 : i32 + %5 = llvm.or %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @or_and_not_constant_commute2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.or %arg1, %arg0 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.and %arg1, %1 : i32 + %5 = llvm.or %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @or_and_not_constant_commute3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.or %arg0, %arg1 : i32 + %3 = llvm.and %0, %2 : i32 + %4 = llvm.and %1, %arg1 : i32 + %5 = llvm.or %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @or_and_not_constant_commute0_splat(%arg0: vector<2xi7>, %arg1: vector<2xi7>) -> vector<2xi7> { + %0 = llvm.mlir.constant(42 : i7) : i7 + %1 = llvm.mlir.constant(dense<42> : vector<2xi7>) : vector<2xi7> + %2 = llvm.mlir.constant(-43 : i7) : i7 + %3 = llvm.mlir.constant(dense<-43> : vector<2xi7>) : vector<2xi7> + %4 = llvm.or %arg1, %arg0 : vector<2xi7> + %5 = llvm.and %4, %1 : vector<2xi7> + %6 = llvm.and %arg1, %3 : vector<2xi7> + %7 = llvm.or %5, %6 : vector<2xi7> + llvm.return %7 : vector<2xi7> + } + llvm.func @or_and_or_commute0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(59 : i8) : i8 + %2 = llvm.mlir.constant(64 : i8) : i8 + %3 = llvm.or %arg0, %0 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.and %3, %1 : i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.and %arg0, %2 : i8 + llvm.call @use(%5) : (i8) -> () + %6 = llvm.or %4, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @or_and_or_commute1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(59 : i8) : i8 + %2 = llvm.mlir.constant(64 : i8) : i8 + %3 = llvm.or %arg0, %0 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.and %3, %1 : i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.and %arg0, %2 : i8 + llvm.call @use(%5) : (i8) -> () + %6 = llvm.or %5, %4 : i8 + llvm.return %6 : i8 + } + llvm.func @or_and_or_commute1_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<59> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<64> : vector<2xi8>) : vector<2xi8> + %3 = llvm.or %arg0, %0 : vector<2xi8> + llvm.call @use_vec(%3) : (vector<2xi8>) -> () + %4 = llvm.and %3, %1 : vector<2xi8> + llvm.call @use_vec(%4) : (vector<2xi8>) -> () + %5 = llvm.and %arg0, %2 : vector<2xi8> + llvm.call @use_vec(%5) : (vector<2xi8>) -> () + %6 = llvm.or %5, %4 : vector<2xi8> + llvm.return %6 : vector<2xi8> + } + llvm.func @or_and_or_commute2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(-69 : i8) : i8 + %2 = llvm.mlir.constant(64 : i8) : i8 + %3 = llvm.lshr %arg1, %0 : i8 + %4 = llvm.or %3, %arg0 : i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.and %4, %1 : i8 + llvm.call @use(%5) : (i8) -> () + %6 = llvm.and %arg0, %2 : i8 + llvm.call @use(%6) : (i8) -> () + %7 = llvm.or %5, %6 : i8 + llvm.return %7 : i8 + } + llvm.func @or_and_or_commute2_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-69> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<64> : vector<2xi8>) : vector<2xi8> + %3 = llvm.lshr %arg1, %0 : vector<2xi8> + %4 = llvm.or %3, %arg0 : vector<2xi8> + llvm.call @use_vec(%4) : (vector<2xi8>) -> () + %5 = llvm.and %4, %1 : vector<2xi8> + llvm.call @use_vec(%5) : (vector<2xi8>) -> () + %6 = llvm.and %arg0, %2 : vector<2xi8> + llvm.call @use_vec(%6) : (vector<2xi8>) -> () + %7 = llvm.or %5, %6 : vector<2xi8> + llvm.return %7 : vector<2xi8> + } + llvm.func @or_and_or_commute3(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(-69 : i8) : i8 + %2 = llvm.mlir.constant(64 : i8) : i8 + %3 = llvm.lshr %arg1, %0 : i8 + %4 = llvm.or %3, %arg0 : i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.and %4, %1 : i8 + llvm.call @use(%5) : (i8) -> () + %6 = llvm.and %arg0, %2 : i8 + llvm.call @use(%6) : (i8) -> () + %7 = llvm.or %6, %5 : i8 + llvm.return %7 : i8 + } + llvm.func @or_and2_or2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(-71 : i8) : i8 + %3 = llvm.mlir.constant(66 : i8) : i8 + %4 = llvm.or %arg0, %0 : i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.or %arg0, %1 : i8 + llvm.call @use(%5) : (i8) -> () + %6 = llvm.and %4, %2 : i8 + llvm.call @use(%6) : (i8) -> () + %7 = llvm.and %5, %3 : i8 + llvm.call @use(%7) : (i8) -> () + %8 = llvm.or %6, %7 : i8 + llvm.return %8 : i8 + } + llvm.func @or_and2_or2_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<-71> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<66> : vector<2xi8>) : vector<2xi8> + %4 = llvm.or %arg0, %0 : vector<2xi8> + llvm.call @use_vec(%4) : (vector<2xi8>) -> () + %5 = llvm.or %arg0, %1 : vector<2xi8> + llvm.call @use_vec(%5) : (vector<2xi8>) -> () + %6 = llvm.and %4, %2 : vector<2xi8> + llvm.call @use_vec(%6) : (vector<2xi8>) -> () + %7 = llvm.and %5, %3 : vector<2xi8> + llvm.call @use_vec(%7) : (vector<2xi8>) -> () + %8 = llvm.or %6, %7 : vector<2xi8> + llvm.return %8 : vector<2xi8> + } + llvm.func @and_or_hoist_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.or %2, %arg1 : i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @and_xor_hoist_mask_vec_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %arg0, %0 : vector<2xi8> + %3 = llvm.xor %2, %arg1 : vector<2xi8> + %4 = llvm.and %3, %1 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @and_xor_hoist_mask_commute(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(43 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.mul %arg1, %0 : i8 + %4 = llvm.lshr %arg0, %1 : i8 + %5 = llvm.xor %3, %4 : i8 + %6 = llvm.and %5, %2 : i8 + llvm.return %6 : i8 + } + llvm.func @and_or_hoist_mask_commute_vec_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<43> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mul %arg1, %0 : vector<2xi8> + %4 = llvm.lshr %arg0, %1 : vector<2xi8> + %5 = llvm.or %3, %4 : vector<2xi8> + %6 = llvm.and %5, %2 : vector<2xi8> + llvm.return %6 : vector<2xi8> + } + llvm.func @pr64114_and_xor_hoist_mask_constexpr() -> i32 { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.lshr %1, %2 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.and %5, %3 : i32 + llvm.return %6 : i32 + } + llvm.func @and_or_do_not_hoist_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.or %2, %arg1 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.mul %3, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @or_or_and_complex(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(71776119061217280 : i64) : i64 + %2 = llvm.mlir.constant(-72057594037927936 : i64) : i64 + %3 = llvm.mlir.constant(1095216660480 : i64) : i64 + %4 = llvm.mlir.constant(280375465082880 : i64) : i64 + %5 = llvm.mlir.constant(16711680 : i64) : i64 + %6 = llvm.mlir.constant(4278190080 : i64) : i64 + %7 = llvm.mlir.constant(255 : i64) : i64 + %8 = llvm.mlir.constant(65280 : i64) : i64 + %9 = llvm.lshr %arg0, %0 : i64 + %10 = llvm.and %9, %1 : i64 + %11 = llvm.shl %arg0, %0 : i64 + %12 = llvm.and %11, %2 : i64 + %13 = llvm.or %10, %12 : i64 + %14 = llvm.and %9, %3 : i64 + %15 = llvm.or %13, %14 : i64 + %16 = llvm.and %11, %4 : i64 + %17 = llvm.or %15, %16 : i64 + %18 = llvm.and %9, %5 : i64 + %19 = llvm.or %17, %18 : i64 + %20 = llvm.and %11, %6 : i64 + %21 = llvm.or %19, %20 : i64 + %22 = llvm.and %9, %7 : i64 + %23 = llvm.or %21, %22 : i64 + %24 = llvm.and %11, %8 : i64 + %25 = llvm.or %23, %24 : i64 + llvm.return %25 : i64 + } + llvm.func @or_or_and_noOneUse(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.and %arg0, %arg1 : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.and %arg0, %arg3 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.or %arg2, %1 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.or %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @or_or_and_pat1(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.udiv %0, %arg2 : i8 + %2 = llvm.and %arg0, %arg1 : i8 + %3 = llvm.and %arg0, %arg3 : i8 + %4 = llvm.or %1, %3 : i8 + %5 = llvm.or %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @or_or_and_pat2(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.udiv %0, %arg2 : i8 + %2 = llvm.and %arg0, %arg1 : i8 + %3 = llvm.and %arg3, %arg0 : i8 + %4 = llvm.or %1, %3 : i8 + %5 = llvm.or %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @or_or_and_pat3(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.udiv %0, %arg2 : i8 + %2 = llvm.and %arg0, %arg1 : i8 + %3 = llvm.and %arg1, %arg3 : i8 + %4 = llvm.or %1, %3 : i8 + %5 = llvm.or %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @or_or_and_pat4(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.udiv %0, %arg2 : i8 + %2 = llvm.and %arg0, %arg1 : i8 + %3 = llvm.and %arg3, %arg1 : i8 + %4 = llvm.or %1, %3 : i8 + %5 = llvm.or %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @or_or_and_pat5(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.and %arg0, %arg1 : i8 + %1 = llvm.and %arg0, %arg3 : i8 + %2 = llvm.or %1, %arg2 : i8 + %3 = llvm.or %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @or_or_and_pat6(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.and %arg0, %arg1 : i8 + %1 = llvm.and %arg3, %arg0 : i8 + %2 = llvm.or %1, %arg2 : i8 + %3 = llvm.or %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @or_or_and_pat7(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.and %arg0, %arg1 : i8 + %1 = llvm.and %arg1, %arg3 : i8 + %2 = llvm.or %1, %arg2 : i8 + %3 = llvm.or %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @or_or_and_pat8(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.and %arg0, %arg1 : i8 + %1 = llvm.and %arg3, %arg1 : i8 + %2 = llvm.or %1, %arg2 : i8 + %3 = llvm.or %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @or_and_or_noOneUse(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.and %arg0, %arg1 : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.and %arg0, %arg3 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.or %arg2, %1 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.or %0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @or_and_or_pat1(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.udiv %0, %arg2 : i8 + %2 = llvm.and %arg0, %arg1 : i8 + %3 = llvm.and %arg0, %arg3 : i8 + %4 = llvm.or %1, %3 : i8 + %5 = llvm.or %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @or_and_or_pat2(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.udiv %0, %arg2 : i8 + %2 = llvm.and %arg0, %arg1 : i8 + %3 = llvm.and %arg3, %arg0 : i8 + %4 = llvm.or %1, %3 : i8 + %5 = llvm.or %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @or_and_or_pat3(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.udiv %0, %arg2 : i8 + %2 = llvm.and %arg0, %arg1 : i8 + %3 = llvm.and %arg1, %arg3 : i8 + %4 = llvm.or %1, %3 : i8 + %5 = llvm.or %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @or_and_or_pat4(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.udiv %0, %arg2 : i8 + %2 = llvm.and %arg0, %arg1 : i8 + %3 = llvm.and %arg3, %arg1 : i8 + %4 = llvm.or %1, %3 : i8 + %5 = llvm.or %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @or_and_or_pat5(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.and %arg0, %arg1 : i8 + %1 = llvm.and %arg0, %arg3 : i8 + %2 = llvm.or %1, %arg2 : i8 + %3 = llvm.or %0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @or_and_or_pat6(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.and %arg0, %arg1 : i8 + %1 = llvm.and %arg3, %arg0 : i8 + %2 = llvm.or %1, %arg2 : i8 + %3 = llvm.or %0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @or_and_or_pat7(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.and %arg0, %arg1 : i8 + %1 = llvm.and %arg1, %arg3 : i8 + %2 = llvm.or %1, %arg2 : i8 + %3 = llvm.or %0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @or_and_or_pat8(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.and %arg0, %arg1 : i8 + %1 = llvm.and %arg3, %arg1 : i8 + %2 = llvm.or %1, %arg2 : i8 + %3 = llvm.or %0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @use2(i32) + llvm.func @or_or_and_noOneUse_fail1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(23 : i32) : i32 + %1 = llvm.mlir.constant(925 : i32) : i32 + %2 = llvm.mlir.constant(157 : i32) : i32 + %3 = llvm.ashr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.zext %4 : i8 to i32 + %6 = llvm.and %5, %1 : i32 + llvm.call @use2(%6) : (i32) -> () + %7 = llvm.and %3, %arg1 : i32 + %8 = llvm.or %7, %6 : i32 + %9 = llvm.ashr %arg1, %0 : i32 + %10 = llvm.and %9, %2 : i32 + %11 = llvm.or %8, %10 : i32 + llvm.return %11 : i32 + } + llvm.func @or_or_and_noOneUse_fail2(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1, %arg5: i1, %arg6: i1, %arg7: i1) -> !llvm.struct<(i1, i1, i1, i1, i1)> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.undef : !llvm.struct<(i1, i1, i1, i1, i1)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<(i1, i1, i1, i1, i1)> + %4 = llvm.insertvalue %1, %3[1] : !llvm.struct<(i1, i1, i1, i1, i1)> + %5 = llvm.insertvalue %1, %4[2] : !llvm.struct<(i1, i1, i1, i1, i1)> + %6 = llvm.insertvalue %1, %5[3] : !llvm.struct<(i1, i1, i1, i1, i1)> + %7 = llvm.insertvalue %1, %6[4] : !llvm.struct<(i1, i1, i1, i1, i1)> + %8 = llvm.and %arg0, %arg4 : i1 + %9 = llvm.and %arg3, %arg7 : i1 + %10 = llvm.xor %arg2, %arg6 : i1 + %11 = llvm.and %arg1, %arg5 : i1 + %12 = llvm.xor %11, %0 : i1 + %13 = llvm.and %8, %arg1 : i1 + %14 = llvm.and %10, %arg5 : i1 + %15 = llvm.or %11, %14 : i1 + %16 = llvm.or %15, %13 : i1 + %17 = llvm.xor %16, %0 : i1 + %18 = llvm.xor %17, %0 : i1 + %19 = llvm.xor %9, %0 : i1 + %20 = llvm.and %19, %12 : i1 + %21 = llvm.xor %20, %0 : i1 + %22 = llvm.insertvalue %18, %7[0] : !llvm.struct<(i1, i1, i1, i1, i1)> + %23 = llvm.insertvalue %12, %22[1] : !llvm.struct<(i1, i1, i1, i1, i1)> + %24 = llvm.insertvalue %0, %23[2] : !llvm.struct<(i1, i1, i1, i1, i1)> + %25 = llvm.insertvalue %arg3, %24[3] : !llvm.struct<(i1, i1, i1, i1, i1)> + %26 = llvm.insertvalue %21, %25[4] : !llvm.struct<(i1, i1, i1, i1, i1)> + llvm.return %26 : !llvm.struct<(i1, i1, i1, i1, i1)> + } +} diff --git a/test/LLVMDialect/InstCombine/and-xor-merge.ll.mlir b/test/LLVMDialect/InstCombine/and-xor-merge.ll.mlir index 108ec3a03..dc1057425 100644 --- a/test/LLVMDialect/InstCombine/and-xor-merge.ll.mlir +++ b/test/LLVMDialect/InstCombine/and-xor-merge.ll.mlir @@ -1,28 +1,48 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.and"(%arg2, %arg0) : (i32, i32) -> i32 - %1 = "llvm.and"(%arg2, %arg1) : (i32, i32) -> i32 - %2 = "llvm.xor"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.and"(%arg1, %arg0) : (i32, i32) -> i32 - %1 = "llvm.or"(%arg1, %arg0) : (i32, i32) -> i32 - %2 = "llvm.xor"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.xor"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.lshr"(%arg1, %1) : (i32, i32) -> i32 - %5 = "llvm.xor"(%4, %0) : (i32, i32) -> i32 - %6 = "llvm.and"(%5, %3) : (i32, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "PR38781", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.and %arg2, %arg0 : i32 + %1 = llvm.and %arg2, %arg1 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.and %arg1, %arg0 : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @PR38781(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.xor %2, %1 : i32 + %4 = llvm.lshr %arg1, %0 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.and %5, %3 : i32 + llvm.return %6 : i32 + } + llvm.func @PR75692_1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(-5 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @PR75692_2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(-4 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @PR75692_3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(-5 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %arg1, %1 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/and-xor-or.ll.mlir b/test/LLVMDialect/InstCombine/and-xor-or.ll.mlir new file mode 100644 index 000000000..76feb7d78 --- /dev/null +++ b/test/LLVMDialect/InstCombine/and-xor-or.ll.mlir @@ -0,0 +1,2613 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g() {addr_space = 0 : i32} : i8 + llvm.func @use(i32) + llvm.func @use_i8(i8) + llvm.func @use_i1(i1) + llvm.func @and_xor_common_op(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(43 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.udiv %1, %arg1 : i32 + %4 = llvm.xor %2, %3 : i32 + %5 = llvm.and %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @and_xor_common_op_commute1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(43 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.udiv %1, %arg1 : i32 + %4 = llvm.xor %3, %2 : i32 + %5 = llvm.and %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @and_xor_common_op_commute2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(43 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.udiv %1, %arg1 : i32 + %4 = llvm.xor %3, %2 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @and_xor_common_op_commute3(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 43]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[43, 42]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.udiv %0, %arg0 : vector<2xi32> + %3 = llvm.udiv %1, %arg1 : vector<2xi32> + %4 = llvm.xor %2, %3 : vector<2xi32> + %5 = llvm.and %4, %2 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @and_xor_common_op_constant(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.xor %arg0, %0 : vector<4xi32> + %2 = llvm.and %0, %1 : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @and_xor_not_common_op(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %1 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @and_xor_not_common_op_extrause(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + llvm.store %1, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %2 = llvm.xor %arg0, %1 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @and_not_xor_common_op(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @gen32() -> i32 + llvm.func @and_not_xor_common_op_commutative(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.xor %1, %arg0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.and %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @or(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.and %arg1, %arg0 : i64 + %1 = llvm.xor %arg1, %arg0 : i64 + %2 = llvm.add %0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @or2(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.and %arg1, %arg0 : i64 + %1 = llvm.xor %arg1, %arg0 : i64 + %2 = llvm.or %0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @and_xor_or1(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.udiv %0, %arg0 : i64 + %2 = llvm.udiv %0, %arg1 : i64 + %3 = llvm.udiv %0, %arg2 : i64 + %4 = llvm.and %1, %2 : i64 + %5 = llvm.xor %4, %3 : i64 + %6 = llvm.or %5, %2 : i64 + llvm.return %6 : i64 + } + llvm.func @and_xor_or2(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.udiv %0, %arg0 : i64 + %2 = llvm.udiv %0, %arg1 : i64 + %3 = llvm.udiv %0, %arg2 : i64 + %4 = llvm.and %2, %1 : i64 + %5 = llvm.xor %4, %3 : i64 + %6 = llvm.or %5, %2 : i64 + llvm.return %6 : i64 + } + llvm.func @and_xor_or3(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.udiv %0, %arg0 : i64 + %2 = llvm.udiv %0, %arg1 : i64 + %3 = llvm.udiv %0, %arg2 : i64 + %4 = llvm.and %1, %2 : i64 + %5 = llvm.xor %3, %4 : i64 + %6 = llvm.or %5, %2 : i64 + llvm.return %6 : i64 + } + llvm.func @and_xor_or4(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.udiv %0, %arg0 : i64 + %2 = llvm.udiv %0, %arg1 : i64 + %3 = llvm.udiv %0, %arg2 : i64 + %4 = llvm.and %2, %1 : i64 + %5 = llvm.xor %3, %4 : i64 + %6 = llvm.or %5, %2 : i64 + llvm.return %6 : i64 + } + llvm.func @and_xor_or5(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.udiv %0, %arg0 : i64 + %2 = llvm.udiv %0, %arg1 : i64 + %3 = llvm.udiv %0, %arg2 : i64 + %4 = llvm.and %1, %2 : i64 + %5 = llvm.xor %4, %3 : i64 + %6 = llvm.or %2, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @and_xor_or6(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.udiv %0, %arg0 : i64 + %2 = llvm.udiv %0, %arg1 : i64 + %3 = llvm.udiv %0, %arg2 : i64 + %4 = llvm.and %2, %1 : i64 + %5 = llvm.xor %4, %3 : i64 + %6 = llvm.or %2, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @and_xor_or7(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.udiv %0, %arg0 : i64 + %2 = llvm.udiv %0, %arg1 : i64 + %3 = llvm.udiv %0, %arg2 : i64 + %4 = llvm.and %1, %2 : i64 + %5 = llvm.xor %3, %4 : i64 + %6 = llvm.or %2, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @and_xor_or8(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.udiv %0, %arg0 : i64 + %2 = llvm.udiv %0, %arg1 : i64 + %3 = llvm.udiv %0, %arg2 : i64 + %4 = llvm.and %2, %1 : i64 + %5 = llvm.xor %3, %4 : i64 + %6 = llvm.or %2, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @and_xor_or_negative(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i64 { + %0 = llvm.and %arg1, %arg0 : i64 + %1 = llvm.xor %arg2, %0 : i64 + %2 = llvm.or %arg3, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @and_shl(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.shl %arg0, %arg3 : i8 + %1 = llvm.shl %arg1, %arg3 : i8 + %2 = llvm.and %0, %arg2 : i8 + %3 = llvm.and %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @or_shl(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.shl %arg0, %arg3 : i8 + %1 = llvm.shl %arg1, %arg3 : i8 + %2 = llvm.or %0, %arg2 : i8 + %3 = llvm.or %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @xor_shl(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sdiv %0, %arg2 : i8 + %2 = llvm.shl %arg0, %arg3 : i8 + %3 = llvm.shl %arg1, %arg3 : i8 + %4 = llvm.xor %1, %2 : i8 + %5 = llvm.xor %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @and_lshr(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sdiv %0, %arg2 : i8 + %2 = llvm.lshr %arg0, %arg3 : i8 + %3 = llvm.lshr %arg1, %arg3 : i8 + %4 = llvm.and %1, %2 : i8 + %5 = llvm.and %3, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @or_lshr(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg3 : i8 + %1 = llvm.lshr %arg1, %arg3 : i8 + %2 = llvm.or %0, %arg2 : i8 + %3 = llvm.or %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @xor_lshr(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg3 : i8 + %1 = llvm.lshr %arg1, %arg3 : i8 + %2 = llvm.xor %0, %arg2 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @and_ashr(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sdiv %0, %arg2 : i8 + %2 = llvm.ashr %arg0, %arg3 : i8 + %3 = llvm.ashr %arg1, %arg3 : i8 + %4 = llvm.and %1, %2 : i8 + %5 = llvm.and %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @or_ashr(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sdiv %0, %arg2 : i8 + %2 = llvm.ashr %arg0, %arg3 : i8 + %3 = llvm.ashr %arg1, %arg3 : i8 + %4 = llvm.or %1, %2 : i8 + %5 = llvm.or %3, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @xor_ashr(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.ashr %arg0, %arg3 : vector<2xi8> + %1 = llvm.ashr %arg1, %arg3 : vector<2xi8> + %2 = llvm.xor %0, %arg2 : vector<2xi8> + %3 = llvm.xor %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @or_and_shl(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.shl %arg0, %arg3 : i8 + %1 = llvm.shl %arg1, %arg3 : i8 + %2 = llvm.or %0, %arg2 : i8 + %3 = llvm.and %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @or_lshr_shl(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg3 : i8 + %1 = llvm.shl %arg1, %arg3 : i8 + %2 = llvm.or %0, %arg2 : i8 + %3 = llvm.or %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @or_lshr_shamt2(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.lshr %arg1, %arg3 : i8 + %3 = llvm.or %1, %arg2 : i8 + %4 = llvm.or %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @xor_lshr_multiuse(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg3 : i8 + %1 = llvm.lshr %arg1, %arg3 : i8 + %2 = llvm.xor %0, %arg2 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.sdiv %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @sext_or_chain(%arg0: i64, %arg1: i16, %arg2: i16) -> i64 { + %0 = llvm.sext %arg1 : i16 to i64 + %1 = llvm.sext %arg2 : i16 to i64 + %2 = llvm.or %arg0, %0 : i64 + %3 = llvm.or %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @zext_or_chain(%arg0: i64, %arg1: i16, %arg2: i16) -> i64 { + %0 = llvm.zext %arg1 : i16 to i64 + %1 = llvm.zext %arg2 : i16 to i64 + %2 = llvm.or %arg0, %0 : i64 + %3 = llvm.or %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @sext_and_chain(%arg0: i64, %arg1: i16, %arg2: i16) -> i64 { + %0 = llvm.sext %arg1 : i16 to i64 + %1 = llvm.sext %arg2 : i16 to i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.and %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @zext_and_chain(%arg0: i64, %arg1: i16, %arg2: i16) -> i64 { + %0 = llvm.zext %arg1 : i16 to i64 + %1 = llvm.zext %arg2 : i16 to i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.and %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @sext_xor_chain(%arg0: i64, %arg1: i16, %arg2: i16) -> i64 { + %0 = llvm.sext %arg1 : i16 to i64 + %1 = llvm.sext %arg2 : i16 to i64 + %2 = llvm.xor %arg0, %0 : i64 + %3 = llvm.xor %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @zext_xor_chain(%arg0: i64, %arg1: i16, %arg2: i16) -> i64 { + %0 = llvm.zext %arg1 : i16 to i64 + %1 = llvm.zext %arg2 : i16 to i64 + %2 = llvm.xor %arg0, %0 : i64 + %3 = llvm.xor %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @sext_or_chain_two_uses1(%arg0: i64, %arg1: i16, %arg2: i16, %arg3: i64) -> i64 { + %0 = llvm.sext %arg1 : i16 to i64 + %1 = llvm.sext %arg2 : i16 to i64 + %2 = llvm.or %arg0, %0 : i64 + %3 = llvm.or %2, %1 : i64 + %4 = llvm.udiv %2, %arg3 : i64 + %5 = llvm.udiv %3, %4 : i64 + llvm.return %5 : i64 + } + llvm.func @sext_or_chain_two_uses2(%arg0: i64, %arg1: i16, %arg2: i16, %arg3: i64) -> i64 { + %0 = llvm.sext %arg1 : i16 to i64 + %1 = llvm.sext %arg2 : i16 to i64 + %2 = llvm.or %arg0, %0 : i64 + %3 = llvm.or %2, %1 : i64 + %4 = llvm.udiv %3, %arg3 : i64 + %5 = llvm.udiv %3, %4 : i64 + llvm.return %5 : i64 + } + llvm.func @not_and_and_not(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.xor %arg1, %1 : i32 + %4 = llvm.xor %arg2, %1 : i32 + %5 = llvm.and %2, %3 : i32 + %6 = llvm.and %5, %4 : i32 + llvm.return %6 : i32 + } + llvm.func @not_and_and_not_4i64(%arg0: vector<4xi64>, %arg1: vector<4xi64>, %arg2: vector<4xi64>) -> vector<4xi64> { + %0 = llvm.mlir.constant(dense<42> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mlir.constant(dense<-1> : vector<4xi64>) : vector<4xi64> + %2 = llvm.sdiv %0, %arg0 : vector<4xi64> + %3 = llvm.xor %arg1, %1 : vector<4xi64> + %4 = llvm.xor %arg2, %1 : vector<4xi64> + %5 = llvm.and %2, %3 : vector<4xi64> + %6 = llvm.and %5, %4 : vector<4xi64> + llvm.return %6 : vector<4xi64> + } + llvm.func @not_and_and_not_commute1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %1, %arg0 : i32 + %4 = llvm.and %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @not_and_and_not_commute2_extra_not_use(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.xor %arg1, %1 : i32 + %4 = llvm.xor %arg2, %1 : i32 + %5 = llvm.and %2, %3 : i32 + %6 = llvm.and %4, %5 : i32 + llvm.call @use(%4) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_and_and_not_extra_and1_use(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.xor %arg1, %1 : i32 + %4 = llvm.xor %arg2, %1 : i32 + %5 = llvm.and %2, %3 : i32 + %6 = llvm.and %5, %4 : i32 + llvm.call @use(%5) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_or_or_not(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.xor %arg1, %1 : i32 + %4 = llvm.xor %arg2, %1 : i32 + %5 = llvm.or %2, %3 : i32 + %6 = llvm.or %5, %4 : i32 + llvm.return %6 : i32 + } + llvm.func @not_or_or_not_2i6(%arg0: vector<2xi6>, %arg1: vector<2xi6>, %arg2: vector<2xi6>) -> vector<2xi6> { + %0 = llvm.mlir.constant(3 : i6) : i6 + %1 = llvm.mlir.constant(dense<3> : vector<2xi6>) : vector<2xi6> + %2 = llvm.mlir.constant(-1 : i6) : i6 + %3 = llvm.mlir.constant(dense<-1> : vector<2xi6>) : vector<2xi6> + %4 = llvm.mlir.poison : i6 + %5 = llvm.mlir.undef : vector<2xi6> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<2xi6> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %4, %7[%8 : i32] : vector<2xi6> + %10 = llvm.sdiv %1, %arg0 : vector<2xi6> + %11 = llvm.xor %arg1, %3 : vector<2xi6> + %12 = llvm.xor %arg2, %9 : vector<2xi6> + %13 = llvm.or %10, %11 : vector<2xi6> + %14 = llvm.or %13, %12 : vector<2xi6> + llvm.return %14 : vector<2xi6> + } + llvm.func @not_or_or_not_commute1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.or %1, %arg0 : i32 + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @not_or_or_not_commute2_extra_not_use(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.xor %arg1, %1 : i32 + %4 = llvm.xor %arg2, %1 : i32 + %5 = llvm.or %2, %3 : i32 + %6 = llvm.or %4, %5 : i32 + llvm.call @use(%4) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_or_or_not_extra_or1_use(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.xor %arg1, %1 : i32 + %4 = llvm.xor %arg2, %1 : i32 + %5 = llvm.or %2, %3 : i32 + %6 = llvm.or %5, %4 : i32 + llvm.call @use(%5) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @or_not_and(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg2 : i32 + %4 = llvm.or %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %5, %arg1 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_not_and_commute1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg1 : i32 + %3 = llvm.or %arg0, %2 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.and %4, %arg2 : i32 + %6 = llvm.or %arg0, %arg2 : i32 + %7 = llvm.xor %6, %1 : i32 + %8 = llvm.and %2, %7 : i32 + %9 = llvm.or %5, %8 : i32 + llvm.return %9 : i32 + } + llvm.func @or_not_and_commute2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg1 : i32 + %3 = llvm.or %arg0, %2 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.and %4, %arg2 : i32 + %6 = llvm.or %arg0, %arg2 : i32 + %7 = llvm.xor %6, %1 : i32 + %8 = llvm.and %2, %7 : i32 + %9 = llvm.or %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @or_not_and_commute3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg2 : i32 + %4 = llvm.or %arg2, %arg0 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %5, %arg1 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_not_and_commute4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg2 : i32 + %3 = llvm.or %arg0, %arg1 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.and %2, %4 : i32 + %6 = llvm.or %arg0, %2 : i32 + %7 = llvm.xor %6, %1 : i32 + %8 = llvm.and %7, %arg1 : i32 + %9 = llvm.or %5, %8 : i32 + llvm.return %9 : i32 + } + llvm.func @or_not_and_commute5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.sdiv %0, %arg2 : i32 + %4 = llvm.or %2, %arg1 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.and %3, %5 : i32 + %7 = llvm.or %2, %3 : i32 + %8 = llvm.xor %7, %1 : i32 + %9 = llvm.and %8, %arg1 : i32 + %10 = llvm.or %6, %9 : i32 + llvm.return %10 : i32 + } + llvm.func @or_not_and_commute6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg2 : i32 + %4 = llvm.or %arg2, %arg0 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %5, %arg1 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_not_and_commute7(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg2 : i32 + %4 = llvm.or %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %5, %arg1 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_not_and_commute8(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.sdiv %0, %arg1 : i32 + %4 = llvm.or %2, %3 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.and %5, %arg2 : i32 + %7 = llvm.or %arg2, %2 : i32 + %8 = llvm.xor %7, %1 : i32 + %9 = llvm.and %3, %8 : i32 + %10 = llvm.or %6, %9 : i32 + llvm.return %10 : i32 + } + llvm.func @or_not_and_commute9(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.sdiv %0, %arg1 : i32 + %4 = llvm.sdiv %0, %arg2 : i32 + %5 = llvm.or %2, %3 : i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.and %6, %4 : i32 + %8 = llvm.or %2, %4 : i32 + %9 = llvm.xor %8, %1 : i32 + %10 = llvm.and %3, %9 : i32 + %11 = llvm.or %7, %10 : i32 + llvm.return %11 : i32 + } + llvm.func @or_not_and_extra_not_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg2 : i32 + %4 = llvm.or %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %5, %arg1 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @or_not_and_extra_not_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg2 : i32 + %4 = llvm.or %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %5, %arg1 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.call @use(%5) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @or_not_and_extra_and_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg2 : i32 + %4 = llvm.or %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %5, %arg1 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @or_not_and_extra_and_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg2 : i32 + %4 = llvm.or %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %5, %arg1 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.call @use(%6) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @or_not_and_extra_or_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg2 : i32 + %4 = llvm.or %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %5, %arg1 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.call @use(%1) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @or_not_and_extra_or_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg2 : i32 + %4 = llvm.or %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %5, %arg1 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.call @use(%4) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @or_not_and_wrong_c(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg2 : i32 + %4 = llvm.or %arg0, %arg3 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %5, %arg1 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_not_and_wrong_b(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg2 : i32 + %4 = llvm.or %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %5, %arg3 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @and_not_or(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg2 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.or %5, %arg1 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @and_not_or_commute1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg1 : i32 + %3 = llvm.and %arg0, %2 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.or %4, %arg2 : i32 + %6 = llvm.and %arg0, %arg2 : i32 + %7 = llvm.xor %6, %1 : i32 + %8 = llvm.or %2, %7 : i32 + %9 = llvm.and %5, %8 : i32 + llvm.return %9 : i32 + } + llvm.func @and_not_or_commute2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg1 : i32 + %3 = llvm.and %arg0, %2 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.or %4, %arg2 : i32 + %6 = llvm.and %arg0, %arg2 : i32 + %7 = llvm.xor %6, %1 : i32 + %8 = llvm.or %2, %7 : i32 + %9 = llvm.and %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @and_not_or_commute3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg2 : i32 + %4 = llvm.and %arg2, %arg0 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.or %5, %arg1 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @and_not_or_commute4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg2 : i32 + %3 = llvm.and %arg0, %arg1 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.or %2, %4 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.xor %6, %1 : i32 + %8 = llvm.or %7, %arg1 : i32 + %9 = llvm.and %5, %8 : i32 + llvm.return %9 : i32 + } + llvm.func @and_not_or_commute5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.sdiv %0, %arg2 : i32 + %4 = llvm.and %2, %arg1 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.or %3, %5 : i32 + %7 = llvm.and %2, %3 : i32 + %8 = llvm.xor %7, %1 : i32 + %9 = llvm.or %8, %arg1 : i32 + %10 = llvm.and %6, %9 : i32 + llvm.return %10 : i32 + } + llvm.func @and_not_or_commute6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg2 : i32 + %4 = llvm.and %arg2, %arg0 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.or %5, %arg1 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @and_not_or_commute7(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg2 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.or %5, %arg1 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @and_not_or_commute8(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.sdiv %0, %arg1 : i32 + %4 = llvm.and %2, %3 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.or %5, %arg2 : i32 + %7 = llvm.and %arg2, %2 : i32 + %8 = llvm.xor %7, %1 : i32 + %9 = llvm.or %3, %8 : i32 + %10 = llvm.and %6, %9 : i32 + llvm.return %10 : i32 + } + llvm.func @and_not_or_commute9(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.sdiv %0, %arg1 : i32 + %4 = llvm.sdiv %0, %arg2 : i32 + %5 = llvm.and %2, %3 : i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.or %6, %4 : i32 + %8 = llvm.and %2, %4 : i32 + %9 = llvm.xor %8, %1 : i32 + %10 = llvm.or %3, %9 : i32 + %11 = llvm.and %7, %10 : i32 + llvm.return %11 : i32 + } + llvm.func @and_not_or_extra_not_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg2 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.or %5, %arg1 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @and_not_or_extra_not_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg2 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.or %5, %arg1 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.call @use(%5) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @and_not_or_extra_and_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg2 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.or %5, %arg1 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @and_not_or_extra_and_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg2 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.or %5, %arg1 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.call @use(%6) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @and_not_or_extra_or_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg2 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.or %5, %arg1 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.call @use(%1) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @and_not_or_extra_or_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg2 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.or %5, %arg1 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.call @use(%4) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @and_not_or_wrong_c(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg2 : i32 + %4 = llvm.and %arg0, %arg3 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.or %5, %arg1 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @and_not_or_wrong_b(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg2 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.or %5, %arg3 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_and_not_not(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @or_and_not_not_commute1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg1 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.or %arg0, %arg2 : i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.and %2, %6 : i32 + %8 = llvm.or %7, %4 : i32 + llvm.return %8 : i32 + } + llvm.func @or_and_not_not_commute2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @or_and_not_not_commute3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg2, %arg0 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @or_and_not_not_commute4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @or_and_not_not_commute5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %2, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @or_and_not_not_commute6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg1 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.or %arg2, %arg0 : i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.and %2, %6 : i32 + %8 = llvm.or %7, %4 : i32 + llvm.return %8 : i32 + } + llvm.func @or_and_not_not_commute7(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg2, %arg0 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @or_and_not_not_extra_not_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @or_and_not_not_extra_not_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.call @use(%4) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @or_and_not_not_extra_and_use(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.call @use(%5) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @or_and_not_not_extra_or_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.call @use(%1) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @or_and_not_not_extra_or_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @or_and_not_not_2_extra_uses(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + llvm.call @use(%5) : (i32) -> () + %6 = llvm.or %2, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @or_and_not_not_wrong_a(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg3 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @or_and_not_not_wrong_b(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg3, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @and_or_not_not(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @and_or_not_not_commute1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.and %arg0, %arg2 : i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.or %2, %6 : i32 + %8 = llvm.and %7, %4 : i32 + llvm.return %8 : i32 + } + llvm.func @and_or_not_not_commute2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @and_or_not_not_commute3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg2, %arg0 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @and_or_not_not_commute4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @and_or_not_not_commute5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %2, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @and_or_not_not_commute6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.and %arg2, %arg0 : i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.or %2, %6 : i32 + %8 = llvm.and %7, %4 : i32 + llvm.return %8 : i32 + } + llvm.func @and_or_not_not_commute7(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg2, %arg0 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @and_or_not_not_extra_not_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @and_or_not_not_extra_not_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.call @use(%4) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @and_or_not_not_extra_and_use(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.call @use(%5) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @and_or_not_not_extra_or_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.call @use(%1) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @and_or_not_not_extra_or_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @and_or_not_not_2_extra_uses(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + llvm.call @use(%5) : (i32) -> () + %6 = llvm.and %2, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @and_or_not_not_wrong_a(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg3 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @and_or_not_not_wrong_b(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg3, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg0, %arg2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @and_not_or_or_not_or_xor(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.or %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @and_not_or_or_not_or_xor_commute1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg2, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.or %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @and_not_or_or_not_or_xor_commute2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.or %arg1, %arg2 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.and %2, %4 : i32 + %6 = llvm.xor %arg1, %arg2 : i32 + %7 = llvm.or %6, %2 : i32 + %8 = llvm.xor %7, %1 : i32 + %9 = llvm.or %5, %8 : i32 + llvm.return %9 : i32 + } + llvm.func @and_not_or_or_not_or_xor_commute3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.xor %arg2, %arg1 : i32 + %5 = llvm.or %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @and_not_or_or_not_or_xor_commute4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.or %arg1, %arg2 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.and %2, %4 : i32 + %6 = llvm.xor %arg1, %arg2 : i32 + %7 = llvm.or %2, %6 : i32 + %8 = llvm.xor %7, %1 : i32 + %9 = llvm.or %5, %8 : i32 + llvm.return %9 : i32 + } + llvm.func @and_not_or_or_not_or_xor_commute5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.or %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.or %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @and_not_or_or_not_or_xor_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.or %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.call @use(%1) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @and_not_or_or_not_or_xor_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.or %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @and_not_or_or_not_or_xor_use3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.or %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @and_not_or_or_not_or_xor_use4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.or %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.call @use(%4) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @and_not_or_or_not_or_xor_use5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.or %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.call @use(%5) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @and_not_or_or_not_or_xor_use6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.or %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.or %3, %6 : i32 + llvm.call @use(%6) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @or_not_and_and_not_and_xor(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_not_and_and_not_and_xor_commute1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg2, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_not_and_and_not_and_xor_commute2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.and %arg1, %arg2 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.or %2, %4 : i32 + %6 = llvm.xor %arg1, %arg2 : i32 + %7 = llvm.and %6, %2 : i32 + %8 = llvm.xor %7, %1 : i32 + %9 = llvm.and %5, %8 : i32 + llvm.return %9 : i32 + } + llvm.func @or_not_and_and_not_and_xor_commute3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.xor %arg2, %arg1 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_not_and_and_not_and_xor_commute4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.and %arg1, %arg2 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.or %2, %4 : i32 + %6 = llvm.xor %arg1, %arg2 : i32 + %7 = llvm.and %2, %6 : i32 + %8 = llvm.xor %7, %1 : i32 + %9 = llvm.and %5, %8 : i32 + llvm.return %9 : i32 + } + llvm.func @or_not_and_and_not_and_xor_commute5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.and %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @or_not_and_and_not_and_xor_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.call @use(%1) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @or_not_and_and_not_and_xor_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @or_not_and_and_not_and_xor_use3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @or_not_and_and_not_and_xor_use4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.call @use(%4) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @or_not_and_and_not_and_xor_use5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.call @use(%5) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @or_not_and_and_not_and_xor_use6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg2 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.xor %arg1, %arg2 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.xor %5, %0 : i32 + %7 = llvm.and %3, %6 : i32 + llvm.call @use(%6) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @not_and_and_or_not_or_or(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.or %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.and %5, %arg2 : i32 + %7 = llvm.or %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @not_and_and_or_not_or_or_commute1_or(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg2, %arg0 : i32 + %2 = llvm.or %1, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.and %5, %arg2 : i32 + %7 = llvm.or %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @not_and_and_or_not_or_or_commute2_or(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg2 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.and %5, %arg2 : i32 + %7 = llvm.or %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @not_and_and_or_not_or_or_commute1_and(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.or %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.and %4, %arg2 : i32 + %6 = llvm.and %5, %arg1 : i32 + %7 = llvm.or %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @not_and_and_or_not_or_or_commute2_and(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.or %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.and %arg1, %arg2 : i32 + %6 = llvm.and %5, %4 : i32 + %7 = llvm.or %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @not_and_and_or_not_or_or_commute1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.or %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.and %5, %arg2 : i32 + %7 = llvm.or %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @not_and_and_or_not_or_or_commute2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg2 : i32 + %3 = llvm.or %arg1, %arg0 : i32 + %4 = llvm.or %2, %3 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.xor %arg0, %1 : i32 + %7 = llvm.and %6, %arg1 : i32 + %8 = llvm.and %7, %2 : i32 + %9 = llvm.or %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @not_and_and_or_not_or_or_commute3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg1 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.or %3, %arg2 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.xor %arg0, %1 : i32 + %7 = llvm.and %2, %6 : i32 + %8 = llvm.and %7, %arg2 : i32 + %9 = llvm.or %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @not_and_and_or_not_or_or_commute4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg2 : i32 + %3 = llvm.or %arg1, %arg0 : i32 + %4 = llvm.or %3, %2 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.xor %arg0, %1 : i32 + %7 = llvm.and %6, %arg1 : i32 + %8 = llvm.and %2, %7 : i32 + %9 = llvm.or %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @not_and_and_or_not_or_or_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.or %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.and %5, %arg2 : i32 + %7 = llvm.or %6, %3 : i32 + llvm.call @use(%1) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @not_and_and_or_not_or_or_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.or %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.and %5, %arg2 : i32 + %7 = llvm.or %6, %3 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @not_and_and_or_not_or_or_use3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.or %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.and %5, %arg2 : i32 + %7 = llvm.or %6, %3 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @not_and_and_or_not_or_or_use4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.or %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.and %5, %arg2 : i32 + %7 = llvm.or %6, %3 : i32 + llvm.call @use(%4) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @not_and_and_or_not_or_or_use5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.or %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.and %5, %arg2 : i32 + %7 = llvm.or %6, %3 : i32 + llvm.call @use(%5) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @not_and_and_or_not_or_or_use6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.or %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.and %5, %arg2 : i32 + %7 = llvm.or %6, %3 : i32 + llvm.call @use(%6) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @not_or_or_and_not_and_and(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.or %5, %arg2 : i32 + %7 = llvm.and %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @not_or_or_and_not_and_and_commute1_and(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg2, %arg0 : i32 + %2 = llvm.and %1, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.or %5, %arg2 : i32 + %7 = llvm.and %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @not_or_or_and_not_and_and_commute2_and(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg2 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.or %5, %arg2 : i32 + %7 = llvm.and %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @not_or_or_and_not_and_and_commute1_or(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.or %4, %arg2 : i32 + %6 = llvm.or %5, %arg1 : i32 + %7 = llvm.and %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @not_or_or_and_not_and_and_commute2_or(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.or %arg1, %arg2 : i32 + %6 = llvm.or %5, %4 : i32 + %7 = llvm.and %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @not_or_or_and_not_and_and_commute1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.or %5, %arg2 : i32 + %7 = llvm.and %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @not_or_or_and_not_and_and_commute2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg2 : i32 + %3 = llvm.and %arg1, %arg0 : i32 + %4 = llvm.and %2, %3 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.xor %arg0, %1 : i32 + %7 = llvm.or %6, %arg1 : i32 + %8 = llvm.or %7, %2 : i32 + %9 = llvm.and %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @not_or_or_and_not_and_and_commute3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.and %3, %arg2 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.xor %arg0, %1 : i32 + %7 = llvm.or %2, %6 : i32 + %8 = llvm.or %7, %arg2 : i32 + %9 = llvm.and %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @not_or_or_and_not_and_and_commute4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg2 : i32 + %3 = llvm.and %arg1, %arg0 : i32 + %4 = llvm.and %3, %2 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.xor %arg0, %1 : i32 + %7 = llvm.or %6, %arg1 : i32 + %8 = llvm.or %2, %7 : i32 + %9 = llvm.and %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @not_or_or_and_not_and_and_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.or %5, %arg2 : i32 + %7 = llvm.and %6, %3 : i32 + llvm.call @use(%1) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @not_or_or_and_not_and_and_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.or %5, %arg2 : i32 + %7 = llvm.and %6, %3 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @not_or_or_and_not_and_and_use3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.or %5, %arg2 : i32 + %7 = llvm.and %6, %3 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @not_or_or_and_not_and_and_use4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.or %5, %arg2 : i32 + %7 = llvm.and %6, %3 : i32 + llvm.call @use(%4) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @not_or_or_and_not_and_and_use5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.or %5, %arg2 : i32 + %7 = llvm.and %6, %3 : i32 + llvm.call @use(%5) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @not_or_or_and_not_and_and_use6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.or %5, %arg2 : i32 + %7 = llvm.and %6, %3 : i32 + llvm.call @use(%6) : (i32) -> () + llvm.return %7 : i32 + } + llvm.func @not_and_and_or_no_or(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.and %3, %arg1 : i32 + %5 = llvm.and %4, %arg2 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @not_and_and_or_no_or_commute1_and(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.and %arg2, %arg1 : i32 + %5 = llvm.and %4, %3 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @not_and_and_or_no_or_commute2_and(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.and %3, %arg2 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @not_and_and_or_no_or_commute1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.and %3, %arg1 : i32 + %5 = llvm.and %4, %arg2 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @not_and_and_or_no_or_commute2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg1 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.xor %arg0, %1 : i32 + %6 = llvm.and %2, %5 : i32 + %7 = llvm.and %6, %arg2 : i32 + %8 = llvm.or %7, %4 : i32 + llvm.return %8 : i32 + } + llvm.func @not_and_and_or_no_or_commute3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg2 : i32 + %3 = llvm.or %arg1, %arg0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.xor %arg0, %1 : i32 + %6 = llvm.and %5, %arg1 : i32 + %7 = llvm.and %2, %6 : i32 + %8 = llvm.or %7, %4 : i32 + llvm.return %8 : i32 + } + llvm.func @not_and_and_or_no_or_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.and %3, %arg1 : i32 + %5 = llvm.and %4, %arg2 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_and_and_or_no_or_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.and %arg1, %arg2 : i32 + %5 = llvm.and %4, %3 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_and_and_or_no_or_use3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.and %3, %arg2 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_and_and_or_no_or_use4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.and %3, %arg2 : i32 + %5 = llvm.and %4, %arg1 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_and_and_or_no_or_use5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.and %3, %arg1 : i32 + %5 = llvm.and %4, %arg2 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.call @use(%1) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_and_and_or_no_or_use6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.and %3, %arg1 : i32 + %5 = llvm.and %4, %arg2 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_and_and_or_no_or_use7(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.and %3, %arg1 : i32 + %5 = llvm.and %4, %arg2 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.call @use(%4) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_and_and_or_no_or_use8(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.and %3, %arg1 : i32 + %5 = llvm.and %4, %arg2 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.call @use(%5) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_or_or_and_no_and(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.or %3, %arg1 : i32 + %5 = llvm.or %4, %arg2 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @not_or_or_and_no_and_commute1_or(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.or %arg2, %arg1 : i32 + %5 = llvm.or %4, %3 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @not_or_or_and_no_and_commute2_or(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.or %3, %arg2 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @not_or_or_and_no_and_commute1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.or %3, %arg1 : i32 + %5 = llvm.or %4, %arg2 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @not_or_or_and_no_and_commute2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.xor %arg0, %1 : i32 + %6 = llvm.or %2, %5 : i32 + %7 = llvm.or %6, %arg2 : i32 + %8 = llvm.and %7, %4 : i32 + llvm.return %8 : i32 + } + llvm.func @not_or_or_and_no_and_commute3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg2 : i32 + %3 = llvm.and %arg1, %arg0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.xor %arg0, %1 : i32 + %6 = llvm.or %5, %arg1 : i32 + %7 = llvm.or %2, %6 : i32 + %8 = llvm.and %7, %4 : i32 + llvm.return %8 : i32 + } + llvm.func @not_or_or_and_no_and_use1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.or %3, %arg1 : i32 + %5 = llvm.or %4, %arg2 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_or_or_and_no_and_use2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.or %arg1, %arg2 : i32 + %5 = llvm.or %4, %3 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_or_or_and_no_and_use3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.or %3, %arg2 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_or_or_and_no_and_use4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.or %3, %arg2 : i32 + %5 = llvm.or %4, %arg1 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_or_or_and_no_and_use5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.or %3, %arg1 : i32 + %5 = llvm.or %4, %arg2 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.call @use(%1) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_or_or_and_no_and_use6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.or %3, %arg1 : i32 + %5 = llvm.or %4, %arg2 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_or_or_and_no_and_use7(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.or %3, %arg1 : i32 + %5 = llvm.or %4, %arg2 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.call @use(%4) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @not_or_or_and_no_and_use8(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.or %3, %arg1 : i32 + %5 = llvm.or %4, %arg2 : i32 + %6 = llvm.and %5, %2 : i32 + llvm.call @use(%5) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @and_orn_xor(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg0, %arg1 : i4 + %2 = llvm.xor %arg0, %0 : i4 + %3 = llvm.or %2, %arg1 : i4 + %4 = llvm.and %3, %1 : i4 + llvm.return %4 : i4 + } + llvm.func @and_orn_xor_commute1(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.poison : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.mlir.undef : vector<2xi4> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi4> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi4> + %7 = llvm.xor %arg0, %arg1 : vector<2xi4> + %8 = llvm.xor %arg0, %6 : vector<2xi4> + %9 = llvm.or %8, %arg1 : vector<2xi4> + %10 = llvm.and %7, %9 : vector<2xi4> + llvm.return %10 : vector<2xi4> + } + llvm.func @and_orn_xor_commute2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.or %2, %arg1 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @and_orn_xor_commute3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.or %2, %arg1 : i32 + %4 = llvm.and %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @and_orn_xor_commute5(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mul %arg0, %arg0 : i32 + %2 = llvm.mul %arg1, %arg1 : i32 + %3 = llvm.xor %1, %2 : i32 + %4 = llvm.xor %1, %0 : i32 + %5 = llvm.or %2, %4 : i32 + llvm.call @use(%5) : (i32) -> () + %6 = llvm.and %5, %3 : i32 + llvm.return %6 : i32 + } + llvm.func @and_orn_xor_commute6(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mul %arg0, %arg0 : i32 + %2 = llvm.mul %arg1, %arg1 : i32 + %3 = llvm.xor %1, %2 : i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.xor %1, %0 : i32 + llvm.call @use(%4) : (i32) -> () + %5 = llvm.or %2, %4 : i32 + %6 = llvm.and %3, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @and_orn_xor_commute7(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mul %arg0, %arg0 : i32 + %2 = llvm.mul %arg1, %arg1 : i32 + %3 = llvm.xor %2, %1 : i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.xor %1, %0 : i32 + llvm.call @use(%4) : (i32) -> () + %5 = llvm.or %2, %4 : i32 + llvm.call @use(%5) : (i32) -> () + %6 = llvm.and %5, %3 : i32 + llvm.return %6 : i32 + } + llvm.func @and_orn_xor_commute8(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mul %arg0, %arg0 : i32 + %2 = llvm.mul %arg1, %arg1 : i32 + %3 = llvm.xor %2, %1 : i32 + %4 = llvm.xor %1, %0 : i32 + %5 = llvm.or %2, %4 : i32 + %6 = llvm.and %3, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @zext_zext_and_uses(%arg0: i8, %arg1: i8) -> i32 { + %0 = llvm.zext %arg0 : i8 to i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.zext %arg1 : i8 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.and %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @sext_sext_or_uses(%arg0: i8, %arg1: i8) -> i32 { + %0 = llvm.sext %arg0 : i8 to i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.sext %arg1 : i8 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.or %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @trunc_trunc_xor_uses(%arg0: i65, %arg1: i65) -> i32 { + %0 = llvm.trunc %arg0 : i65 to i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.trunc %arg1 : i65 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @and_zext_zext(%arg0: i8, %arg1: i4) -> i16 { + %0 = llvm.zext %arg0 : i8 to i16 + %1 = llvm.zext %arg1 : i4 to i16 + %2 = llvm.and %0, %1 : i16 + llvm.return %2 : i16 + } + llvm.func @or_zext_zext(%arg0: i8, %arg1: i4) -> i16 { + %0 = llvm.zext %arg0 : i8 to i16 + %1 = llvm.zext %arg1 : i4 to i16 + %2 = llvm.or %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @xor_zext_zext(%arg0: vector<2xi8>, %arg1: vector<2xi4>) -> vector<2xi16> { + %0 = llvm.zext %arg0 : vector<2xi8> to vector<2xi16> + %1 = llvm.zext %arg1 : vector<2xi4> to vector<2xi16> + %2 = llvm.xor %0, %1 : vector<2xi16> + llvm.return %2 : vector<2xi16> + } + llvm.func @and_sext_sext(%arg0: i8, %arg1: i4) -> i16 { + %0 = llvm.sext %arg0 : i8 to i16 + %1 = llvm.sext %arg1 : i4 to i16 + %2 = llvm.and %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @or_sext_sext(%arg0: i8, %arg1: i4) -> i16 { + %0 = llvm.sext %arg0 : i8 to i16 + %1 = llvm.sext %arg1 : i4 to i16 + %2 = llvm.or %0, %1 : i16 + llvm.return %2 : i16 + } + llvm.func @xor_sext_sext(%arg0: i8, %arg1: i4) -> i16 { + %0 = llvm.sext %arg0 : i8 to i16 + %1 = llvm.sext %arg1 : i4 to i16 + %2 = llvm.xor %0, %1 : i16 + llvm.return %2 : i16 + } + llvm.func @and_zext_sext(%arg0: i8, %arg1: i4) -> i16 { + %0 = llvm.zext %arg0 : i8 to i16 + %1 = llvm.sext %arg1 : i4 to i16 + %2 = llvm.and %0, %1 : i16 + llvm.return %2 : i16 + } + llvm.func @and_zext_zext_use1(%arg0: i8, %arg1: i4) -> i32 { + %0 = llvm.zext %arg0 : i8 to i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.zext %arg1 : i4 to i32 + %2 = llvm.and %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @or_sext_sext_use1(%arg0: i8, %arg1: i4) -> i32 { + %0 = llvm.sext %arg0 : i8 to i32 + %1 = llvm.sext %arg1 : i4 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.or %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @PR56294(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.and %arg0, %1 : i8 + %5 = llvm.zext %3 : i1 to i32 + %6 = llvm.zext %4 : i8 to i32 + %7 = llvm.and %5, %6 : i32 + %8 = llvm.icmp "ne" %7, %2 : i32 + llvm.return %8 : i1 + } + llvm.func @canonicalize_logic_first_or0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(112 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.or %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @canonicalize_logic_first_or0_nsw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(112 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.or %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @canonicalize_logic_first_or0_nswnuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(112 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.or %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @canonicalize_logic_first_or_vector0(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<112> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 : vector<2xi32> + %3 = llvm.or %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @canonicalize_logic_first_or_vector0_nsw(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<112> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 overflow : vector<2xi32> + %3 = llvm.or %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @canonicalize_logic_first_or_vector0_nswnuw(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<112> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 overflow : vector<2xi32> + %3 = llvm.or %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @canonicalize_logic_first_or_vector1(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[-8388608, 2071986176]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[32783, 2063]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 : vector<2xi32> + %3 = llvm.or %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @canonicalize_logic_first_or_vector1_nsw(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[-8388608, 2071986176]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[32783, 2063]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 overflow : vector<2xi32> + %3 = llvm.or %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @canonicalize_logic_first_or_vector1_nswnuw(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[-8388608, 2071986176]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[32783, 2063]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 overflow : vector<2xi32> + %3 = llvm.or %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @canonicalize_logic_first_or_vector2(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[2147483632, 2147483640]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[32783, 2063]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 : vector<2xi32> + %3 = llvm.or %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @canonicalize_logic_first_or_mult_use1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(112 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.or %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @canonicalize_logic_first_or_bad_constraints2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(112 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.or %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @canonicalize_logic_first_and0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(48 : i8) : i8 + %1 = llvm.mlir.constant(-10 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @canonicalize_logic_first_and0_nsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(48 : i8) : i8 + %1 = llvm.mlir.constant(-10 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @canonicalize_logic_first_and0_nswnuw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(48 : i8) : i8 + %1 = llvm.mlir.constant(-10 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @canonicalize_logic_first_and_vector0(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<48> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-10> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %0, %arg0 : vector<2xi8> + %3 = llvm.and %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @canonicalize_logic_first_and_vector0_nsw(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<48> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-10> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %0, %arg0 overflow : vector<2xi8> + %3 = llvm.and %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @canonicalize_logic_first_and_vector0_nswnuw(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<48> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-10> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %0, %arg0 overflow : vector<2xi8> + %3 = llvm.and %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @canonicalize_logic_first_and_vector1(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[48, 32]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-10, -4]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %0, %arg0 : vector<2xi8> + %3 = llvm.and %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @canonicalize_logic_first_and_vector2(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<612368384> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-65536, -32768]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 : vector<2xi32> + %3 = llvm.and %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @canonicalize_logic_first_and_vector3(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[32768, 16384]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-65536, -32768]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 : vector<2xi32> + %3 = llvm.and %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @canonicalize_logic_first_and_mult_use1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(48 : i8) : i8 + %1 = llvm.mlir.constant(-10 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + llvm.call @use_i8(%2) : (i8) -> () + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @canonicalize_logic_first_and_bad_constraints2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(48 : i8) : i8 + %1 = llvm.mlir.constant(-26 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @canonicalize_logic_first_xor_0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(96 : i8) : i8 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @canonicalize_logic_first_xor_0_nsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(96 : i8) : i8 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @canonicalize_logic_first_xor_0_nswnuw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(96 : i8) : i8 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @canonicalize_logic_first_xor_vector0(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-8388608> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<32783> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 : vector<2xi32> + %3 = llvm.xor %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @canonicalize_logic_first_xor_vector0_nsw(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-8388608> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<32783> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 overflow : vector<2xi32> + %3 = llvm.xor %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @canonicalize_logic_first_xor_vector0_nswnuw(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-8388608> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<32783> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 overflow : vector<2xi32> + %3 = llvm.xor %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @canonicalize_logic_first_xor_vector1(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[-8388608, 2071986176]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[32783, 2063]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 : vector<2xi32> + %3 = llvm.xor %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @canonicalize_logic_first_xor_vector2(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[2147483632, 2147483640]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[32783, 2063]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 : vector<2xi32> + %3 = llvm.xor %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @canonicalize_logic_first_xor_mult_use1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(96 : i8) : i8 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + llvm.call @use_i8(%2) : (i8) -> () + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @canonicalize_logic_first_xor_bad_constants2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(96 : i8) : i8 + %1 = llvm.mlir.constant(32 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @canonicalize_logic_first_constexpr(%arg0: i32) -> i32 { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i32 + %2 = llvm.mlir.constant(48 : i32) : i32 + %3 = llvm.mlir.constant(-10 : i32) : i32 + %4 = llvm.add %1, %2 : i32 + %5 = llvm.and %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @canonicalize_logic_first_constexpr_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i32 + %2 = llvm.mlir.constant(48 : i32) : i32 + %3 = llvm.mlir.constant(-10 : i32) : i32 + %4 = llvm.add %1, %2 overflow : i32 + %5 = llvm.and %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @test_and_xor_freely_invertable(%arg0: i32, %arg1: i32, %arg2: i1) -> i1 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %1 = llvm.xor %0, %arg2 : i1 + %2 = llvm.and %1, %arg2 : i1 + llvm.return %2 : i1 + } + llvm.func @test_and_xor_freely_invertable_multiuse(%arg0: i32, %arg1: i32, %arg2: i1) -> i1 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i32 + llvm.call @use_i1(%0) : (i1) -> () + %1 = llvm.xor %0, %arg2 : i1 + %2 = llvm.and %1, %arg2 : i1 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/and.ll.mlir b/test/LLVMDialect/InstCombine/and.ll.mlir new file mode 100644 index 000000000..f2d7fb0bf --- /dev/null +++ b/test/LLVMDialect/InstCombine/and.ll.mlir @@ -0,0 +1,1846 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g() {addr_space = 0 : i32} : i64 + llvm.func @use8(i8) + llvm.func @use16(i16) + llvm.func @use32(i32) + llvm.func @test_with_1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %0, %arg0 : i32 + %2 = llvm.and %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @test_with_3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test_with_5(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test_with_neg_5(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-5 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test_with_even(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.shl %0, %arg0 : vector<2xi32> + %3 = llvm.and %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @test_with_neg_even(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-4 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test_with_more_one_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.return %3 : i32 + } + llvm.func @test1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @test2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @test3(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.and %arg0, %0 : i1 + llvm.return %1 : i1 + } + llvm.func @test3_logical(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %0, %0 : i1, i1 + llvm.return %1 : i1 + } + llvm.func @test4(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.and %arg0, %0 : i1 + llvm.return %1 : i1 + } + llvm.func @test4_logical(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @test5(%arg0: i32) -> i32 { + %0 = llvm.and %arg0, %arg0 : i32 + llvm.return %0 : i32 + } + llvm.func @test6(%arg0: i1) -> i1 { + %0 = llvm.and %arg0, %arg0 : i1 + llvm.return %0 : i1 + } + llvm.func @test6_logical(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg0, %0 : i1, i1 + llvm.return %1 : i1 + } + llvm.func @test7(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.and %arg0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test8(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @test9(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test9a(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test10(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test11(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.xor %2, %1 : i32 + llvm.store %3, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.and %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @test12(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.icmp "ule" %arg0, %arg1 : i32 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test12_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.icmp "ult" %arg0, %arg1 : i32 + %2 = llvm.icmp "ule" %arg0, %arg1 : i32 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @test13(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test13_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.icmp "ult" %arg0, %arg1 : i32 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @test14(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @test15(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @test16(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @test18(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-128 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test18_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @test18a(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @test18a_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-2> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.and %arg0, %0 : vector<2xi8> + %4 = llvm.icmp "eq" %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @test19(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test20(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @test23(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "sle" %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test23_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.icmp "sle" %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @test23vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %3 = llvm.icmp "sle" %arg0, %1 : vector<2xi32> + %4 = llvm.and %2, %3 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @test24(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "ne" %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test24_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @test25(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(50 : i32) : i32 + %1 = llvm.mlir.constant(100 : i32) : i32 + %2 = llvm.icmp "sge" %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test25_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(50 : i32) : i32 + %1 = llvm.mlir.constant(100 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "sge" %arg0, %0 : i32 + %4 = llvm.icmp "slt" %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @test25vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<50> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<100> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "sge" %arg0, %0 : vector<2xi32> + %3 = llvm.icmp "slt" %arg0, %1 : vector<2xi32> + %4 = llvm.and %2, %3 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @test27(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(16 : i8) : i8 + %2 = llvm.mlir.constant(-16 : i8) : i8 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.sub %3, %1 : i8 + %5 = llvm.and %4, %2 : i8 + %6 = llvm.add %5, %1 : i8 + llvm.return %6 : i8 + } + llvm.func @ashr_lowmask(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_lowmask_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_lowmask_use_splat(%arg0: vector<2xi8>, %arg1: !llvm.ptr) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.ashr %arg0, %0 : vector<2xi8> + llvm.store %2, %arg1 {alignment = 2 : i64} : vector<2xi8>, !llvm.ptr + %3 = llvm.and %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @ashr_not_lowmask1_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(254 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_not_lowmask2_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(127 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_not_lowmask3_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(511 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test29(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.and %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @test30(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.and %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @test31(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.zext %arg0 : i1 to i32 + %3 = llvm.shl %2, %0 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @and_demanded_bits_splat_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<7> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %arg0, %0 : vector<2xi32> + %3 = llvm.and %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @and_zext_demanded(%arg0: i16, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.or %arg1, %1 : i32 + %5 = llvm.and %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @test32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %3, %1 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test33(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.or %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @test33b(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.or %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test33vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-2> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.xor %2, %0 : vector<2xi32> + %4 = llvm.and %arg0, %1 : vector<2xi32> + %5 = llvm.or %4, %3 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test33vecb(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-2> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.xor %2, %0 : vector<2xi32> + %4 = llvm.and %arg0, %1 : vector<2xi32> + %5 = llvm.or %3, %4 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test34(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg1, %arg0 : i32 + %1 = llvm.and %0, %arg1 : i32 + llvm.return %1 : i32 + } + llvm.func @PR24942(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.and %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @test35(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(240 : i64) : i64 + %2 = llvm.zext %arg0 : i32 to i64 + %3 = llvm.sub %0, %2 : i64 + %4 = llvm.and %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @test35_uniform(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.constant(dense<240> : vector<2xi64>) : vector<2xi64> + %3 = llvm.zext %arg0 : vector<2xi32> to vector<2xi64> + %4 = llvm.sub %1, %3 : vector<2xi64> + %5 = llvm.and %4, %2 : vector<2xi64> + llvm.return %5 : vector<2xi64> + } + llvm.func @test36(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.mlir.constant(240 : i64) : i64 + %2 = llvm.zext %arg0 : i32 to i64 + %3 = llvm.add %2, %0 : i64 + %4 = llvm.and %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @test36_uniform(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<240> : vector<2xi64>) : vector<2xi64> + %2 = llvm.zext %arg0 : vector<2xi32> to vector<2xi64> + %3 = llvm.add %2, %0 : vector<2xi64> + %4 = llvm.and %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test36_poison(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.poison : i64 + %1 = llvm.mlir.constant(7 : i64) : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.mlir.constant(240 : i64) : i64 + %8 = llvm.mlir.undef : vector<2xi64> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi64> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi64> + %13 = llvm.zext %arg0 : vector<2xi32> to vector<2xi64> + %14 = llvm.add %13, %6 : vector<2xi64> + %15 = llvm.and %14, %12 : vector<2xi64> + llvm.return %15 : vector<2xi64> + } + llvm.func @test37(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.mlir.constant(240 : i64) : i64 + %2 = llvm.zext %arg0 : i32 to i64 + %3 = llvm.mul %2, %0 : i64 + %4 = llvm.and %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @test37_uniform(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<240> : vector<2xi64>) : vector<2xi64> + %2 = llvm.zext %arg0 : vector<2xi32> to vector<2xi64> + %3 = llvm.mul %2, %0 : vector<2xi64> + %4 = llvm.and %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test37_nonuniform(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[7, 9]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<[240, 110]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.zext %arg0 : vector<2xi32> to vector<2xi64> + %3 = llvm.mul %2, %0 : vector<2xi64> + %4 = llvm.and %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test38(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.mlir.constant(240 : i64) : i64 + %2 = llvm.zext %arg0 : i32 to i64 + %3 = llvm.xor %2, %0 : i64 + %4 = llvm.and %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @test39(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.mlir.constant(240 : i64) : i64 + %2 = llvm.zext %arg0 : i32 to i64 + %3 = llvm.or %2, %0 : i64 + %4 = llvm.and %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @lowmask_add_zext(%arg0: i8, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.add %1, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @lowmask_add_zext_commute(%arg0: i16, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mul %arg1, %arg1 : i32 + %2 = llvm.zext %arg0 : i16 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.and %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @lowmask_add_zext_wrong_mask(%arg0: i8, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(511 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.add %1, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @lowmask_add_zext_use1(%arg0: i8, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.add %1, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @lowmask_add_zext_use2(%arg0: i8, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.add %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.and %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @lowmask_sub_zext(%arg0: vector<2xi4>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi4> to vector<2xi32> + %2 = llvm.sub %1, %arg1 : vector<2xi32> + %3 = llvm.and %2, %0 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @lowmask_sub_zext_commute(%arg0: i5, %arg1: i17) -> i17 { + %0 = llvm.mlir.constant(31 : i17) : i17 + %1 = llvm.zext %arg0 : i5 to i17 + %2 = llvm.sub %arg1, %1 : i17 + %3 = llvm.and %2, %0 : i17 + llvm.return %3 : i17 + } + llvm.func @lowmask_mul_zext(%arg0: i8, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.mul %1, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @lowmask_xor_zext_commute(%arg0: i8, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mul %arg1, %arg1 : i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.xor %1, %2 : i32 + %4 = llvm.and %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @lowmask_or_zext_commute(%arg0: i16, %arg1: i24) -> i24 { + %0 = llvm.mlir.constant(65535 : i24) : i24 + %1 = llvm.zext %arg0 : i16 to i24 + %2 = llvm.or %arg1, %1 : i24 + %3 = llvm.and %2, %0 : i24 + llvm.return %3 : i24 + } + llvm.func @test40(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1000 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.constant(123 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.and %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @test40vec(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1000> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<123> : vector<2xi32>) : vector<2xi32> + %3 = llvm.select %arg0, %0, %1 : i1, vector<2xi32> + %4 = llvm.and %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test40vec2(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[1000, 2500]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[10, 30]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[123, 333]> : vector<2xi32>) : vector<2xi32> + %3 = llvm.select %arg0, %0, %1 : i1, vector<2xi32> + %4 = llvm.and %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test41(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1000 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.constant(123 : i32) : i32 + llvm.cond_br %arg0, ^bb2(%0 : i32), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : i32) + ^bb2(%3: i32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.and %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @test41vec(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1000> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<123> : vector<2xi32>) : vector<2xi32> + llvm.cond_br %arg0, ^bb2(%0 : vector<2xi32>), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : vector<2xi32>) + ^bb2(%3: vector<2xi32>): // 2 preds: ^bb0, ^bb1 + %4 = llvm.and %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test41vec2(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[1000, 2500]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[10, 30]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[123, 333]> : vector<2xi32>) : vector<2xi32> + llvm.cond_br %arg0, ^bb2(%0 : vector<2xi32>), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : vector<2xi32>) + ^bb2(%3: vector<2xi32>): // 2 preds: ^bb0, ^bb1 + %4 = llvm.and %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test42(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mul %arg1, %arg2 : i32 + %2 = llvm.or %arg0, %1 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test43(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mul %arg1, %arg2 : i32 + %2 = llvm.or %arg0, %1 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.and %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test44(%arg0: i32, %arg1: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.and %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @test45(%arg0: i32, %arg1: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.or %arg0, %1 : i32 + %3 = llvm.and %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @test46(%arg0: i32, %arg1: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.and %arg1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test47(%arg0: i32, %arg1: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.or %arg0, %1 : i32 + %3 = llvm.and %arg1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @and_orn_cmp_1(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %2 = llvm.icmp "sle" %arg0, %arg1 : i32 + %3 = llvm.icmp "ugt" %arg2, %0 : i32 + %4 = llvm.or %3, %2 : i1 + %5 = llvm.and %1, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @and_orn_cmp_1_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %4 = llvm.icmp "sle" %arg0, %arg1 : i32 + %5 = llvm.icmp "ugt" %arg2, %0 : i32 + %6 = llvm.select %5, %1, %4 : i1, i1 + %7 = llvm.select %3, %6, %2 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @and_orn_cmp_2(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[42, 47]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "sge" %arg0, %arg1 : vector<2xi32> + %2 = llvm.icmp "slt" %arg0, %arg1 : vector<2xi32> + %3 = llvm.icmp "ugt" %arg2, %0 : vector<2xi32> + %4 = llvm.or %3, %2 : vector<2xi1> + %5 = llvm.and %4, %1 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @and_orn_cmp_3(%arg0: i72, %arg1: i72, %arg2: i72) -> i1 { + %0 = llvm.mlir.constant(42 : i72) : i72 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i72 + %2 = llvm.icmp "ule" %arg0, %arg1 : i72 + %3 = llvm.icmp "ugt" %arg2, %0 : i72 + %4 = llvm.or %2, %3 : i1 + %5 = llvm.and %1, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @and_orn_cmp_3_logical(%arg0: i72, %arg1: i72, %arg2: i72) -> i1 { + %0 = llvm.mlir.constant(42 : i72) : i72 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "ugt" %arg0, %arg1 : i72 + %4 = llvm.icmp "ule" %arg0, %arg1 : i72 + %5 = llvm.icmp "ugt" %arg2, %0 : i72 + %6 = llvm.select %4, %1, %5 : i1, i1 + %7 = llvm.select %3, %6, %2 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @or_andn_cmp_4(%arg0: vector<3xi32>, %arg1: vector<3xi32>, %arg2: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<[42, 43, -1]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.icmp "eq" %arg0, %arg1 : vector<3xi32> + %2 = llvm.icmp "ne" %arg0, %arg1 : vector<3xi32> + %3 = llvm.icmp "ugt" %arg2, %0 : vector<3xi32> + %4 = llvm.or %2, %3 : vector<3xi1> + %5 = llvm.and %4, %1 : vector<3xi1> + llvm.return %5 : vector<3xi1> + } + llvm.func @andn_or_cmp_1(%arg0: i37, %arg1: i37, %arg2: i37) -> i1 { + %0 = llvm.mlir.constant(42 : i37) : i37 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i37 + %2 = llvm.icmp "sle" %arg0, %arg1 : i37 + %3 = llvm.icmp "ugt" %arg2, %0 : i37 + %4 = llvm.or %3, %1 : i1 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @andn_or_cmp_1_logical(%arg0: i37, %arg1: i37, %arg2: i37) -> i1 { + %0 = llvm.mlir.constant(42 : i37) : i37 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "sgt" %arg0, %arg1 : i37 + %4 = llvm.icmp "sle" %arg0, %arg1 : i37 + %5 = llvm.icmp "ugt" %arg2, %0 : i37 + %6 = llvm.select %5, %1, %3 : i1, i1 + %7 = llvm.select %4, %6, %2 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @andn_or_cmp_2(%arg0: i16, %arg1: i16, %arg2: i16) -> i1 { + %0 = llvm.mlir.constant(42 : i16) : i16 + %1 = llvm.icmp "sge" %arg0, %arg1 : i16 + %2 = llvm.icmp "slt" %arg0, %arg1 : i16 + %3 = llvm.icmp "ugt" %arg2, %0 : i16 + %4 = llvm.or %3, %1 : i1 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @andn_or_cmp_2_logical(%arg0: i16, %arg1: i16, %arg2: i16) -> i1 { + %0 = llvm.mlir.constant(42 : i16) : i16 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "sge" %arg0, %arg1 : i16 + %4 = llvm.icmp "slt" %arg0, %arg1 : i16 + %5 = llvm.icmp "ugt" %arg2, %0 : i16 + %6 = llvm.select %5, %1, %3 : i1, i1 + %7 = llvm.select %6, %4, %2 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @andn_or_cmp_3(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<[42, 0, 1, -1]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.icmp "ugt" %arg0, %arg1 : vector<4xi32> + %2 = llvm.icmp "ule" %arg0, %arg1 : vector<4xi32> + %3 = llvm.icmp "ugt" %arg2, %0 : vector<4xi32> + %4 = llvm.or %1, %3 : vector<4xi1> + %5 = llvm.and %2, %4 : vector<4xi1> + llvm.return %5 : vector<4xi1> + } + llvm.func @andn_or_cmp_4(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "ne" %arg0, %arg1 : i32 + %3 = llvm.icmp "ugt" %arg2, %0 : i32 + %4 = llvm.or %1, %3 : i1 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @andn_or_cmp_4_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "eq" %arg0, %arg1 : i32 + %4 = llvm.icmp "ne" %arg0, %arg1 : i32 + %5 = llvm.icmp "ugt" %arg2, %0 : i32 + %6 = llvm.select %3, %1, %5 : i1, i1 + %7 = llvm.select %6, %4, %2 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @lowbitmask_casted_shift(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.sext %2 : i8 to i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @lowbitmask_casted_shift_wrong_mask1(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.sext %2 : i8 to i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @lowbitmask_casted_shift_wrong_mask2(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(536870911 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.sext %2 : i8 to i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @lowbitmask_casted_shift_use1(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(536870911 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sext %2 : i8 to i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @lowbitmask_casted_shift_use2(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(536870911 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.sext %2 : i8 to i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @lowbitmask_casted_shift_vec_splat(%arg0: vector<2xi47>) -> vector<2xi59> { + %0 = llvm.mlir.constant(5 : i47) : i47 + %1 = llvm.mlir.constant(dense<5> : vector<2xi47>) : vector<2xi47> + %2 = llvm.mlir.constant(18014398509481983 : i59) : i59 + %3 = llvm.mlir.constant(dense<18014398509481983> : vector<2xi59>) : vector<2xi59> + %4 = llvm.ashr %arg0, %1 : vector<2xi47> + %5 = llvm.sext %4 : vector<2xi47> to vector<2xi59> + %6 = llvm.and %5, %3 : vector<2xi59> + llvm.return %6 : vector<2xi59> + } + llvm.func @lowmask_sext_in_reg(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(20 : i32) : i32 + %1 = llvm.mlir.constant(4095 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.ashr %2, %0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @lowmask_not_sext_in_reg(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(19 : i32) : i32 + %1 = llvm.mlir.constant(20 : i32) : i32 + %2 = llvm.mlir.constant(4095 : i32) : i32 + %3 = llvm.shl %arg0, %0 : i32 + %4 = llvm.ashr %3, %1 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @not_lowmask_sext_in_reg(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(20 : i32) : i32 + %1 = llvm.mlir.constant(4096 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.ashr %2, %0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @not_lowmask_sext_in_reg2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(21 : i32) : i32 + %1 = llvm.mlir.constant(4095 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.ashr %2, %0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @lowmask_sext_in_reg_splat(%arg0: vector<2xi32>, %arg1: !llvm.ptr) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<20> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<4095> : vector<2xi32>) : vector<2xi32> + %2 = llvm.shl %arg0, %0 : vector<2xi32> + %3 = llvm.ashr %2, %0 : vector<2xi32> + llvm.store %3, %arg1 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + %4 = llvm.and %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @lowmask_add(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.mlir.constant(32 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @lowmask_add_2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.mlir.constant(63 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @lowmask_add_2_uses(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.mlir.constant(63 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @lowmask_add_2_splat(%arg0: vector<2xi8>, %arg1: !llvm.ptr) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-64> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<63> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 : vector<2xi8> + llvm.store %2, %arg1 {alignment = 2 : i64} : vector<2xi8>, !llvm.ptr + %3 = llvm.and %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @not_lowmask_add(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_lowmask_add2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-96 : i8) : i8 + %1 = llvm.mlir.constant(63 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @lowmask_add_splat(%arg0: vector<2xi8>, %arg1: !llvm.ptr) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-64> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<32> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 : vector<2xi8> + llvm.store %2, %arg1 {alignment = 2 : i64} : vector<2xi8>, !llvm.ptr + %3 = llvm.and %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @lowmask_add_splat_poison(%arg0: vector<2xi8>, %arg1: !llvm.ptr) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-64 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(32 : i8) : i8 + %8 = llvm.mlir.undef : vector<2xi8> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<2xi8> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %7, %10[%11 : i32] : vector<2xi8> + %13 = llvm.add %arg0, %6 : vector<2xi8> + llvm.store %13, %arg1 {alignment = 2 : i64} : vector<2xi8>, !llvm.ptr + %14 = llvm.and %13, %12 : vector<2xi8> + llvm.return %14 : vector<2xi8> + } + llvm.func @lowmask_add_vec(%arg0: vector<2xi8>, %arg1: !llvm.ptr) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[-96, -64]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[16, 32]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 : vector<2xi8> + llvm.store %2, %arg1 {alignment = 2 : i64} : vector<2xi8>, !llvm.ptr + %3 = llvm.and %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @flip_masked_bit(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.and %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @flip_masked_bit_uniform(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi8>) : vector<2xi8> + %1 = llvm.add %arg0, %0 : vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @flip_masked_bit_poison(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(16 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.add %arg0, %6 : vector<2xi8> + %8 = llvm.and %7, %6 : vector<2xi8> + llvm.return %8 : vector<2xi8> + } + llvm.func @flip_masked_bit_nonuniform(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[16, 4]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.add %arg0, %0 : vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @ashr_bitwidth_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.and %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @ashr_bitwidth_mask_vec_commute(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[42, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mul %arg1, %0 : vector<2xi8> + %3 = llvm.ashr %arg0, %1 : vector<2xi8> + %4 = llvm.and %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @ashr_bitwidth_mask_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.and %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @ashr_not_bitwidth_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.and %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @lshr_bitwidth_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.and %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @signbit_splat_mask(%arg0: i8, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.sext %1 : i8 to i16 + %3 = llvm.and %2, %arg1 : i16 + llvm.return %3 : i16 + } + llvm.func @signbit_splat_mask_commute(%arg0: vector<2xi5>, %arg1: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.poison : i5 + %1 = llvm.mlir.constant(4 : i5) : i5 + %2 = llvm.mlir.undef : vector<2xi5> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi5> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi5> + %7 = llvm.mul %arg1, %arg1 : vector<2xi16> + %8 = llvm.ashr %arg0, %6 : vector<2xi5> + %9 = llvm.sext %8 : vector<2xi5> to vector<2xi16> + %10 = llvm.and %7, %9 : vector<2xi16> + llvm.return %10 : vector<2xi16> + } + llvm.func @signbit_splat_mask_use1(%arg0: i8, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sext %1 : i8 to i16 + %3 = llvm.and %2, %arg1 : i16 + llvm.return %3 : i16 + } + llvm.func @signbit_splat_mask_use2(%arg0: i8, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.sext %1 : i8 to i16 + llvm.call @use16(%2) : (i16) -> () + %3 = llvm.and %2, %arg1 : i16 + llvm.return %3 : i16 + } + llvm.func @not_signbit_splat_mask1(%arg0: i8, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.zext %1 : i8 to i16 + %3 = llvm.and %2, %arg1 : i16 + llvm.return %3 : i16 + } + llvm.func @not_signbit_splat_mask2(%arg0: i8, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.sext %1 : i8 to i16 + %3 = llvm.and %2, %arg1 : i16 + llvm.return %3 : i16 + } + llvm.func @not_ashr_bitwidth_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.and %3, %arg1 : i8 + llvm.return %4 : i8 + } + llvm.func @not_ashr_bitwidth_mask_vec_commute(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[42, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mul %arg1, %0 : vector<2xi8> + %4 = llvm.ashr %arg0, %1 : vector<2xi8> + %5 = llvm.xor %4, %2 : vector<2xi8> + %6 = llvm.and %3, %5 : vector<2xi8> + llvm.return %6 : vector<2xi8> + } + llvm.func @not_ashr_bitwidth_mask_use1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.and %3, %arg1 : i8 + llvm.return %4 : i8 + } + llvm.func @not_ashr_bitwidth_mask_use2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.and %3, %arg1 : i8 + llvm.return %4 : i8 + } + llvm.func @not_ashr_not_bitwidth_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.and %3, %arg1 : i8 + llvm.return %4 : i8 + } + llvm.func @not_lshr_bitwidth_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.and %3, %arg1 : i8 + llvm.return %4 : i8 + } + llvm.func @invert_signbit_splat_mask(%arg0: i8, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.sext %3 : i8 to i16 + %5 = llvm.and %4, %arg1 : i16 + llvm.return %5 : i16 + } + llvm.func @invert_signbit_splat_mask_commute(%arg0: vector<2xi5>, %arg1: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.poison : i5 + %1 = llvm.mlir.constant(4 : i5) : i5 + %2 = llvm.mlir.undef : vector<2xi5> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi5> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi5> + %7 = llvm.mlir.constant(-1 : i5) : i5 + %8 = llvm.mlir.constant(dense<-1> : vector<2xi5>) : vector<2xi5> + %9 = llvm.mul %arg1, %arg1 : vector<2xi16> + %10 = llvm.ashr %arg0, %6 : vector<2xi5> + %11 = llvm.xor %10, %8 : vector<2xi5> + %12 = llvm.sext %11 : vector<2xi5> to vector<2xi16> + %13 = llvm.and %9, %12 : vector<2xi16> + llvm.return %13 : vector<2xi16> + } + llvm.func @invert_signbit_splat_mask_use1(%arg0: i8, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.sext %3 : i8 to i16 + %5 = llvm.and %4, %arg1 : i16 + llvm.return %5 : i16 + } + llvm.func @invert_signbit_splat_mask_use2(%arg0: i8, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.sext %3 : i8 to i16 + %5 = llvm.and %4, %arg1 : i16 + llvm.return %5 : i16 + } + llvm.func @invert_signbit_splat_mask_use3(%arg0: i8, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.sext %3 : i8 to i16 + llvm.call @use16(%4) : (i16) -> () + %5 = llvm.and %4, %arg1 : i16 + llvm.return %5 : i16 + } + llvm.func @not_invert_signbit_splat_mask1(%arg0: i8, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.zext %3 : i8 to i16 + %5 = llvm.and %4, %arg1 : i16 + llvm.return %5 : i16 + } + llvm.func @not_invert_signbit_splat_mask2(%arg0: i8, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.sext %3 : i8 to i16 + %5 = llvm.and %4, %arg1 : i16 + llvm.return %5 : i16 + } + llvm.func @shl_lshr_pow2_const_case1(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.mlir.constant(8 : i16) : i16 + %3 = llvm.shl %0, %arg0 : i16 + %4 = llvm.lshr %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @shl_ashr_pow2_const_case1(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.mlir.constant(8 : i16) : i16 + %3 = llvm.shl %0, %arg0 : i16 + %4 = llvm.ashr %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @shl_lshr_pow2_const_case1_uniform_vec(%arg0: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<4> : vector<3xi16>) : vector<3xi16> + %1 = llvm.mlir.constant(dense<6> : vector<3xi16>) : vector<3xi16> + %2 = llvm.mlir.constant(dense<8> : vector<3xi16>) : vector<3xi16> + %3 = llvm.shl %0, %arg0 : vector<3xi16> + %4 = llvm.lshr %3, %1 : vector<3xi16> + %5 = llvm.and %4, %2 : vector<3xi16> + llvm.return %5 : vector<3xi16> + } + llvm.func @shl_lshr_pow2_const_case1_non_uniform_vec(%arg0: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<[2, 8, 32]> : vector<3xi16>) : vector<3xi16> + %1 = llvm.mlir.constant(dense<[5, 6, 3]> : vector<3xi16>) : vector<3xi16> + %2 = llvm.mlir.constant(dense<[8, 4, 8]> : vector<3xi16>) : vector<3xi16> + %3 = llvm.shl %0, %arg0 : vector<3xi16> + %4 = llvm.lshr %3, %1 : vector<3xi16> + %5 = llvm.and %4, %2 : vector<3xi16> + llvm.return %5 : vector<3xi16> + } + llvm.func @shl_lshr_pow2_const_case1_non_uniform_vec_negative(%arg0: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<[2, 8, 32]> : vector<3xi16>) : vector<3xi16> + %1 = llvm.mlir.constant(dense<[5, 6, 3]> : vector<3xi16>) : vector<3xi16> + %2 = llvm.mlir.constant(dense<[8, 4, 16384]> : vector<3xi16>) : vector<3xi16> + %3 = llvm.shl %0, %arg0 : vector<3xi16> + %4 = llvm.lshr %3, %1 : vector<3xi16> + %5 = llvm.and %4, %2 : vector<3xi16> + llvm.return %5 : vector<3xi16> + } + llvm.func @shl_lshr_pow2_const_case1_poison1_vec(%arg0: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(16 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<3xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<3xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<3xi16> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi16> + %9 = llvm.mlir.constant(dense<5> : vector<3xi16>) : vector<3xi16> + %10 = llvm.mlir.constant(dense<8> : vector<3xi16>) : vector<3xi16> + %11 = llvm.shl %8, %arg0 : vector<3xi16> + %12 = llvm.lshr %11, %9 : vector<3xi16> + %13 = llvm.and %12, %10 : vector<3xi16> + llvm.return %13 : vector<3xi16> + } + llvm.func @shl_lshr_pow2_const_case1_poison2_vec(%arg0: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<16> : vector<3xi16>) : vector<3xi16> + %1 = llvm.mlir.constant(5 : i16) : i16 + %2 = llvm.mlir.poison : i16 + %3 = llvm.mlir.undef : vector<3xi16> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi16> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi16> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi16> + %10 = llvm.mlir.constant(dense<8> : vector<3xi16>) : vector<3xi16> + %11 = llvm.shl %0, %arg0 : vector<3xi16> + %12 = llvm.lshr %11, %9 : vector<3xi16> + %13 = llvm.and %12, %10 : vector<3xi16> + llvm.return %13 : vector<3xi16> + } + llvm.func @shl_lshr_pow2_const_case1_poison3_vec(%arg0: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<16> : vector<3xi16>) : vector<3xi16> + %1 = llvm.mlir.constant(dense<5> : vector<3xi16>) : vector<3xi16> + %2 = llvm.mlir.constant(8 : i16) : i16 + %3 = llvm.mlir.poison : i16 + %4 = llvm.mlir.undef : vector<3xi16> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<3xi16> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<3xi16> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %2, %8[%9 : i32] : vector<3xi16> + %11 = llvm.shl %0, %arg0 : vector<3xi16> + %12 = llvm.lshr %11, %1 : vector<3xi16> + %13 = llvm.and %12, %10 : vector<3xi16> + llvm.return %13 : vector<3xi16> + } + llvm.func @shl_lshr_pow2_const_case2(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(16 : i16) : i16 + %1 = llvm.mlir.constant(3 : i16) : i16 + %2 = llvm.mlir.constant(8 : i16) : i16 + %3 = llvm.shl %0, %arg0 : i16 + %4 = llvm.lshr %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @shl_lshr_pow2_not_const_case2(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(16 : i16) : i16 + %1 = llvm.mlir.constant(3 : i16) : i16 + %2 = llvm.mlir.constant(8 : i16) : i16 + %3 = llvm.shl %0, %arg0 : i16 + %4 = llvm.lshr %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + %6 = llvm.xor %5, %2 : i16 + llvm.return %6 : i16 + } + llvm.func @shl_lshr_pow2_const_negative_overflow1(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(4096 : i16) : i16 + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.mlir.constant(8 : i16) : i16 + %3 = llvm.shl %0, %arg0 : i16 + %4 = llvm.lshr %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @shl_lshr_pow2_const_negative_overflow2(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.mlir.constant(-32768 : i16) : i16 + %3 = llvm.shl %0, %arg0 : i16 + %4 = llvm.lshr %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @shl_lshr_pow2_const_negative_oneuse(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.mlir.constant(8 : i16) : i16 + %3 = llvm.shl %0, %arg0 : i16 + %4 = llvm.lshr %3, %1 : i16 + llvm.call @use16(%4) : (i16) -> () + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @shl_lshr_pow2_const_negative_nopow2_1(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(3 : i16) : i16 + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.mlir.constant(8 : i16) : i16 + %3 = llvm.shl %0, %arg0 : i16 + %4 = llvm.lshr %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @shl_lshr_pow2_const_negative_nopow2_2(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(3 : i16) : i16 + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.mlir.constant(7 : i16) : i16 + %3 = llvm.shl %0, %arg0 : i16 + %4 = llvm.lshr %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @lshr_lshr_pow2_const(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(2048 : i16) : i16 + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.mlir.constant(4 : i16) : i16 + %3 = llvm.lshr %0, %arg0 : i16 + %4 = llvm.lshr %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @lshr_lshr_pow2_const_negative_oneuse(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(2048 : i16) : i16 + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.mlir.constant(4 : i16) : i16 + %3 = llvm.lshr %0, %arg0 : i16 + %4 = llvm.lshr %3, %1 : i16 + llvm.call @use16(%4) : (i16) -> () + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @lshr_lshr_pow2_const_negative_nopow2_1(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(2047 : i16) : i16 + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.mlir.constant(4 : i16) : i16 + %3 = llvm.lshr %0, %arg0 : i16 + %4 = llvm.lshr %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @lshr_lshr_pow2_const_negative_nopow2_2(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8192 : i16) : i16 + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.mlir.constant(3 : i16) : i16 + %3 = llvm.lshr %0, %arg0 : i16 + %4 = llvm.lshr %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @lshr_lshr_pow2_const_negative_overflow(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(-32768 : i16) : i16 + %1 = llvm.mlir.constant(15 : i16) : i16 + %2 = llvm.mlir.constant(4 : i16) : i16 + %3 = llvm.lshr %0, %arg0 : i16 + %4 = llvm.lshr %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @lshr_shl_pow2_const_case1(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(256 : i16) : i16 + %1 = llvm.mlir.constant(2 : i16) : i16 + %2 = llvm.mlir.constant(8 : i16) : i16 + %3 = llvm.lshr %0, %arg0 : i16 + %4 = llvm.shl %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @lshr_shl_pow2_const_xor(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(256 : i16) : i16 + %1 = llvm.mlir.constant(2 : i16) : i16 + %2 = llvm.mlir.constant(8 : i16) : i16 + %3 = llvm.lshr %0, %arg0 : i16 + %4 = llvm.shl %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + %6 = llvm.xor %5, %2 : i16 + llvm.return %6 : i16 + } + llvm.func @lshr_shl_pow2_const_case2(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8192 : i16) : i16 + %1 = llvm.mlir.constant(4 : i16) : i16 + %2 = llvm.mlir.constant(32 : i16) : i16 + %3 = llvm.lshr %0, %arg0 : i16 + %4 = llvm.shl %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @lshr_shl_pow2_const_overflow(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8192 : i16) : i16 + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.mlir.constant(32 : i16) : i16 + %3 = llvm.lshr %0, %arg0 : i16 + %4 = llvm.shl %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @lshr_shl_pow2_const_negative_oneuse(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8192 : i16) : i16 + %1 = llvm.mlir.constant(4 : i16) : i16 + %2 = llvm.mlir.constant(32 : i16) : i16 + %3 = llvm.lshr %0, %arg0 : i16 + %4 = llvm.shl %3, %1 : i16 + llvm.call @use16(%4) : (i16) -> () + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @lshr_shl_pow2_const_case1_uniform_vec(%arg0: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<8192> : vector<3xi16>) : vector<3xi16> + %1 = llvm.mlir.constant(dense<6> : vector<3xi16>) : vector<3xi16> + %2 = llvm.mlir.constant(dense<128> : vector<3xi16>) : vector<3xi16> + %3 = llvm.lshr %0, %arg0 : vector<3xi16> + %4 = llvm.shl %3, %1 : vector<3xi16> + %5 = llvm.and %4, %2 : vector<3xi16> + llvm.return %5 : vector<3xi16> + } + llvm.func @lshr_shl_pow2_const_case1_non_uniform_vec(%arg0: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<[8192, 16384, -32768]> : vector<3xi16>) : vector<3xi16> + %1 = llvm.mlir.constant(dense<[7, 5, 3]> : vector<3xi16>) : vector<3xi16> + %2 = llvm.mlir.constant(dense<[128, 256, 512]> : vector<3xi16>) : vector<3xi16> + %3 = llvm.lshr %0, %arg0 : vector<3xi16> + %4 = llvm.shl %3, %1 : vector<3xi16> + %5 = llvm.and %4, %2 : vector<3xi16> + llvm.return %5 : vector<3xi16> + } + llvm.func @lshr_shl_pow2_const_case1_non_uniform_vec_negative(%arg0: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<[8192, 16384, -32768]> : vector<3xi16>) : vector<3xi16> + %1 = llvm.mlir.constant(dense<[8, 5, 3]> : vector<3xi16>) : vector<3xi16> + %2 = llvm.mlir.constant(dense<[128, 256, 512]> : vector<3xi16>) : vector<3xi16> + %3 = llvm.lshr %0, %arg0 : vector<3xi16> + %4 = llvm.shl %3, %1 : vector<3xi16> + %5 = llvm.and %4, %2 : vector<3xi16> + llvm.return %5 : vector<3xi16> + } + llvm.func @lshr_shl_pow2_const_case1_poison1_vec(%arg0: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(8192 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<3xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<3xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<3xi16> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi16> + %9 = llvm.mlir.constant(dense<6> : vector<3xi16>) : vector<3xi16> + %10 = llvm.mlir.constant(dense<128> : vector<3xi16>) : vector<3xi16> + %11 = llvm.lshr %8, %arg0 : vector<3xi16> + %12 = llvm.shl %11, %9 : vector<3xi16> + %13 = llvm.and %12, %10 : vector<3xi16> + llvm.return %13 : vector<3xi16> + } + llvm.func @lshr_shl_pow2_const_case1_poison2_vec(%arg0: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<8192> : vector<3xi16>) : vector<3xi16> + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.mlir.poison : i16 + %3 = llvm.mlir.undef : vector<3xi16> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi16> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi16> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi16> + %10 = llvm.mlir.constant(dense<128> : vector<3xi16>) : vector<3xi16> + %11 = llvm.lshr %0, %arg0 : vector<3xi16> + %12 = llvm.shl %11, %9 : vector<3xi16> + %13 = llvm.and %12, %10 : vector<3xi16> + llvm.return %13 : vector<3xi16> + } + llvm.func @lshr_shl_pow2_const_case1_poison3_vec(%arg0: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<8192> : vector<3xi16>) : vector<3xi16> + %1 = llvm.mlir.constant(dense<6> : vector<3xi16>) : vector<3xi16> + %2 = llvm.mlir.constant(128 : i16) : i16 + %3 = llvm.mlir.poison : i16 + %4 = llvm.mlir.undef : vector<3xi16> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<3xi16> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<3xi16> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %2, %8[%9 : i32] : vector<3xi16> + %11 = llvm.lshr %0, %arg0 : vector<3xi16> + %12 = llvm.shl %11, %1 : vector<3xi16> + %13 = llvm.and %12, %10 : vector<3xi16> + llvm.return %13 : vector<3xi16> + } + llvm.func @negate_lowbitmask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.sub %1, %2 : i8 + %4 = llvm.and %3, %arg1 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_lowbitmask_commute(%arg0: vector<2xi5>, %arg1: vector<2xi5>) -> vector<2xi5> { + %0 = llvm.mlir.poison : i5 + %1 = llvm.mlir.constant(1 : i5) : i5 + %2 = llvm.mlir.undef : vector<2xi5> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi5> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi5> + %7 = llvm.mlir.constant(0 : i5) : i5 + %8 = llvm.mlir.undef : vector<2xi5> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<2xi5> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %7, %10[%11 : i32] : vector<2xi5> + %13 = llvm.mul %arg1, %arg1 : vector<2xi5> + %14 = llvm.and %arg0, %6 : vector<2xi5> + %15 = llvm.sub %12, %14 : vector<2xi5> + %16 = llvm.and %13, %15 : vector<2xi5> + llvm.return %16 : vector<2xi5> + } + llvm.func @negate_lowbitmask_use1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + %4 = llvm.and %3, %arg1 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_lowbitmask_use2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.and %3, %arg1 : i8 + llvm.return %4 : i8 + } + llvm.func @test_and_or_constexpr_infloop() -> i64 { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %2 = llvm.mlir.constant(-8 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.and %1, %2 : i64 + %5 = llvm.or %4, %3 : i64 + llvm.return %5 : i64 + } + llvm.func @and_zext(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.zext %arg1 : i1 to i32 + %1 = llvm.and %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @and_zext_commuted(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.zext %arg1 : i1 to i32 + %1 = llvm.and %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @and_zext_multiuse(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.zext %arg1 : i1 to i32 + llvm.call @use32(%0) : (i32) -> () + %1 = llvm.and %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @and_zext_vec(%arg0: vector<2xi32>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.zext %arg1 : vector<2xi1> to vector<2xi32> + %1 = llvm.and %arg0, %0 : vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @and_zext_eq_even(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.zext %1 : i1 to i32 + %3 = llvm.and %arg0, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @and_zext_eq_even_commuted(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.zext %1 : i1 to i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @and_zext_eq_odd(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.zext %1 : i1 to i32 + %3 = llvm.and %arg0, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @and_zext_eq_odd_commuted(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.zext %1 : i1 to i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @and_zext_eq_zero(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %arg1 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.and %3, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @canonicalize_and_add_power2_or_zero(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.and %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.mul %arg0, %arg0 : i32 + %4 = llvm.add %3, %2 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @canonicalize_and_sub_power2_or_zero(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.and %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.sub %arg0, %2 : i32 + %4 = llvm.and %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @canonicalize_and_add_power2_or_zero_commuted1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.and %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.add %2, %arg0 : i32 + %4 = llvm.and %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @canonicalize_and_add_power2_or_zero_commuted2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.and %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.mul %arg0, %arg0 : i32 + %4 = llvm.add %3, %2 : i32 + %5 = llvm.and %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @canonicalize_and_add_power2_or_zero_commuted3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.and %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.add %2, %arg0 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @canonicalize_and_sub_power2_or_zero_commuted_nofold(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.and %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.sub %2, %arg0 : i32 + %4 = llvm.and %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @canonicalize_and_add_non_power2_or_zero_nofold(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.add %arg0, %arg1 : i32 + %1 = llvm.and %0, %arg1 : i32 + llvm.return %1 : i32 + } + llvm.func @canonicalize_and_add_power2_or_zero_multiuse_nofold(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.and %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.mul %arg0, %arg0 : i32 + %4 = llvm.add %3, %2 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @canonicalize_and_sub_power2_or_zero_multiuse_nofold(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.and %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.sub %arg0, %2 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.and %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @add_constant_equal_with_the_top_bit_of_demandedbits_pass(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @add_constant_equal_with_the_top_bit_of_demandedbits_pass_vector(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<24> : vector<2xi16>) : vector<2xi16> + %2 = llvm.add %arg0, %0 : vector<2xi16> + %3 = llvm.and %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @add_constant_equal_with_the_top_bit_of_demandedbits_fail1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @add_constant_equal_with_the_top_bit_of_demandedbits_fail2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.and %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @add_constant_equal_with_the_top_bit_of_demandedbits_insertpt(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.or %2, %arg1 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @and_sext_multiuse(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %1 = llvm.sext %0 : i1 to i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.and %1, %arg3 : i32 + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/and2.ll.mlir b/test/LLVMDialect/InstCombine/and2.ll.mlir new file mode 100644 index 000000000..829110e10 --- /dev/null +++ b/test/LLVMDialect/InstCombine/and2.ll.mlir @@ -0,0 +1,184 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.and %arg0, %arg1 : i1 + %1 = llvm.and %0, %arg0 : i1 + llvm.return %1 : i1 + } + llvm.func @test2_logical(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + %2 = llvm.select %1, %arg0, %0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @test3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.and %arg0, %arg1 : i32 + %1 = llvm.and %arg1, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @test7(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.and %2, %arg1 : i1 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @test7_logical(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.icmp "sgt" %arg0, %1 : i32 + %5 = llvm.select %3, %arg1, %2 : i1, i1 + %6 = llvm.select %5, %4, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @test8(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(14 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + %3 = llvm.icmp "ult" %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test8_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(14 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "ne" %arg0, %0 : i32 + %4 = llvm.icmp "ult" %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @test8vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<14> : vector<2xi32>) : vector<2xi32> + %3 = llvm.icmp "ne" %arg0, %1 : vector<2xi32> + %4 = llvm.icmp "ult" %arg0, %2 : vector<2xi32> + %5 = llvm.and %3, %4 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @test9(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.sub %0, %arg0 overflow : i64 + %3 = llvm.and %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @test9vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.constant(dense<1> : vector<2xi64>) : vector<2xi64> + %3 = llvm.sub %1, %arg0 overflow : vector<2xi64> + %4 = llvm.and %3, %2 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test10(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.sub %0, %arg0 overflow : i64 + %3 = llvm.and %2, %1 : i64 + %4 = llvm.add %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @and1_shl1_is_cmp_eq_0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.and %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @and1_shl1_is_cmp_eq_0_multiuse(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.add %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @and1_shl1_is_cmp_eq_0_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %0, %arg0 : vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @and1_shl1_is_cmp_eq_0_vec_poison(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.shl %6, %arg0 : vector<2xi8> + %8 = llvm.and %7, %6 : vector<2xi8> + llvm.return %8 : vector<2xi8> + } + llvm.func @and1_lshr1_is_cmp_eq_0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.lshr %0, %arg0 : i8 + %2 = llvm.and %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @and1_lshr1_is_cmp_eq_0_multiuse(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.lshr %0, %arg0 : i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.add %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @and1_lshr1_is_cmp_eq_0_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.lshr %0, %arg0 : vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @and1_lshr1_is_cmp_eq_0_vec_poison(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.lshr %6, %arg0 : vector<2xi8> + %8 = llvm.and %7, %6 : vector<2xi8> + llvm.return %8 : vector<2xi8> + } + llvm.func @test11(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.add %2, %arg1 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.mul %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test12(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.add %arg1, %2 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.mul %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test13(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.sub %arg1, %2 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.mul %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test14(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.sub %2, %arg1 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.mul %4, %2 : i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/annotation-intrinsic.ll.mlir b/test/LLVMDialect/InstCombine/annotation-intrinsic.ll.mlir index 904fed400..ee25e16dc 100644 --- a/test/LLVMDialect/InstCombine/annotation-intrinsic.ll.mlir +++ b/test/LLVMDialect/InstCombine/annotation-intrinsic.ll.mlir @@ -1,15 +1,11 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.annotation.i32", type = !llvm.func, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.undef"() : () -> i32 - %1 = "llvm.mlir.undef"() : () -> !llvm.ptr - %2 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %3 = "llvm.call"(%2, %1, %1, %0) {callee = @llvm.annotation.i32, fastmathFlags = #llvm.fastmath<>} : (i32, !llvm.ptr, !llvm.ptr, i32) -> i32 - %4 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %5 = "llvm.add"(%3, %4) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "annotated", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<64> : vector<4xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func local_unnamed_addr @annotated(%arg0: !llvm.ptr) -> i32 attributes {passthrough = ["mustprogress", "nofree", "nounwind", "willreturn", ["uwtable", "2"]]} { + %0 = llvm.mlir.undef : !llvm.ptr + %1 = llvm.mlir.undef : i32 + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %3 = "llvm.intr.annotation"(%2, %0, %0, %1) : (i32, !llvm.ptr, !llvm.ptr, i32) -> i32 + %4 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %5 = llvm.add %3, %4 overflow : i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/annotations.ll.mlir b/test/LLVMDialect/InstCombine/annotations.ll.mlir new file mode 100644 index 000000000..ac6b2bcbc --- /dev/null +++ b/test/LLVMDialect/InstCombine/annotations.ll.mlir @@ -0,0 +1,70 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fold_to_new_instruction(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.icmp "uge" %arg0, %arg1 : !llvm.ptr + llvm.return %0 : i1 + } + llvm.func @fold_to_new_instruction2(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.icmp "uge" %arg0, %arg1 : !llvm.ptr + llvm.return %0 : i1 + } + llvm.func @do_not_add_annotation_to_existing_instr(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.add %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @copy_1_byte(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @memcpy(!llvm.ptr {llvm.noalias, llvm.returned}, !llvm.ptr {llvm.noalias, llvm.nocapture, llvm.readonly}, i64) -> !llvm.ptr attributes {passthrough = ["nofree", "nounwind"]} + llvm.func @libcallcopy_1_byte(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.call @memcpy(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return + } + llvm.func @__memcpy_chk(!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr attributes {passthrough = ["nofree", "nounwind"]} + llvm.func @libcallcopy_1_byte_chk(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.call @__memcpy_chk(%arg0, %arg1, %0, %0) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return + } + llvm.func @move_1_byte(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + "llvm.intr.memmove"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @memmove(!llvm.ptr {llvm.returned}, !llvm.ptr {llvm.nocapture, llvm.readonly}, i64) -> !llvm.ptr attributes {passthrough = ["nofree", "nounwind"]} + llvm.func @libcallmove_1_byte(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.call @memmove(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return + } + llvm.func @__memmove_chk(!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr attributes {passthrough = ["nofree", "nounwind"]} + llvm.func @libcallmove_1_byte_chk(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.call @__memmove_chk(%arg0, %arg1, %0, %0) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return + } + llvm.func @set_1_byte(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(1 : i32) : i32 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i32) -> () + llvm.return + } + llvm.func @memset(!llvm.ptr, i32, i64) -> !llvm.ptr attributes {passthrough = ["nofree"]} + llvm.func @libcall_set_1_byte(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.call @memset(%arg0, %0, %1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return + } + llvm.func @__memset_chk(!llvm.ptr, i32, i64, i64) -> !llvm.ptr attributes {passthrough = ["nofree"]} + llvm.func @libcall_set_1_byte_chk(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.call @__memset_chk(%arg0, %0, %1, %1) : (!llvm.ptr, i32, i64, i64) -> !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/apint-add.ll.mlir b/test/LLVMDialect/InstCombine/apint-add.ll.mlir new file mode 100644 index 000000000..2312e4dac --- /dev/null +++ b/test/LLVMDialect/InstCombine/apint-add.ll.mlir @@ -0,0 +1,103 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.add %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @test2(%arg0: i47) -> i47 { + %0 = llvm.mlir.constant(-70368744177664 : i47) : i47 + %1 = llvm.xor %arg0, %0 : i47 + %2 = llvm.add %1, %0 : i47 + llvm.return %2 : i47 + } + llvm.func @test3(%arg0: i15) -> i15 { + %0 = llvm.mlir.constant(-16384 : i15) : i15 + %1 = llvm.xor %arg0, %0 : i15 + %2 = llvm.add %1, %0 : i15 + llvm.return %2 : i15 + } + llvm.func @test3vec(%arg0: vector<2xi5>) -> vector<2xi5> { + %0 = llvm.mlir.constant(-16 : i5) : i5 + %1 = llvm.mlir.constant(dense<-16> : vector<2xi5>) : vector<2xi5> + %2 = llvm.add %arg0, %1 : vector<2xi5> + llvm.return %2 : vector<2xi5> + } + llvm.func @test4(%arg0: i49) -> i49 { + %0 = llvm.mlir.constant(-2 : i49) : i49 + %1 = llvm.mlir.constant(1 : i49) : i49 + %2 = llvm.and %arg0, %0 : i49 + %3 = llvm.add %2, %1 : i49 + llvm.return %3 : i49 + } + llvm.func @sext(%arg0: i4) -> i7 { + %0 = llvm.mlir.constant(-8 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i7) : i7 + %2 = llvm.xor %arg0, %0 : i4 + %3 = llvm.zext %2 : i4 to i7 + %4 = llvm.add %3, %1 overflow : i7 + llvm.return %4 : i7 + } + llvm.func @sext_vec(%arg0: vector<2xi3>) -> vector<2xi10> { + %0 = llvm.mlir.constant(-4 : i3) : i3 + %1 = llvm.mlir.constant(dense<-4> : vector<2xi3>) : vector<2xi3> + %2 = llvm.mlir.constant(-4 : i10) : i10 + %3 = llvm.mlir.constant(dense<-4> : vector<2xi10>) : vector<2xi10> + %4 = llvm.xor %arg0, %1 : vector<2xi3> + %5 = llvm.zext %4 : vector<2xi3> to vector<2xi10> + %6 = llvm.add %5, %3 overflow : vector<2xi10> + llvm.return %6 : vector<2xi10> + } + llvm.func @sext_multiuse(%arg0: i4) -> i4 { + %0 = llvm.mlir.constant(-8 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i7) : i7 + %2 = llvm.xor %arg0, %0 : i4 + %3 = llvm.zext %2 : i4 to i7 + %4 = llvm.add %3, %1 overflow : i7 + %5 = llvm.sdiv %3, %4 : i7 + %6 = llvm.trunc %5 : i7 to i4 + %7 = llvm.sdiv %6, %2 : i4 + llvm.return %7 : i4 + } + llvm.func @test5(%arg0: i111) -> i111 { + %0 = llvm.mlir.constant(1 : i111) : i111 + %1 = llvm.mlir.constant(110 : i111) : i111 + %2 = llvm.shl %0, %1 : i111 + %3 = llvm.xor %arg0, %2 : i111 + %4 = llvm.add %3, %2 : i111 + llvm.return %4 : i111 + } + llvm.func @test6(%arg0: i65) -> i65 { + %0 = llvm.mlir.constant(1 : i65) : i65 + %1 = llvm.mlir.constant(64 : i65) : i65 + %2 = llvm.shl %0, %1 : i65 + %3 = llvm.xor %arg0, %2 : i65 + %4 = llvm.add %3, %2 : i65 + llvm.return %4 : i65 + } + llvm.func @test7(%arg0: i1024) -> i1024 { + %0 = llvm.mlir.constant(1 : i1024) : i1024 + %1 = llvm.mlir.constant(1023 : i1024) : i1024 + %2 = llvm.shl %0, %1 : i1024 + %3 = llvm.xor %arg0, %2 : i1024 + %4 = llvm.add %3, %2 : i1024 + llvm.return %4 : i1024 + } + llvm.func @test8(%arg0: i128) -> i128 { + %0 = llvm.mlir.constant(1 : i128) : i128 + %1 = llvm.mlir.constant(127 : i128) : i128 + %2 = llvm.mlir.constant(120 : i128) : i128 + %3 = llvm.shl %0, %1 : i128 + %4 = llvm.ashr %3, %2 : i128 + %5 = llvm.xor %arg0, %4 : i128 + %6 = llvm.add %5, %3 : i128 + llvm.return %6 : i128 + } + llvm.func @test9(%arg0: i77) -> i77 { + %0 = llvm.mlir.constant(562949953421310 : i77) : i77 + %1 = llvm.mlir.constant(1 : i77) : i77 + %2 = llvm.and %arg0, %0 : i77 + %3 = llvm.add %2, %1 : i77 + llvm.return %3 : i77 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-and-compare.ll.mlir b/test/LLVMDialect/InstCombine/apint-and-compare.ll.mlir index 09be5aac6..4f5ba7b9b 100644 --- a/test/LLVMDialect/InstCombine/apint-and-compare.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-and-compare.ll.mlir @@ -1,19 +1,16 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i33, %arg1: i33): // no predecessors - %0 = "llvm.mlir.constant"() {value = 65280 : i33} : () -> i33 - %1 = "llvm.and"(%arg0, %0) : (i33, i33) -> i33 - %2 = "llvm.and"(%arg1, %0) : (i33, i33) -> i33 - %3 = "llvm.icmp"(%1, %2) {predicate = 1 : i64} : (i33, i33) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i999, %arg1: i999): // no predecessors - %0 = "llvm.mlir.constant"() {value = 65280 : i999} : () -> i999 - %1 = "llvm.and"(%arg0, %0) : (i999, i999) -> i999 - %2 = "llvm.and"(%arg1, %0) : (i999, i999) -> i999 - %3 = "llvm.icmp"(%1, %2) {predicate = 1 : i64} : (i999, i999) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i33, %arg1: i33) -> i1 { + %0 = llvm.mlir.constant(65280 : i33) : i33 + %1 = llvm.and %arg0, %0 : i33 + %2 = llvm.and %arg1, %0 : i33 + %3 = llvm.icmp "ne" %1, %2 : i33 + llvm.return %3 : i1 + } + llvm.func @test2(%arg0: i999, %arg1: i999) -> i1 { + %0 = llvm.mlir.constant(65280 : i999) : i999 + %1 = llvm.and %arg0, %0 : i999 + %2 = llvm.and %arg1, %0 : i999 + %3 = llvm.icmp "ne" %1, %2 : i999 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-and-or-and.ll.mlir b/test/LLVMDialect/InstCombine/apint-and-or-and.ll.mlir index 12f22deea..26b960d7a 100644 --- a/test/LLVMDialect/InstCombine/apint-and-or-and.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-and-or-and.ll.mlir @@ -1,45 +1,39 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i17, %arg1: i17): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i17} : () -> i17 - %1 = "llvm.mlir.constant"() {value = 7 : i17} : () -> i17 - %2 = "llvm.and"(%arg0, %1) : (i17, i17) -> i17 - %3 = "llvm.and"(%arg1, %0) : (i17, i17) -> i17 - %4 = "llvm.or"(%2, %3) : (i17, i17) -> i17 - %5 = "llvm.and"(%4, %1) : (i17, i17) -> i17 - "llvm.return"(%5) : (i17) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i49, %arg1: i49): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i49} : () -> i49 - %1 = "llvm.shl"(%arg1, %0) : (i49, i49) -> i49 - %2 = "llvm.or"(%arg0, %1) : (i49, i49) -> i49 - %3 = "llvm.and"(%2, %0) : (i49, i49) -> i49 - "llvm.return"(%3) : (i49) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i67, %arg1: i67): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i67} : () -> i67 - %1 = "llvm.mlir.constant"() {value = 66 : i67} : () -> i67 - %2 = "llvm.lshr"(%arg1, %1) : (i67, i67) -> i67 - %3 = "llvm.or"(%arg0, %2) : (i67, i67) -> i67 - %4 = "llvm.and"(%3, %0) : (i67, i67) -> i67 - "llvm.return"(%4) : (i67) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i231, %arg1: i231): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i231} : () -> i231 - %1 = "llvm.and"(%arg0, %0) : (i231, i231) -> i231 - %2 = "llvm.or"(%1, %0) : (i231, i231) -> i231 - "llvm.return"(%2) : (i231) -> () - }) {linkage = 10 : i64, sym_name = "or_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i7, %arg1: i7): // no predecessors - %0 = "llvm.mlir.constant"() {value = -64 : i7} : () -> i7 - %1 = "llvm.mlir.constant"() {value = 6 : i7} : () -> i7 - %2 = "llvm.shl"(%arg0, %1) : (i7, i7) -> i7 - %3 = "llvm.or"(%2, %0) : (i7, i7) -> i7 - "llvm.return"(%3) : (i7) -> () - }) {linkage = 10 : i64, sym_name = "or_test2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i17, %arg1: i17) -> i17 { + %0 = llvm.mlir.constant(7 : i17) : i17 + %1 = llvm.mlir.constant(8 : i17) : i17 + %2 = llvm.and %arg0, %0 : i17 + %3 = llvm.and %arg1, %1 : i17 + %4 = llvm.or %2, %3 : i17 + %5 = llvm.and %4, %0 : i17 + llvm.return %5 : i17 + } + llvm.func @test3(%arg0: i49, %arg1: i49) -> i49 { + %0 = llvm.mlir.constant(1 : i49) : i49 + %1 = llvm.shl %arg1, %0 : i49 + %2 = llvm.or %arg0, %1 : i49 + %3 = llvm.and %2, %0 : i49 + llvm.return %3 : i49 + } + llvm.func @test4(%arg0: i67, %arg1: i67) -> i67 { + %0 = llvm.mlir.constant(66 : i67) : i67 + %1 = llvm.mlir.constant(2 : i67) : i67 + %2 = llvm.lshr %arg1, %0 : i67 + %3 = llvm.or %arg0, %2 : i67 + %4 = llvm.and %3, %1 : i67 + llvm.return %4 : i67 + } + llvm.func @or_test1(%arg0: i231, %arg1: i231) -> i231 { + %0 = llvm.mlir.constant(1 : i231) : i231 + %1 = llvm.and %arg0, %0 : i231 + %2 = llvm.or %1, %0 : i231 + llvm.return %2 : i231 + } + llvm.func @or_test2(%arg0: i7, %arg1: i7) -> i7 { + %0 = llvm.mlir.constant(6 : i7) : i7 + %1 = llvm.mlir.constant(-64 : i7) : i7 + %2 = llvm.shl %arg0, %0 : i7 + %3 = llvm.or %2, %1 : i7 + llvm.return %3 : i7 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-and-xor-merge.ll.mlir b/test/LLVMDialect/InstCombine/apint-and-xor-merge.ll.mlir index c7a0d0486..8b1e9b089 100644 --- a/test/LLVMDialect/InstCombine/apint-and-xor-merge.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-and-xor-merge.ll.mlir @@ -1,17 +1,14 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i57, %arg1: i57, %arg2: i57): // no predecessors - %0 = "llvm.and"(%arg2, %arg0) : (i57, i57) -> i57 - %1 = "llvm.and"(%arg2, %arg1) : (i57, i57) -> i57 - %2 = "llvm.xor"(%0, %1) : (i57, i57) -> i57 - "llvm.return"(%2) : (i57) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i23, %arg1: i23, %arg2: i23): // no predecessors - %0 = "llvm.and"(%arg1, %arg0) : (i23, i23) -> i23 - %1 = "llvm.or"(%arg1, %arg0) : (i23, i23) -> i23 - %2 = "llvm.xor"(%0, %1) : (i23, i23) -> i23 - "llvm.return"(%2) : (i23) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i57, %arg1: i57, %arg2: i57) -> i57 { + %0 = llvm.and %arg2, %arg0 : i57 + %1 = llvm.and %arg2, %arg1 : i57 + %2 = llvm.xor %0, %1 : i57 + llvm.return %2 : i57 + } + llvm.func @test2(%arg0: i23, %arg1: i23, %arg2: i23) -> i23 { + %0 = llvm.and %arg1, %arg0 : i23 + %1 = llvm.or %arg1, %arg0 : i23 + %2 = llvm.xor %0, %1 : i23 + llvm.return %2 : i23 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-and.ll.mlir b/test/LLVMDialect/InstCombine/apint-and.ll.mlir index 23029024f..96cb6fd3f 100644 --- a/test/LLVMDialect/InstCombine/apint-and.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-and.ll.mlir @@ -1,95 +1,82 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i39): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i39} : () -> i39 - %1 = "llvm.and"(%arg0, %0) : (i39, i39) -> i39 - "llvm.return"(%1) : (i39) -> () - }) {linkage = 10 : i64, sym_name = "test0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i15): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i15} : () -> i15 - %1 = "llvm.and"(%arg0, %0) : (i15, i15) -> i15 - "llvm.return"(%1) : (i15) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i23): // no predecessors - %0 = "llvm.mlir.constant"() {value = 128 : i23} : () -> i23 - %1 = "llvm.mlir.constant"() {value = 127 : i23} : () -> i23 - %2 = "llvm.and"(%arg0, %1) : (i23, i23) -> i23 - %3 = "llvm.and"(%2, %0) : (i23, i23) -> i23 - "llvm.return"(%3) : (i23) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i37): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i37} : () -> i37 - %1 = "llvm.mlir.constant"() {value = -2147483648 : i37} : () -> i37 - %2 = "llvm.and"(%arg0, %1) : (i37, i37) -> i37 - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (i37, i37) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i7, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 12 : i7} : () -> i7 - %1 = "llvm.mlir.constant"() {value = 3 : i7} : () -> i7 - %2 = "llvm.or"(%arg0, %1) : (i7, i7) -> i7 - %3 = "llvm.xor"(%2, %0) : (i7, i7) -> i7 - "llvm.store"(%3, %arg1) : (i7, !llvm.ptr) -> () - %4 = "llvm.and"(%3, %1) : (i7, i7) -> i7 - "llvm.return"(%4) : (i7) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i47): // no predecessors - %0 = "llvm.mlir.constant"() {value = 255 : i47} : () -> i47 - %1 = "llvm.mlir.constant"() {value = 39 : i47} : () -> i47 - %2 = "llvm.ashr"(%arg0, %1) : (i47, i47) -> i47 - %3 = "llvm.and"(%2, %0) : (i47, i47) -> i47 - "llvm.return"(%3) : (i47) -> () - }) {linkage = 10 : i64, sym_name = "test7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i999): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i999} : () -> i999 - %1 = "llvm.and"(%arg0, %0) : (i999, i999) -> i999 - "llvm.return"(%1) : (i999) -> () - }) {linkage = 10 : i64, sym_name = "test8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1005): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i1005} : () -> i1005 - %1 = "llvm.and"(%arg0, %0) : (i1005, i1005) -> i1005 - "llvm.return"(%1) : (i1005) -> () - }) {linkage = 10 : i64, sym_name = "test9", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i123): // no predecessors - %0 = "llvm.mlir.constant"() {value = 128 : i123} : () -> i123 - %1 = "llvm.mlir.constant"() {value = 127 : i123} : () -> i123 - %2 = "llvm.and"(%arg0, %1) : (i123, i123) -> i123 - %3 = "llvm.and"(%2, %0) : (i123, i123) -> i123 - "llvm.return"(%3) : (i123) -> () - }) {linkage = 10 : i64, sym_name = "test10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i737): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i737} : () -> i737 - %1 = "llvm.mlir.constant"() {value = -2147483648 : i737} : () -> i737 - %2 = "llvm.and"(%arg0, %1) : (i737, i737) -> i737 - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (i737, i737) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i117, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 12 : i117} : () -> i117 - %1 = "llvm.mlir.constant"() {value = 3 : i117} : () -> i117 - %2 = "llvm.or"(%arg0, %1) : (i117, i117) -> i117 - %3 = "llvm.xor"(%2, %0) : (i117, i117) -> i117 - "llvm.store"(%3, %arg1) : (i117, !llvm.ptr) -> () - %4 = "llvm.and"(%3, %1) : (i117, i117) -> i117 - "llvm.return"(%4) : (i117) -> () - }) {linkage = 10 : i64, sym_name = "test12", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1024): // no predecessors - %0 = "llvm.mlir.constant"() {value = 255 : i1024} : () -> i1024 - %1 = "llvm.mlir.constant"() {value = 1016 : i1024} : () -> i1024 - %2 = "llvm.ashr"(%arg0, %1) : (i1024, i1024) -> i1024 - %3 = "llvm.and"(%2, %0) : (i1024, i1024) -> i1024 - "llvm.return"(%3) : (i1024) -> () - }) {linkage = 10 : i64, sym_name = "test13", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test0(%arg0: i39) -> i39 { + %0 = llvm.mlir.constant(0 : i39) : i39 + %1 = llvm.and %arg0, %0 : i39 + llvm.return %1 : i39 + } + llvm.func @test2(%arg0: i15) -> i15 { + %0 = llvm.mlir.constant(-1 : i15) : i15 + %1 = llvm.and %arg0, %0 : i15 + llvm.return %1 : i15 + } + llvm.func @test3(%arg0: i23) -> i23 { + %0 = llvm.mlir.constant(127 : i23) : i23 + %1 = llvm.mlir.constant(128 : i23) : i23 + %2 = llvm.and %arg0, %0 : i23 + %3 = llvm.and %2, %1 : i23 + llvm.return %3 : i23 + } + llvm.func @test4(%arg0: i37) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i37) : i37 + %1 = llvm.mlir.constant(0 : i37) : i37 + %2 = llvm.and %arg0, %0 : i37 + %3 = llvm.icmp "ne" %2, %1 : i37 + llvm.return %3 : i1 + } + llvm.func @test5(%arg0: i7, %arg1: !llvm.ptr) -> i7 { + %0 = llvm.mlir.constant(3 : i7) : i7 + %1 = llvm.mlir.constant(12 : i7) : i7 + %2 = llvm.or %arg0, %0 : i7 + %3 = llvm.xor %2, %1 : i7 + llvm.store %3, %arg1 {alignment = 1 : i64} : i7, !llvm.ptr + %4 = llvm.and %3, %0 : i7 + llvm.return %4 : i7 + } + llvm.func @test7(%arg0: i47) -> i47 { + %0 = llvm.mlir.constant(39 : i47) : i47 + %1 = llvm.mlir.constant(255 : i47) : i47 + %2 = llvm.ashr %arg0, %0 : i47 + %3 = llvm.and %2, %1 : i47 + llvm.return %3 : i47 + } + llvm.func @test8(%arg0: i999) -> i999 { + %0 = llvm.mlir.constant(0 : i999) : i999 + %1 = llvm.and %arg0, %0 : i999 + llvm.return %1 : i999 + } + llvm.func @test9(%arg0: i1005) -> i1005 { + %0 = llvm.mlir.constant(-1 : i1005) : i1005 + %1 = llvm.and %arg0, %0 : i1005 + llvm.return %1 : i1005 + } + llvm.func @test10(%arg0: i123) -> i123 { + %0 = llvm.mlir.constant(127 : i123) : i123 + %1 = llvm.mlir.constant(128 : i123) : i123 + %2 = llvm.and %arg0, %0 : i123 + %3 = llvm.and %2, %1 : i123 + llvm.return %3 : i123 + } + llvm.func @test11(%arg0: i737) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i737) : i737 + %1 = llvm.mlir.constant(0 : i737) : i737 + %2 = llvm.and %arg0, %0 : i737 + %3 = llvm.icmp "ne" %2, %1 : i737 + llvm.return %3 : i1 + } + llvm.func @test12(%arg0: i117, %arg1: !llvm.ptr) -> i117 { + %0 = llvm.mlir.constant(3 : i117) : i117 + %1 = llvm.mlir.constant(12 : i117) : i117 + %2 = llvm.or %arg0, %0 : i117 + %3 = llvm.xor %2, %1 : i117 + llvm.store %3, %arg1 {alignment = 4 : i64} : i117, !llvm.ptr + %4 = llvm.and %3, %0 : i117 + llvm.return %4 : i117 + } + llvm.func @test13(%arg0: i1024) -> i1024 { + %0 = llvm.mlir.constant(1016 : i1024) : i1024 + %1 = llvm.mlir.constant(255 : i1024) : i1024 + %2 = llvm.ashr %arg0, %0 : i1024 + %3 = llvm.and %2, %1 : i1024 + llvm.return %3 : i1024 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-call-cast-target.ll.mlir b/test/LLVMDialect/InstCombine/apint-call-cast-target.ll.mlir index 803d31e1a..d4176f5ec 100644 --- a/test/LLVMDialect/InstCombine/apint-call-cast-target.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-call-cast-target.ll.mlir @@ -1,21 +1,15 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "main2", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "ctime2", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @main2} : () -> !llvm.ptr> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>) -> !llvm.ptr ()>> - %2 = "llvm.call"(%1) : (!llvm.ptr ()>>) -> !llvm.ptr - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "ctime", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @ctime2} : () -> !llvm.ptr (ptr)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr (ptr)>>) -> !llvm.ptr)>> - %2 = "llvm.mlir.null"() : () -> !llvm.ptr - %3 = "llvm.call"(%1, %2) : (!llvm.ptr)>>, !llvm.ptr) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "main", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @main2() -> i32 + llvm.func @ctime2(!llvm.ptr) -> !llvm.ptr + llvm.func @ctime(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.addressof @main2 : !llvm.ptr + %1 = llvm.call %0() : !llvm.ptr, () -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @main() -> i32 { + %0 = llvm.mlir.addressof @ctime2 : !llvm.ptr + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.call %0(%1) : !llvm.ptr, (!llvm.ptr) -> i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-cast-and-cast.ll.mlir b/test/LLVMDialect/InstCombine/apint-cast-and-cast.ll.mlir index a574246af..ff94a15d8 100644 --- a/test/LLVMDialect/InstCombine/apint-cast-and-cast.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-cast-and-cast.ll.mlir @@ -1,19 +1,16 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i43): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i43} : () -> i43 - %1 = "llvm.bitcast"(%arg0) : (i43) -> i43 - %2 = "llvm.and"(%1, %0) : (i43, i43) -> i43 - %3 = "llvm.trunc"(%2) : (i43) -> i19 - "llvm.return"(%3) : (i19) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i677): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i677} : () -> i677 - %1 = "llvm.bitcast"(%arg0) : (i677) -> i677 - %2 = "llvm.and"(%1, %0) : (i677, i677) -> i677 - %3 = "llvm.trunc"(%2) : (i677) -> i73 - "llvm.return"(%3) : (i73) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i43) -> i19 { + %0 = llvm.mlir.constant(1 : i43) : i43 + %1 = llvm.bitcast %arg0 : i43 to i43 + %2 = llvm.and %1, %0 : i43 + %3 = llvm.trunc %2 : i43 to i19 + llvm.return %3 : i19 + } + llvm.func @test2(%arg0: i677) -> i73 { + %0 = llvm.mlir.constant(1 : i677) : i677 + %1 = llvm.bitcast %arg0 : i677 to i677 + %2 = llvm.and %1, %0 : i677 + %3 = llvm.trunc %2 : i677 to i73 + llvm.return %3 : i73 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-cast-cast-to-and.ll.mlir b/test/LLVMDialect/InstCombine/apint-cast-cast-to-and.ll.mlir index f47f79810..5734b5d1b 100644 --- a/test/LLVMDialect/InstCombine/apint-cast-cast-to-and.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-cast-cast-to-and.ll.mlir @@ -1,9 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i61): // no predecessors - %0 = "llvm.trunc"(%arg0) : (i61) -> i41 - %1 = "llvm.zext"(%0) : (i41) -> i61 - "llvm.return"(%1) : (i61) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i61) -> i61 { + %0 = llvm.trunc %arg0 : i61 to i41 + %1 = llvm.zext %0 : i41 to i61 + llvm.return %1 : i61 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-cast.ll.mlir b/test/LLVMDialect/InstCombine/apint-cast.ll.mlir index 0126f0319..0a7f69cf7 100644 --- a/test/LLVMDialect/InstCombine/apint-cast.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-cast.ll.mlir @@ -1,24 +1,21 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i17): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i37} : () -> i37 - %1 = "llvm.zext"(%arg0) : (i17) -> i37 - %2 = "llvm.lshr"(%1, %0) : (i37, i37) -> i37 - %3 = "llvm.shl"(%1, %0) : (i37, i37) -> i37 - %4 = "llvm.or"(%2, %3) : (i37, i37) -> i37 - %5 = "llvm.trunc"(%4) : (i37) -> i17 - "llvm.return"(%5) : (i17) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i167): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i577} : () -> i577 - %1 = "llvm.mlir.constant"() {value = 9 : i577} : () -> i577 - %2 = "llvm.zext"(%arg0) : (i167) -> i577 - %3 = "llvm.lshr"(%2, %1) : (i577, i577) -> i577 - %4 = "llvm.shl"(%2, %0) : (i577, i577) -> i577 - %5 = "llvm.or"(%3, %4) : (i577, i577) -> i577 - %6 = "llvm.trunc"(%5) : (i577) -> i167 - "llvm.return"(%6) : (i167) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i17) -> i17 { + %0 = llvm.mlir.constant(8 : i37) : i37 + %1 = llvm.zext %arg0 : i17 to i37 + %2 = llvm.lshr %1, %0 : i37 + %3 = llvm.shl %1, %0 : i37 + %4 = llvm.or %2, %3 : i37 + %5 = llvm.trunc %4 : i37 to i17 + llvm.return %5 : i17 + } + llvm.func @test2(%arg0: i167) -> i167 { + %0 = llvm.mlir.constant(9 : i577) : i577 + %1 = llvm.mlir.constant(8 : i577) : i577 + %2 = llvm.zext %arg0 : i167 to i577 + %3 = llvm.lshr %2, %0 : i577 + %4 = llvm.shl %2, %1 : i577 + %5 = llvm.or %3, %4 : i577 + %6 = llvm.trunc %5 : i577 to i167 + llvm.return %6 : i167 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-div1.ll.mlir b/test/LLVMDialect/InstCombine/apint-div1.ll.mlir new file mode 100644 index 000000000..0b1ce5c31 --- /dev/null +++ b/test/LLVMDialect/InstCombine/apint-div1.ll.mlir @@ -0,0 +1,21 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i33) -> i33 { + %0 = llvm.mlir.constant(4096 : i33) : i33 + %1 = llvm.udiv %arg0, %0 : i33 + llvm.return %1 : i33 + } + llvm.func @test2(%arg0: i49) -> i49 { + %0 = llvm.mlir.constant(4096 : i49) : i49 + %1 = llvm.mlir.constant(17 : i49) : i49 + %2 = llvm.shl %0, %1 : i49 + %3 = llvm.udiv %arg0, %2 : i49 + llvm.return %3 : i49 + } + llvm.func @test3(%arg0: i59, %arg1: i1) -> i59 { + %0 = llvm.mlir.constant(1024 : i59) : i59 + %1 = llvm.mlir.constant(4096 : i59) : i59 + %2 = llvm.select %arg1, %0, %1 : i1, i59 + %3 = llvm.udiv %arg0, %2 : i59 + llvm.return %3 : i59 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-div2.ll.mlir b/test/LLVMDialect/InstCombine/apint-div2.ll.mlir new file mode 100644 index 000000000..1de8dfa1f --- /dev/null +++ b/test/LLVMDialect/InstCombine/apint-div2.ll.mlir @@ -0,0 +1,21 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i333) -> i333 { + %0 = llvm.mlir.constant(70368744177664 : i333) : i333 + %1 = llvm.udiv %arg0, %0 : i333 + llvm.return %1 : i333 + } + llvm.func @test2(%arg0: i499) -> i499 { + %0 = llvm.mlir.constant(4096 : i499) : i499 + %1 = llvm.mlir.constant(197 : i499) : i499 + %2 = llvm.shl %0, %1 : i499 + %3 = llvm.udiv %arg0, %2 : i499 + llvm.return %3 : i499 + } + llvm.func @test3(%arg0: i599, %arg1: i1) -> i599 { + %0 = llvm.mlir.constant(70368744177664 : i599) : i599 + %1 = llvm.mlir.constant(4096 : i599) : i599 + %2 = llvm.select %arg1, %0, %1 : i1, i599 + %3 = llvm.udiv %arg0, %2 : i599 + llvm.return %3 : i599 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-mul1.ll.mlir b/test/LLVMDialect/InstCombine/apint-mul1.ll.mlir new file mode 100644 index 000000000..ddc27a3bd --- /dev/null +++ b/test/LLVMDialect/InstCombine/apint-mul1.ll.mlir @@ -0,0 +1,20 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i17) -> i17 { + %0 = llvm.mlir.constant(1024 : i17) : i17 + %1 = llvm.mul %arg0, %0 : i17 + llvm.return %1 : i17 + } + llvm.func @test2(%arg0: vector<2xi17>) -> vector<2xi17> { + %0 = llvm.mlir.constant(1024 : i17) : i17 + %1 = llvm.mlir.constant(dense<1024> : vector<2xi17>) : vector<2xi17> + %2 = llvm.mul %arg0, %1 : vector<2xi17> + llvm.return %2 : vector<2xi17> + } + llvm.func @test3(%arg0: vector<2xi17>) -> vector<2xi17> { + %0 = llvm.mlir.constant(256 : i17) : i17 + %1 = llvm.mlir.constant(1024 : i17) : i17 + %2 = llvm.mlir.constant(dense<[1024, 256]> : vector<2xi17>) : vector<2xi17> + %3 = llvm.mul %arg0, %2 : vector<2xi17> + llvm.return %3 : vector<2xi17> + } +} diff --git a/test/LLVMDialect/InstCombine/apint-mul2.ll.mlir b/test/LLVMDialect/InstCombine/apint-mul2.ll.mlir new file mode 100644 index 000000000..433c2bc33 --- /dev/null +++ b/test/LLVMDialect/InstCombine/apint-mul2.ll.mlir @@ -0,0 +1,28 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i177) -> i177 { + %0 = llvm.mlir.constant(1 : i177) : i177 + %1 = llvm.mlir.constant(155 : i177) : i177 + %2 = llvm.shl %0, %1 : i177 + %3 = llvm.mul %arg0, %2 : i177 + llvm.return %3 : i177 + } + llvm.func @test2(%arg0: vector<2xi177>) -> vector<2xi177> { + %0 = llvm.mlir.constant(1 : i177) : i177 + %1 = llvm.mlir.constant(dense<1> : vector<2xi177>) : vector<2xi177> + %2 = llvm.mlir.constant(155 : i177) : i177 + %3 = llvm.mlir.constant(dense<155> : vector<2xi177>) : vector<2xi177> + %4 = llvm.shl %1, %3 : vector<2xi177> + %5 = llvm.mul %arg0, %4 : vector<2xi177> + llvm.return %5 : vector<2xi177> + } + llvm.func @test3(%arg0: vector<2xi177>) -> vector<2xi177> { + %0 = llvm.mlir.constant(1 : i177) : i177 + %1 = llvm.mlir.constant(dense<1> : vector<2xi177>) : vector<2xi177> + %2 = llvm.mlir.constant(155 : i177) : i177 + %3 = llvm.mlir.constant(150 : i177) : i177 + %4 = llvm.mlir.constant(dense<[150, 155]> : vector<2xi177>) : vector<2xi177> + %5 = llvm.shl %1, %4 : vector<2xi177> + %6 = llvm.mul %arg0, %5 : vector<2xi177> + llvm.return %6 : vector<2xi177> + } +} diff --git a/test/LLVMDialect/InstCombine/apint-not.ll.mlir b/test/LLVMDialect/InstCombine/apint-not.ll.mlir index 984dc707a..d86587f3a 100644 --- a/test/LLVMDialect/InstCombine/apint-not.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-not.ll.mlir @@ -1,17 +1,14 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i33): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i33} : () -> i33 - %1 = "llvm.xor"(%arg0, %0) : (i33, i33) -> i33 - %2 = "llvm.xor"(%1, %0) : (i33, i33) -> i33 - "llvm.return"(%2) : (i33) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i52, %arg1: i52): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.icmp"(%arg0, %arg1) {predicate = 7 : i64} : (i52, i52) -> i1 - %2 = "llvm.xor"(%1, %0) : (i1, i1) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i33) -> i33 { + %0 = llvm.mlir.constant(-1 : i33) : i33 + %1 = llvm.xor %arg0, %0 : i33 + %2 = llvm.xor %1, %0 : i33 + llvm.return %2 : i33 + } + llvm.func @test2(%arg0: i52, %arg1: i52) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "ule" %arg0, %arg1 : i52 + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-or.ll.mlir b/test/LLVMDialect/InstCombine/apint-or.ll.mlir index 0b89c0b3d..658a1c98b 100644 --- a/test/LLVMDialect/InstCombine/apint-or.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-or.ll.mlir @@ -1,43 +1,38 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i23): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i23} : () -> i23 - %1 = "llvm.xor"(%0, %arg0) : (i23, i23) -> i23 - %2 = "llvm.or"(%arg0, %1) : (i23, i23) -> i23 - "llvm.return"(%2) : (i23) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i39, %arg1: i39): // no predecessors - %0 = "llvm.mlir.constant"() {value = -274877906944 : i39} : () -> i39 - %1 = "llvm.mlir.constant"() {value = -1 : i39} : () -> i39 - %2 = "llvm.mlir.constant"() {value = 274877906943 : i39} : () -> i39 - %3 = "llvm.xor"(%2, %1) : (i39, i39) -> i39 - %4 = "llvm.and"(%arg1, %0) : (i39, i39) -> i39 - %5 = "llvm.add"(%arg0, %4) : (i39, i39) -> i39 - %6 = "llvm.and"(%5, %3) : (i39, i39) -> i39 - %7 = "llvm.and"(%arg0, %2) : (i39, i39) -> i39 - %8 = "llvm.or"(%6, %7) : (i39, i39) -> i39 - "llvm.return"(%8) : (i39) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1023): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i1023} : () -> i1023 - %1 = "llvm.xor"(%0, %arg0) : (i1023, i1023) -> i1023 - %2 = "llvm.or"(%arg0, %1) : (i1023, i1023) -> i1023 - "llvm.return"(%2) : (i1023) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i399, %arg1: i399): // no predecessors - %0 = "llvm.mlir.constant"() {value = 18446742974197923840 : i399} : () -> i399 - %1 = "llvm.mlir.constant"() {value = -1 : i399} : () -> i399 - %2 = "llvm.mlir.constant"() {value = 274877906943 : i399} : () -> i399 - %3 = "llvm.xor"(%2, %1) : (i399, i399) -> i399 - %4 = "llvm.and"(%arg1, %0) : (i399, i399) -> i399 - %5 = "llvm.add"(%arg0, %4) : (i399, i399) -> i399 - %6 = "llvm.and"(%5, %3) : (i399, i399) -> i399 - %7 = "llvm.and"(%arg0, %2) : (i399, i399) -> i399 - %8 = "llvm.or"(%6, %7) : (i399, i399) -> i399 - "llvm.return"(%8) : (i399) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i23) -> i23 { + %0 = llvm.mlir.constant(-1 : i23) : i23 + %1 = llvm.xor %0, %arg0 : i23 + %2 = llvm.or %arg0, %1 : i23 + llvm.return %2 : i23 + } + llvm.func @test2(%arg0: i39, %arg1: i39) -> i39 { + %0 = llvm.mlir.constant(274877906943 : i39) : i39 + %1 = llvm.mlir.constant(-1 : i39) : i39 + %2 = llvm.mlir.constant(-274877906944 : i39) : i39 + %3 = llvm.xor %0, %1 : i39 + %4 = llvm.and %arg1, %2 : i39 + %5 = llvm.add %arg0, %4 : i39 + %6 = llvm.and %5, %3 : i39 + %7 = llvm.and %arg0, %0 : i39 + %8 = llvm.or %6, %7 : i39 + llvm.return %8 : i39 + } + llvm.func @test4(%arg0: i1023) -> i1023 { + %0 = llvm.mlir.constant(-1 : i1023) : i1023 + %1 = llvm.xor %0, %arg0 : i1023 + %2 = llvm.or %arg0, %1 : i1023 + llvm.return %2 : i1023 + } + llvm.func @test5(%arg0: i399, %arg1: i399) -> i399 { + %0 = llvm.mlir.constant(274877906943 : i399) : i399 + %1 = llvm.mlir.constant(-1 : i399) : i399 + %2 = llvm.mlir.constant(18446742974197923840 : i399) : i399 + %3 = llvm.xor %0, %1 : i399 + %4 = llvm.and %arg1, %2 : i399 + %5 = llvm.add %arg0, %4 : i399 + %6 = llvm.and %5, %3 : i399 + %7 = llvm.and %arg0, %0 : i399 + %8 = llvm.or %6, %7 : i399 + llvm.return %8 : i399 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-rem1.ll.mlir b/test/LLVMDialect/InstCombine/apint-rem1.ll.mlir new file mode 100644 index 000000000..c003c2343 --- /dev/null +++ b/test/LLVMDialect/InstCombine/apint-rem1.ll.mlir @@ -0,0 +1,21 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i33) -> i33 { + %0 = llvm.mlir.constant(4096 : i33) : i33 + %1 = llvm.urem %arg0, %0 : i33 + llvm.return %1 : i33 + } + llvm.func @test2(%arg0: i49) -> i49 { + %0 = llvm.mlir.constant(4096 : i49) : i49 + %1 = llvm.mlir.constant(11 : i49) : i49 + %2 = llvm.shl %0, %1 : i49 + %3 = llvm.urem %arg0, %2 : i49 + llvm.return %3 : i49 + } + llvm.func @test3(%arg0: i59, %arg1: i1) -> i59 { + %0 = llvm.mlir.constant(70368744177664 : i59) : i59 + %1 = llvm.mlir.constant(4096 : i59) : i59 + %2 = llvm.select %arg1, %0, %1 : i1, i59 + %3 = llvm.urem %arg0, %2 : i59 + llvm.return %3 : i59 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-rem2.ll.mlir b/test/LLVMDialect/InstCombine/apint-rem2.ll.mlir new file mode 100644 index 000000000..e9ac1e309 --- /dev/null +++ b/test/LLVMDialect/InstCombine/apint-rem2.ll.mlir @@ -0,0 +1,21 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i333) -> i333 { + %0 = llvm.mlir.constant(70368744177664 : i333) : i333 + %1 = llvm.urem %arg0, %0 : i333 + llvm.return %1 : i333 + } + llvm.func @test2(%arg0: i499) -> i499 { + %0 = llvm.mlir.constant(4096 : i499) : i499 + %1 = llvm.mlir.constant(111 : i499) : i499 + %2 = llvm.shl %0, %1 : i499 + %3 = llvm.urem %arg0, %2 : i499 + llvm.return %3 : i499 + } + llvm.func @test3(%arg0: i599, %arg1: i1) -> i599 { + %0 = llvm.mlir.constant(70368744177664 : i599) : i599 + %1 = llvm.mlir.constant(4096 : i599) : i599 + %2 = llvm.select %arg1, %0, %1 : i1, i599 + %3 = llvm.urem %arg0, %2 : i599 + llvm.return %3 : i599 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-select.ll.mlir b/test/LLVMDialect/InstCombine/apint-select.ll.mlir new file mode 100644 index 000000000..a4e55eade --- /dev/null +++ b/test/LLVMDialect/InstCombine/apint-select.ll.mlir @@ -0,0 +1,77 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @zext(%arg0: i1) -> i41 { + %0 = llvm.mlir.constant(1 : i41) : i41 + %1 = llvm.mlir.constant(0 : i41) : i41 + %2 = llvm.select %arg0, %0, %1 : i1, i41 + llvm.return %2 : i41 + } + llvm.func @sext(%arg0: i1) -> i41 { + %0 = llvm.mlir.constant(-1 : i41) : i41 + %1 = llvm.mlir.constant(0 : i41) : i41 + %2 = llvm.select %arg0, %0, %1 : i1, i41 + llvm.return %2 : i41 + } + llvm.func @not_zext(%arg0: i1) -> i999 { + %0 = llvm.mlir.constant(0 : i999) : i999 + %1 = llvm.mlir.constant(1 : i999) : i999 + %2 = llvm.select %arg0, %0, %1 : i1, i999 + llvm.return %2 : i999 + } + llvm.func @not_sext(%arg0: i1) -> i999 { + %0 = llvm.mlir.constant(0 : i999) : i999 + %1 = llvm.mlir.constant(-1 : i999) : i999 + %2 = llvm.select %arg0, %0, %1 : i1, i999 + llvm.return %2 : i999 + } + llvm.func @zext_vec(%arg0: vector<2xi1>) -> vector<2xi41> { + %0 = llvm.mlir.constant(1 : i41) : i41 + %1 = llvm.mlir.constant(dense<1> : vector<2xi41>) : vector<2xi41> + %2 = llvm.mlir.constant(0 : i41) : i41 + %3 = llvm.mlir.constant(dense<0> : vector<2xi41>) : vector<2xi41> + %4 = llvm.select %arg0, %1, %3 : vector<2xi1>, vector<2xi41> + llvm.return %4 : vector<2xi41> + } + llvm.func @sext_vec(%arg0: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.select %arg0, %0, %2 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @not_zext_vec(%arg0: vector<2xi1>) -> vector<2xi999> { + %0 = llvm.mlir.constant(0 : i999) : i999 + %1 = llvm.mlir.constant(dense<0> : vector<2xi999>) : vector<2xi999> + %2 = llvm.mlir.constant(1 : i999) : i999 + %3 = llvm.mlir.constant(dense<1> : vector<2xi999>) : vector<2xi999> + %4 = llvm.select %arg0, %1, %3 : vector<2xi1>, vector<2xi999> + llvm.return %4 : vector<2xi999> + } + llvm.func @not_sext_vec(%arg0: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi64>) : vector<2xi64> + %3 = llvm.select %arg0, %1, %2 : vector<2xi1>, vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @scalar_select_of_vectors(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.select %arg0, %0, %2 : i1, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @test3(%arg0: i41) -> i41 { + %0 = llvm.mlir.constant(0 : i41) : i41 + %1 = llvm.mlir.constant(-1 : i41) : i41 + %2 = llvm.icmp "slt" %arg0, %0 : i41 + %3 = llvm.select %2, %1, %0 : i1, i41 + llvm.return %3 : i41 + } + llvm.func @test4(%arg0: i1023) -> i1023 { + %0 = llvm.mlir.constant(0 : i1023) : i1023 + %1 = llvm.mlir.constant(-1 : i1023) : i1023 + %2 = llvm.icmp "slt" %arg0, %0 : i1023 + %3 = llvm.select %2, %1, %0 : i1, i1023 + llvm.return %3 : i1023 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-shift-simplify.ll.mlir b/test/LLVMDialect/InstCombine/apint-shift-simplify.ll.mlir index 32313bfb2..96ae6bc44 100644 --- a/test/LLVMDialect/InstCombine/apint-shift-simplify.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-shift-simplify.ll.mlir @@ -1,24 +1,20 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i41, %arg1: i41, %arg2: i41): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i41, i41) -> i41 - %1 = "llvm.shl"(%arg1, %arg2) : (i41, i41) -> i41 - %2 = "llvm.and"(%0, %1) : (i41, i41) -> i41 - "llvm.return"(%2) : (i41) -> () - }) {linkage = 10 : i64, sym_name = "test0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i57, %arg1: i57, %arg2: i57): // no predecessors - %0 = "llvm.lshr"(%arg0, %arg2) : (i57, i57) -> i57 - %1 = "llvm.lshr"(%arg1, %arg2) : (i57, i57) -> i57 - %2 = "llvm.or"(%0, %1) : (i57, i57) -> i57 - "llvm.return"(%2) : (i57) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i49, %arg1: i49, %arg2: i49): // no predecessors - %0 = "llvm.ashr"(%arg0, %arg2) : (i49, i49) -> i49 - %1 = "llvm.ashr"(%arg1, %arg2) : (i49, i49) -> i49 - %2 = "llvm.xor"(%0, %1) : (i49, i49) -> i49 - "llvm.return"(%2) : (i49) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test0(%arg0: i41, %arg1: i41, %arg2: i41) -> i41 { + %0 = llvm.shl %arg0, %arg2 : i41 + %1 = llvm.shl %arg1, %arg2 : i41 + %2 = llvm.and %0, %1 : i41 + llvm.return %2 : i41 + } + llvm.func @test1(%arg0: i57, %arg1: i57, %arg2: i57) -> i57 { + %0 = llvm.lshr %arg0, %arg2 : i57 + %1 = llvm.lshr %arg1, %arg2 : i57 + %2 = llvm.or %0, %1 : i57 + llvm.return %2 : i57 + } + llvm.func @test2(%arg0: i49, %arg1: i49, %arg2: i49) -> i49 { + %0 = llvm.ashr %arg0, %arg2 : i49 + %1 = llvm.ashr %arg1, %arg2 : i49 + %2 = llvm.xor %0, %1 : i49 + llvm.return %2 : i49 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-shift.ll.mlir b/test/LLVMDialect/InstCombine/apint-shift.ll.mlir new file mode 100644 index 000000000..7a119a325 --- /dev/null +++ b/test/LLVMDialect/InstCombine/apint-shift.ll.mlir @@ -0,0 +1,412 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test6(%arg0: i55) -> i55 { + %0 = llvm.mlir.constant(1 : i55) : i55 + %1 = llvm.mlir.constant(3 : i55) : i55 + %2 = llvm.shl %arg0, %0 : i55 + %3 = llvm.mul %2, %1 : i55 + llvm.return %3 : i55 + } + llvm.func @test6a(%arg0: i55) -> i55 { + %0 = llvm.mlir.constant(3 : i55) : i55 + %1 = llvm.mlir.constant(1 : i55) : i55 + %2 = llvm.mul %arg0, %0 : i55 + %3 = llvm.shl %2, %1 : i55 + llvm.return %3 : i55 + } + llvm.func @use(i55) + llvm.func @test6a_negative_oneuse(%arg0: i55) -> i55 { + %0 = llvm.mlir.constant(3 : i55) : i55 + %1 = llvm.mlir.constant(1 : i55) : i55 + %2 = llvm.mul %arg0, %0 : i55 + %3 = llvm.shl %2, %1 : i55 + llvm.call @use(%2) : (i55) -> () + llvm.return %3 : i55 + } + llvm.func @test6a_vec(%arg0: vector<2xi55>) -> vector<2xi55> { + %0 = llvm.mlir.constant(12 : i55) : i55 + %1 = llvm.mlir.constant(3 : i55) : i55 + %2 = llvm.mlir.constant(dense<[3, 12]> : vector<2xi55>) : vector<2xi55> + %3 = llvm.mlir.constant(2 : i55) : i55 + %4 = llvm.mlir.constant(1 : i55) : i55 + %5 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi55>) : vector<2xi55> + %6 = llvm.mul %arg0, %2 : vector<2xi55> + %7 = llvm.shl %6, %5 : vector<2xi55> + llvm.return %7 : vector<2xi55> + } + llvm.func @test7(%arg0: i8) -> i29 { + %0 = llvm.mlir.constant(-1 : i29) : i29 + %1 = llvm.zext %arg0 : i8 to i29 + %2 = llvm.ashr %0, %1 : i29 + llvm.return %2 : i29 + } + llvm.func @test8(%arg0: i7) -> i7 { + %0 = llvm.mlir.constant(4 : i7) : i7 + %1 = llvm.mlir.constant(3 : i7) : i7 + %2 = llvm.shl %arg0, %0 : i7 + %3 = llvm.shl %2, %1 : i7 + llvm.return %3 : i7 + } + llvm.func @test9(%arg0: i17) -> i17 { + %0 = llvm.mlir.constant(16 : i17) : i17 + %1 = llvm.shl %arg0, %0 : i17 + %2 = llvm.lshr %1, %0 : i17 + llvm.return %2 : i17 + } + llvm.func @test10(%arg0: i19) -> i19 { + %0 = llvm.mlir.constant(18 : i19) : i19 + %1 = llvm.lshr %arg0, %0 : i19 + %2 = llvm.shl %1, %0 : i19 + llvm.return %2 : i19 + } + llvm.func @lshr_lshr_splat_vec(%arg0: vector<2xi19>) -> vector<2xi19> { + %0 = llvm.mlir.constant(3 : i19) : i19 + %1 = llvm.mlir.constant(dense<3> : vector<2xi19>) : vector<2xi19> + %2 = llvm.mlir.constant(2 : i19) : i19 + %3 = llvm.mlir.constant(dense<2> : vector<2xi19>) : vector<2xi19> + %4 = llvm.lshr %arg0, %1 : vector<2xi19> + %5 = llvm.lshr %4, %3 : vector<2xi19> + llvm.return %5 : vector<2xi19> + } + llvm.func @multiuse_lshr_lshr(%arg0: i9) -> i9 { + %0 = llvm.mlir.constant(2 : i9) : i9 + %1 = llvm.mlir.constant(3 : i9) : i9 + %2 = llvm.lshr %arg0, %0 : i9 + %3 = llvm.lshr %2, %1 : i9 + %4 = llvm.mul %2, %3 : i9 + llvm.return %4 : i9 + } + llvm.func @multiuse_lshr_lshr_splat(%arg0: vector<2xi9>) -> vector<2xi9> { + %0 = llvm.mlir.constant(2 : i9) : i9 + %1 = llvm.mlir.constant(dense<2> : vector<2xi9>) : vector<2xi9> + %2 = llvm.mlir.constant(3 : i9) : i9 + %3 = llvm.mlir.constant(dense<3> : vector<2xi9>) : vector<2xi9> + %4 = llvm.lshr %arg0, %1 : vector<2xi9> + %5 = llvm.lshr %4, %3 : vector<2xi9> + %6 = llvm.mul %4, %5 : vector<2xi9> + llvm.return %6 : vector<2xi9> + } + llvm.func @shl_shl_splat_vec(%arg0: vector<2xi19>) -> vector<2xi19> { + %0 = llvm.mlir.constant(3 : i19) : i19 + %1 = llvm.mlir.constant(dense<3> : vector<2xi19>) : vector<2xi19> + %2 = llvm.mlir.constant(2 : i19) : i19 + %3 = llvm.mlir.constant(dense<2> : vector<2xi19>) : vector<2xi19> + %4 = llvm.shl %arg0, %1 : vector<2xi19> + %5 = llvm.shl %4, %3 : vector<2xi19> + llvm.return %5 : vector<2xi19> + } + llvm.func @multiuse_shl_shl(%arg0: i42) -> i42 { + %0 = llvm.mlir.constant(8 : i42) : i42 + %1 = llvm.mlir.constant(9 : i42) : i42 + %2 = llvm.shl %arg0, %0 : i42 + %3 = llvm.shl %2, %1 : i42 + %4 = llvm.mul %2, %3 : i42 + llvm.return %4 : i42 + } + llvm.func @multiuse_shl_shl_splat(%arg0: vector<2xi42>) -> vector<2xi42> { + %0 = llvm.mlir.constant(8 : i42) : i42 + %1 = llvm.mlir.constant(dense<8> : vector<2xi42>) : vector<2xi42> + %2 = llvm.mlir.constant(9 : i42) : i42 + %3 = llvm.mlir.constant(dense<9> : vector<2xi42>) : vector<2xi42> + %4 = llvm.shl %arg0, %1 : vector<2xi42> + %5 = llvm.shl %4, %3 : vector<2xi42> + %6 = llvm.mul %4, %5 : vector<2xi42> + llvm.return %6 : vector<2xi42> + } + llvm.func @eq_shl_lshr_splat_vec(%arg0: vector<2xi19>) -> vector<2xi19> { + %0 = llvm.mlir.constant(3 : i19) : i19 + %1 = llvm.mlir.constant(dense<3> : vector<2xi19>) : vector<2xi19> + %2 = llvm.shl %arg0, %1 : vector<2xi19> + %3 = llvm.lshr %2, %1 : vector<2xi19> + llvm.return %3 : vector<2xi19> + } + llvm.func @eq_lshr_shl_splat_vec(%arg0: vector<2xi19>) -> vector<2xi19> { + %0 = llvm.mlir.constant(3 : i19) : i19 + %1 = llvm.mlir.constant(dense<3> : vector<2xi19>) : vector<2xi19> + %2 = llvm.lshr %arg0, %1 : vector<2xi19> + %3 = llvm.shl %2, %1 : vector<2xi19> + llvm.return %3 : vector<2xi19> + } + llvm.func @lshr_shl_splat_vec(%arg0: vector<2xi7>) -> vector<2xi7> { + %0 = llvm.mlir.constant(-8 : i7) : i7 + %1 = llvm.mlir.constant(dense<-8> : vector<2xi7>) : vector<2xi7> + %2 = llvm.mlir.constant(3 : i7) : i7 + %3 = llvm.mlir.constant(dense<3> : vector<2xi7>) : vector<2xi7> + %4 = llvm.mlir.constant(2 : i7) : i7 + %5 = llvm.mlir.constant(dense<2> : vector<2xi7>) : vector<2xi7> + %6 = llvm.mul %arg0, %1 : vector<2xi7> + %7 = llvm.lshr %6, %3 : vector<2xi7> + %8 = llvm.shl %7, %5 overflow : vector<2xi7> + llvm.return %8 : vector<2xi7> + } + llvm.func @shl_lshr_splat_vec(%arg0: vector<2xi7>) -> vector<2xi7> { + %0 = llvm.mlir.constant(9 : i7) : i7 + %1 = llvm.mlir.constant(dense<9> : vector<2xi7>) : vector<2xi7> + %2 = llvm.mlir.constant(3 : i7) : i7 + %3 = llvm.mlir.constant(dense<3> : vector<2xi7>) : vector<2xi7> + %4 = llvm.mlir.constant(2 : i7) : i7 + %5 = llvm.mlir.constant(dense<2> : vector<2xi7>) : vector<2xi7> + %6 = llvm.udiv %arg0, %1 : vector<2xi7> + %7 = llvm.shl %6, %3 overflow : vector<2xi7> + %8 = llvm.lshr %7, %5 : vector<2xi7> + llvm.return %8 : vector<2xi7> + } + llvm.func @test11(%arg0: i23) -> i23 { + %0 = llvm.mlir.constant(3 : i23) : i23 + %1 = llvm.mlir.constant(11 : i23) : i23 + %2 = llvm.mlir.constant(12 : i23) : i23 + %3 = llvm.mul %arg0, %0 : i23 + %4 = llvm.lshr %3, %1 : i23 + %5 = llvm.shl %4, %2 : i23 + llvm.return %5 : i23 + } + llvm.func @test12(%arg0: i47) -> i47 { + %0 = llvm.mlir.constant(8 : i47) : i47 + %1 = llvm.ashr %arg0, %0 : i47 + %2 = llvm.shl %1, %0 : i47 + llvm.return %2 : i47 + } + llvm.func @test12_splat_vec(%arg0: vector<2xi47>) -> vector<2xi47> { + %0 = llvm.mlir.constant(8 : i47) : i47 + %1 = llvm.mlir.constant(dense<8> : vector<2xi47>) : vector<2xi47> + %2 = llvm.ashr %arg0, %1 : vector<2xi47> + %3 = llvm.shl %2, %1 : vector<2xi47> + llvm.return %3 : vector<2xi47> + } + llvm.func @test13(%arg0: i18) -> i18 { + %0 = llvm.mlir.constant(3 : i18) : i18 + %1 = llvm.mlir.constant(8 : i18) : i18 + %2 = llvm.mlir.constant(9 : i18) : i18 + %3 = llvm.mul %arg0, %0 : i18 + %4 = llvm.ashr %3, %1 : i18 + %5 = llvm.shl %4, %2 : i18 + llvm.return %5 : i18 + } + llvm.func @test14(%arg0: i35) -> i35 { + %0 = llvm.mlir.constant(4 : i35) : i35 + %1 = llvm.mlir.constant(1234 : i35) : i35 + %2 = llvm.lshr %arg0, %0 : i35 + %3 = llvm.or %2, %1 : i35 + %4 = llvm.shl %3, %0 : i35 + llvm.return %4 : i35 + } + llvm.func @test14a(%arg0: i79) -> i79 { + %0 = llvm.mlir.constant(4 : i79) : i79 + %1 = llvm.mlir.constant(1234 : i79) : i79 + %2 = llvm.shl %arg0, %0 : i79 + %3 = llvm.and %2, %1 : i79 + %4 = llvm.lshr %3, %0 : i79 + llvm.return %4 : i79 + } + llvm.func @test15(%arg0: i1) -> i45 { + %0 = llvm.mlir.constant(3 : i45) : i45 + %1 = llvm.mlir.constant(1 : i45) : i45 + %2 = llvm.mlir.constant(2 : i45) : i45 + %3 = llvm.select %arg0, %0, %1 : i1, i45 + %4 = llvm.shl %3, %2 : i45 + llvm.return %4 : i45 + } + llvm.func @test15a(%arg0: i1) -> i53 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(64 : i53) : i53 + %3 = llvm.select %arg0, %0, %1 : i1, i8 + %4 = llvm.zext %3 : i8 to i53 + %5 = llvm.shl %2, %4 : i53 + llvm.return %5 : i53 + } + llvm.func @test16(%arg0: i84) -> i1 { + %0 = llvm.mlir.constant(4 : i84) : i84 + %1 = llvm.mlir.constant(1 : i84) : i84 + %2 = llvm.mlir.constant(0 : i84) : i84 + %3 = llvm.ashr %arg0, %0 : i84 + %4 = llvm.and %3, %1 : i84 + %5 = llvm.icmp "ne" %4, %2 : i84 + llvm.return %5 : i1 + } + llvm.func @test16vec(%arg0: vector<2xi84>) -> vector<2xi1> { + %0 = llvm.mlir.constant(4 : i84) : i84 + %1 = llvm.mlir.constant(dense<4> : vector<2xi84>) : vector<2xi84> + %2 = llvm.mlir.constant(1 : i84) : i84 + %3 = llvm.mlir.constant(dense<1> : vector<2xi84>) : vector<2xi84> + %4 = llvm.mlir.constant(0 : i84) : i84 + %5 = llvm.mlir.constant(dense<0> : vector<2xi84>) : vector<2xi84> + %6 = llvm.ashr %arg0, %1 : vector<2xi84> + %7 = llvm.and %6, %3 : vector<2xi84> + %8 = llvm.icmp "ne" %7, %5 : vector<2xi84> + llvm.return %8 : vector<2xi1> + } + llvm.func @test16vec_nonuniform(%arg0: vector<2xi84>) -> vector<2xi1> { + %0 = llvm.mlir.constant(2 : i84) : i84 + %1 = llvm.mlir.constant(4 : i84) : i84 + %2 = llvm.mlir.constant(dense<[4, 2]> : vector<2xi84>) : vector<2xi84> + %3 = llvm.mlir.constant(1 : i84) : i84 + %4 = llvm.mlir.constant(dense<1> : vector<2xi84>) : vector<2xi84> + %5 = llvm.mlir.constant(0 : i84) : i84 + %6 = llvm.mlir.constant(dense<0> : vector<2xi84>) : vector<2xi84> + %7 = llvm.ashr %arg0, %2 : vector<2xi84> + %8 = llvm.and %7, %4 : vector<2xi84> + %9 = llvm.icmp "ne" %8, %6 : vector<2xi84> + llvm.return %9 : vector<2xi1> + } + llvm.func @test16vec_undef(%arg0: vector<2xi84>) -> vector<2xi1> { + %0 = llvm.mlir.undef : i84 + %1 = llvm.mlir.constant(4 : i84) : i84 + %2 = llvm.mlir.undef : vector<2xi84> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi84> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi84> + %7 = llvm.mlir.constant(1 : i84) : i84 + %8 = llvm.mlir.constant(dense<1> : vector<2xi84>) : vector<2xi84> + %9 = llvm.mlir.constant(0 : i84) : i84 + %10 = llvm.mlir.constant(dense<0> : vector<2xi84>) : vector<2xi84> + %11 = llvm.ashr %arg0, %6 : vector<2xi84> + %12 = llvm.and %11, %8 : vector<2xi84> + %13 = llvm.icmp "ne" %12, %10 : vector<2xi84> + llvm.return %13 : vector<2xi1> + } + llvm.func @test17(%arg0: i106) -> i1 { + %0 = llvm.mlir.constant(3 : i106) : i106 + %1 = llvm.mlir.constant(1234 : i106) : i106 + %2 = llvm.lshr %arg0, %0 : i106 + %3 = llvm.icmp "eq" %2, %1 : i106 + llvm.return %3 : i1 + } + llvm.func @test17vec(%arg0: vector<2xi106>) -> vector<2xi1> { + %0 = llvm.mlir.constant(3 : i106) : i106 + %1 = llvm.mlir.constant(dense<3> : vector<2xi106>) : vector<2xi106> + %2 = llvm.mlir.constant(1234 : i106) : i106 + %3 = llvm.mlir.constant(dense<1234> : vector<2xi106>) : vector<2xi106> + %4 = llvm.lshr %arg0, %1 : vector<2xi106> + %5 = llvm.icmp "eq" %4, %3 : vector<2xi106> + llvm.return %5 : vector<2xi1> + } + llvm.func @test18(%arg0: i11) -> i1 { + %0 = llvm.mlir.constant(10 : i11) : i11 + %1 = llvm.mlir.constant(123 : i11) : i11 + %2 = llvm.lshr %arg0, %0 : i11 + %3 = llvm.icmp "eq" %2, %1 : i11 + llvm.return %3 : i1 + } + llvm.func @test19(%arg0: i37) -> i1 { + %0 = llvm.mlir.constant(2 : i37) : i37 + %1 = llvm.mlir.constant(0 : i37) : i37 + %2 = llvm.ashr %arg0, %0 : i37 + %3 = llvm.icmp "eq" %2, %1 : i37 + llvm.return %3 : i1 + } + llvm.func @test19vec(%arg0: vector<2xi37>) -> vector<2xi1> { + %0 = llvm.mlir.constant(2 : i37) : i37 + %1 = llvm.mlir.constant(dense<2> : vector<2xi37>) : vector<2xi37> + %2 = llvm.mlir.constant(0 : i37) : i37 + %3 = llvm.mlir.constant(dense<0> : vector<2xi37>) : vector<2xi37> + %4 = llvm.ashr %arg0, %1 : vector<2xi37> + %5 = llvm.icmp "eq" %4, %3 : vector<2xi37> + llvm.return %5 : vector<2xi1> + } + llvm.func @test19a(%arg0: i39) -> i1 { + %0 = llvm.mlir.constant(2 : i39) : i39 + %1 = llvm.mlir.constant(-1 : i39) : i39 + %2 = llvm.ashr %arg0, %0 : i39 + %3 = llvm.icmp "eq" %2, %1 : i39 + llvm.return %3 : i1 + } + llvm.func @test19a_vec(%arg0: vector<2xi39>) -> vector<2xi1> { + %0 = llvm.mlir.constant(2 : i39) : i39 + %1 = llvm.mlir.constant(dense<2> : vector<2xi39>) : vector<2xi39> + %2 = llvm.mlir.constant(-1 : i39) : i39 + %3 = llvm.mlir.constant(dense<-1> : vector<2xi39>) : vector<2xi39> + %4 = llvm.ashr %arg0, %1 : vector<2xi39> + %5 = llvm.icmp "eq" %4, %3 : vector<2xi39> + llvm.return %5 : vector<2xi1> + } + llvm.func @test20(%arg0: i13) -> i1 { + %0 = llvm.mlir.constant(12 : i13) : i13 + %1 = llvm.mlir.constant(123 : i13) : i13 + %2 = llvm.ashr %arg0, %0 : i13 + %3 = llvm.icmp "eq" %2, %1 : i13 + llvm.return %3 : i1 + } + llvm.func @test21(%arg0: i12) -> i1 { + %0 = llvm.mlir.constant(6 : i12) : i12 + %1 = llvm.mlir.constant(-128 : i12) : i12 + %2 = llvm.shl %arg0, %0 : i12 + %3 = llvm.icmp "eq" %2, %1 : i12 + llvm.return %3 : i1 + } + llvm.func @test22(%arg0: i14) -> i1 { + %0 = llvm.mlir.constant(7 : i14) : i14 + %1 = llvm.mlir.constant(0 : i14) : i14 + %2 = llvm.shl %arg0, %0 : i14 + %3 = llvm.icmp "eq" %2, %1 : i14 + llvm.return %3 : i1 + } + llvm.func @test23(%arg0: i44) -> i11 { + %0 = llvm.mlir.constant(33 : i44) : i44 + %1 = llvm.shl %arg0, %0 : i44 + %2 = llvm.ashr %1, %0 : i44 + %3 = llvm.trunc %2 : i44 to i11 + llvm.return %3 : i11 + } + llvm.func @shl_lshr_eq_amt_multi_use(%arg0: i44) -> i44 { + %0 = llvm.mlir.constant(33 : i44) : i44 + %1 = llvm.shl %arg0, %0 : i44 + %2 = llvm.lshr %1, %0 : i44 + %3 = llvm.add %1, %2 : i44 + llvm.return %3 : i44 + } + llvm.func @shl_lshr_eq_amt_multi_use_splat_vec(%arg0: vector<2xi44>) -> vector<2xi44> { + %0 = llvm.mlir.constant(33 : i44) : i44 + %1 = llvm.mlir.constant(dense<33> : vector<2xi44>) : vector<2xi44> + %2 = llvm.shl %arg0, %1 : vector<2xi44> + %3 = llvm.lshr %2, %1 : vector<2xi44> + %4 = llvm.add %2, %3 : vector<2xi44> + llvm.return %4 : vector<2xi44> + } + llvm.func @lshr_shl_eq_amt_multi_use(%arg0: i43) -> i43 { + %0 = llvm.mlir.constant(23 : i43) : i43 + %1 = llvm.lshr %arg0, %0 : i43 + %2 = llvm.shl %1, %0 : i43 + %3 = llvm.mul %1, %2 : i43 + llvm.return %3 : i43 + } + llvm.func @lshr_shl_eq_amt_multi_use_splat_vec(%arg0: vector<2xi43>) -> vector<2xi43> { + %0 = llvm.mlir.constant(23 : i43) : i43 + %1 = llvm.mlir.constant(dense<23> : vector<2xi43>) : vector<2xi43> + %2 = llvm.lshr %arg0, %1 : vector<2xi43> + %3 = llvm.shl %2, %1 : vector<2xi43> + %4 = llvm.mul %2, %3 : vector<2xi43> + llvm.return %4 : vector<2xi43> + } + llvm.func @test25(%arg0: i37, %arg1: i37) -> i37 { + %0 = llvm.mlir.constant(17 : i37) : i37 + %1 = llvm.lshr %arg1, %0 : i37 + %2 = llvm.lshr %arg0, %0 : i37 + %3 = llvm.add %2, %1 : i37 + %4 = llvm.shl %3, %0 : i37 + llvm.return %4 : i37 + } + llvm.func @test26(%arg0: i40) -> i40 { + %0 = llvm.mlir.constant(1 : i40) : i40 + %1 = llvm.lshr %arg0, %0 : i40 + %2 = llvm.bitcast %1 : i40 to i40 + %3 = llvm.shl %2, %0 : i40 + llvm.return %3 : i40 + } + llvm.func @ossfuzz_9880(%arg0: i177) -> i177 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i177) : i177 + %2 = llvm.mlir.constant(-1 : i177) : i177 + %3 = llvm.alloca %0 x i177 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i177 + %5 = llvm.or %1, %2 : i177 + %6 = llvm.udiv %4, %5 : i177 + %7 = llvm.add %6, %5 : i177 + %8 = llvm.add %5, %7 : i177 + %9 = llvm.mul %6, %8 : i177 + %10 = llvm.shl %4, %9 : i177 + %11 = llvm.sub %10, %6 : i177 + %12 = llvm.udiv %11, %9 : i177 + llvm.return %12 : i177 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-shl-trunc.ll.mlir b/test/LLVMDialect/InstCombine/apint-shl-trunc.ll.mlir index 9ba66e820..80b71ac95 100644 --- a/test/LLVMDialect/InstCombine/apint-shl-trunc.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-shl-trunc.ll.mlir @@ -1,21 +1,17 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i39, %arg1: i39): // no predecessors - %0 = "llvm.lshr"(%arg0, %arg1) : (i39, i39) -> i39 - %1 = "llvm.trunc"(%0) : (i39) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i799, %arg1: i799): // no predecessors - %0 = "llvm.lshr"(%arg0, %arg1) : (i799, i799) -> i799 - %1 = "llvm.trunc"(%0) : (i799) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi39>, %arg1: vector<2xi39>): // no predecessors - %0 = "llvm.lshr"(%arg0, %arg1) : (vector<2xi39>, vector<2xi39>) -> vector<2xi39> - %1 = "llvm.trunc"(%0) : (vector<2xi39>) -> vector<2xi1> - "llvm.return"(%1) : (vector<2xi1>) -> () - }) {linkage = 10 : i64, sym_name = "test0vec", type = !llvm.func (vector<2xi39>, vector<2xi39>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test0(%arg0: i39, %arg1: i39) -> i1 { + %0 = llvm.lshr %arg0, %arg1 : i39 + %1 = llvm.trunc %0 : i39 to i1 + llvm.return %1 : i1 + } + llvm.func @test1(%arg0: i799, %arg1: i799) -> i1 { + %0 = llvm.lshr %arg0, %arg1 : i799 + %1 = llvm.trunc %0 : i799 to i1 + llvm.return %1 : i1 + } + llvm.func @test0vec(%arg0: vector<2xi39>, %arg1: vector<2xi39>) -> vector<2xi1> { + %0 = llvm.lshr %arg0, %arg1 : vector<2xi39> + %1 = llvm.trunc %0 : vector<2xi39> to vector<2xi1> + llvm.return %1 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/apint-sub.ll.mlir b/test/LLVMDialect/InstCombine/apint-sub.ll.mlir index 05d618b74..21e631539 100644 --- a/test/LLVMDialect/InstCombine/apint-sub.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-sub.ll.mlir @@ -1,134 +1,114 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i23): // no predecessors - %0 = "llvm.sub"(%arg0, %arg0) : (i23, i23) -> i23 - "llvm.return"(%0) : (i23) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i47): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i47} : () -> i47 - %1 = "llvm.sub"(%arg0, %0) : (i47, i47) -> i47 - "llvm.return"(%1) : (i47) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i97): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i97} : () -> i97 - %1 = "llvm.sub"(%0, %arg0) : (i97, i97) -> i97 - %2 = "llvm.sub"(%0, %1) : (i97, i97) -> i97 - "llvm.return"(%2) : (i97) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i108, %arg1: i108): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i108} : () -> i108 - %1 = "llvm.sub"(%0, %arg0) : (i108, i108) -> i108 - %2 = "llvm.sub"(%arg1, %1) : (i108, i108) -> i108 - "llvm.return"(%2) : (i108) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i19, %arg1: i19, %arg2: i19): // no predecessors - %0 = "llvm.sub"(%arg1, %arg2) : (i19, i19) -> i19 - %1 = "llvm.sub"(%arg0, %0) : (i19, i19) -> i19 - "llvm.return"(%1) : (i19) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i57, %arg1: i57): // no predecessors - %0 = "llvm.and"(%arg0, %arg1) : (i57, i57) -> i57 - %1 = "llvm.sub"(%arg0, %0) : (i57, i57) -> i57 - "llvm.return"(%1) : (i57) -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i77): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i77} : () -> i77 - %1 = "llvm.sub"(%0, %arg0) : (i77, i77) -> i77 - "llvm.return"(%1) : (i77) -> () - }) {linkage = 10 : i64, sym_name = "test7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i27): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i27} : () -> i27 - %1 = "llvm.mul"(%0, %arg0) : (i27, i27) -> i27 - %2 = "llvm.sub"(%1, %arg0) : (i27, i27) -> i27 - "llvm.return"(%2) : (i27) -> () - }) {linkage = 10 : i64, sym_name = "test8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i42): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i42} : () -> i42 - %1 = "llvm.mul"(%0, %arg0) : (i42, i42) -> i42 - %2 = "llvm.sub"(%arg0, %1) : (i42, i42) -> i42 - "llvm.return"(%2) : (i42) -> () - }) {linkage = 10 : i64, sym_name = "test9", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i9, %arg1: i9): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i9} : () -> i9 - %1 = "llvm.sub"(%arg0, %arg1) : (i9, i9) -> i9 - %2 = "llvm.icmp"(%1, %0) {predicate = 1 : i64} : (i9, i9) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i43): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i43} : () -> i43 - %1 = "llvm.mlir.constant"() {value = 42 : i43} : () -> i43 - %2 = "llvm.ashr"(%arg0, %1) : (i43, i43) -> i43 - %3 = "llvm.sub"(%0, %2) : (i43, i43) -> i43 - "llvm.return"(%3) : (i43) -> () - }) {linkage = 10 : i64, sym_name = "test12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i79): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i79} : () -> i79 - %1 = "llvm.mlir.constant"() {value = 78 : i79} : () -> i79 - %2 = "llvm.lshr"(%arg0, %1) : (i79, i79) -> i79 - %3 = "llvm.sub"(%0, %2) : (i79, i79) -> i79 - "llvm.return"(%3) : (i79) -> () - }) {linkage = 10 : i64, sym_name = "test13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1024): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i1024} : () -> i1024 - %1 = "llvm.mlir.constant"() {value = 1023 : i1024} : () -> i1024 - %2 = "llvm.lshr"(%arg0, %1) : (i1024, i1024) -> i1024 - %3 = "llvm.bitcast"(%2) : (i1024) -> i1024 - %4 = "llvm.sub"(%0, %3) : (i1024, i1024) -> i1024 - "llvm.return"(%4) : (i1024) -> () - }) {linkage = 10 : i64, sym_name = "test14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i51): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i51} : () -> i51 - %1 = "llvm.mlir.constant"() {value = 1123 : i51} : () -> i51 - %2 = "llvm.sdiv"(%arg0, %1) : (i51, i51) -> i51 - %3 = "llvm.sub"(%0, %2) : (i51, i51) -> i51 - "llvm.return"(%3) : (i51) -> () - }) {linkage = 10 : i64, sym_name = "test16", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i25): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1234 : i25} : () -> i25 - %1 = "llvm.mlir.constant"() {value = 0 : i25} : () -> i25 - %2 = "llvm.sub"(%1, %arg0) : (i25, i25) -> i25 - %3 = "llvm.sdiv"(%2, %0) : (i25, i25) -> i25 - "llvm.return"(%3) : (i25) -> () - }) {linkage = 10 : i64, sym_name = "test17", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i128): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i128} : () -> i128 - %1 = "llvm.shl"(%arg0, %0) : (i128, i128) -> i128 - %2 = "llvm.shl"(%arg0, %0) : (i128, i128) -> i128 - %3 = "llvm.sub"(%1, %2) : (i128, i128) -> i128 - "llvm.return"(%3) : (i128) -> () - }) {linkage = 10 : i64, sym_name = "test18", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i39, %arg1: i39): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i39, i39) -> i39 - %1 = "llvm.add"(%0, %arg1) : (i39, i39) -> i39 - "llvm.return"(%1) : (i39) -> () - }) {linkage = 10 : i64, sym_name = "test19", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i33, %arg1: i33): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i33, i33) -> i33 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 1 : i64} : (i33, i33) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test20", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i256, %arg1: i256): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i256, i256) -> i256 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 1 : i64} : (i256, i256) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test21", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i23) -> i23 { + %0 = llvm.sub %arg0, %arg0 : i23 + llvm.return %0 : i23 + } + llvm.func @test2(%arg0: i47) -> i47 { + %0 = llvm.mlir.constant(0 : i47) : i47 + %1 = llvm.sub %arg0, %0 : i47 + llvm.return %1 : i47 + } + llvm.func @test3(%arg0: i97) -> i97 { + %0 = llvm.mlir.constant(0 : i97) : i97 + %1 = llvm.sub %0, %arg0 : i97 + %2 = llvm.sub %0, %1 : i97 + llvm.return %2 : i97 + } + llvm.func @test4(%arg0: i108, %arg1: i108) -> i108 { + %0 = llvm.mlir.constant(0 : i108) : i108 + %1 = llvm.sub %0, %arg0 : i108 + %2 = llvm.sub %arg1, %1 : i108 + llvm.return %2 : i108 + } + llvm.func @test5(%arg0: i19, %arg1: i19, %arg2: i19) -> i19 { + %0 = llvm.sub %arg1, %arg2 : i19 + %1 = llvm.sub %arg0, %0 : i19 + llvm.return %1 : i19 + } + llvm.func @test6(%arg0: i57, %arg1: i57) -> i57 { + %0 = llvm.and %arg0, %arg1 : i57 + %1 = llvm.sub %arg0, %0 : i57 + llvm.return %1 : i57 + } + llvm.func @test7(%arg0: i77) -> i77 { + %0 = llvm.mlir.constant(-1 : i77) : i77 + %1 = llvm.sub %0, %arg0 : i77 + llvm.return %1 : i77 + } + llvm.func @test8(%arg0: i27) -> i27 { + %0 = llvm.mlir.constant(9 : i27) : i27 + %1 = llvm.mul %0, %arg0 : i27 + %2 = llvm.sub %1, %arg0 : i27 + llvm.return %2 : i27 + } + llvm.func @test9(%arg0: i42) -> i42 { + %0 = llvm.mlir.constant(3 : i42) : i42 + %1 = llvm.mul %0, %arg0 : i42 + %2 = llvm.sub %arg0, %1 : i42 + llvm.return %2 : i42 + } + llvm.func @test11(%arg0: i9, %arg1: i9) -> i1 { + %0 = llvm.mlir.constant(0 : i9) : i9 + %1 = llvm.sub %arg0, %arg1 : i9 + %2 = llvm.icmp "ne" %1, %0 : i9 + llvm.return %2 : i1 + } + llvm.func @test12(%arg0: i43) -> i43 { + %0 = llvm.mlir.constant(42 : i43) : i43 + %1 = llvm.mlir.constant(0 : i43) : i43 + %2 = llvm.ashr %arg0, %0 : i43 + %3 = llvm.sub %1, %2 : i43 + llvm.return %3 : i43 + } + llvm.func @test13(%arg0: i79) -> i79 { + %0 = llvm.mlir.constant(78 : i79) : i79 + %1 = llvm.mlir.constant(0 : i79) : i79 + %2 = llvm.lshr %arg0, %0 : i79 + %3 = llvm.sub %1, %2 : i79 + llvm.return %3 : i79 + } + llvm.func @test14(%arg0: i1024) -> i1024 { + %0 = llvm.mlir.constant(1023 : i1024) : i1024 + %1 = llvm.mlir.constant(0 : i1024) : i1024 + %2 = llvm.lshr %arg0, %0 : i1024 + %3 = llvm.bitcast %2 : i1024 to i1024 + %4 = llvm.sub %1, %3 : i1024 + llvm.return %4 : i1024 + } + llvm.func @test16(%arg0: i51) -> i51 { + %0 = llvm.mlir.constant(1123 : i51) : i51 + %1 = llvm.mlir.constant(0 : i51) : i51 + %2 = llvm.sdiv %arg0, %0 : i51 + %3 = llvm.sub %1, %2 : i51 + llvm.return %3 : i51 + } + llvm.func @test17(%arg0: i25) -> i25 { + %0 = llvm.mlir.constant(0 : i25) : i25 + %1 = llvm.mlir.constant(1234 : i25) : i25 + %2 = llvm.sub %0, %arg0 : i25 + %3 = llvm.sdiv %2, %1 : i25 + llvm.return %3 : i25 + } + llvm.func @test18(%arg0: i128) -> i128 { + %0 = llvm.mlir.constant(2 : i128) : i128 + %1 = llvm.shl %arg0, %0 : i128 + %2 = llvm.shl %arg0, %0 : i128 + %3 = llvm.sub %1, %2 : i128 + llvm.return %3 : i128 + } + llvm.func @test19(%arg0: i39, %arg1: i39) -> i39 { + %0 = llvm.sub %arg0, %arg1 : i39 + %1 = llvm.add %0, %arg1 : i39 + llvm.return %1 : i39 + } + llvm.func @test20(%arg0: i33, %arg1: i33) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i33 + %1 = llvm.icmp "ne" %0, %arg0 : i33 + llvm.return %1 : i1 + } + llvm.func @test21(%arg0: i256, %arg1: i256) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i256 + %1 = llvm.icmp "ne" %0, %arg0 : i256 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-xor1.ll.mlir b/test/LLVMDialect/InstCombine/apint-xor1.ll.mlir index 5455d2b64..88071413e 100644 --- a/test/LLVMDialect/InstCombine/apint-xor1.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-xor1.ll.mlir @@ -1,52 +1,44 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i47, %arg1: i47): // no predecessors - %0 = "llvm.mlir.constant"() {value = 70368744177661 : i47} : () -> i47 - %1 = "llvm.mlir.constant"() {value = -70368744177664 : i47} : () -> i47 - %2 = "llvm.and"(%arg0, %1) : (i47, i47) -> i47 - %3 = "llvm.and"(%arg1, %0) : (i47, i47) -> i47 - %4 = "llvm.xor"(%2, %3) : (i47, i47) -> i47 - "llvm.return"(%4) : (i47) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i15): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i15} : () -> i15 - %1 = "llvm.xor"(%arg0, %0) : (i15, i15) -> i15 - "llvm.return"(%1) : (i15) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i23): // no predecessors - %0 = "llvm.xor"(%arg0, %arg0) : (i23, i23) -> i23 - "llvm.return"(%0) : (i23) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i37): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i37} : () -> i37 - %1 = "llvm.xor"(%0, %arg0) : (i37, i37) -> i37 - %2 = "llvm.xor"(%arg0, %1) : (i37, i37) -> i37 - "llvm.return"(%2) : (i37) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i7): // no predecessors - %0 = "llvm.mlir.constant"() {value = 23 : i7} : () -> i7 - %1 = "llvm.or"(%arg0, %0) : (i7, i7) -> i7 - %2 = "llvm.xor"(%1, %0) : (i7, i7) -> i7 - "llvm.return"(%2) : (i7) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i7): // no predecessors - %0 = "llvm.mlir.constant"() {value = 23 : i7} : () -> i7 - %1 = "llvm.xor"(%arg0, %0) : (i7, i7) -> i7 - %2 = "llvm.xor"(%1, %0) : (i7, i7) -> i7 - "llvm.return"(%2) : (i7) -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i47): // no predecessors - %0 = "llvm.mlir.constant"() {value = 703687463 : i47} : () -> i47 - %1 = "llvm.mlir.constant"() {value = 70368744177663 : i47} : () -> i47 - %2 = "llvm.or"(%arg0, %1) : (i47, i47) -> i47 - %3 = "llvm.xor"(%2, %0) : (i47, i47) -> i47 - "llvm.return"(%3) : (i47) -> () - }) {linkage = 10 : i64, sym_name = "test7", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i47, %arg1: i47) -> i47 { + %0 = llvm.mlir.constant(-70368744177664 : i47) : i47 + %1 = llvm.mlir.constant(70368744177661 : i47) : i47 + %2 = llvm.and %arg0, %0 : i47 + %3 = llvm.and %arg1, %1 : i47 + %4 = llvm.xor %2, %3 : i47 + llvm.return %4 : i47 + } + llvm.func @test2(%arg0: i15) -> i15 { + %0 = llvm.mlir.constant(0 : i15) : i15 + %1 = llvm.xor %arg0, %0 : i15 + llvm.return %1 : i15 + } + llvm.func @test3(%arg0: i23) -> i23 { + %0 = llvm.xor %arg0, %arg0 : i23 + llvm.return %0 : i23 + } + llvm.func @test4(%arg0: i37) -> i37 { + %0 = llvm.mlir.constant(-1 : i37) : i37 + %1 = llvm.xor %0, %arg0 : i37 + %2 = llvm.xor %arg0, %1 : i37 + llvm.return %2 : i37 + } + llvm.func @test5(%arg0: i7) -> i7 { + %0 = llvm.mlir.constant(23 : i7) : i7 + %1 = llvm.or %arg0, %0 : i7 + %2 = llvm.xor %1, %0 : i7 + llvm.return %2 : i7 + } + llvm.func @test6(%arg0: i7) -> i7 { + %0 = llvm.mlir.constant(23 : i7) : i7 + %1 = llvm.xor %arg0, %0 : i7 + %2 = llvm.xor %1, %0 : i7 + llvm.return %2 : i7 + } + llvm.func @test7(%arg0: i47) -> i47 { + %0 = llvm.mlir.constant(70368744177663 : i47) : i47 + %1 = llvm.mlir.constant(703687463 : i47) : i47 + %2 = llvm.or %arg0, %0 : i47 + %3 = llvm.xor %2, %1 : i47 + llvm.return %3 : i47 + } +} diff --git a/test/LLVMDialect/InstCombine/apint-xor2.ll.mlir b/test/LLVMDialect/InstCombine/apint-xor2.ll.mlir index 6c1d040b9..7d9373464 100644 --- a/test/LLVMDialect/InstCombine/apint-xor2.ll.mlir +++ b/test/LLVMDialect/InstCombine/apint-xor2.ll.mlir @@ -1,52 +1,44 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i447, %arg1: i447): // no predecessors - %0 = "llvm.mlir.constant"() {value = 70368744177663 : i447} : () -> i447 - %1 = "llvm.mlir.constant"() {value = 70368744177664 : i447} : () -> i447 - %2 = "llvm.and"(%arg0, %1) : (i447, i447) -> i447 - %3 = "llvm.and"(%arg1, %0) : (i447, i447) -> i447 - %4 = "llvm.xor"(%2, %3) : (i447, i447) -> i447 - "llvm.return"(%4) : (i447) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1005): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i1005} : () -> i1005 - %1 = "llvm.xor"(%arg0, %0) : (i1005, i1005) -> i1005 - "llvm.return"(%1) : (i1005) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i123): // no predecessors - %0 = "llvm.xor"(%arg0, %arg0) : (i123, i123) -> i123 - "llvm.return"(%0) : (i123) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i737): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i737} : () -> i737 - %1 = "llvm.xor"(%0, %arg0) : (i737, i737) -> i737 - %2 = "llvm.xor"(%arg0, %1) : (i737, i737) -> i737 - "llvm.return"(%2) : (i737) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i700): // no predecessors - %0 = "llvm.mlir.constant"() {value = 288230376151711743 : i700} : () -> i700 - %1 = "llvm.or"(%arg0, %0) : (i700, i700) -> i700 - %2 = "llvm.xor"(%1, %0) : (i700, i700) -> i700 - "llvm.return"(%2) : (i700) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i77): // no predecessors - %0 = "llvm.mlir.constant"() {value = 23 : i77} : () -> i77 - %1 = "llvm.xor"(%arg0, %0) : (i77, i77) -> i77 - %2 = "llvm.xor"(%1, %0) : (i77, i77) -> i77 - "llvm.return"(%2) : (i77) -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1023): // no predecessors - %0 = "llvm.mlir.constant"() {value = 703687463 : i1023} : () -> i1023 - %1 = "llvm.mlir.constant"() {value = 70368744177663 : i1023} : () -> i1023 - %2 = "llvm.or"(%arg0, %1) : (i1023, i1023) -> i1023 - %3 = "llvm.xor"(%2, %0) : (i1023, i1023) -> i1023 - "llvm.return"(%3) : (i1023) -> () - }) {linkage = 10 : i64, sym_name = "test7", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i447, %arg1: i447) -> i447 { + %0 = llvm.mlir.constant(70368744177664 : i447) : i447 + %1 = llvm.mlir.constant(70368744177663 : i447) : i447 + %2 = llvm.and %arg0, %0 : i447 + %3 = llvm.and %arg1, %1 : i447 + %4 = llvm.xor %2, %3 : i447 + llvm.return %4 : i447 + } + llvm.func @test2(%arg0: i1005) -> i1005 { + %0 = llvm.mlir.constant(0 : i1005) : i1005 + %1 = llvm.xor %arg0, %0 : i1005 + llvm.return %1 : i1005 + } + llvm.func @test3(%arg0: i123) -> i123 { + %0 = llvm.xor %arg0, %arg0 : i123 + llvm.return %0 : i123 + } + llvm.func @test4(%arg0: i737) -> i737 { + %0 = llvm.mlir.constant(-1 : i737) : i737 + %1 = llvm.xor %0, %arg0 : i737 + %2 = llvm.xor %arg0, %1 : i737 + llvm.return %2 : i737 + } + llvm.func @test5(%arg0: i700) -> i700 { + %0 = llvm.mlir.constant(288230376151711743 : i700) : i700 + %1 = llvm.or %arg0, %0 : i700 + %2 = llvm.xor %1, %0 : i700 + llvm.return %2 : i700 + } + llvm.func @test6(%arg0: i77) -> i77 { + %0 = llvm.mlir.constant(23 : i77) : i77 + %1 = llvm.xor %arg0, %0 : i77 + %2 = llvm.xor %1, %0 : i77 + llvm.return %2 : i77 + } + llvm.func @test7(%arg0: i1023) -> i1023 { + %0 = llvm.mlir.constant(70368744177663 : i1023) : i1023 + %1 = llvm.mlir.constant(703687463 : i1023) : i1023 + %2 = llvm.or %arg0, %0 : i1023 + %3 = llvm.xor %2, %1 : i1023 + llvm.return %3 : i1023 + } +} diff --git a/test/LLVMDialect/InstCombine/array.ll.mlir b/test/LLVMDialect/InstCombine/array.ll.mlir new file mode 100644 index 000000000..5677f391c --- /dev/null +++ b/test/LLVMDialect/InstCombine/array.ll.mlir @@ -0,0 +1,132 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.add %arg1, %0 overflow : i32 + %2 = llvm.sext %1 : i32 to i64 + %3 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %arg2, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test_add_res_moreoneuse(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.add %arg1, %0 overflow : i32 + %2 = llvm.sext %1 : i32 to i64 + %3 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %arg2, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %1 : i32 + } + llvm.func @test_addop_nonsw_flag(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.add %arg1, %0 : i32 + %2 = llvm.sext %1 : i32 to i64 + %3 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %arg2, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test_add_op2_not_constant(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) { + %0 = llvm.add %arg1, %arg2 : i32 + %1 = llvm.sext %0 : i32 to i64 + %2 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %arg2, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test_zext_nneg(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.add %arg1, %0 overflow : i32 + %2 = llvm.zext %1 : i32 to i64 + %3 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %arg2, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test_zext_missing_nneg(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.add %arg1, %0 overflow : i32 + %2 = llvm.zext %1 : i32 to i64 + %3 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %arg2, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @gep_inbounds_add_nsw_nonneg(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.icmp "sgt" %arg1, %0 : i64 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.icmp "sgt" %arg2, %0 : i64 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg1, %arg2 overflow : i64 + %4 = llvm.getelementptr inbounds %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @gep_inbounds_add_nsw_not_nonneg1(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.icmp "sgt" %arg1, %0 : i64 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg1, %arg2 overflow : i64 + %3 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %3 : !llvm.ptr + } + llvm.func @gep_inbounds_add_nsw_not_nonneg2(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.icmp "sgt" %arg2, %0 : i64 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg1, %arg2 overflow : i64 + %3 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %3 : !llvm.ptr + } + llvm.func @gep_not_inbounds_add_nsw_nonneg(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.icmp "sgt" %arg1, %0 : i64 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.icmp "sgt" %arg2, %0 : i64 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg1, %arg2 overflow : i64 + %4 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @gep_inbounds_add_not_nsw_nonneg(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.icmp "sgt" %arg1, %0 : i64 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.icmp "sgt" %arg2, %0 : i64 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg1, %arg2 : i64 + %4 = llvm.getelementptr inbounds %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @gep_inbounds_sext_add_nonneg(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.icmp "sgt" %arg1, %0 : i32 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg1, %1 overflow : i32 + %4 = llvm.sext %3 : i32 to i64 + %5 = llvm.getelementptr inbounds %arg0[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %5 : !llvm.ptr + } + llvm.func @gep_inbounds_sext_add_not_nonneg_1(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-10 : i32) : i32 + %2 = llvm.icmp "sgt" %arg1, %0 : i32 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg1, %1 overflow : i32 + %4 = llvm.sext %3 : i32 to i64 + %5 = llvm.getelementptr inbounds %arg0[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %5 : !llvm.ptr + } + llvm.func @gep_inbounds_sext_add_not_nonneg_2(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.add %arg1, %0 overflow : i32 + %2 = llvm.sext %1 : i32 to i64 + %3 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %3 : !llvm.ptr + } + llvm.func @gep_not_inbounds_sext_add_nonneg(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.icmp "sgt" %arg1, %0 : i32 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg1, %1 overflow : i32 + %4 = llvm.sext %3 : i32 to i64 + %5 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %5 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/ashr-demand.ll.mlir b/test/LLVMDialect/InstCombine/ashr-demand.ll.mlir index 55a849498..eb866eab8 100644 --- a/test/LLVMDialect/InstCombine/ashr-demand.ll.mlir +++ b/test/LLVMDialect/InstCombine/ashr-demand.ll.mlir @@ -1,39 +1,34 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.srem"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.and"(%3, %1) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "srem2_ashr_mask", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %3 = "llvm.srem"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.ashr"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.and"(%4, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "srem8_ashr_mask", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<31> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.mlir.constant"() {value = dense<2> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.srem"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.ashr"(%2, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.and"(%3, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%4) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "srem2_ashr_mask_vector", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<2> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.srem"(%arg0, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.ashr"(%1, %arg1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.and"(%2, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%3) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "srem2_ashr_mask_vector_nonconstant", type = !llvm.func (vector<2xi32>, vector<2xi32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @srem2_ashr_mask(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.ashr %2, %1 : i32 + %4 = llvm.and %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @srem8_ashr_mask(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.srem %arg0, %0 : i32 + %4 = llvm.ashr %3, %1 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @srem2_ashr_mask_vector(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %2 = llvm.srem %arg0, %0 : vector<2xi32> + %3 = llvm.ashr %2, %1 : vector<2xi32> + %4 = llvm.and %3, %0 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @srem2_ashr_mask_vector_nonconstant(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.srem %arg0, %0 : vector<2xi32> + %2 = llvm.ashr %1, %arg1 : vector<2xi32> + %3 = llvm.and %2, %0 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/ashr-icmp-minmax-idiom-break.ll.mlir b/test/LLVMDialect/InstCombine/ashr-icmp-minmax-idiom-break.ll.mlir new file mode 100644 index 000000000..6067e2d53 --- /dev/null +++ b/test/LLVMDialect/InstCombine/ashr-icmp-minmax-idiom-break.ll.mlir @@ -0,0 +1,13 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @dont_break_minmax_i64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(348731 : i64) : i64 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mul %arg0, %arg1 overflow : i64 + %4 = llvm.ashr %3, %0 : i64 + %5 = llvm.icmp "sgt" %4, %1 : i64 + %6 = llvm.icmp "ult" %5, %2 : i1 + %7 = llvm.select %6, %4, %1 : i1, i64 + llvm.return %7 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/ashr-lshr.ll.mlir b/test/LLVMDialect/InstCombine/ashr-lshr.ll.mlir new file mode 100644 index 000000000..697e9b1f1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/ashr-lshr.ll.mlir @@ -0,0 +1,537 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @ashr_lshr_exact_ashr_only(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg1 : i32 + %4 = llvm.select %1, %2, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_no_exact(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg1 : i32 + %4 = llvm.select %1, %2, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_exact_both(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg1 : i32 + %4 = llvm.select %1, %2, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_exact_lshr_only(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg1 : i32 + %4 = llvm.select %1, %2, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg1 : i32 + %4 = llvm.select %1, %2, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_splat_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %2 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %3 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %4 = llvm.select %1, %2, %3 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @ashr_lshr_splat_vec2(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %2 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %3 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %4 = llvm.select %1, %2, %3 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @ashr_lshr_splat_vec3(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %2 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %3 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %4 = llvm.select %1, %2, %3 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @ashr_lshr_splat_vec4(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %2 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %3 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %4 = llvm.select %1, %2, %3 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @ashr_lshr_nonsplat_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[-1, 1]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %2 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %3 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %4 = llvm.select %1, %2, %3 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @ashr_lshr_nonsplat_vec2(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[2, 4]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %2 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %3 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %4 = llvm.select %1, %2, %3 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @ashr_lshr_nonsplat_vec3(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[5, 6]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %2 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %3 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %4 = llvm.select %1, %2, %3 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @ashr_lshr_nonsplat_vec4(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[8, 7]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %2 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %3 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %4 = llvm.select %1, %2, %3 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @ashr_lshr_cst(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.lshr %arg0, %1 : i32 + %4 = llvm.ashr %arg0, %1 : i32 + %5 = llvm.select %2, %4, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @ashr_lshr_cst2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.lshr %arg0, %1 : i32 + %4 = llvm.ashr %arg0, %1 : i32 + %5 = llvm.select %2, %3, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @ashr_lshr_inv(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg1 : i32 + %4 = llvm.select %1, %3, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_inv2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg1 : i32 + %4 = llvm.select %1, %3, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_inv_splat_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "slt" %arg0, %0 : vector<2xi32> + %2 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %3 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %4 = llvm.select %1, %3, %2 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @ashr_lshr_inv_nonsplat_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[4, 5]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "slt" %arg0, %0 : vector<2xi32> + %2 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %3 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %4 = llvm.select %1, %3, %2 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @ashr_lshr_vec_poison(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.icmp "sgt" %arg0, %6 : vector<2xi32> + %8 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %9 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %10 = llvm.select %7, %8, %9 : vector<2xi1>, vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @ashr_lshr_vec_poison2(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.icmp "slt" %arg0, %6 : vector<2xi32> + %8 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %9 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %10 = llvm.select %7, %9, %8 : vector<2xi1>, vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @ashr_lshr_wrong_cst(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg1 : i32 + %4 = llvm.select %1, %2, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_wrong_cst2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg1 : i32 + %4 = llvm.select %1, %3, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_wrong_cond(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "sge" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg1 : i32 + %4 = llvm.select %1, %2, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_shift_wrong_pred(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sle" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg1 : i32 + %4 = llvm.select %1, %2, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_shift_wrong_pred2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sge" %arg2, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg1 : i32 + %4 = llvm.select %1, %2, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_wrong_operands(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sge" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg1 : i32 + %4 = llvm.select %1, %3, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_no_ashr(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sge" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.xor %arg0, %arg1 : i32 + %4 = llvm.select %1, %2, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_shift_amt_mismatch(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sge" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg2 : i32 + %4 = llvm.select %1, %2, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_shift_base_mismatch(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sge" %arg0, %0 : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.ashr %arg2, %arg1 : i32 + %4 = llvm.select %1, %2, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_no_lshr(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sge" %arg0, %0 : i32 + %2 = llvm.add %arg0, %arg1 : i32 + %3 = llvm.ashr %arg0, %arg1 : i32 + %4 = llvm.select %1, %2, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_vec_wrong_pred(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "sle" %arg0, %1 : vector<2xi32> + %3 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %4 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %5 = llvm.select %2, %3, %4 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @ashr_lshr_inv_vec_wrong_pred(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "sge" %arg0, %1 : vector<2xi32> + %3 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %4 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %5 = llvm.select %2, %4, %3 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @lshr_sub_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg0, %arg1 overflow : i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @lshr_sub_wrong_amount(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(30 : i32) : i32 + %1 = llvm.sub %arg0, %arg1 overflow : i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @lshr_sub(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg0, %arg1 : i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @lshr_sub_nsw_extra_use(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg0, %arg1 overflow : i32 + llvm.store %1, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @lshr_sub_nsw_splat(%arg0: vector<3xi42>, %arg1: vector<3xi42>) -> vector<3xi42> { + %0 = llvm.mlir.constant(41 : i42) : i42 + %1 = llvm.mlir.constant(dense<41> : vector<3xi42>) : vector<3xi42> + %2 = llvm.sub %arg0, %arg1 overflow : vector<3xi42> + %3 = llvm.lshr %2, %1 : vector<3xi42> + llvm.return %3 : vector<3xi42> + } + llvm.func @lshr_sub_nsw_splat_poison(%arg0: vector<3xi42>, %arg1: vector<3xi42>) -> vector<3xi42> { + %0 = llvm.mlir.constant(41 : i42) : i42 + %1 = llvm.mlir.poison : i42 + %2 = llvm.mlir.undef : vector<3xi42> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi42> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi42> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi42> + %9 = llvm.sub %arg0, %arg1 overflow : vector<3xi42> + %10 = llvm.lshr %9, %8 : vector<3xi42> + llvm.return %10 : vector<3xi42> + } + llvm.func @ashr_sub_nsw(%arg0: i17, %arg1: i17) -> i17 { + %0 = llvm.mlir.constant(16 : i17) : i17 + %1 = llvm.sub %arg0, %arg1 overflow : i17 + %2 = llvm.ashr %1, %0 : i17 + llvm.return %2 : i17 + } + llvm.func @ashr_sub_wrong_amount(%arg0: i17, %arg1: i17) -> i17 { + %0 = llvm.mlir.constant(15 : i17) : i17 + %1 = llvm.sub %arg0, %arg1 overflow : i17 + %2 = llvm.ashr %1, %0 : i17 + llvm.return %2 : i17 + } + llvm.func @ashr_sub(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg0, %arg1 : i32 + %2 = llvm.ashr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @ashr_sub_nsw_extra_use(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg0, %arg1 overflow : i32 + llvm.store %1, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %2 = llvm.ashr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @ashr_sub_nsw_splat(%arg0: vector<3xi43>, %arg1: vector<3xi43>) -> vector<3xi43> { + %0 = llvm.mlir.constant(42 : i43) : i43 + %1 = llvm.mlir.constant(dense<42> : vector<3xi43>) : vector<3xi43> + %2 = llvm.sub %arg0, %arg1 overflow : vector<3xi43> + %3 = llvm.ashr %2, %1 : vector<3xi43> + llvm.return %3 : vector<3xi43> + } + llvm.func @ashr_sub_nsw_splat_poison(%arg0: vector<3xi43>, %arg1: vector<3xi43>) -> vector<3xi43> { + %0 = llvm.mlir.constant(42 : i43) : i43 + %1 = llvm.mlir.poison : i43 + %2 = llvm.mlir.undef : vector<3xi43> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi43> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi43> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi43> + %9 = llvm.sub %arg0, %arg1 overflow : vector<3xi43> + %10 = llvm.ashr %9, %8 : vector<3xi43> + llvm.return %10 : vector<3xi43> + } + llvm.func @ashr_known_pos_exact(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.ashr %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @ashr_known_pos_exact_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mul %arg0, %arg0 overflow : vector<2xi8> + %1 = llvm.ashr %0, %arg1 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @lshr_mul_times_3_div_2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_mul_times_3_div_2_exact(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_mul_times_3_div_2_no_flags(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @mul_times_3_div_2_multiuse_lshr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %3 : i32 + } + llvm.func @lshr_mul_times_3_div_2_exact_2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_mul_times_5_div_4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_mul_times_5_div_4_exact(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_mul_times_5_div_4_no_flags(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @mul_times_5_div_4_multiuse_lshr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %3 : i32 + } + llvm.func @lshr_mul_times_5_div_4_exact_2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_mul_times_3_div_2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_mul_times_3_div_2_exact(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_mul_times_3_div_2_no_flags(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_mul_times_3_div_2_no_nsw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @mul_times_3_div_2_multiuse_ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %3 : i32 + } + llvm.func @ashr_mul_times_3_div_2_exact_2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_mul_times_5_div_4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_mul_times_5_div_4_exact(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_mul_times_5_div_4_no_flags(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @mul_times_5_div_4_multiuse_ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %3 : i32 + } + llvm.func @ashr_mul_times_5_div_4_exact_2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @use(i32) +} diff --git a/test/LLVMDialect/InstCombine/ashr-or-mul-abs.ll.mlir b/test/LLVMDialect/InstCombine/ashr-or-mul-abs.ll.mlir new file mode 100644 index 000000000..e394fe5e1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/ashr-or-mul-abs.ll.mlir @@ -0,0 +1,95 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @ashr_or_mul_to_abs(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.or %2, %1 : i32 + %4 = llvm.mul %3, %arg0 overflow : i32 + llvm.return %4 : i32 + } + llvm.func @ashr_or_mul_to_abs2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.or %2, %1 : i32 + %4 = llvm.mul %3, %arg0 : i32 + llvm.return %4 : i32 + } + llvm.func @ashr_or_mul_to_abs3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.sdiv %0, %arg0 : i32 + %4 = llvm.ashr %3, %1 : i32 + %5 = llvm.or %4, %2 : i32 + %6 = llvm.mul %3, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @ashr_or_mul_to_abs_vec(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %2 = llvm.ashr %arg0, %0 : vector<4xi32> + %3 = llvm.or %2, %1 : vector<4xi32> + %4 = llvm.mul %3, %arg0 : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @ashr_or_mul_to_abs_vec2(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %2 = llvm.ashr %arg0, %0 : vector<4xi32> + %3 = llvm.or %2, %1 : vector<4xi32> + %4 = llvm.mul %3, %arg0 overflow : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @ashr_or_mul_to_abs_vec3_poison(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.mlir.undef : vector<4xi32> + %13 = llvm.mlir.constant(0 : i32) : i32 + %14 = llvm.insertelement %11, %12[%13 : i32] : vector<4xi32> + %15 = llvm.mlir.constant(1 : i32) : i32 + %16 = llvm.insertelement %11, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(2 : i32) : i32 + %18 = llvm.insertelement %11, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(3 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.ashr %arg0, %10 : vector<4xi32> + %22 = llvm.or %21, %20 : vector<4xi32> + %23 = llvm.mul %22, %arg0 : vector<4xi32> + llvm.return %23 : vector<4xi32> + } + llvm.func @ashr_or_mul_to_abs_neg(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(30 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.or %2, %1 : i32 + %4 = llvm.mul %3, %arg0 overflow : i32 + llvm.return %4 : i32 + } + llvm.func @ashr_or_mul_to_abs_neg2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.or %2, %1 : i32 + %4 = llvm.mul %3, %arg0 overflow : i32 + llvm.return %4 : i32 + } + llvm.func @ashr_or_mul_to_abs_neg3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.or %2, %1 : i32 + %4 = llvm.mul %3, %arg1 overflow : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/assoc-cast-assoc.ll.mlir b/test/LLVMDialect/InstCombine/assoc-cast-assoc.ll.mlir new file mode 100644 index 000000000..db4cc8ec4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/assoc-cast-assoc.ll.mlir @@ -0,0 +1,62 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @XorZextXor(%arg0: i3) -> i5 { + %0 = llvm.mlir.constant(3 : i3) : i3 + %1 = llvm.mlir.constant(12 : i5) : i5 + %2 = llvm.xor %arg0, %0 : i3 + %3 = llvm.zext %2 : i3 to i5 + %4 = llvm.xor %3, %1 : i5 + llvm.return %4 : i5 + } + llvm.func @XorZextXorVec(%arg0: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : vector<2xi1> + %3 = llvm.mlir.constant(dense<[3, 1]> : vector<2xi32>) : vector<2xi32> + %4 = llvm.xor %arg0, %2 : vector<2xi1> + %5 = llvm.zext %4 : vector<2xi1> to vector<2xi32> + %6 = llvm.xor %5, %3 : vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @OrZextOr(%arg0: i3) -> i5 { + %0 = llvm.mlir.constant(3 : i3) : i3 + %1 = llvm.mlir.constant(8 : i5) : i5 + %2 = llvm.or %arg0, %0 : i3 + %3 = llvm.zext %2 : i3 to i5 + %4 = llvm.or %3, %1 : i5 + llvm.return %4 : i5 + } + llvm.func @OrZextOrVec(%arg0: vector<2xi2>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i2) : i2 + %1 = llvm.mlir.constant(-2 : i2) : i2 + %2 = llvm.mlir.constant(dense<[-2, 0]> : vector<2xi2>) : vector<2xi2> + %3 = llvm.mlir.constant(dense<[1, 5]> : vector<2xi32>) : vector<2xi32> + %4 = llvm.or %arg0, %2 : vector<2xi2> + %5 = llvm.zext %4 : vector<2xi2> to vector<2xi32> + %6 = llvm.or %5, %3 : vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @AndZextAnd(%arg0: i3) -> i5 { + %0 = llvm.mlir.constant(3 : i3) : i3 + %1 = llvm.mlir.constant(14 : i5) : i5 + %2 = llvm.and %arg0, %0 : i3 + %3 = llvm.zext %2 : i3 to i5 + %4 = llvm.and %3, %1 : i5 + llvm.return %4 : i5 + } + llvm.func @AndZextAndVec(%arg0: vector<2xi8>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[7, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[261, 1]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi8> + %3 = llvm.zext %2 : vector<2xi8> to vector<2xi32> + %4 = llvm.and %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @zext_nneg(%arg0: i16) -> i24 { + %0 = llvm.mlir.constant(32767 : i16) : i16 + %1 = llvm.mlir.constant(8388607 : i24) : i24 + %2 = llvm.and %arg0, %0 : i16 + %3 = llvm.zext %2 : i16 to i24 + %4 = llvm.and %3, %1 : i24 + llvm.return %4 : i24 + } +} diff --git a/test/LLVMDialect/InstCombine/assume-align.ll.mlir b/test/LLVMDialect/InstCombine/assume-align.ll.mlir index b5f7d3f84..43af9b17a 100644 --- a/test/LLVMDialect/InstCombine/assume-align.ll.mlir +++ b/test/LLVMDialect/InstCombine/assume-align.ll.mlir @@ -1,83 +1,72 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.assume", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = true} : () -> i1 - %3 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %6 = "llvm.getelementptr"(%arg0, %5) : (!llvm.ptr, i64) -> !llvm.ptr - %7 = "llvm.ptrtoint"(%6) : (!llvm.ptr) -> i64 - %8 = "llvm.and"(%7, %4) : (i64, i64) -> i64 - %9 = "llvm.icmp"(%8, %3) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%9)[^bb1, ^bb4] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.mlir.constant(1 : i8) : i8 + %5 = llvm.mlir.constant(4 : i32) : i32 + %6 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %7 = llvm.ptrtoint %6 : !llvm.ptr to i64 + %8 = llvm.and %7, %1 : i64 + %9 = llvm.icmp "eq" %8, %2 : i64 + llvm.cond_br %9, ^bb1, ^bb4 ^bb1: // pred: ^bb0 - "llvm.call"(%2) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %10 = "llvm.ptrtoint"(%6) : (!llvm.ptr) -> i64 - %11 = "llvm.and"(%10, %4) : (i64, i64) -> i64 - %12 = "llvm.icmp"(%11, %3) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%12)[^bb2, ^bb3] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + "llvm.intr.assume"(%3) : (i1) -> () + %10 = llvm.ptrtoint %6 : !llvm.ptr to i64 + %11 = llvm.and %10, %1 : i64 + %12 = llvm.icmp "eq" %11, %2 : i64 + llvm.cond_br %12, ^bb2, ^bb3 ^bb2: // pred: ^bb1 - %13 = "llvm.bitcast"(%6) : (!llvm.ptr) -> !llvm.ptr - "llvm.store"(%1, %13) : (i32, !llvm.ptr) -> () - "llvm.br"()[^bb4] : () -> () + llvm.store %5, %6 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb4 ^bb3: // pred: ^bb1 - "llvm.store"(%0, %6) : (i8, !llvm.ptr) -> () - "llvm.br"()[^bb4] : () -> () + llvm.store %4, %6 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.br ^bb4 ^bb4: // 3 preds: ^bb0, ^bb2, ^bb3 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "f1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 15 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = true} : () -> i1 - "llvm.call"(%5) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %6 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i64) -> !llvm.ptr - %7 = "llvm.ptrtoint"(%6) : (!llvm.ptr) -> i64 - %8 = "llvm.and"(%7, %3) : (i64, i64) -> i64 - %9 = "llvm.icmp"(%8, %2) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%9)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.return + } + llvm.func @f2(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(8 : i64) : i64 + %2 = llvm.mlir.constant(15 : i64) : i64 + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.mlir.constant(1 : i8) : i8 + %5 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.assume"(%0) : (i1) -> () + %6 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %7 = llvm.ptrtoint %6 : !llvm.ptr to i64 + %8 = llvm.and %7, %2 : i64 + %9 = llvm.icmp "eq" %8, %3 : i64 + llvm.cond_br %9, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %10 = "llvm.bitcast"(%6) : (!llvm.ptr) -> !llvm.ptr - "llvm.store"(%1, %10) : (i64, !llvm.ptr) -> () - "llvm.br"()[^bb3] : () -> () + llvm.store %5, %6 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.br ^bb3 ^bb2: // pred: ^bb0 - "llvm.store"(%0, %6) : (i8, !llvm.ptr) -> () - "llvm.br"()[^bb3] : () -> () + llvm.store %4, %6 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.br ^bb3 ^bb3: // 2 preds: ^bb1, ^bb2 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "f2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.ptrtoint"(%arg1) : (!llvm.ptr) -> i64 - "llvm.call"(%0) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %2 = "llvm.add"(%arg0, %1) : (i64, i64) -> i64 - "llvm.call"(%2) {callee = @g, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "f3", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "g", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - "llvm.call"(%0) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i8 - "llvm.return"(%1) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "assume_align_zero", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - "llvm.call"(%0) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i8 - "llvm.return"(%1) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "assume_align_non_pow2", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } + llvm.func @f3(%arg0: i64, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.ptrtoint %arg1 : !llvm.ptr to i64 + "llvm.intr.assume"(%0) : (i1) -> () + %2 = llvm.add %arg0, %1 : i64 + llvm.call @g(%2) : (i64) -> () + llvm.return + } + llvm.func @g(i64) + llvm.func @assume_align_zero(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + "llvm.intr.assume"(%0) : (i1) -> () + %1 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %1 : i8 + } + llvm.func @assume_align_non_pow2(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + "llvm.intr.assume"(%0) : (i1) -> () + %1 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %1 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/assume-icmp-null-select.ll.mlir b/test/LLVMDialect/InstCombine/assume-icmp-null-select.ll.mlir new file mode 100644 index 000000000..318d7d3b9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/assume-icmp-null-select.ll.mlir @@ -0,0 +1,20 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<64> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @example(%arg0: !llvm.ptr {llvm.dereferenceable = 24 : i64}) -> !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %2 = llvm.icmp "eq" %1, %0 : !llvm.ptr + %3 = llvm.select %2, %0, %arg0 : i1, !llvm.ptr + %4 = llvm.icmp "ne" %3, %0 : !llvm.ptr + "llvm.intr.assume"(%4) : (i1) -> () + llvm.return %3 : !llvm.ptr + } + llvm.func @example2(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %2 = llvm.icmp "eq" %1, %0 : !llvm.ptr + %3 = llvm.select %2, %0, %arg0 : i1, !llvm.ptr + %4 = llvm.icmp "ne" %3, %0 : !llvm.ptr + "llvm.intr.assume"(%4) : (i1) -> () + llvm.return %3 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/assume-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/assume-inseltpoison.ll.mlir new file mode 100644 index 000000000..16627b0a6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/assume-inseltpoison.ll.mlir @@ -0,0 +1,11 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @PR40940(%arg0: vector<4xi8>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.shufflevector %arg0, %0 [1, 1, 2, 3] : vector<4xi8> + %3 = llvm.bitcast %2 : vector<4xi8> to i32 + %4 = llvm.icmp "ult" %3, %1 : i32 + "llvm.intr.assume"(%4) : (i1) -> () + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/assume-loop-align.ll.mlir b/test/LLVMDialect/InstCombine/assume-loop-align.ll.mlir index 4e7f2b7e8..bbfd81026 100644 --- a/test/LLVMDialect/InstCombine/assume-loop-align.ll.mlir +++ b/test/LLVMDialect/InstCombine/assume-loop-align.ll.mlir @@ -1,34 +1,30 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1648 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 63 : i64} : () -> i64 - %5 = "llvm.ptrtoint"(%arg0) : (!llvm.ptr) -> i64 - %6 = "llvm.and"(%5, %4) : (i64, i64) -> i64 - %7 = "llvm.icmp"(%6, %3) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.call"(%7) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %8 = "llvm.ptrtoint"(%arg1) : (!llvm.ptr) -> i64 - %9 = "llvm.and"(%8, %4) : (i64, i64) -> i64 - %10 = "llvm.icmp"(%9, %3) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.call"(%10) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.br"(%3)[^bb1] : (i64) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: !llvm.ptr, %arg1: !llvm.ptr) attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(16 : i64) : i64 + %4 = llvm.mlir.constant(1648 : i32) : i32 + %5 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %6 = llvm.and %5, %0 : i64 + %7 = llvm.icmp "eq" %6, %1 : i64 + "llvm.intr.assume"(%7) : (i1) -> () + %8 = llvm.ptrtoint %arg1 : !llvm.ptr to i64 + %9 = llvm.and %8, %0 : i64 + %10 = llvm.icmp "eq" %9, %1 : i64 + "llvm.intr.assume"(%10) : (i1) -> () + llvm.br ^bb1(%1 : i64) ^bb1(%11: i64): // 2 preds: ^bb0, ^bb1 - %12 = "llvm.getelementptr"(%arg1, %11) : (!llvm.ptr, i64) -> !llvm.ptr - %13 = "llvm.load"(%12) : (!llvm.ptr) -> i32 - %14 = "llvm.add"(%13, %2) : (i32, i32) -> i32 - %15 = "llvm.getelementptr"(%arg0, %11) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%14, %15) : (i32, !llvm.ptr) -> () - %16 = "llvm.add"(%11, %1) : (i64, i64) -> i64 - %17 = "llvm.trunc"(%16) : (i64) -> i32 - %18 = "llvm.icmp"(%17, %0) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%18, %16)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i64) -> () + %12 = llvm.getelementptr inbounds %arg1[%11] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %13 = llvm.load %12 {alignment = 4 : i64} : !llvm.ptr -> i32 + %14 = llvm.add %13, %2 overflow : i32 + %15 = llvm.getelementptr inbounds %arg0[%11] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %14, %15 {alignment = 4 : i64} : i32, !llvm.ptr + %16 = llvm.add %11, %3 overflow : i64 + %17 = llvm.trunc %16 : i64 to i32 + %18 = llvm.icmp "slt" %17, %4 : i32 + llvm.cond_br %18, ^bb1(%16 : i64), ^bb2 ^bb2: // pred: ^bb1 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.assume", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/assume-redundant.ll.mlir b/test/LLVMDialect/InstCombine/assume-redundant.ll.mlir index 25625d4a0..448edbbbe 100644 --- a/test/LLVMDialect/InstCombine/assume-redundant.ll.mlir +++ b/test/LLVMDialect/InstCombine/assume-redundant.ll.mlir @@ -1,65 +1,58 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr)>>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1599 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 2.000000e+00 : f64} : () -> f64 - %3 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %4 = "llvm.mlir.constant"() {value = 31 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %7 = "llvm.getelementptr"(%arg0, %6, %5) : (!llvm.ptr)>>, i64, i32) -> !llvm.ptr> - %8 = "llvm.load"(%7) : (!llvm.ptr>) -> !llvm.ptr - %9 = "llvm.ptrtoint"(%8) : (!llvm.ptr) -> i64 - %10 = "llvm.and"(%9, %4) : (i64, i64) -> i64 - %11 = "llvm.icmp"(%10, %6) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.br"(%6)[^bb1] : (i64) -> () - ^bb1(%12: i64): // 2 preds: ^bb0, ^bb1 - "llvm.call"(%11) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %13 = "llvm.getelementptr"(%8, %12) : (!llvm.ptr, i64) -> !llvm.ptr - %14 = "llvm.load"(%13) : (!llvm.ptr) -> f64 - %15 = "llvm.fadd"(%14, %3) : (f64, f64) -> f64 - "llvm.call"(%11) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %16 = "llvm.fmul"(%15, %2) : (f64, f64) -> f64 - "llvm.store"(%16, %13) : (f64, !llvm.ptr) -> () - %17 = "llvm.add"(%12, %1) : (i64, i64) -> i64 - "llvm.call"(%11) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %18 = "llvm.getelementptr"(%8, %17) : (!llvm.ptr, i64) -> !llvm.ptr - %19 = "llvm.load"(%18) : (!llvm.ptr) -> f64 - %20 = "llvm.fadd"(%19, %3) : (f64, f64) -> f64 - "llvm.call"(%11) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %21 = "llvm.fmul"(%20, %2) : (f64, f64) -> f64 - "llvm.store"(%21, %18) : (f64, !llvm.ptr) -> () - %22 = "llvm.add"(%17, %1) : (i64, i64) -> i64 - %23 = "llvm.icmp"(%17, %0) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%23, %22)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i64) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @_Z3fooR1s(%arg0: !llvm.ptr {llvm.dereferenceable = 8 : i64, llvm.nocapture, llvm.readonly}) attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(31 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %3 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %4 = llvm.mlir.constant(1 : i64) : i64 + %5 = llvm.mlir.constant(1599 : i64) : i64 + %6 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %7 = llvm.ptrtoint %6 : !llvm.ptr to i64 + %8 = llvm.and %7, %0 : i64 + %9 = llvm.icmp "eq" %8, %1 : i64 + llvm.br ^bb1(%1 : i64) + ^bb1(%10: i64): // 2 preds: ^bb0, ^bb1 + "llvm.intr.assume"(%9) : (i1) -> () + %11 = llvm.getelementptr inbounds %6[%10] : (!llvm.ptr, i64) -> !llvm.ptr, f64 + %12 = llvm.load %11 {alignment = 16 : i64} : !llvm.ptr -> f64 + %13 = llvm.fadd %12, %2 : f64 + "llvm.intr.assume"(%9) : (i1) -> () + %14 = llvm.fmul %13, %3 : f64 + llvm.store %14, %11 {alignment = 16 : i64} : f64, !llvm.ptr + %15 = llvm.add %10, %4 overflow : i64 + "llvm.intr.assume"(%9) : (i1) -> () + %16 = llvm.getelementptr inbounds %6[%15] : (!llvm.ptr, i64) -> !llvm.ptr, f64 + %17 = llvm.load %16 {alignment = 8 : i64} : !llvm.ptr -> f64 + %18 = llvm.fadd %17, %2 : f64 + "llvm.intr.assume"(%9) : (i1) -> () + %19 = llvm.fmul %18, %3 : f64 + llvm.store %19, %16 {alignment = 8 : i64} : f64, !llvm.ptr + %20 = llvm.add %15, %4 overflow : i64 + %21 = llvm.icmp "eq" %15, %5 : i64 + llvm.cond_br %21, ^bb2, ^bb1(%20 : i64) ^bb2: // pred: ^bb1 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "_Z3fooR1s", type = !llvm.func)>>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "get", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %2 = "llvm.call"() {callee = @get, fastmathFlags = #llvm.fastmath<>} : () -> !llvm.ptr - %3 = "llvm.ptrtoint"(%2) : (!llvm.ptr) -> i64 - %4 = "llvm.and"(%3, %1) : (i64, i64) -> i64 - %5 = "llvm.icmp"(%4, %0) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.call"(%5) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %4 = "llvm.ptrtoint"(%3) : (!llvm.ptr) -> i64 - %5 = "llvm.and"(%4, %1) : (i64, i64) -> i64 - %6 = "llvm.icmp"(%5, %0) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.call"(%6) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.assume", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } + llvm.func @get() -> (!llvm.ptr {llvm.align = 8 : i64}) + llvm.func @test1() { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.call @get() : () -> !llvm.ptr + %3 = llvm.ptrtoint %2 : !llvm.ptr to i64 + %4 = llvm.and %3, %0 : i64 + %5 = llvm.icmp "eq" %4, %1 : i64 + "llvm.intr.assume"(%5) : (i1) -> () + llvm.return + } + llvm.func @test3() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(7 : i64) : i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.alloca %0 x i8 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.ptrtoint %3 : !llvm.ptr to i64 + %5 = llvm.and %4, %1 : i64 + %6 = llvm.icmp "eq" %5, %2 : i64 + "llvm.intr.assume"(%6) : (i1) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/assume-separate_storage.ll.mlir b/test/LLVMDialect/InstCombine/assume-separate_storage.ll.mlir new file mode 100644 index 000000000..b987dc59d --- /dev/null +++ b/test/LLVMDialect/InstCombine/assume-separate_storage.ll.mlir @@ -0,0 +1,29 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @some_global(777 : i32) {addr_space = 0 : i32} : i32 + llvm.func @simple_folding(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(123 : i64) : i64 + %1 = llvm.mlir.constant(777 : i64) : i64 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.getelementptr %arg1[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + "llvm.intr.assume"(%2) : (i1) -> () + llvm.return + } + llvm.func @folds_removed_operands(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64, %arg3: i64) -> i64 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.add %arg2, %arg3 : i64 + %2 = llvm.add %1, %arg3 : i64 + %3 = llvm.getelementptr %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + "llvm.intr.assume"(%0) : (i1) -> () + llvm.return %2 : i64 + } + llvm.func @handles_globals(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(777 : i32) : i32 + %1 = llvm.mlir.addressof @some_global : !llvm.ptr + %2 = llvm.mlir.constant(3 : i65) : i65 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.getelementptr %1[%2] : (!llvm.ptr, i65) -> !llvm.ptr, i8 + "llvm.intr.assume"(%3) : (i1) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/assume.ll.mlir b/test/LLVMDialect/InstCombine/assume.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/assume2.ll.mlir b/test/LLVMDialect/InstCombine/assume2.ll.mlir index 04fb4b8fb..3625fe1fa 100644 --- a/test/LLVMDialect/InstCombine/assume2.ll.mlir +++ b/test/LLVMDialect/InstCombine/assume2.ll.mlir @@ -1,124 +1,110 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.assume", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 15 : i32} : () -> i32 - %3 = "llvm.and"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.icmp"(%3, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.call"(%4) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %5 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -11 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 15 : i32} : () -> i32 - %4 = "llvm.and"(%arg0, %3) : (i32, i32) -> i32 - %5 = "llvm.xor"(%4, %2) : (i32, i32) -> i32 - %6 = "llvm.icmp"(%5, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.call"(%6) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %7 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%7) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -11 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = -16 : i32} : () -> i32 - %3 = "llvm.or"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.icmp"(%3, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.call"(%4) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %5 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = -16 : i32} : () -> i32 - %4 = "llvm.or"(%arg0, %3) : (i32, i32) -> i32 - %5 = "llvm.xor"(%4, %2) : (i32, i32) -> i32 - %6 = "llvm.icmp"(%5, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.call"(%6) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %7 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%7) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.xor"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.icmp"(%3, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.call"(%4) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %5 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 63 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 20 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %3 = "llvm.shl"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.icmp"(%3, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.call"(%4) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %5 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 252 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %3 = "llvm.lshr"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.icmp"(%3, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.call"(%4) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %5 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 252 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %3 = "llvm.lshr"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.icmp"(%3, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.call"(%4) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %5 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2147483648 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.icmp"(%arg0, %1) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.call"(%2) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %3 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test9", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2147483648 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -2 : i32} : () -> i32 - %2 = "llvm.icmp"(%arg0, %1) {predicate = 3 : i64} : (i32, i32) -> i1 - "llvm.call"(%2) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %3 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3072 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 256 : i32} : () -> i32 - %2 = "llvm.icmp"(%arg0, %1) {predicate = 7 : i64} : (i32, i32) -> i1 - "llvm.call"(%2) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %3 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test11", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + "llvm.intr.assume"(%4) : (i1) -> () + %5 = llvm.and %arg0, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test2(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(-11 : i32) : i32 + %3 = llvm.mlir.constant(7 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + "llvm.intr.assume"(%6) : (i1) -> () + %7 = llvm.and %arg0, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @test3(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(-16 : i32) : i32 + %1 = llvm.mlir.constant(-11 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.or %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + "llvm.intr.assume"(%4) : (i1) -> () + %5 = llvm.and %arg0, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test4(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(-16 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(5 : i32) : i32 + %3 = llvm.mlir.constant(7 : i32) : i32 + %4 = llvm.or %arg0, %0 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + "llvm.intr.assume"(%6) : (i1) -> () + %7 = llvm.and %arg0, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @test5(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + "llvm.intr.assume"(%4) : (i1) -> () + %5 = llvm.and %arg0, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test6(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(20 : i32) : i32 + %2 = llvm.mlir.constant(63 : i32) : i32 + %3 = llvm.shl %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + "llvm.intr.assume"(%4) : (i1) -> () + %5 = llvm.and %arg0, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test7(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(252 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + "llvm.intr.assume"(%4) : (i1) -> () + %5 = llvm.and %arg0, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test8(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(252 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + "llvm.intr.assume"(%4) : (i1) -> () + %5 = llvm.and %arg0, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test9(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.and %arg0, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test10(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.icmp "sle" %arg0, %0 : i32 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.and %arg0, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test11(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(256 : i32) : i32 + %1 = llvm.mlir.constant(3072 : i32) : i32 + %2 = llvm.icmp "ule" %arg0, %0 : i32 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.and %arg0, %1 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/assume_inevitable.ll.mlir b/test/LLVMDialect/InstCombine/assume_inevitable.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/atomic.ll.mlir b/test/LLVMDialect/InstCombine/atomic.ll.mlir new file mode 100644 index 000000000..36d59d4d0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/atomic.ll.mlir @@ -0,0 +1,240 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @a() {addr_space = 0 : i32} : i32 + llvm.mlir.global external @b() {addr_space = 0 : i32} : i32 + llvm.mlir.global external constant @c(42 : i32) {addr_space = 0 : i32} : i32 + llvm.mlir.global external @g(42 : i32) {addr_space = 0 : i32} : i32 + llvm.func @test1(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 atomic seq_cst {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %2 = llvm.add %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test2(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load volatile %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.load volatile %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %2 = llvm.add %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test3(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load volatile %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %2 = llvm.add %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test4(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 atomic seq_cst {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.load %arg0 atomic unordered {alignment = 4 : i64} : !llvm.ptr -> i32 + %2 = llvm.add %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test5(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 atomic unordered {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %2 = llvm.add %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test6(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 atomic unordered {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.load %arg0 atomic unordered {alignment = 4 : i64} : !llvm.ptr -> i32 + %2 = llvm.add %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test7(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 atomic seq_cst {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.load %arg0 atomic monotonic {alignment = 4 : i64} : !llvm.ptr -> i32 + %2 = llvm.add %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test8(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 atomic seq_cst {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.load %arg0 atomic acquire {alignment = 4 : i64} : !llvm.ptr -> i32 + %2 = llvm.add %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test9() -> i32 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.load %0 atomic unordered {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %1 : i32 + } + llvm.func @test9_no_null_opt() -> i32 attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.load %0 atomic unordered {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %1 : i32 + } + llvm.func @test10() -> i32 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.load %0 atomic monotonic {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %1 : i32 + } + llvm.func @test10_no_null_opt() -> i32 attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.load %0 atomic monotonic {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %1 : i32 + } + llvm.func @test11() -> i32 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.load %0 atomic seq_cst {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %1 : i32 + } + llvm.func @test11_no_null_opt() -> i32 attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.load %0 atomic seq_cst {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %1 : i32 + } + llvm.func @test12() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + llvm.store %0, %1 atomic unordered {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %0 : i32 + } + llvm.func @test12_no_null_opt() -> i32 attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + llvm.store %0, %1 atomic unordered {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %0 : i32 + } + llvm.func @test13() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + llvm.store %0, %1 atomic monotonic {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %0 : i32 + } + llvm.func @test13_no_null_opt() -> i32 attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + llvm.store %0, %1 atomic monotonic {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %0 : i32 + } + llvm.func @test14() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + llvm.store %0, %1 atomic seq_cst {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %0 : i32 + } + llvm.func @test14_no_null_opt() -> i32 attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + llvm.store %0, %1 atomic seq_cst {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %0 : i32 + } + llvm.func @test15(%arg0: i1) -> i32 { + %0 = llvm.mlir.addressof @a : !llvm.ptr + %1 = llvm.mlir.addressof @b : !llvm.ptr + %2 = llvm.select %arg0, %0, %1 : i1, !llvm.ptr + %3 = llvm.load %2 atomic unordered {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %3 : i32 + } + llvm.func @test16(%arg0: i1) -> i32 { + %0 = llvm.mlir.addressof @a : !llvm.ptr + %1 = llvm.mlir.addressof @b : !llvm.ptr + %2 = llvm.select %arg0, %0, %1 : i1, !llvm.ptr + %3 = llvm.load %2 atomic monotonic {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %3 : i32 + } + llvm.func @test17(%arg0: i1) -> i32 { + %0 = llvm.mlir.addressof @a : !llvm.ptr + %1 = llvm.mlir.addressof @b : !llvm.ptr + %2 = llvm.select %arg0, %0, %1 : i1, !llvm.ptr + %3 = llvm.load %2 atomic seq_cst {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %3 : i32 + } + llvm.func @test22(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.store %2, %1 atomic unordered {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 + ^bb2: // pred: ^bb0 + llvm.store %0, %1 atomic unordered {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + llvm.return %3 : i32 + } + llvm.func @test23(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.store %2, %1 atomic monotonic {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 + ^bb2: // pred: ^bb0 + llvm.store %0, %1 atomic monotonic {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + llvm.return %3 : i32 + } + llvm.func @clobber() + llvm.func @test18(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 atomic unordered {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.call @clobber() : () -> () + llvm.store %1, %arg0 atomic unordered {alignment = 4 : i64} : f32, !llvm.ptr + llvm.return %0 : i32 + } + llvm.func @test19(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 atomic seq_cst {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.call @clobber() : () -> () + llvm.store %1, %arg0 atomic seq_cst {alignment = 4 : i64} : f32, !llvm.ptr + llvm.return %0 : i32 + } + llvm.func @test20(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.store %arg1, %arg0 atomic unordered {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return %0 : i32 + } + llvm.func @test21(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.store %arg1, %arg0 atomic monotonic {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return %0 : i32 + } + llvm.func @pr27490a(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store volatile %0, %arg1 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @pr27490b(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store %0, %arg1 atomic seq_cst {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @no_atomic_vector_load(%arg0: !llvm.ptr) -> vector<2xf32> { + %0 = llvm.load %arg0 atomic unordered {alignment = 8 : i64} : !llvm.ptr -> i64 + %1 = llvm.bitcast %0 : i64 to vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @no_atomic_vector_store(%arg0: vector<2xf32>, %arg1: !llvm.ptr) { + %0 = llvm.bitcast %arg0 : vector<2xf32> to i64 + llvm.store %0, %arg1 atomic unordered {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @atomic_load_from_constant_global() -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.addressof @c : !llvm.ptr + %2 = llvm.load %1 atomic seq_cst {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %2 : i32 + } + llvm.func @atomic_load_from_constant_global_bitcast() -> i8 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.addressof @c : !llvm.ptr + %2 = llvm.load %1 atomic seq_cst {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %2 : i8 + } + llvm.func @atomic_load_from_non_constant_global() { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.addressof @g : !llvm.ptr + %2 = llvm.load %1 atomic seq_cst {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return + } + llvm.func @volatile_load_from_constant_global() { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.addressof @c : !llvm.ptr + %2 = llvm.load volatile %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/atomicrmw.ll.mlir b/test/LLVMDialect/InstCombine/atomicrmw.ll.mlir new file mode 100644 index 000000000..63d436faa --- /dev/null +++ b/test/LLVMDialect/InstCombine/atomicrmw.ll.mlir @@ -0,0 +1,412 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @atomic_add_zero(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw add %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @atomic_or_zero(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw _or %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @atomic_sub_zero(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw sub %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @atomic_and_allones(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw _and %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @atomic_umin_uint_max(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw umin %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @atomic_umax_zero(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw umax %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @atomic_min_smax_char(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.atomicrmw min %arg0, %0 monotonic {alignment = 1 : i64} : !llvm.ptr, i8 + llvm.return %1 : i8 + } + llvm.func @atomic_max_smin_char(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.atomicrmw max %arg0, %0 monotonic {alignment = 1 : i64} : !llvm.ptr, i8 + llvm.return %1 : i8 + } + llvm.func @atomic_fsub_zero(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.atomicrmw fsub %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, f32 + llvm.return %1 : f32 + } + llvm.func @atomic_fadd_zero(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.atomicrmw fadd %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, f32 + llvm.return %1 : f32 + } + llvm.func @atomic_fsub_canon(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.atomicrmw fsub %arg0, %0 release {alignment = 4 : i64} : !llvm.ptr, f32 + llvm.return %1 : f32 + } + llvm.func @atomic_fadd_canon(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.atomicrmw fadd %arg0, %0 release {alignment = 4 : i64} : !llvm.ptr, f32 + llvm.return %1 : f32 + } + llvm.func @atomic_sub_zero_volatile(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.atomicrmw volatile sub %arg0, %0 acquire {alignment = 8 : i64} : !llvm.ptr, i64 + llvm.return %1 : i64 + } + llvm.func @atomic_syncscope(%arg0: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.atomicrmw _or %arg0, %0 syncscope("some_syncscope") acquire {alignment = 2 : i64} : !llvm.ptr, i16 + llvm.return %1 : i16 + } + llvm.func @atomic_seq_cst(%arg0: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.atomicrmw add %arg0, %0 seq_cst {alignment = 2 : i64} : !llvm.ptr, i16 + llvm.return %1 : i16 + } + llvm.func @atomic_add_non_zero(%arg0: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(2 : i16) : i16 + %1 = llvm.atomicrmw add %arg0, %0 monotonic {alignment = 2 : i64} : !llvm.ptr, i16 + llvm.return %1 : i16 + } + llvm.func @atomic_xor_zero(%arg0: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.atomicrmw _xor %arg0, %0 monotonic {alignment = 2 : i64} : !llvm.ptr, i16 + llvm.return %1 : i16 + } + llvm.func @atomic_release(%arg0: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.atomicrmw sub %arg0, %0 release {alignment = 2 : i64} : !llvm.ptr, i16 + llvm.return %1 : i16 + } + llvm.func @atomic_acq_rel(%arg0: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.atomicrmw _xor %arg0, %0 acq_rel {alignment = 2 : i64} : !llvm.ptr, i16 + llvm.return %1 : i16 + } + llvm.func @sat_or_allones(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw _or %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @sat_and_zero(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw _and %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @sat_umin_uint_min(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw umin %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @sat_umax_uint_max(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw umax %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @sat_min_smin_char(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.atomicrmw min %arg0, %0 monotonic {alignment = 1 : i64} : !llvm.ptr, i8 + llvm.return %1 : i8 + } + llvm.func @sat_max_smax_char(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.atomicrmw max %arg0, %0 monotonic {alignment = 1 : i64} : !llvm.ptr, i8 + llvm.return %1 : i8 + } + llvm.func @sat_fadd_nan(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0x7FF00000FFFFFFFF : f64) : f64 + %1 = llvm.atomicrmw fadd %arg0, %0 release {alignment = 8 : i64} : !llvm.ptr, f64 + llvm.return %1 : f64 + } + llvm.func @sat_fsub_nan(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0x7FF00000FFFFFFFF : f64) : f64 + %1 = llvm.atomicrmw fsub %arg0, %0 release {alignment = 8 : i64} : !llvm.ptr, f64 + llvm.return %1 : f64 + } + llvm.func @sat_fsub_nan_unused(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0x7FF00000FFFFFFFF : f64) : f64 + %1 = llvm.atomicrmw fsub %arg0, %0 monotonic {alignment = 8 : i64} : !llvm.ptr, f64 + llvm.return + } + llvm.func @xchg_unused_monotonic(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw xchg %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @xchg_unused_release(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw xchg %arg0, %0 release {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @xchg_unused_under_aligned(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw xchg %arg0, %0 release {alignment = 1 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @xchg_unused_over_aligned(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw xchg %arg0, %0 release {alignment = 8 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @xchg_unused_seq_cst(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw xchg %arg0, %0 seq_cst {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @xchg_unused_volatile(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw volatile xchg %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @sat_or_allones_unused(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw _or %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @undef_operand_unused(%arg0: !llvm.ptr) { + %0 = llvm.mlir.undef : i32 + %1 = llvm.atomicrmw _or %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @undef_operand_used(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.undef : i32 + %1 = llvm.atomicrmw _or %arg0, %0 monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @sat_fmax_inf(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0x7FF0000000000000 : f64) : f64 + %1 = llvm.atomicrmw fmax %arg0, %0 monotonic {alignment = 8 : i64} : !llvm.ptr, f64 + llvm.return %1 : f64 + } + llvm.func @no_sat_fmax_inf(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(1.000000e-01 : f64) : f64 + %1 = llvm.atomicrmw fmax %arg0, %0 monotonic {alignment = 8 : i64} : !llvm.ptr, f64 + llvm.return %1 : f64 + } + llvm.func @sat_fmin_inf(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0xFFF0000000000000 : f64) : f64 + %1 = llvm.atomicrmw fmin %arg0, %0 monotonic {alignment = 8 : i64} : !llvm.ptr, f64 + llvm.return %1 : f64 + } + llvm.func @no_sat_fmin_inf(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(1.000000e-01 : f64) : f64 + %1 = llvm.atomicrmw fmin %arg0, %0 monotonic {alignment = 8 : i64} : !llvm.ptr, f64 + llvm.return %1 : f64 + } + llvm.func @atomic_add_zero_preserve_md(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw add %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @atomic_or_zero_preserve_md(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw _or %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @atomic_sub_zero_preserve_md(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw sub %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @atomic_and_allones_preserve_md(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw _and %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @atomic_umin_uint_max_preserve_md(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw umin %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @atomic_umax_zero_preserve_md(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw umax %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @atomic_min_smax_char_preserve_md(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.atomicrmw min %arg0, %0 syncscope("agent") monotonic {alignment = 1 : i64} : !llvm.ptr, i8 + llvm.return %1 : i8 + } + llvm.func @atomic_max_smin_char_preserve_md(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.atomicrmw max %arg0, %0 syncscope("agent") monotonic {alignment = 1 : i64} : !llvm.ptr, i8 + llvm.return %1 : i8 + } + llvm.func @atomic_fsub_zero_preserve_md(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.atomicrmw fsub %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, f32 + llvm.return %1 : f32 + } + llvm.func @atomic_fadd_zero_preserve_md(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.atomicrmw fadd %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, f32 + llvm.return %1 : f32 + } + llvm.func @atomic_fsub_canon_preserve_md(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.atomicrmw fsub %arg0, %0 release {alignment = 4 : i64} : !llvm.ptr, f32 + llvm.return %1 : f32 + } + llvm.func @atomic_fadd_canon_preserve_md(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.atomicrmw fadd %arg0, %0 release {alignment = 4 : i64} : !llvm.ptr, f32 + llvm.return %1 : f32 + } + llvm.func @atomic_sub_zero_volatile_preserve_md(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.atomicrmw volatile sub %arg0, %0 acquire {alignment = 8 : i64} : !llvm.ptr, i64 + llvm.return %1 : i64 + } + llvm.func @atomic_syncscope_preserve_md(%arg0: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.atomicrmw _or %arg0, %0 syncscope("some_syncscope") acquire {alignment = 2 : i64} : !llvm.ptr, i16 + llvm.return %1 : i16 + } + llvm.func @atomic_seq_cst_preserve_md(%arg0: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.atomicrmw add %arg0, %0 seq_cst {alignment = 2 : i64} : !llvm.ptr, i16 + llvm.return %1 : i16 + } + llvm.func @atomic_add_non_zero_preserve_md(%arg0: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(2 : i16) : i16 + %1 = llvm.atomicrmw add %arg0, %0 syncscope("agent") monotonic {alignment = 2 : i64} : !llvm.ptr, i16 + llvm.return %1 : i16 + } + llvm.func @atomic_xor_zero_preserve_md(%arg0: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.atomicrmw _xor %arg0, %0 syncscope("agent") monotonic {alignment = 2 : i64} : !llvm.ptr, i16 + llvm.return %1 : i16 + } + llvm.func @atomic_release_preserve_md(%arg0: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.atomicrmw sub %arg0, %0 release {alignment = 2 : i64} : !llvm.ptr, i16 + llvm.return %1 : i16 + } + llvm.func @atomic_acq_rel_preserve_md(%arg0: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.atomicrmw _xor %arg0, %0 acq_rel {alignment = 2 : i64} : !llvm.ptr, i16 + llvm.return %1 : i16 + } + llvm.func @sat_or_allones_preserve_md(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw _or %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @sat_and_zero_preserve_md(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw _and %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @sat_umin_uint_min_preserve_md(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw umin %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @sat_umax_uint_max_preserve_md(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw umax %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @sat_min_smin_char_preserve_md(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.atomicrmw min %arg0, %0 syncscope("agent") monotonic {alignment = 1 : i64} : !llvm.ptr, i8 + llvm.return %1 : i8 + } + llvm.func @sat_max_smax_char_preserve_md(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.atomicrmw max %arg0, %0 syncscope("agent") monotonic {alignment = 1 : i64} : !llvm.ptr, i8 + llvm.return %1 : i8 + } + llvm.func @sat_fadd_nan_preserve_md(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0x7FF00000FFFFFFFF : f64) : f64 + %1 = llvm.atomicrmw fadd %arg0, %0 release {alignment = 8 : i64} : !llvm.ptr, f64 + llvm.return %1 : f64 + } + llvm.func @sat_fsub_nan_preserve_md(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0x7FF00000FFFFFFFF : f64) : f64 + %1 = llvm.atomicrmw fsub %arg0, %0 release {alignment = 8 : i64} : !llvm.ptr, f64 + llvm.return %1 : f64 + } + llvm.func @sat_fsub_nan_unused_preserve_md(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0x7FF00000FFFFFFFF : f64) : f64 + %1 = llvm.atomicrmw fsub %arg0, %0 syncscope("agent") monotonic {alignment = 8 : i64} : !llvm.ptr, f64 + llvm.return + } + llvm.func @xchg_unused_monotonic_preserve_md(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw xchg %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @xchg_unused_release_preserve_md(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw xchg %arg0, %0 syncscope("agent") release {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @xchg_unused_under_aligned_preserve_md(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw xchg %arg0, %0 syncscope("agent") release {alignment = 1 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @xchg_unused_over_aligned_preserve_md(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw xchg %arg0, %0 syncscope("agent") release {alignment = 8 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @xchg_unused_seq_cst_preserve_md(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw xchg %arg0, %0 syncscope("agent") seq_cst {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @xchg_unused_volatile_preserve_md(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.atomicrmw volatile xchg %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @sat_or_allones_unused_preserve_md(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.atomicrmw _or %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @undef_operand_unused_preserve_md(%arg0: !llvm.ptr) { + %0 = llvm.mlir.undef : i32 + %1 = llvm.atomicrmw _or %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return + } + llvm.func @undef_operand_used_preserve_md(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.undef : i32 + %1 = llvm.atomicrmw _or %arg0, %0 syncscope("agent") monotonic {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.return %1 : i32 + } + llvm.func @sat_fmax_inf_preserve_md(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0x7FF0000000000000 : f64) : f64 + %1 = llvm.atomicrmw fmax %arg0, %0 syncscope("agent") monotonic {alignment = 8 : i64} : !llvm.ptr, f64 + llvm.return %1 : f64 + } + llvm.func @no_sat_fmax_inf_preserve_md(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(1.000000e-01 : f64) : f64 + %1 = llvm.atomicrmw fmax %arg0, %0 syncscope("agent") monotonic {alignment = 8 : i64} : !llvm.ptr, f64 + llvm.return %1 : f64 + } + llvm.func @sat_fmin_inf_preserve_md(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0xFFF0000000000000 : f64) : f64 + %1 = llvm.atomicrmw fmin %arg0, %0 syncscope("agent") monotonic {alignment = 8 : i64} : !llvm.ptr, f64 + llvm.return %1 : f64 + } + llvm.func @no_sat_fmin_inf_preserve_md(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(1.000000e-01 : f64) : f64 + %1 = llvm.atomicrmw fmin %arg0, %0 syncscope("agent") monotonic {alignment = 8 : i64} : !llvm.ptr, f64 + llvm.return %1 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/avg-lsb.ll.mlir b/test/LLVMDialect/InstCombine/avg-lsb.ll.mlir new file mode 100644 index 000000000..ea4f10de3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/avg-lsb.ll.mlir @@ -0,0 +1,27 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @avg_lsb(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.add %2, %1 overflow : i8 + %4 = llvm.lshr %3, %0 : i8 + llvm.return %4 : i8 + } + llvm.func @avg_lsb_mismatch(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.add %3, %2 overflow : i8 + %5 = llvm.lshr %4, %0 : i8 + llvm.return %5 : i8 + } + llvm.func @avg_lsb_vector(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.and %arg1, %0 : vector<2xi8> + %3 = llvm.add %2, %1 overflow : vector<2xi8> + %4 = llvm.lshr %3, %0 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/badmalloc.ll.mlir b/test/LLVMDialect/InstCombine/badmalloc.ll.mlir new file mode 100644 index 000000000..0a8ebd0b8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/badmalloc.ll.mlir @@ -0,0 +1,27 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @malloc(i64) -> (!llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind", ["allockind", "9"], ["alloc-family", "malloc"]]} + llvm.func @free(!llvm.ptr) attributes {passthrough = [["allockind", "4"], ["alloc-family", "malloc"]]} + llvm.func @test1() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %4 = llvm.icmp "eq" %3, %1 : !llvm.ptr + llvm.store %2, %3 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.call @free(%3) : (!llvm.ptr) -> () + llvm.return %4 : i1 + } + llvm.func @test2() -> (!llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %4 = llvm.icmp "eq" %3, %1 : !llvm.ptr + llvm.cond_br %4, ^bb2(%1 : !llvm.ptr), ^bb1 + ^bb1: // pred: ^bb0 + llvm.store %2, %3 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.br ^bb2(%3 : !llvm.ptr) + ^bb2(%5: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + llvm.return %5 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/bcmp-1.ll.mlir b/test/LLVMDialect/InstCombine/bcmp-1.ll.mlir index a7ba8359d..b24ad9a94 100644 --- a/test/LLVMDialect/InstCombine/bcmp-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/bcmp-1.ll.mlir @@ -1,110 +1,89 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "foo", type = !llvm.array<4 x i8>, value = "foo\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hel", type = !llvm.array<4 x i8>, value = "hel\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello_u", type = !llvm.array<8 x i8>, value = "hello_u\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bcmp", type = !llvm.func, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg0, %arg1) {callee = @bcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify1", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @bcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify2", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @bcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify3", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @hello_u} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @hel} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%4, %5, %0) {callee = @bcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify4", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @foo} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @hel} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%4, %5, %0) {callee = @bcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify5", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @hel} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @foo} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%4, %5, %0) {callee = @bcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %4 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - "llvm.store"(%arg0, %3) : (i64, !llvm.ptr) -> () - "llvm.store"(%arg1, %4) : (i64, !llvm.ptr) -> () - %5 = "llvm.bitcast"(%3) : (!llvm.ptr) -> !llvm.ptr - %6 = "llvm.bitcast"(%4) : (!llvm.ptr) -> !llvm.ptr - %7 = "llvm.call"(%5, %6, %1) {callee = @bcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - %8 = "llvm.icmp"(%7, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%8) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %4 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - "llvm.store"(%arg0, %3) : (i32, !llvm.ptr) -> () - "llvm.store"(%arg1, %4) : (i32, !llvm.ptr) -> () - %5 = "llvm.bitcast"(%3) : (!llvm.ptr) -> !llvm.ptr - %6 = "llvm.bitcast"(%4) : (!llvm.ptr) -> !llvm.ptr - %7 = "llvm.call"(%5, %6, %1) {callee = @bcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - %8 = "llvm.icmp"(%7, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%8) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %4 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - "llvm.store"(%arg0, %3) : (i16, !llvm.ptr) -> () - "llvm.store"(%arg1, %4) : (i16, !llvm.ptr) -> () - %5 = "llvm.bitcast"(%3) : (!llvm.ptr) -> !llvm.ptr - %6 = "llvm.bitcast"(%4) : (!llvm.ptr) -> !llvm.ptr - %7 = "llvm.call"(%5, %6, %1) {callee = @bcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - %8 = "llvm.icmp"(%7, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%8) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify9", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @bcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify10", type = !llvm.func, ptr, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @foo("foo\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hel("hel\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hello_u("hello_u\00") {addr_space = 0 : i32} + llvm.func @bcmp(!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.func @test_simplify1(%arg0: !llvm.ptr, %arg1: i32) -> i32 { + %0 = llvm.call @bcmp(%arg0, %arg0, %arg1) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %0 : i32 + } + llvm.func @test_simplify2(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @bcmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify3(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.call @bcmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify4() -> i32 { + %0 = llvm.mlir.constant("hel\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @hel : !llvm.ptr + %2 = llvm.mlir.constant("hello_u\00") : !llvm.array<8 x i8> + %3 = llvm.mlir.addressof @hello_u : !llvm.ptr + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.call @bcmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @test_simplify5() -> i32 { + %0 = llvm.mlir.constant("hel\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @hel : !llvm.ptr + %2 = llvm.mlir.constant("foo\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.addressof @foo : !llvm.ptr + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.call @bcmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @test_simplify6() -> i32 { + %0 = llvm.mlir.constant("foo\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @foo : !llvm.ptr + %2 = llvm.mlir.constant("hel\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.addressof @hel : !llvm.ptr + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.call @bcmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @test_simplify7(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %3 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.store %arg1, %4 {alignment = 8 : i64} : i64, !llvm.ptr + %5 = llvm.call @bcmp(%3, %4, %1) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @test_simplify8(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %arg1, %4 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.call @bcmp(%3, %4, %1) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @test_simplify9(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.alloca %0 x i16 {alignment = 2 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x i16 {alignment = 2 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %3 {alignment = 2 : i64} : i16, !llvm.ptr + llvm.store %arg1, %4 {alignment = 2 : i64} : i16, !llvm.ptr + %5 = llvm.call @bcmp(%3, %4, %1) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @test_simplify10(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @bcmp(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/bcopy.ll.mlir b/test/LLVMDialect/InstCombine/bcopy.ll.mlir index 625b4de53..0ba062796 100644 --- a/test/LLVMDialect/InstCombine/bcopy.ll.mlir +++ b/test/LLVMDialect/InstCombine/bcopy.ll.mlir @@ -1,16 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bcopy", type = !llvm.func, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %0) {callee = @bcopy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bcopy_memmove", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - "llvm.call"(%arg0, %arg1, %arg2) {callee = @bcopy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bcopy_memmove2", type = !llvm.func, ptr, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bcopy(!llvm.ptr {llvm.nocapture, llvm.readonly}, !llvm.ptr {llvm.nocapture}, i32) + llvm.func @bcopy_memmove(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture}) { + %0 = llvm.mlir.constant(8 : i32) : i32 + llvm.call @bcopy(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @bcopy_memmove2(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture}, %arg2: i32) { + llvm.call @bcopy(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/binop-and-shifts.ll.mlir b/test/LLVMDialect/InstCombine/binop-and-shifts.ll.mlir new file mode 100644 index 000000000..ef8602e1d --- /dev/null +++ b/test/LLVMDialect/InstCombine/binop-and-shifts.ll.mlir @@ -0,0 +1,620 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @shl_and_and(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(88 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.shl %arg1, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.and %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @shl_and_and_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.mlir.constant(88 : i8) : i8 + %3 = llvm.shl %arg0, %0 : i8 + %4 = llvm.shl %arg1, %1 : i8 + %5 = llvm.and %4, %2 : i8 + %6 = llvm.and %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @shl_add_add(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(48 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.shl %arg1, %0 : i8 + %4 = llvm.add %3, %1 : i8 + %5 = llvm.add %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @shl_add_add_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(48 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.lshr %arg1, %0 : i8 + %4 = llvm.add %3, %1 : i8 + %5 = llvm.add %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @shl_and_and_fail2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(88 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + %3 = llvm.shl %0, %arg1 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.and %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_and_or(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[4, 5]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[44, 99]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %arg0, %0 : vector<2xi8> + %3 = llvm.lshr %arg1, %0 : vector<2xi8> + %4 = llvm.and %2, %1 : vector<2xi8> + %5 = llvm.or %3, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @lshr_and_or_fail(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[4, 5]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[5, 4]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<[44, 99]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.lshr %arg0, %0 : vector<2xi8> + %4 = llvm.lshr %arg1, %1 : vector<2xi8> + %5 = llvm.and %4, %2 : vector<2xi8> + %6 = llvm.or %3, %5 : vector<2xi8> + llvm.return %6 : vector<2xi8> + } + llvm.func @shl_and_xor(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.shl %arg1, %0 : i8 + %4 = llvm.and %2, %1 : i8 + %5 = llvm.xor %3, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @shl_and_add(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(119 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.shl %arg1, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.add %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @shl_xor_add_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(119 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.shl %arg1, %0 : i8 + %4 = llvm.xor %3, %1 : i8 + %5 = llvm.add %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_or_and(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-58 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.lshr %arg1, %0 : i8 + %4 = llvm.or %2, %1 : i8 + %5 = llvm.and %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_or_or_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-58 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.lshr %arg1, %0 : i8 + %4 = llvm.or %3, %1 : i8 + %5 = llvm.or %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @shl_xor_and(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(44 : i8) : i8 + %8 = llvm.mlir.undef : vector<2xi8> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi8> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi8> + %13 = llvm.shl %arg0, %6 : vector<2xi8> + %14 = llvm.shl %arg1, %6 : vector<2xi8> + %15 = llvm.xor %14, %12 : vector<2xi8> + %16 = llvm.and %15, %13 : vector<2xi8> + llvm.return %16 : vector<2xi8> + } + llvm.func @shl_xor_and_fail(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.undef : vector<2xi8> + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<2xi8> + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<2xi8> + %12 = llvm.mlir.constant(44 : i8) : i8 + %13 = llvm.mlir.undef : vector<2xi8> + %14 = llvm.mlir.constant(0 : i32) : i32 + %15 = llvm.insertelement %12, %13[%14 : i32] : vector<2xi8> + %16 = llvm.mlir.constant(1 : i32) : i32 + %17 = llvm.insertelement %0, %15[%16 : i32] : vector<2xi8> + %18 = llvm.shl %arg0, %6 : vector<2xi8> + %19 = llvm.shl %arg1, %11 : vector<2xi8> + %20 = llvm.xor %19, %17 : vector<2xi8> + %21 = llvm.and %18, %20 : vector<2xi8> + llvm.return %21 : vector<2xi8> + } + llvm.func @lshr_or_or_no_const(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg2 : i8 + %1 = llvm.lshr %arg1, %arg2 : i8 + %2 = llvm.or %1, %arg3 : i8 + %3 = llvm.or %0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @lshr_or_or_no_const_fail(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 : i8 + %1 = llvm.lshr %arg1, %arg2 : i8 + %2 = llvm.or %1, %arg3 : i8 + %3 = llvm.or %0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @shl_xor_xor_no_const(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 : i8 + %1 = llvm.shl %arg1, %arg2 : i8 + %2 = llvm.xor %1, %arg3 : i8 + %3 = llvm.xor %0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @shl_xor_and_no_const_fail(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 : i8 + %1 = llvm.shl %arg1, %arg2 : i8 + %2 = llvm.xor %1, %arg3 : i8 + %3 = llvm.and %0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @shl_and_and_no_const(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.shl %arg0, %arg2 : vector<2xi8> + %1 = llvm.shl %arg1, %arg2 : vector<2xi8> + %2 = llvm.and %1, %arg3 : vector<2xi8> + %3 = llvm.and %0, %2 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @shl_add_add_no_const(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 : i8 + %1 = llvm.shl %arg1, %arg2 : i8 + %2 = llvm.add %1, %arg3 : i8 + %3 = llvm.add %0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @lshr_add_add_no_const_fail(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg2 : i8 + %1 = llvm.lshr %arg1, %arg2 : i8 + %2 = llvm.add %1, %arg3 : i8 + %3 = llvm.add %0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @lshr_add_and(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[3, 4]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-1, 1]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %arg0, %0 : vector<2xi8> + %3 = llvm.lshr %arg1, %0 : vector<2xi8> + %4 = llvm.add %3, %1 : vector<2xi8> + %5 = llvm.and %2, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @lshr_add_or_fail_dif_masks(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[3, 4]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mlir.constant(dense<[-1, 1]> : vector<2xi8>) : vector<2xi8> + %9 = llvm.lshr %arg0, %0 : vector<2xi8> + %10 = llvm.lshr %arg1, %7 : vector<2xi8> + %11 = llvm.add %10, %8 : vector<2xi8> + %12 = llvm.and %9, %11 : vector<2xi8> + llvm.return %12 : vector<2xi8> + } + llvm.func @shl_or_or_good_mask(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[18, 24]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.shl %arg1, %0 : vector<2xi8> + %4 = llvm.or %3, %1 : vector<2xi8> + %5 = llvm.or %2, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @shl_or_or_fail_bad_mask(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[19, 24]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.shl %arg1, %0 : vector<2xi8> + %4 = llvm.or %3, %1 : vector<2xi8> + %5 = llvm.or %2, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @lshr_xor_or_good_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(48 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.lshr %arg1, %0 : i8 + %4 = llvm.xor %3, %1 : i8 + %5 = llvm.or %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_xor_or_fail_bad_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.lshr %arg1, %0 : i8 + %4 = llvm.xor %3, %1 : i8 + %5 = llvm.or %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_or_xor_good_mask(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[3, 1]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %arg0, %0 : vector<2xi8> + %3 = llvm.lshr %arg1, %0 : vector<2xi8> + %4 = llvm.or %3, %1 : vector<2xi8> + %5 = llvm.xor %2, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @lshr_or_xor_fail_bad_mask(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[7, 1]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %arg0, %0 : vector<2xi8> + %3 = llvm.lshr %arg1, %0 : vector<2xi8> + %4 = llvm.or %3, %1 : vector<2xi8> + %5 = llvm.xor %2, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @shl_xor_xor_good_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(88 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.shl %arg1, %0 : i8 + %4 = llvm.xor %3, %1 : i8 + %5 = llvm.xor %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @shl_xor_xor_bad_mask_distribute(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-68 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.shl %arg1, %0 : i8 + %4 = llvm.xor %3, %1 : i8 + %5 = llvm.xor %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @shl_add_and(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.shl %arg1, %0 : i8 + %4 = llvm.add %3, %1 : i8 + %5 = llvm.and %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_and_add_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.lshr %arg1, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.add %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_add_or_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.lshr %arg1, %0 : i8 + %4 = llvm.add %3, %1 : i8 + %5 = llvm.or %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_add_xor_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.lshr %arg1, %0 : i8 + %4 = llvm.add %3, %1 : i8 + %5 = llvm.xor %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_and_add(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[4, 5]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-67, 123]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.shl %arg1, %0 : vector<2xi8> + %4 = llvm.and %2, %1 : vector<2xi8> + %5 = llvm.add %3, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @lshr_or_add_fail(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[4, 5]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-67, 123]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.shl %arg1, %0 : vector<2xi8> + %4 = llvm.or %2, %1 : vector<2xi8> + %5 = llvm.add %3, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @shl_add_and_fail_mismatch_shift(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.lshr %arg1, %0 : i8 + %4 = llvm.add %3, %1 : i8 + %5 = llvm.and %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @and_ashr_not(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.ashr %arg0, %arg2 : i8 + %2 = llvm.ashr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.and %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @and_ashr_not_commuted(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.ashr %arg0, %arg2 : i8 + %2 = llvm.ashr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @and_ashr_not_fail_lshr_ashr(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %arg0, %arg2 : i8 + %2 = llvm.ashr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.and %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @and_ashr_not_fail_ashr_lshr(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.ashr %arg0, %arg2 : i8 + %2 = llvm.lshr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.and %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @and_ashr_not_fail_invalid_xor_constant(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.ashr %arg0, %arg2 : i8 + %2 = llvm.ashr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.and %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @and_ashr_not_vec(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.ashr %arg0, %arg2 : vector<4xi8> + %2 = llvm.ashr %arg1, %arg2 : vector<4xi8> + %3 = llvm.xor %2, %0 : vector<4xi8> + %4 = llvm.and %1, %3 : vector<4xi8> + llvm.return %4 : vector<4xi8> + } + llvm.func @and_ashr_not_vec_commuted(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.ashr %arg0, %arg2 : vector<4xi8> + %2 = llvm.ashr %arg1, %arg2 : vector<4xi8> + %3 = llvm.xor %2, %0 : vector<4xi8> + %4 = llvm.and %3, %1 : vector<4xi8> + llvm.return %4 : vector<4xi8> + } + llvm.func @and_ashr_not_vec_poison_1(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.undef : vector<4xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<4xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xi8> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi8> + %11 = llvm.ashr %arg0, %arg2 : vector<4xi8> + %12 = llvm.ashr %arg1, %arg2 : vector<4xi8> + %13 = llvm.xor %12, %10 : vector<4xi8> + %14 = llvm.and %11, %13 : vector<4xi8> + llvm.return %14 : vector<4xi8> + } + llvm.func @and_ashr_not_vec_poison_2(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.ashr %arg0, %arg2 : vector<4xi8> + %2 = llvm.ashr %arg1, %arg2 : vector<4xi8> + %3 = llvm.xor %2, %0 : vector<4xi8> + %4 = llvm.and %1, %3 : vector<4xi8> + llvm.return %4 : vector<4xi8> + } + llvm.func @or_ashr_not(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.ashr %arg0, %arg2 : i8 + %2 = llvm.ashr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.or %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @or_ashr_not_commuted(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.ashr %arg0, %arg2 : i8 + %2 = llvm.ashr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.or %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @or_ashr_not_fail_lshr_ashr(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %arg0, %arg2 : i8 + %2 = llvm.ashr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.or %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @or_ashr_not_fail_ashr_lshr(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.ashr %arg0, %arg2 : i8 + %2 = llvm.lshr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.or %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @or_ashr_not_fail_invalid_xor_constant(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.ashr %arg0, %arg2 : i8 + %2 = llvm.ashr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.or %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @or_ashr_not_vec(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.ashr %arg0, %arg2 : vector<4xi8> + %2 = llvm.ashr %arg1, %arg2 : vector<4xi8> + %3 = llvm.xor %2, %0 : vector<4xi8> + %4 = llvm.or %1, %3 : vector<4xi8> + llvm.return %4 : vector<4xi8> + } + llvm.func @or_ashr_not_vec_commuted(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.ashr %arg0, %arg2 : vector<4xi8> + %2 = llvm.ashr %arg1, %arg2 : vector<4xi8> + %3 = llvm.xor %2, %0 : vector<4xi8> + %4 = llvm.or %3, %1 : vector<4xi8> + llvm.return %4 : vector<4xi8> + } + llvm.func @or_ashr_not_vec_poison_1(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.undef : vector<4xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<4xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xi8> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi8> + %11 = llvm.ashr %arg0, %arg2 : vector<4xi8> + %12 = llvm.ashr %arg1, %arg2 : vector<4xi8> + %13 = llvm.xor %12, %10 : vector<4xi8> + %14 = llvm.or %11, %13 : vector<4xi8> + llvm.return %14 : vector<4xi8> + } + llvm.func @or_ashr_not_vec_poison_2(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.ashr %arg0, %arg2 : vector<4xi8> + %2 = llvm.ashr %arg1, %arg2 : vector<4xi8> + %3 = llvm.xor %2, %0 : vector<4xi8> + %4 = llvm.or %1, %3 : vector<4xi8> + llvm.return %4 : vector<4xi8> + } + llvm.func @xor_ashr_not(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.ashr %arg0, %arg2 : i8 + %2 = llvm.ashr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.xor %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @xor_ashr_not_commuted(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.ashr %arg0, %arg2 : i8 + %2 = llvm.ashr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.xor %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @xor_ashr_not_fail_lshr_ashr(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %arg0, %arg2 : i8 + %2 = llvm.ashr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.xor %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @xor_ashr_not_fail_ashr_lshr(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.ashr %arg0, %arg2 : i8 + %2 = llvm.lshr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.xor %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @xor_ashr_not_fail_invalid_xor_constant(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.ashr %arg0, %arg2 : i8 + %2 = llvm.ashr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.xor %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @xor_ashr_not_vec(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.ashr %arg0, %arg2 : vector<4xi8> + %2 = llvm.ashr %arg1, %arg2 : vector<4xi8> + %3 = llvm.xor %2, %0 : vector<4xi8> + %4 = llvm.xor %1, %3 : vector<4xi8> + llvm.return %4 : vector<4xi8> + } + llvm.func @xor_ashr_not_vec_commuted(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.ashr %arg0, %arg2 : vector<4xi8> + %2 = llvm.ashr %arg1, %arg2 : vector<4xi8> + %3 = llvm.xor %2, %0 : vector<4xi8> + %4 = llvm.xor %3, %1 : vector<4xi8> + llvm.return %4 : vector<4xi8> + } + llvm.func @xor_ashr_not_vec_poison_1(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.undef : vector<4xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<4xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xi8> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi8> + %11 = llvm.ashr %arg0, %arg2 : vector<4xi8> + %12 = llvm.ashr %arg1, %arg2 : vector<4xi8> + %13 = llvm.xor %12, %10 : vector<4xi8> + %14 = llvm.xor %11, %13 : vector<4xi8> + llvm.return %14 : vector<4xi8> + } + llvm.func @xor_ashr_not_vec_poison_2(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.ashr %arg0, %arg2 : vector<4xi8> + %2 = llvm.ashr %arg1, %arg2 : vector<4xi8> + %3 = llvm.xor %2, %0 : vector<4xi8> + %4 = llvm.xor %1, %3 : vector<4xi8> + llvm.return %4 : vector<4xi8> + } + llvm.func @binop_ashr_not_fail_invalid_binop(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.ashr %arg0, %arg2 : i8 + %2 = llvm.ashr %arg1, %arg2 : i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.add %1, %3 : i8 + llvm.return %4 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/binop-cast.ll.mlir b/test/LLVMDialect/InstCombine/binop-cast.ll.mlir index 4c755aaa2..234b51854 100644 --- a/test/LLVMDialect/InstCombine/binop-cast.ll.mlir +++ b/test/LLVMDialect/InstCombine/binop-cast.ll.mlir @@ -1,116 +1,179 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.bitcast"(%0) : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "testAdd", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i1): // no predecessors - %0 = "llvm.sext"(%arg1) : (i1) -> i32 - %1 = "llvm.and"(%0, %arg0) : (i32, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "and_sext_to_sel", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi1>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[42, -7]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sext"(%arg0) : (vector<2xi1>) -> vector<2xi32> - %2 = "llvm.and"(%0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "and_sext_to_sel_constant_vec", type = !llvm.func (vector<2xi1>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>, %arg1: vector<2xi1>): // no predecessors - %0 = "llvm.mul"(%arg0, %arg0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %1 = "llvm.sext"(%arg1) : (vector<2xi1>) -> vector<2xi32> - %2 = "llvm.and"(%0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "and_sext_to_sel_swap", type = !llvm.func (vector<2xi32>, vector<2xi1>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i1): // no predecessors - %0 = "llvm.sext"(%arg1) : (i1) -> i32 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %1 = "llvm.and"(%0, %arg0) : (i32, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "and_sext_to_sel_multi_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %1 = "llvm.sext"(%arg0) : (i1) -> i32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %2 = "llvm.and"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "and_sext_to_sel_multi_use_constant_mask", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i1): // no predecessors - %0 = "llvm.sext"(%arg1) : (i1) -> i32 - %1 = "llvm.or"(%0, %arg0) : (i32, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "or_sext_to_sel", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi1>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[42, -7]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sext"(%arg0) : (vector<2xi1>) -> vector<2xi32> - %2 = "llvm.or"(%0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "or_sext_to_sel_constant_vec", type = !llvm.func (vector<2xi1>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>, %arg1: vector<2xi1>): // no predecessors - %0 = "llvm.mul"(%arg0, %arg0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %1 = "llvm.sext"(%arg1) : (vector<2xi1>) -> vector<2xi32> - %2 = "llvm.or"(%0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "or_sext_to_sel_swap", type = !llvm.func (vector<2xi32>, vector<2xi1>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i1): // no predecessors - %0 = "llvm.sext"(%arg1) : (i1) -> i32 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %1 = "llvm.or"(%0, %arg0) : (i32, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "or_sext_to_sel_multi_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %1 = "llvm.sext"(%arg0) : (i1) -> i32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %2 = "llvm.or"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "or_sext_to_sel_multi_use_constant_mask", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i1): // no predecessors - %0 = "llvm.sext"(%arg1) : (i1) -> i32 - %1 = "llvm.xor"(%0, %arg0) : (i32, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_sext_to_sel", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi1>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[42, -7]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sext"(%arg0) : (vector<2xi1>) -> vector<2xi32> - %2 = "llvm.xor"(%0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "xor_sext_to_sel_constant_vec", type = !llvm.func (vector<2xi1>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>, %arg1: vector<2xi1>): // no predecessors - %0 = "llvm.mul"(%arg0, %arg0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %1 = "llvm.sext"(%arg1) : (vector<2xi1>) -> vector<2xi32> - %2 = "llvm.xor"(%0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "xor_sext_to_sel_swap", type = !llvm.func (vector<2xi32>, vector<2xi1>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i1): // no predecessors - %0 = "llvm.sext"(%arg1) : (i1) -> i32 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %1 = "llvm.xor"(%0, %arg0) : (i32, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_sext_to_sel_multi_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %1 = "llvm.sext"(%arg0) : (i1) -> i32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %2 = "llvm.xor"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_sext_to_sel_multi_use_constant_mask", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @use_vec(vector<2xi32>) + llvm.func @testAdd(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.add %arg0, %arg1 : i32 + %1 = llvm.bitcast %0 : i32 to i32 + llvm.return %1 : i32 + } + llvm.func @and_sext_to_sel(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.sext %arg1 : i1 to i32 + %1 = llvm.and %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @and_sext_to_sel_constant_vec(%arg0: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, -7]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.and %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @and_sext_to_sel_swap(%arg0: vector<2xi32>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mul %arg0, %arg0 : vector<2xi32> + %1 = llvm.sext %arg1 : vector<2xi1> to vector<2xi32> + %2 = llvm.and %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @and_sext_to_sel_multi_use(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.sext %arg1 : i1 to i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.and %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @and_sext_to_sel_multi_use_constant_mask(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.and %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @and_not_sext_to_sel(%arg0: vector<2xi32>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg1 : vector<2xi1> to vector<2xi32> + llvm.call @use_vec(%1) : (vector<2xi32>) -> () + %2 = llvm.xor %1, %0 : vector<2xi32> + %3 = llvm.and %2, %arg0 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @and_not_sext_to_sel_commute(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mul %arg0, %arg0 : i32 + %2 = llvm.sext %arg1 : i1 to i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.xor %2, %0 : i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.and %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @and_xor_sext_to_sel(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.sext %arg1 : i1 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @and_not_zext_to_sel(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg1 : i1 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @or_sext_to_sel(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.sext %arg1 : i1 to i32 + %1 = llvm.or %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @or_sext_to_sel_constant_vec(%arg0: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, -7]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.or %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @or_sext_to_sel_swap(%arg0: vector<2xi32>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mul %arg0, %arg0 : vector<2xi32> + %1 = llvm.sext %arg1 : vector<2xi1> to vector<2xi32> + %2 = llvm.or %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @or_sext_to_sel_multi_use(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.sext %arg1 : i1 to i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.or %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @or_sext_to_sel_multi_use_constant_mask(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.or %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_sext_to_sel(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.sext %arg1 : i1 to i32 + %1 = llvm.xor %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @xor_sext_to_sel_constant_vec(%arg0: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, -7]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.xor %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @xor_sext_to_sel_swap(%arg0: vector<2xi32>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mul %arg0, %arg0 : vector<2xi32> + %1 = llvm.sext %arg1 : vector<2xi1> to vector<2xi32> + %2 = llvm.xor %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @xor_sext_to_sel_multi_use(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.sext %arg1 : i1 to i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.xor %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @xor_sext_to_sel_multi_use_constant_mask(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.xor %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @PR63321(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %2 = llvm.zext %1 : i8 to i64 + %3 = llvm.add %0, %2 : i64 + %4 = llvm.and %3, %arg1 : i64 + llvm.return %4 : i64 + } + llvm.func @and_add_non_bool(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %2 = llvm.zext %1 : i8 to i64 + %3 = llvm.add %0, %2 : i64 + %4 = llvm.and %3, %arg1 : i64 + llvm.return %4 : i64 + } + llvm.func @and_add_bool_to_select(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.add %0, %1 : i32 + %3 = llvm.and %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @and_add_bool_no_fold(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.and %3, %arg0 : i32 + llvm.return %4 : i32 + } + llvm.func @and_add_bool_vec_to_select(%arg0: vector<2xi1>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.add %0, %1 : vector<2xi32> + %3 = llvm.and %2, %arg1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @and_add_bool_to_select_multi_use(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.add %0, %1 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.add %3, %2 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/binop-itofp.ll.mlir b/test/LLVMDialect/InstCombine/binop-itofp.ll.mlir new file mode 100644 index 000000000..5a4aac925 --- /dev/null +++ b/test/LLVMDialect/InstCombine/binop-itofp.ll.mlir @@ -0,0 +1,717 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_ui_ui_i8_add(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.uitofp %1 : i8 to f16 + %4 = llvm.uitofp %2 : i8 to f16 + %5 = llvm.fadd %3, %4 : f16 + llvm.return %5 : f16 + } + llvm.func @test_ui_ui_i8_add_fail_overflow(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.uitofp %2 : i8 to f16 + %5 = llvm.uitofp %3 : i8 to f16 + %6 = llvm.fadd %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_ui_ui_i8_add_C(%arg0: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(1.280000e+02 : f16) : f16 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.uitofp %2 : i8 to f16 + %4 = llvm.fadd %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_ui_ui_i8_add_C_fail_no_repr(%arg0: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(1.275000e+02 : f16) : f16 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.uitofp %2 : i8 to f16 + %4 = llvm.fadd %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_ui_ui_i8_add_C_fail_overflow(%arg0: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(1.290000e+02 : f16) : f16 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.uitofp %2 : i8 to f16 + %4 = llvm.fadd %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_si_si_i8_add(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.or %arg1, %0 : i8 + %3 = llvm.sitofp %1 : i8 to f16 + %4 = llvm.sitofp %2 : i8 to f16 + %5 = llvm.fadd %3, %4 : f16 + llvm.return %5 : f16 + } + llvm.func @test_si_si_i8_add_fail_overflow(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.mlir.constant(-65 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.or %arg1, %1 : i8 + %4 = llvm.sitofp %2 : i8 to f16 + %5 = llvm.sitofp %3 : i8 to f16 + %6 = llvm.fadd %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_ui_si_i8_add(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(63 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.sitofp %1 : i8 to f16 + %4 = llvm.uitofp %2 : i8 to f16 + %5 = llvm.fadd %3, %4 : f16 + llvm.return %5 : f16 + } + llvm.func @test_ui_si_i8_add_overflow(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(63 : i8) : i8 + %1 = llvm.mlir.constant(65 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.sitofp %2 : i8 to f16 + %5 = llvm.uitofp %3 : i8 to f16 + %6 = llvm.fadd %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_ui_ui_i8_sub_C(%arg0: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(1.280000e+02 : f16) : f16 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.uitofp %2 : i8 to f16 + %4 = llvm.fsub %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_ui_ui_i8_sub_C_fail_overflow(%arg0: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(1.280000e+02 : f16) : f16 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.uitofp %2 : i8 to f16 + %4 = llvm.fsub %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_si_si_i8_sub(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(63 : i8) : i8 + %1 = llvm.mlir.constant(-64 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.or %arg1, %1 : i8 + %4 = llvm.sitofp %2 : i8 to f16 + %5 = llvm.sitofp %3 : i8 to f16 + %6 = llvm.fsub %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_si_si_i8_sub_fail_overflow(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(63 : i8) : i8 + %1 = llvm.mlir.constant(-65 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.or %arg1, %1 : i8 + %4 = llvm.sitofp %2 : i8 to f16 + %5 = llvm.sitofp %3 : i8 to f16 + %6 = llvm.fsub %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_si_si_i8_sub_C(%arg0: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(63 : i8) : i8 + %1 = llvm.mlir.constant(-6.400000e+01 : f16) : f16 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.sitofp %2 : i8 to f16 + %4 = llvm.fsub %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_si_si_i8_sub_C_fail_overflow(%arg0: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(65 : i8) : i8 + %1 = llvm.mlir.constant(-6.400000e+01 : f16) : f16 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.sitofp %2 : i8 to f16 + %4 = llvm.fsub %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_ui_si_i8_sub(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(64 : i8) : i8 + %1 = llvm.mlir.constant(63 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.sitofp %2 : i8 to f16 + %5 = llvm.uitofp %3 : i8 to f16 + %6 = llvm.fsub %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_ui_si_i8_sub_fail_maybe_sign(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(64 : i8) : i8 + %1 = llvm.mlir.constant(63 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.uitofp %2 : i8 to f16 + %5 = llvm.sitofp %3 : i8 to f16 + %6 = llvm.fsub %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_ui_ui_i8_mul(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.uitofp %1 : i8 to f16 + %4 = llvm.uitofp %2 : i8 to f16 + %5 = llvm.fmul %3, %4 : f16 + llvm.return %5 : f16 + } + llvm.func @test_ui_ui_i8_mul_C(%arg0: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(1.600000e+01 : f16) : f16 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.uitofp %2 : i8 to f16 + %4 = llvm.fmul %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_ui_ui_i8_mul_C_fail_overlow(%arg0: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(14 : i8) : i8 + %1 = llvm.mlir.constant(1.900000e+01 : f16) : f16 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.uitofp %2 : i8 to f16 + %4 = llvm.fmul %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_si_si_i8_mul(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(-8 : i8) : i8 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.add %3, %1 overflow : i8 + %5 = llvm.or %arg1, %2 : i8 + %6 = llvm.sitofp %4 : i8 to f16 + %7 = llvm.sitofp %5 : i8 to f16 + %8 = llvm.fmul %6, %7 : f16 + llvm.return %8 : f16 + } + llvm.func @test_si_si_i8_mul_fail_maybe_zero(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-8 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.or %arg1, %1 : i8 + %4 = llvm.sitofp %2 : i8 to f16 + %5 = llvm.sitofp %3 : i8 to f16 + %6 = llvm.fmul %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_si_si_i8_mul_C_fail_no_repr(%arg0: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(-7.500000e+00 : f16) : f16 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.add %3, %1 overflow : i8 + %5 = llvm.sitofp %4 : i8 to f16 + %6 = llvm.fmul %5, %2 : f16 + llvm.return %6 : f16 + } + llvm.func @test_si_si_i8_mul_C_fail_overflow(%arg0: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(-1.900000e+01 : f16) : f16 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.add %3, %1 overflow : i8 + %5 = llvm.sitofp %4 : i8 to f16 + %6 = llvm.fmul %5, %2 : f16 + llvm.return %6 : f16 + } + llvm.func @test_ui_si_i8_mul(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.add %3, %1 : i8 + %5 = llvm.and %arg1, %2 : i8 + %6 = llvm.add %5, %1 : i8 + %7 = llvm.sitofp %4 : i8 to f16 + %8 = llvm.uitofp %6 : i8 to f16 + %9 = llvm.fmul %7, %8 : f16 + llvm.return %9 : f16 + } + llvm.func @test_ui_si_i8_mul_fail_maybe_zero(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.add %2, %1 : i8 + %4 = llvm.and %arg1, %0 : i8 + %5 = llvm.sitofp %3 : i8 to f16 + %6 = llvm.uitofp %4 : i8 to f16 + %7 = llvm.fmul %5, %6 : f16 + llvm.return %7 : f16 + } + llvm.func @test_ui_si_i8_mul_fail_signed(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(-4 : i8) : i8 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.add %3, %1 : i8 + %5 = llvm.or %arg1, %2 : i8 + %6 = llvm.sitofp %4 : i8 to f16 + %7 = llvm.uitofp %5 : i8 to f16 + %8 = llvm.fmul %6, %7 : f16 + llvm.return %8 : f16 + } + llvm.func @test_ui_ui_i16_add(%arg0: i16 {llvm.noundef}, %arg1: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(2047 : i16) : i16 + %1 = llvm.and %arg0, %0 : i16 + %2 = llvm.and %arg1, %0 : i16 + %3 = llvm.uitofp %1 : i16 to f16 + %4 = llvm.uitofp %2 : i16 to f16 + %5 = llvm.fadd %3, %4 : f16 + llvm.return %5 : f16 + } + llvm.func @test_ui_ui_i16_add_fail_not_promotable(%arg0: i16 {llvm.noundef}, %arg1: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(2049 : i16) : i16 + %1 = llvm.mlir.constant(2047 : i16) : i16 + %2 = llvm.and %arg0, %0 : i16 + %3 = llvm.and %arg1, %1 : i16 + %4 = llvm.uitofp %2 : i16 to f16 + %5 = llvm.uitofp %3 : i16 to f16 + %6 = llvm.fadd %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_ui_ui_i16_add_C(%arg0: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(2047 : i16) : i16 + %1 = llvm.mlir.constant(6.348800e+04 : f16) : f16 + %2 = llvm.and %arg0, %0 : i16 + %3 = llvm.uitofp %2 : i16 to f16 + %4 = llvm.fadd %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_ui_ui_i16_add_C_fail_overflow(%arg0: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(2047 : i16) : i16 + %1 = llvm.mlir.constant(6.400000e+04 : f16) : f16 + %2 = llvm.and %arg0, %0 : i16 + %3 = llvm.uitofp %2 : i16 to f16 + %4 = llvm.fadd %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_si_si_i16_add(%arg0: i16 {llvm.noundef}, %arg1: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-2048 : i16) : i16 + %1 = llvm.or %arg0, %0 : i16 + %2 = llvm.or %arg1, %0 : i16 + %3 = llvm.sitofp %1 : i16 to f16 + %4 = llvm.sitofp %2 : i16 to f16 + %5 = llvm.fadd %3, %4 : f16 + llvm.return %5 : f16 + } + llvm.func @test_si_si_i16_add_fail_no_promotion(%arg0: i16 {llvm.noundef}, %arg1: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-2048 : i16) : i16 + %1 = llvm.mlir.constant(1 : i16) : i16 + %2 = llvm.or %arg0, %0 : i16 + %3 = llvm.sub %2, %1 : i16 + %4 = llvm.or %arg1, %0 : i16 + %5 = llvm.sitofp %3 : i16 to f16 + %6 = llvm.sitofp %4 : i16 to f16 + %7 = llvm.fadd %5, %6 : f16 + llvm.return %7 : f16 + } + llvm.func @test_si_si_i16_add_C_overflow(%arg0: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-2048 : i16) : i16 + %1 = llvm.mlir.constant(3.481600e+04 : f16) : f16 + %2 = llvm.or %arg0, %0 : i16 + %3 = llvm.sitofp %2 : i16 to f16 + %4 = llvm.fadd %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_si_si_i16_sub(%arg0: i16 {llvm.noundef}, %arg1: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-2048 : i16) : i16 + %1 = llvm.mlir.constant(2047 : i16) : i16 + %2 = llvm.or %arg0, %0 : i16 + %3 = llvm.and %arg1, %1 : i16 + %4 = llvm.sitofp %2 : i16 to f16 + %5 = llvm.sitofp %3 : i16 to f16 + %6 = llvm.fsub %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_si_si_i16_sub_fail_no_promotion(%arg0: i16 {llvm.noundef}, %arg1: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(2047 : i16) : i16 + %1 = llvm.mlir.constant(-2049 : i16) : i16 + %2 = llvm.and %arg0, %0 : i16 + %3 = llvm.or %arg1, %1 : i16 + %4 = llvm.sitofp %2 : i16 to f16 + %5 = llvm.sitofp %3 : i16 to f16 + %6 = llvm.fsub %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_ui_si_i16_sub(%arg0: i16 {llvm.noundef}, %arg1: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(2047 : i16) : i16 + %1 = llvm.and %arg0, %0 : i16 + %2 = llvm.and %arg1, %0 : i16 + %3 = llvm.uitofp %1 : i16 to f16 + %4 = llvm.sitofp %2 : i16 to f16 + %5 = llvm.fsub %3, %4 : f16 + llvm.return %5 : f16 + } + llvm.func @test_ui_si_i16_sub_fail_maybe_signed(%arg0: i16 {llvm.noundef}, %arg1: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-2048 : i16) : i16 + %1 = llvm.mlir.constant(2047 : i16) : i16 + %2 = llvm.or %arg0, %0 : i16 + %3 = llvm.and %arg1, %1 : i16 + %4 = llvm.uitofp %2 : i16 to f16 + %5 = llvm.sitofp %3 : i16 to f16 + %6 = llvm.fsub %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_ui_ui_i16_mul(%arg0: i16 {llvm.noundef}, %arg1: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(255 : i16) : i16 + %1 = llvm.and %arg0, %0 : i16 + %2 = llvm.and %arg1, %0 : i16 + %3 = llvm.uitofp %1 : i16 to f16 + %4 = llvm.uitofp %2 : i16 to f16 + %5 = llvm.fmul %3, %4 : f16 + llvm.return %5 : f16 + } + llvm.func @test_ui_ui_i16_mul_fail_no_promotion(%arg0: i16 {llvm.noundef}, %arg1: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(4095 : i16) : i16 + %1 = llvm.mlir.constant(3 : i16) : i16 + %2 = llvm.and %arg0, %0 : i16 + %3 = llvm.and %arg1, %1 : i16 + %4 = llvm.uitofp %2 : i16 to f16 + %5 = llvm.uitofp %3 : i16 to f16 + %6 = llvm.fmul %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_si_si_i16_mul(%arg0: i16 {llvm.noundef}, %arg1: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(126 : i16) : i16 + %1 = llvm.mlir.constant(1 : i16) : i16 + %2 = llvm.mlir.constant(-255 : i16) : i16 + %3 = llvm.and %arg0, %0 : i16 + %4 = llvm.add %3, %1 overflow : i16 + %5 = llvm.or %arg1, %2 : i16 + %6 = llvm.sitofp %4 : i16 to f16 + %7 = llvm.sitofp %5 : i16 to f16 + %8 = llvm.fmul %6, %7 : f16 + llvm.return %8 : f16 + } + llvm.func @test_si_si_i16_mul_fail_overflow(%arg0: i16 {llvm.noundef}, %arg1: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(126 : i16) : i16 + %1 = llvm.mlir.constant(1 : i16) : i16 + %2 = llvm.mlir.constant(-257 : i16) : i16 + %3 = llvm.and %arg0, %0 : i16 + %4 = llvm.add %3, %1 overflow : i16 + %5 = llvm.or %arg1, %2 : i16 + %6 = llvm.sitofp %4 : i16 to f16 + %7 = llvm.sitofp %5 : i16 to f16 + %8 = llvm.fmul %6, %7 : f16 + llvm.return %8 : f16 + } + llvm.func @test_si_si_i16_mul_C_fail_overflow(%arg0: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-129 : i16) : i16 + %1 = llvm.mlir.constant(1.280000e+02 : f16) : f16 + %2 = llvm.or %arg0, %0 : i16 + %3 = llvm.sitofp %2 : i16 to f16 + %4 = llvm.fmul %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_si_si_i16_mul_C_fail_no_promotion(%arg0: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-4097 : i16) : i16 + %1 = llvm.mlir.constant(5.000000e+00 : f16) : f16 + %2 = llvm.or %arg0, %0 : i16 + %3 = llvm.sitofp %2 : i16 to f16 + %4 = llvm.fmul %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_ui_si_i16_mul(%arg0: i16 {llvm.noundef}, %arg1: i16 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(126 : i16) : i16 + %1 = llvm.mlir.constant(1 : i16) : i16 + %2 = llvm.and %arg0, %0 : i16 + %3 = llvm.add %2, %1 : i16 + %4 = llvm.and %arg1, %0 : i16 + %5 = llvm.add %4, %1 : i16 + %6 = llvm.sitofp %3 : i16 to f16 + %7 = llvm.uitofp %5 : i16 to f16 + %8 = llvm.fmul %6, %7 : f16 + llvm.return %8 : f16 + } + llvm.func @test_ui_ui_i12_add(%arg0: i12 {llvm.noundef}, %arg1: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(2047 : i12) : i12 + %1 = llvm.and %arg0, %0 : i12 + %2 = llvm.and %arg1, %0 : i12 + %3 = llvm.uitofp %1 : i12 to f16 + %4 = llvm.uitofp %2 : i12 to f16 + %5 = llvm.fadd %3, %4 : f16 + llvm.return %5 : f16 + } + llvm.func @test_ui_ui_i12_add_fail_overflow(%arg0: i12 {llvm.noundef}, %arg1: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(2047 : i12) : i12 + %1 = llvm.mlir.constant(-2047 : i12) : i12 + %2 = llvm.and %arg0, %0 : i12 + %3 = llvm.and %arg1, %1 : i12 + %4 = llvm.uitofp %2 : i12 to f16 + %5 = llvm.uitofp %3 : i12 to f16 + %6 = llvm.fadd %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_si_si_i12_add(%arg0: i12 {llvm.noundef}, %arg1: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-1024 : i12) : i12 + %1 = llvm.or %arg0, %0 : i12 + %2 = llvm.or %arg1, %0 : i12 + %3 = llvm.sitofp %1 : i12 to f16 + %4 = llvm.sitofp %2 : i12 to f16 + %5 = llvm.fadd %3, %4 : f16 + llvm.return %5 : f16 + } + llvm.func @test_si_si_i12_add_fail_overflow(%arg0: i12 {llvm.noundef}, %arg1: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-1025 : i12) : i12 + %1 = llvm.or %arg0, %0 : i12 + %2 = llvm.or %arg1, %0 : i12 + %3 = llvm.sitofp %1 : i12 to f16 + %4 = llvm.sitofp %2 : i12 to f16 + %5 = llvm.fadd %3, %4 : f16 + llvm.return %5 : f16 + } + llvm.func @test_si_si_i12_add_C_fail_overflow(%arg0: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-2048 : i12) : i12 + %1 = llvm.mlir.constant(-1.000000e+00 : f16) : f16 + %2 = llvm.or %arg0, %0 : i12 + %3 = llvm.sitofp %2 : i12 to f16 + %4 = llvm.fadd %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_ui_ui_i12_sub(%arg0: i12 {llvm.noundef}, %arg1: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(1023 : i12) : i12 + %1 = llvm.and %arg0, %0 : i12 + %2 = llvm.and %arg1, %0 : i12 + %3 = llvm.uitofp %1 : i12 to f16 + %4 = llvm.uitofp %2 : i12 to f16 + %5 = llvm.fsub %3, %4 : f16 + llvm.return %5 : f16 + } + llvm.func @test_ui_ui_i12_sub_fail_overflow(%arg0: i12 {llvm.noundef}, %arg1: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(1023 : i12) : i12 + %1 = llvm.mlir.constant(2047 : i12) : i12 + %2 = llvm.and %arg0, %0 : i12 + %3 = llvm.and %arg1, %1 : i12 + %4 = llvm.uitofp %2 : i12 to f16 + %5 = llvm.uitofp %3 : i12 to f16 + %6 = llvm.fsub %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_si_si_i12_sub(%arg0: i12 {llvm.noundef}, %arg1: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(1023 : i12) : i12 + %1 = llvm.mlir.constant(-1024 : i12) : i12 + %2 = llvm.and %arg0, %0 : i12 + %3 = llvm.or %arg1, %1 : i12 + %4 = llvm.sitofp %2 : i12 to f16 + %5 = llvm.sitofp %3 : i12 to f16 + %6 = llvm.fsub %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_si_si_i12_sub_fail_overflow(%arg0: i12 {llvm.noundef}, %arg1: i12 {llvm.noundef}) -> f16 { + %0 = llvm.sitofp %arg0 : i12 to f16 + %1 = llvm.sitofp %arg1 : i12 to f16 + %2 = llvm.fsub %0, %1 : f16 + llvm.return %2 : f16 + } + llvm.func @test_ui_ui_i12_mul(%arg0: i12 {llvm.noundef}, %arg1: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(31 : i12) : i12 + %1 = llvm.mlir.constant(63 : i12) : i12 + %2 = llvm.and %arg0, %0 : i12 + %3 = llvm.and %arg1, %1 : i12 + %4 = llvm.uitofp %2 : i12 to f16 + %5 = llvm.uitofp %3 : i12 to f16 + %6 = llvm.fmul %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_ui_ui_i12_mul_fail_overflow(%arg0: i12 {llvm.noundef}, %arg1: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(31 : i12) : i12 + %1 = llvm.mlir.constant(1 : i12) : i12 + %2 = llvm.mlir.constant(63 : i12) : i12 + %3 = llvm.and %arg0, %0 : i12 + %4 = llvm.add %3, %1 : i12 + %5 = llvm.and %arg1, %2 : i12 + %6 = llvm.uitofp %4 : i12 to f16 + %7 = llvm.uitofp %5 : i12 to f16 + %8 = llvm.fmul %6, %7 : f16 + llvm.return %8 : f16 + } + llvm.func @test_ui_ui_i12_mul_C(%arg0: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(31 : i12) : i12 + %1 = llvm.mlir.constant(6.400000e+01 : f16) : f16 + %2 = llvm.and %arg0, %0 : i12 + %3 = llvm.uitofp %2 : i12 to f16 + %4 = llvm.fmul %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_si_si_i12_mul(%arg0: i12 {llvm.noundef}, %arg1: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(30 : i12) : i12 + %1 = llvm.mlir.constant(1 : i12) : i12 + %2 = llvm.mlir.constant(-64 : i12) : i12 + %3 = llvm.and %arg0, %0 : i12 + %4 = llvm.add %3, %1 overflow : i12 + %5 = llvm.or %arg1, %2 : i12 + %6 = llvm.sitofp %4 : i12 to f16 + %7 = llvm.sitofp %5 : i12 to f16 + %8 = llvm.fmul %6, %7 : f16 + llvm.return %8 : f16 + } + llvm.func @test_si_si_i12_mul_fail_overflow(%arg0: i12 {llvm.noundef}, %arg1: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(30 : i12) : i12 + %1 = llvm.mlir.constant(1 : i12) : i12 + %2 = llvm.mlir.constant(-128 : i12) : i12 + %3 = llvm.and %arg0, %0 : i12 + %4 = llvm.add %3, %1 overflow : i12 + %5 = llvm.or %arg1, %2 : i12 + %6 = llvm.sitofp %4 : i12 to f16 + %7 = llvm.sitofp %5 : i12 to f16 + %8 = llvm.fmul %6, %7 : f16 + llvm.return %8 : f16 + } + llvm.func @test_si_si_i12_mul_fail_maybe_non_zero(%arg0: i12 {llvm.noundef}, %arg1: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(30 : i12) : i12 + %1 = llvm.mlir.constant(-128 : i12) : i12 + %2 = llvm.and %arg0, %0 : i12 + %3 = llvm.or %arg1, %1 : i12 + %4 = llvm.sitofp %2 : i12 to f16 + %5 = llvm.sitofp %3 : i12 to f16 + %6 = llvm.fmul %4, %5 : f16 + llvm.return %6 : f16 + } + llvm.func @test_si_si_i12_mul_C(%arg0: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-64 : i12) : i12 + %1 = llvm.mlir.constant(-1.600000e+01 : f16) : f16 + %2 = llvm.or %arg0, %0 : i12 + %3 = llvm.sitofp %2 : i12 to f16 + %4 = llvm.fmul %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_si_si_i12_mul_C_fail_overflow(%arg0: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(-64 : i12) : i12 + %1 = llvm.mlir.constant(-6.400000e+01 : f16) : f16 + %2 = llvm.or %arg0, %0 : i12 + %3 = llvm.sitofp %2 : i12 to f16 + %4 = llvm.fmul %3, %1 : f16 + llvm.return %4 : f16 + } + llvm.func @test_ui_si_i12_mul_nsw(%arg0: i12 {llvm.noundef}, %arg1: i12 {llvm.noundef}) -> f16 { + %0 = llvm.mlir.constant(31 : i12) : i12 + %1 = llvm.mlir.constant(1 : i12) : i12 + %2 = llvm.mlir.constant(30 : i12) : i12 + %3 = llvm.and %arg0, %0 : i12 + %4 = llvm.add %3, %1 : i12 + %5 = llvm.and %arg1, %2 : i12 + %6 = llvm.add %5, %1 : i12 + %7 = llvm.uitofp %4 : i12 to f16 + %8 = llvm.sitofp %6 : i12 to f16 + %9 = llvm.fmul %7, %8 : f16 + llvm.return %9 : f16 + } + llvm.func @test_ui_add_with_signed_constant(%arg0: i32) -> f32 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-1.638300e+04 : f32) : f32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.uitofp %2 : i32 to f32 + %4 = llvm.fadd %3, %1 : f32 + llvm.return %4 : f32 + } + llvm.func @missed_nonzero_check_on_constant_for_si_fmul(%arg0: i1, %arg1: i1, %arg2: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(65529 : i32) : i32 + %1 = llvm.mlir.constant(53264 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.trunc %3 : i32 to i16 + %5 = llvm.sitofp %4 : i16 to f32 + %6 = llvm.fmul %5, %2 : f32 + llvm.store %3, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %6 : f32 + } + llvm.func @missed_nonzero_check_on_constant_for_si_fmul_vec(%arg0: i1, %arg1: i1, %arg2: !llvm.ptr) -> vector<2xf32> { + %0 = llvm.mlir.constant(65529 : i32) : i32 + %1 = llvm.mlir.constant(53264 : i32) : i32 + %2 = llvm.mlir.poison : vector<2xi16> + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.mlir.constant(1 : i64) : i64 + %5 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %6 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %7 = llvm.select %arg0, %0, %1 : i1, i32 + %8 = llvm.trunc %7 : i32 to i16 + %9 = llvm.insertelement %8, %2[%3 : i64] : vector<2xi16> + %10 = llvm.insertelement %8, %9[%4 : i64] : vector<2xi16> + %11 = llvm.sitofp %10 : vector<2xi16> to vector<2xf32> + %12 = llvm.fmul %11, %6 : vector<2xf32> + llvm.store %7, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %12 : vector<2xf32> + } + llvm.func @negzero_check_on_constant_for_si_fmul(%arg0: i1, %arg1: i1, %arg2: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(65529 : i32) : i32 + %1 = llvm.mlir.constant(53264 : i32) : i32 + %2 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.trunc %3 : i32 to i16 + %5 = llvm.sitofp %4 : i16 to f32 + %6 = llvm.fmul %5, %2 : f32 + llvm.store %3, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %6 : f32 + } + llvm.func @nonzero_check_on_constant_for_si_fmul_vec_w_poison(%arg0: i1, %arg1: i1, %arg2: !llvm.ptr) -> vector<2xf32> { + %0 = llvm.mlir.constant(65529 : i32) : i32 + %1 = llvm.mlir.constant(53264 : i32) : i32 + %2 = llvm.mlir.poison : vector<2xi16> + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.mlir.constant(1 : i64) : i64 + %5 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %6 = llvm.mlir.poison : f32 + %7 = llvm.mlir.undef : vector<2xf32> + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.insertelement %6, %7[%8 : i32] : vector<2xf32> + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.insertelement %5, %9[%10 : i32] : vector<2xf32> + %12 = llvm.select %arg0, %0, %1 : i1, i32 + %13 = llvm.trunc %12 : i32 to i16 + %14 = llvm.insertelement %13, %2[%3 : i64] : vector<2xi16> + %15 = llvm.insertelement %13, %14[%4 : i64] : vector<2xi16> + %16 = llvm.sitofp %15 : vector<2xi16> to vector<2xf32> + %17 = llvm.fmul %16, %11 : vector<2xf32> + llvm.store %12, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %17 : vector<2xf32> + } + llvm.func @nonzero_check_on_constant_for_si_fmul_nz_vec_w_poison(%arg0: i1, %arg1: i1, %arg2: !llvm.ptr) -> vector<2xf32> { + %0 = llvm.mlir.constant(65529 : i32) : i32 + %1 = llvm.mlir.constant(53264 : i32) : i32 + %2 = llvm.mlir.poison : vector<2xi16> + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.mlir.constant(1 : i64) : i64 + %5 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %6 = llvm.mlir.poison : f32 + %7 = llvm.mlir.undef : vector<2xf32> + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.insertelement %6, %7[%8 : i32] : vector<2xf32> + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.insertelement %5, %9[%10 : i32] : vector<2xf32> + %12 = llvm.select %arg0, %0, %1 : i1, i32 + %13 = llvm.trunc %12 : i32 to i16 + %14 = llvm.insertelement %13, %2[%3 : i64] : vector<2xi16> + %15 = llvm.insertelement %13, %14[%4 : i64] : vector<2xi16> + %16 = llvm.sitofp %15 : vector<2xi16> to vector<2xf32> + %17 = llvm.fmul %16, %11 : vector<2xf32> + llvm.store %12, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %17 : vector<2xf32> + } + llvm.func @nonzero_check_on_constant_for_si_fmul_negz_vec_w_poison(%arg0: i1, %arg1: i1, %arg2: !llvm.ptr) -> vector<2xf32> { + %0 = llvm.mlir.constant(65529 : i32) : i32 + %1 = llvm.mlir.constant(53264 : i32) : i32 + %2 = llvm.mlir.poison : vector<2xi16> + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.mlir.constant(1 : i64) : i64 + %5 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %6 = llvm.mlir.poison : f32 + %7 = llvm.mlir.undef : vector<2xf32> + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.insertelement %6, %7[%8 : i32] : vector<2xf32> + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.insertelement %5, %9[%10 : i32] : vector<2xf32> + %12 = llvm.select %arg0, %0, %1 : i1, i32 + %13 = llvm.trunc %12 : i32 to i16 + %14 = llvm.insertelement %13, %2[%3 : i64] : vector<2xi16> + %15 = llvm.insertelement %13, %14[%4 : i64] : vector<2xi16> + %16 = llvm.sitofp %15 : vector<2xi16> to vector<2xf32> + %17 = llvm.fmul %16, %11 : vector<2xf32> + llvm.store %12, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %17 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/binop-of-displaced-shifts.ll.mlir b/test/LLVMDialect/InstCombine/binop-of-displaced-shifts.ll.mlir new file mode 100644 index 000000000..85e89ec2c --- /dev/null +++ b/test/LLVMDialect/InstCombine/binop-of-displaced-shifts.ll.mlir @@ -0,0 +1,273 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @shl_or(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.shl %2, %4 : i8 + %6 = llvm.or %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @lshr_or(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.lshr %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.lshr %2, %4 : i8 + %6 = llvm.or %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @ashr_or(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = llvm.ashr %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.ashr %2, %4 : i8 + %6 = llvm.or %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @shl_xor(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.shl %2, %4 : i8 + %6 = llvm.xor %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @lshr_xor(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.lshr %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.lshr %2, %4 : i8 + %6 = llvm.xor %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @ashr_xor(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(-64 : i8) : i8 + %3 = llvm.ashr %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.ashr %2, %4 : i8 + %6 = llvm.xor %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @shl_and(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(48 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(8 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.shl %2, %4 : i8 + %6 = llvm.and %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @lshr_and(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(48 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(64 : i8) : i8 + %3 = llvm.lshr %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.lshr %2, %4 : i8 + %6 = llvm.and %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @ashr_and(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = llvm.ashr %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.ashr %2, %4 : i8 + %6 = llvm.and %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @shl_add(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.shl %2, %4 : i8 + %6 = llvm.add %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @lshr_add_fail(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.lshr %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.lshr %2, %4 : i8 + %6 = llvm.add %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @ashr_add_fail(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.add %arg0, %1 : i8 + %4 = llvm.ashr %0, %3 : i8 + %5 = llvm.add %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @shl_or_commuted(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.shl %2, %4 : i8 + %6 = llvm.or %5, %3 : i8 + llvm.return %6 : i8 + } + llvm.func @shl_or_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %3 = llvm.shl %0, %arg0 : vector<2xi8> + %4 = llvm.add %arg0, %1 : vector<2xi8> + %5 = llvm.shl %2, %4 : vector<2xi8> + %6 = llvm.or %3, %5 : vector<2xi8> + llvm.return %6 : vector<2xi8> + } + llvm.func @shl_or_non_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[16, 32]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<[3, 7]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.shl %0, %arg0 : vector<2xi8> + %4 = llvm.add %arg0, %1 : vector<2xi8> + %5 = llvm.shl %2, %4 : vector<2xi8> + %6 = llvm.or %3, %5 : vector<2xi8> + llvm.return %6 : vector<2xi8> + } + llvm.func @shl_or_poison_in_add(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %9 = llvm.shl %0, %arg0 : vector<2xi8> + %10 = llvm.add %arg0, %7 : vector<2xi8> + %11 = llvm.shl %8, %10 : vector<2xi8> + %12 = llvm.or %9, %11 : vector<2xi8> + llvm.return %12 : vector<2xi8> + } + llvm.func @shl_or_poison_in_shift1(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(16 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %8 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %9 = llvm.shl %6, %arg0 : vector<2xi8> + %10 = llvm.add %arg0, %7 : vector<2xi8> + %11 = llvm.shl %8, %10 : vector<2xi8> + %12 = llvm.or %9, %11 : vector<2xi8> + llvm.return %12 : vector<2xi8> + } + llvm.func @shl_or_poison_in_shift2(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.constant(3 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.shl %0, %arg0 : vector<2xi8> + %10 = llvm.add %arg0, %1 : vector<2xi8> + %11 = llvm.shl %8, %10 : vector<2xi8> + %12 = llvm.or %9, %11 : vector<2xi8> + llvm.return %12 : vector<2xi8> + } + llvm.func @use(i8) + llvm.func @shl_or_multiuse(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.shl %2, %4 : i8 + llvm.call @use(%3) : (i8) -> () + llvm.call @use(%4) : (i8) -> () + llvm.call @use(%5) : (i8) -> () + %6 = llvm.or %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @mismatched_shifts(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.lshr %2, %4 : i8 + %6 = llvm.or %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @mismatched_ops(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.add %arg1, %1 : i8 + %5 = llvm.shl %2, %4 : i8 + %6 = llvm.or %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @add_out_of_range(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(32 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.shl %2, %4 : i8 + %6 = llvm.or %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @shl_or_non_splat_out_of_range(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[16, 32]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[1, 32]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<[3, 7]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.shl %0, %arg0 : vector<2xi8> + %4 = llvm.add %arg0, %1 : vector<2xi8> + %5 = llvm.shl %2, %4 : vector<2xi8> + %6 = llvm.or %3, %5 : vector<2xi8> + llvm.return %6 : vector<2xi8> + } + llvm.func @shl_or_with_or_disjoint_instead_of_add(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.or %arg0, %1 : i8 + %5 = llvm.shl %2, %4 : i8 + %6 = llvm.or %3, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @shl_or_with_or_instead_of_add(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.or %arg0, %1 : i8 + %5 = llvm.shl %2, %4 : i8 + %6 = llvm.or %3, %5 : i8 + llvm.return %6 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/binop-phi-operands.ll.mlir b/test/LLVMDialect/InstCombine/binop-phi-operands.ll.mlir new file mode 100644 index 000000000..a31e22b39 --- /dev/null +++ b/test/LLVMDialect/InstCombine/binop-phi-operands.ll.mlir @@ -0,0 +1,326 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @sideeffect() + llvm.func @add_const_incoming0_speculative(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i32, i32) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%0, %1 : i32, i32) + ^bb2(%2: i32, %3: i32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @add_const_incoming0_nonspeculative(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i32, i32) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i32, i32) + ^bb2(%2: i32, %3: i32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @sub_const_incoming0(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i32, i32) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%0, %1 : i32, i32) + ^bb2(%2: i32, %3: i32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.sub %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @sub_const_incoming1(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i32, i32) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i32, i32) + ^bb2(%2: i32, %3: i32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.sub %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @mul_const_incoming1(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(17 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + %4 = llvm.mul %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @and_const_incoming1(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(17 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + %4 = llvm.and %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @xor_const_incoming1(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(17 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + %4 = llvm.xor %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @or_const_incoming1(%arg0: i1, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.mlir.constant(16 : i64) : i64 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i64, i64) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i64, i64) + ^bb2(%2: i64, %3: i64): // 2 preds: ^bb0, ^bb1 + %4 = llvm.or %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @or_const_incoming01(%arg0: i1, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.mlir.constant(16 : i64) : i64 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i64, i64) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i64, i64) + ^bb2(%2: i64, %3: i64): // 2 preds: ^bb0, ^bb1 + %4 = llvm.or %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @or_const_incoming10(%arg0: i1, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(3 : i64) : i64 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i64, i64) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg2, %arg1 : i64, i64) + ^bb2(%2: i64, %3: i64): // 2 preds: ^bb0, ^bb1 + %4 = llvm.or %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @ashr_const_incoming0_speculative(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%0, %1 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + %4 = llvm.ashr %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @ashr_const_incoming0(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + %4 = llvm.ashr %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @lshr_const_incoming1(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + %4 = llvm.lshr %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_const_incoming1(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + %4 = llvm.shl %2, %3 overflow : i8 + llvm.return %4 : i8 + } + llvm.func @sdiv_not_safe_to_speculate(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%0, %1 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + %4 = llvm.sdiv %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @sdiv_const_incoming1(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.mlir.constant(17 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + %4 = llvm.sdiv %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @udiv_const_incoming1(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.mlir.constant(17 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + %4 = llvm.udiv %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @srem_const_incoming1(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(-17 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + %4 = llvm.srem %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @urem_const_incoming1(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(-17 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + %4 = llvm.urem %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @fmul_const_incoming1(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1.700000e+01 : f32) : f32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : f32, f32) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : f32, f32) + ^bb2(%2: f32, %3: f32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.fmul %2, %3 : f32 + llvm.return %4 : f32 + } + llvm.func @fadd_const_incoming1(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1.700000e+01 : f32) : f32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : f32, f32) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : f32, f32) + ^bb2(%2: f32, %3: f32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @fsub_const_incoming1(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1.700000e+01 : f32) : f32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : f32, f32) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : f32, f32) + ^bb2(%2: f32, %3: f32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.fsub %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @frem_const_incoming1(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1.700000e+01 : f32) : f32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : f32, f32) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : f32, f32) + ^bb2(%2: f32, %3: f32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.frem %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @add_const_incoming0_use1(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i32, i32) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%0, %1 : i32, i32) + ^bb2(%2: i32, %3: i32): // 2 preds: ^bb0, ^bb1 + llvm.call @use(%2) : (i32) -> () + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @add_const_incoming0_use2(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i32, i32) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%0, %1 : i32, i32) + ^bb2(%2: i32, %3: i32): // 2 preds: ^bb0, ^bb1 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @or_notconst_incoming(%arg0: i1, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(43 : i64) : i64 + %1 = llvm.mlir.constant(42 : i64) : i64 + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %0 : i64, i64) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1, %arg2 : i64, i64) + ^bb2(%2: i64, %3: i64): // 2 preds: ^bb0, ^bb1 + %4 = llvm.or %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @mul_const_incoming0_speculatable(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(17 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + llvm.call @sideeffect() : () -> () + %4 = llvm.mul %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @udiv_const_incoming0_not_speculatable(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(17 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + llvm.call @sideeffect() : () -> () + %4 = llvm.udiv %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @udiv_const_incoming0_different_block(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(17 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %1 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1, %arg2 : i8, i8) + ^bb2(%2: i8, %3: i8): // 2 preds: ^bb0, ^bb1 + llvm.br ^bb3 + ^bb3: // pred: ^bb2 + %4 = llvm.udiv %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @ParseRetVal(%arg0: i1, %arg1: !llvm.ptr) -> !llvm.struct<(i64, i32)> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-4294967296 : i64) : i64 + %3 = llvm.mlir.constant(4294901760 : i64) : i64 + %4 = llvm.mlir.constant(65280 : i64) : i64 + %5 = llvm.mlir.constant(255 : i64) : i64 + %6 = llvm.mlir.poison : !llvm.struct<(i64, i32)> + llvm.cond_br %arg0, ^bb1, ^bb2(%0, %0, %0, %0, %1 : i64, i64, i64, i64, i32) + ^bb1: // pred: ^bb0 + %7 = llvm.call %arg1() : !llvm.ptr, () -> !llvm.struct<(i64, i32)> + %8 = llvm.extractvalue %7[0] : !llvm.struct<(i64, i32)> + %9 = llvm.extractvalue %7[1] : !llvm.struct<(i64, i32)> + %10 = llvm.and %8, %2 : i64 + %11 = llvm.and %8, %3 : i64 + %12 = llvm.and %8, %4 : i64 + %13 = llvm.and %8, %5 : i64 + llvm.br ^bb2(%13, %12, %11, %10, %9 : i64, i64, i64, i64, i32) + ^bb2(%14: i64, %15: i64, %16: i64, %17: i64, %18: i32): // 2 preds: ^bb0, ^bb1 + %19 = llvm.or %15, %14 : i64 + %20 = llvm.or %19, %16 : i64 + %21 = llvm.or %20, %17 : i64 + %22 = llvm.insertvalue %21, %6[0] : !llvm.struct<(i64, i32)> + %23 = llvm.insertvalue %18, %22[1] : !llvm.struct<(i64, i32)> + llvm.return %23 : !llvm.struct<(i64, i32)> + } +} diff --git a/test/LLVMDialect/InstCombine/binop-select-cast-of-select-cond.ll.mlir b/test/LLVMDialect/InstCombine/binop-select-cast-of-select-cond.ll.mlir new file mode 100644 index 000000000..f35996606 --- /dev/null +++ b/test/LLVMDialect/InstCombine/binop-select-cast-of-select-cond.ll.mlir @@ -0,0 +1,156 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @b() {addr_space = 0 : i32} : !llvm.array<72 x i32> + llvm.mlir.global external @c() {addr_space = 0 : i32} : i32 + llvm.func @add_select_zext(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.select %arg0, %0, %1 : i1, i64 + %3 = llvm.zext %arg0 : i1 to i64 + %4 = llvm.add %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @add_select_sext(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.select %arg0, %0, %1 : i1, i64 + %3 = llvm.sext %arg0 : i1 to i64 + %4 = llvm.add %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @add_select_not_zext(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.select %arg0, %0, %1 : i1, i64 + %4 = llvm.xor %arg0, %2 : i1 + %5 = llvm.zext %4 : i1 to i64 + %6 = llvm.add %3, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @add_select_not_sext(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.select %arg0, %0, %1 : i1, i64 + %4 = llvm.xor %arg0, %2 : i1 + %5 = llvm.sext %4 : i1 to i64 + %6 = llvm.add %3, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @sub_select_sext(%arg0: i1, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.select %arg0, %0, %arg1 : i1, i64 + %2 = llvm.sext %arg0 : i1 to i64 + %3 = llvm.sub %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @sub_select_not_zext(%arg0: i1, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %arg1, %0 : i1, i64 + %3 = llvm.xor %arg0, %1 : i1 + %4 = llvm.zext %3 : i1 to i64 + %5 = llvm.sub %2, %4 : i64 + llvm.return %5 : i64 + } + llvm.func @sub_select_not_sext(%arg0: i1, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %arg1, %0 : i1, i64 + %3 = llvm.xor %arg0, %1 : i1 + %4 = llvm.sext %3 : i1 to i64 + %5 = llvm.sub %2, %4 : i64 + llvm.return %5 : i64 + } + llvm.func @mul_select_zext(%arg0: i1, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.select %arg0, %arg1, %0 : i1, i64 + %2 = llvm.zext %arg0 : i1 to i64 + %3 = llvm.mul %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @mul_select_sext(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.select %arg0, %0, %1 : i1, i64 + %3 = llvm.sext %arg0 : i1 to i64 + %4 = llvm.mul %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @select_zext_different_condition(%arg0: i1, %arg1: i1) -> i64 { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.select %arg0, %0, %1 : i1, i64 + %3 = llvm.zext %arg1 : i1 to i64 + %4 = llvm.add %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @vector_test(%arg0: i1) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<64> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<1> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.select %arg0, %0, %1 : i1, vector<2xi64> + %6 = llvm.zext %arg0 : i1 to i64 + %7 = llvm.insertelement %6, %2[%3 : i32] : vector<2xi64> + %8 = llvm.insertelement %6, %7[%4 : i32] : vector<2xi64> + %9 = llvm.add %5, %8 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @multiuse_add(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.select %arg0, %0, %1 : i1, i64 + %3 = llvm.zext %arg0 : i1 to i64 + %4 = llvm.add %2, %3 : i64 + %5 = llvm.add %4, %1 : i64 + llvm.return %5 : i64 + } + llvm.func @multiuse_select(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.select %arg0, %0, %1 : i1, i64 + %3 = llvm.zext %arg0 : i1 to i64 + %4 = llvm.sub %2, %3 : i64 + %5 = llvm.mul %2, %4 : i64 + llvm.return %5 : i64 + } + llvm.func @select_non_const_sides(%arg0: i1, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.zext %arg0 : i1 to i64 + %1 = llvm.select %arg0, %arg1, %arg2 : i1, i64 + %2 = llvm.sub %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @sub_select_sext_op_swapped_non_const_args(%arg0: i1, %arg1: i6, %arg2: i6) -> i6 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, i6 + %1 = llvm.sext %arg0 : i1 to i6 + %2 = llvm.sub %1, %0 : i6 + llvm.return %2 : i6 + } + llvm.func @sub_select_zext_op_swapped_non_const_args(%arg0: i1, %arg1: i6, %arg2: i6) -> i6 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, i6 + %1 = llvm.zext %arg0 : i1 to i6 + %2 = llvm.sub %1, %0 : i6 + llvm.return %2 : i6 + } + llvm.func @vectorized_add(%arg0: vector<2xi1>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi8> + %2 = llvm.select %arg0, %arg1, %0 : vector<2xi1>, vector<2xi8> + %3 = llvm.add %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @pr64669(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(25 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.addressof @b : !llvm.ptr + %3 = llvm.getelementptr inbounds %2[%1, %0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<72 x i32> + %4 = llvm.mlir.addressof @c : !llvm.ptr + %5 = llvm.icmp "ne" %3, %4 : !llvm.ptr + %6 = llvm.select %5, %arg0, %1 : i1, i64 + %7 = llvm.zext %5 : i1 to i64 + %8 = llvm.add %6, %7 overflow : i64 + llvm.return %8 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/binop-select.ll.mlir b/test/LLVMDialect/InstCombine/binop-select.ll.mlir new file mode 100644 index 000000000..ee787b99e --- /dev/null +++ b/test/LLVMDialect/InstCombine/binop-select.ll.mlir @@ -0,0 +1,274 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @use_f32(f32) + llvm.func @use_v2f16(vector<2xf16>) + llvm.func @use_v2i8(vector<2xi8>) + llvm.func @test1(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.select %arg0, %1, %arg2 : i1, i32 + %3 = llvm.add %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @test2(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.select %arg0, %1, %arg1 : i1, i32 + %3 = llvm.add %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @test3(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.select %arg0, %2, %1 : i1, i32 + %4 = llvm.mul %3, %arg1 : i32 + llvm.return %4 : i32 + } + llvm.func @test4(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.select %arg0, %2, %1 : i1, i32 + %4 = llvm.mul %3, %arg1 : i32 + llvm.return %4 : i32 + } + llvm.func @test5(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.select %arg0, %arg1, %0 : i1, i32 + %2 = llvm.add %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_sub_deduce_true(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.intr.sadd.sat(%arg0, %3) : (i32, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_sub_deduce_true_no_const_fold(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.intr.sadd.sat(%arg0, %3) : (i32, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_sub_deduce_false(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.intr.sadd.sat(%arg0, %3) : (i32, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_sub_dont_deduce_with_undef_cond_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.undef : i8 + %1 = llvm.mlir.constant(9 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %8 = llvm.icmp "ne" %arg0, %6 : vector<2xi8> + %9 = llvm.select %8, %arg1, %7 : vector<2xi1>, vector<2xi8> + %10 = llvm.intr.sadd.sat(%arg0, %9) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @test_sub_dont_deduce_with_poison_cond_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(9 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %8 = llvm.icmp "ne" %arg0, %6 : vector<2xi8> + %9 = llvm.select %8, %arg1, %7 : vector<2xi1>, vector<2xi8> + %10 = llvm.intr.sadd.sat(%arg0, %9) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @test_sub_deduce_with_undef_val_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.icmp "ne" %arg0, %0 : vector<2xi8> + %9 = llvm.select %8, %arg1, %7 : vector<2xi1>, vector<2xi8> + %10 = llvm.intr.sadd.sat(%arg0, %9) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @test6(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.select %arg0, %0, %arg1 : i1, i32 + %2 = llvm.and %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @test7(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.select %arg0, %arg1, %1 : i1, i32 + %3 = llvm.sdiv %arg1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test8(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.select %arg0, %0, %arg2 : i1, i32 + %3 = llvm.sdiv %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test9(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.select %arg0, %0, %arg1 : i1, i32 + %3 = llvm.sub %1, %2 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @test10(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.select %arg0, %0, %arg2 : i1, i32 + %3 = llvm.udiv %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test11(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.select %arg0, %0, %arg2 : i1, i32 + %3 = llvm.srem %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test12(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.select %arg0, %0, %arg2 : i1, i32 + %3 = llvm.urem %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @extra_use(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.select %arg0, %0, %arg1 : i1, i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.sub %1, %2 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @extra_use2(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.select %arg0, %arg1, %1 : i1, i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.sdiv %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @and_sel_op0(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(25 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.and %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @and_sel_op0_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(25 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.and %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @mul_sel_op0(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.udiv %0, %arg1 : i32 + %3 = llvm.select %arg0, %1, %2 : i1, i32 + %4 = llvm.mul %3, %arg1 : i32 + llvm.return %4 : i32 + } + llvm.func @mul_sel_op0_use(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.udiv %0, %arg1 : i32 + %3 = llvm.select %arg0, %1, %2 : i1, i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.mul %3, %arg1 : i32 + llvm.return %4 : i32 + } + llvm.func @sub_sel_op1(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(41 : i32) : i32 + %2 = llvm.select %arg0, %0, %1 : i1, i32 + %3 = llvm.sub %0, %2 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @sub_sel_op1_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(41 : i32) : i32 + %2 = llvm.select %arg0, %0, %1 : i1, i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.sub %0, %2 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @fadd_sel_op0(%arg0: i1, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0xFF800000 : f32) : f32 + %1 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %2 = llvm.select %arg0, %0, %1 : i1, f32 + %3 = llvm.fadd %2, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fadd_sel_op0_use(%arg0: i1, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0xFF800000 : f32) : f32 + %1 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %2 = llvm.select %arg0, %0, %1 : i1, f32 + llvm.call @use_f32(%2) : (f32) -> () + %3 = llvm.fadd %2, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fmul_sel_op1(%arg0: i1, %arg1: vector<2xf16>) -> vector<2xf16> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00]> : vector<2xf16>) : vector<2xf16> + %1 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %2 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf16>) : vector<2xf16> + %3 = llvm.mlir.constant(dense<0xFFFF> : vector<2xf16>) : vector<2xf16> + %4 = llvm.fadd %arg1, %0 : vector<2xf16> + %5 = llvm.select %arg0, %2, %3 : i1, vector<2xf16> + %6 = llvm.fmul %4, %5 {fastmathFlags = #llvm.fastmath} : vector<2xf16> + llvm.return %6 : vector<2xf16> + } + llvm.func @fmul_sel_op1_use(%arg0: i1, %arg1: vector<2xf16>) -> vector<2xf16> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00]> : vector<2xf16>) : vector<2xf16> + %1 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %2 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf16>) : vector<2xf16> + %3 = llvm.mlir.constant(dense<0xFFFF> : vector<2xf16>) : vector<2xf16> + %4 = llvm.fadd %arg1, %0 : vector<2xf16> + %5 = llvm.select %arg0, %2, %3 : i1, vector<2xf16> + llvm.call @use_v2f16(%5) : (vector<2xf16>) -> () + %6 = llvm.fmul %4, %5 {fastmathFlags = #llvm.fastmath} : vector<2xf16> + llvm.return %6 : vector<2xf16> + } + llvm.func @ashr_sel_op1(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-2 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.ashr %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @ashr_sel_op1_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-2 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.ashr %2, %3 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/bit-checks.ll.mlir b/test/LLVMDialect/InstCombine/bit-checks.ll.mlir new file mode 100644 index 000000000..7390df884 --- /dev/null +++ b/test/LLVMDialect/InstCombine/bit-checks.ll.mlir @@ -0,0 +1,991 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @main1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %4, %6 : i1 + %8 = llvm.select %7, %2, %0 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @main1_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.select %5, %7, %3 : i1, i1 + %9 = llvm.select %8, %2, %0 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.or %4, %6 : i1 + %8 = llvm.select %7, %1, %0 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @main2_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.select %5, %3, %7 : i1, i1 + %9 = llvm.select %8, %1, %0 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(48 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.and %5, %7 : i1 + %9 = llvm.select %8, %1, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main3_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(48 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %1 : i32 + %9 = llvm.select %6, %8, %3 : i1, i1 + %10 = llvm.select %9, %1, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main3b(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(16 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %2 : i32 + %8 = llvm.and %5, %7 : i1 + %9 = llvm.select %8, %1, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main3b_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(16 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %2 : i32 + %9 = llvm.select %6, %8, %3 : i1, i1 + %10 = llvm.select %9, %1, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main3e_like(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.icmp "eq" %4, %0 : i32 + %6 = llvm.and %3, %5 : i1 + %7 = llvm.select %6, %0, %1 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @main3e_like_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %arg1 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + %5 = llvm.and %arg0, %arg2 : i32 + %6 = llvm.icmp "eq" %5, %0 : i32 + %7 = llvm.select %4, %6, %1 : i1, i1 + %8 = llvm.select %7, %0, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @main3c(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(48 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.or %5, %7 : i1 + %9 = llvm.select %8, %1, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main3c_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(48 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %1 : i32 + %9 = llvm.select %6, %3, %8 : i1, i1 + %10 = llvm.select %9, %1, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main3d(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(16 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %2 : i32 + %8 = llvm.or %5, %7 : i1 + %9 = llvm.select %8, %1, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main3d_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(16 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %2 : i32 + %9 = llvm.select %6, %3, %8 : i1, i1 + %10 = llvm.select %9, %1, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main3f_like(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.icmp "ne" %4, %0 : i32 + %6 = llvm.or %3, %5 : i1 + %7 = llvm.select %6, %0, %1 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @main3f_like_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %arg1 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + %5 = llvm.and %arg0, %arg2 : i32 + %6 = llvm.icmp "ne" %5, %0 : i32 + %7 = llvm.select %4, %1, %6 : i1, i1 + %8 = llvm.select %7, %0, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @main4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(48 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %0 : i32 + %6 = llvm.and %arg0, %1 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.and %5, %7 : i1 + %9 = llvm.select %8, %2, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main4_splat(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<48> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %5 = llvm.and %arg0, %0 : vector<2xi32> + %6 = llvm.icmp "eq" %5, %0 : vector<2xi32> + %7 = llvm.and %arg0, %1 : vector<2xi32> + %8 = llvm.icmp "eq" %7, %1 : vector<2xi32> + %9 = llvm.and %6, %8 : vector<2xi1> + %10 = llvm.select %9, %3, %4 : vector<2xi1>, vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @main4_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(48 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %0 : i32 + %7 = llvm.and %arg0, %1 : i32 + %8 = llvm.icmp "eq" %7, %1 : i32 + %9 = llvm.select %6, %8, %2 : i1, i1 + %10 = llvm.select %9, %3, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main4b(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %0 : i32 + %6 = llvm.and %arg0, %1 : i32 + %7 = llvm.icmp "ne" %6, %2 : i32 + %8 = llvm.and %5, %7 : i1 + %9 = llvm.select %8, %2, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main4b_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %0 : i32 + %7 = llvm.and %arg0, %1 : i32 + %8 = llvm.icmp "ne" %7, %2 : i32 + %9 = llvm.select %6, %8, %3 : i1, i1 + %10 = llvm.select %9, %2, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main4e_like(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %2, %arg1 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.icmp "eq" %4, %arg2 : i32 + %6 = llvm.and %3, %5 : i1 + %7 = llvm.select %6, %0, %1 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @main4e_like_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %arg1 : i32 + %4 = llvm.icmp "eq" %3, %arg1 : i32 + %5 = llvm.and %arg0, %arg2 : i32 + %6 = llvm.icmp "eq" %5, %arg2 : i32 + %7 = llvm.select %4, %6, %0 : i1, i1 + %8 = llvm.select %7, %1, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @main4c(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(48 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %0 : i32 + %6 = llvm.and %arg0, %1 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.or %5, %7 : i1 + %9 = llvm.select %8, %2, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main4c_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(48 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %0 : i32 + %7 = llvm.and %arg0, %1 : i32 + %8 = llvm.icmp "ne" %7, %1 : i32 + %9 = llvm.select %6, %2, %8 : i1, i1 + %10 = llvm.select %9, %3, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main4d(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %0 : i32 + %6 = llvm.and %arg0, %1 : i32 + %7 = llvm.icmp "eq" %6, %2 : i32 + %8 = llvm.or %5, %7 : i1 + %9 = llvm.select %8, %2, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main4d_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %0 : i32 + %7 = llvm.and %arg0, %1 : i32 + %8 = llvm.icmp "eq" %7, %2 : i32 + %9 = llvm.select %6, %3, %8 : i1, i1 + %10 = llvm.select %9, %2, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main4f_like(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "ne" %2, %arg1 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.icmp "ne" %4, %arg2 : i32 + %6 = llvm.or %3, %5 : i1 + %7 = llvm.select %6, %0, %1 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @main4f_like_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %arg1 : i32 + %4 = llvm.icmp "ne" %3, %arg1 : i32 + %5 = llvm.and %arg0, %arg2 : i32 + %6 = llvm.icmp "ne" %5, %arg2 : i32 + %7 = llvm.select %4, %0, %6 : i1, i1 + %8 = llvm.select %7, %1, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @main5_like(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + %5 = llvm.and %arg1, %0 : i32 + %6 = llvm.icmp "eq" %5, %0 : i32 + %7 = llvm.and %4, %6 : i1 + %8 = llvm.select %7, %1, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @main5_like_logical(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %0 : i32 + %6 = llvm.and %arg1, %0 : i32 + %7 = llvm.icmp "eq" %6, %0 : i32 + %8 = llvm.select %5, %7, %1 : i1, i1 + %9 = llvm.select %8, %2, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main5e_like(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %2, %arg0 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.icmp "eq" %4, %arg0 : i32 + %6 = llvm.and %3, %5 : i1 + %7 = llvm.select %6, %0, %1 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @main5e_like_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %arg1 : i32 + %4 = llvm.icmp "eq" %3, %arg0 : i32 + %5 = llvm.and %arg0, %arg2 : i32 + %6 = llvm.icmp "eq" %5, %arg0 : i32 + %7 = llvm.select %4, %6, %0 : i1, i1 + %8 = llvm.select %7, %1, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @main5c_like(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + %5 = llvm.and %arg1, %0 : i32 + %6 = llvm.icmp "ne" %5, %0 : i32 + %7 = llvm.or %4, %6 : i1 + %8 = llvm.select %7, %1, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @main5c_like_logical(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %0 : i32 + %6 = llvm.and %arg1, %0 : i32 + %7 = llvm.icmp "ne" %6, %0 : i32 + %8 = llvm.select %5, %1, %7 : i1, i1 + %9 = llvm.select %8, %2, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main5f_like(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "ne" %2, %arg0 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.icmp "ne" %4, %arg0 : i32 + %6 = llvm.or %3, %5 : i1 + %7 = llvm.select %6, %0, %1 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @main5f_like_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %arg1 : i32 + %4 = llvm.icmp "ne" %3, %arg0 : i32 + %5 = llvm.and %arg0, %arg2 : i32 + %6 = llvm.icmp "ne" %5, %arg0 : i32 + %7 = llvm.select %4, %0, %6 : i1, i1 + %8 = llvm.select %7, %1, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @main6(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(48 : i32) : i32 + %3 = llvm.mlir.constant(16 : i32) : i32 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.and %arg0, %0 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.and %arg0, %2 : i32 + %9 = llvm.icmp "eq" %8, %3 : i32 + %10 = llvm.and %7, %9 : i1 + %11 = llvm.select %10, %4, %5 : i1, i32 + llvm.return %11 : i32 + } + llvm.func @main6_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(48 : i32) : i32 + %3 = llvm.mlir.constant(16 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.and %arg0, %0 : i32 + %8 = llvm.icmp "eq" %7, %1 : i32 + %9 = llvm.and %arg0, %2 : i32 + %10 = llvm.icmp "eq" %9, %3 : i32 + %11 = llvm.select %8, %10, %4 : i1, i1 + %12 = llvm.select %11, %5, %6 : i1, i32 + llvm.return %12 : i32 + } + llvm.func @main6b(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(16 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.and %6, %8 : i1 + %10 = llvm.select %9, %3, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main6b_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(16 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.and %arg0, %0 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.and %arg0, %2 : i32 + %9 = llvm.icmp "ne" %8, %3 : i32 + %10 = llvm.select %7, %9, %4 : i1, i1 + %11 = llvm.select %10, %3, %5 : i1, i32 + llvm.return %11 : i32 + } + llvm.func @main6c(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(48 : i32) : i32 + %3 = llvm.mlir.constant(16 : i32) : i32 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.and %arg0, %0 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.and %arg0, %2 : i32 + %9 = llvm.icmp "ne" %8, %3 : i32 + %10 = llvm.or %7, %9 : i1 + %11 = llvm.select %10, %4, %5 : i1, i32 + llvm.return %11 : i32 + } + llvm.func @main6c_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(48 : i32) : i32 + %3 = llvm.mlir.constant(16 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.and %arg0, %0 : i32 + %8 = llvm.icmp "ne" %7, %1 : i32 + %9 = llvm.and %arg0, %2 : i32 + %10 = llvm.icmp "ne" %9, %3 : i32 + %11 = llvm.select %8, %4, %10 : i1, i1 + %12 = llvm.select %11, %5, %6 : i1, i32 + llvm.return %12 : i32 + } + llvm.func @main6d(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(16 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.or %6, %8 : i1 + %10 = llvm.select %9, %3, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main6d_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(16 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.and %arg0, %0 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.and %arg0, %2 : i32 + %9 = llvm.icmp "eq" %8, %3 : i32 + %10 = llvm.select %7, %4, %9 : i1, i1 + %11 = llvm.select %10, %3, %5 : i1, i32 + llvm.return %11 : i32 + } + llvm.func @main7a(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg1, %arg0 : i32 + %3 = llvm.icmp "eq" %2, %arg1 : i32 + %4 = llvm.and %arg2, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %arg2 : i32 + %6 = llvm.and %3, %5 : i1 + %7 = llvm.select %6, %0, %1 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @main7a_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg1, %arg0 : i32 + %4 = llvm.icmp "eq" %3, %arg1 : i32 + %5 = llvm.and %arg2, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %arg2 : i32 + %7 = llvm.select %4, %6, %0 : i1, i1 + %8 = llvm.select %7, %1, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @main7b(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %arg1, %2 : i32 + %4 = llvm.and %arg0, %arg2 : i32 + %5 = llvm.icmp "eq" %arg2, %4 : i32 + %6 = llvm.and %3, %5 : i1 + %7 = llvm.select %6, %0, %1 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @main7b_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %arg1 : i32 + %4 = llvm.icmp "eq" %arg1, %3 : i32 + %5 = llvm.and %arg0, %arg2 : i32 + %6 = llvm.icmp "eq" %arg2, %5 : i32 + %7 = llvm.select %4, %6, %0 : i1, i1 + %8 = llvm.select %7, %1, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @main7c(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg1, %arg0 : i32 + %3 = llvm.icmp "eq" %arg1, %2 : i32 + %4 = llvm.and %arg2, %arg0 : i32 + %5 = llvm.icmp "eq" %arg2, %4 : i32 + %6 = llvm.and %3, %5 : i1 + %7 = llvm.select %6, %0, %1 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @main7c_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg1, %arg0 : i32 + %4 = llvm.icmp "eq" %arg1, %3 : i32 + %5 = llvm.and %arg2, %arg0 : i32 + %6 = llvm.icmp "eq" %arg2, %5 : i32 + %7 = llvm.select %4, %6, %0 : i1, i1 + %8 = llvm.select %7, %1, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @main7d(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg1, %arg3 : i32 + %3 = llvm.and %arg2, %arg4 : i32 + %4 = llvm.and %arg0, %2 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.and %arg0, %3 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + %9 = llvm.select %8, %0, %1 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main7d_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg1, %arg3 : i32 + %4 = llvm.and %arg2, %arg4 : i32 + %5 = llvm.and %arg0, %3 : i32 + %6 = llvm.icmp "eq" %5, %3 : i32 + %7 = llvm.and %arg0, %4 : i32 + %8 = llvm.icmp "eq" %7, %4 : i32 + %9 = llvm.select %6, %8, %0 : i1, i1 + %10 = llvm.select %9, %1, %2 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main7e(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg1, %arg3 : i32 + %3 = llvm.and %arg2, %arg4 : i32 + %4 = llvm.and %2, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.and %3, %arg0 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + %9 = llvm.select %8, %0, %1 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main7e_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg1, %arg3 : i32 + %4 = llvm.and %arg2, %arg4 : i32 + %5 = llvm.and %3, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %3 : i32 + %7 = llvm.and %4, %arg0 : i32 + %8 = llvm.icmp "eq" %7, %4 : i32 + %9 = llvm.select %6, %8, %0 : i1, i1 + %10 = llvm.select %9, %1, %2 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main7f(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg1, %arg3 : i32 + %3 = llvm.and %arg2, %arg4 : i32 + %4 = llvm.and %arg0, %2 : i32 + %5 = llvm.icmp "eq" %2, %4 : i32 + %6 = llvm.and %arg0, %3 : i32 + %7 = llvm.icmp "eq" %3, %6 : i32 + %8 = llvm.and %5, %7 : i1 + %9 = llvm.select %8, %0, %1 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main7f_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg1, %arg3 : i32 + %4 = llvm.and %arg2, %arg4 : i32 + %5 = llvm.and %arg0, %3 : i32 + %6 = llvm.icmp "eq" %3, %5 : i32 + %7 = llvm.and %arg0, %4 : i32 + %8 = llvm.icmp "eq" %4, %7 : i32 + %9 = llvm.select %6, %8, %0 : i1, i1 + %10 = llvm.select %9, %1, %2 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main7g(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg1, %arg3 : i32 + %3 = llvm.and %arg2, %arg4 : i32 + %4 = llvm.and %2, %arg0 : i32 + %5 = llvm.icmp "eq" %2, %4 : i32 + %6 = llvm.and %3, %arg0 : i32 + %7 = llvm.icmp "eq" %3, %6 : i32 + %8 = llvm.and %5, %7 : i1 + %9 = llvm.select %8, %0, %1 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main7g_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg1, %arg3 : i32 + %4 = llvm.and %arg2, %arg4 : i32 + %5 = llvm.and %3, %arg0 : i32 + %6 = llvm.icmp "eq" %3, %5 : i32 + %7 = llvm.and %4, %arg0 : i32 + %8 = llvm.icmp "eq" %4, %7 : i32 + %9 = llvm.select %6, %8, %0 : i1, i1 + %10 = llvm.select %9, %1, %2 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main8(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.trunc %arg0 : i32 to i8 + %8 = llvm.icmp "slt" %7, %2 : i8 + %9 = llvm.or %6, %8 : i1 + %10 = llvm.select %9, %3, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main8_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.and %arg0, %0 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.trunc %arg0 : i32 to i8 + %9 = llvm.icmp "slt" %8, %2 : i8 + %10 = llvm.select %7, %3, %9 : i1, i1 + %11 = llvm.select %10, %4, %5 : i1, i32 + llvm.return %11 : i32 + } + llvm.func @main9(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.trunc %arg0 : i32 to i8 + %8 = llvm.icmp "slt" %7, %2 : i8 + %9 = llvm.and %6, %8 : i1 + %10 = llvm.select %9, %3, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main9_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.and %arg0, %0 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.trunc %arg0 : i32 to i8 + %9 = llvm.icmp "slt" %8, %2 : i8 + %10 = llvm.select %7, %9, %3 : i1, i1 + %11 = llvm.select %10, %4, %5 : i1, i32 + llvm.return %11 : i32 + } + llvm.func @main10(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.trunc %arg0 : i32 to i8 + %8 = llvm.icmp "sge" %7, %2 : i8 + %9 = llvm.and %6, %8 : i1 + %10 = llvm.select %9, %3, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main10_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.and %arg0, %0 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.trunc %arg0 : i32 to i8 + %9 = llvm.icmp "sge" %8, %2 : i8 + %10 = llvm.select %7, %9, %3 : i1, i1 + %11 = llvm.select %10, %4, %5 : i1, i32 + llvm.return %11 : i32 + } + llvm.func @main11(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.trunc %arg0 : i32 to i8 + %8 = llvm.icmp "sge" %7, %2 : i8 + %9 = llvm.or %6, %8 : i1 + %10 = llvm.select %9, %3, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main11_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.and %arg0, %0 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.trunc %arg0 : i32 to i8 + %9 = llvm.icmp "sge" %8, %2 : i8 + %10 = llvm.select %7, %3, %9 : i1, i1 + %11 = llvm.select %10, %4, %5 : i1, i32 + llvm.return %11 : i32 + } + llvm.func @main12(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.trunc %arg0 : i32 to i16 + %5 = llvm.icmp "slt" %4, %0 : i16 + %6 = llvm.trunc %arg0 : i32 to i8 + %7 = llvm.icmp "slt" %6, %1 : i8 + %8 = llvm.or %5, %7 : i1 + %9 = llvm.select %8, %2, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main12_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.trunc %arg0 : i32 to i16 + %6 = llvm.icmp "slt" %5, %0 : i16 + %7 = llvm.trunc %arg0 : i32 to i8 + %8 = llvm.icmp "slt" %7, %1 : i8 + %9 = llvm.select %6, %2, %8 : i1, i1 + %10 = llvm.select %9, %3, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main13(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.trunc %arg0 : i32 to i16 + %5 = llvm.icmp "slt" %4, %0 : i16 + %6 = llvm.trunc %arg0 : i32 to i8 + %7 = llvm.icmp "slt" %6, %1 : i8 + %8 = llvm.and %5, %7 : i1 + %9 = llvm.select %8, %2, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main13_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.trunc %arg0 : i32 to i16 + %6 = llvm.icmp "slt" %5, %0 : i16 + %7 = llvm.trunc %arg0 : i32 to i8 + %8 = llvm.icmp "slt" %7, %1 : i8 + %9 = llvm.select %6, %8, %2 : i1, i1 + %10 = llvm.select %9, %3, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main14(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.trunc %arg0 : i32 to i16 + %5 = llvm.icmp "sge" %4, %0 : i16 + %6 = llvm.trunc %arg0 : i32 to i8 + %7 = llvm.icmp "sge" %6, %1 : i8 + %8 = llvm.and %5, %7 : i1 + %9 = llvm.select %8, %2, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main14_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.trunc %arg0 : i32 to i16 + %6 = llvm.icmp "sge" %5, %0 : i16 + %7 = llvm.trunc %arg0 : i32 to i8 + %8 = llvm.icmp "sge" %7, %1 : i8 + %9 = llvm.select %6, %8, %2 : i1, i1 + %10 = llvm.select %9, %3, %4 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @main15(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.trunc %arg0 : i32 to i16 + %5 = llvm.icmp "sge" %4, %0 : i16 + %6 = llvm.trunc %arg0 : i32 to i8 + %7 = llvm.icmp "sge" %6, %1 : i8 + %8 = llvm.or %5, %7 : i1 + %9 = llvm.select %8, %2, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @main15_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.trunc %arg0 : i32 to i16 + %6 = llvm.icmp "sge" %5, %0 : i16 + %7 = llvm.trunc %arg0 : i32 to i8 + %8 = llvm.icmp "sge" %7, %1 : i8 + %9 = llvm.select %6, %2, %8 : i1, i1 + %10 = llvm.select %9, %3, %4 : i1, i32 + llvm.return %10 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/bit_ceil.ll.mlir b/test/LLVMDialect/InstCombine/bit_ceil.ll.mlir new file mode 100644 index 000000000..2066ac0a7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/bit_ceil.ll.mlir @@ -0,0 +1,204 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bit_ceil_32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + %5 = llvm.sub %1, %4 : i32 + %6 = llvm.shl %2, %5 : i32 + %7 = llvm.icmp "ugt" %arg0, %2 : i32 + %8 = llvm.select %7, %6, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @bit_ceil_64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(64 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.add %arg0, %0 : i64 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = false}> : (i64) -> i64 + %5 = llvm.sub %1, %4 : i64 + %6 = llvm.shl %2, %5 : i64 + %7 = llvm.icmp "ugt" %arg0, %2 : i64 + %8 = llvm.select %7, %6, %2 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @bit_ceil_32_minus_1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(-3 : i32) : i32 + %4 = llvm.add %arg0, %0 : i32 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = false}> : (i32) -> i32 + %6 = llvm.sub %1, %5 overflow : i32 + %7 = llvm.shl %2, %6 overflow : i32 + %8 = llvm.add %arg0, %3 : i32 + %9 = llvm.icmp "ult" %8, %0 : i32 + %10 = llvm.select %9, %7, %2 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @bit_ceil_32_plus_1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(-2 : i32) : i32 + %4 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %5 = llvm.sub %0, %4 : i32 + %6 = llvm.shl %1, %5 : i32 + %7 = llvm.add %arg0, %2 : i32 + %8 = llvm.icmp "ult" %7, %3 : i32 + %9 = llvm.select %8, %6, %1 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @bit_ceil_plus_2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(-2 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + %5 = llvm.sub %1, %4 overflow : i32 + %6 = llvm.shl %0, %5 overflow : i32 + %7 = llvm.icmp "ult" %arg0, %2 : i32 + %8 = llvm.select %7, %6, %0 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @bit_ceil_32_neg(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(-2 : i32) : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = false}> : (i32) -> i32 + %6 = llvm.sub %1, %5 overflow : i32 + %7 = llvm.shl %2, %6 overflow : i32 + %8 = llvm.add %arg0, %0 : i32 + %9 = llvm.icmp "ult" %8, %3 : i32 + %10 = llvm.select %9, %7, %2 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @bit_ceil_not(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.sub %0, %arg0 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + %5 = llvm.sub %1, %4 overflow : i32 + %6 = llvm.shl %2, %5 overflow : i32 + %7 = llvm.icmp "ult" %arg0, %0 : i32 + %8 = llvm.select %7, %6, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @bit_ceil_commuted_operands(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.add %arg0, %0 : i32 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = false}> : (i32) -> i32 + %6 = llvm.sub %1, %5 : i32 + %7 = llvm.shl %2, %6 : i32 + %8 = llvm.icmp "eq" %4, %3 : i32 + %9 = llvm.select %8, %2, %7 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @bit_ceil_wrong_select_constant(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.add %arg0, %0 : i32 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = false}> : (i32) -> i32 + %6 = llvm.sub %1, %5 : i32 + %7 = llvm.shl %2, %6 : i32 + %8 = llvm.icmp "ugt" %arg0, %2 : i32 + %9 = llvm.select %8, %7, %3 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @bit_ceil_32_wrong_cond(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.add %arg0, %0 : i32 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = false}> : (i32) -> i32 + %6 = llvm.sub %1, %5 : i32 + %7 = llvm.shl %2, %6 : i32 + %8 = llvm.icmp "ugt" %arg0, %3 : i32 + %9 = llvm.select %8, %7, %2 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @bit_ceil_wrong_sub_constant(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(33 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + %5 = llvm.sub %1, %4 : i32 + %6 = llvm.shl %2, %5 : i32 + %7 = llvm.icmp "ugt" %arg0, %2 : i32 + %8 = llvm.select %7, %6, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @bit_ceil_32_shl_used_twice(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + %5 = llvm.sub %1, %4 : i32 + %6 = llvm.shl %2, %5 : i32 + %7 = llvm.icmp "ugt" %arg0, %2 : i32 + %8 = llvm.select %7, %6, %2 : i1, i32 + llvm.store %6, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %8 : i32 + } + llvm.func @bit_ceil_32_sub_used_twice(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + %5 = llvm.sub %1, %4 : i32 + %6 = llvm.shl %2, %5 : i32 + %7 = llvm.icmp "ugt" %arg0, %2 : i32 + %8 = llvm.select %7, %6, %2 : i1, i32 + llvm.store %5, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %8 : i32 + } + llvm.func @bit_ceil_v4i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<32> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %3 = llvm.add %arg0, %0 : vector<4xi32> + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = false}> : (vector<4xi32>) -> vector<4xi32> + %5 = llvm.sub %1, %4 : vector<4xi32> + %6 = llvm.shl %2, %5 : vector<4xi32> + %7 = llvm.icmp "ugt" %arg0, %2 : vector<4xi32> + %8 = llvm.select %7, %6, %2 : vector<4xi1>, vector<4xi32> + llvm.return %8 : vector<4xi32> + } + llvm.func @pr91691(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + %5 = llvm.sub %1, %4 : i32 + %6 = llvm.shl %2, %5 : i32 + %7 = llvm.icmp "ult" %arg0, %0 : i32 + %8 = llvm.select %7, %6, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @pr91691_keep_nsw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.sub %0, %arg0 overflow : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + %5 = llvm.sub %1, %4 : i32 + %6 = llvm.shl %2, %5 : i32 + %7 = llvm.icmp "ult" %arg0, %0 : i32 + %8 = llvm.select %7, %6, %2 : i1, i32 + llvm.return %8 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/bit_floor.ll.mlir b/test/LLVMDialect/InstCombine/bit_floor.ll.mlir new file mode 100644 index 000000000..fc783c9da --- /dev/null +++ b/test/LLVMDialect/InstCombine/bit_floor.ll.mlir @@ -0,0 +1,103 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bit_floor_32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = false}> : (i32) -> i32 + %6 = llvm.sub %2, %5 : i32 + %7 = llvm.shl %1, %6 : i32 + %8 = llvm.select %3, %0, %7 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @bit_floor_64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(64 : i64) : i64 + %3 = llvm.icmp "eq" %arg0, %0 : i64 + %4 = llvm.lshr %arg0, %1 : i64 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = false}> : (i64) -> i64 + %6 = llvm.sub %2, %5 : i64 + %7 = llvm.shl %1, %6 : i64 + %8 = llvm.select %3, %0, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @bit_floor_commuted_operands(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.icmp "ne" %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = false}> : (i32) -> i32 + %6 = llvm.sub %2, %5 : i32 + %7 = llvm.shl %1, %6 : i32 + %8 = llvm.select %3, %7, %0 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @bit_floor_lshr_used_twice(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = false}> : (i32) -> i32 + %6 = llvm.sub %2, %5 : i32 + %7 = llvm.shl %1, %6 : i32 + %8 = llvm.select %3, %0, %7 : i1, i32 + llvm.store %4, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %8 : i32 + } + llvm.func @bit_floor_ctlz_used_twice(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = false}> : (i32) -> i32 + %6 = llvm.sub %2, %5 : i32 + %7 = llvm.shl %1, %6 : i32 + %8 = llvm.select %3, %0, %7 : i1, i32 + llvm.store %5, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %8 : i32 + } + llvm.func @bit_floor_sub_used_twice(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = false}> : (i32) -> i32 + %6 = llvm.sub %2, %5 : i32 + %7 = llvm.shl %1, %6 : i32 + %8 = llvm.select %3, %0, %7 : i1, i32 + llvm.store %6, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %8 : i32 + } + llvm.func @bit_floor_shl_used_twice(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = false}> : (i32) -> i32 + %6 = llvm.sub %2, %5 : i32 + %7 = llvm.shl %1, %6 : i32 + %8 = llvm.select %3, %0, %7 : i1, i32 + llvm.store %7, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %8 : i32 + } + llvm.func @bit_floor_v4i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %3 = llvm.mlir.constant(dense<32> : vector<4xi32>) : vector<4xi32> + %4 = llvm.icmp "eq" %arg0, %1 : vector<4xi32> + %5 = llvm.lshr %arg0, %2 : vector<4xi32> + %6 = "llvm.intr.ctlz"(%5) <{is_zero_poison = false}> : (vector<4xi32>) -> vector<4xi32> + %7 = llvm.sub %3, %6 : vector<4xi32> + %8 = llvm.shl %2, %7 : vector<4xi32> + %9 = llvm.select %4, %1, %8 : vector<4xi1>, vector<4xi32> + llvm.return %9 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/bitcast-bfloat-half-mixing.ll.mlir b/test/LLVMDialect/InstCombine/bitcast-bfloat-half-mixing.ll.mlir new file mode 100644 index 000000000..0e0107cb3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/bitcast-bfloat-half-mixing.ll.mlir @@ -0,0 +1,32 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @F0(%arg0: bf16) -> f64 { + %0 = llvm.bitcast %arg0 : bf16 to f16 + %1 = llvm.fpext %0 : f16 to f64 + llvm.return %1 : f64 + } + llvm.func @F1(%arg0: f16) -> f64 { + %0 = llvm.bitcast %arg0 : f16 to bf16 + %1 = llvm.fpext %0 : bf16 to f64 + llvm.return %1 : f64 + } + llvm.func @F2(%arg0: bf16) -> i32 { + %0 = llvm.bitcast %arg0 : bf16 to f16 + %1 = llvm.fptoui %0 : f16 to i32 + llvm.return %1 : i32 + } + llvm.func @F3(%arg0: f16) -> i32 { + %0 = llvm.bitcast %arg0 : f16 to bf16 + %1 = llvm.fptoui %0 : bf16 to i32 + llvm.return %1 : i32 + } + llvm.func @F4(%arg0: bf16) -> i32 { + %0 = llvm.bitcast %arg0 : bf16 to f16 + %1 = llvm.fptosi %0 : f16 to i32 + llvm.return %1 : i32 + } + llvm.func @F5(%arg0: f16) -> i32 { + %0 = llvm.bitcast %arg0 : f16 to bf16 + %1 = llvm.fptosi %0 : bf16 to i32 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/bitcast-bigendian.ll.mlir b/test/LLVMDialect/InstCombine/bitcast-bigendian.ll.mlir index 326b5c8d4..1a50ad4af 100644 --- a/test/LLVMDialect/InstCombine/bitcast-bigendian.ll.mlir +++ b/test/LLVMDialect/InstCombine/bitcast-bigendian.ll.mlir @@ -1,83 +1,74 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (vector<2xf32>) -> i64 - %1 = "llvm.trunc"(%0) : (i64) -> i32 - %2 = "llvm.bitcast"(%1) : (i32) -> f32 - %3 = "llvm.bitcast"(%arg1) : (vector<2xi32>) -> i64 - %4 = "llvm.trunc"(%3) : (i64) -> i32 - %5 = "llvm.bitcast"(%4) : (i32) -> f32 - %6 = "llvm.fadd"(%2, %5) : (f32, f32) -> f32 - "llvm.return"(%6) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>, %arg1: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 64 : i128} : () -> i128 - %1 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %2 = "llvm.bitcast"(%arg0) : (vector<2xf32>) -> i64 - %3 = "llvm.lshr"(%2, %1) : (i64, i64) -> i64 - %4 = "llvm.trunc"(%3) : (i64) -> i32 - %5 = "llvm.bitcast"(%4) : (i32) -> f32 - %6 = "llvm.bitcast"(%arg1) : (vector<2xi64>) -> i128 - %7 = "llvm.lshr"(%6, %0) : (i128, i128) -> i128 - %8 = "llvm.trunc"(%7) : (i128) -> i32 - %9 = "llvm.bitcast"(%8) : (i32) -> f32 - %10 = "llvm.fadd"(%5, %9) : (f32, f32) -> f32 - "llvm.return"(%10) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func, vector<2xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %1 = "llvm.zext"(%arg0) : (i32) -> i64 - %2 = "llvm.zext"(%arg1) : (i32) -> i64 - %3 = "llvm.shl"(%2, %0) : (i64, i64) -> i64 - %4 = "llvm.or"(%3, %1) : (i64, i64) -> i64 - %5 = "llvm.bitcast"(%4) : (i64) -> vector<2xi32> - "llvm.return"(%5) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func (i32, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %1 = "llvm.bitcast"(%arg0) : (f32) -> i32 - %2 = "llvm.zext"(%1) : (i32) -> i64 - %3 = "llvm.bitcast"(%arg1) : (f32) -> i32 - %4 = "llvm.zext"(%3) : (i32) -> i64 - %5 = "llvm.shl"(%4, %0) : (i64, i64) -> i64 - %6 = "llvm.or"(%5, %2) : (i64, i64) -> i64 - %7 = "llvm.bitcast"(%6) : (i64) -> vector<2xf32> - "llvm.return"(%7) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func (f32, f32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1109917696 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %2 = "llvm.bitcast"(%arg0) : (f32) -> i32 - %3 = "llvm.zext"(%2) : (i32) -> i64 - %4 = "llvm.shl"(%3, %1) : (i64, i64) -> i64 - %5 = "llvm.or"(%4, %0) : (i64, i64) -> i64 - %6 = "llvm.bitcast"(%5) : (i64) -> vector<2xf32> - "llvm.return"(%6) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func (f32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<1xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[1, 2]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.bitcast"(%arg0) : (vector<1xi64>) -> vector<2xi32> - %2 = "llvm.xor"(%0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "xor_bitcast_vec_to_vec", type = !llvm.func (vector<1xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.bitcast"(%arg0) : (vector<2xi32>) -> i64 - %2 = "llvm.and"(%1, %0) : (i64, i64) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "and_bitcast_vec_to_int", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[1, 2]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.bitcast"(%arg0) : (i64) -> vector<2xi32> - %2 = "llvm.or"(%1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "or_bitcast_int_to_vec", type = !llvm.func (i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "big">>} { + llvm.func @test2(%arg0: vector<2xf32>, %arg1: vector<2xi32>) -> f32 { + %0 = llvm.bitcast %arg0 : vector<2xf32> to i64 + %1 = llvm.trunc %0 : i64 to i32 + %2 = llvm.bitcast %1 : i32 to f32 + %3 = llvm.bitcast %arg1 : vector<2xi32> to i64 + %4 = llvm.trunc %3 : i64 to i32 + %5 = llvm.bitcast %4 : i32 to f32 + %6 = llvm.fadd %2, %5 : f32 + llvm.return %6 : f32 + } + llvm.func @test3(%arg0: vector<2xf32>, %arg1: vector<2xi64>) -> f32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(64 : i128) : i128 + %2 = llvm.bitcast %arg0 : vector<2xf32> to i64 + %3 = llvm.lshr %2, %0 : i64 + %4 = llvm.trunc %3 : i64 to i32 + %5 = llvm.bitcast %4 : i32 to f32 + %6 = llvm.bitcast %arg1 : vector<2xi64> to i128 + %7 = llvm.lshr %6, %1 : i128 + %8 = llvm.trunc %7 : i128 to i32 + %9 = llvm.bitcast %8 : i32 to f32 + %10 = llvm.fadd %5, %9 : f32 + llvm.return %10 : f32 + } + llvm.func @test4(%arg0: i32, %arg1: i32) -> vector<2xi32> { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.zext %arg0 : i32 to i64 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.shl %2, %0 : i64 + %4 = llvm.or %3, %1 : i64 + %5 = llvm.bitcast %4 : i64 to vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test5(%arg0: f32, %arg1: f32) -> vector<2xf32> { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.zext %1 : i32 to i64 + %3 = llvm.bitcast %arg1 : f32 to i32 + %4 = llvm.zext %3 : i32 to i64 + %5 = llvm.shl %4, %0 : i64 + %6 = llvm.or %5, %2 : i64 + %7 = llvm.bitcast %6 : i64 to vector<2xf32> + llvm.return %7 : vector<2xf32> + } + llvm.func @test6(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(1109917696 : i64) : i64 + %2 = llvm.bitcast %arg0 : f32 to i32 + %3 = llvm.zext %2 : i32 to i64 + %4 = llvm.shl %3, %0 : i64 + %5 = llvm.or %4, %1 : i64 + %6 = llvm.bitcast %5 : i64 to vector<2xf32> + llvm.return %6 : vector<2xf32> + } + llvm.func @xor_bitcast_vec_to_vec(%arg0: vector<1xi64>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.bitcast %arg0 : vector<1xi64> to vector<2xi32> + %2 = llvm.xor %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @and_bitcast_vec_to_int(%arg0: vector<2xi32>) -> i64 { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.bitcast %arg0 : vector<2xi32> to i64 + %2 = llvm.and %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @or_bitcast_int_to_vec(%arg0: i64) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.bitcast %arg0 : i64 to vector<2xi32> + %2 = llvm.or %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/bitcast-bitcast.ll.mlir b/test/LLVMDialect/InstCombine/bitcast-bitcast.ll.mlir index 08f5898b0..0ca4c32d7 100644 --- a/test/LLVMDialect/InstCombine/bitcast-bitcast.ll.mlir +++ b/test/LLVMDialect/InstCombine/bitcast-bitcast.ll.mlir @@ -1,51 +1,42 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i128): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (i128) -> f128 - %1 = "llvm.bitcast"(%0) : (f128) -> !llvm.ppc_fp128 - "llvm.return"(%1) : (!llvm.ppc_fp128) -> () - }) {linkage = 10 : i64, sym_name = "bitcast_bitcast_s_s_s", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (i64) -> f64 - %1 = "llvm.bitcast"(%0) : (f64) -> vector<2xi32> - "llvm.return"(%1) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "bitcast_bitcast_s_s_v", type = !llvm.func (i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (i64) -> vector<2xi32> - %1 = "llvm.bitcast"(%0) : (vector<2xi32>) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "bitcast_bitcast_s_v_s", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (i64) -> vector<4xi16> - %1 = "llvm.bitcast"(%0) : (vector<4xi16>) -> vector<2xi32> - "llvm.return"(%1) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "bitcast_bitcast_s_v_v", type = !llvm.func (i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (vector<2xi32>) -> f64 - %1 = "llvm.bitcast"(%0) : (f64) -> i64 - "llvm.return"(%1) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "bitcast_bitcast_v_s_s", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (vector<2xi32>) -> f64 - %1 = "llvm.bitcast"(%0) : (f64) -> vector<4xi16> - "llvm.return"(%1) : (vector<4xi16>) -> () - }) {linkage = 10 : i64, sym_name = "bitcast_bitcast_v_s_v", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (vector<2xf32>) -> vector<4xi16> - %1 = "llvm.bitcast"(%0) : (vector<4xi16>) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "bitcast_bitcast_v_v_s", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (vector<2xf32>) -> vector<4xi16> - %1 = "llvm.bitcast"(%0) : (vector<4xi16>) -> vector<2xi32> - "llvm.return"(%1) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "bitcast_bitcast_v_v_v", type = !llvm.func (vector<2xf32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bitcast_bitcast_s_s_s(%arg0: i128) -> !llvm.ppc_fp128 { + %0 = llvm.bitcast %arg0 : i128 to f128 + %1 = llvm.bitcast %0 : f128 to !llvm.ppc_fp128 + llvm.return %1 : !llvm.ppc_fp128 + } + llvm.func @bitcast_bitcast_s_s_v(%arg0: i64) -> vector<2xi32> { + %0 = llvm.bitcast %arg0 : i64 to f64 + %1 = llvm.bitcast %0 : f64 to vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @bitcast_bitcast_s_v_s(%arg0: i64) -> f64 { + %0 = llvm.bitcast %arg0 : i64 to vector<2xi32> + %1 = llvm.bitcast %0 : vector<2xi32> to f64 + llvm.return %1 : f64 + } + llvm.func @bitcast_bitcast_s_v_v(%arg0: i64) -> vector<2xi32> { + %0 = llvm.bitcast %arg0 : i64 to vector<4xi16> + %1 = llvm.bitcast %0 : vector<4xi16> to vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @bitcast_bitcast_v_s_s(%arg0: vector<2xi32>) -> i64 { + %0 = llvm.bitcast %arg0 : vector<2xi32> to f64 + %1 = llvm.bitcast %0 : f64 to i64 + llvm.return %1 : i64 + } + llvm.func @bitcast_bitcast_v_s_v(%arg0: vector<2xi32>) -> vector<4xi16> { + %0 = llvm.bitcast %arg0 : vector<2xi32> to f64 + %1 = llvm.bitcast %0 : f64 to vector<4xi16> + llvm.return %1 : vector<4xi16> + } + llvm.func @bitcast_bitcast_v_v_s(%arg0: vector<2xf32>) -> f64 { + %0 = llvm.bitcast %arg0 : vector<2xf32> to vector<4xi16> + %1 = llvm.bitcast %0 : vector<4xi16> to f64 + llvm.return %1 : f64 + } + llvm.func @bitcast_bitcast_v_v_v(%arg0: vector<2xf32>) -> vector<2xi32> { + %0 = llvm.bitcast %arg0 : vector<2xf32> to vector<4xi16> + %1 = llvm.bitcast %0 : vector<4xi16> to vector<2xi32> + llvm.return %1 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/bitcast-function.ll.mlir b/test/LLVMDialect/InstCombine/bitcast-function.ll.mlir index 185257e53..07ecf3932 100644 --- a/test/LLVMDialect/InstCombine/bitcast-function.ll.mlir +++ b/test/LLVMDialect/InstCombine/bitcast-function.ll.mlir @@ -1,139 +1,106 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - "llvm.return"(%arg0) : (vector<2xi32>) -> () - }) {linkage = 1 : i64, sym_name = "func_v2i32", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>): // no predecessors - "llvm.return"(%arg0) : (vector<2xf32>) -> () - }) {linkage = 1 : i64, sym_name = "func_v2f32", type = !llvm.func (vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>): // no predecessors - "llvm.return"(%arg0) : (vector<4xf32>) -> () - }) {linkage = 1 : i64, sym_name = "func_v4f32", type = !llvm.func (vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - "llvm.return"(%arg0) : (i32) -> () - }) {linkage = 1 : i64, sym_name = "func_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - "llvm.return"(%arg0) : (i64) -> () - }) {linkage = 1 : i64, sym_name = "func_i64", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - "llvm.return"(%arg0) : (vector<2xi64>) -> () - }) {linkage = 1 : i64, sym_name = "func_v2i64", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec<2 x ptr>): // no predecessors - "llvm.return"(%arg0) : (!llvm.vec<2 x ptr>) -> () - }) {linkage = 1 : i64, sym_name = "func_v2i32p", type = !llvm.func> (vec<2 x ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @func_i32} : () -> !llvm.ptr> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>) -> !llvm.ptr> - %2 = "llvm.load"(%arg0) : (!llvm.ptr) -> f32 - %3 = "llvm.call"(%1, %2) : (!llvm.ptr>, f32) -> f32 - "llvm.store"(%3, %arg1) : (f32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bitcast_scalar", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @func_v2i32} : () -> !llvm.ptr (vector<2xi32>)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr (vector<2xi32>)>>) -> !llvm.ptr (vector<2xf32>)>> - %2 = "llvm.load"(%arg0) : (!llvm.ptr>) -> vector<2xf32> - %3 = "llvm.call"(%1, %2) : (!llvm.ptr (vector<2xf32>)>>, vector<2xf32>) -> vector<2xf32> - "llvm.store"(%3, %arg1) : (vector<2xf32>, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bitcast_vector", type = !llvm.func>, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @func_i64} : () -> !llvm.ptr> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>) -> !llvm.ptr (vector<2xf32>)>> - %2 = "llvm.load"(%arg0) : (!llvm.ptr>) -> vector<2xf32> - %3 = "llvm.call"(%1, %2) : (!llvm.ptr (vector<2xf32>)>>, vector<2xf32>) -> vector<2xf32> - "llvm.store"(%3, %arg1) : (vector<2xf32>, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bitcast_vector_scalar_same_size", type = !llvm.func>, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @func_v2f32} : () -> !llvm.ptr (vector<2xf32>)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr (vector<2xf32>)>>) -> !llvm.ptr> - %2 = "llvm.load"(%arg0) : (!llvm.ptr) -> i64 - %3 = "llvm.call"(%1, %2) : (!llvm.ptr>, i64) -> i64 - "llvm.store"(%3, %arg1) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bitcast_scalar_vector_same_size", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>>, %arg1: !llvm.ptr>>): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @func_v2i32p} : () -> !llvm.ptr> (vec<2 x ptr>)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr> (vec<2 x ptr>)>>) -> !llvm.ptr> (vec<2 x ptr>)>> - %2 = "llvm.load"(%arg0) : (!llvm.ptr>>) -> !llvm.vec<2 x ptr> - %3 = "llvm.call"(%1, %2) : (!llvm.ptr> (vec<2 x ptr>)>>, !llvm.vec<2 x ptr>) -> !llvm.vec<2 x ptr> - "llvm.store"(%3, %arg1) : (!llvm.vec<2 x ptr>, !llvm.ptr>>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bitcast_vector_ptrs_same_size", type = !llvm.func>>, ptr>>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @func_i64} : () -> !llvm.ptr> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>) -> !llvm.ptr> - %2 = "llvm.load"(%arg0) : (!llvm.ptr) -> f32 - %3 = "llvm.call"(%1, %2) : (!llvm.ptr>, f32) -> f32 - "llvm.store"(%3, %arg1) : (f32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bitcast_mismatch_scalar_size", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @func_v2i64} : () -> !llvm.ptr (vector<2xi64>)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr (vector<2xi64>)>>) -> !llvm.ptr (vector<2xf32>)>> - %2 = "llvm.load"(%arg0) : (!llvm.ptr>) -> vector<2xf32> - %3 = "llvm.call"(%1, %2) : (!llvm.ptr (vector<2xf32>)>>, vector<2xf32>) -> vector<2xf32> - "llvm.store"(%3, %arg1) : (vector<2xf32>, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bitcast_mismatch_vector_element_and_bit_size", type = !llvm.func>, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @func_v2i32} : () -> !llvm.ptr (vector<2xi32>)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr (vector<2xi32>)>>) -> !llvm.ptr (vector<4xf32>)>> - %2 = "llvm.load"(%arg0) : (!llvm.ptr>) -> vector<4xf32> - %3 = "llvm.call"(%1, %2) : (!llvm.ptr (vector<4xf32>)>>, vector<4xf32>) -> vector<4xf32> - "llvm.store"(%3, %arg1) : (vector<4xf32>, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bitcast_vector_mismatched_number_elements", type = !llvm.func>, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @func_i64} : () -> !llvm.ptr> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>) -> !llvm.ptr (vector<4xf32>)>> - %2 = "llvm.load"(%arg0) : (!llvm.ptr>) -> vector<4xf32> - %3 = "llvm.call"(%1, %2) : (!llvm.ptr (vector<4xf32>)>>, vector<4xf32>) -> vector<4xf32> - "llvm.store"(%3, %arg1) : (vector<4xf32>, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bitcast_vector_scalar_mismatched_bit_size", type = !llvm.func>, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>>, %arg1: !llvm.ptr>>): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @func_i64} : () -> !llvm.ptr> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>) -> !llvm.ptr> (vec<4 x ptr>)>> - %2 = "llvm.load"(%arg0) : (!llvm.ptr>>) -> !llvm.vec<4 x ptr> - %3 = "llvm.call"(%1, %2) : (!llvm.ptr> (vec<4 x ptr>)>>, !llvm.vec<4 x ptr>) -> !llvm.vec<4 x ptr> - "llvm.store"(%3, %arg1) : (!llvm.vec<4 x ptr>, !llvm.ptr>>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bitcast_vector_ptrs_scalar_mismatched_bit_size", type = !llvm.func>>, ptr>>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @func_v2i32p} : () -> !llvm.ptr> (vec<2 x ptr>)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr> (vec<2 x ptr>)>>) -> !llvm.ptr> - %2 = "llvm.load"(%arg0) : (!llvm.ptr) -> i64 - %3 = "llvm.call"(%1, %2) : (!llvm.ptr>, i64) -> i64 - "llvm.store"(%3, %arg1) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bitcast_scalar_vector_ptrs_same_size", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @func_v4f32} : () -> !llvm.ptr (vector<4xf32>)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr (vector<4xf32>)>>) -> !llvm.ptr> - %2 = "llvm.load"(%arg0) : (!llvm.ptr) -> i64 - %3 = "llvm.call"(%1, %2) : (!llvm.ptr>, i64) -> i64 - "llvm.store"(%3, %arg1) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bitcast_scalar_vector_mismatched_bit_size", type = !llvm.func, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func internal @func_v2i32(%arg0: vector<2xi32>) -> vector<2xi32> attributes {dso_local, passthrough = ["noinline", "nounwind"]} { + llvm.return %arg0 : vector<2xi32> + } + llvm.func internal @func_v2f32(%arg0: vector<2xf32>) -> vector<2xf32> attributes {dso_local, passthrough = ["noinline", "nounwind"]} { + llvm.return %arg0 : vector<2xf32> + } + llvm.func internal @func_v4f32(%arg0: vector<4xf32>) -> vector<4xf32> attributes {dso_local, passthrough = ["noinline", "nounwind"]} { + llvm.return %arg0 : vector<4xf32> + } + llvm.func internal @func_i32(%arg0: i32) -> i32 attributes {dso_local, passthrough = ["noinline", "nounwind"]} { + llvm.return %arg0 : i32 + } + llvm.func internal @func_i64(%arg0: i64) -> i64 attributes {dso_local, passthrough = ["noinline", "nounwind"]} { + llvm.return %arg0 : i64 + } + llvm.func internal @func_v2i64(%arg0: vector<2xi64>) -> vector<2xi64> attributes {dso_local, passthrough = ["noinline", "nounwind"]} { + llvm.return %arg0 : vector<2xi64> + } + llvm.func internal @func_v2i32p(%arg0: !llvm.vec<2 x ptr>) -> !llvm.vec<2 x ptr> attributes {dso_local, passthrough = ["noinline", "nounwind"]} { + llvm.return %arg0 : !llvm.vec<2 x ptr> + } + llvm.func @bitcast_scalar(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.addressof @func_i32 : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> f32 + %2 = llvm.call %0(%1) : !llvm.ptr, (f32) -> f32 + llvm.store %2, %arg1 {alignment = 8 : i64} : f32, !llvm.ptr + llvm.return + } + llvm.func @bitcast_vector(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.addressof @func_v2i32 : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> vector<2xf32> + %2 = llvm.call %0(%1) : !llvm.ptr, (vector<2xf32>) -> vector<2xf32> + llvm.store %2, %arg1 {alignment = 8 : i64} : vector<2xf32>, !llvm.ptr + llvm.return + } + llvm.func @bitcast_vector_scalar_same_size(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.addressof @func_i64 : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> vector<2xf32> + %2 = llvm.call %0(%1) : !llvm.ptr, (vector<2xf32>) -> vector<2xf32> + llvm.store %2, %arg1 {alignment = 8 : i64} : vector<2xf32>, !llvm.ptr + llvm.return + } + llvm.func @bitcast_scalar_vector_same_size(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.addressof @func_v2f32 : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + %2 = llvm.call %0(%1) : !llvm.ptr, (i64) -> i64 + llvm.store %2, %arg1 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @bitcast_vector_ptrs_same_size(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.vec<2 x ptr> + %1 = llvm.call @func_v2i32p(%0) : (!llvm.vec<2 x ptr>) -> !llvm.vec<2 x ptr> + llvm.store %1, %arg1 {alignment = 8 : i64} : !llvm.vec<2 x ptr>, !llvm.ptr + llvm.return + } + llvm.func @bitcast_mismatch_scalar_size(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.addressof @func_i64 : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> f32 + %2 = llvm.call %0(%1) : !llvm.ptr, (f32) -> f32 + llvm.store %2, %arg1 {alignment = 8 : i64} : f32, !llvm.ptr + llvm.return + } + llvm.func @bitcast_mismatch_vector_element_and_bit_size(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.addressof @func_v2i64 : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> vector<2xf32> + %2 = llvm.call %0(%1) : !llvm.ptr, (vector<2xf32>) -> vector<2xf32> + llvm.store %2, %arg1 {alignment = 8 : i64} : vector<2xf32>, !llvm.ptr + llvm.return + } + llvm.func @bitcast_vector_mismatched_number_elements(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.addressof @func_v2i32 : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> vector<4xf32> + %2 = llvm.call %0(%1) : !llvm.ptr, (vector<4xf32>) -> vector<4xf32> + llvm.store %2, %arg1 {alignment = 8 : i64} : vector<4xf32>, !llvm.ptr + llvm.return + } + llvm.func @bitcast_vector_scalar_mismatched_bit_size(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.addressof @func_i64 : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> vector<4xf32> + %2 = llvm.call %0(%1) : !llvm.ptr, (vector<4xf32>) -> vector<4xf32> + llvm.store %2, %arg1 {alignment = 8 : i64} : vector<4xf32>, !llvm.ptr + llvm.return + } + llvm.func @bitcast_vector_ptrs_scalar_mismatched_bit_size(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.addressof @func_i64 : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.vec<4 x ptr> + %2 = llvm.call %0(%1) : !llvm.ptr, (!llvm.vec<4 x ptr>) -> !llvm.vec<4 x ptr> + llvm.store %2, %arg1 {alignment = 8 : i64} : !llvm.vec<4 x ptr>, !llvm.ptr + llvm.return + } + llvm.func @bitcast_scalar_vector_ptrs_same_size(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.addressof @func_v2i32p : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + %2 = llvm.call %0(%1) : !llvm.ptr, (i64) -> i64 + llvm.store %2, %arg1 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @bitcast_scalar_vector_mismatched_bit_size(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.addressof @func_v4f32 : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + %2 = llvm.call %0(%1) : !llvm.ptr, (i64) -> i64 + llvm.store %2, %arg1 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/bitcast-inselt-bitcast.ll.mlir b/test/LLVMDialect/InstCombine/bitcast-inselt-bitcast.ll.mlir new file mode 100644 index 000000000..b91b49134 --- /dev/null +++ b/test/LLVMDialect/InstCombine/bitcast-inselt-bitcast.ll.mlir @@ -0,0 +1,75 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(vector<2xi8>) + llvm.func @insert0_v2i8(%arg0: i16, %arg1: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i16 to vector<2xi8> + %2 = llvm.insertelement %arg1, %1[%0 : i8] : vector<2xi8> + %3 = llvm.bitcast %2 : vector<2xi8> to i16 + llvm.return %3 : i16 + } + llvm.func @insert1_v2i8(%arg0: i16, %arg1: i8) -> i16 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.bitcast %arg0 : i16 to vector<2xi8> + %2 = llvm.insertelement %arg1, %1[%0 : i8] : vector<2xi8> + %3 = llvm.bitcast %2 : vector<2xi8> to i16 + llvm.return %3 : i16 + } + llvm.func @insert0_v4i8(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i32 to vector<4xi8> + %2 = llvm.insertelement %arg1, %1[%0 : i8] : vector<4xi8> + %3 = llvm.bitcast %2 : vector<4xi8> to i32 + llvm.return %3 : i32 + } + llvm.func @insert0_v2half(%arg0: i32, %arg1: f16) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i32 to vector<2xf16> + %2 = llvm.insertelement %arg1, %1[%0 : i8] : vector<2xf16> + %3 = llvm.bitcast %2 : vector<2xf16> to i32 + llvm.return %3 : i32 + } + llvm.func @insert0_v4i16(%arg0: i64, %arg1: i16) -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i64 to vector<4xi16> + %2 = llvm.insertelement %arg1, %1[%0 : i8] : vector<4xi16> + %3 = llvm.bitcast %2 : vector<4xi16> to i64 + llvm.return %3 : i64 + } + llvm.func @insert1_v4i16(%arg0: i64, %arg1: i16) -> i64 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.bitcast %arg0 : i64 to vector<4xi16> + %2 = llvm.insertelement %arg1, %1[%0 : i8] : vector<4xi16> + %3 = llvm.bitcast %2 : vector<4xi16> to i64 + llvm.return %3 : i64 + } + llvm.func @insert3_v4i16(%arg0: i64, %arg1: i16) -> i64 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.bitcast %arg0 : i64 to vector<4xi16> + %2 = llvm.insertelement %arg1, %1[%0 : i8] : vector<4xi16> + %3 = llvm.bitcast %2 : vector<4xi16> to i64 + llvm.return %3 : i64 + } + llvm.func @insert0_v4i32(%arg0: i128, %arg1: i32) -> i128 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i128 to vector<4xi32> + %2 = llvm.insertelement %arg1, %1[%0 : i8] : vector<4xi32> + %3 = llvm.bitcast %2 : vector<4xi32> to i128 + llvm.return %3 : i128 + } + llvm.func @insert0_v2i8_use1(%arg0: i16, %arg1: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i16 to vector<2xi8> + llvm.call @use(%1) : (vector<2xi8>) -> () + %2 = llvm.insertelement %arg1, %1[%0 : i8] : vector<2xi8> + %3 = llvm.bitcast %2 : vector<2xi8> to i16 + llvm.return %3 : i16 + } + llvm.func @insert0_v2i8_use2(%arg0: i16, %arg1: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i16 to vector<2xi8> + %2 = llvm.insertelement %arg1, %1[%0 : i8] : vector<2xi8> + llvm.call @use(%2) : (vector<2xi8>) -> () + %3 = llvm.bitcast %2 : vector<2xi8> to i16 + llvm.return %3 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/bitcast-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/bitcast-inseltpoison.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/bitcast-phi-uselistorder.ll.mlir b/test/LLVMDialect/InstCombine/bitcast-phi-uselistorder.ll.mlir index ae22729c9..7978ae867 100644 --- a/test/LLVMDialect/InstCombine/bitcast-phi-uselistorder.ll.mlir +++ b/test/LLVMDialect/InstCombine/bitcast-phi-uselistorder.ll.mlir @@ -1,19 +1,16 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 1 : i64, sym_name = "Q", type = f64, value = 1.000000e+00 : f64} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @Q} : () -> !llvm.ptr - %1 = "llvm.bitcast"(%0) : (!llvm.ptr) -> !llvm.ptr - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - "llvm.cond_br"(%arg0, %2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i64) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal unnamed_addr @Q(1.000000e+00 : f64) {addr_space = 0 : i32, alignment = 8 : i64, dso_local} : f64 + llvm.func @test(%arg0: i1, %arg1: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %2 = llvm.mlir.addressof @Q : !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2(%0 : i64) ^bb1: // pred: ^bb0 - %3 = "llvm.load"(%1) : (!llvm.ptr) -> i64 - "llvm.br"(%3)[^bb2] : (i64) -> () + %3 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> i64 + llvm.br ^bb2(%3 : i64) ^bb2(%4: i64): // 2 preds: ^bb0, ^bb1 - "llvm.store"(%4, %arg1) : (i64, !llvm.ptr) -> () - %5 = "llvm.bitcast"(%4) : (i64) -> f64 - "llvm.return"(%5) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.store %4, %arg1 {alignment = 8 : i64} : i64, !llvm.ptr + %5 = llvm.bitcast %4 : i64 to f64 + llvm.return %5 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/bitcast-sext-vector.ll.mlir b/test/LLVMDialect/InstCombine/bitcast-sext-vector.ll.mlir index 313cb29c5..e7b997496 100644 --- a/test/LLVMDialect/InstCombine/bitcast-sext-vector.ll.mlir +++ b/test/LLVMDialect/InstCombine/bitcast-sext-vector.ll.mlir @@ -1,10 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi8>, %arg1: vector<4xi8>): // no predecessors - %0 = "llvm.icmp"(%arg0, %arg1) {predicate = 0 : i64} : (vector<4xi8>, vector<4xi8>) -> i1 - %1 = "llvm.sext"(%0) : (i1) -> vector<4xi8> - %2 = "llvm.bitcast"(%1) : (vector<4xi8>) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "t", type = !llvm.func, vector<4xi8>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t(%arg0: vector<4xi8>, %arg1: vector<4xi8>) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.icmp "eq" %arg0, %arg1 : vector<4xi8> + %1 = llvm.sext %0 : vector<4xi1> to vector<4xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/bitcast-store.ll.mlir b/test/LLVMDialect/InstCombine/bitcast-store.ll.mlir index a812286f4..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/bitcast-store.ll.mlir +++ b/test/LLVMDialect/InstCombine/bitcast-store.ll.mlir @@ -1,32 +0,0 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "G", type = !llvm.array<5 x ptr>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (i32) -> f32 - "llvm.store"(%0, %arg1) : (f32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.bitcast"(%arg1) : (!llvm.ptr>) -> !llvm.ptr> - "llvm.store"(%arg0, %0) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr>>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr> - "llvm.store"(%0, %arg1) : (!llvm.ptr>, !llvm.ptr>>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "swifterror_store", type = !llvm.func, ptr>>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i128} : () -> i128 - %1 = "llvm.mlir.constant"() {value = 0 : i128} : () -> i128 - %2 = "llvm.or"(%1, %0) : (i128, i128) -> i128 - %3 = "llvm.bitcast"(%2) : (i128) -> !llvm.ppc_fp128 - "llvm.store"(%3, %arg0) : (!llvm.ppc_fp128, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "ppcf128_ones_store", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/bitcast-vec-canon-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/bitcast-vec-canon-inseltpoison.ll.mlir new file mode 100644 index 000000000..ca0491a49 --- /dev/null +++ b/test/LLVMDialect/InstCombine/bitcast-vec-canon-inseltpoison.ll.mlir @@ -0,0 +1,79 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a(%arg0: vector<1xi64>) -> f64 { + %0 = llvm.bitcast %arg0 : vector<1xi64> to f64 + llvm.return %0 : f64 + } + llvm.func @b(%arg0: vector<1xi64>) -> i64 { + %0 = llvm.bitcast %arg0 : vector<1xi64> to i64 + llvm.return %0 : i64 + } + llvm.func @c(%arg0: f64) -> vector<1xi64> { + %0 = llvm.bitcast %arg0 : f64 to vector<1xi64> + llvm.return %0 : vector<1xi64> + } + llvm.func @d(%arg0: i64) -> vector<1xi64> { + %0 = llvm.bitcast %arg0 : i64 to vector<1xi64> + llvm.return %0 : vector<1xi64> + } + llvm.func @e(%arg0: vector<1xi64>) -> !llvm.x86_mmx { + %0 = llvm.bitcast %arg0 : vector<1xi64> to !llvm.x86_mmx + llvm.return %0 : !llvm.x86_mmx + } + llvm.func @f(%arg0: !llvm.x86_mmx) -> vector<1xi64> { + %0 = llvm.bitcast %arg0 : !llvm.x86_mmx to vector<1xi64> + llvm.return %0 : vector<1xi64> + } + llvm.func @g(%arg0: !llvm.x86_mmx) -> f64 { + %0 = llvm.bitcast %arg0 : !llvm.x86_mmx to vector<1xi64> + %1 = llvm.bitcast %0 : vector<1xi64> to f64 + llvm.return %1 : f64 + } + llvm.func @bitcast_inselt_undef(%arg0: f64, %arg1: i32) -> vector<3xi64> { + %0 = llvm.mlir.poison : vector<3xi64> + %1 = llvm.bitcast %arg0 : f64 to i64 + %2 = llvm.insertelement %1, %0[%arg1 : i32] : vector<3xi64> + llvm.return %2 : vector<3xi64> + } + llvm.func @bitcast_inselt_undef_fp(%arg0: i32, %arg1: i567) -> vector<3xf32> { + %0 = llvm.mlir.poison : vector<3xf32> + %1 = llvm.bitcast %arg0 : i32 to f32 + %2 = llvm.insertelement %1, %0[%arg1 : i567] : vector<3xf32> + llvm.return %2 : vector<3xf32> + } + llvm.func @bitcast_inselt_undef_vscale(%arg0: i32, %arg1: i567) -> !llvm.vec { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.bitcast %arg0 : i32 to f32 + %2 = llvm.insertelement %1, %0[%arg1 : i567] : !llvm.vec + llvm.return %2 : !llvm.vec + } + llvm.func @use(i64) + llvm.func @bitcast_inselt_undef_extra_use(%arg0: f64, %arg1: i32) -> vector<3xi64> { + %0 = llvm.mlir.poison : vector<3xi64> + %1 = llvm.bitcast %arg0 : f64 to i64 + llvm.call @use(%1) : (i64) -> () + %2 = llvm.insertelement %1, %0[%arg1 : i32] : vector<3xi64> + llvm.return %2 : vector<3xi64> + } + llvm.func @bitcast_inselt_undef_vec_src(%arg0: vector<2xi32>, %arg1: i32) -> vector<3xi64> { + %0 = llvm.mlir.poison : vector<3xi64> + %1 = llvm.bitcast %arg0 : vector<2xi32> to i64 + %2 = llvm.insertelement %1, %0[%arg1 : i32] : vector<3xi64> + llvm.return %2 : vector<3xi64> + } + llvm.func @bitcast_inselt_undef_from_mmx(%arg0: !llvm.x86_mmx, %arg1: i32) -> vector<3xi64> { + %0 = llvm.mlir.poison : vector<3xi64> + %1 = llvm.bitcast %arg0 : !llvm.x86_mmx to i64 + %2 = llvm.insertelement %1, %0[%arg1 : i32] : vector<3xi64> + llvm.return %2 : vector<3xi64> + } + llvm.func @PR45748(%arg0: f64, %arg1: f64) -> vector<2xi64> { + %0 = llvm.mlir.poison : vector<2xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.bitcast %arg0 : f64 to i64 + %4 = llvm.insertelement %3, %0[%1 : i32] : vector<2xi64> + %5 = llvm.bitcast %arg1 : f64 to i64 + %6 = llvm.insertelement %5, %4[%2 : i32] : vector<2xi64> + llvm.return %6 : vector<2xi64> + } +} diff --git a/test/LLVMDialect/InstCombine/bitcast-vec-canon.ll.mlir b/test/LLVMDialect/InstCombine/bitcast-vec-canon.ll.mlir new file mode 100644 index 000000000..e4a7a77d3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/bitcast-vec-canon.ll.mlir @@ -0,0 +1,79 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a(%arg0: vector<1xi64>) -> f64 { + %0 = llvm.bitcast %arg0 : vector<1xi64> to f64 + llvm.return %0 : f64 + } + llvm.func @b(%arg0: vector<1xi64>) -> i64 { + %0 = llvm.bitcast %arg0 : vector<1xi64> to i64 + llvm.return %0 : i64 + } + llvm.func @c(%arg0: f64) -> vector<1xi64> { + %0 = llvm.bitcast %arg0 : f64 to vector<1xi64> + llvm.return %0 : vector<1xi64> + } + llvm.func @d(%arg0: i64) -> vector<1xi64> { + %0 = llvm.bitcast %arg0 : i64 to vector<1xi64> + llvm.return %0 : vector<1xi64> + } + llvm.func @e(%arg0: vector<1xi64>) -> !llvm.x86_mmx { + %0 = llvm.bitcast %arg0 : vector<1xi64> to !llvm.x86_mmx + llvm.return %0 : !llvm.x86_mmx + } + llvm.func @f(%arg0: !llvm.x86_mmx) -> vector<1xi64> { + %0 = llvm.bitcast %arg0 : !llvm.x86_mmx to vector<1xi64> + llvm.return %0 : vector<1xi64> + } + llvm.func @g(%arg0: !llvm.x86_mmx) -> f64 { + %0 = llvm.bitcast %arg0 : !llvm.x86_mmx to vector<1xi64> + %1 = llvm.bitcast %0 : vector<1xi64> to f64 + llvm.return %1 : f64 + } + llvm.func @bitcast_inselt_undef(%arg0: f64, %arg1: i32) -> vector<3xi64> { + %0 = llvm.mlir.undef : vector<3xi64> + %1 = llvm.bitcast %arg0 : f64 to i64 + %2 = llvm.insertelement %1, %0[%arg1 : i32] : vector<3xi64> + llvm.return %2 : vector<3xi64> + } + llvm.func @bitcast_inselt_undef_fp(%arg0: i32, %arg1: i567) -> vector<3xf32> { + %0 = llvm.mlir.undef : vector<3xf32> + %1 = llvm.bitcast %arg0 : i32 to f32 + %2 = llvm.insertelement %1, %0[%arg1 : i567] : vector<3xf32> + llvm.return %2 : vector<3xf32> + } + llvm.func @bitcast_inselt_undef_vscale(%arg0: i32, %arg1: i567) -> !llvm.vec { + %0 = llvm.mlir.undef : !llvm.vec + %1 = llvm.bitcast %arg0 : i32 to f32 + %2 = llvm.insertelement %1, %0[%arg1 : i567] : !llvm.vec + llvm.return %2 : !llvm.vec + } + llvm.func @use(i64) + llvm.func @bitcast_inselt_undef_extra_use(%arg0: f64, %arg1: i32) -> vector<3xi64> { + %0 = llvm.mlir.undef : vector<3xi64> + %1 = llvm.bitcast %arg0 : f64 to i64 + llvm.call @use(%1) : (i64) -> () + %2 = llvm.insertelement %1, %0[%arg1 : i32] : vector<3xi64> + llvm.return %2 : vector<3xi64> + } + llvm.func @bitcast_inselt_undef_vec_src(%arg0: vector<2xi32>, %arg1: i32) -> vector<3xi64> { + %0 = llvm.mlir.undef : vector<3xi64> + %1 = llvm.bitcast %arg0 : vector<2xi32> to i64 + %2 = llvm.insertelement %1, %0[%arg1 : i32] : vector<3xi64> + llvm.return %2 : vector<3xi64> + } + llvm.func @bitcast_inselt_undef_from_mmx(%arg0: !llvm.x86_mmx, %arg1: i32) -> vector<3xi64> { + %0 = llvm.mlir.undef : vector<3xi64> + %1 = llvm.bitcast %arg0 : !llvm.x86_mmx to i64 + %2 = llvm.insertelement %1, %0[%arg1 : i32] : vector<3xi64> + llvm.return %2 : vector<3xi64> + } + llvm.func @PR45748(%arg0: f64, %arg1: f64) -> vector<2xi64> { + %0 = llvm.mlir.undef : vector<2xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.bitcast %arg0 : f64 to i64 + %4 = llvm.insertelement %3, %0[%1 : i32] : vector<2xi64> + %5 = llvm.bitcast %arg1 : f64 to i64 + %6 = llvm.insertelement %5, %4[%2 : i32] : vector<2xi64> + llvm.return %6 : vector<2xi64> + } +} diff --git a/test/LLVMDialect/InstCombine/bitcast.ll.mlir b/test/LLVMDialect/InstCombine/bitcast.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/bitreverse-hang.ll.mlir b/test/LLVMDialect/InstCombine/bitreverse-hang.ll.mlir index c68eb0b29..9465d101a 100644 --- a/test/LLVMDialect/InstCombine/bitreverse-hang.ll.mlir +++ b/test/LLVMDialect/InstCombine/bitreverse-hang.ll.mlir @@ -1,24 +1,25 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 5 : i64, sym_name = "b", type = i32, value = 0 : i32} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.undef"() : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @b} : () -> !llvm.ptr - %2 = "llvm.mlir.constant"() {value = 32 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %5 = "llvm.mlir.addressof"() {global_name = @b} : () -> !llvm.ptr - %6 = "llvm.load"(%5) : (!llvm.ptr) -> i32 - "llvm.br"(%6, %4)[^bb1] : (i32, i32) -> () - ^bb1(%7: i32, %8: i32): // 2 preds: ^bb0, ^bb1 - %9 = "llvm.lshr"(%7, %3) : (i32, i32) -> i32 - %10 = "llvm.or"(%9, %7) : (i32, i32) -> i32 - %11 = "llvm.add"(%8, %3) : (i32, i32) -> i32 - %12 = "llvm.icmp"(%11, %2) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%12, %10, %11)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 0, 2]> : vector<3xi32>} : (i1, i32, i32) -> () +#tbaa_root = #llvm.tbaa_root +#tbaa_type_desc = #llvm.tbaa_type_desc}> +#tbaa_type_desc1 = #llvm.tbaa_type_desc}> +#tbaa_tag = #llvm.tbaa_tag +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @b(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.func @fn1() -> i32 attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["norecurse", "nounwind", "ssp", ["uwtable", "2"], ["disable-tail-calls", "false"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["target-cpu", "core2"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]], target_cpu = "core2", target_features = #llvm.target_features<["+cx16", "+fxsr", "+mmx", "+sse", "+sse2", "+sse3", "+ssse3"]>} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @b : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(32 : i32) : i32 + %4 = llvm.mlir.undef : i32 + %5 = llvm.load %1 {alignment = 4 : i64, tbaa = [#tbaa_tag]} : !llvm.ptr -> i32 + llvm.br ^bb1(%5, %0 : i32, i32) + ^bb1(%6: i32, %7: i32): // 2 preds: ^bb0, ^bb1 + %8 = llvm.lshr %6, %2 : i32 + %9 = llvm.or %8, %6 : i32 + %10 = llvm.add %7, %2 overflow : i32 + %11 = llvm.icmp "eq" %10, %3 : i32 + llvm.cond_br %11, ^bb2, ^bb1(%9, %10 : i32, i32) ^bb2: // pred: ^bb1 - "llvm.store"(%10, %1) : (i32, !llvm.ptr) -> () - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "fn1", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.store %9, %1 {alignment = 4 : i64, tbaa = [#tbaa_tag]} : i32, !llvm.ptr + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/bitreverse-known-bits.ll.mlir b/test/LLVMDialect/InstCombine/bitreverse-known-bits.ll.mlir index 450852a8a..291738f16 100644 --- a/test/LLVMDialect/InstCombine/bitreverse-known-bits.ll.mlir +++ b/test/LLVMDialect/InstCombine/bitreverse-known-bits.ll.mlir @@ -1,48 +1,39 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.bitreverse.i8", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.bitreverse.i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 65535 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -65536 : i32} : () -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.call"(%2) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %4 = "llvm.and"(%3, %0) : (i32, i32) -> i32 - %5 = "llvm.icmp"(%4, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2147483648 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.call"(%2) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %4 = "llvm.and"(%3, %0) : (i32, i32) -> i32 - %5 = "llvm.call"(%4) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %6 = "llvm.icmp"(%5, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 32768 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 65536 : i32} : () -> i32 - %3 = "llvm.or"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.call"(%3) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %5 = "llvm.and"(%4, %1) : (i32, i32) -> i32 - %6 = "llvm.icmp"(%5, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -16 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = -4 : i8} : () -> i8 - %2 = "llvm.and"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.call"(%2) {callee = @llvm.bitreverse.i8, fastmathFlags = #llvm.fastmath<>} : (i8) -> i8 - %4 = "llvm.add"(%3, %0) : (i8, i8) -> i8 - "llvm.return"(%4) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "add_bitreverse", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.intr.bitreverse(%2) : (i32) -> i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @test2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.intr.bitreverse(%2) : (i32) -> i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.intr.bitreverse(%4) : (i32) -> i32 + %6 = llvm.icmp "eq" %5, %0 : i32 + llvm.return %6 : i1 + } + llvm.func @test3(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.mlir.constant(32768 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.or %arg0, %0 : i32 + %4 = llvm.intr.bitreverse(%3) : (i32) -> i32 + %5 = llvm.and %4, %1 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @add_bitreverse(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-4 : i8) : i8 + %1 = llvm.mlir.constant(-16 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.intr.bitreverse(%2) : (i8) -> i8 + %4 = llvm.add %3, %1 : i8 + llvm.return %4 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/bitreverse.ll.mlir b/test/LLVMDialect/InstCombine/bitreverse.ll.mlir new file mode 100644 index 000000000..8b3d38a04 --- /dev/null +++ b/test/LLVMDialect/InstCombine/bitreverse.ll.mlir @@ -0,0 +1,392 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use_i32(i32) + llvm.func @use_i64(i64) + llvm.func @rev8(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(51 : i8) : i8 + %3 = llvm.mlir.constant(-52 : i8) : i8 + %4 = llvm.mlir.constant(1 : i8) : i8 + %5 = llvm.mlir.constant(85 : i8) : i8 + %6 = llvm.mlir.constant(-86 : i8) : i8 + %7 = llvm.lshr %arg0, %0 : i8 + %8 = llvm.shl %arg0, %0 : i8 + %9 = llvm.or %7, %8 : i8 + %10 = llvm.lshr %9, %1 : i8 + %11 = llvm.and %10, %2 : i8 + %12 = llvm.shl %9, %1 : i8 + %13 = llvm.and %12, %3 : i8 + %14 = llvm.or %11, %13 : i8 + %15 = llvm.lshr %14, %4 : i8 + %16 = llvm.and %15, %5 : i8 + %17 = llvm.shl %14, %4 : i8 + %18 = llvm.and %17, %6 : i8 + %19 = llvm.or %16, %18 : i8 + llvm.return %19 : i8 + } + llvm.func @rev16(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(4 : i16) : i16 + %2 = llvm.mlir.constant(3855 : i16) : i16 + %3 = llvm.mlir.constant(-3856 : i16) : i16 + %4 = llvm.mlir.constant(2 : i16) : i16 + %5 = llvm.mlir.constant(13107 : i16) : i16 + %6 = llvm.mlir.constant(-13108 : i16) : i16 + %7 = llvm.mlir.constant(1 : i16) : i16 + %8 = llvm.mlir.constant(21845 : i16) : i16 + %9 = llvm.mlir.constant(-21846 : i16) : i16 + %10 = llvm.lshr %arg0, %0 : i16 + %11 = llvm.shl %arg0, %0 : i16 + %12 = llvm.or %10, %11 : i16 + %13 = llvm.lshr %12, %1 : i16 + %14 = llvm.and %13, %2 : i16 + %15 = llvm.shl %12, %1 : i16 + %16 = llvm.and %15, %3 : i16 + %17 = llvm.or %14, %16 : i16 + %18 = llvm.lshr %17, %4 : i16 + %19 = llvm.and %18, %5 : i16 + %20 = llvm.shl %17, %4 : i16 + %21 = llvm.and %20, %6 : i16 + %22 = llvm.or %19, %21 : i16 + %23 = llvm.lshr %22, %7 : i16 + %24 = llvm.and %23, %8 : i16 + %25 = llvm.shl %22, %7 : i16 + %26 = llvm.and %25, %9 : i16 + %27 = llvm.or %24, %26 : i16 + llvm.return %27 : i16 + } + llvm.func @rev32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(16711935 : i32) : i32 + %3 = llvm.mlir.constant(-16711936 : i32) : i32 + %4 = llvm.mlir.constant(4 : i32) : i32 + %5 = llvm.mlir.constant(252645135 : i32) : i32 + %6 = llvm.mlir.constant(-252645136 : i32) : i32 + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.mlir.constant(858993459 : i32) : i32 + %9 = llvm.mlir.constant(-858993460 : i32) : i32 + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.mlir.constant(1431655765 : i32) : i32 + %12 = llvm.mlir.constant(-1431655766 : i32) : i32 + %13 = llvm.lshr %arg0, %0 : i32 + %14 = llvm.shl %arg0, %0 : i32 + %15 = llvm.or %13, %14 : i32 + %16 = llvm.lshr %15, %1 : i32 + %17 = llvm.and %16, %2 : i32 + %18 = llvm.shl %15, %1 : i32 + %19 = llvm.and %18, %3 : i32 + %20 = llvm.or %17, %19 : i32 + %21 = llvm.lshr %20, %4 : i32 + %22 = llvm.and %21, %5 : i32 + %23 = llvm.shl %20, %4 : i32 + %24 = llvm.and %23, %6 : i32 + %25 = llvm.or %22, %24 : i32 + %26 = llvm.lshr %25, %7 : i32 + %27 = llvm.and %26, %8 : i32 + %28 = llvm.shl %25, %7 : i32 + %29 = llvm.and %28, %9 : i32 + %30 = llvm.or %27, %29 : i32 + %31 = llvm.lshr %30, %10 : i32 + %32 = llvm.and %31, %11 : i32 + %33 = llvm.shl %30, %10 : i32 + %34 = llvm.and %33, %12 : i32 + %35 = llvm.or %32, %34 : i32 + llvm.return %35 : i32 + } + llvm.func @rev32_bswap(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(1431655765 : i32) : i32 + %2 = llvm.mlir.constant(-1431655766 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(858993459 : i32) : i32 + %5 = llvm.mlir.constant(-858993460 : i32) : i32 + %6 = llvm.mlir.constant(4 : i32) : i32 + %7 = llvm.mlir.constant(252645135 : i32) : i32 + %8 = llvm.mlir.constant(-252645136 : i32) : i32 + %9 = llvm.lshr %arg0, %0 : i32 + %10 = llvm.and %9, %1 : i32 + %11 = llvm.shl %arg0, %0 : i32 + %12 = llvm.and %11, %2 : i32 + %13 = llvm.or %10, %12 : i32 + %14 = llvm.lshr %13, %3 : i32 + %15 = llvm.and %14, %4 : i32 + %16 = llvm.shl %13, %3 : i32 + %17 = llvm.and %16, %5 : i32 + %18 = llvm.or %15, %17 : i32 + %19 = llvm.lshr %18, %6 : i32 + %20 = llvm.and %19, %7 : i32 + %21 = llvm.shl %18, %6 : i32 + %22 = llvm.and %21, %8 : i32 + %23 = llvm.or %20, %22 : i32 + %24 = llvm.intr.bswap(%23) : (i32) -> i32 + llvm.return %24 : i32 + } + llvm.func @rev64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(16 : i64) : i64 + %2 = llvm.mlir.constant(281470681808895 : i64) : i64 + %3 = llvm.mlir.constant(-281470681808896 : i64) : i64 + %4 = llvm.mlir.constant(8 : i64) : i64 + %5 = llvm.mlir.constant(71777214294589695 : i64) : i64 + %6 = llvm.mlir.constant(-71777214294589696 : i64) : i64 + %7 = llvm.mlir.constant(4 : i64) : i64 + %8 = llvm.mlir.constant(1085102592571150095 : i64) : i64 + %9 = llvm.mlir.constant(-1085102592571150096 : i64) : i64 + %10 = llvm.mlir.constant(2 : i64) : i64 + %11 = llvm.mlir.constant(3689348814741910323 : i64) : i64 + %12 = llvm.mlir.constant(-3689348814741910324 : i64) : i64 + %13 = llvm.mlir.constant(1 : i64) : i64 + %14 = llvm.mlir.constant(6148914691236517205 : i64) : i64 + %15 = llvm.mlir.constant(-6148914691236517206 : i64) : i64 + %16 = llvm.lshr %arg0, %0 : i64 + %17 = llvm.shl %arg0, %0 : i64 + %18 = llvm.or %16, %17 : i64 + %19 = llvm.lshr %18, %1 : i64 + %20 = llvm.and %19, %2 : i64 + %21 = llvm.shl %18, %1 : i64 + %22 = llvm.and %21, %3 : i64 + %23 = llvm.or %20, %22 : i64 + %24 = llvm.lshr %23, %4 : i64 + %25 = llvm.and %24, %5 : i64 + %26 = llvm.shl %23, %4 : i64 + %27 = llvm.and %26, %6 : i64 + %28 = llvm.or %25, %27 : i64 + %29 = llvm.lshr %28, %7 : i64 + %30 = llvm.and %29, %8 : i64 + %31 = llvm.shl %28, %7 : i64 + %32 = llvm.and %31, %9 : i64 + %33 = llvm.or %30, %32 : i64 + %34 = llvm.lshr %33, %10 : i64 + %35 = llvm.and %34, %11 : i64 + %36 = llvm.shl %33, %10 : i64 + %37 = llvm.and %36, %12 : i64 + %38 = llvm.or %35, %37 : i64 + %39 = llvm.lshr %38, %13 : i64 + %40 = llvm.and %39, %14 : i64 + %41 = llvm.shl %38, %13 : i64 + %42 = llvm.and %41, %15 : i64 + %43 = llvm.or %40, %42 : i64 + llvm.return %43 : i64 + } + llvm.func @rev8_xor(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(85 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(6 : i8) : i8 + %3 = llvm.mlir.constant(102 : i8) : i8 + %4 = llvm.mlir.constant(4 : i8) : i8 + %5 = llvm.mlir.constant(5 : i8) : i8 + %6 = llvm.mlir.constant(1 : i8) : i8 + %7 = llvm.mlir.constant(7 : i8) : i8 + %8 = llvm.and %arg0, %0 : i8 + %9 = llvm.xor %arg0, %8 : i8 + %10 = llvm.shl %8, %1 : i8 + %11 = llvm.lshr %8, %2 : i8 + %12 = llvm.or %11, %9 : i8 + %13 = llvm.or %12, %10 : i8 + %14 = llvm.and %13, %3 : i8 + %15 = llvm.xor %13, %14 : i8 + %16 = llvm.lshr %14, %4 : i8 + %17 = llvm.or %16, %15 : i8 + %18 = llvm.shl %14, %5 : i8 + %19 = llvm.shl %17, %6 : i8 + %20 = llvm.or %18, %19 : i8 + %21 = llvm.lshr %arg0, %7 : i8 + %22 = llvm.or %20, %21 : i8 + llvm.return %22 : i8 + } + llvm.func @rev8_xor_vector(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<85> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<102> : vector<2xi8>) : vector<2xi8> + %4 = llvm.mlir.constant(dense<4> : vector<2xi8>) : vector<2xi8> + %5 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %6 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %7 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %8 = llvm.and %arg0, %0 : vector<2xi8> + %9 = llvm.xor %arg0, %8 : vector<2xi8> + %10 = llvm.shl %8, %1 : vector<2xi8> + %11 = llvm.lshr %8, %2 : vector<2xi8> + %12 = llvm.or %11, %9 : vector<2xi8> + %13 = llvm.or %12, %10 : vector<2xi8> + %14 = llvm.and %13, %3 : vector<2xi8> + %15 = llvm.xor %13, %14 : vector<2xi8> + %16 = llvm.lshr %14, %4 : vector<2xi8> + %17 = llvm.or %16, %15 : vector<2xi8> + %18 = llvm.shl %14, %5 : vector<2xi8> + %19 = llvm.shl %17, %6 : vector<2xi8> + %20 = llvm.or %18, %19 : vector<2xi8> + %21 = llvm.lshr %arg0, %7 : vector<2xi8> + %22 = llvm.or %20, %21 : vector<2xi8> + llvm.return %22 : vector<2xi8> + } + llvm.func @rev8_mul_and_urem(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(8623620610 : i64) : i64 + %1 = llvm.mlir.constant(1136090292240 : i64) : i64 + %2 = llvm.mlir.constant(1023 : i64) : i64 + %3 = llvm.zext %arg0 : i8 to i64 + %4 = llvm.mul %3, %0 overflow : i64 + %5 = llvm.and %4, %1 : i64 + %6 = llvm.urem %5, %2 : i64 + %7 = llvm.trunc %6 : i64 to i8 + llvm.return %7 : i8 + } + llvm.func @rev8_mul_and_mul(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(2149582850 : i64) : i64 + %1 = llvm.mlir.constant(36578664720 : i64) : i64 + %2 = llvm.mlir.constant(4311810305 : i64) : i64 + %3 = llvm.mlir.constant(32 : i64) : i64 + %4 = llvm.zext %arg0 : i8 to i64 + %5 = llvm.mul %4, %0 overflow : i64 + %6 = llvm.and %5, %1 : i64 + %7 = llvm.mul %6, %2 : i64 + %8 = llvm.lshr %7, %3 : i64 + %9 = llvm.trunc %8 : i64 to i8 + llvm.return %9 : i8 + } + llvm.func @rev8_mul_and_lshr(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(2050 : i64) : i64 + %1 = llvm.mlir.constant(139536 : i64) : i64 + %2 = llvm.mlir.constant(32800 : i64) : i64 + %3 = llvm.mlir.constant(558144 : i64) : i64 + %4 = llvm.mlir.constant(65793 : i64) : i64 + %5 = llvm.mlir.constant(16 : i64) : i64 + %6 = llvm.zext %arg0 : i8 to i64 + %7 = llvm.mul %6, %0 overflow : i64 + %8 = llvm.and %7, %1 : i64 + %9 = llvm.mul %6, %2 overflow : i64 + %10 = llvm.and %9, %3 : i64 + %11 = llvm.or %8, %10 : i64 + %12 = llvm.mul %11, %4 overflow : i64 + %13 = llvm.lshr %12, %5 : i64 + %14 = llvm.trunc %13 : i64 to i8 + llvm.return %14 : i8 + } + llvm.func @shuf_4bits(%arg0: vector<4xi1>) -> i4 { + %0 = llvm.mlir.undef : vector<4xi1> + %1 = llvm.shufflevector %arg0, %0 [3, 2, 1, 0] : vector<4xi1> + %2 = llvm.bitcast %1 : vector<4xi1> to i4 + llvm.return %2 : i4 + } + llvm.func @shuf_load_4bits(%arg0: !llvm.ptr) -> i4 { + %0 = llvm.mlir.undef : vector<4xi1> + %1 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> vector<4xi1> + %2 = llvm.shufflevector %1, %0 [3, 2, 1, 0] : vector<4xi1> + %3 = llvm.bitcast %2 : vector<4xi1> to i4 + llvm.return %3 : i4 + } + llvm.func @shuf_bitcast_twice_4bits(%arg0: i4) -> i4 { + %0 = llvm.mlir.undef : vector<4xi1> + %1 = llvm.bitcast %arg0 : i4 to vector<4xi1> + %2 = llvm.shufflevector %1, %0 [-1, 2, 1, 0] : vector<4xi1> + %3 = llvm.bitcast %2 : vector<4xi1> to i4 + llvm.return %3 : i4 + } + llvm.func @shuf_4bits_not_reverse(%arg0: vector<4xi1>) -> i4 { + %0 = llvm.mlir.undef : vector<4xi1> + %1 = llvm.shufflevector %arg0, %0 [3, 1, 2, 0] : vector<4xi1> + %2 = llvm.bitcast %1 : vector<4xi1> to i4 + llvm.return %2 : i4 + } + llvm.func @use(vector<4xi1>) + llvm.func @shuf_4bits_extra_use(%arg0: vector<4xi1>) -> i4 { + %0 = llvm.mlir.undef : vector<4xi1> + %1 = llvm.shufflevector %arg0, %0 [3, 2, 1, 0] : vector<4xi1> + llvm.call @use(%1) : (vector<4xi1>) -> () + %2 = llvm.bitcast %1 : vector<4xi1> to i4 + llvm.return %2 : i4 + } + llvm.func @rev_i1(%arg0: i1) -> i32 { + %0 = llvm.zext %arg0 : i1 to i32 + llvm.call @use_i32(%0) : (i32) -> () + %1 = llvm.intr.bitreverse(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @rev_v2i1(%arg0: vector<2xi1>) -> vector<2xi8> { + %0 = llvm.zext %arg0 : vector<2xi1> to vector<2xi8> + %1 = llvm.intr.bitreverse(%0) : (vector<2xi8>) -> vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @rev_i2(%arg0: i2) -> i32 { + %0 = llvm.zext %arg0 : i2 to i32 + %1 = llvm.intr.bitreverse(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @PR59897(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.zext %arg0 : i1 to i32 + %3 = llvm.intr.bitreverse(%2) : (i32) -> i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.lshr %4, %1 : i32 + %6 = llvm.zext %5 : i32 to i64 + llvm.return %6 : i64 + } + llvm.func @rev_xor_lhs_rev16(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.intr.bitreverse(%arg0) : (i16) -> i16 + %1 = llvm.xor %0, %arg1 : i16 + %2 = llvm.intr.bitreverse(%1) : (i16) -> i16 + llvm.return %2 : i16 + } + llvm.func @rev_and_rhs_rev32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.bitreverse(%arg1) : (i32) -> i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.intr.bitreverse(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @rev_or_rhs_rev32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.bitreverse(%arg1) : (i32) -> i32 + %1 = llvm.or %arg0, %0 : i32 + %2 = llvm.intr.bitreverse(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @rev_or_rhs_rev64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bitreverse(%arg1) : (i64) -> i64 + %1 = llvm.or %arg0, %0 : i64 + %2 = llvm.intr.bitreverse(%1) : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @rev_xor_rhs_rev64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bitreverse(%arg1) : (i64) -> i64 + %1 = llvm.xor %arg0, %0 : i64 + %2 = llvm.intr.bitreverse(%1) : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @rev_xor_rhs_i32vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.intr.bitreverse(%arg1) : (vector<2xi32>) -> vector<2xi32> + %1 = llvm.xor %arg0, %0 : vector<2xi32> + %2 = llvm.intr.bitreverse(%1) : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @rev_and_rhs_rev64_multiuse1(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bitreverse(%arg1) : (i64) -> i64 + %1 = llvm.and %arg0, %0 : i64 + %2 = llvm.intr.bitreverse(%1) : (i64) -> i64 + %3 = llvm.mul %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @rev_and_rhs_rev64_multiuse2(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bitreverse(%arg1) : (i64) -> i64 + %1 = llvm.and %arg0, %0 : i64 + %2 = llvm.intr.bitreverse(%1) : (i64) -> i64 + %3 = llvm.mul %0, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @rev_all_operand64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bitreverse(%arg0) : (i64) -> i64 + %1 = llvm.intr.bitreverse(%arg1) : (i64) -> i64 + %2 = llvm.and %0, %1 : i64 + %3 = llvm.intr.bitreverse(%2) : (i64) -> i64 + llvm.return %3 : i64 + } + llvm.func @rev_all_operand64_multiuse_both(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bitreverse(%arg0) : (i64) -> i64 + %1 = llvm.intr.bitreverse(%arg1) : (i64) -> i64 + %2 = llvm.and %0, %1 : i64 + %3 = llvm.intr.bitreverse(%2) : (i64) -> i64 + llvm.call @use_i64(%0) : (i64) -> () + llvm.call @use_i64(%1) : (i64) -> () + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/bittest.ll.mlir b/test/LLVMDialect/InstCombine/bittest.ll.mlir new file mode 100644 index 000000000..40883292f --- /dev/null +++ b/test/LLVMDialect/InstCombine/bittest.ll.mlir @@ -0,0 +1,29 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @b_rec.0() {addr_space = 0 : i32} : i32 + llvm.func @_Z12h000007_testv(%arg0: !llvm.ptr) { + %0 = llvm.mlir.addressof @b_rec.0 : !llvm.ptr + %1 = llvm.mlir.constant(-989855744 : i32) : i32 + %2 = llvm.mlir.constant(-805306369 : i32) : i32 + %3 = llvm.mlir.constant(-973078529 : i32) : i32 + %4 = llvm.mlir.constant(-1073741824 : i32) : i32 + %5 = llvm.mlir.constant(100663295 : i32) : i32 + %6 = llvm.load %0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %7 = llvm.or %6, %1 : i32 + %8 = llvm.and %7, %2 : i32 + %9 = llvm.and %7, %3 : i32 + llvm.store %9, %0 {alignment = 4 : i64} : i32, !llvm.ptr + %10 = llvm.bitcast %8 : i32 to i32 + %11 = llvm.and %10, %4 : i32 + %12 = llvm.icmp "eq" %11, %4 : i32 + llvm.cond_br %12, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.call @abort() : () -> () + llvm.unreachable + ^bb2: // pred: ^bb0 + %13 = llvm.bitcast %8 : i32 to i32 + %14 = llvm.and %13, %5 : i32 + llvm.store %14, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @abort() +} diff --git a/test/LLVMDialect/InstCombine/bitwiselogic-bitmanip.ll.mlir b/test/LLVMDialect/InstCombine/bitwiselogic-bitmanip.ll.mlir new file mode 100644 index 000000000..80b6c4570 --- /dev/null +++ b/test/LLVMDialect/InstCombine/bitwiselogic-bitmanip.ll.mlir @@ -0,0 +1,104 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_or_fshl(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.intr.fshl(%arg0, %arg1, %arg4) : (i32, i32, i32) -> i32 + %1 = llvm.intr.fshl(%arg2, %arg3, %arg4) : (i32, i32, i32) -> i32 + %2 = llvm.or %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_and_fshl(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.intr.fshl(%arg0, %arg1, %arg4) : (i32, i32, i32) -> i32 + %1 = llvm.intr.fshl(%arg2, %arg3, %arg4) : (i32, i32, i32) -> i32 + %2 = llvm.and %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_xor_fshl(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.intr.fshl(%arg0, %arg1, %arg4) : (i32, i32, i32) -> i32 + %1 = llvm.intr.fshl(%arg2, %arg3, %arg4) : (i32, i32, i32) -> i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_fshr(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.intr.fshr(%arg0, %arg1, %arg4) : (i32, i32, i32) -> i32 + %1 = llvm.intr.fshr(%arg2, %arg3, %arg4) : (i32, i32, i32) -> i32 + %2 = llvm.or %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_fshl_cascade(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.intr.fshl(%arg0, %arg0, %0) : (i32, i32, i32) -> i32 + %2 = llvm.intr.fshl(%arg1, %arg1, %0) : (i32, i32, i32) -> i32 + %3 = llvm.intr.fshl(%arg2, %arg2, %0) : (i32, i32, i32) -> i32 + %4 = llvm.or %1, %2 : i32 + %5 = llvm.or %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @test_or_bitreverse(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.bitreverse(%arg0) : (i32) -> i32 + %1 = llvm.intr.bitreverse(%arg1) : (i32) -> i32 + %2 = llvm.or %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_bitreverse_constant(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-16777216 : i32) : i32 + %1 = llvm.intr.bitreverse(%arg0) : (i32) -> i32 + %2 = llvm.or %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_bswap(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.bswap(%arg0) : (i32) -> i32 + %1 = llvm.intr.bswap(%arg1) : (i32) -> i32 + %2 = llvm.or %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_bswap_constant(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-16777216 : i32) : i32 + %1 = llvm.intr.bswap(%arg0) : (i32) -> i32 + %2 = llvm.or %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_fshl_fshr(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.intr.fshl(%arg0, %arg1, %arg4) : (i32, i32, i32) -> i32 + %1 = llvm.intr.fshr(%arg2, %arg3, %arg4) : (i32, i32, i32) -> i32 + %2 = llvm.or %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_bitreverse_bswap(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.bitreverse(%arg0) : (i32) -> i32 + %1 = llvm.intr.bswap(%arg1) : (i32) -> i32 + %2 = llvm.or %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_fshl_mismatched_shamt(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32, %arg5: i32) -> i32 { + %0 = llvm.intr.fshl(%arg0, %arg1, %arg4) : (i32, i32, i32) -> i32 + %1 = llvm.intr.fshl(%arg2, %arg3, %arg5) : (i32, i32, i32) -> i32 + %2 = llvm.or %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_add_fshl(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.intr.fshl(%arg0, %arg1, %arg4) : (i32, i32, i32) -> i32 + %1 = llvm.intr.fshl(%arg2, %arg3, %arg4) : (i32, i32, i32) -> i32 + %2 = llvm.add %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_fshl_multiuse(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32) -> i32 { + %0 = llvm.intr.fshl(%arg0, %arg1, %arg4) : (i32, i32, i32) -> i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.intr.fshl(%arg2, %arg3, %arg4) : (i32, i32, i32) -> i32 + %2 = llvm.or %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_bitreverse_multiuse(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.bitreverse(%arg0) : (i32) -> i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.intr.bitreverse(%arg1) : (i32) -> i32 + %2 = llvm.or %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_fshl_constant(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-16777216 : i32) : i32 + %1 = llvm.intr.fshl(%arg0, %arg1, %arg2) : (i32, i32, i32) -> i32 + %2 = llvm.or %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @use(i32) +} diff --git a/test/LLVMDialect/InstCombine/branch.ll.mlir b/test/LLVMDialect/InstCombine/branch.ll.mlir index 8fd8f396e..bec6b3007 100644 --- a/test/LLVMDialect/InstCombine/branch.ll.mlir +++ b/test/LLVMDialect/InstCombine/branch.ll.mlir @@ -1,59 +1,119 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "global", type = i8, value = 0 : i8} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 6 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%1)[^bb1, ^bb1] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @global(0 : i8) {addr_space = 0 : i32} : i8 + llvm.func @use(i1) + llvm.func @test(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.icmp "ult" %arg0, %0 : i32 + llvm.cond_br %1, ^bb1, ^bb1 ^bb1: // 2 preds: ^bb0, ^bb0 - "llvm.return"(%arg0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @global} : () -> !llvm.ptr - %1 = "llvm.ptrtoint"(%0) : (!llvm.ptr) -> i32 - %2 = "llvm.mlir.constant"() {value = 27 : i32} : () -> i32 - %3 = "llvm.icmp"(%2, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%3)[^bb1, ^bb1] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.return %arg0 : i32 + } + llvm.func @pat(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(27 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.addressof @global : !llvm.ptr + %3 = llvm.ptrtoint %2 : !llvm.ptr to i32 + %4 = llvm.icmp "eq" %0, %3 : i32 + llvm.cond_br %4, ^bb1, ^bb1 ^bb1: // 2 preds: ^bb0, ^bb0 - "llvm.return"(%arg0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "pat", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = true} : () -> i1 - "llvm.cond_br"(%arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.return %arg0 : i32 + } + llvm.func @test01(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.br"(%1)[^bb3] : (i1) -> () + llvm.br ^bb3(%1 : i1) ^bb2: // pred: ^bb0 - "llvm.br"(%0)[^bb3] : (i1) -> () + llvm.br ^bb3(%0 : i1) ^bb3(%2: i1): // 2 preds: ^bb1, ^bb2 - "llvm.cond_br"(%2)[^bb4, ^bb5] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.cond_br %2, ^bb4, ^bb5 ^bb4: // pred: ^bb3 - "llvm.br"(%1)[^bb6] : (i1) -> () + llvm.br ^bb6(%1 : i1) ^bb5: // pred: ^bb3 - "llvm.br"(%0)[^bb6] : (i1) -> () + llvm.br ^bb6(%0 : i1) ^bb6(%3: i1): // 2 preds: ^bb4, ^bb5 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test01", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - "llvm.cond_br"(%arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.return %3 : i1 + } + llvm.func @test02(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.br"(%1)[^bb3] : (i1) -> () + llvm.br ^bb3(%1 : i1) ^bb2: // pred: ^bb0 - "llvm.br"(%0)[^bb3] : (i1) -> () + llvm.br ^bb3(%0 : i1) ^bb3(%2: i1): // 2 preds: ^bb1, ^bb2 - "llvm.cond_br"(%2)[^bb4, ^bb5] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.cond_br %2, ^bb4, ^bb5 ^bb4: // pred: ^bb3 - "llvm.br"(%1)[^bb6] : (i1) -> () + llvm.br ^bb6(%1 : i1) ^bb5: // pred: ^bb3 - "llvm.br"(%0)[^bb6] : (i1) -> () + llvm.br ^bb6(%0 : i1) ^bb6(%3: i1): // 2 preds: ^bb4, ^bb5 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test02", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %3 : i1 + } + llvm.func @logical_and_not(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.xor %arg1, %0 : i1 + %5 = llvm.select %arg0, %4, %1 : i1, i1 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %3 : i32 + ^bb2: // pred: ^bb0 + llvm.return %2 : i32 + } + llvm.func @logical_and_or(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.select %arg0, %arg1, %0 : i1, i1 + llvm.cond_br %3, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %2 : i32 + } + llvm.func @logical_or_not(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.xor %arg0, %0 : i1 + %4 = llvm.select %3, %0, %arg1 : i1, i1 + llvm.cond_br %4, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %2 : i32 + } + llvm.func @logical_and_not_use1(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.xor %arg1, %0 : i1 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.select %arg0, %4, %1 : i1, i1 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %3 : i32 + ^bb2: // pred: ^bb0 + llvm.return %2 : i32 + } + llvm.func @logical_and_not_use2(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.xor %arg1, %0 : i1 + %5 = llvm.select %arg0, %4, %1 : i1, i1 + llvm.call @use(%5) : (i1) -> () + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %3 : i32 + ^bb2: // pred: ^bb0 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/broadcast-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/broadcast-inseltpoison.ll.mlir new file mode 100644 index 000000000..4f9218c52 --- /dev/null +++ b/test/LLVMDialect/InstCombine/broadcast-inseltpoison.ll.mlir @@ -0,0 +1,144 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @good1(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg0, %5[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%4 : i32] : vector<4xf32> + llvm.return %8 : vector<4xf32> + } + llvm.func @good2(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg0, %5[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%4 : i32] : vector<4xf32> + llvm.return %8 : vector<4xf32> + } + llvm.func @good3(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.insertelement %arg0, %1[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%4 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg0, %8[%5 : i32] : vector<4xf32> + llvm.return %9 : vector<4xf32> + } + llvm.func @good4(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.insertelement %arg0, %1[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%4 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg0, %8[%5 : i32] : vector<4xf32> + %10 = llvm.fadd %9, %9 : vector<4xf32> + llvm.return %10 : vector<4xf32> + } + llvm.func @good5(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %6 = llvm.fadd %5, %5 : vector<4xf32> + %7 = llvm.insertelement %arg0, %5[%2 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg0, %8[%4 : i32] : vector<4xf32> + %10 = llvm.fadd %6, %9 : vector<4xf32> + llvm.return %10 : vector<4xf32> + } + llvm.func @splat_undef1(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %arg0, %4[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg0, %5[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + llvm.return %7 : vector<4xf32> + } + llvm.func @splat_undef2(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %arg0, %4[%2 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg0, %5[%3 : i32] : vector<4xf32> + llvm.return %6 : vector<4xf32> + } + llvm.func @bad3(%arg0: f32, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%4 : i32] : vector<4xf32> + llvm.return %8 : vector<4xf32> + } + llvm.func @bad4(%arg0: f32) -> vector<1xf32> { + %0 = llvm.mlir.poison : vector<1xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<1xf32> + llvm.return %2 : vector<1xf32> + } + llvm.func @splat_undef3(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg0, %5[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%4 : i32] : vector<4xf32> + %9 = llvm.fadd %8, %6 : vector<4xf32> + llvm.return %9 : vector<4xf32> + } + llvm.func @bad6(%arg0: f32, %arg1: i32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %arg0, %4[%2 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg0, %5[%arg1 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + llvm.return %7 : vector<4xf32> + } + llvm.func @bad7(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %6 = llvm.fadd %5, %5 : vector<4xf32> + %7 = llvm.insertelement %arg0, %5[%2 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg0, %8[%4 : i32] : vector<4xf32> + %10 = llvm.fadd %6, %9 : vector<4xf32> + llvm.return %10 : vector<4xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/broadcast.ll.mlir b/test/LLVMDialect/InstCombine/broadcast.ll.mlir new file mode 100644 index 000000000..d5e7f1baf --- /dev/null +++ b/test/LLVMDialect/InstCombine/broadcast.ll.mlir @@ -0,0 +1,144 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @good1(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg0, %5[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%4 : i32] : vector<4xf32> + llvm.return %8 : vector<4xf32> + } + llvm.func @good2(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg0, %5[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%4 : i32] : vector<4xf32> + llvm.return %8 : vector<4xf32> + } + llvm.func @good3(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.insertelement %arg0, %1[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%4 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg0, %8[%5 : i32] : vector<4xf32> + llvm.return %9 : vector<4xf32> + } + llvm.func @good4(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.insertelement %arg0, %1[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%4 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg0, %8[%5 : i32] : vector<4xf32> + %10 = llvm.fadd %9, %9 : vector<4xf32> + llvm.return %10 : vector<4xf32> + } + llvm.func @good5(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %6 = llvm.fadd %5, %5 : vector<4xf32> + %7 = llvm.insertelement %arg0, %5[%2 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg0, %8[%4 : i32] : vector<4xf32> + %10 = llvm.fadd %6, %9 : vector<4xf32> + llvm.return %10 : vector<4xf32> + } + llvm.func @splat_undef1(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %arg0, %4[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg0, %5[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + llvm.return %7 : vector<4xf32> + } + llvm.func @splat_undef2(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %arg0, %4[%2 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg0, %5[%3 : i32] : vector<4xf32> + llvm.return %6 : vector<4xf32> + } + llvm.func @bad3(%arg0: f32, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%4 : i32] : vector<4xf32> + llvm.return %8 : vector<4xf32> + } + llvm.func @bad4(%arg0: f32) -> vector<1xf32> { + %0 = llvm.mlir.undef : vector<1xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<1xf32> + llvm.return %2 : vector<1xf32> + } + llvm.func @splat_undef3(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg0, %5[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%4 : i32] : vector<4xf32> + %9 = llvm.fadd %8, %6 : vector<4xf32> + llvm.return %9 : vector<4xf32> + } + llvm.func @bad6(%arg0: f32, %arg1: i32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %arg0, %4[%2 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg0, %5[%arg1 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xf32> + llvm.return %7 : vector<4xf32> + } + llvm.func @bad7(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %6 = llvm.fadd %5, %5 : vector<4xf32> + %7 = llvm.insertelement %arg0, %5[%2 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg0, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg0, %8[%4 : i32] : vector<4xf32> + %10 = llvm.fadd %6, %9 : vector<4xf32> + llvm.return %10 : vector<4xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/bswap-fold.ll.mlir b/test/LLVMDialect/InstCombine/bswap-fold.ll.mlir new file mode 100644 index 000000000..0106adaf9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/bswap-fold.ll.mlir @@ -0,0 +1,575 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @gp() {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.func @test4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.intr.bswap(%arg0) : (i32) -> i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @test6(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.intr.bswap(%arg0) : (i32) -> i32 + %2 = llvm.and %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @lshr8_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.intr.bswap(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @lshr16_v2i32(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.lshr %arg0, %0 : vector<2xi32> + %2 = llvm.intr.bswap(%1) : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @lshr24_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.intr.bswap(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @lshr12_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.intr.bswap(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @lshr8_i32_use(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + llvm.store %1, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %2 = llvm.intr.bswap(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @shl16_i64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @shl16_v2i64(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(24 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.shl %arg0, %6 : vector<2xi64> + %8 = llvm.intr.bswap(%7) : (vector<2xi64>) -> vector<2xi64> + llvm.return %8 : vector<2xi64> + } + llvm.func @shl56_i64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(56 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @shl42_i64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @shl8_i32_use(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.shl %arg0, %0 : i32 + llvm.store %1, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %2 = llvm.intr.bswap(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @swap_shl16_i64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.intr.bswap(%arg0) : (i64) -> i64 + %2 = llvm.shl %1, %0 : i64 + %3 = llvm.intr.bswap(%2) : (i64) -> i64 + llvm.return %3 : i64 + } + llvm.func @variable_lshr_v2i32(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[-8, -16]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg1, %0 : vector<2xi32> + %2 = llvm.shl %arg0, %1 : vector<2xi32> + %3 = llvm.intr.bswap(%2) : (vector<2xi32>) -> vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @variable_shl_i64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.mlir.constant(56 : i64) : i64 + %2 = llvm.intr.bswap(%arg0) : (i64) -> i64 + %3 = llvm.shl %arg1, %0 : i64 + %4 = llvm.and %3, %1 : i64 + %5 = llvm.shl %2, %4 : i64 + %6 = llvm.intr.bswap(%5) : (i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @variable_shl_not_masked_enough_i64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.and %arg1, %0 : i64 + %2 = llvm.shl %arg0, %1 : i64 + %3 = llvm.intr.bswap(%2) : (i64) -> i64 + llvm.return %3 : i64 + } + llvm.func @test7(%arg0: i32) -> i16 { + %0 = llvm.intr.bswap(%arg0) : (i32) -> i32 + %1 = llvm.trunc %0 : i32 to i16 + %2 = llvm.intr.bswap(%1) : (i16) -> i16 + llvm.return %2 : i16 + } + llvm.func @test7_vector(%arg0: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.intr.bswap(%arg0) : (vector<2xi32>) -> vector<2xi32> + %1 = llvm.trunc %0 : vector<2xi32> to vector<2xi16> + %2 = llvm.intr.bswap(%1) : (vector<2xi16>) -> vector<2xi16> + llvm.return %2 : vector<2xi16> + } + llvm.func @test8(%arg0: i64) -> i16 { + %0 = llvm.intr.bswap(%arg0) : (i64) -> i64 + %1 = llvm.trunc %0 : i64 to i16 + %2 = llvm.intr.bswap(%1) : (i16) -> i16 + llvm.return %2 : i16 + } + llvm.func @test8_vector(%arg0: vector<2xi64>) -> vector<2xi16> { + %0 = llvm.intr.bswap(%arg0) : (vector<2xi64>) -> vector<2xi64> + %1 = llvm.trunc %0 : vector<2xi64> to vector<2xi16> + %2 = llvm.intr.bswap(%1) : (vector<2xi16>) -> vector<2xi16> + llvm.return %2 : vector<2xi16> + } + llvm.func @foo() -> i64 { + %0 = llvm.mlir.undef : i64 + %1 = llvm.intr.bswap(%0) : (i64) -> i64 + llvm.return %1 : i64 + } + llvm.func @bs_and16i(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(10001 : i16) : i16 + %1 = llvm.intr.bswap(%arg0) : (i16) -> i16 + %2 = llvm.and %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @bs_and16(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.intr.bswap(%arg0) : (i16) -> i16 + %1 = llvm.intr.bswap(%arg1) : (i16) -> i16 + %2 = llvm.and %0, %1 : i16 + llvm.return %2 : i16 + } + llvm.func @bs_or16(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.intr.bswap(%arg0) : (i16) -> i16 + %1 = llvm.intr.bswap(%arg1) : (i16) -> i16 + %2 = llvm.or %0, %1 : i16 + llvm.return %2 : i16 + } + llvm.func @bs_xor16(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.intr.bswap(%arg0) : (i16) -> i16 + %1 = llvm.intr.bswap(%arg1) : (i16) -> i16 + %2 = llvm.xor %0, %1 : i16 + llvm.return %2 : i16 + } + llvm.func @bs_and32i(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(100001 : i32) : i32 + %1 = llvm.intr.bswap(%arg0) : (i32) -> i32 + %2 = llvm.and %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @bs_and32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.bswap(%arg0) : (i32) -> i32 + %1 = llvm.intr.bswap(%arg1) : (i32) -> i32 + %2 = llvm.and %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @bs_or32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.bswap(%arg0) : (i32) -> i32 + %1 = llvm.intr.bswap(%arg1) : (i32) -> i32 + %2 = llvm.or %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @bs_xor32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.bswap(%arg0) : (i32) -> i32 + %1 = llvm.intr.bswap(%arg1) : (i32) -> i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @bs_and64i(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(1000000001 : i64) : i64 + %1 = llvm.intr.bswap(%arg0) : (i64) -> i64 + %2 = llvm.and %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @bs_and64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bswap(%arg0) : (i64) -> i64 + %1 = llvm.intr.bswap(%arg1) : (i64) -> i64 + %2 = llvm.and %0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @bs_or64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bswap(%arg0) : (i64) -> i64 + %1 = llvm.intr.bswap(%arg1) : (i64) -> i64 + %2 = llvm.or %0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @bs_xor64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bswap(%arg0) : (i64) -> i64 + %1 = llvm.intr.bswap(%arg1) : (i64) -> i64 + %2 = llvm.xor %0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @bs_and32vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.intr.bswap(%arg0) : (vector<2xi32>) -> vector<2xi32> + %1 = llvm.intr.bswap(%arg1) : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.and %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @bs_or32vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.intr.bswap(%arg0) : (vector<2xi32>) -> vector<2xi32> + %1 = llvm.intr.bswap(%arg1) : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.or %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @bs_xor32vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.intr.bswap(%arg0) : (vector<2xi32>) -> vector<2xi32> + %1 = llvm.intr.bswap(%arg1) : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.xor %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @bs_and32ivec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<100001> : vector<2xi32>) : vector<2xi32> + %1 = llvm.intr.bswap(%arg0) : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.and %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @bs_or32ivec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<100001> : vector<2xi32>) : vector<2xi32> + %1 = llvm.intr.bswap(%arg0) : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.or %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @bs_xor32ivec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<100001> : vector<2xi32>) : vector<2xi32> + %1 = llvm.intr.bswap(%arg0) : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.xor %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @bs_and64_multiuse1(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bswap(%arg0) : (i64) -> i64 + %1 = llvm.intr.bswap(%arg1) : (i64) -> i64 + %2 = llvm.and %0, %1 : i64 + %3 = llvm.mul %2, %0 : i64 + %4 = llvm.mul %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @bs_and64_multiuse2(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bswap(%arg0) : (i64) -> i64 + %1 = llvm.intr.bswap(%arg1) : (i64) -> i64 + %2 = llvm.and %0, %1 : i64 + %3 = llvm.mul %2, %0 : i64 + llvm.return %3 : i64 + } + llvm.func @bs_and64_multiuse3(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bswap(%arg0) : (i64) -> i64 + %1 = llvm.intr.bswap(%arg1) : (i64) -> i64 + %2 = llvm.and %0, %1 : i64 + %3 = llvm.mul %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @bs_and64i_multiuse(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(1000000001 : i64) : i64 + %1 = llvm.intr.bswap(%arg0) : (i64) -> i64 + %2 = llvm.and %1, %0 : i64 + %3 = llvm.mul %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @bs_and_lhs_bs16(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.intr.bswap(%arg0) : (i16) -> i16 + %1 = llvm.and %0, %arg1 : i16 + %2 = llvm.intr.bswap(%1) : (i16) -> i16 + llvm.return %2 : i16 + } + llvm.func @bs_or_lhs_bs16(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.intr.bswap(%arg0) : (i16) -> i16 + %1 = llvm.or %0, %arg1 : i16 + %2 = llvm.intr.bswap(%1) : (i16) -> i16 + llvm.return %2 : i16 + } + llvm.func @bs_xor_lhs_bs16(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.intr.bswap(%arg0) : (i16) -> i16 + %1 = llvm.xor %0, %arg1 : i16 + %2 = llvm.intr.bswap(%1) : (i16) -> i16 + llvm.return %2 : i16 + } + llvm.func @bs_and_rhs_bs16(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.intr.bswap(%arg1) : (i16) -> i16 + %1 = llvm.and %arg0, %0 : i16 + %2 = llvm.intr.bswap(%1) : (i16) -> i16 + llvm.return %2 : i16 + } + llvm.func @bs_or_rhs_bs16(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.intr.bswap(%arg1) : (i16) -> i16 + %1 = llvm.or %arg0, %0 : i16 + %2 = llvm.intr.bswap(%1) : (i16) -> i16 + llvm.return %2 : i16 + } + llvm.func @bs_xor_rhs_bs16(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.intr.bswap(%arg1) : (i16) -> i16 + %1 = llvm.xor %arg0, %0 : i16 + %2 = llvm.intr.bswap(%1) : (i16) -> i16 + llvm.return %2 : i16 + } + llvm.func @bs_and_rhs_bs32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.bswap(%arg1) : (i32) -> i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.intr.bswap(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @bs_or_rhs_bs32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.bswap(%arg1) : (i32) -> i32 + %1 = llvm.or %arg0, %0 : i32 + %2 = llvm.intr.bswap(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @bs_xor_rhs_bs32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.bswap(%arg1) : (i32) -> i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.intr.bswap(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @bs_and_rhs_bs64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bswap(%arg1) : (i64) -> i64 + %1 = llvm.and %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @bs_or_rhs_bs64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bswap(%arg1) : (i64) -> i64 + %1 = llvm.or %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @bs_xor_rhs_bs64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bswap(%arg1) : (i64) -> i64 + %1 = llvm.xor %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @bs_and_rhs_i32vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.intr.bswap(%arg1) : (vector<2xi32>) -> vector<2xi32> + %1 = llvm.and %arg0, %0 : vector<2xi32> + %2 = llvm.intr.bswap(%1) : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @bs_or_rhs_i32vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.intr.bswap(%arg1) : (vector<2xi32>) -> vector<2xi32> + %1 = llvm.or %arg0, %0 : vector<2xi32> + %2 = llvm.intr.bswap(%1) : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @bs_xor_rhs_i32vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.intr.bswap(%arg1) : (vector<2xi32>) -> vector<2xi32> + %1 = llvm.xor %arg0, %0 : vector<2xi32> + %2 = llvm.intr.bswap(%1) : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @bs_and_rhs_bs64_multiuse1(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bswap(%arg1) : (i64) -> i64 + %1 = llvm.and %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + %3 = llvm.mul %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @bs_and_rhs_bs64_multiuse2(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bswap(%arg1) : (i64) -> i64 + %1 = llvm.and %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + %3 = llvm.mul %0, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @bs_all_operand64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.intr.bswap(%arg0) : (i64) -> i64 + %1 = llvm.intr.bswap(%arg1) : (i64) -> i64 + %2 = llvm.and %0, %1 : i64 + %3 = llvm.intr.bswap(%2) : (i64) -> i64 + llvm.return %3 : i64 + } + llvm.func @bs_all_operand64_multiuse_both(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.addressof @use.i64 : !llvm.ptr + %1 = llvm.intr.bswap(%arg0) : (i64) -> i64 + %2 = llvm.intr.bswap(%arg1) : (i64) -> i64 + %3 = llvm.and %1, %2 : i64 + %4 = llvm.intr.bswap(%3) : (i64) -> i64 + llvm.call %0(%1) : !llvm.ptr, (i64) -> () + llvm.call %0(%2) : !llvm.ptr, (i64) -> () + llvm.return %4 : i64 + } + llvm.func @bs_and_constexpr(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.addressof @gp : !llvm.ptr + %1 = llvm.mlir.constant(4095 : i64) : i64 + %2 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %3 = llvm.and %2, %1 : i64 + %4 = llvm.intr.bswap(%3) : (i64) -> i64 + llvm.store %4, %arg0 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @bs_and_bs_constexpr(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.addressof @gp : !llvm.ptr + %1 = llvm.mlir.constant(4095 : i64) : i64 + %2 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %3 = llvm.intr.bswap(%2) : (i64) -> i64 + %4 = llvm.and %3, %1 : i64 + %5 = llvm.intr.bswap(%4) : (i64) -> i64 + llvm.store %5, %arg0 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @bs_active_high8(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(56 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @bs_active_high7(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-33554432 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.intr.bswap(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @bs_active_high4(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<60> : vector<2xi64>) : vector<2xi64> + %1 = llvm.shl %arg0, %0 : vector<2xi64> + %2 = llvm.intr.bswap(%1) : (vector<2xi64>) -> vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @bs_active_high_different(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[56, 57]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.shl %arg0, %0 : vector<2xi64> + %2 = llvm.intr.bswap(%1) : (vector<2xi64>) -> vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @bs_active_high_different_negative(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[56, 55]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.shl %arg0, %0 : vector<2xi64> + %2 = llvm.intr.bswap(%1) : (vector<2xi64>) -> vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @bs_active_high_poison(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.poison : i64 + %1 = llvm.mlir.constant(56 : i64) : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.shl %arg0, %6 : vector<2xi64> + %8 = llvm.intr.bswap(%7) : (vector<2xi64>) -> vector<2xi64> + llvm.return %8 : vector<2xi64> + } + llvm.func @bs_active_high8_multiuse(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(56 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + %3 = llvm.mul %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @bs_active_high7_multiuse(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(57 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + %3 = llvm.mul %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @bs_active_byte_6h(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(280375465082880 : i64) : i64 + %1 = llvm.and %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @bs_active_byte_3h(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(393216 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.intr.bswap(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @bs_active_byte_3h_v2(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[8388608, 65536]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg0, %0 : vector<2xi32> + %2 = llvm.intr.bswap(%1) : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @bs_active_byte_78h(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(108086391056891904 : i64) : i64 + %1 = llvm.and %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @bs_active_low1(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(15 : i16) : i16 + %1 = llvm.lshr %arg0, %0 : i16 + %2 = llvm.intr.bswap(%1) : (i16) -> i16 + llvm.return %2 : i16 + } + llvm.func @bs_active_low8(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<255> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg0, %0 : vector<2xi32> + %2 = llvm.intr.bswap(%1) : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @bs_active_low_different(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[2, 128]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg0, %0 : vector<2xi32> + %2 = llvm.intr.bswap(%1) : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @bs_active_low_different_negative(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[256, 255]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg0, %0 : vector<2xi32> + %2 = llvm.intr.bswap(%1) : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @bs_active_low_undef(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.and %arg0, %6 : vector<2xi32> + %8 = llvm.intr.bswap(%7) : (vector<2xi32>) -> vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @bs_active_low8_multiuse(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(255 : i64) : i64 + %1 = llvm.and %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + %3 = llvm.mul %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @bs_active_low7_multiuse(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(127 : i64) : i64 + %1 = llvm.and %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + %3 = llvm.mul %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @bs_active_byte_4l(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(1140850688 : i64) : i64 + %1 = llvm.and %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @bs_active_byte_2l(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.intr.bswap(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @bs_active_byte_2l_v2(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[256, 65280]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.and %arg0, %0 : vector<2xi64> + %2 = llvm.intr.bswap(%1) : (vector<2xi64>) -> vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @bs_active_byte_12l(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(384 : i64) : i64 + %1 = llvm.and %arg0, %0 : i64 + %2 = llvm.intr.bswap(%1) : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @use.i64(i64) -> i64 +} diff --git a/test/LLVMDialect/InstCombine/bswap-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/bswap-inseltpoison.ll.mlir new file mode 100644 index 000000000..056605d46 --- /dev/null +++ b/test/LLVMDialect/InstCombine/bswap-inseltpoison.ll.mlir @@ -0,0 +1,42 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @shuf_4bytes(%arg0: vector<4xi8>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.shufflevector %arg0, %0 [3, 2, 1, 0] : vector<4xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.return %2 : i32 + } + llvm.func @shuf_load_4bytes(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> vector<4xi8> + %2 = llvm.shufflevector %1, %0 [3, 2, -1, 0] : vector<4xi8> + %3 = llvm.bitcast %2 : vector<4xi8> to i32 + llvm.return %3 : i32 + } + llvm.func @shuf_bitcast_twice_4bytes(%arg0: i32) -> i32 { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.bitcast %arg0 : i32 to vector<4xi8> + %2 = llvm.shufflevector %1, %0 [-1, 2, 1, 0] : vector<4xi8> + %3 = llvm.bitcast %2 : vector<4xi8> to i32 + llvm.return %3 : i32 + } + llvm.func @use(vector<4xi8>) + llvm.func @shuf_4bytes_extra_use(%arg0: vector<4xi8>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.shufflevector %arg0, %0 [3, 2, 1, 0] : vector<4xi8> + llvm.call @use(%1) : (vector<4xi8>) -> () + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.return %2 : i32 + } + llvm.func @shuf_16bytes(%arg0: vector<16xi8>) -> i128 { + %0 = llvm.mlir.poison : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<16xi8> to i128 + llvm.return %2 : i128 + } + llvm.func @shuf_2bytes_widening(%arg0: vector<2xi8>) -> i32 { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.shufflevector %arg0, %0 [1, 0, -1, -1] : vector<2xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/bswap-known-bits.ll.mlir b/test/LLVMDialect/InstCombine/bswap-known-bits.ll.mlir index 57375f548..c4c110ead 100644 --- a/test/LLVMDialect/InstCombine/bswap-known-bits.ll.mlir +++ b/test/LLVMDialect/InstCombine/bswap-known-bits.ll.mlir @@ -1,47 +1,38 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.bswap.i16", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.bswap.i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 256 : i16} : () -> i16 - %1 = "llvm.mlir.constant"() {value = 511 : i16} : () -> i16 - %2 = "llvm.or"(%arg0, %1) : (i16, i16) -> i16 - %3 = "llvm.call"(%2) {callee = @llvm.bswap.i16, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - %4 = "llvm.and"(%3, %0) : (i16, i16) -> i16 - %5 = "llvm.icmp"(%4, %0) {predicate = 0 : i64} : (i16, i16) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 256 : i16} : () -> i16 - %1 = "llvm.mlir.constant"() {value = 1 : i16} : () -> i16 - %2 = "llvm.or"(%arg0, %1) : (i16, i16) -> i16 - %3 = "llvm.call"(%2) {callee = @llvm.bswap.i16, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - %4 = "llvm.and"(%3, %0) : (i16, i16) -> i16 - %5 = "llvm.icmp"(%4, %0) {predicate = 0 : i64} : (i16, i16) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i16} : () -> i16 - %1 = "llvm.mlir.constant"() {value = 256 : i16} : () -> i16 - %2 = "llvm.or"(%arg0, %1) : (i16, i16) -> i16 - %3 = "llvm.call"(%2) {callee = @llvm.bswap.i16, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - %4 = "llvm.and"(%3, %0) : (i16, i16) -> i16 - %5 = "llvm.icmp"(%4, %0) {predicate = 0 : i64} : (i16, i16) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 127 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2147483647 : i32} : () -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.call"(%2) {callee = @llvm.bswap.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %4 = "llvm.and"(%3, %0) : (i32, i32) -> i32 - %5 = "llvm.icmp"(%4, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(511 : i16) : i16 + %1 = llvm.mlir.constant(256 : i16) : i16 + %2 = llvm.or %arg0, %0 : i16 + %3 = llvm.intr.bswap(%2) : (i16) -> i16 + %4 = llvm.and %3, %1 : i16 + %5 = llvm.icmp "eq" %4, %1 : i16 + llvm.return %5 : i1 + } + llvm.func @test2(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.constant(256 : i16) : i16 + %2 = llvm.or %arg0, %0 : i16 + %3 = llvm.intr.bswap(%2) : (i16) -> i16 + %4 = llvm.and %3, %1 : i16 + %5 = llvm.icmp "eq" %4, %1 : i16 + llvm.return %5 : i1 + } + llvm.func @test3(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(256 : i16) : i16 + %1 = llvm.mlir.constant(1 : i16) : i16 + %2 = llvm.or %arg0, %0 : i16 + %3 = llvm.intr.bswap(%2) : (i16) -> i16 + %4 = llvm.and %3, %1 : i16 + %5 = llvm.icmp "eq" %4, %1 : i16 + llvm.return %5 : i1 + } + llvm.func @test4(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(127 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.intr.bswap(%2) : (i32) -> i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/bswap.ll.mlir b/test/LLVMDialect/InstCombine/bswap.ll.mlir new file mode 100644 index 000000000..dddd0c77f --- /dev/null +++ b/test/LLVMDialect/InstCombine/bswap.ll.mlir @@ -0,0 +1,822 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(65280 : i32) : i32 + %3 = llvm.mlir.constant(16711680 : i32) : i32 + %4 = llvm.lshr %arg0, %0 : i32 + %5 = llvm.lshr %arg0, %1 : i32 + %6 = llvm.and %5, %2 : i32 + %7 = llvm.or %4, %6 : i32 + %8 = llvm.shl %arg0, %1 : i32 + %9 = llvm.and %8, %3 : i32 + %10 = llvm.or %7, %9 : i32 + %11 = llvm.shl %arg0, %0 : i32 + %12 = llvm.or %10, %11 : i32 + llvm.return %12 : i32 + } + llvm.func @test1_vector(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<24> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<65280> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<16711680> : vector<2xi32>) : vector<2xi32> + %4 = llvm.lshr %arg0, %0 : vector<2xi32> + %5 = llvm.lshr %arg0, %1 : vector<2xi32> + %6 = llvm.and %5, %2 : vector<2xi32> + %7 = llvm.or %4, %6 : vector<2xi32> + %8 = llvm.shl %arg0, %1 : vector<2xi32> + %9 = llvm.and %8, %3 : vector<2xi32> + %10 = llvm.or %7, %9 : vector<2xi32> + %11 = llvm.shl %arg0, %0 : vector<2xi32> + %12 = llvm.or %10, %11 : vector<2xi32> + llvm.return %12 : vector<2xi32> + } + llvm.func @test1_trunc(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(65280 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %4, %2 : i32 + %6 = llvm.or %3, %5 : i32 + %7 = llvm.trunc %6 : i32 to i16 + llvm.return %7 : i16 + } + llvm.func @test1_trunc_extra_use(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(65280 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %4, %2 : i32 + %6 = llvm.or %3, %5 : i32 + llvm.call @extra_use(%6) : (i32) -> () + %7 = llvm.trunc %6 : i32 to i16 + llvm.return %7 : i16 + } + llvm.func @test2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(16711680 : i32) : i32 + %3 = llvm.mlir.constant(65280 : i32) : i32 + %4 = llvm.shl %arg0, %0 : i32 + %5 = llvm.shl %arg0, %1 : i32 + %6 = llvm.and %5, %2 : i32 + %7 = llvm.or %4, %6 : i32 + %8 = llvm.lshr %arg0, %1 : i32 + %9 = llvm.and %8, %3 : i32 + %10 = llvm.or %7, %9 : i32 + %11 = llvm.lshr %arg0, %0 : i32 + %12 = llvm.or %10, %11 : i32 + llvm.return %12 : i32 + } + llvm.func @test2_vector(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<24> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<16711680> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<65280> : vector<2xi32>) : vector<2xi32> + %4 = llvm.shl %arg0, %0 : vector<2xi32> + %5 = llvm.shl %arg0, %1 : vector<2xi32> + %6 = llvm.and %5, %2 : vector<2xi32> + %7 = llvm.or %4, %6 : vector<2xi32> + %8 = llvm.lshr %arg0, %1 : vector<2xi32> + %9 = llvm.and %8, %3 : vector<2xi32> + %10 = llvm.or %7, %9 : vector<2xi32> + %11 = llvm.lshr %arg0, %0 : vector<2xi32> + %12 = llvm.or %10, %11 : vector<2xi32> + llvm.return %12 : vector<2xi32> + } + llvm.func @test2_vector_poison(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %8 = llvm.mlir.constant(16711680 : i32) : i32 + %9 = llvm.mlir.undef : vector<2xi32> + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.insertelement %8, %9[%10 : i32] : vector<2xi32> + %12 = llvm.mlir.constant(1 : i32) : i32 + %13 = llvm.insertelement %0, %11[%12 : i32] : vector<2xi32> + %14 = llvm.mlir.constant(65280 : i32) : i32 + %15 = llvm.mlir.undef : vector<2xi32> + %16 = llvm.mlir.constant(0 : i32) : i32 + %17 = llvm.insertelement %14, %15[%16 : i32] : vector<2xi32> + %18 = llvm.mlir.constant(1 : i32) : i32 + %19 = llvm.insertelement %0, %17[%18 : i32] : vector<2xi32> + %20 = llvm.shl %arg0, %6 : vector<2xi32> + %21 = llvm.shl %arg0, %7 : vector<2xi32> + %22 = llvm.and %21, %13 : vector<2xi32> + %23 = llvm.or %20, %22 : vector<2xi32> + %24 = llvm.lshr %arg0, %7 : vector<2xi32> + %25 = llvm.and %24, %19 : vector<2xi32> + %26 = llvm.or %23, %25 : vector<2xi32> + %27 = llvm.lshr %arg0, %6 : vector<2xi32> + %28 = llvm.or %26, %27 : vector<2xi32> + llvm.return %28 : vector<2xi32> + } + llvm.func @test3(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.lshr %arg0, %0 : i16 + %2 = llvm.shl %arg0, %0 : i16 + %3 = llvm.or %1, %2 : i16 + llvm.return %3 : i16 + } + llvm.func @test3_vector(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi16>) : vector<2xi16> + %1 = llvm.lshr %arg0, %0 : vector<2xi16> + %2 = llvm.shl %arg0, %0 : vector<2xi16> + %3 = llvm.or %1, %2 : vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @test3_vector_poison(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<2xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi16> + %7 = llvm.mlir.undef : vector<2xi16> + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<2xi16> + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<2xi16> + %12 = llvm.lshr %arg0, %6 : vector<2xi16> + %13 = llvm.shl %arg0, %11 : vector<2xi16> + %14 = llvm.or %12, %13 : vector<2xi16> + llvm.return %14 : vector<2xi16> + } + llvm.func @test4(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.lshr %arg0, %0 : i16 + %2 = llvm.shl %arg0, %0 : i16 + %3 = llvm.or %2, %1 : i16 + llvm.return %3 : i16 + } + llvm.func @test4_vector(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi16>) : vector<2xi16> + %1 = llvm.lshr %arg0, %0 : vector<2xi16> + %2 = llvm.shl %arg0, %0 : vector<2xi16> + %3 = llvm.or %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @test5(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(255 : i32) : i32 + %3 = llvm.zext %arg0 : i16 to i32 + %4 = llvm.and %3, %0 : i32 + %5 = llvm.ashr %4, %1 : i32 + %6 = llvm.trunc %5 : i32 to i16 + %7 = llvm.and %3, %2 : i32 + %8 = llvm.shl %7, %1 : i32 + %9 = llvm.trunc %8 : i32 to i16 + %10 = llvm.or %6, %9 : i16 + %11 = llvm.bitcast %10 : i16 to i16 + %12 = llvm.zext %11 : i16 to i32 + %13 = llvm.trunc %12 : i32 to i16 + llvm.return %13 : i16 + } + llvm.func @test5_vector(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<65280> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<255> : vector<2xi32>) : vector<2xi32> + %3 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %4 = llvm.and %3, %0 : vector<2xi32> + %5 = llvm.ashr %4, %1 : vector<2xi32> + %6 = llvm.trunc %5 : vector<2xi32> to vector<2xi16> + %7 = llvm.and %3, %2 : vector<2xi32> + %8 = llvm.shl %7, %1 : vector<2xi32> + %9 = llvm.trunc %8 : vector<2xi32> to vector<2xi16> + %10 = llvm.or %6, %9 : vector<2xi16> + %11 = llvm.bitcast %10 : vector<2xi16> to vector<2xi16> + %12 = llvm.zext %11 : vector<2xi16> to vector<2xi32> + %13 = llvm.trunc %12 : vector<2xi32> to vector<2xi16> + llvm.return %13 : vector<2xi16> + } + llvm.func @test6(%arg0: i32) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(65280 : i32) : i32 + %2 = llvm.mlir.constant(255 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(24 : i32) : i32 + %5 = llvm.shl %arg0, %0 : i32 + %6 = llvm.and %arg0, %1 : i32 + %7 = llvm.lshr %arg0, %0 : i32 + %8 = llvm.and %7, %2 : i32 + %9 = llvm.or %6, %5 : i32 + %10 = llvm.or %9, %8 : i32 + %11 = llvm.shl %10, %3 : i32 + %12 = llvm.lshr %arg0, %4 : i32 + %13 = llvm.or %11, %12 : i32 + llvm.return %13 : i32 + } + llvm.func @test6_vector(%arg0: vector<2xi32>) -> vector<2xi32> attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<65280> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<255> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %4 = llvm.mlir.constant(dense<24> : vector<2xi32>) : vector<2xi32> + %5 = llvm.shl %arg0, %0 : vector<2xi32> + %6 = llvm.and %arg0, %1 : vector<2xi32> + %7 = llvm.lshr %arg0, %0 : vector<2xi32> + %8 = llvm.and %7, %2 : vector<2xi32> + %9 = llvm.or %6, %5 : vector<2xi32> + %10 = llvm.or %9, %8 : vector<2xi32> + %11 = llvm.shl %10, %3 : vector<2xi32> + %12 = llvm.lshr %arg0, %4 : vector<2xi32> + %13 = llvm.or %11, %12 : vector<2xi32> + llvm.return %13 : vector<2xi32> + } + llvm.func @extra_use(i32) + llvm.func @bswap32_and_first(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(16711935 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.shl %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %0 : i32 + %5 = llvm.or %3, %4 : i32 + %6 = llvm.and %5, %1 : i32 + %7 = llvm.shl %6, %2 overflow : i32 + %8 = llvm.lshr %5, %2 : i32 + %9 = llvm.and %8, %1 : i32 + %10 = llvm.or %7, %9 : i32 + llvm.return %10 : i32 + } + llvm.func @bswap32_and_first_extra_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(16711935 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.shl %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %0 : i32 + %5 = llvm.or %3, %4 : i32 + %6 = llvm.and %5, %1 : i32 + %7 = llvm.shl %6, %2 overflow : i32 + %8 = llvm.lshr %5, %2 : i32 + %9 = llvm.and %8, %1 : i32 + %10 = llvm.or %7, %9 : i32 + llvm.call @extra_use(%6) : (i32) -> () + llvm.return %10 : i32 + } + llvm.func @bswap32_shl_first(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(-16711936 : i32) : i32 + %3 = llvm.mlir.constant(16711935 : i32) : i32 + %4 = llvm.shl %arg0, %0 : i32 + %5 = llvm.lshr %arg0, %0 : i32 + %6 = llvm.or %4, %5 : i32 + %7 = llvm.shl %6, %1 : i32 + %8 = llvm.and %7, %2 : i32 + %9 = llvm.lshr %6, %1 : i32 + %10 = llvm.and %9, %3 : i32 + %11 = llvm.or %8, %10 : i32 + llvm.return %11 : i32 + } + llvm.func @bswap32_shl_first_extra_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(-16711936 : i32) : i32 + %3 = llvm.mlir.constant(16711935 : i32) : i32 + %4 = llvm.shl %arg0, %0 : i32 + %5 = llvm.lshr %arg0, %0 : i32 + %6 = llvm.or %4, %5 : i32 + %7 = llvm.shl %6, %1 : i32 + %8 = llvm.and %7, %2 : i32 + %9 = llvm.lshr %6, %1 : i32 + %10 = llvm.and %9, %3 : i32 + %11 = llvm.or %8, %10 : i32 + llvm.call @extra_use(%7) : (i32) -> () + llvm.return %11 : i32 + } + llvm.func @test8(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.zext %arg0 : i16 to i32 + %3 = llvm.lshr %arg0, %0 : i16 + %4 = llvm.shl %2, %1 : i32 + %5 = llvm.zext %3 : i16 to i32 + %6 = llvm.or %5, %4 : i32 + %7 = llvm.trunc %6 : i32 to i16 + llvm.return %7 : i16 + } + llvm.func @test9(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.shl %1, %0 : i32 + %4 = llvm.or %2, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + llvm.return %5 : i16 + } + llvm.func @test10(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.mlir.constant(65280 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.shl %arg0, %0 : i32 + %6 = llvm.and %5, %2 : i32 + %7 = llvm.or %4, %6 : i32 + %8 = llvm.trunc %7 : i32 to i16 + llvm.return %8 : i16 + } + llvm.func @test10_vector(%arg0: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<255> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<65280> : vector<2xi32>) : vector<2xi32> + %3 = llvm.lshr %arg0, %0 : vector<2xi32> + %4 = llvm.and %3, %1 : vector<2xi32> + %5 = llvm.shl %arg0, %0 : vector<2xi32> + %6 = llvm.and %5, %2 : vector<2xi32> + %7 = llvm.or %4, %6 : vector<2xi32> + %8 = llvm.trunc %7 : vector<2xi32> to vector<2xi16> + llvm.return %8 : vector<2xi16> + } + llvm.func @PR39793_bswap_u64_as_u32(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(24 : i64) : i64 + %1 = llvm.mlir.constant(255 : i64) : i64 + %2 = llvm.mlir.constant(8 : i64) : i64 + %3 = llvm.mlir.constant(65280 : i64) : i64 + %4 = llvm.mlir.constant(16711680 : i64) : i64 + %5 = llvm.mlir.constant(4278190080 : i64) : i64 + %6 = llvm.lshr %arg0, %0 : i64 + %7 = llvm.and %6, %1 : i64 + %8 = llvm.lshr %arg0, %2 : i64 + %9 = llvm.and %8, %3 : i64 + %10 = llvm.or %7, %9 : i64 + %11 = llvm.shl %arg0, %2 : i64 + %12 = llvm.and %11, %4 : i64 + %13 = llvm.or %10, %12 : i64 + %14 = llvm.shl %arg0, %0 : i64 + %15 = llvm.and %14, %5 : i64 + %16 = llvm.or %13, %15 : i64 + llvm.return %16 : i64 + } + llvm.func @PR39793_bswap_u64_as_u32_trunc(%arg0: i64) -> i16 { + %0 = llvm.mlir.constant(24 : i64) : i64 + %1 = llvm.mlir.constant(255 : i64) : i64 + %2 = llvm.mlir.constant(8 : i64) : i64 + %3 = llvm.mlir.constant(65280 : i64) : i64 + %4 = llvm.mlir.constant(16711680 : i64) : i64 + %5 = llvm.mlir.constant(4278190080 : i64) : i64 + %6 = llvm.lshr %arg0, %0 : i64 + %7 = llvm.and %6, %1 : i64 + %8 = llvm.lshr %arg0, %2 : i64 + %9 = llvm.and %8, %3 : i64 + %10 = llvm.or %7, %9 : i64 + %11 = llvm.shl %arg0, %2 : i64 + %12 = llvm.and %11, %4 : i64 + %13 = llvm.or %10, %12 : i64 + %14 = llvm.shl %arg0, %0 : i64 + %15 = llvm.and %14, %5 : i64 + %16 = llvm.or %13, %15 : i64 + %17 = llvm.trunc %16 : i64 to i16 + llvm.return %17 : i16 + } + llvm.func @PR39793_bswap_u64_as_u16(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(255 : i64) : i64 + %2 = llvm.mlir.constant(65280 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.and %3, %1 : i64 + %5 = llvm.shl %arg0, %0 : i64 + %6 = llvm.and %5, %2 : i64 + %7 = llvm.or %4, %6 : i64 + llvm.return %7 : i64 + } + llvm.func @PR39793_bswap_u64_as_u16_vector(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<255> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.constant(dense<65280> : vector<2xi64>) : vector<2xi64> + %3 = llvm.lshr %arg0, %0 : vector<2xi64> + %4 = llvm.and %3, %1 : vector<2xi64> + %5 = llvm.shl %arg0, %0 : vector<2xi64> + %6 = llvm.and %5, %2 : vector<2xi64> + %7 = llvm.or %4, %6 : vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @PR39793_bswap_u64_as_u16_trunc(%arg0: i64) -> i8 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(255 : i64) : i64 + %2 = llvm.mlir.constant(65280 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.and %3, %1 : i64 + %5 = llvm.shl %arg0, %0 : i64 + %6 = llvm.and %5, %2 : i64 + %7 = llvm.or %4, %6 : i64 + %8 = llvm.trunc %7 : i64 to i8 + llvm.return %8 : i8 + } + llvm.func @PR39793_bswap_u50_as_u16(%arg0: i50) -> i50 { + %0 = llvm.mlir.constant(8 : i50) : i50 + %1 = llvm.mlir.constant(255 : i50) : i50 + %2 = llvm.mlir.constant(65280 : i50) : i50 + %3 = llvm.lshr %arg0, %0 : i50 + %4 = llvm.and %3, %1 : i50 + %5 = llvm.shl %arg0, %0 : i50 + %6 = llvm.and %5, %2 : i50 + %7 = llvm.or %4, %6 : i50 + llvm.return %7 : i50 + } + llvm.func @PR39793_bswap_u32_as_u16(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.mlir.constant(65280 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.shl %arg0, %0 : i32 + %6 = llvm.and %5, %2 : i32 + %7 = llvm.or %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @PR39793_bswap_u32_as_u16_trunc(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.mlir.constant(65280 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.shl %arg0, %0 : i32 + %6 = llvm.and %5, %2 : i32 + %7 = llvm.or %4, %6 : i32 + %8 = llvm.trunc %7 : i32 to i8 + llvm.return %8 : i8 + } + llvm.func @partial_bswap(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(16711680 : i32) : i32 + %3 = llvm.mlir.constant(-65536 : i32) : i32 + %4 = llvm.shl %arg0, %0 : i32 + %5 = llvm.shl %arg0, %1 : i32 + %6 = llvm.and %5, %2 : i32 + %7 = llvm.or %4, %6 : i32 + %8 = llvm.and %arg0, %3 : i32 + %9 = llvm.intr.bswap(%8) : (i32) -> i32 + %10 = llvm.or %7, %9 : i32 + llvm.return %10 : i32 + } + llvm.func @partial_bswap_vector(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<24> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<16711680> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<-65536> : vector<2xi32>) : vector<2xi32> + %4 = llvm.shl %arg0, %0 : vector<2xi32> + %5 = llvm.shl %arg0, %1 : vector<2xi32> + %6 = llvm.and %5, %2 : vector<2xi32> + %7 = llvm.or %4, %6 : vector<2xi32> + %8 = llvm.and %arg0, %3 : vector<2xi32> + %9 = llvm.intr.bswap(%8) : (vector<2xi32>) -> vector<2xi32> + %10 = llvm.or %7, %9 : vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @partial_bitreverse(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(255 : i16) : i16 + %1 = llvm.mlir.constant(-256 : i16) : i16 + %2 = llvm.mlir.constant(8 : i16) : i16 + %3 = llvm.intr.bitreverse(%arg0) : (i16) -> i16 + %4 = llvm.and %3, %0 : i16 + %5 = llvm.and %3, %1 : i16 + %6 = llvm.intr.bitreverse(%4) : (i16) -> i16 + %7 = llvm.intr.bitreverse(%5) : (i16) -> i16 + %8 = llvm.lshr %6, %2 : i16 + %9 = llvm.shl %7, %2 : i16 + %10 = llvm.or %8, %9 : i16 + llvm.return %10 : i16 + } + llvm.func @bswap_and_mask_0(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(56 : i64) : i64 + %1 = llvm.lshr %arg0, %0 : i64 + %2 = llvm.shl %arg0, %0 : i64 + %3 = llvm.or %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @bswap_and_mask_1(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(56 : i64) : i64 + %1 = llvm.mlir.constant(40 : i64) : i64 + %2 = llvm.mlir.constant(65280 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.lshr %arg0, %1 : i64 + %5 = llvm.and %4, %2 : i64 + %6 = llvm.or %5, %3 : i64 + llvm.return %6 : i64 + } + llvm.func @bswap_and_mask_2(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(56 : i64) : i64 + %1 = llvm.mlir.constant(40 : i64) : i64 + %2 = llvm.mlir.constant(71776119061217280 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.shl %arg0, %0 : i64 + %5 = llvm.or %3, %4 : i64 + %6 = llvm.shl %arg0, %1 : i64 + %7 = llvm.and %6, %2 : i64 + %8 = llvm.or %5, %7 : i64 + llvm.return %8 : i64 + } + llvm.func @bswap_trunc(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(56 : i64) : i64 + %1 = llvm.mlir.constant(8 : i64) : i64 + %2 = llvm.mlir.constant(40 : i64) : i64 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(24 : i64) : i64 + %5 = llvm.shl %arg0, %0 : i64 + %6 = llvm.lshr %arg0, %1 : i64 + %7 = llvm.lshr %arg0, %2 : i64 + %8 = llvm.trunc %6 : i64 to i32 + %9 = llvm.trunc %7 : i64 to i32 + %10 = llvm.intr.bswap(%8) : (i32) -> i32 + %11 = llvm.intr.bswap(%9) : (i32) -> i32 + %12 = llvm.lshr %11, %3 : i32 + %13 = llvm.zext %10 : i32 to i64 + %14 = llvm.zext %12 : i32 to i64 + %15 = llvm.shl %13, %4 : i64 + %16 = llvm.or %14, %15 : i64 + %17 = llvm.or %16, %5 : i64 + llvm.return %17 : i64 + } + llvm.func @shuf_4bytes(%arg0: vector<4xi8>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.shufflevector %arg0, %0 [3, 2, 1, 0] : vector<4xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.return %2 : i32 + } + llvm.func @shuf_load_4bytes(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> vector<4xi8> + %2 = llvm.shufflevector %1, %0 [3, 2, -1, 0] : vector<4xi8> + %3 = llvm.bitcast %2 : vector<4xi8> to i32 + llvm.return %3 : i32 + } + llvm.func @shuf_bitcast_twice_4bytes(%arg0: i32) -> i32 { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.bitcast %arg0 : i32 to vector<4xi8> + %2 = llvm.shufflevector %1, %0 [-1, 2, 1, 0] : vector<4xi8> + %3 = llvm.bitcast %2 : vector<4xi8> to i32 + llvm.return %3 : i32 + } + llvm.func @use(vector<4xi8>) + llvm.func @shuf_4bytes_extra_use(%arg0: vector<4xi8>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.shufflevector %arg0, %0 [3, 2, 1, 0] : vector<4xi8> + llvm.call @use(%1) : (vector<4xi8>) -> () + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.return %2 : i32 + } + llvm.func @shuf_16bytes(%arg0: vector<16xi8>) -> i128 { + %0 = llvm.mlir.poison : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<16xi8> to i128 + llvm.return %2 : i128 + } + llvm.func @shuf_2bytes_widening(%arg0: vector<2xi8>) -> i32 { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.shufflevector %arg0, %0 [1, 0, -1, -1] : vector<2xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.return %2 : i32 + } + llvm.func @funnel_unary(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(-16711936 : i32) : i32 + %2 = llvm.mlir.constant(16711935 : i32) : i32 + %3 = llvm.intr.fshl(%arg0, %arg0, %0) : (i32, i32, i32) -> i32 + %4 = llvm.intr.fshr(%arg0, %arg0, %0) : (i32, i32, i32) -> i32 + %5 = llvm.and %3, %1 : i32 + %6 = llvm.and %4, %2 : i32 + %7 = llvm.or %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @funnel_binary(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.mlir.constant(-65536 : i32) : i32 + %3 = llvm.mlir.constant(65535 : i32) : i32 + %4 = llvm.shl %arg0, %0 : i32 + %5 = llvm.intr.fshl(%arg0, %4, %1) : (i32, i32, i32) -> i32 + %6 = llvm.lshr %arg0, %0 : i32 + %7 = llvm.intr.fshr(%6, %arg0, %1) : (i32, i32, i32) -> i32 + %8 = llvm.and %5, %2 : i32 + %9 = llvm.and %7, %3 : i32 + %10 = llvm.or %8, %9 : i32 + llvm.return %10 : i32 + } + llvm.func @funnel_and(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(16711680 : i32) : i32 + %3 = llvm.mlir.constant(24 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.intr.fshl(%4, %arg0, %1) : (i32, i32, i32) -> i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.intr.fshl(%arg0, %6, %3) : (i32, i32, i32) -> i32 + %8 = llvm.or %5, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @trunc_bswap_i160(%arg0: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(128 : i160) : i160 + %1 = llvm.mlir.constant(136 : i160) : i160 + %2 = llvm.mlir.constant(255 : i16) : i16 + %3 = llvm.mlir.constant(8 : i16) : i16 + %4 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i160 + %5 = llvm.lshr %4, %0 : i160 + %6 = llvm.lshr %4, %1 : i160 + %7 = llvm.trunc %5 : i160 to i16 + %8 = llvm.trunc %6 : i160 to i16 + %9 = llvm.and %7, %2 : i16 + %10 = llvm.and %8, %2 : i16 + %11 = llvm.shl %9, %3 : i16 + %12 = llvm.or %10, %11 : i16 + llvm.return %12 : i16 + } + llvm.func @PR47191_problem1(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(56 : i64) : i64 + %1 = llvm.mlir.constant(40 : i64) : i64 + %2 = llvm.mlir.constant(65280 : i64) : i64 + %3 = llvm.mlir.constant(24 : i64) : i64 + %4 = llvm.mlir.constant(16711680 : i64) : i64 + %5 = llvm.mlir.constant(8 : i64) : i64 + %6 = llvm.mlir.constant(4278190080 : i64) : i64 + %7 = llvm.mlir.constant(71776119061217280 : i64) : i64 + %8 = llvm.mlir.constant(280375465082880 : i64) : i64 + %9 = llvm.mlir.constant(1095216660480 : i64) : i64 + %10 = llvm.lshr %arg0, %0 : i64 + %11 = llvm.lshr %arg0, %1 : i64 + %12 = llvm.and %11, %2 : i64 + %13 = llvm.lshr %arg0, %3 : i64 + %14 = llvm.and %13, %4 : i64 + %15 = llvm.lshr %arg0, %5 : i64 + %16 = llvm.and %15, %6 : i64 + %17 = llvm.shl %arg0, %0 : i64 + %18 = llvm.shl %arg0, %1 : i64 + %19 = llvm.and %18, %7 : i64 + %20 = llvm.shl %arg0, %3 : i64 + %21 = llvm.and %20, %8 : i64 + %22 = llvm.or %17, %10 : i64 + %23 = llvm.or %22, %12 : i64 + %24 = llvm.or %23, %14 : i64 + %25 = llvm.or %24, %16 : i64 + %26 = llvm.or %25, %19 : i64 + %27 = llvm.or %26, %21 : i64 + %28 = llvm.shl %arg0, %5 : i64 + %29 = llvm.and %28, %9 : i64 + %30 = llvm.add %27, %29 : i64 + llvm.return %30 : i64 + } + llvm.func @PR47191_problem2(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(56 : i64) : i64 + %1 = llvm.mlir.constant(40 : i64) : i64 + %2 = llvm.mlir.constant(65280 : i64) : i64 + %3 = llvm.mlir.constant(24 : i64) : i64 + %4 = llvm.mlir.constant(16711680 : i64) : i64 + %5 = llvm.mlir.constant(8 : i64) : i64 + %6 = llvm.mlir.constant(4278190080 : i64) : i64 + %7 = llvm.mlir.constant(71776119061217280 : i64) : i64 + %8 = llvm.mlir.constant(280375465082880 : i64) : i64 + %9 = llvm.mlir.constant(1095216660480 : i64) : i64 + %10 = llvm.lshr %arg0, %0 : i64 + %11 = llvm.lshr %arg0, %1 : i64 + %12 = llvm.and %11, %2 : i64 + %13 = llvm.lshr %arg0, %3 : i64 + %14 = llvm.and %13, %4 : i64 + %15 = llvm.lshr %arg0, %5 : i64 + %16 = llvm.and %15, %6 : i64 + %17 = llvm.shl %arg0, %0 : i64 + %18 = llvm.shl %arg0, %1 : i64 + %19 = llvm.and %18, %7 : i64 + %20 = llvm.or %17, %10 : i64 + %21 = llvm.or %20, %12 : i64 + %22 = llvm.or %21, %14 : i64 + %23 = llvm.or %22, %16 : i64 + %24 = llvm.or %23, %19 : i64 + %25 = llvm.shl %arg0, %3 : i64 + %26 = llvm.and %25, %8 : i64 + %27 = llvm.shl %arg0, %5 : i64 + %28 = llvm.and %27, %9 : i64 + %29 = llvm.or %28, %26 : i64 + %30 = llvm.xor %29, %24 : i64 + llvm.return %30 : i64 + } + llvm.func @PR47191_problem3(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(56 : i64) : i64 + %1 = llvm.mlir.constant(40 : i64) : i64 + %2 = llvm.mlir.constant(65280 : i64) : i64 + %3 = llvm.mlir.constant(24 : i64) : i64 + %4 = llvm.mlir.constant(16711680 : i64) : i64 + %5 = llvm.mlir.constant(8 : i64) : i64 + %6 = llvm.mlir.constant(4278190080 : i64) : i64 + %7 = llvm.mlir.constant(71776119061217280 : i64) : i64 + %8 = llvm.mlir.constant(280375465082880 : i64) : i64 + %9 = llvm.mlir.constant(1095216660480 : i64) : i64 + %10 = llvm.lshr %arg0, %0 : i64 + %11 = llvm.lshr %arg0, %1 : i64 + %12 = llvm.and %11, %2 : i64 + %13 = llvm.lshr %arg0, %3 : i64 + %14 = llvm.and %13, %4 : i64 + %15 = llvm.lshr %arg0, %5 : i64 + %16 = llvm.and %15, %6 : i64 + %17 = llvm.shl %arg0, %0 : i64 + %18 = llvm.shl %arg0, %1 : i64 + %19 = llvm.and %18, %7 : i64 + %20 = llvm.or %17, %10 : i64 + %21 = llvm.or %20, %12 : i64 + %22 = llvm.or %21, %14 : i64 + %23 = llvm.or %22, %16 : i64 + %24 = llvm.or %23, %19 : i64 + %25 = llvm.shl %arg0, %3 : i64 + %26 = llvm.and %25, %8 : i64 + %27 = llvm.shl %arg0, %5 : i64 + %28 = llvm.and %27, %9 : i64 + %29 = llvm.or %28, %26 : i64 + %30 = llvm.xor %29, %24 : i64 + llvm.return %30 : i64 + } + llvm.func @PR47191_problem4(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(56 : i64) : i64 + %1 = llvm.mlir.constant(40 : i64) : i64 + %2 = llvm.mlir.constant(65280 : i64) : i64 + %3 = llvm.mlir.constant(71776119061217280 : i64) : i64 + %4 = llvm.mlir.constant(24 : i64) : i64 + %5 = llvm.mlir.constant(16711680 : i64) : i64 + %6 = llvm.mlir.constant(280375465082880 : i64) : i64 + %7 = llvm.mlir.constant(8 : i64) : i64 + %8 = llvm.mlir.constant(4278190080 : i64) : i64 + %9 = llvm.mlir.constant(1095216660480 : i64) : i64 + %10 = llvm.lshr %arg0, %0 : i64 + %11 = llvm.shl %arg0, %0 : i64 + %12 = llvm.or %10, %11 : i64 + %13 = llvm.lshr %arg0, %1 : i64 + %14 = llvm.and %13, %2 : i64 + %15 = llvm.or %12, %14 : i64 + %16 = llvm.shl %arg0, %1 : i64 + %17 = llvm.and %16, %3 : i64 + %18 = llvm.or %15, %17 : i64 + %19 = llvm.lshr %arg0, %4 : i64 + %20 = llvm.and %19, %5 : i64 + %21 = llvm.or %18, %20 : i64 + %22 = llvm.shl %arg0, %4 : i64 + %23 = llvm.and %22, %6 : i64 + %24 = llvm.or %21, %23 : i64 + %25 = llvm.lshr %arg0, %7 : i64 + %26 = llvm.and %25, %8 : i64 + %27 = llvm.or %24, %26 : i64 + %28 = llvm.shl %arg0, %7 : i64 + %29 = llvm.and %28, %9 : i64 + %30 = llvm.add %27, %29 : i64 + llvm.return %30 : i64 + } + llvm.func @PR50910(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(72057594037927935 : i64) : i64 + %1 = llvm.mlir.constant(56 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.intr.bswap(%2) : (i64) -> i64 + %4 = llvm.lshr %arg0, %1 : i64 + %5 = llvm.or %3, %4 : i64 + %6 = llvm.trunc %5 : i64 to i32 + llvm.return %6 : i32 + } + llvm.func @PR60690_call_fshl(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(71777214294589695 : i64) : i64 + %2 = llvm.mlir.constant(-71777214294589696 : i64) : i64 + %3 = llvm.mlir.constant(16 : i64) : i64 + %4 = llvm.mlir.constant(-281470681808896 : i64) : i64 + %5 = llvm.mlir.constant(281470681808895 : i64) : i64 + %6 = llvm.mlir.constant(32 : i64) : i64 + %7 = llvm.lshr %arg0, %0 : i64 + %8 = llvm.and %7, %1 : i64 + %9 = llvm.shl %arg0, %0 : i64 + %10 = llvm.and %9, %2 : i64 + %11 = llvm.or %8, %10 : i64 + %12 = llvm.shl %11, %3 : i64 + %13 = llvm.and %12, %4 : i64 + %14 = llvm.lshr %11, %3 : i64 + %15 = llvm.and %14, %5 : i64 + %16 = llvm.or %13, %15 : i64 + %17 = llvm.intr.fshl(%16, %16, %6) : (i64, i64, i64) -> i64 + llvm.return %17 : i64 + } + llvm.func @PR60690_call_fshr(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(71777214294589695 : i64) : i64 + %2 = llvm.mlir.constant(-71777214294589696 : i64) : i64 + %3 = llvm.mlir.constant(16 : i64) : i64 + %4 = llvm.mlir.constant(-281470681808896 : i64) : i64 + %5 = llvm.mlir.constant(281470681808895 : i64) : i64 + %6 = llvm.mlir.constant(32 : i64) : i64 + %7 = llvm.lshr %arg0, %0 : i64 + %8 = llvm.and %7, %1 : i64 + %9 = llvm.shl %arg0, %0 : i64 + %10 = llvm.and %9, %2 : i64 + %11 = llvm.or %8, %10 : i64 + %12 = llvm.shl %11, %3 : i64 + %13 = llvm.and %12, %4 : i64 + %14 = llvm.lshr %11, %3 : i64 + %15 = llvm.and %14, %5 : i64 + %16 = llvm.or %13, %15 : i64 + %17 = llvm.intr.fshr(%16, %16, %6) : (i64, i64, i64) -> i64 + llvm.return %17 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/builtin-dynamic-object-size.ll.mlir b/test/LLVMDialect/InstCombine/builtin-dynamic-object-size.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/builtin-object-size-custom-dl.ll.mlir b/test/LLVMDialect/InstCombine/builtin-object-size-custom-dl.ll.mlir index 603bbaf0b..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/builtin-object-size-custom-dl.ll.mlir +++ b/test/LLVMDialect/InstCombine/builtin-object-size-custom-dl.ll.mlir @@ -1,38 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %3 = "llvm.call"(%arg0) {callee = @malloc, fastmathFlags = #llvm.fastmath<>} : (i64) -> !llvm.ptr - %4 = "llvm.getelementptr"(%3, %2) : (!llvm.ptr, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0, %0) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "objsize1_custom_idx", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 28 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %6 = "llvm.alloca"(%5) : (i32) -> !llvm.ptr, i32, array<10 x i8>)>> - %7 = "llvm.bitcast"(%6) : (!llvm.ptr, i32, array<10 x i8>)>>) -> !llvm.ptr - "llvm.call"(%4, %7) {callee = @llvm.lifetime.start.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - %8 = "llvm.getelementptr"(%6, %3, %3) : (!llvm.ptr, i32, array<10 x i8>)>>, i32, i32) -> !llvm.ptr> - %9 = "llvm.getelementptr"(%8, %2, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %10 = "llvm.call"(%9, %0, %0, %0) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - %11 = "llvm.trunc"(%10) : (i64) -> i32 - "llvm.call"(%4, %7) {callee = @llvm.lifetime.end.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.return"(%11) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "objsize2_custom_idx", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.lifetime.start.p0i8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.lifetime.end.p0i8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "malloc", type = !llvm.func (i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.objectsize.i64.p0i8", type = !llvm.func, i1, i1, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/builtin-object-size-offset.ll.mlir b/test/LLVMDialect/InstCombine/builtin-object-size-offset.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/builtin-object-size-ptr.ll.mlir b/test/LLVMDialect/InstCombine/builtin-object-size-ptr.ll.mlir index 1dd5551f2..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/builtin-object-size-ptr.ll.mlir +++ b/test/LLVMDialect/InstCombine/builtin-object-size-ptr.ll.mlir @@ -1,66 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 28 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %6 = "llvm.alloca"(%5) : (i32) -> !llvm.ptr, i32, array<10 x i8>)>> - %7 = "llvm.bitcast"(%6) : (!llvm.ptr, i32, array<10 x i8>)>>) -> !llvm.ptr - "llvm.call"(%4, %7) {callee = @llvm.lifetime.start.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - %8 = "llvm.getelementptr"(%6, %3, %3) : (!llvm.ptr, i32, array<10 x i8>)>>, i32, i32) -> !llvm.ptr> - %9 = "llvm.getelementptr"(%8, %2, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %10 = "llvm.call"(%9, %0, %0, %0) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - %11 = "llvm.trunc"(%10) : (i64) -> i32 - "llvm.call"(%4, %7) {callee = @llvm.lifetime.end.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.return"(%11) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 10 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 9 : i8} : () -> i8 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr> - %5 = "llvm.bitcast"(%4) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%5, %2, %1, %0) {callee = @llvm.memset.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i64, i1) -> () - %6 = "llvm.call"(%1, %5) {callee = @llvm.invariant.start.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> !llvm.ptr> - "llvm.call"(%6, %1, %5) {callee = @llvm.invariant.end.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>, i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "PR43723", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>>): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 10 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 9 : i8} : () -> i8 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr> - %5 = "llvm.bitcast"(%4) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%5, %2, %1, %0) {callee = @llvm.memset.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i64, i1) -> () - %6 = "llvm.call"(%1, %5) {callee = @llvm.invariant.start.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> !llvm.ptr> - "llvm.call"(%6, %1, %5) {callee = @llvm.invariant.end.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>, i64, !llvm.ptr) -> () - "llvm.store"(%6, %arg0) : (!llvm.ptr>, !llvm.ptr>>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "unknown_use_of_invariant_start", type = !llvm.func>>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - %3 = "llvm.call"(%0, %2) {callee = @llvm.invariant.start.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> !llvm.ptr> - "llvm.return"(%3) : (!llvm.ptr>) -> () - }) {linkage = 10 : i64, sym_name = "minimal_invariant_start_use", type = !llvm.func> (i8)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.lifetime.start.p0i8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.lifetime.end.p0i8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memset.p0i8.i64", type = !llvm.func, i8, i64, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.invariant.start.p0i8", type = !llvm.func> (i64, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.invariant.end.p0i8", type = !llvm.func>, i64, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.objectsize.i64.p0i8", type = !llvm.func, i1, i1, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/builtin-object-size-strdup-family.ll.mlir b/test/LLVMDialect/InstCombine/builtin-object-size-strdup-family.ll.mlir index 4ca64e8d0..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/builtin-object-size-strdup-family.ll.mlir +++ b/test/LLVMDialect/InstCombine/builtin-object-size-strdup-family.ll.mlir @@ -1,63 +0,0 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "str", type = !llvm.array<11 x i8>, value = "toulbroc'h\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "malloc", type = !llvm.func (i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.objectsize.i64.p0i8", type = !llvm.func, i1, i1, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strdup", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "__strdup", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strndup", type = !llvm.func (ptr, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "__strndup", type = !llvm.func (ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @str} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%4) {callee = @strdup, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> !llvm.ptr - %6 = "llvm.call"(%5, %1, %0, %1) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "check_strdup", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @str} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%4) {callee = @__strdup, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> !llvm.ptr - %6 = "llvm.call"(%5, %1, %0, %1) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "check_dunder_strdup", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %4 = "llvm.mlir.addressof"() {global_name = @str} : () -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %3, %3) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %6 = "llvm.call"(%5, %2) {callee = @strndup, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> !llvm.ptr - %7 = "llvm.call"(%6, %1, %0, %1) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.return"(%7) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "check_strndup", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %4 = "llvm.mlir.addressof"() {global_name = @str} : () -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %3, %3) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %6 = "llvm.call"(%5, %2) {callee = @__strndup, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> !llvm.ptr - %7 = "llvm.call"(%6, %1, %0, %1) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.return"(%7) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "check_dunder_strndup", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/byval.ll.mlir b/test/LLVMDialect/InstCombine/byval.ll.mlir index 1372eeca0..1ca22c430 100644 --- a/test/LLVMDialect/InstCombine/byval.ll.mlir +++ b/test/LLVMDialect/InstCombine/byval.ll.mlir @@ -1,30 +1,18 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "add_byval_callee", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "add_byval_callee_2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @add_byval_callee} : () -> !llvm.ptr)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr)>>) -> !llvm.ptr)>> - "llvm.call"(%1, %arg0) : (!llvm.ptr)>>, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "add_byval", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @add_byval_callee_2} : () -> !llvm.ptr)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr)>>) -> !llvm.ptr)>> - "llvm.call"(%1, %arg0) : (!llvm.ptr)>>, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "add_byval_2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.undef"() : () -> i8 - %1 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr> - "llvm.call"(%0, %1) {callee = @vararg_callee, fastmathFlags = #llvm.fastmath<>} : (i8, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "vararg_byval", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "vararg_callee", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @add_byval_callee(!llvm.ptr) + llvm.func @add_byval_callee_2(!llvm.ptr {llvm.byval = f64}) + llvm.func @add_byval(%arg0: !llvm.ptr) { + llvm.call @add_byval_callee(%arg0) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @add_byval_2(%arg0: !llvm.ptr) { + llvm.call @add_byval_callee_2(%arg0) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @vararg_byval(%arg0: !llvm.ptr) { + %0 = llvm.mlir.undef : i8 + llvm.call @vararg_callee(%0, %arg0) vararg(!llvm.func) : (i8, !llvm.ptr) -> () + llvm.return + } + llvm.func @vararg_callee(i8, ...) +} diff --git a/test/LLVMDialect/InstCombine/cabs-array.ll.mlir b/test/LLVMDialect/InstCombine/cabs-array.ll.mlir index d6fdb6c89..2d487bfc8 100644 --- a/test/LLVMDialect/InstCombine/cabs-array.ll.mlir +++ b/test/LLVMDialect/InstCombine/cabs-array.ll.mlir @@ -1,39 +1,29 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.array<2 x f64>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @cabs, fastmathFlags = #llvm.fastmath<>} : (!llvm.array<2 x f64>) -> f64 - "llvm.return"(%0) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "std_cabs", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.array<2 x f32>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @cabsf, fastmathFlags = #llvm.fastmath<>} : (!llvm.array<2 x f32>) -> f32 - "llvm.return"(%0) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "std_cabsf", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.array<2 x f128>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @cabsl, fastmathFlags = #llvm.fastmath<>} : (!llvm.array<2 x f128>) -> f128 - "llvm.return"(%0) : (f128) -> () - }) {linkage = 10 : i64, sym_name = "std_cabsl", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.array<2 x f64>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @cabs, fastmathFlags = #llvm.fastmath<>} : (!llvm.array<2 x f64>) -> f64 - "llvm.return"(%0) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fast_cabs", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.array<2 x f32>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @cabsf, fastmathFlags = #llvm.fastmath<>} : (!llvm.array<2 x f32>) -> f32 - "llvm.return"(%0) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fast_cabsf", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.array<2 x f128>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @cabsl, fastmathFlags = #llvm.fastmath<>} : (!llvm.array<2 x f128>) -> f128 - "llvm.return"(%0) : (f128) -> () - }) {linkage = 10 : i64, sym_name = "fast_cabsl", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "cabs", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "cabsf", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "cabsl", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @std_cabs(%arg0: !llvm.array<2 x f64>) -> f64 { + %0 = llvm.call @cabs(%arg0) : (!llvm.array<2 x f64>) -> f64 + llvm.return %0 : f64 + } + llvm.func @std_cabsf(%arg0: !llvm.array<2 x f32>) -> f32 { + %0 = llvm.call @cabsf(%arg0) : (!llvm.array<2 x f32>) -> f32 + llvm.return %0 : f32 + } + llvm.func @std_cabsl(%arg0: !llvm.array<2 x f128>) -> f128 { + %0 = llvm.call @cabsl(%arg0) : (!llvm.array<2 x f128>) -> f128 + llvm.return %0 : f128 + } + llvm.func @fast_cabs(%arg0: !llvm.array<2 x f64>) -> f64 { + %0 = llvm.call @cabs(%arg0) {fastmathFlags = #llvm.fastmath} : (!llvm.array<2 x f64>) -> f64 + llvm.return %0 : f64 + } + llvm.func @fast_cabsf(%arg0: !llvm.array<2 x f32>) -> f32 { + %0 = llvm.call @cabsf(%arg0) {fastmathFlags = #llvm.fastmath} : (!llvm.array<2 x f32>) -> f32 + llvm.return %0 : f32 + } + llvm.func @fast_cabsl(%arg0: !llvm.array<2 x f128>) -> f128 { + %0 = llvm.call @cabsl(%arg0) {fastmathFlags = #llvm.fastmath} : (!llvm.array<2 x f128>) -> f128 + llvm.return %0 : f128 + } + llvm.func @cabs(!llvm.array<2 x f64>) -> f64 + llvm.func @cabsf(!llvm.array<2 x f32>) -> f32 + llvm.func @cabsl(!llvm.array<2 x f128>) -> f128 +} diff --git a/test/LLVMDialect/InstCombine/cabs-discrete.ll.mlir b/test/LLVMDialect/InstCombine/cabs-discrete.ll.mlir index 7977ca572..98d3b19ca 100644 --- a/test/LLVMDialect/InstCombine/cabs-discrete.ll.mlir +++ b/test/LLVMDialect/InstCombine/cabs-discrete.ll.mlir @@ -1,39 +1,29 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @cabs, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%0) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "std_cabs", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @cabsf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%0) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "std_cabsf", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f128, %arg1: f128): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @cabsl, fastmathFlags = #llvm.fastmath<>} : (f128, f128) -> f128 - "llvm.return"(%0) : (f128) -> () - }) {linkage = 10 : i64, sym_name = "std_cabsl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @cabs, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%0) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fast_cabs", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @cabsf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%0) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fast_cabsf", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f128, %arg1: f128): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @cabsl, fastmathFlags = #llvm.fastmath<>} : (f128, f128) -> f128 - "llvm.return"(%0) : (f128) -> () - }) {linkage = 10 : i64, sym_name = "fast_cabsl", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "cabs", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "cabsf", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "cabsl", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @std_cabs(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.call @cabs(%arg0, %arg1) : (f64, f64) -> f64 + llvm.return %0 : f64 + } + llvm.func @std_cabsf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.call @cabsf(%arg0, %arg1) : (f32, f32) -> f32 + llvm.return %0 : f32 + } + llvm.func @std_cabsl(%arg0: f128, %arg1: f128) -> f128 { + %0 = llvm.call @cabsl(%arg0, %arg1) : (f128, f128) -> f128 + llvm.return %0 : f128 + } + llvm.func @fast_cabs(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.call @cabs(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %0 : f64 + } + llvm.func @fast_cabsf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.call @cabsf(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %0 : f32 + } + llvm.func @fast_cabsl(%arg0: f128, %arg1: f128) -> f128 { + %0 = llvm.call @cabsl(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f128, f128) -> f128 + llvm.return %0 : f128 + } + llvm.func @cabs(f64, f64) -> f64 + llvm.func @cabsf(f32, f32) -> f32 + llvm.func @cabsl(f128, f128) -> f128 +} diff --git a/test/LLVMDialect/InstCombine/call-callconv-mismatch.ll.mlir b/test/LLVMDialect/InstCombine/call-callconv-mismatch.ll.mlir index 0371a68af..97efb637e 100644 --- a/test/LLVMDialect/InstCombine/call-callconv-mismatch.ll.mlir +++ b/test/LLVMDialect/InstCombine/call-callconv-mismatch.ll.mlir @@ -1,13 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i8 - "llvm.return"(%0) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @bar, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i8 - "llvm.return"(%0) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func arm_aapcs_vfpcc @bar(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %0 : i8 + } + llvm.func arm_aapcs_vfpcc @foo(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.call @bar(%arg0) : (!llvm.ptr) -> i8 + llvm.return %0 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/call-callconv.ll.mlir b/test/LLVMDialect/InstCombine/call-callconv.ll.mlir index 6caf7c644..028070885 100644 --- a/test/LLVMDialect/InstCombine/call-callconv.ll.mlir +++ b/test/LLVMDialect/InstCombine/call-callconv.ll.mlir @@ -1,35 +1,26 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str", type = !llvm.array<4 x i8>, value = "abc\00"} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @abs, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "_abs", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "abs", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @labs, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "_labs", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "labs", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%2) {callee = @strlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "_strlen1", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strlen", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.call"(%arg0) {callee = @strlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "_strlen2", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private unnamed_addr constant @".str"("abc\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.func arm_aapcscc @_abs(%arg0: i32) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.call arm_aapcscc @abs(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } + llvm.func arm_aapcscc @abs(i32) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func arm_aapcscc @_labs(%arg0: i32) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.call arm_aapcscc @labs(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } + llvm.func arm_aapcscc @labs(i32) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func arm_aapcscc @_strlen1() -> i32 { + %0 = llvm.mlir.constant("abc\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.call arm_aapcscc @strlen(%1) : (!llvm.ptr) -> i32 + llvm.return %2 : i32 + } + llvm.func arm_aapcscc @strlen(!llvm.ptr) -> i32 + llvm.func arm_aapcscc @_strlen2(%arg0: !llvm.ptr) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call arm_aapcscc @strlen(%arg0) : (!llvm.ptr) -> i32 + %2 = llvm.icmp "ne" %1, %0 : i32 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/call-cast-attrs.ll.mlir b/test/LLVMDialect/InstCombine/call-cast-attrs.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/call-cast-target-inalloca.ll.mlir b/test/LLVMDialect/InstCombine/call-cast-target-inalloca.ll.mlir new file mode 100644 index 000000000..df887a443 --- /dev/null +++ b/test/LLVMDialect/InstCombine/call-cast-target-inalloca.ll.mlir @@ -0,0 +1,17 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @takes_i32(i32) + llvm.func @takes_i32_inalloca(!llvm.ptr {llvm.inalloca = i32}) + llvm.func @f() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.addressof @takes_i32 : !llvm.ptr + %2 = llvm.alloca inalloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call %1(%2) : !llvm.ptr, (!llvm.ptr) -> () + llvm.return + } + llvm.func @g() { + %0 = llvm.mlir.addressof @takes_i32_inalloca : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + llvm.call %0(%1) : !llvm.ptr, (i32) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/call-cast-target-preallocated.ll.mlir b/test/LLVMDialect/InstCombine/call-cast-target-preallocated.ll.mlir index 125ad9c1a..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/call-cast-target-preallocated.ll.mlir +++ b/test/LLVMDialect/InstCombine/call-cast-target-preallocated.ll.mlir @@ -1,29 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.call.preallocated.setup", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.call.preallocated.arg", type = !llvm.func (metadata, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "takes_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "takes_i32_preallocated", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @takes_i32} : () -> !llvm.ptr> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>) -> !llvm.ptr)>> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.call"(%3) {callee = @llvm.call.preallocated.setup, fastmathFlags = #llvm.fastmath<>} : (i32) -> !llvm.metadata - %5 = "llvm.call"(%4, %2) {callee = @llvm.call.preallocated.arg, fastmathFlags = #llvm.fastmath<>} : (!llvm.metadata, i32) -> !llvm.ptr - %6 = "llvm.bitcast"(%5) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%1, %6) : (!llvm.ptr)>>, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @takes_i32_preallocated} : () -> !llvm.ptr)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr)>>) -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.call"(%1, %2) : (!llvm.ptr>, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "g", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/call-cast-target.ll.mlir b/test/LLVMDialect/InstCombine/call-cast-target.ll.mlir new file mode 100644 index 000000000..7e22792bf --- /dev/null +++ b/test/LLVMDialect/InstCombine/call-cast-target.ll.mlir @@ -0,0 +1,57 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @main() -> i32 { + %0 = llvm.mlir.addressof @ctime : !llvm.ptr + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.call %0(%1) : !llvm.ptr, (!llvm.ptr) -> i32 + llvm.return %2 : i32 + } + llvm.func @ctime(!llvm.ptr) -> !llvm.ptr + llvm.func internal @foo(%arg0: !llvm.ptr) -> !llvm.struct<(i8)> attributes {dso_local} { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.undef : !llvm.struct<(i8)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<(i8)> + llvm.return %2 : !llvm.struct<(i8)> + } + llvm.func @test_struct_ret() { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.call @foo(%0) : (!llvm.ptr) -> !llvm.struct<(i8)> + llvm.return + } + llvm.func @fn1(i32) -> i32 + llvm.func @test1(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.addressof @fn1 : !llvm.ptr + %1 = llvm.call %0(%arg0) : !llvm.ptr, (!llvm.ptr) -> i32 + llvm.return %1 : i32 + } + llvm.func @fn2(i16) -> i32 + llvm.func @test2(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.addressof @fn2 : !llvm.ptr + %1 = llvm.call %0(%arg0) : !llvm.ptr, (!llvm.ptr) -> i32 + llvm.return %1 : i32 + } + llvm.func @fn3(i64) -> i32 + llvm.func @test3(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.addressof @fn3 : !llvm.ptr + %1 = llvm.call %0(%arg0) : !llvm.ptr, (!llvm.ptr) -> i32 + llvm.return %1 : i32 + } + llvm.func @fn4(i32) -> i32 attributes {passthrough = ["thunk"]} + llvm.func @test4(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.addressof @fn4 : !llvm.ptr + %1 = llvm.call %0(%arg0) : !llvm.ptr, (!llvm.ptr) -> i32 + llvm.return %1 : i32 + } + llvm.func @fn5(!llvm.ptr {llvm.align = 4 : i64, llvm.byval = !llvm.struct<(i32, i32)>}) -> i1 + llvm.func @test5() -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @fn5 : !llvm.ptr + %3 = llvm.alloca %0 x !llvm.struct<(i32, i32)> {alignment = 4 : i64} : (i32) -> !llvm.ptr + %4 = llvm.getelementptr inbounds %3[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i32, i32)> + %5 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> i32 + %6 = llvm.getelementptr inbounds %3[%1, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i32, i32)> + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + %8 = llvm.call %2(%5, %7) : !llvm.ptr, (i32, i32) -> i1 + llvm.return %8 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/call-guard.ll.mlir b/test/LLVMDialect/InstCombine/call-guard.ll.mlir index 9c8a0619f..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/call-guard.ll.mlir +++ b/test/LLVMDialect/InstCombine/call-guard.ll.mlir @@ -1,96 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.experimental.guard", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - "llvm.call"(%arg0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.call"(%arg0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.call"(%arg0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.call"(%arg0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.call"(%arg0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.call"(%arg0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.call"(%arg0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.call"(%arg0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.call"(%arg0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.call"(%arg0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_guard_adjacent_same_cond", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i1, %arg2: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 789 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 456 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 123 : i32} : () -> i32 - "llvm.call"(%arg0, %2) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1, i32) -> () - "llvm.call"(%arg1, %1) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1, i32) -> () - "llvm.call"(%arg2, %0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_guard_adjacent_diff_cond", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 789 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 128 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 255 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 456 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 123 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %6 = "llvm.icmp"(%arg0, %5) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.call"(%6, %4) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1, i32) -> () - %7 = "llvm.icmp"(%arg1, %5) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.call"(%7, %3) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1, i32) -> () - %8 = "llvm.and"(%arg0, %2) : (i32, i32) -> i32 - %9 = "llvm.icmp"(%8, %1) {predicate = 3 : i64} : (i32, i32) -> i1 - "llvm.call"(%9, %0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_guard_adjacent_diff_cond2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 456 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 123 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.icmp"(%arg0, %2) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.call"(%3, %1) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1, i32) -> () - %4 = "llvm.load"(%arg1) : (!llvm.ptr) -> i32 - %5 = "llvm.icmp"(%4, %2) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.call"(%5, %0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "negative_load", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 456 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 123 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.icmp"(%arg0, %2) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.call"(%3, %1) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1, i32) -> () - %4 = "llvm.load"(%arg1) : (!llvm.ptr) -> i32 - %5 = "llvm.icmp"(%4, %2) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.call"(%5, %0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "deref_load", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 456 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 123 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.icmp"(%arg0, %2) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.call"(%3, %1) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1, i32) -> () - %4 = "llvm.udiv"(%arg0, %arg1) : (i32, i32) -> i32 - %5 = "llvm.icmp"(%4, %2) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.call"(%5, %0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "negative_div", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 456 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 123 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.icmp"(%arg0, %2) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.call"(%3, %1) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1, i32) -> () - %4 = "llvm.add"(%arg1, %arg2) : (i32, i32) -> i32 - %5 = "llvm.add"(%4, %arg3) : (i32, i32) -> i32 - %6 = "llvm.add"(%5, %arg4) : (i32, i32) -> i32 - %7 = "llvm.icmp"(%6, %2) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.call"(%7, %0) {callee = @llvm.experimental.guard, fastmathFlags = #llvm.fastmath<>} : (i1, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "negative_window", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/call-intrinsics.ll.mlir b/test/LLVMDialect/InstCombine/call-intrinsics.ll.mlir index 7c3bf3d8e..e31e8bdd6 100644 --- a/test/LLVMDialect/InstCombine/call-intrinsics.ll.mlir +++ b/test/LLVMDialect/InstCombine/call-intrinsics.ll.mlir @@ -1,27 +1,16 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "X", type = i8, value = 0 : i8} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "Y", type = i8, value = 12 : i8} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memmove.p0i8.p0i8.i32", type = !llvm.func, ptr, i32, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memcpy.p0i8.p0i8.i32", type = !llvm.func, ptr, i32, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memset.p0i8.i32", type = !llvm.func, i8, i32, i1)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 123 : i8} : () -> i8 - %1 = "llvm.mlir.addressof"() {global_name = @X} : () -> !llvm.ptr - %2 = "llvm.mlir.addressof"() {global_name = @Y} : () -> !llvm.ptr - %3 = "llvm.mlir.addressof"() {global_name = @X} : () -> !llvm.ptr - %4 = "llvm.mlir.constant"() {value = false} : () -> i1 - %5 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %6 = "llvm.mlir.addressof"() {global_name = @Y} : () -> !llvm.ptr - %7 = "llvm.mlir.addressof"() {global_name = @X} : () -> !llvm.ptr - "llvm.call"(%7, %6, %5, %4) {callee = @llvm.memmove.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.call"(%3, %2, %5, %4) {callee = @llvm.memcpy.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.call"(%1, %0, %5, %4) {callee = @llvm.memset.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "zero_byte_test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @X(0 : i8) {addr_space = 0 : i32} : i8 + llvm.mlir.global external @Y(12 : i8) {addr_space = 0 : i32} : i8 + llvm.func @zero_byte_test() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.addressof @X : !llvm.ptr + %2 = llvm.mlir.constant(12 : i8) : i8 + %3 = llvm.mlir.addressof @Y : !llvm.ptr + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(123 : i8) : i8 + "llvm.intr.memmove"(%1, %3, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + "llvm.intr.memcpy"(%1, %3, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + "llvm.intr.memset"(%1, %5, %4) <{isVolatile = false}> : (!llvm.ptr, i8, i32) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/call-returned.ll.mlir b/test/LLVMDialect/InstCombine/call-returned.ll.mlir new file mode 100644 index 000000000..0cd02e86f --- /dev/null +++ b/test/LLVMDialect/InstCombine/call-returned.ll.mlir @@ -0,0 +1,51 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @GV(dense<0> : vector<2xi32>) {addr_space = 0 : i32} : vector<2xi32> + llvm.func @passthru_i32(i32 {llvm.returned}) -> i32 + llvm.func @passthru_p8(!llvm.ptr {llvm.returned}) -> !llvm.ptr + llvm.func @passthru_p8_from_p32(!llvm.ptr {llvm.returned}) -> !llvm.ptr + llvm.func @passthru_8i8v_from_2i32v(vector<2xi32> {llvm.returned}) -> vector<8xi8> + llvm.func @returned_const_int_arg() -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.call @passthru_i32(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @returned_const_ptr_arg() -> !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.call @passthru_p8(%0) : (!llvm.ptr) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @returned_const_ptr_arg_casted() -> !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.call @passthru_p8_from_p32(%0) : (!llvm.ptr) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @returned_ptr_arg_casted(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.call @passthru_p8_from_p32(%arg0) : (!llvm.ptr) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @returned_const_vec_arg_casted() -> vector<8xi8> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.addressof @GV : !llvm.ptr + %3 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> vector<2xi32> + %4 = llvm.call @passthru_8i8v_from_2i32v(%3) : (vector<2xi32>) -> vector<8xi8> + llvm.return %4 : vector<8xi8> + } + llvm.func @returned_vec_arg_casted(%arg0: vector<2xi32>) -> vector<8xi8> { + %0 = llvm.call @passthru_8i8v_from_2i32v(%arg0) : (vector<2xi32>) -> vector<8xi8> + llvm.return %0 : vector<8xi8> + } + llvm.func @returned_var_arg(%arg0: i32) -> i32 { + %0 = llvm.call @passthru_i32(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } + llvm.func @returned_const_int_arg_musttail(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.call @passthru_i32(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @returned_var_arg_musttail(%arg0: i32) -> i32 { + %0 = llvm.call @passthru_i32(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/call-undef.ll.mlir b/test/LLVMDialect/InstCombine/call-undef.ll.mlir new file mode 100644 index 000000000..8b535635e --- /dev/null +++ b/test/LLVMDialect/InstCombine/call-undef.ll.mlir @@ -0,0 +1,52 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @c(i32 {llvm.noundef}) + llvm.func @d(!llvm.ptr {llvm.dereferenceable = 1 : i64}) + llvm.func @e(i32) + llvm.func @f(!llvm.ptr) + llvm.func @test1() { + %0 = llvm.mlir.undef : i32 + llvm.call @c(%0) : (i32) -> () + llvm.return + } + llvm.func @test2() { + %0 = llvm.mlir.poison : i32 + llvm.call @c(%0) : (i32) -> () + llvm.return + } + llvm.func @test3() { + %0 = llvm.mlir.undef : i32 + llvm.call @e(%0) : (i32) -> () + llvm.return + } + llvm.func @test4() { + %0 = llvm.mlir.poison : i32 + llvm.call @e(%0) : (i32) -> () + llvm.return + } + llvm.func @test5() { + %0 = llvm.mlir.undef : !llvm.ptr + llvm.call @d(%0) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test6() { + %0 = llvm.mlir.poison : !llvm.ptr + llvm.call @d(%0) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test7() { + %0 = llvm.mlir.undef : !llvm.ptr + llvm.call @f(%0) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test8() { + %0 = llvm.mlir.poison : !llvm.ptr + llvm.call @f(%0) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test_mismatched_call() { + %0 = llvm.mlir.addressof @e : !llvm.ptr + %1 = llvm.mlir.poison : i8 + llvm.call %0(%1) : !llvm.ptr, (i8) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/call.ll.mlir b/test/LLVMDialect/InstCombine/call.ll.mlir new file mode 100644 index 000000000..400a2fa6e --- /dev/null +++ b/test/LLVMDialect/InstCombine/call.ll.mlir @@ -0,0 +1,180 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<16> : vector<4xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "big">>} { + llvm.func @test1a(!llvm.ptr) + llvm.func @test1(%arg0: !llvm.ptr) { + llvm.call @test1a(%arg0) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test1_as1_illegal(%arg0: !llvm.ptr<1>) { + %0 = llvm.mlir.addressof @test1a : !llvm.ptr + llvm.call %0(%arg0) : !llvm.ptr, (!llvm.ptr<1>) -> () + llvm.return + } + llvm.func @test1a_as1(!llvm.ptr<1>) + llvm.func @test1_as1(%arg0: !llvm.ptr<1>) { + llvm.call @test1a_as1(%arg0) : (!llvm.ptr<1>) -> () + llvm.return + } + llvm.func @test2a(%arg0: i8) { + llvm.return + } + llvm.func @test2(%arg0: i32) -> i32 { + %0 = llvm.mlir.addressof @test2a : !llvm.ptr + llvm.call %0(%arg0) : !llvm.ptr, (i32) -> () + llvm.return %arg0 : i32 + } + llvm.func @test3a(%arg0: i8, ...) { + llvm.unreachable + } + llvm.func @test3(%arg0: i8, %arg1: i8) { + %0 = llvm.mlir.addressof @test3a : !llvm.ptr + llvm.call %0(%arg0, %arg1) : !llvm.ptr, (i8, i8) -> () + llvm.return + } + llvm.func @test4a() -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.return %0 : i8 + } + llvm.func @test4() -> i32 { + %0 = llvm.mlir.addressof @test4a : !llvm.ptr + %1 = llvm.call %0() : !llvm.ptr, () -> i32 + llvm.return %1 : i32 + } + llvm.func @test5a() -> i32 + llvm.func @test5() -> i32 { + %0 = llvm.call @test5a() : () -> i32 + llvm.return %0 : i32 + } + llvm.func @test6a(i32) -> i32 + llvm.func @test6() -> i32 { + %0 = llvm.mlir.addressof @test6a : !llvm.ptr + %1 = llvm.call %0() : !llvm.ptr, () -> i32 + llvm.return %1 : i32 + } + llvm.func @test7a() { + llvm.return + } + llvm.func @test7() { + %0 = llvm.mlir.addressof @test7a : !llvm.ptr + %1 = llvm.mlir.constant(5 : i32) : i32 + llvm.call %0(%1) : !llvm.ptr, (i32) -> () + llvm.return + } + llvm.func @test8a() + llvm.func @test8() -> !llvm.ptr attributes {personality = @__gxx_personality_v0} { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.invoke @test8a() to ^bb1 unwind ^bb2 : () -> () + ^bb1: // pred: ^bb0 + llvm.unreachable + ^bb2: // pred: ^bb0 + %1 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)> + llvm.return %0 : !llvm.ptr + } + llvm.func @__gxx_personality_v0(...) -> i32 + llvm.func @test9x(!llvm.ptr, !llvm.ptr, ...) -> !llvm.ptr attributes {passthrough = ["noredzone"]} + llvm.func @test9(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> !llvm.ptr attributes {passthrough = ["noredzone", "nounwind", "ssp"]} { + %0 = llvm.mlir.addressof @test9x : !llvm.ptr + %1 = llvm.call %0(%arg0, %arg1) : !llvm.ptr, (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test10a(!llvm.vec<2 x ptr>) + llvm.func @test10(%arg0: !llvm.vec<2 x ptr>) { + llvm.call @test10a(%arg0) : (!llvm.vec<2 x ptr>) -> () + llvm.return + } + llvm.func @test10a_mixed_as(!llvm.vec<2 x ptr<1>>) + llvm.func @test10_mixed_as(%arg0: !llvm.vec<2 x ptr>) { + %0 = llvm.mlir.addressof @test10a_mixed_as : !llvm.ptr + llvm.call %0(%arg0) : !llvm.ptr, (!llvm.vec<2 x ptr>) -> () + llvm.return + } + llvm.func @test11a() -> !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test11() -> !llvm.ptr { + %0 = llvm.call @test11a() : () -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test11a_mixed_as() -> !llvm.ptr<1> { + %0 = llvm.mlir.zero : !llvm.ptr<1> + llvm.return %0 : !llvm.ptr<1> + } + llvm.func @test11_mixed_as() -> !llvm.ptr { + %0 = llvm.mlir.addressof @test11a_mixed_as : !llvm.ptr + %1 = llvm.call %0() : !llvm.ptr, () -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test12a() -> !llvm.vec<2 x ptr> { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec<2 x ptr> + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec<2 x ptr> + llvm.return %5 : !llvm.vec<2 x ptr> + } + llvm.func @test12() -> !llvm.vec<2 x ptr> { + %0 = llvm.call @test12a() : () -> !llvm.vec<2 x ptr> + llvm.return %0 : !llvm.vec<2 x ptr> + } + llvm.func @test12a_mixed_as() -> !llvm.vec<2 x ptr<1>> { + %0 = llvm.mlir.zero : !llvm.ptr<1> + %1 = llvm.mlir.undef : !llvm.vec<2 x ptr<1>> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec<2 x ptr<1>> + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec<2 x ptr<1>> + llvm.return %5 : !llvm.vec<2 x ptr<1>> + } + llvm.func @test12_mixed_as() -> !llvm.vec<2 x ptr> { + %0 = llvm.mlir.addressof @test12a_mixed_as : !llvm.ptr + %1 = llvm.call %0() : !llvm.ptr, () -> !llvm.vec<2 x ptr> + llvm.return %1 : !llvm.vec<2 x ptr> + } + llvm.func @test13a(vector<2xi64>) + llvm.func @test13(%arg0: !llvm.vec<2 x ptr>) { + %0 = llvm.mlir.addressof @test13a : !llvm.ptr + llvm.call %0(%arg0) : !llvm.ptr, (!llvm.vec<2 x ptr>) -> () + llvm.return + } + llvm.func @test14a(!llvm.vec<2 x ptr>) + llvm.func @test14(%arg0: vector<2xi64>) { + %0 = llvm.mlir.addressof @test14a : !llvm.ptr + llvm.call %0(%arg0) : !llvm.ptr, (vector<2xi64>) -> () + llvm.return + } + llvm.func @test15a() -> vector<2xi16> { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : vector<2xi16>) : vector<2xi16> + llvm.return %1 : vector<2xi16> + } + llvm.func @test15() -> i32 { + %0 = llvm.mlir.addressof @test15a : !llvm.ptr + %1 = llvm.call %0() : !llvm.ptr, () -> i32 + llvm.return %1 : i32 + } + llvm.func @test16a() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.return %0 : i32 + } + llvm.func @test16() -> vector<2xi16> { + %0 = llvm.mlir.addressof @test16a : !llvm.ptr + %1 = llvm.call %0() : !llvm.ptr, () -> vector<2xi16> + llvm.return %1 : vector<2xi16> + } + llvm.func @pr28655(i32 {llvm.returned}) -> i32 + llvm.func @test17() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @pr28655(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @non_vararg(%arg0: !llvm.ptr, %arg1: i32) { + llvm.return + } + llvm.func @test_cast_to_vararg(%arg0: !llvm.ptr) { + %0 = llvm.mlir.addressof @non_vararg : !llvm.ptr + %1 = llvm.mlir.constant(42 : i32) : i32 + llvm.call %0(%arg0, %1) vararg(!llvm.func) : !llvm.ptr, (!llvm.ptr, i32) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/call2.ll.mlir b/test/LLVMDialect/InstCombine/call2.ll.mlir index 72fc95c4f..38ccfa7a4 100644 --- a/test/LLVMDialect/InstCombine/call2.ll.mlir +++ b/test/LLVMDialect/InstCombine/call2.ll.mlir @@ -1,26 +1,23 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @f} : () -> !llvm.ptr)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr)>>) -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 3.000000e+00 : f64} : () -> f64 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr - %5 = "llvm.call"(%1, %2) : (!llvm.ptr>, f64) -> i32 - "llvm.br"()[^bb1] : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bar() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.addressof @f : !llvm.ptr + %2 = llvm.mlir.constant(3.000000e+00 : f64) : f64 + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %4 = llvm.call %1(%2) vararg(!llvm.func) : !llvm.ptr, (f64) -> i32 + llvm.br ^bb1 ^bb1: // pred: ^bb0 - %6 = "llvm.load"(%4) : (!llvm.ptr) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr> - %2 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - "llvm.store"(%arg0, %1) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.br"()[^bb1] : () -> () + %5 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %5 : i32 + } + llvm.func @f(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %1 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.br ^bb1 ^bb1: // pred: ^bb0 - %3 = "llvm.load"(%2) : (!llvm.ptr) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/call_nonnull_arg.ll.mlir b/test/LLVMDialect/InstCombine/call_nonnull_arg.ll.mlir new file mode 100644 index 000000000..cd8ee4de4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/call_nonnull_arg.ll.mlir @@ -0,0 +1,30 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @dummy(!llvm.ptr, i32) + llvm.func @test(%arg0: !llvm.ptr, %arg1: i32) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + llvm.cond_br %2, ^bb3, ^bb1 + ^bb1: // pred: ^bb0 + %3 = llvm.icmp "eq" %arg1, %1 : i32 + llvm.cond_br %3, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.call @dummy(%arg0, %arg1) : (!llvm.ptr, i32) -> () + llvm.return + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.unreachable + } + llvm.func @bar(!llvm.ptr, !llvm.ptr {llvm.nonnull, llvm.noundef}) + llvm.func @bar_without_noundef(!llvm.ptr, !llvm.ptr {llvm.nonnull}) + llvm.func @baz(!llvm.ptr, !llvm.ptr) + llvm.func @deduce_nonnull_from_another_call(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + llvm.call @bar(%arg0, %arg1) : (!llvm.ptr, !llvm.ptr) -> () + llvm.call @baz(%arg1, %arg1) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @deduce_nonnull_from_another_call2(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + llvm.call @bar_without_noundef(%arg0, %arg1) : (!llvm.ptr, !llvm.ptr) -> () + llvm.call @baz(%arg1, %arg1) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/calloc-mismatch.ll.mlir b/test/LLVMDialect/InstCombine/calloc-mismatch.ll.mlir index b9da28fa1..ed4e67ff7 100644 --- a/test/LLVMDialect/InstCombine/calloc-mismatch.ll.mlir +++ b/test/LLVMDialect/InstCombine/calloc-mismatch.ll.mlir @@ -1,11 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "calloc", type = !llvm.func (i64, i32)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.call"(%1, %0) {callee = @calloc, fastmathFlags = #llvm.fastmath<>} : (i64, i32) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "PR50846", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @calloc(i64, i32) -> !llvm.ptr + llvm.func @PR50846() { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.call @calloc(%0, %1) : (i64, i32) -> !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/callsite_nonnull_args_through_casts.ll.mlir b/test/LLVMDialect/InstCombine/callsite_nonnull_args_through_casts.ll.mlir index 512dbcc03..3c0d7afc8 100644 --- a/test/LLVMDialect/InstCombine/callsite_nonnull_args_through_casts.ll.mlir +++ b/test/LLVMDialect/InstCombine/callsite_nonnull_args_through_casts.ll.mlir @@ -1,80 +1,69 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%2) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "nonnullAfterBitCast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i8) -> i32 - %2 = "llvm.add"(%1, %0) : (i32, i32) -> i32 - %3 = "llvm.sext"(%2) : (i32) -> i64 - %4 = "llvm.inttoptr"(%3) : (i64) -> !llvm.ptr - "llvm.call"(%4) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "nonnullAfterSExt", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i8) -> i32 - %2 = "llvm.add"(%1, %0) : (i32, i32) -> i32 - %3 = "llvm.zext"(%2) : (i32) -> i64 - %4 = "llvm.inttoptr"(%3) : (i64) -> !llvm.ptr - "llvm.call"(%4) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "nonnullAfterZExt", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.assume", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 100 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %2 = "llvm.sdiv"(%1, %arg0) : (i32, i32) -> i32 - %3 = "llvm.inttoptr"(%2) : (i32) -> !llvm.ptr - "llvm.call"(%3) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - %4 = "llvm.sdiv"(%0, %arg1) : (i64, i64) -> i64 - %5 = "llvm.inttoptr"(%4) : (i64) -> !llvm.ptr - "llvm.call"(%5) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "nonnullAfterInt2Ptr", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i64 - %3 = "llvm.inttoptr"(%2) : (i64) -> !llvm.ptr - "llvm.call"(%3) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "nonnullAfterPtr2Int", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i128): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i128} : () -> i128 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 1 : i64} : (i128, i128) -> i1 - "llvm.call"(%1) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %2 = "llvm.inttoptr"(%arg0) : (i128) -> !llvm.ptr - "llvm.call"(%2) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "maybenullAfterInt2Ptr", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i32 - %3 = "llvm.inttoptr"(%2) : (i32) -> !llvm.ptr - "llvm.call"(%3) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "maybenullAfterPtr2Int", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.addrspacecast"(%arg0) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%0) {callee = @bar, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.call"(%arg0) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "maybenullAfterAddrspacecast", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(!llvm.ptr) + llvm.func @bar(!llvm.ptr<1>) + llvm.func @nonnullAfterBitCast() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @foo(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @nonnullAfterSExt(%arg0: i8) { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.add %1, %0 overflow : i32 + %3 = llvm.sext %2 : i32 to i64 + %4 = llvm.inttoptr %3 : i64 to !llvm.ptr + llvm.call @foo(%4) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @nonnullAfterZExt(%arg0: i8) { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.add %1, %0 overflow : i32 + %3 = llvm.zext %2 : i32 to i64 + %4 = llvm.inttoptr %3 : i64 to !llvm.ptr + llvm.call @foo(%4) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @nonnullAfterInt2Ptr(%arg0: i32, %arg1: i64) { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(100 : i64) : i64 + %2 = llvm.sdiv %0, %arg0 : i32 + %3 = llvm.inttoptr %2 : i32 to !llvm.ptr + llvm.call @foo(%3) : (!llvm.ptr) -> () + %4 = llvm.sdiv %1, %arg1 : i64 + %5 = llvm.inttoptr %4 : i64 to !llvm.ptr + llvm.call @foo(%5) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @nonnullAfterPtr2Int() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %3 = llvm.inttoptr %2 : i64 to !llvm.ptr + llvm.call @foo(%3) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @maybenullAfterInt2Ptr(%arg0: i128) { + %0 = llvm.mlir.constant(0 : i128) : i128 + %1 = llvm.icmp "ne" %arg0, %0 : i128 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.inttoptr %arg0 : i128 to !llvm.ptr + llvm.call @foo(%2) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @maybenullAfterPtr2Int() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.inttoptr %2 : i32 to !llvm.ptr + llvm.call @foo(%3) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @maybenullAfterAddrspacecast(%arg0: !llvm.ptr {llvm.nonnull}) { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr to !llvm.ptr<1> + llvm.call @bar(%0) : (!llvm.ptr<1>) -> () + llvm.call @foo(%arg0) : (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-ashr-shl-to-masking.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-ashr-shl-to-masking.ll.mlir new file mode 100644 index 000000000..22588e032 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-ashr-shl-to-masking.ll.mlir @@ -0,0 +1,424 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @positive_samevar(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.ashr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerashr(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_shlnuw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.ashr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst_shlnuw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerashr_shlnuw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_shlnuw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_shlnsw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.ashr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst_shlnsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerashr_shlnsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_shlnsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_shlnuwnsw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.ashr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst_shlnuwnsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerashr_shlnuwnsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_shlnuwnsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_ashrexact(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.ashr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst_ashrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerashr_ashrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_ashrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_shlnsw_ashrexact(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.ashr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst_shlnsw_ashrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerashr_shlnsw_ashrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_shlnsw_ashrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_shlnuw_ashrexact(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.ashr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst_shlnuw_ashrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerashr_shlnuw_ashrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_shlnuw_ashrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_shlnuwnsw_ashrexact(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.ashr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst_shlnuwnsw_ashrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerashr_shlnuwnsw_ashrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_shlnuwnsw_ashrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.ashr %arg0, %arg1 : vector<2xi8> + %1 = llvm.shl %0, %arg1 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @positive_sameconst_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.ashr %arg0, %0 : vector<2xi8> + %2 = llvm.shl %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @positive_sameconst_vec_undef0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<3> : vector<3xi8>) : vector<3xi8> + %10 = llvm.ashr %arg0, %8 : vector<3xi8> + %11 = llvm.shl %10, %9 : vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @positive_sameconst_vec_undef1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.ashr %arg0, %0 : vector<3xi8> + %11 = llvm.shl %10, %9 : vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @positive_sameconst_vec_undef2(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.ashr %arg0, %8 : vector<3xi8> + %10 = llvm.shl %9, %8 : vector<3xi8> + llvm.return %10 : vector<3xi8> + } + llvm.func @positive_biggerashr_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %2 = llvm.ashr %arg0, %0 : vector<2xi8> + %3 = llvm.shl %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @positive_biggerashr_vec_undef0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<3> : vector<3xi8>) : vector<3xi8> + %10 = llvm.ashr %arg0, %8 : vector<3xi8> + %11 = llvm.shl %10, %9 : vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @positive_biggerashr_vec_undef1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<6> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.ashr %arg0, %0 : vector<3xi8> + %11 = llvm.shl %10, %9 : vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @positive_biggerashr_vec_undef2(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(3 : i8) : i8 + %10 = llvm.mlir.undef : vector<3xi8> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi8> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi8> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi8> + %17 = llvm.ashr %arg0, %8 : vector<3xi8> + %18 = llvm.shl %17, %16 : vector<3xi8> + llvm.return %18 : vector<3xi8> + } + llvm.func @positive_biggershl_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %2 = llvm.ashr %arg0, %0 : vector<2xi8> + %3 = llvm.shl %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @positive_biggershl_vec_undef0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<6> : vector<3xi8>) : vector<3xi8> + %10 = llvm.ashr %arg0, %8 : vector<3xi8> + %11 = llvm.shl %10, %9 : vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @positive_biggershl_vec_undef1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.ashr %arg0, %0 : vector<3xi8> + %11 = llvm.shl %10, %9 : vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @positive_biggershl_vec_undef2(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(6 : i8) : i8 + %10 = llvm.mlir.undef : vector<3xi8> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi8> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi8> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi8> + %17 = llvm.ashr %arg0, %8 : vector<3xi8> + %18 = llvm.shl %17, %16 : vector<3xi8> + llvm.return %18 : vector<3xi8> + } + llvm.func @positive_sameconst_multiuse(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + llvm.call @use32(%1) : (i8) -> () + %2 = llvm.shl %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerashr_multiuse(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + llvm.call @use32(%2) : (i8) -> () + %3 = llvm.shl %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_multiuse(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + llvm.call @use32(%2) : (i8) -> () + %3 = llvm.shl %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggerashr_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[3, 6]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.ashr %arg0, %0 : vector<2xi8> + %3 = llvm.shl %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @positive_biggerLashr_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[3, 6]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %2 = llvm.ashr %arg0, %0 : vector<2xi8> + %3 = llvm.shl %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @negative_twovars(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.ashr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg2 : i8 + llvm.return %1 : i8 + } + llvm.func @use32(i8) + llvm.func @negative_oneuse(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.ashr %arg0, %arg1 : i8 + llvm.call @use32(%0) : (i8) -> () + %1 = llvm.shl %0, %arg1 : i8 + llvm.return %1 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-clamp-like-pattern-between-negative-and-positive-thresholds.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-clamp-like-pattern-between-negative-and-positive-thresholds.ll.mlir new file mode 100644 index 000000000..6d6dba1f5 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-clamp-like-pattern-between-negative-and-positive-thresholds.ll.mlir @@ -0,0 +1,319 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_ult_slt_128(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @t1_ult_slt_0(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-16 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @t2_ult_sgt_128(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(127 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg2, %arg1 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @t3_ult_sgt_neg1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-17 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg2, %arg1 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @t4_ugt_slt_128(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(143 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ugt" %5, %2 : i32 + %7 = llvm.select %6, %4, %arg0 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @t5_ugt_slt_0(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-16 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(143 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ugt" %5, %2 : i32 + %7 = llvm.select %6, %4, %arg0 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @t6_ugt_sgt_128(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(127 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(143 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg2, %arg1 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ugt" %5, %2 : i32 + %7 = llvm.select %6, %4, %arg0 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @t7_ugt_sgt_neg1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-17 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(143 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg2, %arg1 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ugt" %5, %2 : i32 + %7 = llvm.select %6, %4, %arg0 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @n8_ult_slt_129(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(129 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @n9_ult_slt_neg17(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-17 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @n10_ugt_slt(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + %4 = llvm.icmp "ugt" %arg0, %1 : i32 + %5 = llvm.select %4, %arg0, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @n11_uge_slt(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(129 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + %4 = llvm.icmp "ult" %arg0, %1 : i32 + %5 = llvm.select %4, %3, %arg0 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @n12_ule_slt(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(127 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + %4 = llvm.icmp "ugt" %arg0, %1 : i32 + %5 = llvm.select %4, %3, %arg0 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @use32(i32) + llvm.func @use1(i1) + llvm.func @t10_oneuse0(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @n11_oneuse1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @t12_oneuse2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @n13_oneuse3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + llvm.call @use1(%6) : (i1) -> () + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @n14_oneuse4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @n15_oneuse5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @n16_oneuse6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + llvm.call @use1(%6) : (i1) -> () + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @n17_oneuse7(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.add %arg0, %1 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @n18_oneuse8(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + llvm.call @use1(%6) : (i1) -> () + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @n19_oneuse9(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(144 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.select %3, %arg1, %arg2 : i1, i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.add %arg0, %1 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.icmp "ult" %5, %2 : i32 + llvm.call @use1(%6) : (i1) -> () + %7 = llvm.select %6, %arg0, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @t20_ult_slt_vec_splat(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<128> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<144> : vector<2xi32>) : vector<2xi32> + %3 = llvm.icmp "slt" %arg0, %0 : vector<2xi32> + %4 = llvm.select %3, %arg1, %arg2 : vector<2xi1>, vector<2xi32> + %5 = llvm.add %arg0, %1 : vector<2xi32> + %6 = llvm.icmp "ult" %5, %2 : vector<2xi32> + %7 = llvm.select %6, %arg0, %4 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @t21_ult_slt_vec_nonsplat(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[128, 64]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[16, 8]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[144, 264]> : vector<2xi32>) : vector<2xi32> + %3 = llvm.icmp "slt" %arg0, %0 : vector<2xi32> + %4 = llvm.select %3, %arg1, %arg2 : vector<2xi1>, vector<2xi32> + %5 = llvm.add %arg0, %1 : vector<2xi32> + %6 = llvm.icmp "ult" %5, %2 : vector<2xi32> + %7 = llvm.select %6, %arg0, %4 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @use2xi1(vector<2xi1>) + llvm.func @use(vector<2xi1>) + llvm.func @t22_uge_slt(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<128> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[144, 0]> : vector<2xi32>) : vector<2xi32> + %3 = llvm.icmp "slt" %arg0, %0 : vector<2xi32> + %4 = llvm.select %3, %arg1, %arg2 : vector<2xi1>, vector<2xi32> + %5 = llvm.add %arg0, %1 : vector<2xi32> + %6 = llvm.icmp "uge" %5, %2 : vector<2xi32> + llvm.call @use2xi1(%6) : (vector<2xi1>) -> () + %7 = llvm.select %6, %4, %arg0 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @t23_ult_sge(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[128, -2147483648]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[16, -2147483648]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[144, -1]> : vector<2xi32>) : vector<2xi32> + %3 = llvm.icmp "sge" %arg0, %0 : vector<2xi32> + llvm.call @use2xi1(%3) : (vector<2xi1>) -> () + %4 = llvm.select %3, %arg2, %arg1 : vector<2xi1>, vector<2xi32> + %5 = llvm.add %arg0, %1 : vector<2xi32> + %6 = llvm.icmp "ult" %5, %2 : vector<2xi32> + %7 = llvm.select %6, %arg0, %4 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-clamp-like-pattern-between-zero-and-positive-threshold.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-clamp-like-pattern-between-zero-and-positive-threshold.ll.mlir new file mode 100644 index 000000000..59d4cf265 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-clamp-like-pattern-between-zero-and-positive-threshold.ll.mlir @@ -0,0 +1,242 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_ult_slt_65536(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.select %1, %arg1, %arg2 : i1, i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.select %3, %arg0, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @t1_ult_slt_0(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + %4 = llvm.icmp "ult" %arg0, %1 : i32 + %5 = llvm.select %4, %arg0, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @t2_ult_sgt_65536(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg2, %arg1 : i1, i32 + %4 = llvm.icmp "ult" %arg0, %1 : i32 + %5 = llvm.select %4, %arg0, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @t3_ult_sgt_neg1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg2, %arg1 : i1, i32 + %4 = llvm.icmp "ult" %arg0, %1 : i32 + %5 = llvm.select %4, %arg0, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @t4_ugt_slt_65536(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + %4 = llvm.icmp "ugt" %arg0, %1 : i32 + %5 = llvm.select %4, %3, %arg0 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @t5_ugt_slt_0(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + %4 = llvm.icmp "ugt" %arg0, %1 : i32 + %5 = llvm.select %4, %3, %arg0 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @t6_ugt_sgt_65536(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.select %1, %arg2, %arg1 : i1, i32 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.select %3, %2, %arg0 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @t7_ugt_sgt_neg1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg2, %arg1 : i1, i32 + %4 = llvm.icmp "ugt" %arg0, %1 : i32 + %5 = llvm.select %4, %3, %arg0 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @n8_ult_slt_65537(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(65537 : i32) : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + %4 = llvm.icmp "ult" %arg0, %1 : i32 + %5 = llvm.select %4, %arg0, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @n9_ult_slt_neg1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + %4 = llvm.icmp "ult" %arg0, %1 : i32 + %5 = llvm.select %4, %arg0, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @use32(i32) + llvm.func @use1(i1) + llvm.func @n10_oneuse0(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(32768 : i32) : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + %4 = llvm.icmp "ult" %arg0, %1 : i32 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %4, %arg0, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @n11_oneuse1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(32768 : i32) : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + %4 = llvm.icmp "ult" %arg0, %1 : i32 + %5 = llvm.select %4, %arg0, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @n12_oneuse2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(32768 : i32) : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.icmp "ult" %arg0, %1 : i32 + %5 = llvm.select %4, %arg0, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @n13_oneuse3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(32768 : i32) : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + %4 = llvm.icmp "ult" %arg0, %1 : i32 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %4, %arg0, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @n14_oneuse4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(32768 : i32) : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.icmp "ult" %arg0, %1 : i32 + %5 = llvm.select %4, %arg0, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @n15_oneuse5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(32768 : i32) : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.icmp "ult" %arg0, %1 : i32 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %4, %arg0, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @n16_oneuse6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(32768 : i32) : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.icmp "ult" %arg0, %1 : i32 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %4, %arg0, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @t17_ult_slt_vec_splat(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<65536> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "slt" %arg0, %0 : vector<2xi32> + %2 = llvm.select %1, %arg1, %arg2 : vector<2xi1>, vector<2xi32> + %3 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %4 = llvm.select %3, %arg0, %2 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @t18_ult_slt_vec_nonsplat(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[65536, 32768]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "slt" %arg0, %0 : vector<2xi32> + %2 = llvm.select %1, %arg1, %arg2 : vector<2xi1>, vector<2xi32> + %3 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %4 = llvm.select %3, %arg0, %2 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @t19_ult_slt_vec_poison0(%arg0: vector<3xi32>, %arg1: vector<3xi32>, %arg2: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(dense<65536> : vector<3xi32>) : vector<3xi32> + %10 = llvm.icmp "slt" %arg0, %8 : vector<3xi32> + %11 = llvm.select %10, %arg1, %arg2 : vector<3xi1>, vector<3xi32> + %12 = llvm.icmp "ult" %arg0, %9 : vector<3xi32> + %13 = llvm.select %12, %arg0, %11 : vector<3xi1>, vector<3xi32> + llvm.return %13 : vector<3xi32> + } + llvm.func @t20_ult_slt_vec_poison1(%arg0: vector<3xi32>, %arg1: vector<3xi32>, %arg2: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<[65536, 65537, 65536]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.undef : vector<3xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi32> + %10 = llvm.icmp "slt" %arg0, %0 : vector<3xi32> + %11 = llvm.select %10, %arg1, %arg2 : vector<3xi1>, vector<3xi32> + %12 = llvm.icmp "ult" %arg0, %9 : vector<3xi32> + %13 = llvm.select %12, %arg0, %11 : vector<3xi1>, vector<3xi32> + llvm.return %13 : vector<3xi32> + } + llvm.func @t21_ult_slt_vec_poison2(%arg0: vector<3xi32>, %arg1: vector<3xi32>, %arg2: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.icmp "slt" %arg0, %8 : vector<3xi32> + %10 = llvm.select %9, %arg1, %arg2 : vector<3xi1>, vector<3xi32> + %11 = llvm.icmp "ult" %arg0, %8 : vector<3xi32> + %12 = llvm.select %11, %arg0, %10 : vector<3xi1>, vector<3xi32> + llvm.return %12 : vector<3xi32> + } + llvm.func @t22_pointers(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(65536 : i64) : i64 + %1 = llvm.inttoptr %0 : i64 to !llvm.ptr + %2 = llvm.icmp "slt" %arg0, %1 : !llvm.ptr + %3 = llvm.select %2, %arg1, %arg2 : i1, !llvm.ptr + %4 = llvm.icmp "ult" %arg0, %1 : !llvm.ptr + %5 = llvm.select %4, %arg0, %3 : i1, !llvm.ptr + llvm.return %5 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-clamp-with-select-of-constant-threshold-pattern.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-clamp-with-select-of-constant-threshold-pattern.ll.mlir new file mode 100644 index 000000000..a11e1d5a0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-clamp-with-select-of-constant-threshold-pattern.ll.mlir @@ -0,0 +1,126 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_select_cond_and_v0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.icmp "sle" %arg0, %0 : i32 + %3 = llvm.icmp "sge" %arg0, %1 : i32 + %4 = llvm.select %2, %1, %0 : i1, i32 + %5 = llvm.and %2, %3 : i1 + %6 = llvm.select %5, %arg0, %4 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @t0_select_cond_and_v0_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "sle" %arg0, %0 : i32 + %4 = llvm.icmp "sge" %arg0, %1 : i32 + %5 = llvm.select %3, %1, %0 : i1, i32 + %6 = llvm.select %3, %4, %2 : i1, i1 + %7 = llvm.select %6, %arg0, %5 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @t1_select_cond_and_v1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.icmp "sle" %arg0, %0 : i32 + %3 = llvm.icmp "sge" %arg0, %1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i32 + %5 = llvm.and %2, %3 : i1 + %6 = llvm.select %5, %arg0, %4 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @t1_select_cond_and_v1_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "sle" %arg0, %0 : i32 + %4 = llvm.icmp "sge" %arg0, %1 : i32 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %4, %2 : i1, i1 + %7 = llvm.select %6, %arg0, %5 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @t2_select_cond_or_v0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.select %2, %0, %1 : i1, i32 + %5 = llvm.or %2, %3 : i1 + %6 = llvm.select %5, %4, %arg0 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @t2_select_cond_or_v0_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.icmp "slt" %arg0, %1 : i32 + %5 = llvm.select %3, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %4 : i1, i1 + %7 = llvm.select %6, %5, %arg0 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @t3_select_cond_or_v1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.select %3, %1, %0 : i1, i32 + %5 = llvm.or %2, %3 : i1 + %6 = llvm.select %5, %4, %arg0 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @t3_select_cond_or_v1_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.icmp "slt" %arg0, %1 : i32 + %5 = llvm.select %4, %1, %0 : i1, i32 + %6 = llvm.select %3, %2, %4 : i1, i1 + %7 = llvm.select %6, %5, %arg0 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @t4_select_cond_xor_v0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.select %2, %0, %1 : i1, i32 + %5 = llvm.xor %2, %3 : i1 + %6 = llvm.select %5, %arg0, %4 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @t4_select_cond_xor_v1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i32 + %5 = llvm.xor %2, %3 : i1 + %6 = llvm.select %5, %arg0, %4 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @t5_select_cond_xor_v2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.icmp "sle" %arg0, %0 : i32 + %3 = llvm.icmp "sle" %arg0, %1 : i32 + %4 = llvm.select %3, %1, %0 : i1, i32 + %5 = llvm.xor %2, %3 : i1 + %6 = llvm.select %5, %arg0, %4 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @t5_select_cond_xor_v3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.icmp "sle" %arg0, %0 : i32 + %3 = llvm.icmp "sle" %arg0, %1 : i32 + %4 = llvm.select %2, %1, %0 : i1, i32 + %5 = llvm.xor %2, %3 : i1 + %6 = llvm.select %5, %arg0, %4 : i1, i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-eq-to-icmp-ule.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-eq-to-icmp-ule.ll.mlir new file mode 100644 index 000000000..f3b0fb128 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-eq-to-icmp-ule.ll.mlir @@ -0,0 +1,111 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "eq" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @pv(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @p1_vec_splat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "eq" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 15]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "eq" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase0(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "eq" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase1(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, -1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "eq" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p3_vec_splat_poison(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.and %arg0, %8 : vector<3xi8> + %10 = llvm.icmp "eq" %9, %arg0 : vector<3xi8> + llvm.return %10 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0() -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "eq" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @cv0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @cv1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "eq" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @cv2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "eq" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @use8(i8) + llvm.func @oneuse0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "eq" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "eq" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "eq" %1, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @n2(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 16]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "eq" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll.mlir new file mode 100644 index 000000000..3f5fdf2f2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll.mlir @@ -0,0 +1,126 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "ne" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @pv(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @p1_vec_splat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "ne" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 15]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "ne" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase0(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "ne" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase1(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, -1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "ne" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p3_vec_splat_poison(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.and %arg0, %8 : vector<3xi8> + %10 = llvm.icmp "ne" %9, %arg0 : vector<3xi8> + llvm.return %10 : vector<3xi1> + } + llvm.func @p3_vec_nonsplat_poison(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi8> + %10 = llvm.and %arg0, %9 : vector<3xi8> + %11 = llvm.icmp "ne" %10, %arg0 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0() -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "ne" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @cv0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "ne" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @cv1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "ne" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @cv2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "ne" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @use8(i8) + llvm.func @oneuse0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "ne" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "ne" %1, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @n2(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 16]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "ne" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sge-to-icmp-sle.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sge-to-icmp-sle.ll.mlir new file mode 100644 index 000000000..63c6b7854 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sge-to-icmp-sle.ll.mlir @@ -0,0 +1,126 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "sge" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @p1_vec_splat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "sge" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 15]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "sge" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "sge" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p3_vec_splat_poison(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.and %arg0, %8 : vector<3xi8> + %10 = llvm.icmp "sge" %9, %arg0 : vector<3xi8> + llvm.return %10 : vector<3xi1> + } + llvm.func @use8(i8) + llvm.func @oneuse0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "sge" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @gen8() -> i8 + llvm.func @c0() -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "sge" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @n0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "sge" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "sge" %1, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @n2(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 16]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "sge" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @nv(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "sge" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n3_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, -1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "sge" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @n4_vec(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi8> + %10 = llvm.and %arg0, %9 : vector<3xi8> + %11 = llvm.icmp "sge" %10, %arg0 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @cv0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "sge" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @cv1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "sge" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @cv2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "sge" %1, %3 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sgt-to-icmp-sgt.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sgt-to-icmp-sgt.ll.mlir new file mode 100644 index 000000000..9605d7059 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sgt-to-icmp-sgt.ll.mlir @@ -0,0 +1,154 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @gen8() -> i8 + llvm.func @gen2x8() -> vector<2xi8> + llvm.func @gen3x8() -> vector<3xi8> + llvm.func @p0() -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "sgt" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @p1_vec_splat() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "sgt" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 15]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "sgt" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "sgt" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p3_vec_splat_poison() -> vector<3xi1> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.call @gen3x8() : () -> vector<3xi8> + %10 = llvm.and %9, %8 : vector<3xi8> + %11 = llvm.icmp "sgt" %9, %10 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @p3_vec_nonsplat_poison() -> vector<3xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(15 : i8) : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi8> + %10 = llvm.call @gen3x8() : () -> vector<3xi8> + %11 = llvm.and %10, %9 : vector<3xi8> + %12 = llvm.icmp "sgt" %10, %11 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @use8(i8) + llvm.func @oneuse0() -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "sgt" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "sgt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n0() -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "sgt" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "sgt" %2, %arg1 : i8 + llvm.return %3 : i1 + } + llvm.func @n2() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 16]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "sgt" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @pv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "sgt" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @n3_vec() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, -1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "sgt" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @n4_vec() -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi8> + %10 = llvm.call @gen3x8() : () -> vector<3xi8> + %11 = llvm.and %10, %9 : vector<3xi8> + %12 = llvm.icmp "sgt" %10, %11 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @cv0_GOOD(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "sgt" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @cv1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "sgt" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @cv2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "sgt" %2, %arg0 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sle-to-icmp-sle.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sle-to-icmp-sle.ll.mlir new file mode 100644 index 000000000..4d6130ab2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sle-to-icmp-sle.ll.mlir @@ -0,0 +1,138 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @gen8() -> i8 + llvm.func @gen2x8() -> vector<2xi8> + llvm.func @gen3x8() -> vector<3xi8> + llvm.func @p0() -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "sle" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @p1_vec_splat() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "sle" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 15]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "sle" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "sle" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p3_vec_splat_poison() -> vector<3xi1> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.call @gen3x8() : () -> vector<3xi8> + %10 = llvm.and %9, %8 : vector<3xi8> + %11 = llvm.icmp "sle" %9, %10 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @use8(i8) + llvm.func @oneuse0() -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "sle" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "sle" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n0() -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "sle" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "sle" %2, %arg1 : i8 + llvm.return %3 : i1 + } + llvm.func @n2() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 16]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "sle" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @pv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "sle" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @n3_vec() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, -1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "sle" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @n4_vec() -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi8> + %10 = llvm.call @gen3x8() : () -> vector<3xi8> + %11 = llvm.and %10, %9 : vector<3xi8> + %12 = llvm.icmp "sle" %10, %11 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @cv0_GOOD(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "sle" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @cv1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "sle" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @cv2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "sle" %2, %arg0 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-slt-to-icmp-sgt.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-slt-to-icmp-sgt.ll.mlir new file mode 100644 index 000000000..cb9ff20cc --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-slt-to-icmp-sgt.ll.mlir @@ -0,0 +1,141 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "slt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @p1_vec_splat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "slt" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 15]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "slt" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "slt" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p3_vec_splat_poison(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.and %arg0, %8 : vector<3xi8> + %10 = llvm.icmp "slt" %9, %arg0 : vector<3xi8> + llvm.return %10 : vector<3xi1> + } + llvm.func @p3_vec_nonsplat_poison(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi8> + %10 = llvm.and %arg0, %9 : vector<3xi8> + %11 = llvm.icmp "slt" %10, %arg0 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @use8(i8) + llvm.func @oneuse0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "slt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @gen8() -> i8 + llvm.func @c0() -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "slt" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @n0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "slt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "slt" %1, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @n2(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 16]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "slt" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @nv(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "slt" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n3(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, -1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "slt" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @n4(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi8> + %10 = llvm.and %arg0, %9 : vector<3xi8> + %11 = llvm.icmp "slt" %10, %arg0 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @cv0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "slt" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @cv1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "slt" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @cv2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "slt" %1, %3 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-uge-to-icmp-ule.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-uge-to-icmp-ule.ll.mlir new file mode 100644 index 000000000..4ddab78a8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-uge-to-icmp-ule.ll.mlir @@ -0,0 +1,111 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "uge" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @pv(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "uge" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @p1_vec_splat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "uge" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 15]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "uge" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase0(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "uge" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase1(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, -1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "uge" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p3_vec_splat_poison(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.and %arg0, %8 : vector<3xi8> + %10 = llvm.icmp "uge" %9, %arg0 : vector<3xi8> + llvm.return %10 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0() -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "uge" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @cv0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "uge" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @cv1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "uge" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @cv2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "uge" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @use8(i8) + llvm.func @oneuse0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "uge" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "uge" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "uge" %1, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @n2(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 16]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "uge" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ugt-to-icmp-ugt.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ugt-to-icmp-ugt.ll.mlir new file mode 100644 index 000000000..fd85b3421 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ugt-to-icmp-ugt.ll.mlir @@ -0,0 +1,138 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @gen8() -> i8 + llvm.func @gen2x8() -> vector<2xi8> + llvm.func @gen3x8() -> vector<3xi8> + llvm.func @p0() -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "ugt" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @pv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "ugt" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @p1_vec_splat() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "ugt" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 15]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "ugt" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase0() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "ugt" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase1() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, -1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "ugt" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p3_vec_splat_poison() -> vector<3xi1> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.call @gen3x8() : () -> vector<3xi8> + %10 = llvm.and %9, %8 : vector<3xi8> + %11 = llvm.icmp "ugt" %9, %10 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @p3_vec_nonsplat_poison() -> vector<3xi1> { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi8> + %10 = llvm.call @gen3x8() : () -> vector<3xi8> + %11 = llvm.and %10, %9 : vector<3xi8> + %12 = llvm.icmp "ugt" %10, %11 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "ugt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @cv0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "ugt" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @cv1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "ugt" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @cv2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "ugt" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @use8(i8) + llvm.func @oneuse0() -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ugt" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @n0() -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "ugt" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "ugt" %2, %arg1 : i8 + llvm.return %3 : i1 + } + llvm.func @n2() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 16]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "ugt" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ule-to-icmp-ule.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ule-to-icmp-ule.ll.mlir new file mode 100644 index 000000000..e7d71bd04 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ule-to-icmp-ule.ll.mlir @@ -0,0 +1,122 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @gen8() -> i8 + llvm.func @gen2x8() -> vector<2xi8> + llvm.func @gen3x8() -> vector<3xi8> + llvm.func @p0() -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "ule" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @pv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "ule" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @p1_vec_splat() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "ule" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 15]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "ule" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase0() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "ule" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase1() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, -1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "ule" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p3_vec_splat_poison() -> vector<3xi1> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.call @gen3x8() : () -> vector<3xi8> + %10 = llvm.and %9, %8 : vector<3xi8> + %11 = llvm.icmp "ule" %9, %10 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "ule" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @cv0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "ule" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @cv1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "ule" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @cv2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "ule" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @use8(i8) + llvm.func @oneuse0() -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ule" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @n0() -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "ule" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "ule" %2, %arg1 : i8 + llvm.return %3 : i1 + } + llvm.func @n2() -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 16]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @gen2x8() : () -> vector<2xi8> + %2 = llvm.and %1, %0 : vector<2xi8> + %3 = llvm.icmp "ule" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ult-to-icmp-ugt.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ult-to-icmp-ugt.ll.mlir new file mode 100644 index 000000000..f645afbef --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ult-to-icmp-ugt.ll.mlir @@ -0,0 +1,126 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "ult" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @pv(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "ult" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @p1_vec_splat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "ult" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 15]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "ult" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase0(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "ult" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat_edgecase1(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, -1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "ult" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p3_vec_splat_poison(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.and %arg0, %8 : vector<3xi8> + %10 = llvm.icmp "ult" %9, %arg0 : vector<3xi8> + llvm.return %10 : vector<3xi1> + } + llvm.func @p3_vec_nonsplat_poison(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi8> + %10 = llvm.and %arg0, %9 : vector<3xi8> + %11 = llvm.icmp "ult" %10, %arg0 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0() -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "ult" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @cv0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "ult" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @cv1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "ult" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @cv2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "ult" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @use8(i8) + llvm.func @oneuse0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ult" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "ult" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "ult" %1, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @n2(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 16]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "ult" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-fcmp-inf.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-fcmp-inf.ll.mlir new file mode 100644 index 000000000..6c255abb6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-fcmp-inf.ll.mlir @@ -0,0 +1,147 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @olt_pinf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "olt" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @ole_pinf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "ole" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @ogt_pinf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "ogt" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @oge_pinf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "oge" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @ult_pinf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "ult" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @ule_pinf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "ule" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @ugt_pinf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "ugt" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @uge_pinf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "uge" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @olt_ninf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0xFC00 : f16) : f16 + %1 = llvm.fcmp "olt" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @ole_ninf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0xFC00 : f16) : f16 + %1 = llvm.fcmp "ole" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @ogt_ninf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0xFC00 : f16) : f16 + %1 = llvm.fcmp "ogt" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @oge_ninf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0xFC00 : f16) : f16 + %1 = llvm.fcmp "oge" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @ult_ninf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0xFC00 : f16) : f16 + %1 = llvm.fcmp "ult" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @ule_ninf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0xFC00 : f16) : f16 + %1 = llvm.fcmp "ule" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @ugt_ninf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0xFC00 : f16) : f16 + %1 = llvm.fcmp "ugt" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @uge_ninf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0xFC00 : f16) : f16 + %1 = llvm.fcmp "uge" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @olt_pinf_fmf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "olt" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %1 : i1 + } + llvm.func @oge_pinf_fmf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "oge" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %1 : i1 + } + llvm.func @olt_pinf_vec(%arg0: vector<2xf16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<0x7C00> : vector<2xf16>) : vector<2xf16> + %1 = llvm.fcmp "olt" %arg0, %0 : vector<2xf16> + llvm.return %1 : vector<2xi1> + } + llvm.func @oge_ninf_vec(%arg0: vector<2xf16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<0xFC00> : vector<2xf16>) : vector<2xf16> + %1 = llvm.fcmp "oge" %arg0, %0 : vector<2xf16> + llvm.return %1 : vector<2xi1> + } + llvm.func @ord_pinf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @uno_pinf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "uno" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @true_pinf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "_true" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @false_pinf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "_false" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @ord_ninf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0xFC00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @uno_ninf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0xFC00 : f16) : f16 + %1 = llvm.fcmp "uno" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @true_ninf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0xFC00 : f16) : f16 + %1 = llvm.fcmp "_true" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @false_ninf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0xFC00 : f16) : f16 + %1 = llvm.fcmp "_false" %arg0, %0 : f16 + llvm.return %1 : i1 + } + llvm.func @olt_one(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f16) : f16 + %1 = llvm.fcmp "olt" %arg0, %0 : f16 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-gep-mul.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-gep-mul.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/canonicalize-lack-of-signed-truncation-check.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-lack-of-signed-truncation-check.ll.mlir new file mode 100644 index 000000000..f8501b10f --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-lack-of-signed-truncation-check.ll.mlir @@ -0,0 +1,142 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + %2 = llvm.ashr %1, %0 : i8 + %3 = llvm.icmp "eq" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @pb(%arg0: i65) -> i1 { + %0 = llvm.mlir.constant(1 : i65) : i65 + %1 = llvm.shl %arg0, %0 : i65 + %2 = llvm.ashr %1, %0 : i65 + %3 = llvm.icmp "eq" %arg0, %2 : i65 + llvm.return %3 : i1 + } + llvm.func @p1_vec_splat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %arg0, %0 : vector<2xi8> + %2 = llvm.ashr %1, %0 : vector<2xi8> + %3 = llvm.icmp "eq" %2, %arg0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[5, 6]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %arg0, %0 : vector<2xi8> + %2 = llvm.ashr %1, %0 : vector<2xi8> + %3 = llvm.icmp "eq" %2, %arg0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p3_vec_undef0(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<5> : vector<3xi8>) : vector<3xi8> + %10 = llvm.shl %arg0, %8 : vector<3xi8> + %11 = llvm.ashr %10, %9 : vector<3xi8> + %12 = llvm.icmp "eq" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @p4_vec_undef1(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.shl %arg0, %0 : vector<3xi8> + %11 = llvm.ashr %10, %9 : vector<3xi8> + %12 = llvm.icmp "eq" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @p5_vec_undef2(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.shl %arg0, %8 : vector<3xi8> + %10 = llvm.ashr %9, %8 : vector<3xi8> + %11 = llvm.icmp "eq" %10, %arg0 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0() -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.shl %1, %0 : i8 + %3 = llvm.ashr %2, %0 : i8 + %4 = llvm.icmp "eq" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @use8(i8) + llvm.func @n_oneuse0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.ashr %1, %0 : i8 + %3 = llvm.icmp "eq" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n_oneuse1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + %2 = llvm.ashr %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n_oneuse2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.ashr %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.ashr %2, %1 : i8 + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + %2 = llvm.lshr %1, %0 : i8 + %3 = llvm.icmp "eq" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + %2 = llvm.ashr %1, %0 : i8 + %3 = llvm.icmp "eq" %2, %arg1 : i8 + llvm.return %3 : i1 + } + llvm.func @n3_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[5, 3]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.ashr %2, %1 : vector<2xi8> + %4 = llvm.icmp "eq" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-and-icmp-eq-to-icmp-ule.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-and-icmp-eq-to-icmp-ule.ll.mlir new file mode 100644 index 000000000..7458340c0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-and-icmp-eq-to-icmp-ule.ll.mlir @@ -0,0 +1,89 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @p1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.lshr %0, %arg1 : vector<2xi8> + %2 = llvm.and %1, %arg0 : vector<2xi8> + %3 = llvm.icmp "eq" %2, %arg0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_poison(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.lshr %8, %arg1 : vector<3xi8> + %10 = llvm.and %9, %arg0 : vector<3xi8> + %11 = llvm.icmp "eq" %10, %arg0 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg0 : i8 + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "eq" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @c1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg0 : i8 + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "eq" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @c2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg0 : i8 + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "eq" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @use8(i8) + llvm.func @oneuse0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @oneuse1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @oneuse2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.and %1, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n0(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %arg2 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll.mlir new file mode 100644 index 000000000..56188ca37 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll.mlir @@ -0,0 +1,89 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @p1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.lshr %0, %arg1 : vector<2xi8> + %2 = llvm.and %1, %arg0 : vector<2xi8> + %3 = llvm.icmp "ne" %2, %arg0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_poison(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.lshr %8, %arg1 : vector<3xi8> + %10 = llvm.and %9, %arg0 : vector<3xi8> + %11 = llvm.icmp "ne" %10, %arg0 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg0 : i8 + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "ne" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @c1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg0 : i8 + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "ne" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @c2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg0 : i8 + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "ne" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @use8(i8) + llvm.func @oneuse0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @oneuse1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @oneuse2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.and %1, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n0(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.lshr %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %arg2 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v2-and-icmp-eq-to-icmp-ule.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v2-and-icmp-eq-to-icmp-ule.ll.mlir new file mode 100644 index 000000000..2651d9848 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v2-and-icmp-eq-to-icmp-ule.ll.mlir @@ -0,0 +1,181 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @p1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %0, %arg1 : vector<2xi8> + %2 = llvm.xor %1, %0 : vector<2xi8> + %3 = llvm.and %2, %arg0 : vector<2xi8> + %4 = llvm.icmp "eq" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @p2_vec_poison0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %10 = llvm.shl %8, %arg1 : vector<3xi8> + %11 = llvm.xor %10, %9 : vector<3xi8> + %12 = llvm.and %11, %arg0 : vector<3xi8> + %13 = llvm.icmp "eq" %12, %arg0 : vector<3xi8> + llvm.return %13 : vector<3xi1> + } + llvm.func @p3_vec_poison0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.shl %0, %arg1 : vector<3xi8> + %11 = llvm.xor %10, %9 : vector<3xi8> + %12 = llvm.and %11, %arg0 : vector<3xi8> + %13 = llvm.icmp "eq" %12, %arg0 : vector<3xi8> + llvm.return %13 : vector<3xi1> + } + llvm.func @p4_vec_poison2(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.shl %8, %arg1 : vector<3xi8> + %10 = llvm.xor %9, %8 : vector<3xi8> + %11 = llvm.and %10, %arg0 : vector<3xi8> + %12 = llvm.icmp "eq" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.and %3, %2 : i8 + %5 = llvm.icmp "eq" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @c1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.and %2, %3 : i8 + %5 = llvm.icmp "eq" %3, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @c2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.and %3, %2 : i8 + %5 = llvm.icmp "eq" %3, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @use8(i8) + llvm.func @oneuse0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @oneuse1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @oneuse2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @oneuse3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @oneuse4(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @oneuse5(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n0(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %arg2 : i8 + llvm.return %4 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.and %3, %arg0 : i8 + %5 = llvm.icmp "eq" %4, %arg0 : i8 + llvm.return %5 : i1 + } + llvm.func @n2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.and %3, %arg0 : i8 + %5 = llvm.icmp "eq" %4, %arg0 : i8 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v2-and-icmp-ne-to-icmp-ugt.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v2-and-icmp-ne-to-icmp-ugt.ll.mlir new file mode 100644 index 000000000..653e89917 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v2-and-icmp-ne-to-icmp-ugt.ll.mlir @@ -0,0 +1,181 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @p1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %0, %arg1 : vector<2xi8> + %2 = llvm.xor %1, %0 : vector<2xi8> + %3 = llvm.and %2, %arg0 : vector<2xi8> + %4 = llvm.icmp "ne" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @p2_vec_poison0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %10 = llvm.shl %8, %arg1 : vector<3xi8> + %11 = llvm.xor %10, %9 : vector<3xi8> + %12 = llvm.and %11, %arg0 : vector<3xi8> + %13 = llvm.icmp "ne" %12, %arg0 : vector<3xi8> + llvm.return %13 : vector<3xi1> + } + llvm.func @p3_vec_poison0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.shl %0, %arg1 : vector<3xi8> + %11 = llvm.xor %10, %9 : vector<3xi8> + %12 = llvm.and %11, %arg0 : vector<3xi8> + %13 = llvm.icmp "ne" %12, %arg0 : vector<3xi8> + llvm.return %13 : vector<3xi1> + } + llvm.func @p4_vec_poison2(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.shl %8, %arg1 : vector<3xi8> + %10 = llvm.xor %9, %8 : vector<3xi8> + %11 = llvm.and %10, %arg0 : vector<3xi8> + %12 = llvm.icmp "ne" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.and %3, %2 : i8 + %5 = llvm.icmp "ne" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @c1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.and %2, %3 : i8 + %5 = llvm.icmp "ne" %3, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @c2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.and %3, %2 : i8 + %5 = llvm.icmp "ne" %3, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @use8(i8) + llvm.func @oneuse0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @oneuse1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @oneuse2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @oneuse3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @oneuse4(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @oneuse5(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n0(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "ne" %3, %arg2 : i8 + llvm.return %4 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.and %3, %arg0 : i8 + %5 = llvm.icmp "ne" %4, %arg0 : i8 + llvm.return %5 : i1 + } + llvm.func @n2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.and %3, %arg0 : i8 + %5 = llvm.icmp "ne" %4, %arg0 : i8 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v3-and-icmp-eq-to-icmp-ule.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v3-and-icmp-eq-to-icmp-ule.ll.mlir new file mode 100644 index 000000000..ff7f2c1bb --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v3-and-icmp-eq-to-icmp-ule.ll.mlir @@ -0,0 +1,182 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use2i8(vector<2xi8>) + llvm.func @use3i8(vector<3xi8>) + llvm.func @p0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.and %3, %arg0 : i8 + %5 = llvm.icmp "eq" %4, %arg0 : i8 + llvm.return %5 : i1 + } + llvm.func @p1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg1 : vector<2xi8> + llvm.call @use2i8(%2) : (vector<2xi8>) -> () + %3 = llvm.add %2, %1 : vector<2xi8> + %4 = llvm.and %3, %arg0 : vector<2xi8> + %5 = llvm.icmp "eq" %4, %arg0 : vector<2xi8> + llvm.return %5 : vector<2xi1> + } + llvm.func @p2_vec_poison0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %10 = llvm.shl %8, %arg1 : vector<3xi8> + llvm.call @use3i8(%10) : (vector<3xi8>) -> () + %11 = llvm.add %10, %9 : vector<3xi8> + %12 = llvm.and %11, %arg0 : vector<3xi8> + %13 = llvm.icmp "eq" %12, %arg0 : vector<3xi8> + llvm.return %13 : vector<3xi1> + } + llvm.func @p3_vec_poison0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.shl %0, %arg1 : vector<3xi8> + llvm.call @use3i8(%10) : (vector<3xi8>) -> () + %11 = llvm.add %10, %9 : vector<3xi8> + %12 = llvm.and %11, %arg0 : vector<3xi8> + %13 = llvm.icmp "eq" %12, %arg0 : vector<3xi8> + llvm.return %13 : vector<3xi1> + } + llvm.func @p4_vec_poiso2(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(-1 : i8) : i8 + %10 = llvm.mlir.undef : vector<3xi8> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi8> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi8> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi8> + %17 = llvm.shl %8, %arg1 : vector<3xi8> + llvm.call @use3i8(%17) : (vector<3xi8>) -> () + %18 = llvm.add %17, %16 : vector<3xi8> + %19 = llvm.and %18, %arg0 : vector<3xi8> + %20 = llvm.icmp "eq" %19, %arg0 : vector<3xi8> + llvm.return %20 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.call @gen8() : () -> i8 + %5 = llvm.and %4, %3 : i8 + %6 = llvm.icmp "eq" %5, %4 : i8 + llvm.return %6 : i1 + } + llvm.func @c1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.call @gen8() : () -> i8 + %5 = llvm.and %3, %4 : i8 + %6 = llvm.icmp "eq" %4, %5 : i8 + llvm.return %6 : i1 + } + llvm.func @c2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.call @gen8() : () -> i8 + %5 = llvm.and %4, %3 : i8 + %6 = llvm.icmp "eq" %4, %5 : i8 + llvm.return %6 : i1 + } + llvm.func @oneuse0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.and %3, %arg0 : i8 + %5 = llvm.icmp "eq" %4, %arg0 : i8 + llvm.return %5 : i1 + } + llvm.func @oneuse1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.and %3, %arg0 : i8 + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.icmp "eq" %4, %arg0 : i8 + llvm.return %5 : i1 + } + llvm.func @oneuse2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.and %3, %arg0 : i8 + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.icmp "eq" %4, %arg0 : i8 + llvm.return %5 : i1 + } + llvm.func @n0(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.and %3, %arg0 : i8 + %5 = llvm.icmp "eq" %4, %arg2 : i8 + llvm.return %5 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.add %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.add %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v3-and-icmp-ne-to-icmp-ugt.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v3-and-icmp-ne-to-icmp-ugt.ll.mlir new file mode 100644 index 000000000..48de20af8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v3-and-icmp-ne-to-icmp-ugt.ll.mlir @@ -0,0 +1,182 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use2i8(vector<2xi8>) + llvm.func @use3i8(vector<3xi8>) + llvm.func @p0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.and %3, %arg0 : i8 + %5 = llvm.icmp "ne" %4, %arg0 : i8 + llvm.return %5 : i1 + } + llvm.func @p1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg1 : vector<2xi8> + llvm.call @use2i8(%2) : (vector<2xi8>) -> () + %3 = llvm.add %2, %1 : vector<2xi8> + %4 = llvm.and %3, %arg0 : vector<2xi8> + %5 = llvm.icmp "ne" %4, %arg0 : vector<2xi8> + llvm.return %5 : vector<2xi1> + } + llvm.func @p2_vec_poison0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %10 = llvm.shl %8, %arg1 : vector<3xi8> + llvm.call @use3i8(%10) : (vector<3xi8>) -> () + %11 = llvm.add %10, %9 : vector<3xi8> + %12 = llvm.and %11, %arg0 : vector<3xi8> + %13 = llvm.icmp "ne" %12, %arg0 : vector<3xi8> + llvm.return %13 : vector<3xi1> + } + llvm.func @p3_vec_poison0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.shl %0, %arg1 : vector<3xi8> + llvm.call @use3i8(%10) : (vector<3xi8>) -> () + %11 = llvm.add %10, %9 : vector<3xi8> + %12 = llvm.and %11, %arg0 : vector<3xi8> + %13 = llvm.icmp "ne" %12, %arg0 : vector<3xi8> + llvm.return %13 : vector<3xi1> + } + llvm.func @p4_vec_poison2(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(-1 : i8) : i8 + %10 = llvm.mlir.undef : vector<3xi8> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi8> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi8> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi8> + %17 = llvm.shl %8, %arg1 : vector<3xi8> + llvm.call @use3i8(%17) : (vector<3xi8>) -> () + %18 = llvm.add %17, %16 : vector<3xi8> + %19 = llvm.and %18, %arg0 : vector<3xi8> + %20 = llvm.icmp "ne" %19, %arg0 : vector<3xi8> + llvm.return %20 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.call @gen8() : () -> i8 + %5 = llvm.and %4, %3 : i8 + %6 = llvm.icmp "ne" %5, %4 : i8 + llvm.return %6 : i1 + } + llvm.func @c1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.call @gen8() : () -> i8 + %5 = llvm.and %3, %4 : i8 + %6 = llvm.icmp "ne" %4, %5 : i8 + llvm.return %6 : i1 + } + llvm.func @c2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.call @gen8() : () -> i8 + %5 = llvm.and %4, %3 : i8 + %6 = llvm.icmp "ne" %4, %5 : i8 + llvm.return %6 : i1 + } + llvm.func @oneuse0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.and %3, %arg0 : i8 + %5 = llvm.icmp "ne" %4, %arg0 : i8 + llvm.return %5 : i1 + } + llvm.func @oneuse1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.and %3, %arg0 : i8 + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.icmp "ne" %4, %arg0 : i8 + llvm.return %5 : i1 + } + llvm.func @oneuse2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.and %3, %arg0 : i8 + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.icmp "ne" %4, %arg0 : i8 + llvm.return %5 : i1 + } + llvm.func @n0(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.and %3, %arg0 : i8 + %5 = llvm.icmp "ne" %4, %arg2 : i8 + llvm.return %5 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.add %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.add %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v4-and-icmp-eq-to-icmp-ule.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v4-and-icmp-eq-to-icmp-ule.ll.mlir new file mode 100644 index 000000000..baa90d79c --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v4-and-icmp-eq-to-icmp-ule.ll.mlir @@ -0,0 +1,129 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use2i8(vector<2xi8>) + llvm.func @use3i8(vector<3xi8>) + llvm.func @p0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg1 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @p1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %0, %arg1 : vector<2xi8> + llvm.call @use2i8(%1) : (vector<2xi8>) -> () + %2 = llvm.lshr %1, %arg1 : vector<2xi8> + %3 = llvm.and %2, %arg0 : vector<2xi8> + %4 = llvm.icmp "eq" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @p2_vec_poison0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.shl %8, %arg1 : vector<3xi8> + llvm.call @use3i8(%9) : (vector<3xi8>) -> () + %10 = llvm.lshr %9, %arg1 : vector<3xi8> + %11 = llvm.and %10, %arg0 : vector<3xi8> + %12 = llvm.icmp "eq" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.and %3, %2 : i8 + %5 = llvm.icmp "eq" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @c1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.and %2, %3 : i8 + %5 = llvm.icmp "eq" %3, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @c2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.and %3, %2 : i8 + %5 = llvm.icmp "eq" %3, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @oneuse0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @oneuse1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg1 : i8 + %3 = llvm.and %2, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @oneuse2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n0(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg1 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %arg2 : i8 + llvm.return %4 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg1 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg2 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v4-and-icmp-ne-to-icmp-ugt.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v4-and-icmp-ne-to-icmp-ugt.ll.mlir new file mode 100644 index 000000000..f4718c3cd --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-low-bit-mask-v4-and-icmp-ne-to-icmp-ugt.ll.mlir @@ -0,0 +1,129 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use2i8(vector<2xi8>) + llvm.func @use3i8(vector<3xi8>) + llvm.func @p0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg1 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @p1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %0, %arg1 : vector<2xi8> + llvm.call @use2i8(%1) : (vector<2xi8>) -> () + %2 = llvm.lshr %1, %arg1 : vector<2xi8> + %3 = llvm.and %2, %arg0 : vector<2xi8> + %4 = llvm.icmp "ne" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @p2_vec_poison0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.shl %8, %arg1 : vector<3xi8> + llvm.call @use3i8(%9) : (vector<3xi8>) -> () + %10 = llvm.lshr %9, %arg1 : vector<3xi8> + %11 = llvm.and %10, %arg0 : vector<3xi8> + %12 = llvm.icmp "ne" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.and %3, %2 : i8 + %5 = llvm.icmp "ne" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @c1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.and %2, %3 : i8 + %5 = llvm.icmp "ne" %3, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @c2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.and %3, %2 : i8 + %5 = llvm.icmp "ne" %3, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @oneuse0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @oneuse1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg1 : i8 + %3 = llvm.and %2, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @oneuse2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n0(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg1 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "ne" %3, %arg2 : i8 + llvm.return %4 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg1 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.lshr %1, %arg2 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-lshr-shl-to-masking.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-lshr-shl-to-masking.ll.mlir new file mode 100644 index 000000000..c8238257d --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-lshr-shl-to-masking.ll.mlir @@ -0,0 +1,424 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @positive_samevar(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerlshr(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_shlnuw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst_shlnuw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerlshr_shlnuw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_shlnuw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_shlnsw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst_shlnsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerlshr_shlnsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_shlnsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_shlnuwnsw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst_shlnuwnsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerlshr_shlnuwnsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_shlnuwnsw(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_lshrexact(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst_lshrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerlshr_lshrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_lshrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_shlnsw_lshrexact(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst_shlnsw_lshrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerlshr_shlnsw_lshrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_shlnsw_lshrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_shlnuw_lshrexact(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst_shlnuw_lshrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerlshr_shlnuw_lshrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_shlnuw_lshrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_shlnuwnsw_lshrexact(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @positive_sameconst_shlnuwnsw_lshrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.shl %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerlshr_shlnuwnsw_lshrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_shlnuwnsw_lshrexact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.shl %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @positive_samevar_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.lshr %arg0, %arg1 : vector<2xi8> + %1 = llvm.shl %0, %arg1 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @positive_sameconst_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.lshr %arg0, %0 : vector<2xi8> + %2 = llvm.shl %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @positive_sameconst_vec_undef0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<3> : vector<3xi8>) : vector<3xi8> + %10 = llvm.lshr %arg0, %8 : vector<3xi8> + %11 = llvm.shl %10, %9 : vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @positive_sameconst_vec_undef1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.lshr %arg0, %0 : vector<3xi8> + %11 = llvm.shl %10, %9 : vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @positive_sameconst_vec_undef2(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.lshr %arg0, %8 : vector<3xi8> + %10 = llvm.shl %9, %8 : vector<3xi8> + llvm.return %10 : vector<3xi8> + } + llvm.func @positive_biggerlshr_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %arg0, %0 : vector<2xi8> + %3 = llvm.shl %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @positive_biggerlshr_vec_undef0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<3> : vector<3xi8>) : vector<3xi8> + %10 = llvm.lshr %arg0, %8 : vector<3xi8> + %11 = llvm.shl %10, %9 : vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @positive_biggerlshr_vec_undef1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<6> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.lshr %arg0, %0 : vector<3xi8> + %11 = llvm.shl %10, %9 : vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @positive_biggerlshr_vec_undef2(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(3 : i8) : i8 + %10 = llvm.mlir.undef : vector<3xi8> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi8> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi8> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi8> + %17 = llvm.lshr %arg0, %8 : vector<3xi8> + %18 = llvm.shl %17, %16 : vector<3xi8> + llvm.return %18 : vector<3xi8> + } + llvm.func @positive_biggershl_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %arg0, %0 : vector<2xi8> + %3 = llvm.shl %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @positive_biggershl_vec_undef0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<6> : vector<3xi8>) : vector<3xi8> + %10 = llvm.lshr %arg0, %8 : vector<3xi8> + %11 = llvm.shl %10, %9 : vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @positive_biggershl_vec_undef1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.lshr %arg0, %0 : vector<3xi8> + %11 = llvm.shl %10, %9 : vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @positive_biggershl_vec_undef2(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(6 : i8) : i8 + %10 = llvm.mlir.undef : vector<3xi8> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi8> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi8> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi8> + %17 = llvm.lshr %arg0, %8 : vector<3xi8> + %18 = llvm.shl %17, %16 : vector<3xi8> + llvm.return %18 : vector<3xi8> + } + llvm.func @positive_sameconst_multiuse(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + llvm.call @use32(%1) : (i8) -> () + %2 = llvm.shl %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @positive_biggerlshr_multiuse(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + llvm.call @use32(%2) : (i8) -> () + %3 = llvm.shl %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggershl_multiuse(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + llvm.call @use32(%2) : (i8) -> () + %3 = llvm.shl %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @positive_biggerlshr_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[3, 6]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %arg0, %0 : vector<2xi8> + %3 = llvm.shl %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @positive_biggerLlshr_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[3, 6]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %arg0, %0 : vector<2xi8> + %3 = llvm.shl %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @negative_twovars(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg1 : i8 + %1 = llvm.shl %0, %arg2 : i8 + llvm.return %1 : i8 + } + llvm.func @use32(i8) + llvm.func @negative_oneuse(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.lshr %arg0, %arg1 : i8 + llvm.call @use32(%0) : (i8) -> () + %1 = llvm.shl %0, %arg1 : i8 + llvm.return %1 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-or-with-overflow-icmp.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-or-with-overflow-icmp.ll.mlir new file mode 100644 index 000000000..971f0944a --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-or-with-overflow-icmp.ll.mlir @@ -0,0 +1,165 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i1) + llvm.func @ckd_add_unsigned(%arg0: i31) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.zext %arg0 : i31 to i32 + %3 = "llvm.intr.sadd.with.overflow"(%2, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i32, i1)> + %6 = llvm.icmp "slt" %5, %1 : i32 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @ckd_add_unsigned_commuted(%arg0: i31) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.zext %arg0 : i31 to i32 + %3 = "llvm.intr.sadd.with.overflow"(%2, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i32, i1)> + %6 = llvm.icmp "slt" %5, %1 : i32 + %7 = llvm.or %6, %4 : i1 + llvm.return %7 : i1 + } + llvm.func @ckd_add_unsigned_imply_true(%arg0: i31) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.zext %arg0 : i31 to i32 + %3 = "llvm.intr.sadd.with.overflow"(%2, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i32, i1)> + %6 = llvm.icmp "sgt" %5, %1 : i32 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @canonicalize_or_sadd_with_overflow_icmp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = "llvm.intr.sadd.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @canonicalize_or_ssub_with_overflow_icmp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = "llvm.intr.ssub.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @canonicalize_or_uadd_with_overflow_icmp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %5 = llvm.icmp "ult" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @canonicalize_or_sadd_with_overflow_icmp_eq(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = "llvm.intr.sadd.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @canonicalize_or_uadd_with_overflow_icmp_ne(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @canonicalize_or_sadd_with_overflow_icmp_mismatched_pred(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = "llvm.intr.sadd.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %5 = llvm.icmp "ult" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @canonicalize_or_sadd_with_overflow_icmp_non_constant1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i32, i1)> + %4 = llvm.icmp "slt" %3, %0 : i32 + %5 = llvm.or %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @canonicalize_or_sadd_with_overflow_icmp_non_constant2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = "llvm.intr.sadd.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i32, i1)> + %4 = llvm.icmp "slt" %3, %arg1 : i32 + %5 = llvm.or %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @canonicalize_or_sadd_with_overflow_icmp_multiuse(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = "llvm.intr.sadd.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %5 = llvm.icmp "slt" %4, %1 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @canonicalize_or_sadd_with_overflow_icmp_overflow(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483647 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = "llvm.intr.sadd.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @canonicalize_or_uadd_with_overflow_icmp_overflow(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %5 = llvm.icmp "ult" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @canonicalize_or_ssub_with_overflow_icmp_overflow(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = "llvm.intr.ssub.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @canonicalize_or_smul_with_overflow_icmp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %5 = llvm.icmp "slt" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-selects-icmp-condition-bittest.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-selects-icmp-condition-bittest.ll.mlir new file mode 100644 index 000000000..0fb0230d3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-selects-icmp-condition-bittest.ll.mlir @@ -0,0 +1,81 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use1(i1) + llvm.func @p0(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + %3 = llvm.select %2, %arg1, %arg2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @p1(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + %4 = llvm.select %3, %arg1, %arg2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @n2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.select %2, %arg1, %arg2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @t3(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: !llvm.ptr, %arg6: i1) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.cond_br %arg6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.select %2, %arg1, %arg2 : i1, i8 + llvm.store %3, %arg5 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + %4 = llvm.select %2, %arg3, %arg4 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @t4(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + %4 = llvm.select %3, %arg1, %arg2 : i1, i8 + llvm.store %4, %arg5 {alignment = 1 : i64} : i8, !llvm.ptr + %5 = llvm.select %3, %arg3, %arg4 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @n5(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + %4 = llvm.select %3, %arg1, %arg2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @n6(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + %4 = llvm.select %3, %arg1, %arg2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @n7(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + %3 = llvm.select %2, %arg1, %arg2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @n8(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + %4 = llvm.select %3, %arg1, %arg2 : i1, i8 + llvm.return %4 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-shl-lshr-to-masking.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-shl-lshr-to-masking.ll.mlir new file mode 100644 index 000000000..4846390ea --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-shl-lshr-to-masking.ll.mlir @@ -0,0 +1,304 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @positive_samevar(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.lshr %0, %arg1 : i32 + llvm.return %1 : i32 + } + llvm.func @positive_sameconst(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.shl %arg0, %0 : i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @positive_biggerShl(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @positive_biggerLshr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @positive_biggerLshr_lshrexact(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @positive_samevar_shlnuw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.lshr %0, %arg1 : i32 + llvm.return %1 : i32 + } + llvm.func @positive_sameconst_shlnuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.shl %arg0, %0 overflow : i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @positive_biggerShl_shlnuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.shl %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @positive_biggerLshr_shlnuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.shl %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @positive_biggerLshr_shlnuw_lshrexact(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.shl %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @positive_samevar_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.shl %arg0, %arg1 : vector<2xi32> + %1 = llvm.lshr %0, %arg1 : vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @positive_sameconst_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %1 = llvm.shl %arg0, %0 : vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @positive_sameconst_vec_undef0(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(dense<5> : vector<3xi32>) : vector<3xi32> + %10 = llvm.shl %arg0, %8 : vector<3xi32> + %11 = llvm.lshr %10, %9 : vector<3xi32> + llvm.return %11 : vector<3xi32> + } + llvm.func @positive_sameconst_vec_undef1(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<5> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.undef : i32 + %3 = llvm.mlir.undef : vector<3xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi32> + %10 = llvm.shl %arg0, %0 : vector<3xi32> + %11 = llvm.lshr %10, %9 : vector<3xi32> + llvm.return %11 : vector<3xi32> + } + llvm.func @positive_sameconst_vec_undef2(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.shl %arg0, %8 : vector<3xi32> + %10 = llvm.lshr %9, %8 : vector<3xi32> + llvm.return %10 : vector<3xi32> + } + llvm.func @positive_biggerShl_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %2 = llvm.shl %arg0, %0 : vector<2xi32> + %3 = llvm.lshr %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @positive_biggerShl_vec_undef0(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(dense<5> : vector<3xi32>) : vector<3xi32> + %10 = llvm.shl %arg0, %8 : vector<3xi32> + %11 = llvm.lshr %10, %9 : vector<3xi32> + llvm.return %11 : vector<3xi32> + } + llvm.func @positive_biggerShl_vec_undef1(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<10> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.undef : i32 + %3 = llvm.mlir.undef : vector<3xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi32> + %10 = llvm.shl %arg0, %0 : vector<3xi32> + %11 = llvm.lshr %10, %9 : vector<3xi32> + llvm.return %11 : vector<3xi32> + } + llvm.func @positive_biggerShl_vec_undef2(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(5 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.shl %arg0, %8 : vector<3xi32> + %18 = llvm.lshr %17, %16 : vector<3xi32> + llvm.return %18 : vector<3xi32> + } + llvm.func @positive_biggerLshr_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.shl %arg0, %0 : vector<2xi32> + %3 = llvm.lshr %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @positive_biggerLshr_vec_undef0(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(dense<10> : vector<3xi32>) : vector<3xi32> + %10 = llvm.shl %arg0, %8 : vector<3xi32> + %11 = llvm.lshr %10, %9 : vector<3xi32> + llvm.return %11 : vector<3xi32> + } + llvm.func @positive_biggerLshr_vec_undef1(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<5> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.undef : i32 + %3 = llvm.mlir.undef : vector<3xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi32> + %10 = llvm.shl %arg0, %0 : vector<3xi32> + %11 = llvm.lshr %10, %9 : vector<3xi32> + llvm.return %11 : vector<3xi32> + } + llvm.func @positive_biggerLshr_vec_undef2(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(10 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.shl %arg0, %8 : vector<3xi32> + %18 = llvm.lshr %17, %16 : vector<3xi32> + llvm.return %18 : vector<3xi32> + } + llvm.func @positive_sameconst_multiuse(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.shl %arg0, %0 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @positive_biggerShl_shlnuw_multiuse(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.shl %arg0, %0 overflow : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @positive_biggerLshr_shlnuw_multiuse(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.shl %arg0, %0 overflow : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @positive_biggerShl_multiuse_extrainstr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @positive_biggerLshr_multiuse_extrainstr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @positive_biggerShl_vec_nonsplat(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[5, 10]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.shl %arg0, %0 : vector<2xi32> + %3 = llvm.lshr %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @positive_biggerLshl_vec_nonsplat(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[5, 10]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %2 = llvm.shl %arg0, %0 : vector<2xi32> + %3 = llvm.lshr %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @negative_twovars(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.lshr %0, %arg2 : i32 + llvm.return %1 : i32 + } + llvm.func @use32(i32) + llvm.func @negative_oneuse(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + llvm.call @use32(%0) : (i32) -> () + %1 = llvm.lshr %0, %arg1 : i32 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-signed-truncation-check.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-signed-truncation-check.ll.mlir new file mode 100644 index 000000000..21e306492 --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize-signed-truncation-check.ll.mlir @@ -0,0 +1,142 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + %2 = llvm.ashr %1, %0 : i8 + %3 = llvm.icmp "ne" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @pb(%arg0: i65) -> i1 { + %0 = llvm.mlir.constant(1 : i65) : i65 + %1 = llvm.shl %arg0, %0 : i65 + %2 = llvm.ashr %1, %0 : i65 + %3 = llvm.icmp "ne" %arg0, %2 : i65 + llvm.return %3 : i1 + } + llvm.func @p1_vec_splat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %arg0, %0 : vector<2xi8> + %2 = llvm.ashr %1, %0 : vector<2xi8> + %3 = llvm.icmp "ne" %2, %arg0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[5, 6]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %arg0, %0 : vector<2xi8> + %2 = llvm.ashr %1, %0 : vector<2xi8> + %3 = llvm.icmp "ne" %2, %arg0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p3_vec_undef0(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<5> : vector<3xi8>) : vector<3xi8> + %10 = llvm.shl %arg0, %8 : vector<3xi8> + %11 = llvm.ashr %10, %9 : vector<3xi8> + %12 = llvm.icmp "ne" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @p4_vec_undef1(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.shl %arg0, %0 : vector<3xi8> + %11 = llvm.ashr %10, %9 : vector<3xi8> + %12 = llvm.icmp "ne" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @p5_vec_undef2(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.shl %arg0, %8 : vector<3xi8> + %10 = llvm.ashr %9, %8 : vector<3xi8> + %11 = llvm.icmp "ne" %10, %arg0 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0() -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.shl %1, %0 : i8 + %3 = llvm.ashr %2, %0 : i8 + %4 = llvm.icmp "ne" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @use8(i8) + llvm.func @n_oneuse0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.ashr %1, %0 : i8 + %3 = llvm.icmp "ne" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n_oneuse1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + %2 = llvm.ashr %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n_oneuse2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.ashr %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.ashr %2, %1 : i8 + %4 = llvm.icmp "ne" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + %2 = llvm.lshr %1, %0 : i8 + %3 = llvm.icmp "ne" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + %2 = llvm.ashr %1, %0 : i8 + %3 = llvm.icmp "ne" %2, %arg1 : i8 + llvm.return %3 : i1 + } + llvm.func @n3_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[5, 3]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.ashr %2, %1 : vector<2xi8> + %4 = llvm.icmp "ne" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-vector-extract.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-vector-extract.ll.mlir index 51fdca1ca..c91cec82a 100644 --- a/test/LLVMDialect/InstCombine/canonicalize-vector-extract.ll.mlir +++ b/test/LLVMDialect/InstCombine/canonicalize-vector-extract.ll.mlir @@ -1,75 +1,46 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.extract.v10i32.v8i32", type = !llvm.func (vector<8xi32>, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.extract.v2i32.v4i32", type = !llvm.func (vector<8xi32>, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.extract.v3i32.v8i32", type = !llvm.func (vector<8xi32>, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.extract.v4i32.nxv4i32", type = !llvm.func (vec, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.extract.v4i32.v8i32", type = !llvm.func (vector<8xi32>, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.extract.v8i32.v8i32", type = !llvm.func (vector<8xi32>, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.vector.extract.v8i32.v8i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, i64) -> vector<8xi32> - "llvm.return"(%1) : (vector<8xi32>) -> () - }) {linkage = 10 : i64, sym_name = "trivial_nop", type = !llvm.func (vector<8xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.vector.extract.v2i32.v4i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, i64) -> vector<2xi32> - "llvm.return"(%1) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_extraction_a", type = !llvm.func (vector<8xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.vector.extract.v2i32.v4i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, i64) -> vector<2xi32> - "llvm.return"(%1) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_extraction_b", type = !llvm.func (vector<8xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.vector.extract.v2i32.v4i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, i64) -> vector<2xi32> - "llvm.return"(%1) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_extraction_c", type = !llvm.func (vector<8xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.vector.extract.v2i32.v4i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, i64) -> vector<2xi32> - "llvm.return"(%1) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_extraction_d", type = !llvm.func (vector<8xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.vector.extract.v4i32.v8i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, i64) -> vector<4xi32> - "llvm.return"(%1) : (vector<4xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_extraction_e", type = !llvm.func (vector<8xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.vector.extract.v4i32.v8i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, i64) -> vector<4xi32> - "llvm.return"(%1) : (vector<4xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_extraction_f", type = !llvm.func (vector<8xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.vector.extract.v3i32.v8i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, i64) -> vector<3xi32> - "llvm.return"(%1) : (vector<3xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_extraction_g", type = !llvm.func (vector<8xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.vector.extract.v3i32.v8i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, i64) -> vector<3xi32> - "llvm.return"(%1) : (vector<3xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_extraction_h", type = !llvm.func (vector<8xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.vector.extract.v4i32.nxv4i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec, i64) -> vector<4xi32> - "llvm.return"(%1) : (vector<4xi32>) -> () - }) {linkage = 10 : i64, sym_name = "scalable_extract", type = !llvm.func (vec)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @trivial_nop(%arg0: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.intr.vector.extract %arg0[0] : vector<8xi32> from vector<8xi32> + llvm.return %0 : vector<8xi32> + } + llvm.func @trivial_nop_scalable(%arg0: !llvm.vec) -> !llvm.vec { + %0 = llvm.intr.vector.extract %arg0[0] : !llvm.vec from !llvm.vec + llvm.return %0 : !llvm.vec + } + llvm.func @valid_extraction_a(%arg0: vector<8xi32>) -> vector<2xi32> { + %0 = llvm.intr.vector.extract %arg0[0] : vector<2xi32> from vector<8xi32> + llvm.return %0 : vector<2xi32> + } + llvm.func @valid_extraction_b(%arg0: vector<8xi32>) -> vector<2xi32> { + %0 = llvm.intr.vector.extract %arg0[2] : vector<2xi32> from vector<8xi32> + llvm.return %0 : vector<2xi32> + } + llvm.func @valid_extraction_c(%arg0: vector<8xi32>) -> vector<2xi32> { + %0 = llvm.intr.vector.extract %arg0[4] : vector<2xi32> from vector<8xi32> + llvm.return %0 : vector<2xi32> + } + llvm.func @valid_extraction_d(%arg0: vector<8xi32>) -> vector<2xi32> { + %0 = llvm.intr.vector.extract %arg0[6] : vector<2xi32> from vector<8xi32> + llvm.return %0 : vector<2xi32> + } + llvm.func @valid_extraction_e(%arg0: vector<8xi32>) -> vector<4xi32> { + %0 = llvm.intr.vector.extract %arg0[0] : vector<4xi32> from vector<8xi32> + llvm.return %0 : vector<4xi32> + } + llvm.func @valid_extraction_f(%arg0: vector<8xi32>) -> vector<4xi32> { + %0 = llvm.intr.vector.extract %arg0[4] : vector<4xi32> from vector<8xi32> + llvm.return %0 : vector<4xi32> + } + llvm.func @valid_extraction_g(%arg0: vector<8xi32>) -> vector<3xi32> { + %0 = llvm.intr.vector.extract %arg0[0] : vector<3xi32> from vector<8xi32> + llvm.return %0 : vector<3xi32> + } + llvm.func @valid_extraction_h(%arg0: vector<8xi32>) -> vector<3xi32> { + %0 = llvm.intr.vector.extract %arg0[3] : vector<3xi32> from vector<8xi32> + llvm.return %0 : vector<3xi32> + } + llvm.func @scalable_extract(%arg0: !llvm.vec) -> vector<4xi32> { + %0 = llvm.intr.vector.extract %arg0[0] : vector<4xi32> from !llvm.vec + llvm.return %0 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize-vector-insert.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize-vector-insert.ll.mlir index 65bfd0b3a..e6ca01bbe 100644 --- a/test/LLVMDialect/InstCombine/canonicalize-vector-insert.ll.mlir +++ b/test/LLVMDialect/InstCombine/canonicalize-vector-insert.ll.mlir @@ -1,73 +1,42 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.insert.v8i32.v2i32", type = !llvm.func (vector<8xi32>, vector<2xi32>, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.insert.v8i32.v3i32", type = !llvm.func (vector<8xi32>, vector<3xi32>, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.insert.v8i32.v4i32", type = !llvm.func (vector<8xi32>, vector<4xi32>, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.insert.v8i32.v8i32", type = !llvm.func (vector<8xi32>, vector<8xi32>, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.insert.nxv4i32.v4i32", type = !llvm.func (vec, vector<4xi32>, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>, %arg1: vector<8xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.vector.insert.v8i32.v8i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, vector<8xi32>, i64) -> vector<8xi32> - "llvm.return"(%1) : (vector<8xi32>) -> () - }) {linkage = 10 : i64, sym_name = "trivial_nop", type = !llvm.func (vector<8xi32>, vector<8xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.vector.insert.v8i32.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, vector<2xi32>, i64) -> vector<8xi32> - "llvm.return"(%1) : (vector<8xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_insertion_a", type = !llvm.func (vector<8xi32>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.vector.insert.v8i32.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, vector<2xi32>, i64) -> vector<8xi32> - "llvm.return"(%1) : (vector<8xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_insertion_b", type = !llvm.func (vector<8xi32>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.vector.insert.v8i32.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, vector<2xi32>, i64) -> vector<8xi32> - "llvm.return"(%1) : (vector<8xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_insertion_c", type = !llvm.func (vector<8xi32>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.vector.insert.v8i32.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, vector<2xi32>, i64) -> vector<8xi32> - "llvm.return"(%1) : (vector<8xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_insertion_d", type = !llvm.func (vector<8xi32>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>, %arg1: vector<4xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.vector.insert.v8i32.v4i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, vector<4xi32>, i64) -> vector<8xi32> - "llvm.return"(%1) : (vector<8xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_insertion_e", type = !llvm.func (vector<8xi32>, vector<4xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>, %arg1: vector<4xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.vector.insert.v8i32.v4i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, vector<4xi32>, i64) -> vector<8xi32> - "llvm.return"(%1) : (vector<8xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_insertion_f", type = !llvm.func (vector<8xi32>, vector<4xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>, %arg1: vector<3xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.vector.insert.v8i32.v3i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, vector<3xi32>, i64) -> vector<8xi32> - "llvm.return"(%1) : (vector<8xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_insertion_g", type = !llvm.func (vector<8xi32>, vector<3xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>, %arg1: vector<3xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.vector.insert.v8i32.v3i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>, vector<3xi32>, i64) -> vector<8xi32> - "llvm.return"(%1) : (vector<8xi32>) -> () - }) {linkage = 10 : i64, sym_name = "valid_insertion_h", type = !llvm.func (vector<8xi32>, vector<3xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec, %arg1: vector<4xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.vector.insert.nxv4i32.v4i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec, vector<4xi32>, i64) -> !llvm.vec - "llvm.return"(%1) : (!llvm.vec) -> () - }) {linkage = 10 : i64, sym_name = "scalable_insert", type = !llvm.func (vec, vector<4xi32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @trivial_nop(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.intr.vector.insert %arg1, %arg0[0] : vector<8xi32> into vector<8xi32> + llvm.return %0 : vector<8xi32> + } + llvm.func @valid_insertion_a(%arg0: vector<8xi32>, %arg1: vector<2xi32>) -> vector<8xi32> { + %0 = llvm.intr.vector.insert %arg1, %arg0[0] : vector<2xi32> into vector<8xi32> + llvm.return %0 : vector<8xi32> + } + llvm.func @valid_insertion_b(%arg0: vector<8xi32>, %arg1: vector<2xi32>) -> vector<8xi32> { + %0 = llvm.intr.vector.insert %arg1, %arg0[2] : vector<2xi32> into vector<8xi32> + llvm.return %0 : vector<8xi32> + } + llvm.func @valid_insertion_c(%arg0: vector<8xi32>, %arg1: vector<2xi32>) -> vector<8xi32> { + %0 = llvm.intr.vector.insert %arg1, %arg0[4] : vector<2xi32> into vector<8xi32> + llvm.return %0 : vector<8xi32> + } + llvm.func @valid_insertion_d(%arg0: vector<8xi32>, %arg1: vector<2xi32>) -> vector<8xi32> { + %0 = llvm.intr.vector.insert %arg1, %arg0[6] : vector<2xi32> into vector<8xi32> + llvm.return %0 : vector<8xi32> + } + llvm.func @valid_insertion_e(%arg0: vector<8xi32>, %arg1: vector<4xi32>) -> vector<8xi32> { + %0 = llvm.intr.vector.insert %arg1, %arg0[0] : vector<4xi32> into vector<8xi32> + llvm.return %0 : vector<8xi32> + } + llvm.func @valid_insertion_f(%arg0: vector<8xi32>, %arg1: vector<4xi32>) -> vector<8xi32> { + %0 = llvm.intr.vector.insert %arg1, %arg0[4] : vector<4xi32> into vector<8xi32> + llvm.return %0 : vector<8xi32> + } + llvm.func @valid_insertion_g(%arg0: vector<8xi32>, %arg1: vector<3xi32>) -> vector<8xi32> { + %0 = llvm.intr.vector.insert %arg1, %arg0[0] : vector<3xi32> into vector<8xi32> + llvm.return %0 : vector<8xi32> + } + llvm.func @valid_insertion_h(%arg0: vector<8xi32>, %arg1: vector<3xi32>) -> vector<8xi32> { + %0 = llvm.intr.vector.insert %arg1, %arg0[3] : vector<3xi32> into vector<8xi32> + llvm.return %0 : vector<8xi32> + } + llvm.func @scalable_insert(%arg0: !llvm.vec, %arg1: vector<4xi32>) -> !llvm.vec { + %0 = llvm.intr.vector.insert %arg1, %arg0[0] : vector<4xi32> into !llvm.vec + llvm.return %0 : !llvm.vec + } +} diff --git a/test/LLVMDialect/InstCombine/canonicalize.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/canonicalize_branch.ll.mlir b/test/LLVMDialect/InstCombine/canonicalize_branch.ll.mlir new file mode 100644 index 000000000..1f6cfac5a --- /dev/null +++ b/test/LLVMDialect/InstCombine/canonicalize_branch.ll.mlir @@ -0,0 +1,262 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @eq(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %arg1 : i32 + llvm.cond_br %2 weights([0, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @ne(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %arg1 : i32 + llvm.cond_br %2 weights([1, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @ugt(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i32 + llvm.cond_br %2 weights([2, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @uge(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.icmp "uge" %arg0, %arg1 : i32 + llvm.cond_br %2 weights([3, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @ult(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %arg1 : i32 + llvm.cond_br %2 weights([4, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @ule(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.icmp "ule" %arg0, %arg1 : i32 + llvm.cond_br %2 weights([5, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @sgt(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i32 + llvm.cond_br %2 weights([6, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @sge(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.icmp "sge" %arg0, %arg1 : i32 + llvm.cond_br %2 weights([7, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @slt(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %arg1 : i32 + llvm.cond_br %2 weights([8, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @sle(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.icmp "sle" %arg0, %arg1 : i32 + llvm.cond_br %2 weights([9, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_false(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([10, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_oeq(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([11, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_ogt(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([12, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_oge(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([13, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_olt(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([14, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_ole(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([15, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_one(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "one" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([16, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_ord(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([17, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_uno(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "uno" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([18, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_ueq(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([19, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_ugt(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([20, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_uge(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "uge" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([21, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_ult(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "ult" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([22, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_ule(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "ule" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([23, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_une(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "une" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([24, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @f_true(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.fcmp "_true" %arg0, %arg1 : f32 + llvm.cond_br %2 weights([25, 99]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/cast-byval.ll.mlir b/test/LLVMDialect/InstCombine/cast-byval.ll.mlir new file mode 100644 index 000000000..708438774 --- /dev/null +++ b/test/LLVMDialect/InstCombine/cast-byval.ll.mlir @@ -0,0 +1,16 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: !llvm.ptr {llvm.byval = !llvm.struct<"Foo", (i64)>}) -> i64 { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i64 + llvm.return %0 : i64 + } + llvm.func @bar(%arg0: i64) -> i64 { + %0 = llvm.mlir.addressof @foo : !llvm.ptr + %1 = llvm.call %0(%arg0) : !llvm.ptr, (i64) -> i64 + llvm.return %1 : i64 + } + llvm.func @qux(%arg0: !llvm.ptr {llvm.byval = !llvm.struct<"Foo", (i64)>}) -> i64 { + %0 = llvm.mlir.addressof @bar : !llvm.ptr + %1 = llvm.call %0(%arg0) : !llvm.ptr, (!llvm.ptr) -> i64 + llvm.return %1 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/cast-call-combine-prof.ll.mlir b/test/LLVMDialect/InstCombine/cast-call-combine-prof.ll.mlir new file mode 100644 index 000000000..e5abc29d0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/cast-call-combine-prof.ll.mlir @@ -0,0 +1,22 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @__gxx_personality_v0(...) -> i32 + llvm.func @__cxa_call_unexpected(!llvm.ptr) + llvm.func @foo(!llvm.ptr) + llvm.func @test_call() { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.call @foo(%0) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test_invoke() attributes {personality = @__gxx_personality_v0} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.undef : !llvm.array<0 x ptr> + llvm.invoke @foo(%0) to ^bb1 unwind ^bb2 : (!llvm.ptr) -> () + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + %2 = llvm.landingpad (filter %1 : !llvm.array<0 x ptr>) : !llvm.struct<(ptr, i32)> + %3 = llvm.extractvalue %2[0] : !llvm.struct<(ptr, i32)> + llvm.call @__cxa_call_unexpected(%3) : (!llvm.ptr) -> () + llvm.unreachable + } +} diff --git a/test/LLVMDialect/InstCombine/cast-call-combine.ll.mlir b/test/LLVMDialect/InstCombine/cast-call-combine.ll.mlir new file mode 100644 index 000000000..c8acb87c0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/cast-call-combine.ll.mlir @@ -0,0 +1,19 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func internal @foo(%arg0: !llvm.ptr) attributes {dso_local, passthrough = ["alwaysinline"]} { + llvm.return + } + llvm.func @bar() attributes {passthrough = ["noinline", "noreturn"]} { + llvm.unreachable + } + llvm.func @test() { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.zero : !llvm.ptr + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @bar() : () -> () + llvm.unreachable + ^bb2: // pred: ^bb0 + llvm.call @foo(%1) : (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/cast-callee-deopt-bundles.ll.mlir b/test/LLVMDialect/InstCombine/cast-callee-deopt-bundles.ll.mlir index 6493868eb..518f09dee 100644 --- a/test/LLVMDialect/InstCombine/cast-callee-deopt-bundles.ll.mlir +++ b/test/LLVMDialect/InstCombine/cast-callee-deopt-bundles.ll.mlir @@ -1,11 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @foo} : () -> !llvm.ptr> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>) -> !llvm.ptr> - "llvm.call"(%1) : (!llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "g", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(i32) + llvm.func @g() { + %0 = llvm.mlir.addressof @foo : !llvm.ptr + llvm.call %0() : !llvm.ptr, () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/cast-int-fcmp-eq-0.ll.mlir b/test/LLVMDialect/InstCombine/cast-int-fcmp-eq-0.ll.mlir new file mode 100644 index 000000000..2d4f81606 --- /dev/null +++ b/test/LLVMDialect/InstCombine/cast-int-fcmp-eq-0.ll.mlir @@ -0,0 +1,339 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @i32_cast_cmp_oeq_int_0_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_n0_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_0_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_n0_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_one_int_0_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "one" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_one_int_n0_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "one" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_one_int_0_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "one" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_one_int_n0_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "one" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_ueq_int_0_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "ueq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_ueq_int_n0_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "ueq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_ueq_int_0_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "ueq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_ueq_int_n0_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "ueq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_une_int_0_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "une" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_une_int_n0_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "une" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_une_int_0_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "une" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_une_int_n0_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "une" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_ogt_int_0_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "ogt" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_ogt_int_n0_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "ogt" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_ogt_int_0_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "ogt" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_ogt_int_n0_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "ogt" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_ole_int_0_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "ole" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_ole_int_0_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "ole" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_olt_int_0_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "olt" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i64_cast_cmp_oeq_int_0_uitofp(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i64 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i64_cast_cmp_oeq_int_0_sitofp(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i64 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i64_cast_cmp_oeq_int_0_uitofp_half(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.uitofp %arg0 : i64 to f16 + %2 = llvm.fcmp "oeq" %1, %0 : f16 + llvm.return %2 : i1 + } + llvm.func @i64_cast_cmp_oeq_int_0_sitofp_half(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.sitofp %arg0 : i64 to f16 + %2 = llvm.fcmp "oeq" %1, %0 : f16 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_0_uitofp_ppcf128(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f128) : !llvm.ppc_fp128 + %1 = llvm.uitofp %arg0 : i32 to !llvm.ppc_fp128 + %2 = llvm.fcmp "oeq" %1, %0 : !llvm.ppc_fp128 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_i24max_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0x4B7FFFFF : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_i24max_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0x4B7FFFFF : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_i24maxp1_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0x4B800000 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_i24maxp1_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0x4B800000 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_i32umax_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4.2949673E+9 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_big_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8.58993459E+9 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_i32umax_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4.2949673E+9 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_i32imin_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2.14748365E+9 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_i32imax_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2.14748365E+9 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_i32imax_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2.14748365E+9 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_negi32umax_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-4.2949673E+9 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_half_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_half_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_one_half_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "one" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_one_half_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "one" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_ueq_half_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "ueq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_ueq_half_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "ueq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_une_half_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "une" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_une_half_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "une" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_inf_uitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_cast_cmp_oeq_int_inf_sitofp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i128_cast_cmp_oeq_int_inf_uitofp(%arg0: i128) -> i1 { + %0 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %1 = llvm.uitofp %arg0 : i128 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @i32_vec_cast_cmp_oeq_vec_int_0_sitofp(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.sitofp %arg0 : vector<2xi32> to vector<2xf32> + %3 = llvm.fcmp "oeq" %2, %1 : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @i32_vec_cast_cmp_oeq_vec_int_n0_sitofp(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.sitofp %arg0 : vector<2xi32> to vector<2xf32> + %2 = llvm.fcmp "oeq" %1, %0 : vector<2xf32> + llvm.return %2 : vector<2xi1> + } + llvm.func @i32_vec_cast_cmp_oeq_vec_int_i32imax_sitofp(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<2.14748365E+9> : vector<2xf32>) : vector<2xf32> + %1 = llvm.sitofp %arg0 : vector<2xi32> to vector<2xf32> + %2 = llvm.fcmp "oeq" %1, %0 : vector<2xf32> + llvm.return %2 : vector<2xi1> + } + llvm.func @i32_vec_cast_cmp_oeq_vec_int_negi32umax_sitofp(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-4.2949673E+9> : vector<2xf32>) : vector<2xf32> + %1 = llvm.sitofp %arg0 : vector<2xi32> to vector<2xf32> + %2 = llvm.fcmp "oeq" %1, %0 : vector<2xf32> + llvm.return %2 : vector<2xi1> + } + llvm.func @i32_vec_cast_cmp_oeq_vec_half_sitofp(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5.000000e-01> : vector<2xf32>) : vector<2xf32> + %1 = llvm.sitofp %arg0 : vector<2xi32> to vector<2xf32> + %2 = llvm.fcmp "oeq" %1, %0 : vector<2xf32> + llvm.return %2 : vector<2xi1> + } + llvm.func @i32_vec_cast_cmp_oeq_vec_int_inf_sitofp(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<0x7F800000> : vector<2xf32>) : vector<2xf32> + %1 = llvm.sitofp %arg0 : vector<2xi32> to vector<2xf32> + %2 = llvm.fcmp "oeq" %1, %0 : vector<2xf32> + llvm.return %2 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/cast-int-icmp-eq-0.ll.mlir b/test/LLVMDialect/InstCombine/cast-int-icmp-eq-0.ll.mlir new file mode 100644 index 000000000..a72f5fde6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/cast-int-icmp-eq-0.ll.mlir @@ -0,0 +1,477 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @i32_cast_cmp_eq_int_0_sitofp_float(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_ne_int_0_sitofp_float(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_slt_int_0_sitofp_float(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_sgt_int_0_sitofp_float(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_slt_int_1_sitofp_float(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_sgt_int_m1_sitofp_float(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_eq_int_0_sitofp_double(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sitofp %arg0 : i32 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "eq" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_ne_int_0_sitofp_double(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sitofp %arg0 : i32 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "ne" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_slt_int_0_sitofp_double(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sitofp %arg0 : i32 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "slt" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_sgt_int_0_sitofp_double(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sitofp %arg0 : i32 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "sgt" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_slt_int_1_sitofp_double(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.sitofp %arg0 : i32 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "slt" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_sgt_int_m1_sitofp_double(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.sitofp %arg0 : i32 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "sgt" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_eq_int_0_sitofp_half(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.sitofp %arg0 : i32 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "eq" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_ne_int_0_sitofp_half(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.sitofp %arg0 : i32 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "ne" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_slt_int_0_sitofp_half(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.sitofp %arg0 : i32 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "slt" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_sgt_int_0_sitofp_half(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.sitofp %arg0 : i32 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "sgt" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_slt_int_1_sitofp_half(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.sitofp %arg0 : i32 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "slt" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_sgt_int_m1_sitofp_half(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i16) : i16 + %1 = llvm.sitofp %arg0 : i32 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "sgt" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_eq_int_0_sitofp_float(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sitofp %arg0 : i64 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_ne_int_0_sitofp_float(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sitofp %arg0 : i64 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_slt_int_0_sitofp_float(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sitofp %arg0 : i64 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_sgt_int_0_sitofp_float(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sitofp %arg0 : i64 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_slt_int_1_sitofp_float(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sitofp %arg0 : i64 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_sgt_int_m1_sitofp_float(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sitofp %arg0 : i64 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_eq_int_0_sitofp_double(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sitofp %arg0 : i64 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "eq" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_ne_int_0_sitofp_double(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sitofp %arg0 : i64 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "ne" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_slt_int_0_sitofp_double(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sitofp %arg0 : i64 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "slt" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_sgt_int_0_sitofp_double(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sitofp %arg0 : i64 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "sgt" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_slt_int_1_sitofp_double(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.sitofp %arg0 : i64 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "slt" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_sgt_int_m1_sitofp_double(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.sitofp %arg0 : i64 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "sgt" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_eq_int_0_sitofp_half(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.sitofp %arg0 : i64 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "eq" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_ne_int_0_sitofp_half(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.sitofp %arg0 : i64 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "ne" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_slt_int_0_sitofp_half(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.sitofp %arg0 : i64 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "slt" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_sgt_int_0_sitofp_half(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.sitofp %arg0 : i64 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "sgt" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_slt_int_1_sitofp_half(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.sitofp %arg0 : i64 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "slt" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i64_cast_cmp_sgt_int_m1_sitofp_half(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(-1 : i16) : i16 + %1 = llvm.sitofp %arg0 : i64 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "sgt" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_eq_int_0_sitofp_float(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sitofp %arg0 : i16 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_ne_int_0_sitofp_float(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sitofp %arg0 : i16 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_slt_int_0_sitofp_float(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sitofp %arg0 : i16 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_sgt_int_0_sitofp_float(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sitofp %arg0 : i16 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_slt_int_1_sitofp_float(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sitofp %arg0 : i16 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_sgt_int_m1_sitofp_float(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sitofp %arg0 : i16 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_eq_int_0_sitofp_double(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sitofp %arg0 : i16 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "eq" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_ne_int_0_sitofp_double(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sitofp %arg0 : i16 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "ne" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_slt_int_0_sitofp_double(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sitofp %arg0 : i16 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "slt" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_sgt_int_0_sitofp_double(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sitofp %arg0 : i16 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "sgt" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_slt_int_1_sitofp_double(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.sitofp %arg0 : i16 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "slt" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_sgt_int_m1_sitofp_double(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.sitofp %arg0 : i16 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "sgt" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_eq_int_0_sitofp_half(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.sitofp %arg0 : i16 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "eq" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_ne_int_0_sitofp_half(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.sitofp %arg0 : i16 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "ne" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_slt_int_0_sitofp_half(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.sitofp %arg0 : i16 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "slt" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_sgt_int_0_sitofp_half(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.sitofp %arg0 : i16 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "sgt" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_slt_int_1_sitofp_half(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.sitofp %arg0 : i16 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "slt" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_sgt_int_m1_sitofp_half(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(-1 : i16) : i16 + %1 = llvm.sitofp %arg0 : i16 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "sgt" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_ne_int_0_sitofp_double_vec(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<3xi64>) : vector<3xi64> + %2 = llvm.sitofp %arg0 : vector<3xi32> to vector<3xf64> + %3 = llvm.bitcast %2 : vector<3xf64> to vector<3xi64> + %4 = llvm.icmp "ne" %3, %1 : vector<3xi64> + llvm.return %4 : vector<3xi1> + } + llvm.func @i32_cast_cmp_eq_int_0_sitofp_float_vec_poison(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.sitofp %arg0 : vector<3xi32> to vector<3xf32> + %10 = llvm.bitcast %9 : vector<3xf32> to vector<3xi32> + %11 = llvm.icmp "eq" %10, %8 : vector<3xi32> + llvm.return %11 : vector<3xi1> + } + llvm.func @i64_cast_cmp_slt_int_1_sitofp_half_vec_poison(%arg0: vector<3xi64>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<3xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi16> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi16> + %9 = llvm.sitofp %arg0 : vector<3xi64> to vector<3xf16> + %10 = llvm.bitcast %9 : vector<3xf16> to vector<3xi16> + %11 = llvm.icmp "slt" %10, %8 : vector<3xi16> + llvm.return %11 : vector<3xi1> + } + llvm.func @i16_cast_cmp_sgt_int_m1_sitofp_float_vec_poison(%arg0: vector<3xi16>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.sitofp %arg0 : vector<3xi16> to vector<3xf32> + %10 = llvm.bitcast %9 : vector<3xf32> to vector<3xi32> + %11 = llvm.icmp "sgt" %10, %8 : vector<3xi32> + llvm.return %11 : vector<3xi1> + } + llvm.func @i16_cast_cmp_sgt_int_m1_bitcast_vector_num_elements_sitofp(%arg0: vector<3xi16>) -> vector<6xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<6xi16>) : vector<6xi16> + %1 = llvm.sitofp %arg0 : vector<3xi16> to vector<3xf32> + %2 = llvm.bitcast %1 : vector<3xf32> to vector<6xi16> + %3 = llvm.icmp "sgt" %2, %0 : vector<6xi16> + llvm.return %3 : vector<6xi1> + } + llvm.func @i16_cast_cmp_sgt_int_m1_bitcast_vector_to_scalar_sitofp(%arg0: vector<3xi16>) -> i1 { + %0 = llvm.mlir.constant(-1 : i96) : i96 + %1 = llvm.sitofp %arg0 : vector<3xi16> to vector<3xf32> + %2 = llvm.bitcast %1 : vector<3xf32> to i96 + %3 = llvm.icmp "sgt" %2, %0 : i96 + llvm.return %3 : i1 + } + llvm.func @i16_cast_cmp_eq_int_0_bitcast_vector_num_elements_uitofp(%arg0: vector<3xi16>) -> vector<6xi1> { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : vector<6xi16>) : vector<6xi16> + %2 = llvm.uitofp %arg0 : vector<3xi16> to vector<3xf32> + %3 = llvm.bitcast %2 : vector<3xf32> to vector<6xi16> + %4 = llvm.icmp "eq" %3, %1 : vector<6xi16> + llvm.return %4 : vector<6xi1> + } + llvm.func @i16_cast_cmp_eq_int_0_bitcast_vector_to_scalar_uitofp(%arg0: vector<3xi16>) -> i1 { + %0 = llvm.mlir.constant(0 : i96) : i96 + %1 = llvm.uitofp %arg0 : vector<3xi16> to vector<3xf32> + %2 = llvm.bitcast %1 : vector<3xf32> to i96 + %3 = llvm.icmp "eq" %2, %0 : i96 + llvm.return %3 : i1 + } + llvm.func @PR55516(%arg0: i64) -> vector<1xi1> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<1xi64>) : vector<1xi64> + %2 = llvm.sitofp %arg0 : i64 to f64 + %3 = llvm.bitcast %2 : f64 to vector<1xi64> + %4 = llvm.icmp "eq" %3, %1 : vector<1xi64> + llvm.return %4 : vector<1xi1> + } + llvm.func @PR55516_alt(%arg0: vector<1xi64>) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sitofp %arg0 : vector<1xi64> to vector<1xf64> + %2 = llvm.bitcast %1 : vector<1xf64> to i64 + %3 = llvm.icmp "eq" %2, %0 : i64 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/cast-mul-select.ll.mlir b/test/LLVMDialect/InstCombine/cast-mul-select.ll.mlir new file mode 100644 index 000000000..43acc30ac --- /dev/null +++ b/test/LLVMDialect/InstCombine/cast-mul-select.ll.mlir @@ -0,0 +1,85 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @mul(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.trunc %arg0 : i32 to i8 + %1 = llvm.trunc %arg1 : i32 to i8 + %2 = llvm.mul %0, %1 : i8 + %3 = llvm.zext %2 : i8 to i32 + llvm.return %3 : i32 + } + llvm.func @select1(%arg0: i1, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.trunc %arg1 : i32 to i8 + %1 = llvm.trunc %arg2 : i32 to i8 + %2 = llvm.trunc %arg3 : i32 to i8 + %3 = llvm.add %0, %1 : i8 + %4 = llvm.select %arg0, %2, %3 : i1, i8 + %5 = llvm.zext %4 : i8 to i32 + llvm.return %5 : i32 + } + llvm.func @select2(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.zext %arg1 : i8 to i32 + %1 = llvm.zext %arg2 : i8 to i32 + %2 = llvm.zext %arg3 : i8 to i32 + %3 = llvm.add %0, %1 : i32 + %4 = llvm.select %arg0, %2, %3 : i1, i32 + %5 = llvm.trunc %4 : i32 to i8 + llvm.return %5 : i8 + } + llvm.func @eval_trunc_multi_use_in_one_inst(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i64) : i64 + %1 = llvm.zext %arg0 : i32 to i64 + %2 = llvm.add %1, %0 overflow : i64 + %3 = llvm.mul %2, %2 : i64 + %4 = llvm.trunc %3 : i64 to i32 + llvm.return %4 : i32 + } + llvm.func @eval_zext_multi_use_in_one_inst(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i16) : i16 + %1 = llvm.trunc %arg0 : i32 to i16 + %2 = llvm.and %1, %0 : i16 + %3 = llvm.mul %2, %2 overflow : i16 + %4 = llvm.zext %3 : i16 to i32 + llvm.return %4 : i32 + } + llvm.func @eval_sext_multi_use_in_one_inst(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(14 : i16) : i16 + %1 = llvm.mlir.constant(-32768 : i16) : i16 + %2 = llvm.trunc %arg0 : i32 to i16 + %3 = llvm.and %2, %0 : i16 + %4 = llvm.mul %3, %3 overflow : i16 + %5 = llvm.or %4, %1 : i16 + %6 = llvm.sext %5 : i16 to i32 + llvm.return %6 : i32 + } + llvm.func @PR36225(%arg0: i32, %arg1: i32, %arg2: i1, %arg3: i3, %arg4: i3) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(4 : i8) : i8 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + %3 = llvm.icmp "eq" %arg1, %0 : i32 + llvm.cond_br %arg2, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %4 = llvm.select %3, %1, %2 : i1, i8 + llvm.switch %arg3 : i3, ^bb6 [ + 0: ^bb4(%4 : i8), + 7: ^bb4(%4 : i8) + ] + ^bb3: // pred: ^bb1 + llvm.switch %arg4 : i3, ^bb6 [ + 0: ^bb4(%1 : i8), + 7: ^bb4(%1 : i8) + ] + ^bb4(%5: i8): // 4 preds: ^bb2, ^bb2, ^bb3, ^bb3 + %6 = llvm.sext %5 : i8 to i32 + %7 = llvm.icmp "sgt" %arg0, %6 : i32 + llvm.cond_br %7, ^bb6, ^bb5 + ^bb5: // pred: ^bb4 + llvm.unreachable + ^bb6: // 3 preds: ^bb2, ^bb3, ^bb4 + llvm.unreachable + } + llvm.func @foo(%arg0: i1 {llvm.zeroext}) -> i1 { + %0 = llvm.zext %arg0 : i1 to i8 + llvm.return %arg0 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/cast-select.ll.mlir b/test/LLVMDialect/InstCombine/cast-select.ll.mlir new file mode 100644 index 000000000..706895a97 --- /dev/null +++ b/test/LLVMDialect/InstCombine/cast-select.ll.mlir @@ -0,0 +1,72 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @zext(%arg0: i32, %arg1: i32, %arg2: i32) -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.select %1, %0, %arg2 : i1, i32 + %3 = llvm.zext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @zext_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 7]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.icmp "ugt" %arg0, %arg1 : vector<2xi8> + %2 = llvm.select %1, %arg2, %0 : vector<2xi1>, vector<2xi8> + %3 = llvm.zext %2 : vector<2xi8> to vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @sext(%arg0: i8, %arg1: i8, %arg2: i8) -> i64 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.icmp "ult" %arg0, %arg1 : i8 + %2 = llvm.select %1, %0, %arg2 : i1, i8 + %3 = llvm.sext %2 : i8 to i64 + llvm.return %3 : i64 + } + llvm.func @sext_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 7]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.icmp "ugt" %arg0, %arg1 : vector<2xi8> + %2 = llvm.select %1, %arg2, %0 : vector<2xi1>, vector<2xi8> + %3 = llvm.sext %2 : vector<2xi8> to vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @trunc(%arg0: i32, %arg1: i32, %arg2: i32) -> i16 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.icmp "ult" %arg0, %arg1 : i32 + %2 = llvm.select %1, %0, %arg2 : i1, i32 + %3 = llvm.trunc %2 : i32 to i16 + llvm.return %3 : i16 + } + llvm.func @trunc_vec(%arg0: vector<2xi64>, %arg1: vector<2xi64>, %arg2: vector<2xi64>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 7]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.icmp "ugt" %arg0, %arg1 : vector<2xi64> + %2 = llvm.select %1, %arg2, %0 : vector<2xi1>, vector<2xi64> + %3 = llvm.trunc %2 : vector<2xi64> to vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @fpext(%arg0: f32, %arg1: f32, %arg2: f32) -> f64 { + %0 = llvm.mlir.constant(1.700000e+01 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f32 + %2 = llvm.select %1, %0, %arg2 : i1, f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @fpext_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[4.200000e+01, -2.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fcmp "ugt" %arg0, %arg1 : vector<2xf32> + %2 = llvm.select %1, %arg2, %0 : vector<2xi1>, vector<2xf32> + %3 = llvm.fpext %2 : vector<2xf32> to vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @fptrunc(%arg0: f64, %arg1: f64, %arg2: f64) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f64) : f64 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.select %1, %0, %arg2 : i1, f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @fptrunc_vec(%arg0: vector<2xf64>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[-4.200000e+01, 1.200000e+01]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fcmp "oge" %arg0, %arg1 : vector<2xf64> + %2 = llvm.select %1, %arg2, %0 : vector<2xi1>, vector<2xf64> + %3 = llvm.fptrunc %2 : vector<2xf64> to vector<2xf32> + llvm.return %3 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/cast-set-preserve-signed-dbg-val.ll.mlir b/test/LLVMDialect/InstCombine/cast-set-preserve-signed-dbg-val.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/cast-set.ll.mlir b/test/LLVMDialect/InstCombine/cast-set.ll.mlir new file mode 100644 index 000000000..6b3d3a829 --- /dev/null +++ b/test/LLVMDialect/InstCombine/cast-set.ll.mlir @@ -0,0 +1,45 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.bitcast %arg0 : i32 to i32 + %2 = llvm.icmp "ne" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @test2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.bitcast %arg0 : i32 to i32 + %1 = llvm.bitcast %arg1 : i32 to i32 + %2 = llvm.icmp "ne" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @test4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.bitcast %arg0 : i32 to i32 + %2 = llvm.shl %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to i32 + llvm.return %3 : i32 + } + llvm.func @test5(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.sext %arg0 : i16 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i16 + llvm.return %3 : i16 + } + llvm.func @test6(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.icmp "ne" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @test6a(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.icmp "ne" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @test7(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/cast-unsigned-icmp-eqcmp-0.ll.mlir b/test/LLVMDialect/InstCombine/cast-unsigned-icmp-eqcmp-0.ll.mlir new file mode 100644 index 000000000..91f8a0a2c --- /dev/null +++ b/test/LLVMDialect/InstCombine/cast-unsigned-icmp-eqcmp-0.ll.mlir @@ -0,0 +1,182 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @i32_cast_cmp_eq_int_0_uitofp_float(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_eq_int_0_uitofp_float_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.uitofp %arg0 : vector<2xi32> to vector<2xf32> + %3 = llvm.bitcast %2 : vector<2xf32> to vector<2xi32> + %4 = llvm.icmp "eq" %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @i32_cast_cmp_eq_int_0_uitofp_float_vec_poison(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.uitofp %arg0 : vector<3xi32> to vector<3xf32> + %10 = llvm.bitcast %9 : vector<3xf32> to vector<3xi32> + %11 = llvm.icmp "eq" %10, %8 : vector<3xi32> + llvm.return %11 : vector<3xi1> + } + llvm.func @i32_cast_cmp_ne_int_0_uitofp_float(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.bitcast %1 : f32 to i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_ne_int_0_uitofp_float_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.uitofp %arg0 : vector<2xi32> to vector<2xf32> + %3 = llvm.bitcast %2 : vector<2xf32> to vector<2xi32> + %4 = llvm.icmp "ne" %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @i32_cast_cmp_ne_int_0_uitofp_float_vec_poison(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.uitofp %arg0 : vector<3xi32> to vector<3xf32> + %10 = llvm.bitcast %9 : vector<3xf32> to vector<3xi32> + %11 = llvm.icmp "ne" %10, %8 : vector<3xi32> + llvm.return %11 : vector<3xi1> + } + llvm.func @i32_cast_cmp_eq_int_0_uitofp_double(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.uitofp %arg0 : i32 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "eq" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_eq_int_0_uitofp_double_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.uitofp %arg0 : vector<2xi32> to vector<2xf64> + %3 = llvm.bitcast %2 : vector<2xf64> to vector<2xi64> + %4 = llvm.icmp "eq" %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi1> + } + llvm.func @i32_cast_cmp_eq_int_0_uitofp_double_vec_poison(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<3xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi64> + %9 = llvm.uitofp %arg0 : vector<3xi32> to vector<3xf64> + %10 = llvm.bitcast %9 : vector<3xf64> to vector<3xi64> + %11 = llvm.icmp "eq" %10, %8 : vector<3xi64> + llvm.return %11 : vector<3xi1> + } + llvm.func @i32_cast_cmp_ne_int_0_uitofp_double(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.uitofp %arg0 : i32 to f64 + %2 = llvm.bitcast %1 : f64 to i64 + %3 = llvm.icmp "ne" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_ne_int_0_uitofp_double_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.uitofp %arg0 : vector<2xi32> to vector<2xf64> + %3 = llvm.bitcast %2 : vector<2xf64> to vector<2xi64> + %4 = llvm.icmp "ne" %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi1> + } + llvm.func @i32_cast_cmp_ne_int_0_uitofp_double_vec_poison(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<3xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi64> + %9 = llvm.uitofp %arg0 : vector<3xi32> to vector<3xf64> + %10 = llvm.bitcast %9 : vector<3xf64> to vector<3xi64> + %11 = llvm.icmp "ne" %10, %8 : vector<3xi64> + llvm.return %11 : vector<3xi1> + } + llvm.func @i32_cast_cmp_eq_int_0_uitofp_half(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.uitofp %arg0 : i32 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "eq" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_eq_int_0_uitofp_half_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : vector<2xi16>) : vector<2xi16> + %2 = llvm.uitofp %arg0 : vector<2xi32> to vector<2xf16> + %3 = llvm.bitcast %2 : vector<2xf16> to vector<2xi16> + %4 = llvm.icmp "eq" %3, %1 : vector<2xi16> + llvm.return %4 : vector<2xi1> + } + llvm.func @i32_cast_cmp_eq_int_0_uitofp_half_vec_poison(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<3xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi16> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi16> + %9 = llvm.uitofp %arg0 : vector<3xi32> to vector<3xf16> + %10 = llvm.bitcast %9 : vector<3xf16> to vector<3xi16> + %11 = llvm.icmp "eq" %10, %8 : vector<3xi16> + llvm.return %11 : vector<3xi1> + } + llvm.func @i32_cast_cmp_ne_int_0_uitofp_half(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.uitofp %arg0 : i32 to f16 + %2 = llvm.bitcast %1 : f16 to i16 + %3 = llvm.icmp "ne" %2, %0 : i16 + llvm.return %3 : i1 + } + llvm.func @i32_cast_cmp_ne_int_0_uitofp_half_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : vector<2xi16>) : vector<2xi16> + %2 = llvm.uitofp %arg0 : vector<2xi32> to vector<2xf16> + %3 = llvm.bitcast %2 : vector<2xf16> to vector<2xi16> + %4 = llvm.icmp "ne" %3, %1 : vector<2xi16> + llvm.return %4 : vector<2xi1> + } + llvm.func @i32_cast_cmp_ne_int_0_uitofp_half_vec_poison(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<3xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi16> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi16> + %9 = llvm.uitofp %arg0 : vector<3xi32> to vector<3xf16> + %10 = llvm.bitcast %9 : vector<3xf16> to vector<3xi16> + %11 = llvm.icmp "ne" %10, %8 : vector<3xi16> + llvm.return %11 : vector<3xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/cast.ll.mlir b/test/LLVMDialect/InstCombine/cast.ll.mlir new file mode 100644 index 000000000..eb0e9e83d --- /dev/null +++ b/test/LLVMDialect/InstCombine/cast.ll.mlir @@ -0,0 +1,1273 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @inbuf() {addr_space = 0 : i32} : !llvm.array<32832 x i8> + llvm.func @use_i32(i32) + llvm.func @use_v2i32(vector<2xi32>) + llvm.func @test1(%arg0: i32) -> i32 { + %0 = llvm.bitcast %arg0 : i32 to i32 + %1 = llvm.bitcast %0 : i32 to i32 + llvm.return %1 : i32 + } + llvm.func @test2(%arg0: i8) -> i64 { + %0 = llvm.zext %arg0 : i8 to i16 + %1 = llvm.zext %0 : i16 to i32 + %2 = llvm.zext %1 : i32 to i64 + llvm.return %2 : i64 + } + llvm.func @test3(%arg0: i64) -> i64 { + %0 = llvm.trunc %arg0 : i64 to i8 + %1 = llvm.zext %0 : i8 to i64 + llvm.return %1 : i64 + } + llvm.func @test4(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.zext %0 : i1 to i8 + %2 = llvm.zext %1 : i8 to i32 + llvm.return %2 : i32 + } + llvm.func @test5(%arg0: i1) -> i32 { + %0 = llvm.zext %arg0 : i1 to i8 + %1 = llvm.zext %0 : i8 to i32 + llvm.return %1 : i32 + } + llvm.func @test6(%arg0: i64) -> i32 { + %0 = llvm.trunc %arg0 : i64 to i32 + %1 = llvm.bitcast %0 : i32 to i32 + llvm.return %1 : i32 + } + llvm.func @test7(%arg0: i1) -> i64 { + %0 = llvm.zext %arg0 : i1 to i32 + %1 = llvm.sext %0 : i32 to i64 + llvm.return %1 : i64 + } + llvm.func @test8(%arg0: i8) -> i64 { + %0 = llvm.sext %arg0 : i8 to i64 + %1 = llvm.bitcast %0 : i64 to i64 + llvm.return %1 : i64 + } + llvm.func @test9(%arg0: i16) -> i16 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.trunc %0 : i32 to i16 + llvm.return %1 : i16 + } + llvm.func @test10(%arg0: i16) -> i16 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.trunc %0 : i32 to i16 + llvm.return %1 : i16 + } + llvm.func @varargs(i32, ...) + llvm.func @test11(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(5 : i32) : i32 + llvm.call @varargs(%0, %arg0) vararg(!llvm.func) : (i32, !llvm.ptr) -> () + llvm.return + } + llvm.func @__gxx_personality_v0(...) -> i32 + llvm.func @test_invoke_vararg_cast(%arg0: !llvm.ptr, %arg1: !llvm.ptr) attributes {personality = @__gxx_personality_v0} { + %0 = llvm.mlir.constant(1 : i32) : i32 + llvm.invoke @varargs(%0, %arg1, %arg0) to ^bb1 unwind ^bb2 vararg(!llvm.func) : (i32, !llvm.ptr, !llvm.ptr) -> () + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + %1 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)> + llvm.return + } + llvm.func @test13(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.addressof @inbuf : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.getelementptr %0[%1, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i8> + llvm.return %2 : !llvm.ptr + } + llvm.func @test14(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.bitcast %arg0 : i8 to i8 + %2 = llvm.icmp "ult" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @test16(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + llvm.return %1 : i1 + } + llvm.func @test17(%arg0: i1) -> i16 { + %0 = llvm.zext %arg0 : i1 to i32 + %1 = llvm.trunc %0 : i32 to i16 + llvm.return %1 : i16 + } + llvm.func @test18(%arg0: i8) -> i16 { + %0 = llvm.sext %arg0 : i8 to i32 + %1 = llvm.trunc %0 : i32 to i16 + llvm.return %1 : i16 + } + llvm.func @test19(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12345 : i64) : i64 + %1 = llvm.sext %arg0 : i32 to i64 + %2 = llvm.icmp "slt" %1, %0 : i64 + llvm.return %2 : i1 + } + llvm.func @test19vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[12345, 2147483647]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.sext %arg0 : vector<2xi32> to vector<2xi64> + %2 = llvm.icmp "slt" %1, %0 : vector<2xi64> + llvm.return %2 : vector<2xi1> + } + llvm.func @test19vec2(%arg0: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<3xi32>) : vector<3xi32> + %2 = llvm.sext %arg0 : vector<3xi1> to vector<3xi32> + %3 = llvm.icmp "eq" %2, %1 : vector<3xi32> + llvm.return %3 : vector<3xi1> + } + llvm.func @test20(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @test21(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.trunc %arg0 : i32 to i8 + %2 = llvm.sext %1 : i8 to i32 + %3 = llvm.and %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @test22(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.trunc %arg0 : i32 to i8 + %2 = llvm.sext %1 : i8 to i32 + %3 = llvm.shl %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @test23(%arg0: i32) -> i32 { + %0 = llvm.trunc %arg0 : i32 to i16 + %1 = llvm.zext %0 : i16 to i32 + llvm.return %1 : i32 + } + llvm.func @test24(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(1234 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.icmp "ne" %3, %2 : i32 + llvm.return %4 : i1 + } + llvm.func @test26(%arg0: f32) -> i32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fptosi %0 : f64 to i32 + llvm.return %1 : i32 + } + llvm.func @test27(%arg0: !llvm.ptr) -> !llvm.ptr { + llvm.return %arg0 : !llvm.ptr + } + llvm.func @test28(%arg0: !llvm.ptr) -> !llvm.ptr { + llvm.return %arg0 : !llvm.ptr + } + llvm.func @test29(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.trunc %arg0 : i32 to i8 + %1 = llvm.trunc %arg1 : i32 to i8 + %2 = llvm.or %1, %0 : i8 + %3 = llvm.zext %2 : i8 to i32 + llvm.return %3 : i32 + } + llvm.func @test30(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.trunc %arg0 : i32 to i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.zext %2 : i8 to i32 + llvm.return %3 : i32 + } + llvm.func @test31(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.trunc %arg0 : i64 to i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @test31vec(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %3 = llvm.and %2, %0 : vector<2xi32> + %4 = llvm.icmp "eq" %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @test32vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<10> : vector<2xi16>) : vector<2xi16> + %2 = llvm.zext %arg0 : vector<2xi8> to vector<2xi16> + %3 = llvm.and %2, %0 : vector<2xi16> + %4 = llvm.icmp "eq" %3, %1 : vector<2xi16> + llvm.return %4 : vector<2xi1> + } + llvm.func @test33(%arg0: i32) -> i32 { + %0 = llvm.bitcast %arg0 : i32 to f32 + %1 = llvm.bitcast %0 : f32 to i32 + llvm.return %1 : i32 + } + llvm.func @test34(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i16 + llvm.return %3 : i16 + } + llvm.func @test35(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.bitcast %arg0 : i16 to i16 + %2 = llvm.lshr %1, %0 : i16 + %3 = llvm.bitcast %2 : i16 to i16 + llvm.return %3 : i16 + } + llvm.func @test36(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @test36vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.lshr %arg0, %0 : vector<2xi32> + %4 = llvm.trunc %3 : vector<2xi32> to vector<2xi8> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi8> + llvm.return %5 : vector<2xi1> + } + llvm.func @test37(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(512 : i32) : i32 + %2 = llvm.mlir.constant(11 : i8) : i8 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.or %3, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.icmp "eq" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @test38(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i8 + %4 = llvm.xor %3, %1 : i8 + %5 = llvm.zext %4 : i8 to i64 + llvm.return %5 : i64 + } + llvm.func @test39(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.shl %1, %0 : i32 + %4 = llvm.or %2, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + llvm.return %5 : i16 + } + llvm.func @test40(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.zext %arg0 : i16 to i32 + %3 = llvm.lshr %2, %0 : i32 + %4 = llvm.shl %2, %1 : i32 + %5 = llvm.or %3, %4 : i32 + %6 = llvm.trunc %5 : i32 to i16 + llvm.return %6 : i16 + } + llvm.func @test40vec(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<9> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.lshr %2, %0 : vector<2xi32> + %4 = llvm.shl %2, %1 : vector<2xi32> + %5 = llvm.or %3, %4 : vector<2xi32> + %6 = llvm.trunc %5 : vector<2xi32> to vector<2xi16> + llvm.return %6 : vector<2xi16> + } + llvm.func @test40vec_nonuniform(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[9, 10]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[8, 9]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.lshr %2, %0 : vector<2xi32> + %4 = llvm.shl %2, %1 : vector<2xi32> + %5 = llvm.or %3, %4 : vector<2xi32> + %6 = llvm.trunc %5 : vector<2xi32> to vector<2xi16> + llvm.return %6 : vector<2xi16> + } + llvm.func @test40vec_poison(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(8 : i32) : i32 + %8 = llvm.mlir.undef : vector<2xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi32> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi32> + %13 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %14 = llvm.lshr %13, %6 : vector<2xi32> + %15 = llvm.shl %13, %12 : vector<2xi32> + %16 = llvm.or %14, %15 : vector<2xi32> + %17 = llvm.trunc %16 : vector<2xi32> to vector<2xi16> + llvm.return %17 : vector<2xi16> + } + llvm.func @test41(%arg0: !llvm.ptr) -> !llvm.ptr { + llvm.return %arg0 : !llvm.ptr + } + llvm.func @test41_addrspacecast_smaller(%arg0: !llvm.ptr) -> !llvm.ptr<1> { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr to !llvm.ptr<1> + llvm.return %0 : !llvm.ptr<1> + } + llvm.func @test41_addrspacecast_larger(%arg0: !llvm.ptr<1>) -> !llvm.ptr { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr<1> to !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test42(%arg0: i32) -> i32 { + %0 = llvm.trunc %arg0 : i32 to i8 + %1 = llvm.zext %0 : i8 to i32 + llvm.return %1 : i32 + } + llvm.func @test43(%arg0: i8 {llvm.zeroext}) -> (i64 {llvm.zeroext}) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.add %1, %0 : i32 + %3 = llvm.sext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @test44(%arg0: i8) -> i64 { + %0 = llvm.mlir.constant(1234 : i16) : i16 + %1 = llvm.zext %arg0 : i8 to i16 + %2 = llvm.or %1, %0 : i16 + %3 = llvm.zext %2 : i16 to i64 + llvm.return %3 : i64 + } + llvm.func @test45(%arg0: i8, %arg1: i64) -> i64 { + %0 = llvm.trunc %arg1 : i64 to i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.or %1, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @test46(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.trunc %arg0 : i64 to i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.shl %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + llvm.return %5 : i64 + } + llvm.func @test46vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %2 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %3 = llvm.and %2, %0 : vector<2xi32> + %4 = llvm.shl %3, %1 : vector<2xi32> + %5 = llvm.zext %4 : vector<2xi32> to vector<2xi64> + llvm.return %5 : vector<2xi64> + } + llvm.func @test47(%arg0: i8) -> i64 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.or %1, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @test48(%arg0: i8, %arg1: i8) -> i64 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.shl %2, %0 : i32 + %4 = llvm.or %3, %2 : i32 + %5 = llvm.zext %4 : i32 to i64 + llvm.return %5 : i64 + } + llvm.func @test49(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.trunc %arg0 : i64 to i32 + %2 = llvm.or %1, %0 : i32 + %3 = llvm.sext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @test50(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.sext %4 : i32 to i64 + llvm.return %5 : i64 + } + llvm.func @test51(%arg0: i64, %arg1: i1) -> i64 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.trunc %arg0 : i64 to i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.or %2, %1 : i32 + %5 = llvm.select %arg1, %3, %4 : i1, i32 + %6 = llvm.sext %5 : i32 to i64 + llvm.return %6 : i64 + } + llvm.func @test52(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(-32574 : i16) : i16 + %1 = llvm.mlir.constant(-25350 : i16) : i16 + %2 = llvm.trunc %arg0 : i64 to i16 + %3 = llvm.or %2, %0 : i16 + %4 = llvm.and %3, %1 : i16 + %5 = llvm.zext %4 : i16 to i32 + llvm.return %5 : i32 + } + llvm.func @test53(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(-32574 : i16) : i16 + %1 = llvm.mlir.constant(-25350 : i16) : i16 + %2 = llvm.trunc %arg0 : i32 to i16 + %3 = llvm.or %2, %0 : i16 + %4 = llvm.and %3, %1 : i16 + %5 = llvm.zext %4 : i16 to i64 + llvm.return %5 : i64 + } + llvm.func @test54(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(-32574 : i16) : i16 + %1 = llvm.mlir.constant(-25350 : i16) : i16 + %2 = llvm.trunc %arg0 : i64 to i16 + %3 = llvm.or %2, %0 : i16 + %4 = llvm.and %3, %1 : i16 + %5 = llvm.sext %4 : i16 to i32 + llvm.return %5 : i32 + } + llvm.func @test55(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(-32574 : i16) : i16 + %1 = llvm.mlir.constant(-25350 : i16) : i16 + %2 = llvm.trunc %arg0 : i32 to i16 + %3 = llvm.or %2, %0 : i16 + %4 = llvm.and %3, %1 : i16 + %5 = llvm.sext %4 : i16 to i64 + llvm.return %5 : i64 + } + llvm.func @test56(%arg0: i16) -> i64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.sext %arg0 : i16 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @test56vec(%arg0: vector<2xi16>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi16> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @test57(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.trunc %arg0 : i64 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @test57vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @test58(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.trunc %arg0 : i64 to i32 + %3 = llvm.lshr %2, %0 : i32 + %4 = llvm.or %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + llvm.return %5 : i64 + } + llvm.func @test59(%arg0: i8, %arg1: i8) -> i64 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(48 : i32) : i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.shl %2, %0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.zext %arg1 : i8 to i32 + %6 = llvm.lshr %5, %0 : i32 + %7 = llvm.or %6, %4 : i32 + %8 = llvm.zext %7 : i32 to i64 + llvm.return %8 : i64 + } + llvm.func @test60(%arg0: vector<4xi32>) -> vector<3xi32> { + %0 = llvm.bitcast %arg0 : vector<4xi32> to i128 + %1 = llvm.trunc %0 : i128 to i96 + %2 = llvm.bitcast %1 : i96 to vector<3xi32> + llvm.return %2 : vector<3xi32> + } + llvm.func @test61(%arg0: vector<3xi32>) -> vector<4xi32> { + %0 = llvm.bitcast %arg0 : vector<3xi32> to i96 + %1 = llvm.zext %0 : i96 to i128 + %2 = llvm.bitcast %1 : i128 to vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @test62(%arg0: vector<3xf32>) -> vector<4xi32> { + %0 = llvm.bitcast %arg0 : vector<3xf32> to i96 + %1 = llvm.zext %0 : i96 to i128 + %2 = llvm.bitcast %1 : i128 to vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @test63(%arg0: i64) -> vector<2xf32> { + %0 = llvm.bitcast %arg0 : i64 to vector<2xi32> + %1 = llvm.uitofp %0 : vector<2xi32> to vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @test64(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.bitcast %arg0 : vector<4xf32> to vector<4xi32> + %1 = llvm.bitcast %0 : vector<4xi32> to vector<4xf32> + llvm.return %1 : vector<4xf32> + } + llvm.func @test65(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.bitcast %arg0 : vector<4xf32> to vector<2xf64> + %1 = llvm.bitcast %0 : vector<2xf64> to vector<4xf32> + llvm.return %1 : vector<4xf32> + } + llvm.func @test66(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.bitcast %arg0 : vector<2xf32> to f64 + %1 = llvm.bitcast %0 : f64 to vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @test2c() -> f32 { + %0 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + llvm.return %0 : f32 + } + llvm.func @test_mmx(%arg0: vector<2xi32>) -> i64 { + %0 = llvm.bitcast %arg0 : vector<2xi32> to !llvm.x86_mmx + %1 = llvm.bitcast %0 : !llvm.x86_mmx to vector<2xi32> + %2 = llvm.bitcast %1 : vector<2xi32> to i64 + llvm.return %2 : i64 + } + llvm.func @test_mmx_const(%arg0: vector<2xi32>) -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.bitcast %1 : vector<2xi32> to !llvm.x86_mmx + %3 = llvm.bitcast %2 : !llvm.x86_mmx to vector<2xi32> + %4 = llvm.bitcast %3 : vector<2xi32> to i64 + llvm.return %4 : i64 + } + llvm.func @test67(%arg0: i1, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.mlir.constant(-16777216 : i32) : i32 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.zext %arg0 : i1 to i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %arg1, %5 : i32 + %7 = llvm.shl %6, %1 overflow : i32 + %8 = llvm.xor %7, %2 : i32 + %9 = llvm.ashr %8, %1 : i32 + %10 = llvm.trunc %9 : i32 to i8 + %11 = llvm.icmp "eq" %10, %3 : i8 + llvm.return %11 : i1 + } + llvm.func @test68(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.struct<"s", (i32, i32, i16)> { + %0 = llvm.mlir.constant(12 : i64) : i64 + %1 = llvm.mul %arg1, %0 : i64 + %2 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> !llvm.struct<"s", (i32, i32, i16)> + llvm.return %3 : !llvm.struct<"s", (i32, i32, i16)> + } + llvm.func @test68_addrspacecast(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.struct<"s", (i32, i32, i16)> { + %0 = llvm.mlir.constant(12 : i64) : i64 + %1 = llvm.mul %arg1, %0 : i64 + %2 = llvm.addrspacecast %arg0 : !llvm.ptr to !llvm.ptr<2> + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr<2>, i64) -> !llvm.ptr<2>, i8 + %4 = llvm.addrspacecast %3 : !llvm.ptr<2> to !llvm.ptr + %5 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> !llvm.struct<"s", (i32, i32, i16)> + llvm.return %5 : !llvm.struct<"s", (i32, i32, i16)> + } + llvm.func @test68_addrspacecast_2(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.struct<"s", (i32, i32, i16)> { + %0 = llvm.mlir.constant(12 : i64) : i64 + %1 = llvm.mul %arg1, %0 : i64 + %2 = llvm.addrspacecast %arg0 : !llvm.ptr to !llvm.ptr<2> + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr<2>, i64) -> !llvm.ptr<2>, i8 + %4 = llvm.addrspacecast %3 : !llvm.ptr<2> to !llvm.ptr<1> + %5 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr<1> -> !llvm.struct<"s", (i32, i32, i16)> + llvm.return %5 : !llvm.struct<"s", (i32, i32, i16)> + } + llvm.func @test68_as1(%arg0: !llvm.ptr<1>, %arg1: i32) -> !llvm.struct<"s", (i32, i32, i16)> { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mul %arg1, %0 : i32 + %2 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr<1>, i32) -> !llvm.ptr<1>, i8 + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr<1> -> !llvm.struct<"s", (i32, i32, i16)> + llvm.return %3 : !llvm.struct<"s", (i32, i32, i16)> + } + llvm.func @test69(%arg0: !llvm.ptr, %arg1: i64) -> f64 { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.shl %arg1, %0 overflow : i64 + %2 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> f64 + llvm.return %3 : f64 + } + llvm.func @test70(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.struct<"s", (i32, i32, i16)> { + %0 = llvm.mlir.constant(36 : i64) : i64 + %1 = llvm.mul %arg1, %0 overflow : i64 + %2 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> !llvm.struct<"s", (i32, i32, i16)> + llvm.return %3 : !llvm.struct<"s", (i32, i32, i16)> + } + llvm.func @test71(%arg0: !llvm.ptr, %arg1: i64) -> f64 { + %0 = llvm.mlir.constant(5 : i64) : i64 + %1 = llvm.shl %arg1, %0 : i64 + %2 = llvm.getelementptr %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> f64 + llvm.return %3 : f64 + } + llvm.func @test72(%arg0: !llvm.ptr, %arg1: i32) -> f64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.shl %arg1, %0 overflow : i32 + %2 = llvm.sext %1 : i32 to i64 + %3 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.load %3 {alignment = 8 : i64} : !llvm.ptr -> f64 + llvm.return %4 : f64 + } + llvm.func @test73(%arg0: !llvm.ptr, %arg1: i128) -> f64 { + %0 = llvm.mlir.constant(3 : i128) : i128 + %1 = llvm.shl %arg1, %0 overflow : i128 + %2 = llvm.trunc %1 : i128 to i64 + %3 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.load %3 {alignment = 8 : i64} : !llvm.ptr -> f64 + llvm.return %4 : f64 + } + llvm.func @test74(%arg0: !llvm.ptr, %arg1: i64) -> f64 { + %0 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + %1 = llvm.load %0 {alignment = 8 : i64} : !llvm.ptr -> f64 + llvm.return %1 : f64 + } + llvm.func @test75(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.shl %arg1, %0 : i32 + %2 = llvm.sext %1 : i32 to i64 + %3 = llvm.getelementptr %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.return %3 : !llvm.ptr + } + llvm.func @test76(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.struct<"s", (i32, i32, i16)> { + %0 = llvm.mlir.constant(12 : i64) : i64 + %1 = llvm.mul %arg1, %0 : i64 + %2 = llvm.mul %1, %arg2 overflow : i64 + %3 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> !llvm.struct<"s", (i32, i32, i16)> + llvm.return %4 : !llvm.struct<"s", (i32, i32, i16)> + } + llvm.func @test77(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.struct<"s", (i32, i32, i16)> { + %0 = llvm.mlir.constant(36 : i64) : i64 + %1 = llvm.mul %arg1, %0 overflow : i64 + %2 = llvm.mul %1, %arg2 overflow : i64 + %3 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> !llvm.struct<"s", (i32, i32, i16)> + llvm.return %4 : !llvm.struct<"s", (i32, i32, i16)> + } + llvm.func @test78(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64, %arg3: i32, %arg4: i32, %arg5: i128, %arg6: i128) -> !llvm.struct<"s", (i32, i32, i16)> { + %0 = llvm.mlir.constant(36 : i32) : i32 + %1 = llvm.mul %arg3, %0 overflow : i32 + %2 = llvm.mul %1, %arg4 overflow : i32 + %3 = llvm.sext %2 : i32 to i128 + %4 = llvm.mul %3, %arg5 overflow : i128 + %5 = llvm.mul %4, %arg6 : i128 + %6 = llvm.trunc %5 : i128 to i64 + %7 = llvm.mul %6, %arg1 overflow : i64 + %8 = llvm.mul %7, %arg2 overflow : i64 + %9 = llvm.getelementptr inbounds %arg0[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %10 = llvm.load %9 {alignment = 4 : i64} : !llvm.ptr -> !llvm.struct<"s", (i32, i32, i16)> + llvm.return %10 : !llvm.struct<"s", (i32, i32, i16)> + } + llvm.func @test79(%arg0: !llvm.ptr, %arg1: i64, %arg2: i32) -> !llvm.struct<"s", (i32, i32, i16)> { + %0 = llvm.mlir.constant(36 : i64) : i64 + %1 = llvm.mul %arg1, %0 overflow : i64 + %2 = llvm.trunc %1 : i64 to i32 + %3 = llvm.mul %2, %arg2 : i32 + %4 = llvm.getelementptr inbounds %arg0[%3] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %5 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> !llvm.struct<"s", (i32, i32, i16)> + llvm.return %5 : !llvm.struct<"s", (i32, i32, i16)> + } + llvm.func @test80(%arg0: !llvm.ptr, %arg1: i32) -> f64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.shl %arg1, %0 overflow : i32 + %2 = llvm.getelementptr %arg0[%1] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %3 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> f64 + llvm.return %3 : f64 + } + llvm.func @test80_addrspacecast(%arg0: !llvm.ptr<1>, %arg1: i32) -> f64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.shl %arg1, %0 overflow : i32 + %2 = llvm.addrspacecast %arg0 : !llvm.ptr<1> to !llvm.ptr<2> + %3 = llvm.getelementptr %2[%1] : (!llvm.ptr<2>, i32) -> !llvm.ptr<2>, i8 + %4 = llvm.addrspacecast %3 : !llvm.ptr<2> to !llvm.ptr<1> + %5 = llvm.load %4 {alignment = 8 : i64} : !llvm.ptr<1> -> f64 + llvm.return %5 : f64 + } + llvm.func @test80_addrspacecast_2(%arg0: !llvm.ptr<1>, %arg1: i32) -> f64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.shl %arg1, %0 overflow : i32 + %2 = llvm.addrspacecast %arg0 : !llvm.ptr<1> to !llvm.ptr<2> + %3 = llvm.getelementptr %2[%1] : (!llvm.ptr<2>, i32) -> !llvm.ptr<2>, i8 + %4 = llvm.addrspacecast %3 : !llvm.ptr<2> to !llvm.ptr<3> + %5 = llvm.load %4 {alignment = 8 : i64} : !llvm.ptr<3> -> f64 + llvm.return %5 : f64 + } + llvm.func @test80_as1(%arg0: !llvm.ptr<1>, %arg1: i16) -> f64 { + %0 = llvm.mlir.constant(3 : i16) : i16 + %1 = llvm.shl %arg1, %0 overflow : i16 + %2 = llvm.getelementptr %arg0[%1] : (!llvm.ptr<1>, i16) -> !llvm.ptr<1>, i8 + %3 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr<1> -> f64 + llvm.return %3 : f64 + } + llvm.func @test81(%arg0: !llvm.ptr, %arg1: f32) -> f64 { + %0 = llvm.fptosi %arg1 : f32 to i64 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %2 = llvm.load %1 {alignment = 8 : i64} : !llvm.ptr -> f64 + llvm.return %2 : f64 + } + llvm.func @test82(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.trunc %arg0 : i64 to i32 + %3 = llvm.lshr %2, %0 : i32 + %4 = llvm.shl %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + llvm.return %5 : i64 + } + llvm.func @test83(%arg0: i16, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.sext %arg0 : i16 to i32 + %2 = llvm.add %arg1, %0 overflow : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.shl %1, %3 : i32 + %5 = llvm.zext %4 : i32 to i64 + llvm.return %5 : i64 + } + llvm.func @test84(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(-16777216 : i32) : i32 + %1 = llvm.mlir.constant(23 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + %4 = llvm.trunc %3 : i32 to i8 + llvm.return %4 : i8 + } + llvm.func @test85(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(-16777216 : i32) : i32 + %1 = llvm.mlir.constant(23 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + %4 = llvm.trunc %3 : i32 to i8 + llvm.return %4 : i8 + } + llvm.func @test86(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.sext %arg0 : i16 to i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i16 + llvm.return %3 : i16 + } + llvm.func @test87(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.sext %arg0 : i16 to i32 + %2 = llvm.mul %1, %0 overflow : i32 + %3 = llvm.ashr %2, %0 : i32 + %4 = llvm.trunc %3 : i32 to i16 + llvm.return %4 : i16 + } + llvm.func @test88(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(18 : i32) : i32 + %1 = llvm.sext %arg0 : i16 to i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i16 + llvm.return %3 : i16 + } + llvm.func @PR21388(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "slt" %arg0, %0 : !llvm.ptr + %2 = llvm.sext %1 : i1 to i32 + llvm.return %2 : i32 + } + llvm.func @sitofp_zext(%arg0: i16) -> f32 { + %0 = llvm.zext %arg0 : i16 to i32 + %1 = llvm.sitofp %0 : i32 to f32 + llvm.return %1 : f32 + } + llvm.func @PR23309(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-4 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.sub %1, %arg1 overflow : i32 + %3 = llvm.trunc %2 : i32 to i1 + llvm.return %3 : i1 + } + llvm.func @PR23309v2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-4 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.add %1, %arg1 overflow : i32 + %3 = llvm.trunc %2 : i32 to i1 + llvm.return %3 : i1 + } + llvm.func @PR24763(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i16 + llvm.return %3 : i16 + } + llvm.func @PR28745() -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<1> : vector<1xi32>) : vector<1xi32> + %2 = llvm.bitcast %1 : vector<1xi32> to vector<2xi16> + %3 = llvm.extractelement %2[%0 : i32] : vector<2xi16> + %4 = llvm.mlir.constant(0 : i16) : i16 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.mlir.undef : !llvm.struct<(i32)> + %7 = llvm.insertvalue %5, %6[0] : !llvm.struct<(i32)> + %8 = llvm.mlir.undef : !llvm.struct<(i32)> + %9 = llvm.insertvalue %0, %8[0] : !llvm.struct<(i32)> + %10 = llvm.icmp "eq" %3, %4 : i16 + %11 = llvm.select %10, %7, %9 : i1, !llvm.struct<(i32)> + %12 = llvm.extractvalue %11[0] : !llvm.struct<(i32)> + %13 = llvm.zext %12 : i32 to i64 + llvm.return %13 : i64 + } + llvm.func @test89() -> i32 { + %0 = llvm.mlir.poison : i16 + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.mlir.undef : vector<2xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi16> + %7 = llvm.bitcast %6 : vector<2xi16> to i32 + llvm.return %7 : i32 + } + llvm.func @test90() -> vector<2xi32> { + %0 = llvm.mlir.constant(1.000000e+00 : f16) : f16 + %1 = llvm.mlir.poison : f16 + %2 = llvm.mlir.undef : vector<4xf16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<4xf16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xf16> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xf16> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xf16> + %11 = llvm.bitcast %10 : vector<4xf16> to vector<2xi32> + llvm.return %11 : vector<2xi32> + } + llvm.func @test91(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(48 : i96) : i96 + %1 = llvm.sext %arg0 : i64 to i96 + %2 = llvm.lshr %1, %0 : i96 + %3 = llvm.trunc %2 : i96 to i64 + llvm.return %3 : i64 + } + llvm.func @test92(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(32 : i96) : i96 + %1 = llvm.sext %arg0 : i64 to i96 + %2 = llvm.lshr %1, %0 : i96 + %3 = llvm.trunc %2 : i96 to i64 + llvm.return %3 : i64 + } + llvm.func @test93(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i96) : i96 + %1 = llvm.sext %arg0 : i32 to i96 + %2 = llvm.lshr %1, %0 : i96 + %3 = llvm.trunc %2 : i96 to i32 + llvm.return %3 : i32 + } + llvm.func @trunc_lshr_sext(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_sext_exact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_sext_uniform(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_sext_uniform_poison(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %8 = llvm.lshr %7, %6 : vector<2xi32> + %9 = llvm.trunc %8 : vector<2xi32> to vector<2xi8> + llvm.return %9 : vector<2xi8> + } + llvm.func @trunc_lshr_sext_nonuniform(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[6, 2]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_sext_nonuniform_poison(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(6 : i32) : i32 + %3 = llvm.mlir.undef : vector<3xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi32> + %10 = llvm.sext %arg0 : vector<3xi8> to vector<3xi32> + %11 = llvm.lshr %10, %9 : vector<3xi32> + %12 = llvm.trunc %11 : vector<3xi32> to vector<3xi8> + llvm.return %12 : vector<3xi8> + } + llvm.func @trunc_lshr_sext_uses1(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + llvm.call @use_v2i32(%1) : (vector<2xi32>) -> () + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_sext_uses2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.call @use_i32(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_sext_uses3(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + llvm.call @use_v2i32(%1) : (vector<2xi32>) -> () + %2 = llvm.lshr %1, %0 : vector<2xi32> + llvm.call @use_v2i32(%2) : (vector<2xi32>) -> () + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_overshift_sext(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_overshift_sext_uses1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + llvm.call @use_i32(%1) : (i32) -> () + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_overshift_sext_uses2(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + llvm.call @use_v2i32(%2) : (vector<2xi32>) -> () + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_overshift_sext_uses3(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + llvm.call @use_i32(%1) : (i32) -> () + %2 = llvm.lshr %1, %0 : i32 + llvm.call @use_i32(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_sext_wide_input(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.sext %arg0 : i16 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_sext_wide_input_exact(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.sext %arg0 : i16 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_sext_wide_input_uses1(%arg0: vector<2xi16>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<9> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi16> to vector<2xi32> + llvm.call @use_v2i32(%1) : (vector<2xi32>) -> () + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_sext_wide_input_uses2(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.sext %arg0 : i16 to i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.call @use_i32(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_sext_wide_input_uses3(%arg0: vector<2xi16>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<9> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi16> to vector<2xi32> + llvm.call @use_v2i32(%1) : (vector<2xi32>) -> () + %2 = llvm.lshr %1, %0 : vector<2xi32> + llvm.call @use_v2i32(%2) : (vector<2xi32>) -> () + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_overshift_wide_input_sext(%arg0: vector<2xi16>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi16> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_overshift_sext_wide_input_uses1(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.sext %arg0 : i16 to i32 + llvm.call @use_i32(%1) : (i32) -> () + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_overshift_sext_wide_input_uses2(%arg0: vector<2xi16>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi16> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + llvm.call @use_v2i32(%2) : (vector<2xi32>) -> () + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_overshift_sext_wide_input_uses3(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.sext %arg0 : i16 to i32 + llvm.call @use_i32(%1) : (i32) -> () + %2 = llvm.lshr %1, %0 : i32 + llvm.call @use_i32(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_sext_narrow_input(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i16 + llvm.return %3 : i16 + } + llvm.func @trunc_lshr_sext_narrow_input_uses1(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + llvm.call @use_v2i32(%1) : (vector<2xi32>) -> () + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @trunc_lshr_sext_narrow_input_uses2(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.call @use_i32(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i16 + llvm.return %3 : i16 + } + llvm.func @trunc_lshr_sext_narrow_input_uses3(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + llvm.call @use_v2i32(%1) : (vector<2xi32>) -> () + %2 = llvm.lshr %1, %0 : vector<2xi32> + llvm.call @use_v2i32(%2) : (vector<2xi32>) -> () + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @trunc_lshr_overshift_narrow_input_sext(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @trunc_lshr_overshift_sext_narrow_input_uses1(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + llvm.call @use_i32(%1) : (i32) -> () + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i16 + llvm.return %3 : i16 + } + llvm.func @trunc_lshr_overshift_sext_narrow_input_uses2(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + llvm.call @use_v2i32(%2) : (vector<2xi32>) -> () + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @trunc_lshr_overshift_sext_narrow_input_uses3(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + llvm.call @use_i32(%1) : (i32) -> () + %2 = llvm.lshr %1, %0 : i32 + llvm.call @use_i32(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i16 + llvm.return %3 : i16 + } + llvm.func @trunc_lshr_overshift2_sext(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<25> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_overshift2_sext_uses1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(25 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + llvm.call @use_i32(%1) : (i32) -> () + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_overshift2_sext_uses2(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<25> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + llvm.call @use_v2i32(%2) : (vector<2xi32>) -> () + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_overshift2_sext_uses3(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(25 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + llvm.call @use_i32(%1) : (i32) -> () + %2 = llvm.lshr %1, %0 : i32 + llvm.call @use_i32(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_zext(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_zext_exact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_zext_uniform(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_zext_uniform_poison(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + %8 = llvm.lshr %7, %6 : vector<2xi32> + %9 = llvm.trunc %8 : vector<2xi32> to vector<2xi8> + llvm.return %9 : vector<2xi8> + } + llvm.func @trunc_lshr_zext_nonuniform(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[6, 2]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_zext_nonuniform_poison(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(6 : i32) : i32 + %3 = llvm.mlir.undef : vector<3xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi32> + %10 = llvm.zext %arg0 : vector<3xi8> to vector<3xi32> + %11 = llvm.lshr %10, %9 : vector<3xi32> + %12 = llvm.trunc %11 : vector<3xi32> to vector<3xi8> + llvm.return %12 : vector<3xi8> + } + llvm.func @trunc_lshr_zext_uses1(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + llvm.call @use_v2i32(%1) : (vector<2xi32>) -> () + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @pr33078_1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.sext %arg0 : i8 to i16 + %2 = llvm.lshr %1, %0 : i16 + %3 = llvm.trunc %2 : i16 to i8 + llvm.return %3 : i8 + } + llvm.func @pr33078_2(%arg0: i8) -> i12 { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = llvm.sext %arg0 : i8 to i16 + %2 = llvm.lshr %1, %0 : i16 + %3 = llvm.trunc %2 : i16 to i12 + llvm.return %3 : i12 + } + llvm.func @pr33078_3(%arg0: i8) -> i4 { + %0 = llvm.mlir.constant(12 : i16) : i16 + %1 = llvm.sext %arg0 : i8 to i16 + %2 = llvm.lshr %1, %0 : i16 + %3 = llvm.trunc %2 : i16 to i4 + llvm.return %3 : i4 + } + llvm.func @pr33078_4(%arg0: i3) -> i8 { + %0 = llvm.mlir.constant(13 : i16) : i16 + %1 = llvm.sext %arg0 : i3 to i16 + %2 = llvm.lshr %1, %0 : i16 + %3 = llvm.trunc %2 : i16 to i8 + llvm.return %3 : i8 + } + llvm.func @test94(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.sext %2 : i1 to i8 + %4 = llvm.xor %3, %1 : i8 + %5 = llvm.sext %4 : i8 to i64 + llvm.return %5 : i64 + } + llvm.func @test95(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(40 : i8) : i8 + %3 = llvm.trunc %arg0 : i32 to i8 + %4 = llvm.lshr %3, %0 : i8 + %5 = llvm.and %4, %1 : i8 + %6 = llvm.or %5, %2 : i8 + %7 = llvm.zext %6 : i8 to i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/cast_phi.ll.mlir b/test/LLVMDialect/InstCombine/cast_phi.ll.mlir index f95f18d35..ea350ca04 100644 --- a/test/LLVMDialect/InstCombine/cast_phi.ll.mlir +++ b/test/LLVMDialect/InstCombine/cast_phi.ll.mlir @@ -1,192 +1,178 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0.000000e+00 : f32} : () -> f32 - %2 = "llvm.mlir.constant"() {value = 256 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %6 = "llvm.alloca"(%5) : (i32) -> !llvm.ptr> - %7 = "llvm.alloca"(%5) : (i32) -> !llvm.ptr> - %8 = "llvm.uitofp"(%arg0) : (i32) -> f32 - %9 = "llvm.bitcast"(%8) : (f32) -> i32 - %10 = "llvm.zext"(%arg1) : (i32) -> i64 - %11 = "llvm.getelementptr"(%6, %4, %10) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %12 = "llvm.bitcast"(%11) : (!llvm.ptr) -> !llvm.ptr - "llvm.store"(%9, %12) : (i32, !llvm.ptr) -> () - %13 = "llvm.getelementptr"(%7, %4, %10) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %14 = "llvm.bitcast"(%13) : (!llvm.ptr) -> !llvm.ptr - "llvm.store"(%9, %14) : (i32, !llvm.ptr) -> () - %15 = "llvm.icmp"(%arg1, %3) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%15)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @MainKernel(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(256 : i64) : i64 + %4 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %5 = llvm.mlir.constant(-4 : i32) : i32 + %6 = llvm.alloca %0 x !llvm.array<258 x f32> {alignment = 4 : i64} : (i32) -> !llvm.ptr + %7 = llvm.alloca %0 x !llvm.array<258 x f32> {alignment = 4 : i64} : (i32) -> !llvm.ptr + %8 = llvm.uitofp %arg0 : i32 to f32 + %9 = llvm.bitcast %8 : f32 to i32 + %10 = llvm.zext %arg1 : i32 to i64 + %11 = llvm.getelementptr inbounds %6[%1, %10] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<258 x f32> + llvm.store %9, %11 {alignment = 4 : i64} : i32, !llvm.ptr + %12 = llvm.getelementptr inbounds %7[%1, %10] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<258 x f32> + llvm.store %9, %12 {alignment = 4 : i64} : i32, !llvm.ptr + %13 = llvm.icmp "eq" %arg1, %2 : i32 + llvm.cond_br %13, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %16 = "llvm.getelementptr"(%6, %4, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - "llvm.store"(%8, %16) : (f32, !llvm.ptr) -> () - %17 = "llvm.getelementptr"(%7, %4, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - "llvm.store"(%1, %17) : (f32, !llvm.ptr) -> () - "llvm.br"()[^bb2] : () -> () + %14 = llvm.getelementptr inbounds %6[%1, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<258 x f32> + llvm.store %8, %14 {alignment = 4 : i64} : f32, !llvm.ptr + %15 = llvm.getelementptr inbounds %7[%1, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<258 x f32> + llvm.store %4, %15 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.br ^bb2 ^bb2: // 2 preds: ^bb0, ^bb1 - %18 = "llvm.icmp"(%arg0, %3) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%18, %9, %9, %arg0)[^bb3, ^bb8] {operand_segment_sizes = dense<[1, 3, 0]> : vector<3xi32>} : (i1, i32, i32, i32) -> () - ^bb3(%19: i32, %20: i32, %21: i32): // 2 preds: ^bb2, ^bb12 - %22 = "llvm.icmp"(%21, %arg2) {predicate = 8 : i64} : (i32, i32) -> i1 - %23 = "llvm.add"(%21, %5) : (i32, i32) -> i32 - %24 = "llvm.sext"(%23) : (i32) -> i64 - %25 = "llvm.getelementptr"(%6, %4, %24) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %26 = "llvm.bitcast"(%25) : (!llvm.ptr) -> !llvm.ptr - %27 = "llvm.getelementptr"(%7, %4, %24) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %28 = "llvm.bitcast"(%27) : (!llvm.ptr) -> !llvm.ptr - %29 = "llvm.icmp"(%21, %arg2) {predicate = 6 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%22, %19, %20)[^bb4, ^bb5] {operand_segment_sizes = dense<[1, 0, 2]> : vector<3xi32>} : (i1, i32, i32) -> () + %16 = llvm.icmp "sgt" %arg0, %2 : i32 + llvm.cond_br %16, ^bb3(%9, %9, %arg0 : i32, i32, i32), ^bb8 + ^bb3(%17: i32, %18: i32, %19: i32): // 2 preds: ^bb2, ^bb12 + %20 = llvm.icmp "ugt" %19, %arg2 : i32 + %21 = llvm.add %19, %0 : i32 + %22 = llvm.sext %21 : i32 to i64 + %23 = llvm.getelementptr inbounds %6[%1, %22] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<258 x f32> + %24 = llvm.getelementptr inbounds %7[%1, %22] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<258 x f32> + %25 = llvm.icmp "ult" %19, %arg2 : i32 + llvm.cond_br %20, ^bb4, ^bb5(%17, %18 : i32, i32) ^bb4: // pred: ^bb3 - %30 = "llvm.load"(%26) : (!llvm.ptr) -> i32 - %31 = "llvm.load"(%28) : (!llvm.ptr) -> i32 - %32 = "llvm.bitcast"(%31) : (i32) -> f32 - %33 = "llvm.bitcast"(%30) : (i32) -> f32 - %34 = "llvm.fadd"(%32, %33) : (f32, f32) -> f32 - %35 = "llvm.bitcast"(%19) : (i32) -> f32 - %36 = "llvm.fadd"(%34, %35) : (f32, f32) -> f32 - %37 = "llvm.bitcast"(%36) : (f32) -> i32 - %38 = "llvm.bitcast"(%20) : (i32) -> f32 - %39 = "llvm.fadd"(%36, %38) : (f32, f32) -> f32 - %40 = "llvm.bitcast"(%39) : (f32) -> i32 - "llvm.br"(%37, %40)[^bb5] : (i32, i32) -> () - ^bb5(%41: i32, %42: i32): // 2 preds: ^bb3, ^bb4 - "llvm.cond_br"(%29)[^bb6, ^bb7] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %26 = llvm.load %23 {alignment = 4 : i64} : !llvm.ptr -> i32 + %27 = llvm.load %24 {alignment = 4 : i64} : !llvm.ptr -> i32 + %28 = llvm.bitcast %27 : i32 to f32 + %29 = llvm.bitcast %26 : i32 to f32 + %30 = llvm.fadd %28, %29 : f32 + %31 = llvm.bitcast %17 : i32 to f32 + %32 = llvm.fadd %30, %31 : f32 + %33 = llvm.bitcast %32 : f32 to i32 + %34 = llvm.bitcast %18 : i32 to f32 + %35 = llvm.fadd %32, %34 : f32 + %36 = llvm.bitcast %35 : f32 to i32 + llvm.br ^bb5(%33, %36 : i32, i32) + ^bb5(%37: i32, %38: i32): // 2 preds: ^bb3, ^bb4 + llvm.cond_br %25, ^bb6, ^bb7 ^bb6: // pred: ^bb5 - "llvm.store"(%42, %12) : (i32, !llvm.ptr) -> () - "llvm.store"(%41, %14) : (i32, !llvm.ptr) -> () - "llvm.br"()[^bb7] : () -> () + llvm.store %38, %11 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %37, %12 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb7 ^bb7: // 2 preds: ^bb5, ^bb6 - "llvm.cond_br"(%22, %41, %42)[^bb9, ^bb10] {operand_segment_sizes = dense<[1, 0, 2]> : vector<3xi32>} : (i1, i32, i32) -> () + llvm.cond_br %20, ^bb9, ^bb10(%37, %38 : i32, i32) ^bb8: // 2 preds: ^bb2, ^bb12 - "llvm.return"() : () -> () + llvm.return ^bb9: // pred: ^bb7 - %43 = "llvm.load"(%26) : (!llvm.ptr) -> i32 - %44 = "llvm.load"(%28) : (!llvm.ptr) -> i32 - %45 = "llvm.bitcast"(%44) : (i32) -> f32 - %46 = "llvm.bitcast"(%43) : (i32) -> f32 - %47 = "llvm.fadd"(%45, %46) : (f32, f32) -> f32 - %48 = "llvm.bitcast"(%41) : (i32) -> f32 - %49 = "llvm.fadd"(%47, %48) : (f32, f32) -> f32 - %50 = "llvm.bitcast"(%49) : (f32) -> i32 - %51 = "llvm.bitcast"(%42) : (i32) -> f32 - %52 = "llvm.fadd"(%49, %51) : (f32, f32) -> f32 - %53 = "llvm.bitcast"(%52) : (f32) -> i32 - "llvm.br"(%50, %53)[^bb10] : (i32, i32) -> () - ^bb10(%54: i32, %55: i32): // 2 preds: ^bb7, ^bb9 - "llvm.cond_br"(%29)[^bb11, ^bb12] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %39 = llvm.load %23 {alignment = 4 : i64} : !llvm.ptr -> i32 + %40 = llvm.load %24 {alignment = 4 : i64} : !llvm.ptr -> i32 + %41 = llvm.bitcast %40 : i32 to f32 + %42 = llvm.bitcast %39 : i32 to f32 + %43 = llvm.fadd %41, %42 : f32 + %44 = llvm.bitcast %37 : i32 to f32 + %45 = llvm.fadd %43, %44 : f32 + %46 = llvm.bitcast %45 : f32 to i32 + %47 = llvm.bitcast %38 : i32 to f32 + %48 = llvm.fadd %45, %47 : f32 + %49 = llvm.bitcast %48 : f32 to i32 + llvm.br ^bb10(%46, %49 : i32, i32) + ^bb10(%50: i32, %51: i32): // 2 preds: ^bb7, ^bb9 + llvm.cond_br %25, ^bb11, ^bb12 ^bb11: // pred: ^bb10 - "llvm.store"(%55, %12) : (i32, !llvm.ptr) -> () - "llvm.store"(%54, %14) : (i32, !llvm.ptr) -> () - "llvm.br"()[^bb12] : () -> () + llvm.store %51, %11 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %50, %12 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb12 ^bb12: // 2 preds: ^bb10, ^bb11 - %56 = "llvm.add"(%21, %0) : (i32, i32) -> i32 - %57 = "llvm.icmp"(%56, %3) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%57, %54, %55, %56)[^bb3, ^bb8] {operand_segment_sizes = dense<[1, 3, 0]> : vector<3xi32>} : (i1, i32, i32, i32) -> () - }) {linkage = 10 : i64, sym_name = "MainKernel", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "get_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "get_i3", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %2 = "llvm.icmp"(%arg0, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %52 = llvm.add %19, %5 : i32 + %53 = llvm.icmp "sgt" %52, %2 : i32 + llvm.cond_br %53, ^bb3(%50, %51, %52 : i32, i32, i32), ^bb8 + } + llvm.func @get_i32() -> i32 + llvm.func @get_i3() -> i3 + llvm.func @bar() + llvm.func @zext_from_legal_to_illegal_type(%arg0: i32) -> i37 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + llvm.cond_br %2, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %3 = "llvm.call"() {callee = @get_i32, fastmathFlags = #llvm.fastmath<>} : () -> i32 - "llvm.br"(%3)[^bb3] : (i32) -> () + %3 = llvm.call @get_i32() : () -> i32 + llvm.br ^bb3(%3 : i32) ^bb2: // pred: ^bb0 - "llvm.call"() {callee = @bar, fastmathFlags = #llvm.fastmath<>} : () -> () - "llvm.br"(%0)[^bb3] : (i32) -> () + llvm.call @bar() : () -> () + llvm.br ^bb3(%1 : i32) ^bb3(%4: i32): // 2 preds: ^bb1, ^bb2 - %5 = "llvm.zext"(%4) : (i32) -> i37 - "llvm.return"(%5) : (i37) -> () - }) {linkage = 10 : i64, sym_name = "zext_from_legal_to_illegal_type", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i3} : () -> i3 - %1 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %2 = "llvm.icmp"(%arg0, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %5 = llvm.zext %4 : i32 to i37 + llvm.return %5 : i37 + } + llvm.func @zext_from_illegal_to_illegal_type(%arg0: i32) -> i37 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(3 : i3) : i3 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + llvm.cond_br %2, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %3 = "llvm.call"() {callee = @get_i3, fastmathFlags = #llvm.fastmath<>} : () -> i3 - "llvm.br"(%3)[^bb3] : (i3) -> () + %3 = llvm.call @get_i3() : () -> i3 + llvm.br ^bb3(%3 : i3) ^bb2: // pred: ^bb0 - "llvm.call"() {callee = @bar, fastmathFlags = #llvm.fastmath<>} : () -> () - "llvm.br"(%0)[^bb3] : (i3) -> () + llvm.call @bar() : () -> () + llvm.br ^bb3(%1 : i3) ^bb3(%4: i3): // 2 preds: ^bb1, ^bb2 - %5 = "llvm.zext"(%4) : (i3) -> i37 - "llvm.return"(%5) : (i37) -> () - }) {linkage = 10 : i64, sym_name = "zext_from_illegal_to_illegal_type", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %2 = "llvm.icmp"(%arg0, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %5 = llvm.zext %4 : i3 to i37 + llvm.return %5 : i37 + } + llvm.func @zext_from_legal_to_legal_type(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + llvm.cond_br %2, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %3 = "llvm.call"() {callee = @get_i32, fastmathFlags = #llvm.fastmath<>} : () -> i32 - "llvm.br"(%3)[^bb3] : (i32) -> () + %3 = llvm.call @get_i32() : () -> i32 + llvm.br ^bb3(%3 : i32) ^bb2: // pred: ^bb0 - "llvm.call"() {callee = @bar, fastmathFlags = #llvm.fastmath<>} : () -> () - "llvm.br"(%0)[^bb3] : (i32) -> () + llvm.call @bar() : () -> () + llvm.br ^bb3(%1 : i32) ^bb3(%4: i32): // 2 preds: ^bb1, ^bb2 - %5 = "llvm.zext"(%4) : (i32) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "zext_from_legal_to_legal_type", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i3} : () -> i3 - %1 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %2 = "llvm.icmp"(%arg0, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %5 = llvm.zext %4 : i32 to i64 + llvm.return %5 : i64 + } + llvm.func @zext_from_illegal_to_legal_type(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(3 : i3) : i3 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + llvm.cond_br %2, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %3 = "llvm.call"() {callee = @get_i3, fastmathFlags = #llvm.fastmath<>} : () -> i3 - "llvm.br"(%3)[^bb3] : (i3) -> () + %3 = llvm.call @get_i3() : () -> i3 + llvm.br ^bb3(%3 : i3) ^bb2: // pred: ^bb0 - "llvm.call"() {callee = @bar, fastmathFlags = #llvm.fastmath<>} : () -> () - "llvm.br"(%0)[^bb3] : (i3) -> () + llvm.call @bar() : () -> () + llvm.br ^bb3(%1 : i3) ^bb3(%4: i3): // 2 preds: ^bb1, ^bb2 - %5 = "llvm.zext"(%4) : (i3) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "zext_from_illegal_to_legal_type", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.br"(%2, %1)[^bb1] : (i32, i32) -> () + %5 = llvm.zext %4 : i3 to i64 + llvm.return %5 : i64 + } + llvm.func @trunc_in_loop_exit_block() -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(100 : i32) : i32 + llvm.br ^bb1(%0, %1 : i32, i32) ^bb1(%3: i32, %4: i32): // 2 preds: ^bb0, ^bb2 - %5 = "llvm.icmp"(%3, %0) {predicate = 6 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%5)[^bb2, ^bb3] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %5 = llvm.icmp "ult" %3, %2 : i32 + llvm.cond_br %5, ^bb2, ^bb3 ^bb2: // pred: ^bb1 - %6 = "llvm.add"(%3, %1) : (i32, i32) -> i32 - "llvm.br"(%6, %6)[^bb1] : (i32, i32) -> () + %6 = llvm.add %3, %1 : i32 + llvm.br ^bb1(%6, %6 : i32, i32) ^bb3: // pred: ^bb1 - %7 = "llvm.trunc"(%4) : (i32) -> i8 - "llvm.return"(%7) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "trunc_in_loop_exit_block", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - "llvm.br"(%0)[^bb1] : (i8) -> () + %7 = llvm.trunc %4 : i32 to i8 + llvm.return %7 : i8 + } + llvm.func @zext_in_loop_and_exit_block(%arg0: i8, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.br ^bb1(%0 : i8) ^bb1(%1: i8): // 2 preds: ^bb0, ^bb2 - %2 = "llvm.zext"(%1) : (i8) -> i32 - %3 = "llvm.icmp"(%2, %arg1) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%3)[^bb2, ^bb3] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %2 = llvm.zext %1 : i8 to i32 + %3 = llvm.icmp "ne" %2, %arg1 : i32 + llvm.cond_br %3, ^bb2, ^bb3 ^bb2: // pred: ^bb1 - %4 = "llvm.zext"(%arg0) : (i8) -> i32 - %5 = "llvm.add"(%2, %4) : (i32, i32) -> i32 - %6 = "llvm.trunc"(%5) : (i32) -> i8 - "llvm.br"(%6)[^bb1] : (i8) -> () + %4 = llvm.zext %arg0 : i8 to i32 + %5 = llvm.add %2, %4 : i32 + %6 = llvm.trunc %5 : i32 to i8 + llvm.br ^bb1(%6 : i8) ^bb3: // pred: ^bb1 - %7 = "llvm.zext"(%1) : (i8) -> i32 - "llvm.return"(%7) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "zext_in_loop_and_exit_block", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %7 = llvm.zext %1 : i8 to i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/cast_ptr.ll.mlir b/test/LLVMDialect/InstCombine/cast_ptr.ll.mlir new file mode 100644 index 000000000..a1191fa32 --- /dev/null +++ b/test/LLVMDialect/InstCombine/cast_ptr.ll.mlir @@ -0,0 +1,208 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry, dense<16> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @global(0 : i8) {addr_space = 0 : i32} : i8 + llvm.mlir.global internal constant @Array() {addr_space = 0 : i32, dso_local} : !llvm.array<1 x ptr> { + %0 = llvm.mlir.addressof @foo : !llvm.ptr + %1 = llvm.mlir.undef : !llvm.array<1 x ptr> + %2 = llvm.insertvalue %0, %1[0] : !llvm.array<1 x ptr> + llvm.return %2 : !llvm.array<1 x ptr> + } + llvm.func @test1(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.ptrtoint %arg0 : !llvm.ptr to i32 + %2 = llvm.add %1, %0 : i32 + %3 = llvm.inttoptr %2 : i32 to !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @test2(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.ptrtoint %arg0 : !llvm.ptr to i32 + %1 = llvm.ptrtoint %arg1 : !llvm.ptr to i32 + %2 = llvm.icmp "eq" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @test2_as2_same_int(%arg0: !llvm.ptr<2>, %arg1: !llvm.ptr<2>) -> i1 { + %0 = llvm.ptrtoint %arg0 : !llvm.ptr<2> to i16 + %1 = llvm.ptrtoint %arg1 : !llvm.ptr<2> to i16 + %2 = llvm.icmp "eq" %0, %1 : i16 + llvm.return %2 : i1 + } + llvm.func @test2_as2_larger(%arg0: !llvm.ptr<2>, %arg1: !llvm.ptr<2>) -> i1 { + %0 = llvm.ptrtoint %arg0 : !llvm.ptr<2> to i32 + %1 = llvm.ptrtoint %arg1 : !llvm.ptr<2> to i32 + %2 = llvm.icmp "eq" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @test2_diff_as(%arg0: !llvm.ptr, %arg1: !llvm.ptr<1>) -> i1 { + %0 = llvm.ptrtoint %arg0 : !llvm.ptr to i32 + %1 = llvm.ptrtoint %arg1 : !llvm.ptr<1> to i32 + %2 = llvm.icmp "sge" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @test2_diff_as_global(%arg0: !llvm.ptr<1>) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.addressof @global : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.ptrtoint %arg0 : !llvm.ptr<1> to i32 + %4 = llvm.icmp "sge" %3, %2 : i32 + llvm.return %4 : i1 + } + llvm.func @test3(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.addressof @global : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.ptrtoint %arg0 : !llvm.ptr to i32 + %4 = llvm.icmp "eq" %3, %2 : i32 + llvm.return %4 : i1 + } + llvm.func @test4(%arg0: i32) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.inttoptr %arg0 : i32 to !llvm.ptr + %2 = llvm.icmp "eq" %1, %0 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @test4_as2(%arg0: i16) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr<2> + %1 = llvm.inttoptr %arg0 : i16 to !llvm.ptr<2> + %2 = llvm.icmp "eq" %1, %0 : !llvm.ptr<2> + llvm.return %2 : i1 + } + llvm.func @foo(!llvm.ptr) -> !llvm.ptr + llvm.func @test5(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.addressof @foo : !llvm.ptr + %1 = llvm.mlir.undef : !llvm.array<1 x ptr> + %2 = llvm.insertvalue %0, %1[0] : !llvm.array<1 x ptr> + %3 = llvm.mlir.addressof @Array : !llvm.ptr + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.call %4(%arg0) : !llvm.ptr, (!llvm.ptr) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @test6(%arg0: !llvm.ptr<1>) -> i8 { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr<1> to !llvm.ptr + %1 = llvm.load %0 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %1 : i8 + } + llvm.func @insertelt(%arg0: vector<2xi32>, %arg1: !llvm.ptr, %arg2: i133) -> vector<2xi32> { + %0 = llvm.inttoptr %arg0 : vector<2xi32> to !llvm.vec<2 x ptr> + %1 = llvm.insertelement %arg1, %0[%arg2 : i133] : !llvm.vec<2 x ptr> + %2 = llvm.ptrtoint %1 : !llvm.vec<2 x ptr> to vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @insertelt_intptr_trunc(%arg0: vector<2xi64>, %arg1: !llvm.ptr) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.inttoptr %arg0 : vector<2xi64> to !llvm.vec<2 x ptr> + %2 = llvm.insertelement %arg1, %1[%0 : i32] : !llvm.vec<2 x ptr> + %3 = llvm.ptrtoint %2 : !llvm.vec<2 x ptr> to vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @insertelt_intptr_zext(%arg0: vector<2xi8>, %arg1: !llvm.ptr) -> vector<2xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.inttoptr %arg0 : vector<2xi8> to !llvm.vec<2 x ptr> + %2 = llvm.insertelement %arg1, %1[%0 : i32] : !llvm.vec<2 x ptr> + %3 = llvm.ptrtoint %2 : !llvm.vec<2 x ptr> to vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @insertelt_intptr_zext_zext(%arg0: vector<2xi8>, %arg1: !llvm.ptr) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.inttoptr %arg0 : vector<2xi8> to !llvm.vec<2 x ptr> + %2 = llvm.insertelement %arg1, %1[%0 : i32] : !llvm.vec<2 x ptr> + %3 = llvm.ptrtoint %2 : !llvm.vec<2 x ptr> to vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @use(!llvm.vec<2 x ptr>) + llvm.func @insertelt_extra_use1(%arg0: vector<2xi32>, %arg1: !llvm.ptr) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.inttoptr %arg0 : vector<2xi32> to !llvm.vec<2 x ptr> + llvm.call @use(%1) : (!llvm.vec<2 x ptr>) -> () + %2 = llvm.insertelement %arg1, %1[%0 : i32] : !llvm.vec<2 x ptr> + %3 = llvm.ptrtoint %2 : !llvm.vec<2 x ptr> to vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @insertelt_extra_use2(%arg0: vector<2xi32>, %arg1: !llvm.ptr) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.inttoptr %arg0 : vector<2xi32> to !llvm.vec<2 x ptr> + %2 = llvm.insertelement %arg1, %1[%0 : i32] : !llvm.vec<2 x ptr> + llvm.call @use(%2) : (!llvm.vec<2 x ptr>) -> () + %3 = llvm.ptrtoint %2 : !llvm.vec<2 x ptr> to vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @ptr_add_in_int(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.inttoptr %arg0 : i32 to !llvm.ptr + %1 = llvm.getelementptr inbounds %0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + llvm.return %2 : i32 + } + llvm.func @ptr_add_in_int_2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.inttoptr %arg0 : i32 to !llvm.ptr + %1 = llvm.getelementptr inbounds %0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + llvm.return %2 : i32 + } + llvm.func @ptr_add_in_int_nneg(%arg0: i32, %arg1: i32) -> i32 { + %0 = "llvm.intr.abs"(%arg1) <{is_int_min_poison = true}> : (i32) -> i32 + %1 = llvm.inttoptr %arg0 : i32 to !llvm.ptr + %2 = llvm.getelementptr inbounds %1[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %3 = llvm.ptrtoint %2 : !llvm.ptr to i32 + llvm.return %3 : i32 + } + llvm.func @ptr_add_in_int_different_type_1(%arg0: i32, %arg1: i32) -> i64 { + %0 = llvm.inttoptr %arg0 : i32 to !llvm.ptr + %1 = llvm.getelementptr %0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %2 = llvm.ptrtoint %1 : !llvm.ptr to i64 + llvm.return %2 : i64 + } + llvm.func @ptr_add_in_int_different_type_2(%arg0: i32, %arg1: i32) -> i16 { + %0 = llvm.inttoptr %arg0 : i32 to !llvm.ptr + %1 = llvm.getelementptr %0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %2 = llvm.ptrtoint %1 : !llvm.ptr to i16 + llvm.return %2 : i16 + } + llvm.func @ptr_add_in_int_different_type_3(%arg0: i16, %arg1: i32) -> i32 { + %0 = llvm.inttoptr %arg0 : i16 to !llvm.ptr + %1 = llvm.getelementptr %0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + llvm.return %2 : i32 + } + llvm.func @ptr_add_in_int_different_type_4(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.inttoptr %arg0 : i64 to !llvm.ptr + %1 = llvm.getelementptr %0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + llvm.return %2 : i32 + } + llvm.func @ptr_add_in_int_not_inbounds(%arg0: i32, %arg1: i32) -> i32 { + %0 = "llvm.intr.abs"(%arg1) <{is_int_min_poison = true}> : (i32) -> i32 + %1 = llvm.inttoptr %arg0 : i32 to !llvm.ptr + %2 = llvm.getelementptr %1[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %3 = llvm.ptrtoint %2 : !llvm.ptr to i32 + llvm.return %3 : i32 + } + llvm.func @ptr_add_in_int_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.inttoptr %arg0 : i32 to !llvm.ptr + %2 = llvm.getelementptr inbounds %1[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %3 = llvm.ptrtoint %2 : !llvm.ptr to i32 + llvm.return %3 : i32 + } + llvm.func @ptr_add_in_int_const_negative(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-4096 : i32) : i32 + %1 = llvm.inttoptr %arg0 : i32 to !llvm.ptr + %2 = llvm.getelementptr inbounds %1[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %3 = llvm.ptrtoint %2 : !llvm.ptr to i32 + llvm.return %3 : i32 + } + llvm.func @use_ptr(!llvm.ptr) + llvm.func @ptr_add_in_int_extra_use1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.inttoptr %arg0 : i32 to !llvm.ptr + llvm.call @use_ptr(%1) : (!llvm.ptr) -> () + %2 = llvm.getelementptr inbounds %1[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %3 = llvm.ptrtoint %2 : !llvm.ptr to i32 + llvm.return %3 : i32 + } + llvm.func @ptr_add_in_int_extra_use2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.inttoptr %arg0 : i32 to !llvm.ptr + %2 = llvm.getelementptr inbounds %1[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + llvm.call @use_ptr(%2) : (!llvm.ptr) -> () + %3 = llvm.ptrtoint %2 : !llvm.ptr to i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/catchswitch-phi.ll.mlir b/test/LLVMDialect/InstCombine/catchswitch-phi.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/ceil.ll.mlir b/test/LLVMDialect/InstCombine/ceil.ll.mlir index d2603492c..c2c3f9ee0 100644 --- a/test/LLVMDialect/InstCombine/ceil.ll.mlir +++ b/test/LLVMDialect/InstCombine/ceil.ll.mlir @@ -1,44 +1,37 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ceil.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ceil.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ceil.v4f32", type = !llvm.func (vector<4xf32>)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f32} : () -> f32 - %1 = "llvm.call"(%0) {callee = @llvm.ceil.f32, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_ceil_f32_01", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1.250000e+00 : f32} : () -> f32 - %1 = "llvm.call"(%0) {callee = @llvm.ceil.f32, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_ceil_f32_02", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = -1.250000e+00 : f32} : () -> f32 - %1 = "llvm.call"(%0) {callee = @llvm.ceil.f32, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_ceil_f32_03", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 1.250000e+00, -1.250000e+00, -1.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.call"(%0) {callee = @llvm.ceil.v4f32, fastmathFlags = #llvm.fastmath<>} : (vector<4xf32>) -> vector<4xf32> - "llvm.return"(%1) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_ceil_v4f32_01", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.ceil.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_ceil_f64_01", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1.300000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.ceil.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_ceil_f64_02", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = -1.750000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.ceil.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_ceil_f64_03", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @constant_fold_ceil_f32_01() -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.ceil(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_ceil_f32_02() -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1.250000e+00 : f32) : f32 + %1 = llvm.intr.ceil(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_ceil_f32_03() -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-1.250000e+00 : f32) : f32 + %1 = llvm.intr.ceil(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_ceil_v4f32_01() -> vector<4xf32> attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 1.250000e+00, -1.250000e+00, -1.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.intr.ceil(%0) : (vector<4xf32>) -> vector<4xf32> + llvm.return %1 : vector<4xf32> + } + llvm.func @constant_fold_ceil_f64_01() -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.intr.ceil(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @constant_fold_ceil_f64_02() -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1.300000e+00 : f64) : f64 + %1 = llvm.intr.ceil(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @constant_fold_ceil_f64_03() -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-1.750000e+00 : f64) : f64 + %1 = llvm.intr.ceil(%0) : (f64) -> f64 + llvm.return %1 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/clamp-to-minmax.ll.mlir b/test/LLVMDialect/InstCombine/clamp-to-minmax.ll.mlir new file mode 100644 index 000000000..338389ec1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/clamp-to-minmax.ll.mlir @@ -0,0 +1,342 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @clamp_float_fast_ordered_strict_maxmin(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "olt" %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_fast_ordered_nonstrict_maxmin(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ole" %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_fast_ordered_strict_minmax(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %2 = llvm.fcmp "ogt" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ogt" %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_fast_ordered_nonstrict_minmax(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %2 = llvm.fcmp "ogt" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "oge" %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_fast_unordered_strict_maxmin(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ult" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ult" %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_fast_unordered_nonstrict_maxmin(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ult" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ule" %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_fast_unordered_strict_minmax(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %2 = llvm.fcmp "ugt" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ugt" %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_fast_unordered_nonstrict_minmax(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %2 = llvm.fcmp "ugt" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "uge" %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_test_1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ult" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ugt" %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.select %4, %3, %1 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_negative_wrong_const(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(5.120000e+02 : f32) : f32 + %2 = llvm.fcmp "ult" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ugt" %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.select %4, %3, %1 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_negative_same_op(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ult" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ult" %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.select %4, %3, %1 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_with_zero1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ole" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_with_zero2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "olt" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_ordered_strict_maxmin1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "olt" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_ordered_strict_maxmin2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ult" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "olt" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_ordered_nonstrict_maxmin1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ole" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_ordered_nonstrict_maxmin2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ult" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ole" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_ordered_strict_minmax1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %2 = llvm.fcmp "ogt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ogt" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_ordered_strict_minmax2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %2 = llvm.fcmp "ugt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ogt" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_ordered_nonstrict_minmax1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %2 = llvm.fcmp "ogt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "oge" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_ordered_nonstrict_minmax2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %2 = llvm.fcmp "ugt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "oge" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_unordered_strict_maxmin1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ult" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_unordered_strict_maxmin2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ult" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ult" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_unordered_nonstrict_maxmin1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ule" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_unordered_nonstrict_maxmin2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ult" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ule" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_unordered_strict_minmax1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %2 = llvm.fcmp "ogt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ugt" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_unordered_strict_minmax2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %2 = llvm.fcmp "ugt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "ugt" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_unordered_nonstrict_minmax1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %2 = llvm.fcmp "ogt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "uge" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @clamp_float_unordered_nonstrict_minmax2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %2 = llvm.fcmp "ugt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "uge" %arg0, %1 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @ui32_clamp_and_cast_to_float(%arg0: i32) -> f32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %3 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %4 = llvm.uitofp %arg0 : i32 to f32 + %5 = llvm.icmp "ugt" %arg0, %0 : i32 + %6 = llvm.icmp "ult" %arg0, %1 : i32 + %7 = llvm.select %5, %2, %4 : i1, f32 + %8 = llvm.select %6, %3, %7 : i1, f32 + llvm.return %8 : f32 + } + llvm.func @ui64_clamp_and_cast_to_float(%arg0: i64) -> f32 { + %0 = llvm.mlir.constant(255 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %3 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %4 = llvm.uitofp %arg0 : i64 to f32 + %5 = llvm.icmp "ugt" %arg0, %0 : i64 + %6 = llvm.icmp "ult" %arg0, %1 : i64 + %7 = llvm.select %5, %2, %4 : i1, f32 + %8 = llvm.select %6, %3, %7 : i1, f32 + llvm.return %8 : f32 + } + llvm.func @mixed_clamp_to_float_1(%arg0: i32) -> f32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.sitofp %3 : i32 to f32 + %5 = llvm.sitofp %arg0 : i32 to f32 + %6 = llvm.fcmp "ult" %5, %1 : f32 + %7 = llvm.select %6, %1, %4 : i1, f32 + llvm.return %7 : f32 + } + llvm.func @mixed_clamp_to_i32_1(%arg0: f32) -> i32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.fcmp "ogt" %arg0, %0 : f32 + %3 = llvm.select %2, %0, %arg0 : i1, f32 + %4 = llvm.fptosi %3 : f32 to i32 + %5 = llvm.fptosi %arg0 : f32 to i32 + %6 = llvm.icmp "ult" %5, %1 : i32 + %7 = llvm.select %6, %1, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @mixed_clamp_to_float_2(%arg0: i32) -> f32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.select %3, %0, %arg0 : i1, i32 + %5 = llvm.sitofp %4 : i32 to f32 + %6 = llvm.icmp "slt" %arg0, %1 : i32 + %7 = llvm.select %6, %2, %5 : i1, f32 + llvm.return %7 : f32 + } + llvm.func @mixed_clamp_to_i32_2(%arg0: f32) -> i32 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.fcmp "ogt" %arg0, %0 : f32 + %4 = llvm.select %3, %0, %arg0 : i1, f32 + %5 = llvm.fptosi %4 : f32 to i32 + %6 = llvm.fcmp "olt" %arg0, %1 : f32 + %7 = llvm.select %6, %2, %5 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @mixed_clamp_to_float_vec(%arg0: vector<2xi32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<255> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %0, %arg0 : vector<2xi1>, vector<2xi32> + %4 = llvm.sitofp %3 : vector<2xi32> to vector<2xf32> + %5 = llvm.sitofp %arg0 : vector<2xi32> to vector<2xf32> + %6 = llvm.fcmp "ult" %5, %1 : vector<2xf32> + %7 = llvm.select %6, %1, %4 : vector<2xi1>, vector<2xf32> + llvm.return %7 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/cmp-intrinsic.ll.mlir b/test/LLVMDialect/InstCombine/cmp-intrinsic.ll.mlir new file mode 100644 index 000000000..a8f828ee6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/cmp-intrinsic.ll.mlir @@ -0,0 +1,547 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use6(i6) + llvm.func @use8(i8) + llvm.func @bswap_eq_i16(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.intr.bswap(%arg0) : (i16) -> i16 + %2 = llvm.icmp "eq" %1, %0 : i16 + llvm.return %2 : i1 + } + llvm.func @bswap_ne_i32(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.intr.bswap(%arg0) : (i32) -> i32 + %2 = llvm.icmp "ne" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @bswap_eq_v2i64(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi64>) : vector<2xi64> + %1 = llvm.intr.bswap(%arg0) : (vector<2xi64>) -> vector<2xi64> + %2 = llvm.icmp "eq" %1, %0 : vector<2xi64> + llvm.return %2 : vector<2xi1> + } + llvm.func @ctlz_eq_bitwidth_i32(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @ctlz_eq_zero_i32(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @ctlz_ne_zero_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @ctlz_eq_bw_minus_1_i32(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @ctlz_ne_bw_minus_1_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ne" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @ctlz_eq_other_i32(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @ctlz_ne_other_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<24> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ne" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @ctlz_eq_other_i32_multiuse(%arg0: i32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + llvm.store %1, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @ctlz_ne_bitwidth_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ne" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @ctlz_ugt_zero_i32(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @ctlz_ugt_one_i32(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @ctlz_ugt_other_i32(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @ctlz_ugt_other_multiuse_i32(%arg0: i32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + llvm.store %1, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %2 = llvm.icmp "ugt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @ctlz_ugt_bw_minus_one_i32(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @ctlz_ult_one_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @ctlz_ult_other_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @ctlz_ult_other_multiuse_v2i32(%arg0: vector<2xi32>, %arg1: !llvm.ptr) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + llvm.store %1, %arg1 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + %2 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @ctlz_ult_bw_minus_one_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @ctlz_ult_bitwidth_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @cttz_ne_bitwidth_i33(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(33 : i33) : i33 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i33) -> i33 + %2 = llvm.icmp "ne" %1, %0 : i33 + llvm.return %2 : i1 + } + llvm.func @cttz_eq_bitwidth_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "eq" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @cttz_eq_zero_i33(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(0 : i33) : i33 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i33) -> i33 + %2 = llvm.icmp "eq" %1, %0 : i33 + llvm.return %2 : i1 + } + llvm.func @cttz_ne_zero_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @cttz_eq_bw_minus_1_i33(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(32 : i33) : i33 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i33) -> i33 + %2 = llvm.icmp "eq" %1, %0 : i33 + llvm.return %2 : i1 + } + llvm.func @cttz_ne_bw_minus_1_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ne" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @cttz_eq_other_i33(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(4 : i33) : i33 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i33) -> i33 + %2 = llvm.icmp "eq" %1, %0 : i33 + llvm.return %2 : i1 + } + llvm.func @cttz_ne_other_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ne" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @cttz_eq_other_i33_multiuse(%arg0: i33, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(4 : i33) : i33 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i33) -> i33 + llvm.store %1, %arg1 {alignment = 4 : i64} : i33, !llvm.ptr + %2 = llvm.icmp "eq" %1, %0 : i33 + llvm.return %2 : i1 + } + llvm.func @cttz_ugt_zero_i33(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(0 : i33) : i33 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i33) -> i33 + %2 = llvm.icmp "ugt" %1, %0 : i33 + llvm.return %2 : i1 + } + llvm.func @cttz_ugt_one_i33(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(1 : i33) : i33 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i33) -> i33 + %2 = llvm.icmp "ugt" %1, %0 : i33 + llvm.return %2 : i1 + } + llvm.func @cttz_ugt_other_i33(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(16 : i33) : i33 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i33) -> i33 + %2 = llvm.icmp "ugt" %1, %0 : i33 + llvm.return %2 : i1 + } + llvm.func @cttz_ugt_other_multiuse_i33(%arg0: i33, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(16 : i33) : i33 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i33) -> i33 + llvm.store %1, %arg1 {alignment = 4 : i64} : i33, !llvm.ptr + %2 = llvm.icmp "ugt" %1, %0 : i33 + llvm.return %2 : i1 + } + llvm.func @cttz_ugt_bw_minus_one_i33(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(32 : i33) : i33 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i33) -> i33 + %2 = llvm.icmp "ugt" %1, %0 : i33 + llvm.return %2 : i1 + } + llvm.func @cttz_ult_one_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @cttz_ult_other_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @cttz_ult_other_multiuse_v2i32(%arg0: vector<2xi32>, %arg1: !llvm.ptr) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + llvm.store %1, %arg1 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + %2 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @cttz_ult_bw_minus_one_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @cttz_ult_bitwidth_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @ctpop_eq_zero_i11(%arg0: i11) -> i1 { + %0 = llvm.mlir.constant(0 : i11) : i11 + %1 = llvm.intr.ctpop(%arg0) : (i11) -> i11 + %2 = llvm.icmp "eq" %1, %0 : i11 + llvm.return %2 : i1 + } + llvm.func @ctpop_ne_zero_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.ctpop(%arg0) : (vector<2xi32>) -> vector<2xi32> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @ctpop_eq_bitwidth_i8(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(8 : i8) : i8 + %1 = llvm.intr.ctpop(%arg0) : (i8) -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @ctpop_ne_bitwidth_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.intr.ctpop(%arg0) : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ne" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @ctpop_ugt_bitwidth_minus_one_i8(%arg0: i8, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.intr.ctpop(%arg0) : (i8) -> i8 + llvm.store %1, %arg1 {alignment = 1 : i64} : i8, !llvm.ptr + %2 = llvm.icmp "ugt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @ctpop_ult_bitwidth_v2i32(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.intr.ctpop(%arg0) : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @trunc_cttz_eq_other_i33_i15(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(4 : i15) : i15 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i33) -> i33 + %2 = llvm.trunc %1 : i33 to i15 + %3 = llvm.icmp "eq" %2, %0 : i15 + llvm.return %3 : i1 + } + llvm.func @trunc_cttz_ugt_other_i33_i15(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(3 : i15) : i15 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i33) -> i33 + %2 = llvm.trunc %1 : i33 to i15 + %3 = llvm.icmp "ugt" %2, %0 : i15 + llvm.return %3 : i1 + } + llvm.func @trunc_cttz_ult_other_i33_i6(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(7 : i6) : i6 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = true}> : (i33) -> i33 + %2 = llvm.trunc %1 : i33 to i6 + %3 = llvm.icmp "ult" %2, %0 : i6 + llvm.return %3 : i1 + } + llvm.func @trunc_cttz_ult_other_i33_i5(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(7 : i5) : i5 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = true}> : (i33) -> i33 + %2 = llvm.trunc %1 : i33 to i5 + %3 = llvm.icmp "ult" %2, %0 : i5 + llvm.return %3 : i1 + } + llvm.func @trunc_cttz_true_ult_other_i32_i5(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i5) : i5 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %2 = llvm.trunc %1 : i32 to i5 + %3 = llvm.icmp "ult" %2, %0 : i5 + llvm.return %3 : i1 + } + llvm.func @trunc_cttz_false_ult_other_i32_i5(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i5) : i5 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.trunc %1 : i32 to i5 + %3 = llvm.icmp "ult" %2, %0 : i5 + llvm.return %3 : i1 + } + llvm.func @trunc_cttz_false_ult_other_i32_i6(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i6) : i6 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.trunc %1 : i32 to i6 + %3 = llvm.icmp "ult" %2, %0 : i6 + llvm.return %3 : i1 + } + llvm.func @trunc_cttz_false_ult_other_i32_i6_extra_use(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i6) : i6 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.trunc %1 : i32 to i6 + llvm.call @use6(%2) : (i6) -> () + %3 = llvm.icmp "ult" %2, %0 : i6 + llvm.return %3 : i1 + } + llvm.func @trunc_ctlz_ugt_zero_i32(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i15) : i15 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.trunc %1 : i32 to i15 + %3 = llvm.icmp "ugt" %2, %0 : i15 + llvm.return %3 : i1 + } + llvm.func @trunc_ctlz_ugt_one_i32(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i15) : i15 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.trunc %1 : i32 to i15 + %3 = llvm.icmp "ugt" %2, %0 : i15 + llvm.return %3 : i1 + } + llvm.func @trunc_ctlz_ugt_other_i33_i6(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(4 : i6) : i6 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i33) -> i33 + %2 = llvm.trunc %1 : i33 to i6 + %3 = llvm.icmp "ugt" %2, %0 : i6 + llvm.return %3 : i1 + } + llvm.func @trunc_ctlz_ugt_other_i33_i5(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(4 : i5) : i5 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i33) -> i33 + %2 = llvm.trunc %1 : i33 to i5 + %3 = llvm.icmp "ugt" %2, %0 : i5 + llvm.return %3 : i1 + } + llvm.func @trunc_ctlz_true_ugt_other_i32_i5(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i5) : i5 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %2 = llvm.trunc %1 : i32 to i5 + %3 = llvm.icmp "ugt" %2, %0 : i5 + llvm.return %3 : i1 + } + llvm.func @trunc_ctlz_false_ugt_other_i32_i5(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i5) : i5 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.trunc %1 : i32 to i5 + %3 = llvm.icmp "ugt" %2, %0 : i5 + llvm.return %3 : i1 + } + llvm.func @trunc_ctlz_false_ugt_other_i32_i6(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i6) : i6 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.trunc %1 : i32 to i6 + %3 = llvm.icmp "ugt" %2, %0 : i6 + llvm.return %3 : i1 + } + llvm.func @trunc_ctlz_false_ugt_other_i32_i6_extra_use(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i6) : i6 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.trunc %1 : i32 to i6 + llvm.call @use6(%2) : (i6) -> () + %3 = llvm.icmp "ugt" %2, %0 : i6 + llvm.return %3 : i1 + } + llvm.func @trunc_ctpop_eq_zero_i11(%arg0: i11) -> i1 { + %0 = llvm.mlir.constant(0 : i5) : i5 + %1 = llvm.intr.ctpop(%arg0) : (i11) -> i11 + %2 = llvm.trunc %1 : i11 to i5 + %3 = llvm.icmp "eq" %2, %0 : i5 + llvm.return %3 : i1 + } + llvm.func @trunc_ctpop_eq_bitwidth_i8(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(8 : i5) : i5 + %1 = llvm.intr.ctpop(%arg0) : (i8) -> i8 + %2 = llvm.trunc %1 : i8 to i5 + %3 = llvm.icmp "eq" %2, %0 : i5 + llvm.return %3 : i1 + } + llvm.func @trunc_negative_destbits_not_enough(%arg0: i33) -> i1 { + %0 = llvm.mlir.constant(7 : i4) : i4 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i33) -> i33 + %2 = llvm.trunc %1 : i33 to i4 + %3 = llvm.icmp "ult" %2, %0 : i4 + llvm.return %3 : i1 + } + llvm.func @bitreverse_ne_22(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(22 : i8) : i8 + %1 = llvm.intr.bitreverse(%arg0) : (i8) -> i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @bitreverse_ult_22_fail_not_equality_pred(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(22 : i8) : i8 + %1 = llvm.intr.bitreverse(%arg0) : (i8) -> i8 + %2 = llvm.icmp "ult" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @bitreverse_vec_eq_2_2(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %1 = llvm.intr.bitreverse(%arg0) : (vector<2xi8>) -> vector<2xi8> + %2 = llvm.icmp "eq" %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @bitreverse_vec_eq_1_2_todo_no_splat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.intr.bitreverse(%arg0) : (vector<2xi8>) -> vector<2xi8> + %2 = llvm.icmp "eq" %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @umax_eq_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.umax(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @umax_eq_1_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.intr.umax(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @umax_sle_zero_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.umax(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "sle" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @umax_ne_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.umax(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @umax_ne_zero_fail_multiuse(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.umax(%arg0, %arg1) : (i8, i8) -> i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @uadd_sat_ne_zero_fail_multiuse(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.uadd.sat(%arg0, %arg1) : (i8, i8) -> i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @ssub_sat_ne_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.ssub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @ssub_sat_ne_fail_nonzero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.intr.ssub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @ssub_sat_eq_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.ssub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @ssub_sat_sle_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.ssub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "sle" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @ssub_sat_sge_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.ssub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "sge" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @ssub_sat_slt_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.ssub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "slt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @ssub_sat_slt_neg1_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.intr.ssub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "slt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @ssub_sat_sgt_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.ssub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "sgt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @ssub_sat_sgt_one_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.intr.ssub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "sgt" %1, %0 : i8 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/cmp-x-vs-neg-x.ll.mlir b/test/LLVMDialect/InstCombine/cmp-x-vs-neg-x.ll.mlir index 0b3e9b88f..ddadaea36 100644 --- a/test/LLVMDialect/InstCombine/cmp-x-vs-neg-x.ll.mlir +++ b/test/LLVMDialect/InstCombine/cmp-x-vs-neg-x.ll.mlir @@ -1,113 +1,96 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen8", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg0) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %2 = "llvm.sub"(%0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%1, %2) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg0) {predicate = 5 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg0) {predicate = 3 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg0) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg0) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg0) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg0) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t9", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg0) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg0) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg1) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n12", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @gen8() -> i8 + llvm.func @use8(i8) + llvm.func @t0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.icmp "sgt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @t0_commutative() -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.sub %0, %1 overflow : i8 + %3 = llvm.icmp "slt" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @t0_extrause(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "sgt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @t1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.icmp "sge" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @t2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.icmp "slt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @t3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.icmp "sle" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @t4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.icmp "ugt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @t5(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.icmp "uge" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @t6(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.icmp "ult" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @t7(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.icmp "ule" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @t8(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.icmp "eq" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @t9(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.icmp "ne" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n10(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.icmp "sgt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n11(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.icmp "sgt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n12(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.icmp "sgt" %1, %arg1 : i8 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/combine-is.fpclass-and-fcmp.ll.mlir b/test/LLVMDialect/InstCombine/combine-is.fpclass-and-fcmp.ll.mlir new file mode 100644 index 000000000..4280d0a34 --- /dev/null +++ b/test/LLVMDialect/InstCombine/combine-is.fpclass-and-fcmp.ll.mlir @@ -0,0 +1,259 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fcmp_oeq_inf_or_class_normal(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "oeq" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @class_normal_or_fcmp_oeq_inf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "oeq" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_oeq_inf_or_class_normal_vector(%arg0: vector<2xf16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<0x7C00> : vector<2xf16>) : vector<2xf16> + %1 = llvm.fcmp "oeq" %arg0, %0 : vector<2xf16> + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (vector<2xf16>) -> vector<2xi1> + %3 = llvm.or %1, %2 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @fcmp_oeq_inf_multi_use_or_class_normal(%arg0: f16, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "oeq" %arg0, %0 : f16 + llvm.store %1, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_oeq_inf_or_class_normal_multi_use(%arg0: f16, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "oeq" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + llvm.store %2, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_or_class_isnan(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 3 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_or_class_isnan_wrong_operand(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg1) <{bit = 3 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_class_isnan(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 3 : i32}> : (f16) -> i1 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_or_class_isnan_commute(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 3 : i32}> : (f16) -> i1 + %2 = llvm.fcmp "ord" %arg0, %0 : f16 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_class_isnan_commute(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 3 : i32}> : (f16) -> i1 + %2 = llvm.fcmp "ord" %arg0, %0 : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_isfinite_and_class_subnormal(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %2 = llvm.fcmp "olt" %1, %0 : f16 + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 144 : i32}> : (f16) -> i1 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @fcmp_isfinite_or_class_subnormal(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %2 = llvm.fcmp "olt" %1, %0 : f16 + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 144 : i32}> : (f16) -> i1 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @fcmp_issubnormal_or_class_finite(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(6.103520e-05 : f16) : f16 + %1 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %2 = llvm.fcmp "olt" %1, %0 : f16 + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 504 : i32}> : (f16) -> i1 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @class_finite_or_fcmp_issubnormal(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(6.103520e-05 : f16) : f16 + %1 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %2 = llvm.fcmp "olt" %1, %0 : f16 + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 504 : i32}> : (f16) -> i1 + %4 = llvm.or %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @fcmp_issubnormal_and_class_finite(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(6.103520e-05 : f16) : f16 + %1 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %2 = llvm.fcmp "olt" %1, %0 : f16 + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 504 : i32}> : (f16) -> i1 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @class_inf_or_fcmp_issubnormal(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(6.103520e-05 : f16) : f16 + %1 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %2 = llvm.fcmp "olt" %1, %0 : f16 + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 516 : i32}> : (f16) -> i1 + %4 = llvm.or %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @class_finite_or_fcmp_issubnormal_vector(%arg0: vector<2xf16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<6.103520e-05> : vector<2xf16>) : vector<2xf16> + %1 = llvm.intr.fabs(%arg0) : (vector<2xf16>) -> vector<2xf16> + %2 = llvm.fcmp "olt" %1, %0 : vector<2xf16> + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 504 : i32}> : (vector<2xf16>) -> vector<2xi1> + %4 = llvm.or %3, %2 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @fcmp_oeq_zero_or_class_normal(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "oeq" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_oeq_zero_or_class_normal_daz(%arg0: f16) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "oeq" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_oeq_zero_or_class_normal_daz_v2f16(%arg0: vector<2xf16>) -> vector<2xi1> attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf16>) : vector<2xf16> + %2 = llvm.fcmp "oeq" %arg0, %1 : vector<2xf16> + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (vector<2xf16>) -> vector<2xi1> + %4 = llvm.or %2, %3 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @fcmp_oeq_zero_or_class_normal_dynamic(%arg0: f16) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,dynamic"]]} { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "oeq" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_oeq_zero_or_class_normal_dynamic_v2f16(%arg0: vector<2xf16>) -> vector<2xi1> attributes {passthrough = [["denormal-fp-math", "ieee,dynamic"]]} { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf16>) : vector<2xf16> + %2 = llvm.fcmp "oeq" %arg0, %1 : vector<2xf16> + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (vector<2xf16>) -> vector<2xi1> + %4 = llvm.or %2, %3 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @class_normal_or_fcmp_oeq_zero(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "oeq" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ueq_zero_or_class_normal(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ueq" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @class_normal_or_fcmp_ueq_zero(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ueq" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_one_zero_or_class_normal(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "one" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_one_zero_or_class_normal_daz(%arg0: f16) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "one" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_one_zero_or_class_normal_dynamic(%arg0: f16) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,dynamic"]]} { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "one" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @class_normal_or_fcmp_one_zero(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "one" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_une_zero_or_class_normal(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "une" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @class_normal_or_fcmp_une_zero(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "une" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @class_normal_or_fcmp_une_zero_daz(%arg0: f16) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "une" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @class_normal_or_fcmp_une_zero_dynamic(%arg0: f16) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,dynamic"]]} { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "une" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_oeq_inf_xor_class_normal(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "oeq" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.xor %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @class_normal_xor_fcmp_oeq_inf(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0x7C00 : f16) : f16 + %1 = llvm.fcmp "oeq" %arg0, %0 : f16 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f16) -> i1 + %3 = llvm.xor %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @llvm.canonicalize.f16(f16) -> f16 attributes {memory = #llvm.memory_effects, passthrough = ["nocallback", "nofree", "nosync", "nounwind", "speculatable", "willreturn"]} +} diff --git a/test/LLVMDialect/InstCombine/commutative-intrinsics.ll.mlir b/test/LLVMDialect/InstCombine/commutative-intrinsics.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/commutative-operation-over-phis.ll.mlir b/test/LLVMDialect/InstCombine/commutative-operation-over-phis.ll.mlir new file mode 100644 index 000000000..f4eb4d274 --- /dev/null +++ b/test/LLVMDialect/InstCombine/commutative-operation-over-phis.ll.mlir @@ -0,0 +1,234 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @dummy() + llvm.func @fold_phi_mul(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : i8, i8) + ^bb2(%0: i8, %1: i8): // 2 preds: ^bb0, ^bb1 + %2 = llvm.mul %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @fold_phi_mul_three(%arg0: i1, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + llvm.cond_br %arg0, ^bb1, ^bb3(%arg2, %arg3 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.cond_br %arg1, ^bb2, ^bb3(%arg3, %arg2 : i8, i8) + ^bb2: // pred: ^bb1 + llvm.call @dummy() : () -> () + llvm.br ^bb3(%arg2, %arg3 : i8, i8) + ^bb3(%0: i8, %1: i8): // 3 preds: ^bb0, ^bb1, ^bb2 + %2 = llvm.mul %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @fold_phi_mul_three_notopt(%arg0: i1, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + llvm.cond_br %arg0, ^bb1, ^bb3(%arg2, %arg3 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.cond_br %arg1, ^bb2, ^bb3(%arg3, %arg2 : i8, i8) + ^bb2: // pred: ^bb1 + llvm.call @dummy() : () -> () + llvm.br ^bb3(%arg2, %arg2 : i8, i8) + ^bb3(%0: i8, %1: i8): // 3 preds: ^bb0, ^bb1, ^bb2 + %2 = llvm.mul %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @fold_phi_mul_nsw_nuw(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : i8, i8) + ^bb2(%0: i8, %1: i8): // 2 preds: ^bb0, ^bb1 + %2 = llvm.mul %0, %1 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @fold_phi_mul_fix_vec(%arg0: i1, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : vector<2xi8>, vector<2xi8>) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : vector<2xi8>, vector<2xi8>) + ^bb2(%0: vector<2xi8>, %1: vector<2xi8>): // 2 preds: ^bb0, ^bb1 + %2 = llvm.mul %0, %1 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @fold_phi_mul_scale_vec(%arg0: i1, %arg1: !llvm.vec, %arg2: !llvm.vec) -> !llvm.vec { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : !llvm.vec, !llvm.vec) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : !llvm.vec, !llvm.vec) + ^bb2(%0: !llvm.vec, %1: !llvm.vec): // 2 preds: ^bb0, ^bb1 + %2 = llvm.mul %0, %1 : !llvm.vec + llvm.return %2 : !llvm.vec + } + llvm.func @fold_phi_mul_commute(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : i8, i8) + ^bb2(%0: i8, %1: i8): // 2 preds: ^bb0, ^bb1 + %2 = llvm.mul %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @fold_phi_mul_notopt(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg3 : i8, i8) + ^bb2(%0: i8, %1: i8): // 2 preds: ^bb0, ^bb1 + %2 = llvm.mul %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @fold_phi_sub(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : i8, i8) + ^bb2(%0: i8, %1: i8): // 2 preds: ^bb0, ^bb1 + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @fold_phi_add(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : i8, i8) + ^bb2(%0: i8, %1: i8): // 2 preds: ^bb0, ^bb1 + %2 = llvm.add %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @fold_phi_and(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : i8, i8) + ^bb2(%0: i8, %1: i8): // 2 preds: ^bb0, ^bb1 + %2 = llvm.and %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @fold_phi_or(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : i8, i8) + ^bb2(%0: i8, %1: i8): // 2 preds: ^bb0, ^bb1 + %2 = llvm.or %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @fold_phi_xor(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i8, i8) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : i8, i8) + ^bb2(%0: i8, %1: i8): // 2 preds: ^bb0, ^bb1 + %2 = llvm.xor %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @fold_phi_fadd(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : f32, f32) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : f32, f32) + ^bb2(%0: f32, %1: f32): // 2 preds: ^bb0, ^bb1 + %2 = llvm.fadd %0, %1 : f32 + llvm.return %2 : f32 + } + llvm.func @fold_phi_fadd_nnan(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : f32, f32) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : f32, f32) + ^bb2(%0: f32, %1: f32): // 2 preds: ^bb0, ^bb1 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fold_phi_fmul(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : f32, f32) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : f32, f32) + ^bb2(%0: f32, %1: f32): // 2 preds: ^bb0, ^bb1 + %2 = llvm.fmul %0, %1 : f32 + llvm.return %2 : f32 + } + llvm.func @fold_phi_smax(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i32, i32) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : i32, i32) + ^bb2(%0: i32, %1: i32): // 2 preds: ^bb0, ^bb1 + %2 = llvm.intr.smax(%0, %1) : (i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @fold_phi_smin(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i32, i32) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : i32, i32) + ^bb2(%0: i32, %1: i32): // 2 preds: ^bb0, ^bb1 + %2 = llvm.intr.smin(%0, %1) : (i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @fold_phi_umax(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i32, i32) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : i32, i32) + ^bb2(%0: i32, %1: i32): // 2 preds: ^bb0, ^bb1 + %2 = llvm.intr.umax(%0, %1) : (i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @fold_phi_umin(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : i32, i32) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : i32, i32) + ^bb2(%0: i32, %1: i32): // 2 preds: ^bb0, ^bb1 + %2 = llvm.intr.umin(%0, %1) : (i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @fold_phi_maxnum(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : f32, f32) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : f32, f32) + ^bb2(%0: f32, %1: f32): // 2 preds: ^bb0, ^bb1 + %2 = llvm.intr.maxnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @fold_phi_pow(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : f32, f32) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : f32, f32) + ^bb2(%0: f32, %1: f32): // 2 preds: ^bb0, ^bb1 + %2 = llvm.intr.pow(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @fold_phi_minnum(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : f32, f32) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : f32, f32) + ^bb2(%0: f32, %1: f32): // 2 preds: ^bb0, ^bb1 + %2 = llvm.intr.minnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @fold_phi_maximum(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : f32, f32) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : f32, f32) + ^bb2(%0: f32, %1: f32): // 2 preds: ^bb0, ^bb1 + %2 = llvm.intr.maximum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @fold_phi_minimum(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : f32, f32) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%arg2, %arg1 : f32, f32) + ^bb2(%0: f32, %1: f32): // 2 preds: ^bb0, ^bb1 + %2 = llvm.intr.minimum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/commutative-operation-over-selects.ll.mlir b/test/LLVMDialect/InstCombine/commutative-operation-over-selects.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/compare-3way.ll.mlir b/test/LLVMDialect/InstCombine/compare-3way.ll.mlir new file mode 100644 index 000000000..66bcbc5cb --- /dev/null +++ b/test/LLVMDialect/InstCombine/compare-3way.ll.mlir @@ -0,0 +1,373 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @test_low_sgt(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "sgt" %6, %0 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_low_slt(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "slt" %6, %0 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_low_sge(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "sge" %6, %0 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_low_sle(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "sle" %6, %0 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_low_ne(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "ne" %6, %0 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_low_eq(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "eq" %6, %0 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_mid_sgt(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "sgt" %6, %2 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_mid_slt(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "slt" %6, %2 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_mid_sge(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "sge" %6, %2 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_mid_sle(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "sle" %6, %2 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_mid_ne(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "ne" %6, %2 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_mid_eq(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "eq" %6, %2 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_high_sgt(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "sgt" %6, %1 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_high_slt(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "slt" %6, %1 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_high_sge(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "sge" %6, %1 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_high_sle(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "sle" %6, %1 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_high_ne(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test_high_eq(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @non_standard_low(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(-2 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "eq" %6, %0 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @non_standard_mid(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(-2 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "eq" %6, %2 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @non_standard_high(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(-2 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %arg1 : i64 + %4 = llvm.icmp "slt" %arg0, %arg1 : i64 + %5 = llvm.select %4, %0, %1 : i1, i32 + %6 = llvm.select %3, %2, %5 : i1, i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + llvm.cond_br %7, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @non_standard_bound1(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(-2 : i32) : i32 + %3 = llvm.mlir.constant(-20 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %arg1 : i64 + %5 = llvm.icmp "slt" %arg0, %arg1 : i64 + %6 = llvm.select %5, %0, %1 : i1, i32 + %7 = llvm.select %4, %2, %6 : i1, i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + llvm.cond_br %8, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%7) : (i32) -> () + llvm.return + } + llvm.func @non_standard_bound2(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(-2 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %arg1 : i64 + %5 = llvm.icmp "slt" %arg0, %arg1 : i64 + %6 = llvm.select %5, %0, %1 : i1, i32 + %7 = llvm.select %4, %2, %6 : i1, i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + llvm.cond_br %8, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @use(%7) : (i32) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/compare-alloca.ll.mlir b/test/LLVMDialect/InstCombine/compare-alloca.ll.mlir new file mode 100644 index 000000000..6c97d0c58 --- /dev/null +++ b/test/LLVMDialect/InstCombine/compare-alloca.ll.mlir @@ -0,0 +1,192 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @gp() {addr_space = 0 : i32, alignment = 8 : i64} : !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @alloca_argument_compare(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %1 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @alloca_argument_compare_swapped(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %2 = llvm.icmp "eq" %1, %arg0 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @alloca_argument_compare_ne(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %1 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @alloca_argument_compare_derived_ptrs(%arg0: !llvm.ptr, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i64) -> !llvm.ptr + %3 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + %4 = llvm.getelementptr %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + %5 = llvm.icmp "eq" %3, %4 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @escape(!llvm.ptr) + llvm.func @alloca_argument_compare_escaped_alloca(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.call @escape(%1) : (!llvm.ptr) -> () + %2 = llvm.icmp "eq" %1, %arg0 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @check_compares(i1, i1) + llvm.func @alloca_argument_compare_two_compares(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i64) -> !llvm.ptr + %4 = llvm.getelementptr %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + %5 = llvm.getelementptr %3[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + %6 = llvm.icmp "eq" %arg0, %3 : !llvm.ptr + %7 = llvm.icmp "eq" %4, %5 : !llvm.ptr + llvm.call @check_compares(%6, %7) : (i1, i1) -> () + llvm.return + } + llvm.func @alloca_argument_compare_escaped_through_store(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %3 = llvm.icmp "eq" %2, %arg0 : !llvm.ptr + %4 = llvm.getelementptr %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %4, %arg1 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @alloca_argument_compare_benign_instrs(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 1, %1 : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %1 : !llvm.ptr + %3 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.store %3, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.intr.lifetime.end 1, %1 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @allocator() -> !llvm.ptr + llvm.func @alloca_call_compare() -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %2 = llvm.call @allocator() : () -> !llvm.ptr + %3 = llvm.icmp "eq" %1, %2 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @hidden_inttoptr() -> !llvm.ptr + llvm.func @hidden_offset(!llvm.ptr) -> !llvm.ptr + llvm.func @ptrtoint_single_cmp() -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(2048 : i64) : i64 + %2 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %3 = llvm.inttoptr %1 : i64 to !llvm.ptr + %4 = llvm.icmp "eq" %2, %3 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @offset_single_cmp() -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %2 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %3 = llvm.getelementptr %2[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %4 = llvm.icmp "eq" %1, %3 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @witness(i1, i1) + llvm.func @consistent_fold1() { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(2048 : i64) : i64 + %2 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %3 = llvm.inttoptr %1 : i64 to !llvm.ptr + %4 = llvm.call @hidden_inttoptr() : () -> !llvm.ptr + %5 = llvm.icmp "eq" %2, %3 : !llvm.ptr + %6 = llvm.icmp "eq" %2, %4 : !llvm.ptr + llvm.call @witness(%5, %6) : (i1, i1) -> () + llvm.return + } + llvm.func @consistent_fold2() { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %2 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %3 = llvm.getelementptr %2[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %4 = llvm.call @hidden_offset(%2) : (!llvm.ptr) -> !llvm.ptr + %5 = llvm.icmp "eq" %1, %3 : !llvm.ptr + %6 = llvm.icmp "eq" %1, %4 : !llvm.ptr + llvm.call @witness(%5, %6) : (i1, i1) -> () + llvm.return + } + llvm.func @consistent_fold3() { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @gp : !llvm.ptr + %3 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %4 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.call @hidden_inttoptr() : () -> !llvm.ptr + %6 = llvm.icmp "eq" %3, %4 : !llvm.ptr + %7 = llvm.icmp "eq" %3, %5 : !llvm.ptr + llvm.call @witness(%6, %7) : (i1, i1) -> () + llvm.return + } + llvm.func @neg_consistent_fold4() { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @gp : !llvm.ptr + %3 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %4 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.icmp "eq" %3, %4 : !llvm.ptr + %6 = llvm.icmp "eq" %3, %4 : !llvm.ptr + llvm.call @witness(%5, %6) : (i1, i1) -> () + llvm.return + } + llvm.func @unknown(!llvm.ptr) + llvm.func @consistent_nocapture_inttoptr() -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(2048 : i64) : i64 + %2 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.call @unknown(%2) : (!llvm.ptr) -> () + %3 = llvm.inttoptr %1 : i64 to !llvm.ptr + %4 = llvm.icmp "eq" %2, %3 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @consistent_nocapture_offset() -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.call @unknown(%1) : (!llvm.ptr) -> () + %2 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %3 = llvm.getelementptr %2[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %4 = llvm.icmp "eq" %1, %3 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @consistent_nocapture_through_global() -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @gp : !llvm.ptr + %3 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.call @unknown(%3) : (!llvm.ptr) -> () + %4 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.icmp "eq" %3, %4 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @select_alloca_unrelated_ptr(%arg0: i1, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %2 = llvm.icmp "eq" %1, %arg1 : !llvm.ptr + %3 = llvm.select %arg0, %1, %arg2 : i1, !llvm.ptr + %4 = llvm.icmp "eq" %3, %arg1 : !llvm.ptr + llvm.call @witness(%2, %4) : (i1, i1) -> () + llvm.return + } + llvm.func @alloca_offset_icmp(%arg0: !llvm.ptr, %arg1: i32) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.array<4 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + %2 = llvm.getelementptr %1[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %3 = llvm.icmp "eq" %1, %arg0 : !llvm.ptr + %4 = llvm.icmp "eq" %1, %2 : !llvm.ptr + llvm.call @witness(%3, %4) : (i1, i1) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/compare-signs.ll.mlir b/test/LLVMDialect/InstCombine/compare-signs.ll.mlir new file mode 100644 index 000000000..cc47cc870 --- /dev/null +++ b/test/LLVMDialect/InstCombine/compare-signs.ll.mlir @@ -0,0 +1,187 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32, %arg1: i32) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg1, %1 : i32 + %4 = llvm.xor %3, %2 : i1 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @test2(%arg0: i32, %arg1: i32) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.icmp "eq" %1, %2 : i32 + %4 = llvm.zext %3 : i1 to i32 + llvm.return %4 : i32 + } + llvm.func @test3(%arg0: i32, %arg1: i32) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.lshr %arg1, %0 : i32 + %3 = llvm.icmp "eq" %1, %2 : i32 + %4 = llvm.zext %3 : i1 to i32 + llvm.return %4 : i32 + } + llvm.func @test3vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %1 = llvm.lshr %arg0, %0 : vector<2xi32> + %2 = llvm.lshr %arg1, %0 : vector<2xi32> + %3 = llvm.icmp "eq" %1, %2 : vector<2xi32> + %4 = llvm.zext %3 : vector<2xi1> to vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test3vec_poison1(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<24> : vector<2xi32>) : vector<2xi32> + %8 = llvm.lshr %arg0, %6 : vector<2xi32> + %9 = llvm.lshr %arg1, %7 : vector<2xi32> + %10 = llvm.icmp "eq" %8, %9 : vector<2xi32> + %11 = llvm.zext %10 : vector<2xi1> to vector<2xi32> + llvm.return %11 : vector<2xi32> + } + llvm.func @test3vec_poison2(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(17 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.lshr %arg0, %6 : vector<2xi32> + %8 = llvm.lshr %arg1, %6 : vector<2xi32> + %9 = llvm.icmp "eq" %7, %8 : vector<2xi32> + %10 = llvm.zext %9 : vector<2xi1> to vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @test3vec_diff(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<30> : vector<2xi32>) : vector<2xi32> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.lshr %arg1, %1 : vector<2xi32> + %4 = llvm.icmp "eq" %2, %3 : vector<2xi32> + %5 = llvm.zext %4 : vector<2xi1> to vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @"test3vec_non-uniform"(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<[30, 31]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.lshr %arg0, %0 : vector<2xi32> + %2 = llvm.lshr %arg1, %0 : vector<2xi32> + %3 = llvm.icmp "eq" %1, %2 : vector<2xi32> + %4 = llvm.zext %3 : vector<2xi1> to vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test3i(%arg0: i32, %arg1: i32) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(29 : i32) : i32 + %1 = llvm.mlir.constant(35 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.lshr %arg1, %0 : i32 + %4 = llvm.or %2, %1 : i32 + %5 = llvm.or %3, %1 : i32 + %6 = llvm.icmp "eq" %4, %5 : i32 + %7 = llvm.zext %6 : i1 to i32 + llvm.return %7 : i32 + } + llvm.func @test4a(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.ashr %arg0, %0 : i32 + %4 = llvm.sub %1, %arg0 : i32 + %5 = llvm.lshr %4, %0 : i32 + %6 = llvm.or %3, %5 : i32 + %7 = llvm.icmp "slt" %6, %2 : i32 + llvm.return %7 : i1 + } + llvm.func @test4a_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %4 = llvm.ashr %arg0, %0 : vector<2xi32> + %5 = llvm.sub %2, %arg0 : vector<2xi32> + %6 = llvm.lshr %5, %0 : vector<2xi32> + %7 = llvm.or %4, %6 : vector<2xi32> + %8 = llvm.icmp "slt" %7, %3 : vector<2xi32> + llvm.return %8 : vector<2xi1> + } + llvm.func @test4b(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.ashr %arg0, %0 : i64 + %4 = llvm.sub %1, %arg0 : i64 + %5 = llvm.lshr %4, %0 : i64 + %6 = llvm.or %3, %5 : i64 + %7 = llvm.icmp "slt" %6, %2 : i64 + llvm.return %7 : i1 + } + llvm.func @test4c(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.ashr %arg0, %0 : i64 + %4 = llvm.sub %1, %arg0 : i64 + %5 = llvm.lshr %4, %0 : i64 + %6 = llvm.or %3, %5 : i64 + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.icmp "slt" %7, %2 : i32 + llvm.return %8 : i1 + } + llvm.func @test4c_vec(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<63> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %4 = llvm.ashr %arg0, %0 : vector<2xi64> + %5 = llvm.sub %2, %arg0 : vector<2xi64> + %6 = llvm.lshr %5, %0 : vector<2xi64> + %7 = llvm.or %4, %6 : vector<2xi64> + %8 = llvm.trunc %7 : vector<2xi64> to vector<2xi32> + %9 = llvm.icmp "slt" %8, %3 : vector<2xi32> + llvm.return %9 : vector<2xi1> + } + llvm.func @shift_trunc_signbit_test(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.icmp "slt" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @shift_trunc_signbit_test_vec_uses(%arg0: vector<2xi17>, %arg1: !llvm.ptr, %arg2: !llvm.ptr) -> vector<2xi1> { + %0 = llvm.mlir.constant(4 : i17) : i17 + %1 = llvm.mlir.constant(dense<4> : vector<2xi17>) : vector<2xi17> + %2 = llvm.mlir.constant(-1 : i13) : i13 + %3 = llvm.mlir.constant(dense<-1> : vector<2xi13>) : vector<2xi13> + %4 = llvm.lshr %arg0, %1 : vector<2xi17> + llvm.store %4, %arg1 {alignment = 8 : i64} : vector<2xi17>, !llvm.ptr + %5 = llvm.trunc %4 : vector<2xi17> to vector<2xi13> + llvm.store %5, %arg2 {alignment = 4 : i64} : vector<2xi13>, !llvm.ptr + %6 = llvm.icmp "sgt" %5, %3 : vector<2xi13> + llvm.return %6 : vector<2xi1> + } + llvm.func @shift_trunc_wrong_shift(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(23 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.icmp "slt" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @shift_trunc_wrong_cmp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.icmp "slt" %3, %1 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/compare-udiv.ll.mlir b/test/LLVMDialect/InstCombine/compare-udiv.ll.mlir new file mode 100644 index 000000000..14fc202d2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/compare-udiv.ll.mlir @@ -0,0 +1,224 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.udiv %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @test1vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.udiv %arg0, %arg1 : vector<2xi32> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test2vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[64, 63]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.udiv %0, %arg0 : vector<2xi32> + %4 = llvm.icmp "eq" %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @test3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.udiv %arg0, %arg1 : i32 + %2 = llvm.icmp "ne" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @test3vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.udiv %arg0, %arg1 : vector<2xi32> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test4(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test4vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[64, 65]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.udiv %0, %arg0 : vector<2xi32> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @test5(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test5vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.udiv %0, %arg0 : vector<2xi32> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @test6(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test6vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.udiv %0, %arg0 : vector<2xi32> + %4 = llvm.icmp "ugt" %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @test7(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.udiv %0, %arg0 : i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @test7vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.udiv %0, %arg0 : vector<2xi32> + %2 = llvm.icmp "ugt" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @test8(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test8vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %2 = llvm.udiv %0, %arg0 : vector<2xi32> + %3 = llvm.icmp "ugt" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test9(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test9vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %2 = llvm.udiv %0, %arg0 : vector<2xi32> + %3 = llvm.icmp "ugt" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test10(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test10vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.udiv %0, %arg0 : vector<2xi32> + %3 = llvm.icmp "ugt" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test11(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test11vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.udiv %0, %arg0 : vector<2xi32> + %3 = llvm.icmp "ult" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test12(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test12vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %2 = llvm.udiv %0, %arg0 : vector<2xi32> + %3 = llvm.icmp "ult" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test13(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test13vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %2 = llvm.udiv %0, %arg0 : vector<2xi32> + %3 = llvm.icmp "ult" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test14(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.udiv %0, %arg0 : i32 + %2 = llvm.icmp "ult" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @test14vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.udiv %0, %arg0 : vector<2xi32> + %2 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @test15(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test15vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.udiv %0, %arg0 : vector<2xi32> + %3 = llvm.icmp "ugt" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test16(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test16vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.udiv %0, %arg0 : vector<2xi32> + %3 = llvm.icmp "ult" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/compare-unescaped.ll.mlir b/test/LLVMDialect/InstCombine/compare-unescaped.ll.mlir new file mode 100644 index 000000000..174e6b009 --- /dev/null +++ b/test/LLVMDialect/InstCombine/compare-unescaped.ll.mlir @@ -0,0 +1,239 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @gp() {addr_space = 0 : i32, alignment = 8 : i64} : !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @malloc(i64) -> (!llvm.ptr {llvm.noalias}) attributes {passthrough = [["allockind", "9"], ["allocsize", "4294967295"]]} + llvm.func @compare_global_trivialeq() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @gp : !llvm.ptr + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %4 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.icmp "eq" %3, %4 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @compare_global_trivialne() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @gp : !llvm.ptr + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %4 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.icmp "ne" %3, %4 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @f() + llvm.func @compare_and_call_with_deopt() -> i1 { + %0 = llvm.mlir.constant(24 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @gp : !llvm.ptr + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %4 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.icmp "eq" %4, %3 : !llvm.ptr + llvm.call @f() : () -> () + llvm.return %5 : i1 + } + llvm.func @compare_ne_and_call_with_deopt() -> i1 { + %0 = llvm.mlir.constant(24 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @gp : !llvm.ptr + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %4 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.icmp "ne" %4, %3 : !llvm.ptr + llvm.call @f() : () -> () + llvm.return %5 : i1 + } + llvm.func @compare_ne_global_maybe_null() -> i1 { + %0 = llvm.mlir.constant(24 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @gp : !llvm.ptr + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %4 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.icmp "ne" %4, %3 : !llvm.ptr + llvm.call @f() : () -> () + llvm.return %5 : i1 + } + llvm.func @escape(!llvm.ptr) + llvm.func @compare_and_call_after() -> i1 { + %0 = llvm.mlir.constant(24 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @gp : !llvm.ptr + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %5 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %6 = llvm.icmp "eq" %4, %5 : !llvm.ptr + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @escape(%4) : (!llvm.ptr) -> () + llvm.return %3 : i1 + ^bb2: // pred: ^bb0 + llvm.return %6 : i1 + } + llvm.func @compare_distinct_mallocs() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %2 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %3 = llvm.icmp "eq" %1, %2 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @compare_samepointer_under_bitcast() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %2 = llvm.icmp "eq" %1, %1 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @compare_samepointer_escaped() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %2 = llvm.icmp "eq" %1, %1 : !llvm.ptr + llvm.call @f() : () -> () + llvm.return %2 : i1 + } + llvm.func @compare_ret_escape(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @gp : !llvm.ptr + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %4 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %5 = llvm.icmp "eq" %4, %arg0 : !llvm.ptr + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // 2 preds: ^bb0, ^bb2 + llvm.return %3 : !llvm.ptr + ^bb2: // pred: ^bb0 + %6 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %7 = llvm.icmp "eq" %3, %6 : !llvm.ptr + llvm.cond_br %7, ^bb1, ^bb3 + ^bb3: // pred: ^bb2 + llvm.return %4 : !llvm.ptr + } + llvm.func @compare_distinct_pointer_escape() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %2 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + llvm.call @f() : () -> () + %3 = llvm.icmp "ne" %1, %2 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @hidden_inttoptr() -> !llvm.ptr + llvm.func @hidden_offset(!llvm.ptr) -> !llvm.ptr + llvm.func @ptrtoint_single_cmp() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(2048 : i64) : i64 + %2 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %3 = llvm.inttoptr %1 : i64 to !llvm.ptr + %4 = llvm.icmp "eq" %2, %3 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @offset_single_cmp() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %4 = llvm.getelementptr %3[%1] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %5 = llvm.icmp "eq" %2, %4 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @witness(i1, i1) + llvm.func @neg_consistent_fold1() { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(2048 : i64) : i64 + %2 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %3 = llvm.inttoptr %1 : i64 to !llvm.ptr + %4 = llvm.call @hidden_inttoptr() : () -> !llvm.ptr + %5 = llvm.icmp "eq" %2, %3 : !llvm.ptr + %6 = llvm.icmp "eq" %2, %4 : !llvm.ptr + llvm.call @witness(%5, %6) : (i1, i1) -> () + llvm.return + } + llvm.func @neg_consistent_fold2() { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %4 = llvm.getelementptr %3[%1] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %5 = llvm.call @hidden_offset(%3) : (!llvm.ptr) -> !llvm.ptr + %6 = llvm.icmp "eq" %2, %4 : !llvm.ptr + %7 = llvm.icmp "eq" %2, %5 : !llvm.ptr + llvm.call @witness(%6, %7) : (i1, i1) -> () + llvm.return + } + llvm.func @neg_consistent_fold3() { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @gp : !llvm.ptr + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %4 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.call @hidden_inttoptr() : () -> !llvm.ptr + %6 = llvm.icmp "eq" %3, %4 : !llvm.ptr + %7 = llvm.icmp "eq" %3, %5 : !llvm.ptr + llvm.call @witness(%6, %7) : (i1, i1) -> () + llvm.return + } + llvm.func @neg_consistent_fold4() { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @gp : !llvm.ptr + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %4 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.icmp "eq" %3, %4 : !llvm.ptr + %6 = llvm.icmp "eq" %3, %4 : !llvm.ptr + llvm.call @witness(%5, %6) : (i1, i1) -> () + llvm.return + } + llvm.func @unknown(!llvm.ptr) + llvm.func @consistent_nocapture_inttoptr() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(2048 : i64) : i64 + %2 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + llvm.call @unknown(%2) : (!llvm.ptr) -> () + %3 = llvm.inttoptr %1 : i64 to !llvm.ptr + %4 = llvm.icmp "eq" %2, %3 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @consistent_nocapture_offset() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + llvm.call @unknown(%2) : (!llvm.ptr) -> () + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %4 = llvm.getelementptr %3[%1] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %5 = llvm.icmp "eq" %2, %4 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @consistent_nocapture_through_global() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @gp : !llvm.ptr + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + llvm.call @unknown(%3) : (!llvm.ptr) -> () + %4 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.icmp "eq" %3, %4 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @two_nonnull_mallocs() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %2 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %3 = llvm.icmp "eq" %1, %2 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @two_nonnull_mallocs2() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %2 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + llvm.call @unknown(%2) : (!llvm.ptr) -> () + %3 = llvm.icmp "eq" %1, %2 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @two_nonnull_mallocs_hidden() -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %4 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + %5 = llvm.getelementptr %3[%1] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %6 = llvm.getelementptr %4[%2] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %7 = llvm.icmp "eq" %5, %6 : !llvm.ptr + llvm.return %7 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/conditional-negation.ll.mlir b/test/LLVMDialect/InstCombine/conditional-negation.ll.mlir new file mode 100644 index 000000000..53ad27e23 --- /dev/null +++ b/test/LLVMDialect/InstCombine/conditional-negation.ll.mlir @@ -0,0 +1,132 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + %1 = llvm.add %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @t0_vec(%arg0: vector<2xi8>, %arg1: vector<2xi1>) -> vector<2xi8> { + %0 = llvm.sext %arg1 : vector<2xi1> to vector<2xi8> + %1 = llvm.add %0, %arg0 : vector<2xi8> + %2 = llvm.xor %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @t1(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + %1 = llvm.sext %arg1 : i1 to i8 + %2 = llvm.add %0, %arg0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @t2(%arg0: i8, %arg1: i1, %arg2: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + %1 = llvm.sext %arg2 : i1 to i8 + %2 = llvm.add %0, %arg0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @t3(%arg0: i8, %arg1: i2) -> i8 { + %0 = llvm.sext %arg1 : i2 to i8 + %1 = llvm.add %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @t3_vec(%arg0: vector<2xi8>, %arg1: vector<2xi2>) -> vector<2xi8> { + %0 = llvm.sext %arg1 : vector<2xi2> to vector<2xi8> + %1 = llvm.add %0, %arg0 : vector<2xi8> + %2 = llvm.xor %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @xor.commuted(%arg0: i1) -> i8 { + %0 = llvm.sext %arg0 : i1 to i8 + %1 = llvm.call @gen.i8() : () -> i8 + %2 = llvm.add %1, %0 : i8 + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @extrause01_v1(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + llvm.call @use.i8(%0) : (i8) -> () + %1 = llvm.add %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @extrause10_v1(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + %1 = llvm.add %0, %arg0 : i8 + llvm.call @use.i8(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @extrause11_v1(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + llvm.call @use.i8(%0) : (i8) -> () + %1 = llvm.add %0, %arg0 : i8 + llvm.call @use.i8(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @extrause001_v2(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + llvm.call @use.i8(%0) : (i8) -> () + %1 = llvm.sext %arg1 : i1 to i8 + %2 = llvm.add %0, %arg0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @extrause010_v2(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + %1 = llvm.sext %arg1 : i1 to i8 + llvm.call @use.i8(%1) : (i8) -> () + %2 = llvm.add %0, %arg0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @extrause011_v2(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + llvm.call @use.i8(%0) : (i8) -> () + %1 = llvm.sext %arg1 : i1 to i8 + llvm.call @use.i8(%1) : (i8) -> () + %2 = llvm.add %0, %arg0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @extrause100_v2(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + %1 = llvm.sext %arg1 : i1 to i8 + %2 = llvm.add %0, %arg0 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @extrause101_v2(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + llvm.call @use.i8(%0) : (i8) -> () + %1 = llvm.sext %arg1 : i1 to i8 + %2 = llvm.add %0, %arg0 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @extrause110_v2(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + %1 = llvm.sext %arg1 : i1 to i8 + llvm.call @use.i8(%1) : (i8) -> () + %2 = llvm.add %0, %arg0 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @extrause111_v2(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + llvm.call @use.i8(%0) : (i8) -> () + %1 = llvm.sext %arg1 : i1 to i8 + llvm.call @use.i8(%1) : (i8) -> () + %2 = llvm.add %0, %arg0 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @use.i8(i8) + llvm.func @gen.i8() -> i8 +} diff --git a/test/LLVMDialect/InstCombine/conditional-variable-length-signext-after-high-bit-extract.ll.mlir b/test/LLVMDialect/InstCombine/conditional-variable-length-signext-after-high-bit-extract.ll.mlir new file mode 100644 index 000000000..c9173efc6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/conditional-variable-length-signext-after-high-bit-extract.ll.mlir @@ -0,0 +1,626 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use1(i1) + llvm.func @use16(i16) + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @t0_notrunc_add(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.add %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @t0_notrunc_or(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.or %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @t1_notrunc_sub(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.sub %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @t2_trunc_add(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.lshr %arg0, %5 : i64 + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.icmp "slt" %arg0, %1 : i64 + %9 = llvm.shl %2, %arg1 : i32 + %10 = llvm.select %8, %9, %3 : i1, i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use32(%7) : (i32) -> () + llvm.call @use1(%8) : (i1) -> () + llvm.call @use32(%9) : (i32) -> () + %11 = llvm.add %10, %7 : i32 + llvm.return %11 : i32 + } + llvm.func @t2_trunc_or(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.lshr %arg0, %5 : i64 + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.icmp "slt" %arg0, %1 : i64 + %9 = llvm.shl %2, %arg1 : i32 + %10 = llvm.select %8, %9, %3 : i1, i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use32(%7) : (i32) -> () + llvm.call @use1(%8) : (i1) -> () + llvm.call @use32(%9) : (i32) -> () + %11 = llvm.or %10, %7 : i32 + llvm.return %11 : i32 + } + llvm.func @t3_trunc_sub(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.lshr %arg0, %5 : i64 + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.icmp "slt" %arg0, %1 : i64 + %9 = llvm.shl %2, %arg1 : i32 + %10 = llvm.select %8, %9, %3 : i1, i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use32(%7) : (i32) -> () + llvm.call @use1(%8) : (i1) -> () + llvm.call @use32(%9) : (i32) -> () + %11 = llvm.sub %7, %10 : i32 + llvm.return %11 : i32 + } + llvm.func @t4_commutativity0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.add %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @t5_commutativity1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "sgt" %arg0, %1 : i32 + %6 = llvm.shl %1, %arg1 : i32 + %7 = llvm.select %5, %2, %6 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.add %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @t6_commutativity2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.add %7, %4 : i32 + llvm.return %8 : i32 + } + llvm.func @t7_trunc_extrause0(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.lshr %arg0, %5 : i64 + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.icmp "slt" %arg0, %1 : i64 + %9 = llvm.shl %2, %arg1 : i32 + %10 = llvm.select %8, %9, %3 : i1, i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use32(%7) : (i32) -> () + llvm.call @use1(%8) : (i1) -> () + llvm.call @use32(%9) : (i32) -> () + %11 = llvm.add %10, %7 : i32 + llvm.return %11 : i32 + } + llvm.func @t8_trunc_extrause1(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.lshr %arg0, %5 : i64 + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.icmp "slt" %arg0, %1 : i64 + %9 = llvm.shl %2, %arg1 : i32 + %10 = llvm.select %8, %9, %3 : i1, i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use1(%8) : (i1) -> () + llvm.call @use32(%9) : (i32) -> () + llvm.call @use32(%10) : (i32) -> () + %11 = llvm.add %10, %7 : i32 + llvm.return %11 : i32 + } + llvm.func @n9_trunc_extrause2(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.lshr %arg0, %5 : i64 + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.icmp "slt" %arg0, %1 : i64 + %9 = llvm.shl %2, %arg1 : i32 + %10 = llvm.select %8, %9, %3 : i1, i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use32(%7) : (i32) -> () + llvm.call @use1(%8) : (i1) -> () + llvm.call @use32(%9) : (i32) -> () + llvm.call @use32(%10) : (i32) -> () + %11 = llvm.add %10, %7 : i32 + llvm.return %11 : i32 + } + llvm.func @t10_preserve_exact(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.add %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @t11_different_zext_of_shamt(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.zext %arg1 : i8 to i16 + %4 = llvm.sub %0, %3 : i16 + %5 = llvm.zext %4 : i16 to i32 + %6 = llvm.lshr %arg0, %5 : i32 + %7 = llvm.icmp "slt" %arg0, %1 : i32 + %8 = llvm.zext %arg1 : i8 to i32 + %9 = llvm.shl %2, %8 : i32 + %10 = llvm.select %7, %9, %1 : i1, i32 + llvm.call @use16(%3) : (i16) -> () + llvm.call @use16(%4) : (i16) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use1(%7) : (i1) -> () + llvm.call @use32(%8) : (i32) -> () + llvm.call @use32(%9) : (i32) -> () + llvm.call @use32(%10) : (i32) -> () + %11 = llvm.add %6, %10 : i32 + llvm.return %11 : i32 + } + llvm.func @t12_add_sext_of_magic(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.zext %arg1 : i8 to i32 + %5 = llvm.sub %0, %4 : i32 + %6 = llvm.lshr %arg0, %5 : i32 + %7 = llvm.icmp "slt" %arg0, %1 : i32 + %8 = llvm.zext %arg1 : i8 to i16 + %9 = llvm.shl %2, %8 : i16 + %10 = llvm.select %7, %9, %3 : i1, i16 + %11 = llvm.sext %10 : i16 to i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use1(%7) : (i1) -> () + llvm.call @use16(%8) : (i16) -> () + llvm.call @use16(%9) : (i16) -> () + llvm.call @use16(%10) : (i16) -> () + llvm.call @use32(%11) : (i32) -> () + %12 = llvm.add %6, %11 : i32 + llvm.return %12 : i32 + } + llvm.func @t13_sub_zext_of_magic(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i16) : i16 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.zext %arg1 : i8 to i32 + %5 = llvm.sub %0, %4 : i32 + %6 = llvm.lshr %arg0, %5 : i32 + %7 = llvm.icmp "slt" %arg0, %1 : i32 + %8 = llvm.zext %arg1 : i8 to i16 + %9 = llvm.shl %2, %8 : i16 + %10 = llvm.select %7, %9, %3 : i1, i16 + %11 = llvm.zext %10 : i16 to i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use1(%7) : (i1) -> () + llvm.call @use16(%8) : (i16) -> () + llvm.call @use16(%9) : (i16) -> () + llvm.call @use16(%10) : (i16) -> () + llvm.call @use32(%11) : (i32) -> () + %12 = llvm.sub %6, %11 : i32 + llvm.return %12 : i32 + } + llvm.func @t14_add_sext_of_shl(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.zext %arg1 : i8 to i32 + %4 = llvm.sub %0, %3 : i32 + %5 = llvm.lshr %arg0, %4 : i32 + %6 = llvm.icmp "slt" %arg0, %1 : i32 + %7 = llvm.zext %arg1 : i8 to i16 + %8 = llvm.shl %2, %7 : i16 + %9 = llvm.sext %8 : i16 to i32 + %10 = llvm.select %6, %9, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use1(%6) : (i1) -> () + llvm.call @use16(%7) : (i16) -> () + llvm.call @use16(%8) : (i16) -> () + llvm.call @use32(%9) : (i32) -> () + llvm.call @use32(%10) : (i32) -> () + %11 = llvm.add %5, %10 : i32 + llvm.return %11 : i32 + } + llvm.func @t15_sub_zext_of_shl(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i16) : i16 + %3 = llvm.zext %arg1 : i8 to i32 + %4 = llvm.sub %0, %3 : i32 + %5 = llvm.lshr %arg0, %4 : i32 + %6 = llvm.icmp "slt" %arg0, %1 : i32 + %7 = llvm.zext %arg1 : i8 to i16 + %8 = llvm.shl %2, %7 : i16 + %9 = llvm.zext %8 : i16 to i32 + %10 = llvm.select %6, %9, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use1(%6) : (i1) -> () + llvm.call @use16(%7) : (i16) -> () + llvm.call @use16(%8) : (i16) -> () + llvm.call @use32(%9) : (i32) -> () + llvm.call @use32(%10) : (i32) -> () + %11 = llvm.sub %5, %10 : i32 + llvm.return %11 : i32 + } + llvm.func @n16(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.add %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @n17_add(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.add %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @n18(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %1, %6 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.add %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @n19(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg1, %1 : i32 + %6 = llvm.shl %2, %arg2 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.add %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @n20(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg2 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.add %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @n21(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "sgt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.add %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @n22(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(63 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.lshr %arg0, %5 : i64 + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.icmp "slt" %arg0, %1 : i64 + %9 = llvm.shl %2, %arg1 : i32 + %10 = llvm.select %8, %9, %3 : i1, i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use32(%7) : (i32) -> () + llvm.call @use1(%8) : (i1) -> () + llvm.call @use32(%9) : (i32) -> () + llvm.call @use32(%10) : (i32) -> () + %11 = llvm.add %10, %7 : i32 + llvm.return %11 : i32 + } + llvm.func @n23(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.ashr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.add %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @n24(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.sub %7, %4 : i32 + llvm.return %8 : i32 + } + llvm.func @n25_sub(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.sub %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @n26(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %6, %2 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.add %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @n27_add_zext_of_magic(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.zext %arg1 : i8 to i32 + %5 = llvm.sub %0, %4 : i32 + %6 = llvm.lshr %arg0, %5 : i32 + %7 = llvm.icmp "slt" %arg0, %1 : i32 + %8 = llvm.zext %arg1 : i8 to i16 + %9 = llvm.shl %2, %8 : i16 + %10 = llvm.select %7, %9, %3 : i1, i16 + %11 = llvm.zext %10 : i16 to i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use1(%7) : (i1) -> () + llvm.call @use16(%8) : (i16) -> () + llvm.call @use16(%9) : (i16) -> () + llvm.call @use16(%10) : (i16) -> () + llvm.call @use32(%11) : (i32) -> () + %12 = llvm.add %6, %11 : i32 + llvm.return %12 : i32 + } + llvm.func @n28_sub_sext_of_magic(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i16) : i16 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.zext %arg1 : i8 to i32 + %5 = llvm.sub %0, %4 : i32 + %6 = llvm.lshr %arg0, %5 : i32 + %7 = llvm.icmp "slt" %arg0, %1 : i32 + %8 = llvm.zext %arg1 : i8 to i16 + %9 = llvm.shl %2, %8 : i16 + %10 = llvm.select %7, %9, %3 : i1, i16 + %11 = llvm.sext %10 : i16 to i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use1(%7) : (i1) -> () + llvm.call @use16(%8) : (i16) -> () + llvm.call @use16(%9) : (i16) -> () + llvm.call @use16(%10) : (i16) -> () + llvm.call @use32(%11) : (i32) -> () + %12 = llvm.sub %6, %11 : i32 + llvm.return %12 : i32 + } + llvm.func @n290_or_with_wrong_magic(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.shl %2, %arg1 : i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use1(%5) : (i1) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.or %4, %7 : i32 + llvm.return %8 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/consecutive-fences.ll.mlir b/test/LLVMDialect/InstCombine/consecutive-fences.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/consecutive-ptrmask.ll.mlir b/test/LLVMDialect/InstCombine/consecutive-ptrmask.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/constant-expr-datalayout.ll.mlir b/test/LLVMDialect/InstCombine/constant-expr-datalayout.ll.mlir new file mode 100644 index 000000000..eb307701a --- /dev/null +++ b/test/LLVMDialect/InstCombine/constant-expr-datalayout.ll.mlir @@ -0,0 +1,32 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @test1.aligned_glbl() {addr_space = 0 : i32, alignment = 4 : i64} : !llvm.struct<"test1.struct", (i32, i32)> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.struct<"test1.struct", (i32, i32)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<"test1.struct", (i32, i32)> + %3 = llvm.insertvalue %0, %2[1] : !llvm.struct<"test1.struct", (i32, i32)> + llvm.return %3 : !llvm.struct<"test1.struct", (i32, i32)> + } + llvm.mlir.global external constant @channel_wg4idx() {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : !llvm.array<9 x i8> + llvm.func @test1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<"test1.struct", (i32, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"test1.struct", (i32, i32)> + %4 = llvm.insertvalue %1, %3[1] : !llvm.struct<"test1.struct", (i32, i32)> + %5 = llvm.mlir.addressof @test1.aligned_glbl : !llvm.ptr + %6 = llvm.getelementptr inbounds %5[%1, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"test1.struct", (i32, i32)> + %7 = llvm.ptrtoint %6 : !llvm.ptr to i64 + %8 = llvm.mlir.constant(3 : i64) : i64 + %9 = llvm.and %7, %8 : i64 + llvm.store %9, %arg0 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @OpenFilter(%arg0: i64) -> i64 { + %0 = llvm.mlir.addressof @channel_wg4idx : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %2 = llvm.sub %arg0, %1 : i64 + %3 = llvm.trunc %2 : i64 to i8 + %4 = llvm.zext %3 : i8 to i64 + llvm.return %4 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/constant-fold-address-space-pointer.ll.mlir b/test/LLVMDialect/InstCombine/constant-fold-address-space-pointer.ll.mlir new file mode 100644 index 000000000..7544c4774 --- /dev/null +++ b/test/LLVMDialect/InstCombine/constant-fold-address-space-pointer.ll.mlir @@ -0,0 +1,270 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry, dense<16> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<8> : vector<4xi64>>, #dlti.dl_entry, dense<16> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry, dense<64> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g(89 : i32) {addr_space = 3 : i32} : i32 + llvm.mlir.global external constant @const_zero_i8_as1(0 : i8) {addr_space = 1 : i32} : i8 + llvm.mlir.global external constant @const_zero_i32_as1(0 : i32) {addr_space = 1 : i32} : i32 + llvm.mlir.global external constant @const_zero_i8_as2(0 : i8) {addr_space = 2 : i32} : i8 + llvm.mlir.global external constant @const_zero_i32_as2(0 : i32) {addr_space = 2 : i32} : i32 + llvm.mlir.global external constant @const_zero_i8_as3(0 : i8) {addr_space = 3 : i32} : i8 + llvm.mlir.global external constant @const_zero_i32_as3(0 : i32) {addr_space = 3 : i32} : i32 + llvm.mlir.global external @g_float_as3(0.000000e+00 : f32) {addr_space = 3 : i32} : f32 + llvm.mlir.global external @g_v4f_as3(dense<0.000000e+00> : vector<4xf32>) {addr_space = 3 : i32} : vector<4xf32> + llvm.mlir.global external @i32_array_as3(dense<0> : tensor<10xi32>) {addr_space = 3 : i32} : !llvm.array<10 x i32> + llvm.mlir.global external @constant_fold_global_ptr() {addr_space = 3 : i32} : !llvm.struct<"struct.foo", (f32, f32, array<4 x i32>, ptr<3>)> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : tensor<10xi32>) : !llvm.array<10 x i32> + %2 = llvm.mlir.addressof @i32_array_as3 : !llvm.ptr<3> + %3 = llvm.mlir.constant(dense<0> : tensor<4xi32>) : !llvm.array<4 x i32> + %4 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %5 = llvm.mlir.undef : !llvm.struct<"struct.foo", (f32, f32, array<4 x i32>, ptr<3>)> + %6 = llvm.insertvalue %4, %5[0] : !llvm.struct<"struct.foo", (f32, f32, array<4 x i32>, ptr<3>)> + %7 = llvm.insertvalue %4, %6[1] : !llvm.struct<"struct.foo", (f32, f32, array<4 x i32>, ptr<3>)> + %8 = llvm.insertvalue %3, %7[2] : !llvm.struct<"struct.foo", (f32, f32, array<4 x i32>, ptr<3>)> + %9 = llvm.insertvalue %2, %8[3] : !llvm.struct<"struct.foo", (f32, f32, array<4 x i32>, ptr<3>)> + llvm.return %9 : !llvm.struct<"struct.foo", (f32, f32, array<4 x i32>, ptr<3>)> + } + llvm.mlir.global external constant @constant_data_as3(dense<[1, 2, 3, 4, 5]> : tensor<5xi32>) {addr_space = 3 : i32} : !llvm.array<5 x i32> + llvm.mlir.global external constant @a(9 : i32) {addr_space = 1 : i32} : i32 + llvm.mlir.global external constant @b(23 : i32) {addr_space = 1 : i32} : i32 + llvm.mlir.global external constant @c(34 : i32) {addr_space = 1 : i32} : i32 + llvm.mlir.global external constant @d(99 : i32) {addr_space = 1 : i32} : i32 + llvm.mlir.global external constant @ptr_array() {addr_space = 2 : i32} : !llvm.array<4 x ptr<1>> { + %0 = llvm.mlir.constant(99 : i32) : i32 + %1 = llvm.mlir.addressof @d : !llvm.ptr<1> + %2 = llvm.mlir.constant(34 : i32) : i32 + %3 = llvm.mlir.addressof @c : !llvm.ptr<1> + %4 = llvm.mlir.constant(23 : i32) : i32 + %5 = llvm.mlir.addressof @b : !llvm.ptr<1> + %6 = llvm.mlir.constant(9 : i32) : i32 + %7 = llvm.mlir.addressof @a : !llvm.ptr<1> + %8 = llvm.mlir.undef : !llvm.array<4 x ptr<1>> + %9 = llvm.insertvalue %7, %8[0] : !llvm.array<4 x ptr<1>> + %10 = llvm.insertvalue %5, %9[1] : !llvm.array<4 x ptr<1>> + %11 = llvm.insertvalue %3, %10[2] : !llvm.array<4 x ptr<1>> + %12 = llvm.insertvalue %1, %11[3] : !llvm.array<4 x ptr<1>> + llvm.return %12 : !llvm.array<4 x ptr<1>> + } + llvm.mlir.global external constant @indirect() {addr_space = 0 : i32} : !llvm.ptr<2> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(99 : i32) : i32 + %3 = llvm.mlir.addressof @d : !llvm.ptr<1> + %4 = llvm.mlir.constant(34 : i32) : i32 + %5 = llvm.mlir.addressof @c : !llvm.ptr<1> + %6 = llvm.mlir.constant(23 : i32) : i32 + %7 = llvm.mlir.addressof @b : !llvm.ptr<1> + %8 = llvm.mlir.constant(9 : i32) : i32 + %9 = llvm.mlir.addressof @a : !llvm.ptr<1> + %10 = llvm.mlir.undef : !llvm.array<4 x ptr<1>> + %11 = llvm.insertvalue %9, %10[0] : !llvm.array<4 x ptr<1>> + %12 = llvm.insertvalue %7, %11[1] : !llvm.array<4 x ptr<1>> + %13 = llvm.insertvalue %5, %12[2] : !llvm.array<4 x ptr<1>> + %14 = llvm.insertvalue %3, %13[3] : !llvm.array<4 x ptr<1>> + %15 = llvm.mlir.addressof @ptr_array : !llvm.ptr<2> + %16 = llvm.getelementptr inbounds %15[%1, %0] : (!llvm.ptr<2>, i1, i32) -> !llvm.ptr<2>, !llvm.array<4 x ptr<1>> + llvm.return %16 : !llvm.ptr<2> + } + llvm.mlir.global external @shared_mem() {addr_space = 3 : i32} : !llvm.array<0 x i8> + llvm.func @test_constant_fold_inttoptr_as_pointer_same_size() -> !llvm.ptr<3> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @const_zero_i32_as3 : !llvm.ptr<3> + %2 = llvm.ptrtoint %1 : !llvm.ptr<3> to i32 + %3 = llvm.inttoptr %2 : i32 to !llvm.ptr<3> + llvm.return %3 : !llvm.ptr<3> + } + llvm.func @test_constant_fold_inttoptr_as_pointer_smaller() -> !llvm.ptr<2> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @const_zero_i32_as2 : !llvm.ptr<2> + %2 = llvm.ptrtoint %1 : !llvm.ptr<2> to i16 + %3 = llvm.inttoptr %2 : i16 to !llvm.ptr<2> + llvm.return %3 : !llvm.ptr<2> + } + llvm.func @test_constant_fold_inttoptr_as_pointer_smaller_different_as() -> !llvm.ptr<4> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @const_zero_i32_as3 : !llvm.ptr<3> + %2 = llvm.ptrtoint %1 : !llvm.ptr<3> to i16 + %3 = llvm.inttoptr %2 : i16 to !llvm.ptr<4> + llvm.return %3 : !llvm.ptr<4> + } + llvm.func @test_constant_fold_inttoptr_as_pointer_smaller_different_size_as() -> !llvm.ptr<2> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @const_zero_i32_as3 : !llvm.ptr<3> + %2 = llvm.ptrtoint %1 : !llvm.ptr<3> to i32 + %3 = llvm.inttoptr %2 : i32 to !llvm.ptr<2> + llvm.return %3 : !llvm.ptr<2> + } + llvm.func @test_constant_fold_inttoptr_as_pointer_larger() -> !llvm.ptr<3> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @const_zero_i32_as3 : !llvm.ptr<3> + %2 = llvm.ptrtoint %1 : !llvm.ptr<3> to i8 + %3 = llvm.inttoptr %2 : i8 to !llvm.ptr<3> + llvm.return %3 : !llvm.ptr<3> + } + llvm.func @const_fold_ptrtoint() -> i8 { + %0 = llvm.mlir.constant(4 : i4) : i4 + %1 = llvm.inttoptr %0 : i4 to !llvm.ptr<2> + %2 = llvm.ptrtoint %1 : !llvm.ptr<2> to i8 + llvm.return %2 : i8 + } + llvm.func @const_fold_ptrtoint_mask() -> i8 { + %0 = llvm.mlir.constant(257 : i32) : i32 + %1 = llvm.inttoptr %0 : i32 to !llvm.ptr<3> + %2 = llvm.ptrtoint %1 : !llvm.ptr<3> to i8 + llvm.return %2 : i8 + } + llvm.func @const_fold_ptrtoint_mask_small_as0() -> i64 { + %0 = llvm.mlir.constant(-1 : i128) : i128 + %1 = llvm.inttoptr %0 : i128 to !llvm.ptr<1> + %2 = llvm.ptrtoint %1 : !llvm.ptr<1> to i64 + llvm.return %2 : i64 + } + llvm.func @const_inttoptr() -> !llvm.ptr<3> { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = llvm.inttoptr %0 : i16 to !llvm.ptr<3> + llvm.return %1 : !llvm.ptr<3> + } + llvm.func @const_ptrtoint() -> i16 { + %0 = llvm.mlir.constant(89 : i32) : i32 + %1 = llvm.mlir.addressof @g : !llvm.ptr<3> + %2 = llvm.ptrtoint %1 : !llvm.ptr<3> to i16 + llvm.return %2 : i16 + } + llvm.func @const_inttoptr_ptrtoint() -> i16 { + %0 = llvm.mlir.constant(9 : i16) : i16 + llvm.return %0 : i16 + } + llvm.func @constant_fold_cmp_constantexpr_inttoptr() -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr<3> + %1 = llvm.icmp "eq" %0, %0 : !llvm.ptr<3> + llvm.return %1 : i1 + } + llvm.func @constant_fold_inttoptr_null(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(99 : i16) : i16 + %1 = llvm.inttoptr %0 : i16 to !llvm.ptr<3> + %2 = llvm.mlir.zero : !llvm.ptr<3> + %3 = llvm.icmp "eq" %1, %2 : !llvm.ptr<3> + llvm.return %3 : i1 + } + llvm.func @constant_fold_ptrtoint_null() -> i1 { + %0 = llvm.mlir.constant(89 : i32) : i32 + %1 = llvm.mlir.addressof @g : !llvm.ptr<3> + %2 = llvm.ptrtoint %1 : !llvm.ptr<3> to i16 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.icmp "eq" %2, %3 : i16 + llvm.return %4 : i1 + } + llvm.func @constant_fold_ptrtoint_null_2() -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(89 : i32) : i32 + %2 = llvm.mlir.addressof @g : !llvm.ptr<3> + %3 = llvm.ptrtoint %2 : !llvm.ptr<3> to i16 + %4 = llvm.icmp "eq" %0, %3 : i16 + llvm.return %4 : i1 + } + llvm.func @constant_fold_ptrtoint() -> i1 { + %0 = llvm.mlir.constant(89 : i32) : i32 + %1 = llvm.mlir.addressof @g : !llvm.ptr<3> + %2 = llvm.ptrtoint %1 : !llvm.ptr<3> to i16 + %3 = llvm.icmp "eq" %2, %2 : i16 + llvm.return %3 : i1 + } + llvm.func @constant_fold_inttoptr() -> i1 { + %0 = llvm.mlir.constant(99 : i16) : i16 + %1 = llvm.inttoptr %0 : i16 to !llvm.ptr<3> + %2 = llvm.mlir.constant(27 : i16) : i16 + %3 = llvm.inttoptr %2 : i16 to !llvm.ptr<3> + %4 = llvm.icmp "eq" %1, %3 : !llvm.ptr<3> + llvm.return %4 : i1 + } + llvm.func @constant_fold_bitcast_ftoi_load() -> f32 { + %0 = llvm.mlir.constant(89 : i32) : i32 + %1 = llvm.mlir.addressof @g : !llvm.ptr<3> + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr<3> -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_bitcast_itof_load() -> i32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.addressof @g_float_as3 : !llvm.ptr<3> + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr<3> -> i32 + llvm.return %2 : i32 + } + llvm.func @constant_fold_bitcast_vector_as() -> vector<4xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.mlir.addressof @g_v4f_as3 : !llvm.ptr<3> + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr<3> -> vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @test_cast_gep_small_indices_as() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : tensor<10xi32>) : !llvm.array<10 x i32> + %2 = llvm.mlir.addressof @i32_array_as3 : !llvm.ptr<3> + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr<3> -> i32 + llvm.return %3 : i32 + } + llvm.func @test_cast_gep_large_indices_as() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : tensor<10xi32>) : !llvm.array<10 x i32> + %2 = llvm.mlir.addressof @i32_array_as3 : !llvm.ptr<3> + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr<3> -> i32 + llvm.return %3 : i32 + } + llvm.func @test_constant_cast_gep_struct_indices_as() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : tensor<10xi32>) : !llvm.array<10 x i32> + %2 = llvm.mlir.addressof @i32_array_as3 : !llvm.ptr<3> + %3 = llvm.mlir.constant(dense<0> : tensor<4xi32>) : !llvm.array<4 x i32> + %4 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %5 = llvm.mlir.undef : !llvm.struct<"struct.foo", (f32, f32, array<4 x i32>, ptr<3>)> + %6 = llvm.insertvalue %4, %5[0] : !llvm.struct<"struct.foo", (f32, f32, array<4 x i32>, ptr<3>)> + %7 = llvm.insertvalue %4, %6[1] : !llvm.struct<"struct.foo", (f32, f32, array<4 x i32>, ptr<3>)> + %8 = llvm.insertvalue %3, %7[2] : !llvm.struct<"struct.foo", (f32, f32, array<4 x i32>, ptr<3>)> + %9 = llvm.insertvalue %2, %8[3] : !llvm.struct<"struct.foo", (f32, f32, array<4 x i32>, ptr<3>)> + %10 = llvm.mlir.addressof @constant_fold_global_ptr : !llvm.ptr<3> + %11 = llvm.mlir.constant(0 : i18) : i18 + %12 = llvm.mlir.constant(2 : i32) : i32 + %13 = llvm.mlir.constant(2 : i12) : i12 + %14 = llvm.getelementptr %10[%11, 2, %13] : (!llvm.ptr<3>, i18, i12) -> !llvm.ptr<3>, !llvm.struct<"struct.foo", (f32, f32, array<4 x i32>, ptr<3>)> + %15 = llvm.load %14 {alignment = 4 : i64} : !llvm.ptr<3> -> i32 + llvm.return %15 : i32 + } + llvm.func @test_read_data_from_global_as3() -> i32 { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4, 5]> : tensor<5xi32>) : !llvm.array<5 x i32> + %1 = llvm.mlir.addressof @constant_data_as3 : !llvm.ptr<3> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr<3>, i32, i32) -> !llvm.ptr<3>, !llvm.array<5 x i32> + %5 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr<3> -> i32 + llvm.return %5 : i32 + } + llvm.func @constant_through_array_as_ptrs() -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(99 : i32) : i32 + %3 = llvm.mlir.addressof @d : !llvm.ptr<1> + %4 = llvm.mlir.constant(34 : i32) : i32 + %5 = llvm.mlir.addressof @c : !llvm.ptr<1> + %6 = llvm.mlir.constant(23 : i32) : i32 + %7 = llvm.mlir.addressof @b : !llvm.ptr<1> + %8 = llvm.mlir.constant(9 : i32) : i32 + %9 = llvm.mlir.addressof @a : !llvm.ptr<1> + %10 = llvm.mlir.undef : !llvm.array<4 x ptr<1>> + %11 = llvm.insertvalue %9, %10[0] : !llvm.array<4 x ptr<1>> + %12 = llvm.insertvalue %7, %11[1] : !llvm.array<4 x ptr<1>> + %13 = llvm.insertvalue %5, %12[2] : !llvm.array<4 x ptr<1>> + %14 = llvm.insertvalue %3, %13[3] : !llvm.array<4 x ptr<1>> + %15 = llvm.mlir.addressof @ptr_array : !llvm.ptr<2> + %16 = llvm.getelementptr inbounds %15[%1, %0] : (!llvm.ptr<2>, i1, i32) -> !llvm.ptr<2>, !llvm.array<4 x ptr<1>> + %17 = llvm.mlir.addressof @indirect : !llvm.ptr + %18 = llvm.load %17 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr<2> + %19 = llvm.load %18 {alignment = 4 : i64} : !llvm.ptr<2> -> !llvm.ptr<1> + %20 = llvm.load %19 {alignment = 4 : i64} : !llvm.ptr<1> -> i32 + llvm.return %20 : i32 + } + llvm.func @canonicalize_addrspacecast(%arg0: i32) -> f32 { + %0 = llvm.mlir.addressof @shared_mem : !llvm.ptr<3> + %1 = llvm.addrspacecast %0 : !llvm.ptr<3> to !llvm.ptr + %2 = llvm.getelementptr inbounds %1[%arg0] : (!llvm.ptr, i32) -> !llvm.ptr, f32 + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.return %3 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/constant-fold-alias.ll.mlir b/test/LLVMDialect/InstCombine/constant-fold-alias.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/constant-fold-compare.ll.mlir b/test/LLVMDialect/InstCombine/constant-fold-compare.ll.mlir index db88e536a..5d1d8e208 100644 --- a/test/LLVMDialect/InstCombine/constant-fold-compare.ll.mlir +++ b/test/LLVMDialect/InstCombine/constant-fold-compare.ll.mlir @@ -1,11 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr>) -> i32 - %3 = "llvm.icmp"(%2, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - %4 = "llvm.zext"(%3) : (i1) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "a", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a() -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.icmp "eq" %0, %2 : i32 + %4 = llvm.zext %3 : i1 to i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/constant-fold-gep.ll.mlir b/test/LLVMDialect/InstCombine/constant-fold-gep.ll.mlir new file mode 100644 index 000000000..bd035dc12 --- /dev/null +++ b/test/LLVMDialect/InstCombine/constant-fold-gep.ll.mlir @@ -0,0 +1,183 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<16> : vector<4xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "big">>} { + llvm.mlir.global internal @Y() {addr_space = 0 : i32, dso_local} : !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : tensor<3xi32>) : !llvm.array<3 x i32> + %2 = llvm.mlir.undef : !llvm.struct<"struct.X", (array<3 x i32>, array<3 x i32>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.X", (array<3 x i32>, array<3 x i32>)> + %4 = llvm.insertvalue %1, %3[1] : !llvm.struct<"struct.X", (array<3 x i32>, array<3 x i32>)> + %5 = llvm.mlir.undef : !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %7 = llvm.insertvalue %4, %6[1] : !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %8 = llvm.insertvalue %4, %7[2] : !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + llvm.return %8 : !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + } + llvm.mlir.global external @X(dense<0> : tensor<1000xi8>) {addr_space = 0 : i32, alignment = 16 : i64} : !llvm.array<1000 x i8> + llvm.mlir.global external @X_as1(dense<0> : tensor<1000xi8>) {addr_space = 1 : i32, alignment = 16 : i64} : !llvm.array<1000 x i8> + llvm.mlir.global external @g() {addr_space = 0 : i32} : i8 + llvm.mlir.global external @g2() {addr_space = 0 : i32} : i8 + llvm.func @frob() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : tensor<3xi32>) : !llvm.array<3 x i32> + %3 = llvm.mlir.undef : !llvm.struct<"struct.X", (array<3 x i32>, array<3 x i32>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.X", (array<3 x i32>, array<3 x i32>)> + %5 = llvm.insertvalue %2, %4[1] : !llvm.struct<"struct.X", (array<3 x i32>, array<3 x i32>)> + %6 = llvm.mlir.undef : !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %7 = llvm.insertvalue %5, %6[0] : !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %8 = llvm.insertvalue %5, %7[1] : !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %9 = llvm.insertvalue %5, %8[2] : !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %10 = llvm.mlir.addressof @Y : !llvm.ptr + %11 = llvm.mlir.constant(1 : i64) : i64 + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.getelementptr inbounds %10[%12, %12, 0, %11] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %14 = llvm.mlir.constant(2 : i64) : i64 + %15 = llvm.getelementptr inbounds %10[%12, %12, 0, %14] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %16 = llvm.mlir.constant(3 : i64) : i64 + %17 = llvm.getelementptr %10[%12, %12, 0, %16] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %18 = llvm.mlir.constant(4 : i64) : i64 + %19 = llvm.getelementptr %10[%12, %12, 0, %18] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %20 = llvm.mlir.constant(5 : i64) : i64 + %21 = llvm.getelementptr %10[%12, %12, 0, %20] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %22 = llvm.mlir.constant(6 : i64) : i64 + %23 = llvm.getelementptr %10[%12, %12, 0, %22] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %24 = llvm.mlir.constant(7 : i64) : i64 + %25 = llvm.getelementptr %10[%12, %12, 0, %24] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %26 = llvm.mlir.constant(8 : i64) : i64 + %27 = llvm.getelementptr %10[%12, %12, 0, %26] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %28 = llvm.mlir.constant(9 : i64) : i64 + %29 = llvm.getelementptr %10[%12, %12, 0, %28] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %30 = llvm.mlir.constant(10 : i64) : i64 + %31 = llvm.getelementptr %10[%12, %12, 0, %30] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %32 = llvm.mlir.constant(11 : i64) : i64 + %33 = llvm.getelementptr %10[%12, %12, 0, %32] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %34 = llvm.mlir.constant(12 : i64) : i64 + %35 = llvm.getelementptr %10[%12, %12, 0, %34] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %36 = llvm.mlir.constant(13 : i64) : i64 + %37 = llvm.getelementptr %10[%12, %12, 0, %36] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %38 = llvm.mlir.constant(14 : i64) : i64 + %39 = llvm.getelementptr %10[%12, %12, 0, %38] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %40 = llvm.mlir.constant(15 : i64) : i64 + %41 = llvm.getelementptr %10[%12, %12, 0, %40] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %42 = llvm.mlir.constant(16 : i64) : i64 + %43 = llvm.getelementptr %10[%12, %12, 0, %42] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %44 = llvm.mlir.constant(17 : i64) : i64 + %45 = llvm.getelementptr %10[%12, %12, 0, %44] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %46 = llvm.mlir.constant(18 : i64) : i64 + %47 = llvm.getelementptr %10[%12, %12, 0, %46] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %48 = llvm.mlir.constant(36 : i64) : i64 + %49 = llvm.getelementptr %10[%12, %12, 0, %48] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + %50 = llvm.mlir.constant(19 : i64) : i64 + %51 = llvm.getelementptr %10[%12, %12, 0, %50] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<3 x struct<"struct.X", (array<3 x i32>, array<3 x i32>)>> + llvm.store %0, %10 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %13 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %15 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %17 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %19 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %21 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %23 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %25 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %27 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %29 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %31 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %33 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %35 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %37 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %39 {alignment = 8 : i64} : i32, !llvm.ptr + llvm.store %0, %41 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %43 {alignment = 8 : i64} : i32, !llvm.ptr + llvm.store %0, %45 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %47 {alignment = 8 : i64} : i32, !llvm.ptr + llvm.store %0, %49 {alignment = 8 : i64} : i32, !llvm.ptr + llvm.store %0, %51 {alignment = 8 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test2() -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(dense<0> : tensor<1000xi8>) : !llvm.array<1000 x i8> + %4 = llvm.mlir.addressof @X : !llvm.ptr + %5 = llvm.getelementptr inbounds %4[%1, %0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<1000 x i8> + %6 = llvm.bitcast %5 : !llvm.ptr to !llvm.ptr + %7 = llvm.ptrtoint %4 : !llvm.ptr to i64 + %8 = llvm.sub %0, %7 : i64 + %9 = llvm.getelementptr %6[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %10 = llvm.ptrtoint %9 : !llvm.ptr to i64 + llvm.return %10 : i64 + } + llvm.func @test2_as1() -> i16 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(dense<0> : tensor<1000xi8>) : !llvm.array<1000 x i8> + %4 = llvm.mlir.addressof @X_as1 : !llvm.ptr<1> + %5 = llvm.getelementptr inbounds %4[%1, %0] : (!llvm.ptr<1>, i64, i64) -> !llvm.ptr<1>, !llvm.array<1000 x i8> + %6 = llvm.mlir.constant(0 : i16) : i16 + %7 = llvm.bitcast %5 : !llvm.ptr<1> to !llvm.ptr<1> + %8 = llvm.ptrtoint %4 : !llvm.ptr<1> to i16 + %9 = llvm.sub %6, %8 : i16 + %10 = llvm.getelementptr %7[%9] : (!llvm.ptr<1>, i16) -> !llvm.ptr<1>, i8 + %11 = llvm.ptrtoint %10 : !llvm.ptr<1> to i16 + llvm.return %11 : i16 + } + llvm.func @get.i64() -> i64 + llvm.func @use.ptr(!llvm.ptr) + llvm.func @gep_sub_self() -> !llvm.ptr { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %3 = llvm.sub %1, %2 : i64 + %4 = llvm.getelementptr %0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.return %4 : !llvm.ptr + } + llvm.func @gep_sub_self_plus_addr(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %3 = llvm.sub %1, %2 : i64 + %4 = llvm.getelementptr %0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %5 = llvm.getelementptr %4[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.return %5 : !llvm.ptr + } + llvm.func @gep_plus_addr_sub_self(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %3 = llvm.sub %1, %2 : i64 + %4 = llvm.getelementptr %0[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %5 = llvm.getelementptr %4[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.return %5 : !llvm.ptr + } + llvm.func @gep_plus_addr_sub_self_in_loop() -> !llvm.ptr { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %3 = llvm.sub %1, %2 : i64 + llvm.br ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb1 + %4 = llvm.call @get.i64() : () -> i64 + %5 = llvm.getelementptr %0[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %6 = llvm.getelementptr %5[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call @use.ptr(%6) : (!llvm.ptr) -> () + llvm.br ^bb1 + } + llvm.func @gep_sub_other() -> !llvm.ptr { + %0 = llvm.mlir.addressof @g2 : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.addressof @g : !llvm.ptr + %3 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %4 = llvm.sub %1, %3 : i64 + %5 = llvm.getelementptr %2[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.return %5 : !llvm.ptr + } + llvm.func @gep_sub_other_to_int() -> i64 { + %0 = llvm.mlir.addressof @g2 : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.addressof @g : !llvm.ptr + %3 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %4 = llvm.sub %1, %3 : i64 + %5 = llvm.getelementptr %2[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %6 = llvm.ptrtoint %5 : !llvm.ptr to i64 + llvm.return %6 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/constant-fold-iteration.ll.mlir b/test/LLVMDialect/InstCombine/constant-fold-iteration.ll.mlir index db88e536a..212a956b7 100644 --- a/test/LLVMDialect/InstCombine/constant-fold-iteration.ll.mlir +++ b/test/LLVMDialect/InstCombine/constant-fold-iteration.ll.mlir @@ -1,11 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr>) -> i32 - %3 = "llvm.icmp"(%2, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - %4 = "llvm.zext"(%3) : (i1) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "a", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a() -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.icmp "eq" %0, %2 : i32 + %4 = llvm.zext %3 : i1 to i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/constant-fold-libfunc.ll.mlir b/test/LLVMDialect/InstCombine/constant-fold-libfunc.ll.mlir index dc582e266..72e0e9456 100644 --- a/test/LLVMDialect/InstCombine/constant-fold-libfunc.ll.mlir +++ b/test/LLVMDialect/InstCombine/constant-fold-libfunc.ll.mlir @@ -1,20 +1,18 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "acos", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = -1.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @acos, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_acos", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = -1.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @acos, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_acos_nobuiltin", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = -1.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @acos, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_acos_strictfp", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @acos(f64) -> f64 attributes {passthrough = ["willreturn"]} + llvm.func @test_simplify_acos() -> f64 { + %0 = llvm.mlir.constant(-1.000000e+00 : f64) : f64 + %1 = llvm.call @acos(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_acos_nobuiltin() -> f64 { + %0 = llvm.mlir.constant(-1.000000e+00 : f64) : f64 + %1 = llvm.call @acos(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_acos_strictfp() -> f64 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(-1.000000e+00 : f64) : f64 + %1 = llvm.call @acos(%0) : (f64) -> f64 + llvm.return %1 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/constant-fold-math.ll.mlir b/test/LLVMDialect/InstCombine/constant-fold-math.ll.mlir index 41367926f..ef038bb97 100644 --- a/test/LLVMDialect/InstCombine/constant-fold-math.ll.mlir +++ b/test/LLVMDialect/InstCombine/constant-fold-math.ll.mlir @@ -1,62 +1,49 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.fma.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.fmuladd.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.fma.v4f32", type = !llvm.func (vector<4xf32>, vector<4xf32>, vector<4xf32>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.fma.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.fmuladd.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.sqrt.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4.000000e+00 : f32} : () -> f32 - %1 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - %2 = "llvm.mlir.constant"() {value = 1.000000e+00 : f32} : () -> f32 - %3 = "llvm.call"(%2, %1, %0) {callee = @llvm.fma.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32, f32) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_fma_f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = dense<1.000000e+01> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.mlir.constant"() {value = dense<2.000000e+00> : vector<4xf32>} : () -> vector<4xf32> - %2 = "llvm.mlir.constant"() {value = dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>} : () -> vector<4xf32> - %3 = "llvm.call"(%2, %1, %0) {callee = @llvm.fma.v4f32, fastmathFlags = #llvm.fastmath<>} : (vector<4xf32>, vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%3) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_fma_v4f32", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4.000000e+00 : f32} : () -> f32 - %1 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - %2 = "llvm.mlir.constant"() {value = 1.000000e+00 : f32} : () -> f32 - %3 = "llvm.call"(%2, %1, %0) {callee = @llvm.fmuladd.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32, f32) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_fmuladd_f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4.000000e+00 : f64} : () -> f64 - %1 = "llvm.mlir.constant"() {value = 2.000000e+00 : f64} : () -> f64 - %2 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %3 = "llvm.call"(%2, %1, %0) {callee = @llvm.fma.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64, f64) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_fma_f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4.000000e+00 : f64} : () -> f64 - %1 = "llvm.mlir.constant"() {value = 2.000000e+00 : f64} : () -> f64 - %2 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %3 = "llvm.call"(%2, %1, %0) {callee = @llvm.fmuladd.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64, f64) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_fmuladd_f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = -2.50991821E+9 : f32} : () -> f32 - %1 = "llvm.mlir.constant"() {value = 4.03345148E+18 : f32} : () -> f32 - %2 = "llvm.frem"(%1, %0) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_frem_f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.mlir.constant"() {value = 9.2233720368547758E+18 : f64} : () -> f64 - %2 = "llvm.frem"(%1, %0) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_frem_f64", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @constant_fold_fma_f32() -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %3 = llvm.intr.fma(%0, %1, %2) : (f32, f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @constant_fold_fma_v4f32() -> vector<4xf32> attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<2.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.mlir.constant(dense<1.000000e+01> : vector<4xf32>) : vector<4xf32> + %3 = llvm.intr.fma(%0, %1, %2) : (vector<4xf32>, vector<4xf32>, vector<4xf32>) -> vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @constant_fold_fmuladd_f32() -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %3 = llvm.intr.fmuladd(%0, %1, %2) : (f32, f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @constant_fold_fma_f64() -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(4.000000e+00 : f64) : f64 + %3 = llvm.intr.fma(%0, %1, %2) : (f64, f64, f64) -> f64 + llvm.return %3 : f64 + } + llvm.func @constant_fold_fmuladd_f64() -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(4.000000e+00 : f64) : f64 + %3 = llvm.intr.fmuladd(%0, %1, %2) : (f64, f64, f64) -> f64 + llvm.return %3 : f64 + } + llvm.func @constant_fold_frem_f32() -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(4.03345148E+18 : f32) : f32 + %1 = llvm.mlir.constant(-2.50991821E+9 : f32) : f32 + %2 = llvm.frem %0, %1 : f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_frem_f64() -> f64 { + %0 = llvm.mlir.constant(9.2233720368547758E+18 : f64) : f64 + %1 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %2 = llvm.frem %0, %1 : f64 + llvm.return %2 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/constant-fold-shifts.ll.mlir b/test/LLVMDialect/InstCombine/constant-fold-shifts.ll.mlir new file mode 100644 index 000000000..f34278684 --- /dev/null +++ b/test/LLVMDialect/InstCombine/constant-fold-shifts.ll.mlir @@ -0,0 +1,33 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @A() {addr_space = 0 : i32} : i32 + llvm.func @ossfuzz_14169_test1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.addressof @A : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(0 : i712) : i712 + %3 = llvm.mlir.constant(1 : i712) : i712 + %4 = llvm.mlir.constant(146783911423364576743092537299333564210980159306769991919205685720763064069663027716481187399048043939495936 : i712) : i712 + %5 = llvm.mlir.undef : !llvm.ptr + %6 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %7 = llvm.icmp "sge" %6, %1 : i64 + %8 = llvm.select %7, %2, %3 : i1, i712 + %9 = llvm.lshr %8, %4 : i712 + %10 = llvm.getelementptr %5[%9] : (!llvm.ptr, i712) -> !llvm.ptr, i64 + llvm.store %10, %5 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @ossfuzz_14169_test2(%arg0: !llvm.ptr) { + %0 = llvm.mlir.addressof @A : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(0 : i712) : i712 + %3 = llvm.mlir.constant(1 : i712) : i712 + %4 = llvm.mlir.constant(146783911423364576743092537299333564210980159306769991919205685720763064069663027716481187399048043939495936 : i712) : i712 + %5 = llvm.mlir.undef : !llvm.ptr + %6 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %7 = llvm.icmp "sge" %6, %1 : i64 + %8 = llvm.select %7, %2, %3 : i1, i712 + %9 = llvm.shl %8, %4 : i712 + %10 = llvm.getelementptr %5[%9] : (!llvm.ptr, i712) -> !llvm.ptr, i64 + llvm.store %10, %5 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/constrained.ll.mlir b/test/LLVMDialect/InstCombine/constrained.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/convergent.ll.mlir b/test/LLVMDialect/InstCombine/convergent.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/copysign-fneg-fabs.ll.mlir b/test/LLVMDialect/InstCombine/copysign-fneg-fabs.ll.mlir new file mode 100644 index 000000000..87ff67318 --- /dev/null +++ b/test/LLVMDialect/InstCombine/copysign-fneg-fabs.ll.mlir @@ -0,0 +1,181 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @copysign_fneg_x(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.fneg %arg0 : f16 + %1 = llvm.intr.copysign(%0, %arg1) : (f16, f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @copysign_fabs_x(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %1 = llvm.intr.copysign(%0, %arg1) : (f16, f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @copysign_fneg_fabs_x(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %1 = llvm.fneg %0 : f16 + %2 = llvm.intr.copysign(%1, %arg1) : (f16, f16) -> f16 + llvm.return %2 : f16 + } + llvm.func @copysign_fneg_y(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.fneg %arg1 : f16 + %1 = llvm.intr.copysign(%arg0, %0) : (f16, f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @copysign_fabs_y(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.intr.fabs(%arg1) : (f16) -> f16 + %1 = llvm.intr.copysign(%arg0, %0) : (f16, f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @copysign_fneg_fabs_y(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.intr.fabs(%arg1) : (f16) -> f16 + %1 = llvm.fneg %0 : f16 + %2 = llvm.intr.copysign(%arg0, %1) : (f16, f16) -> f16 + llvm.return %2 : f16 + } + llvm.func @fneg_copysign(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f16, f16) -> f16 + %1 = llvm.fneg %0 : f16 + llvm.return %1 : f16 + } + llvm.func @fneg_fabs_copysign(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f16, f16) -> f16 + %1 = llvm.intr.fabs(%0) : (f16) -> f16 + %2 = llvm.fneg %1 : f16 + llvm.return %2 : f16 + } + llvm.func @fabs_copysign(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f16, f16) -> f16 + %1 = llvm.intr.fabs(%0) : (f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @fneg_copysign_vector(%arg0: vector<2xf16>, %arg1: vector<2xf16>) -> vector<2xf16> { + %0 = llvm.intr.copysign(%arg0, %arg1) : (vector<2xf16>, vector<2xf16>) -> vector<2xf16> + %1 = llvm.fneg %0 : vector<2xf16> + llvm.return %1 : vector<2xf16> + } + llvm.func @fneg_fabs_copysign_vector(%arg0: vector<2xf16>, %arg1: vector<2xf16>) -> vector<2xf16> { + %0 = llvm.intr.copysign(%arg0, %arg1) : (vector<2xf16>, vector<2xf16>) -> vector<2xf16> + %1 = llvm.intr.fabs(%0) : (vector<2xf16>) -> vector<2xf16> + %2 = llvm.fneg %1 : vector<2xf16> + llvm.return %2 : vector<2xf16> + } + llvm.func @fabs_copysign_vector(%arg0: vector<2xf16>, %arg1: vector<2xf16>) -> vector<2xf16> { + %0 = llvm.intr.copysign(%arg0, %arg1) : (vector<2xf16>, vector<2xf16>) -> vector<2xf16> + %1 = llvm.intr.fabs(%0) : (vector<2xf16>) -> vector<2xf16> + llvm.return %1 : vector<2xf16> + } + llvm.func @fneg_copysign_flags(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f16, f16) -> f16 + %1 = llvm.fneg %0 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %1 : f16 + } + llvm.func @fneg_fabs_copysign_flags(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f16, f16) -> f16 + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f16) -> f16 + %2 = llvm.fneg %1 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %2 : f16 + } + llvm.func @fneg_nsz_copysign(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f16, f16) -> f16 + %1 = llvm.fneg %0 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %1 : f16 + } + llvm.func @fneg_fabs_copysign_flags_none_fabs(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f16, f16) -> f16 + %1 = llvm.intr.fabs(%0) : (f16) -> f16 + %2 = llvm.fneg %1 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %2 : f16 + } + llvm.func @fabs_copysign_flags(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f16, f16) -> f16 + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @fabs_copysign_all_flags(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f16, f16) -> f16 + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @fabs_copysign_no_flags_copysign_user(%arg0: f16, %arg1: f16, %arg2: !llvm.ptr) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f16, f16) -> f16 + llvm.store %0, %arg2 {alignment = 2 : i64} : f16, !llvm.ptr + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @fneg_fabs_copysign_drop_flags(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f16, f16) -> f16 + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f16) -> f16 + %2 = llvm.fneg %1 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %2 : f16 + } + llvm.func @fneg_copysign_multi_use(%arg0: f16, %arg1: f16, %arg2: !llvm.ptr) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f16, f16) -> f16 + llvm.store %0, %arg2 {alignment = 2 : i64} : f16, !llvm.ptr + %1 = llvm.fneg %0 : f16 + llvm.return %1 : f16 + } + llvm.func @fabs_copysign_multi_use(%arg0: f16, %arg1: f16, %arg2: !llvm.ptr) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f16, f16) -> f16 + llvm.store %0, %arg2 {alignment = 2 : i64} : f16, !llvm.ptr + %1 = llvm.intr.fabs(%0) : (f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @fabs_flags_copysign_multi_use(%arg0: f16, %arg1: f16, %arg2: !llvm.ptr) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f16, f16) -> f16 + llvm.store %0, %arg2 {alignment = 2 : i64} : f16, !llvm.ptr + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @fneg_fabs_copysign_multi_use_fabs(%arg0: f16, %arg1: f16, %arg2: !llvm.ptr) -> f16 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f16, f16) -> f16 + %1 = llvm.intr.fabs(%0) : (f16) -> f16 + llvm.store %1, %arg2 {alignment = 2 : i64} : f16, !llvm.ptr + llvm.return %1 : f16 + } + llvm.func @copysign_pos(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(1.000000e+00 : f16) : f16 + %1 = llvm.intr.copysign(%0, %arg0) : (f16, f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @copysign_neg(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(-1.000000e+00 : f16) : f16 + %1 = llvm.intr.copysign(%0, %arg0) : (f16, f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @copysign_negzero(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(-0.000000e+00 : f16) : f16 + %1 = llvm.intr.copysign(%0, %arg0) : (f16, f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @copysign_negnan(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(0xFE00 : f16) : f16 + %1 = llvm.intr.copysign(%0, %arg0) : (f16, f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @copysign_neginf(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(0xFC00 : f16) : f16 + %1 = llvm.intr.copysign(%0, %arg0) : (f16, f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @copysign_splat(%arg0: vector<4xf16>) -> vector<4xf16> { + %0 = llvm.mlir.constant(dense<-1.000000e+00> : vector<4xf16>) : vector<4xf16> + %1 = llvm.intr.copysign(%0, %arg0) : (vector<4xf16>, vector<4xf16>) -> vector<4xf16> + llvm.return %1 : vector<4xf16> + } + llvm.func @copysign_vec4(%arg0: vector<4xf16>) -> vector<4xf16> { + %0 = llvm.mlir.poison : f16 + %1 = llvm.mlir.undef : f16 + %2 = llvm.mlir.constant(-1.000000e+00 : f16) : f16 + %3 = llvm.mlir.constant(1.000000e+00 : f16) : f16 + %4 = llvm.mlir.undef : vector<4xf16> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xf16> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xf16> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xf16> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xf16> + %13 = llvm.intr.copysign(%12, %arg0) : (vector<4xf16>, vector<4xf16>) -> vector<4xf16> + llvm.return %13 : vector<4xf16> + } +} diff --git a/test/LLVMDialect/InstCombine/copysign.ll.mlir b/test/LLVMDialect/InstCombine/copysign.ll.mlir new file mode 100644 index 000000000..8f0148d29 --- /dev/null +++ b/test/LLVMDialect/InstCombine/copysign.ll.mlir @@ -0,0 +1,53 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @positive_sign_arg(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.intr.copysign(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @positive_sign_arg_vec_splat(%arg0: vector<3xf64>) -> vector<3xf64> { + %0 = llvm.mlir.constant(dense<4.200000e+01> : vector<3xf64>) : vector<3xf64> + %1 = llvm.intr.copysign(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<3xf64>, vector<3xf64>) -> vector<3xf64> + llvm.return %1 : vector<3xf64> + } + llvm.func @negative_sign_arg(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.intr.copysign(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @negative_sign_arg_vec_splat(%arg0: vector<3xf64>) -> vector<3xf64> { + %0 = llvm.mlir.constant(dense<-4.200000e+01> : vector<3xf64>) : vector<3xf64> + %1 = llvm.intr.copysign(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<3xf64>, vector<3xf64>) -> vector<3xf64> + llvm.return %1 : vector<3xf64> + } + llvm.func @known_positive_sign_arg(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.fabs(%arg1) : (f32) -> f32 + %1 = llvm.intr.copysign(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @known_positive_sign_arg_vec(%arg0: vector<3xf64>, %arg1: vector<3xi32>) -> vector<3xf64> { + %0 = llvm.uitofp %arg1 : vector<3xi32> to vector<3xf64> + %1 = llvm.intr.copysign(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<3xf64>, vector<3xf64>) -> vector<3xf64> + llvm.return %1 : vector<3xf64> + } + llvm.func @not_known_positive_sign_arg(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.intr.maxnum(%arg0, %0) : (f32, f32) -> f32 + %2 = llvm.intr.copysign(%arg1, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @copysign_sign_arg(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.intr.copysign(%arg1, %arg2) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %1 = llvm.intr.copysign(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fneg_mag(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.intr.copysign(%0, %arg1) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fabs_mag(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.intr.copysign(%0, %arg1) : (f32, f32) -> f32 + llvm.return %1 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/cos-1.ll.mlir b/test/LLVMDialect/InstCombine/cos-1.ll.mlir new file mode 100644 index 000000000..bce8b4c7d --- /dev/null +++ b/test/LLVMDialect/InstCombine/cos-1.ll.mlir @@ -0,0 +1,229 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @cos(f64) -> f64 + llvm.func @cosf(f32) -> f32 + llvm.func @sin(f64) -> f64 + llvm.func @sinf(f32) -> f32 + llvm.func @tan(f64) -> f64 + llvm.func @tanl(f128) -> f128 + llvm.func @fabs(f64) -> f64 + llvm.func @fabsf(f32) -> f32 + llvm.func @cos_negated_arg(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.call @cos(%1) : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @cos_negated_arg_tail(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.call @cos(%1) : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @cos_negated_arg_musttail(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.call @cos(%1) : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @cos_unary_negated_arg(%arg0: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.call @cos(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @cosf_negated_arg(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.call @cosf(%1) : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @cosf_unary_negated_arg(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.call @cosf(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @cosf_negated_arg_FMF(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.call @cosf(%1) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @cosf_unary_negated_arg_FMF(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.call @cosf(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @cos_unary_fabs_arg(%arg0: f64) -> f64 { + %0 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %1 = llvm.call @cos(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @cosf_unary_fabs_arg(%arg0: f32) -> f32 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.call @cosf(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @cosf_unary_fabs_arg_FMF(%arg0: f32) -> f32 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.call @cosf(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @cos_copysign_arg(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.call @cos(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @cosf_unary_copysign_arg(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.copysign(%arg0, %0) : (f32, f32) -> f32 + %2 = llvm.call @cosf(%1) : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @cosf_copysign_arg_FMF(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.call @cosf(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @sin_negated_arg(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.call @sin(%1) : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @sin_unary_negated_arg(%arg0: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.call @sin(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sin_unary_negated_arg_musttail(%arg0: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.call @sin(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sinf_negated_arg(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.call @sinf(%1) : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @sinf_unary_negated_arg(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.call @sinf(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @sinf_negated_arg_FMF(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.call @sinf(%1) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @sinf_unary_negated_arg_FMF(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.call @sinf(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @use(f64) + llvm.func @sin_negated_arg_extra_use(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.call @sin(%1) : (f64) -> f64 + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @sin_unary_negated_arg_extra_use(%arg0: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.call @sin(%0) : (f64) -> f64 + llvm.call @use(%0) : (f64) -> () + llvm.return %1 : f64 + } + llvm.func @neg_sin_negated_arg(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.call @sin(%1) : (f64) -> f64 + %3 = llvm.fsub %0, %2 : f64 + llvm.return %3 : f64 + } + llvm.func @unary_neg_sin_unary_negated_arg(%arg0: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.call @sin(%0) : (f64) -> f64 + %2 = llvm.fneg %1 : f64 + llvm.return %2 : f64 + } + llvm.func @neg_sin_unary_negated_arg(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.call @sin(%1) : (f64) -> f64 + %3 = llvm.fneg %2 : f64 + llvm.return %3 : f64 + } + llvm.func @unary_neg_sin_negated_arg(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fneg %arg0 : f64 + %2 = llvm.call @sin(%1) : (f64) -> f64 + %3 = llvm.fsub %0, %2 : f64 + llvm.return %3 : f64 + } + llvm.func @tan_negated_arg(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.call @tan(%1) : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @tan_negated_arg_tail(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.call @tan(%1) : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @tan_negated_arg_musttail(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.call @tan(%1) : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @tan_unary_negated_arg(%arg0: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.call @tan(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @tanl_negated_arg(%arg0: f128) -> f128 { + %0 = llvm.mlir.constant(-0.000000e+00 : f128) : f128 + %1 = llvm.fsub %0, %arg0 : f128 + %2 = llvm.call @tanl(%1) : (f128) -> f128 + llvm.return %2 : f128 + } + llvm.func @tanl_unary_negated_arg(%arg0: f128) -> f128 { + %0 = llvm.fneg %arg0 : f128 + %1 = llvm.call @tanl(%0) : (f128) -> f128 + llvm.return %1 : f128 + } + llvm.func @negated_and_shrinkable_libcall(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fpext %arg0 : f32 to f64 + %2 = llvm.fsub %0, %1 : f64 + %3 = llvm.call @cos(%2) : (f64) -> f64 + %4 = llvm.fptrunc %3 : f64 to f32 + llvm.return %4 : f32 + } + llvm.func @unary_negated_and_shrinkable_libcall(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fneg %0 : f64 + %2 = llvm.call @cos(%1) : (f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @negated_and_shrinkable_intrinsic(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fpext %arg0 : f32 to f64 + %2 = llvm.fsub %0, %1 : f64 + %3 = llvm.intr.cos(%2) : (f64) -> f64 + %4 = llvm.fptrunc %3 : f64 to f32 + llvm.return %4 : f32 + } + llvm.func @unary_negated_and_shrinkable_intrinsic(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fneg %0 : f64 + %2 = llvm.intr.cos(%1) : (f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/cos-2.ll.mlir b/test/LLVMDialect/InstCombine/cos-2.ll.mlir new file mode 100644 index 000000000..0929eaf4d --- /dev/null +++ b/test/LLVMDialect/InstCombine/cos-2.ll.mlir @@ -0,0 +1,19 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @cos(f64) -> f32 + llvm.func @sqrt(...) -> (i8 {llvm.signext}) + llvm.func @test_no_simplify1(%arg0: f64) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.call @cos(%1) : (f64) -> f32 + llvm.return %2 : f32 + } + llvm.func @test_no_simplify2(%arg0: f64) -> f32 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.call @cos(%0) : (f64) -> f32 + llvm.return %1 : f32 + } + llvm.func @bogus_sqrt() -> i8 { + %0 = llvm.call @sqrt() vararg(!llvm.func) : () -> i8 + llvm.return %0 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/cos-sin-intrinsic.ll.mlir b/test/LLVMDialect/InstCombine/cos-sin-intrinsic.ll.mlir new file mode 100644 index 000000000..83d60cfb9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/cos-sin-intrinsic.ll.mlir @@ -0,0 +1,100 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @undef_arg() -> f64 { + %0 = llvm.mlir.undef : f64 + %1 = llvm.intr.cos(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @undef_arg2(%arg0: f32) -> f32 { + %0 = llvm.mlir.undef : f32 + %1 = llvm.intr.cos(%arg0) : (f32) -> f32 + %2 = llvm.intr.cos(%0) : (f32) -> f32 + %3 = llvm.fadd %2, %1 : f32 + llvm.return %3 : f32 + } + llvm.func @fneg_f32(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.intr.cos(%1) : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @unary_fneg_f32(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.intr.cos(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fneg_v2f32(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 : vector<2xf32> + %2 = llvm.intr.cos(%1) : (vector<2xf32>) -> vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @unary_fneg_v2f32(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fneg %arg0 : vector<2xf32> + %1 = llvm.intr.cos(%0) : (vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @fneg_cos_fmf(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %2 = llvm.intr.cos(%1) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @unary_fneg_cos_fmf(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %1 = llvm.intr.cos(%0) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @fabs_f32(%arg0: f32) -> f32 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.intr.cos(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fabs_fneg_f32(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %2 = llvm.fsub %0, %1 : f32 + %3 = llvm.intr.cos(%2) : (f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @fabs_unary_fneg_f32(%arg0: f32) -> f32 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = llvm.intr.cos(%1) : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @fabs_fneg_v2f32(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.intr.fabs(%arg0) : (vector<2xf32>) -> vector<2xf32> + %2 = llvm.fsub %0, %1 : vector<2xf32> + %3 = llvm.intr.cos(%2) : (vector<2xf32>) -> vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @fabs_unary_fneg_v2f32(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.intr.fabs(%arg0) : (vector<2xf32>) -> vector<2xf32> + %1 = llvm.fneg %0 : vector<2xf32> + %2 = llvm.intr.cos(%1) : (vector<2xf32>) -> vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fneg_sin(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 : vector<2xf32> + %2 = llvm.intr.sin(%1) : (vector<2xf32>) -> vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @unary_fneg_sin(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fneg %arg0 : vector<2xf32> + %1 = llvm.intr.sin(%0) : (vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @fneg_sin_fmf(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %2 = llvm.intr.sin(%1) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @unary_fneg_sin_fmf(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %1 = llvm.intr.sin(%0) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/crash.ll.mlir b/test/LLVMDialect/InstCombine/crash.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/create-class-from-logic-fcmp.ll.mlir b/test/LLVMDialect/InstCombine/create-class-from-logic-fcmp.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/ctlz-cttz-bitreverse.ll.mlir b/test/LLVMDialect/InstCombine/ctlz-cttz-bitreverse.ll.mlir index 9db4c6be5..e50d77527 100644 --- a/test/LLVMDialect/InstCombine/ctlz-cttz-bitreverse.ll.mlir +++ b/test/LLVMDialect/InstCombine/ctlz-cttz-bitreverse.ll.mlir @@ -1,57 +1,32 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.call"(%arg0) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %2 = "llvm.call"(%1, %0) {callee = @llvm.ctlz.i32, fastmathFlags = #llvm.fastmath<>} : (i32, i1) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "ctlz_true_bitreverse", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.call"(%arg0) {callee = @llvm.bitreverse.v2i64, fastmathFlags = #llvm.fastmath<>} : (vector<2xi64>) -> vector<2xi64> - %2 = "llvm.call"(%1, %0) {callee = @llvm.ctlz.v2i64, fastmathFlags = #llvm.fastmath<>} : (vector<2xi64>, i1) -> vector<2xi64> - "llvm.return"(%2) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "ctlz_true_bitreverse_vec", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.call"(%arg0) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %2 = "llvm.call"(%1, %0) {callee = @llvm.ctlz.i32, fastmathFlags = #llvm.fastmath<>} : (i32, i1) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "ctlz_false_bitreverse", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.call"(%arg0) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %2 = "llvm.call"(%1, %0) {callee = @llvm.cttz.i32, fastmathFlags = #llvm.fastmath<>} : (i32, i1) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "cttz_true_bitreverse", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.call"(%arg0) {callee = @llvm.bitreverse.v2i64, fastmathFlags = #llvm.fastmath<>} : (vector<2xi64>) -> vector<2xi64> - %2 = "llvm.call"(%1, %0) {callee = @llvm.cttz.v2i64, fastmathFlags = #llvm.fastmath<>} : (vector<2xi64>, i1) -> vector<2xi64> - "llvm.return"(%2) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "cttz_true_bitreverse_vec", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.call"(%arg0) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %2 = "llvm.call"(%1, %0) {callee = @llvm.cttz.i32, fastmathFlags = #llvm.fastmath<>} : (i32, i1) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "cttz_false_bitreverse", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.bitreverse.i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.bitreverse.v2i64", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ctlz.i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.cttz.i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ctlz.v2i64", type = !llvm.func (vector<2xi64>, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.cttz.v2i64", type = !llvm.func (vector<2xi64>, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @ctlz_true_bitreverse(%arg0: i32) -> i32 { + %0 = llvm.intr.bitreverse(%arg0) : (i32) -> i32 + %1 = "llvm.intr.ctlz"(%0) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @ctlz_true_bitreverse_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.intr.bitreverse(%arg0) : (vector<2xi64>) -> vector<2xi64> + %1 = "llvm.intr.ctlz"(%0) <{is_zero_poison = true}> : (vector<2xi64>) -> vector<2xi64> + llvm.return %1 : vector<2xi64> + } + llvm.func @ctlz_false_bitreverse(%arg0: i32) -> i32 { + %0 = llvm.intr.bitreverse(%arg0) : (i32) -> i32 + %1 = "llvm.intr.ctlz"(%0) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @cttz_true_bitreverse(%arg0: i32) -> i32 { + %0 = llvm.intr.bitreverse(%arg0) : (i32) -> i32 + %1 = "llvm.intr.cttz"(%0) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @cttz_true_bitreverse_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.intr.bitreverse(%arg0) : (vector<2xi64>) -> vector<2xi64> + %1 = "llvm.intr.cttz"(%0) <{is_zero_poison = true}> : (vector<2xi64>) -> vector<2xi64> + llvm.return %1 : vector<2xi64> + } + llvm.func @cttz_false_bitreverse(%arg0: i32) -> i32 { + %0 = llvm.intr.bitreverse(%arg0) : (i32) -> i32 + %1 = "llvm.intr.cttz"(%0) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/ctlz-cttz-shifts.ll.mlir b/test/LLVMDialect/InstCombine/ctlz-cttz-shifts.ll.mlir new file mode 100644 index 000000000..53ec6bd5d --- /dev/null +++ b/test/LLVMDialect/InstCombine/ctlz-cttz-shifts.ll.mlir @@ -0,0 +1,116 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @lshr_ctlz_true(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8387584 : i32) : i32 + %1 = llvm.lshr %0, %arg0 : i32 + %2 = "llvm.intr.ctlz"(%1) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @shl_nuw_ctlz_true(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8387584 : i32) : i32 + %1 = llvm.shl %0, %arg0 overflow : i32 + %2 = "llvm.intr.ctlz"(%1) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @shl_nuw_nsw_ctlz_true(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8387584 : i32) : i32 + %1 = llvm.shl %0, %arg0 overflow : i32 + %2 = "llvm.intr.ctlz"(%1) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @lshr_exact_cttz_true(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8387584 : i32) : i32 + %1 = llvm.lshr %0, %arg0 : i32 + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @shl_cttz_true(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8387584 : i32) : i32 + %1 = llvm.shl %0, %arg0 : i32 + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @vec2_lshr_ctlz_true(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[8387584, 4276440]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.lshr %0, %arg0 : vector<2xi32> + %2 = "llvm.intr.ctlz"(%1) <{is_zero_poison = true}> : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @vec2_shl_nuw_ctlz_true(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[8387584, 4276440]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.shl %0, %arg0 overflow : vector<2xi32> + %2 = "llvm.intr.ctlz"(%1) <{is_zero_poison = true}> : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @vec2_shl_nuw_nsw_ctlz_true(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[8387584, 4276440]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.shl %0, %arg0 overflow : vector<2xi32> + %2 = "llvm.intr.ctlz"(%1) <{is_zero_poison = true}> : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @vec2_lshr_exact_cttz_true(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[8387584, 4276440]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.lshr %0, %arg0 : vector<2xi32> + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = true}> : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @vec2_shl_cttz_true(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[8387584, 4276440]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.shl %0, %arg0 : vector<2xi32> + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = true}> : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @vec2_shl_nsw_ctlz_true_neg(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[8387584, 4276440]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.shl %0, %arg0 overflow : vector<2xi32> + %2 = "llvm.intr.ctlz"(%1) <{is_zero_poison = true}> : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @vec2_lshr_ctlz_false_neg(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[8387584, 4276440]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.lshr %0, %arg0 : vector<2xi32> + %2 = "llvm.intr.ctlz"(%1) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @vec2_shl_ctlz_false_neg(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[8387584, 4276440]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.shl %0, %arg0 : vector<2xi32> + %2 = "llvm.intr.ctlz"(%1) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @vec2_lshr_cttz_false_neg(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[8387584, 4276440]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.lshr %0, %arg0 : vector<2xi32> + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @vec2_shl_cttz_false_neg(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[8387584, 4276440]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.shl %0, %arg0 : vector<2xi32> + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @lshr_ctlz_faslse_neg(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8387584 : i32) : i32 + %1 = llvm.lshr %0, %arg0 : i32 + %2 = "llvm.intr.ctlz"(%1) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @shl_ctlz_false_neg(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8387584 : i32) : i32 + %1 = llvm.shl %0, %arg0 : i32 + %2 = "llvm.intr.ctlz"(%1) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @lshr_cttz_false_neg(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8387584 : i32) : i32 + %1 = llvm.lshr %0, %arg0 : i32 + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @shl_cttz_false_neg(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8387584 : i32) : i32 + %1 = llvm.shl %0, %arg0 : i32 + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/ctpop-bswap-bitreverse.ll.mlir b/test/LLVMDialect/InstCombine/ctpop-bswap-bitreverse.ll.mlir index df003e8c5..365951151 100644 --- a/test/LLVMDialect/InstCombine/ctpop-bswap-bitreverse.ll.mlir +++ b/test/LLVMDialect/InstCombine/ctpop-bswap-bitreverse.ll.mlir @@ -1,39 +1,22 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %1 = "llvm.call"(%0) {callee = @llvm.ctpop.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "ctpop_bitreverse", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.bitreverse.v2i64, fastmathFlags = #llvm.fastmath<>} : (vector<2xi64>) -> vector<2xi64> - %1 = "llvm.call"(%0) {callee = @llvm.ctpop.v2i64, fastmathFlags = #llvm.fastmath<>} : (vector<2xi64>) -> vector<2xi64> - "llvm.return"(%1) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "ctpop_bitreverse_vec", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.bswap.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %1 = "llvm.call"(%0) {callee = @llvm.ctpop.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "ctpop_bswap", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.bswap.v2i64, fastmathFlags = #llvm.fastmath<>} : (vector<2xi64>) -> vector<2xi64> - %1 = "llvm.call"(%0) {callee = @llvm.ctpop.v2i64, fastmathFlags = #llvm.fastmath<>} : (vector<2xi64>) -> vector<2xi64> - "llvm.return"(%1) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "ctpop_bswap_vec", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.bitreverse.i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.bitreverse.v2i64", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.bswap.i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.bswap.v2i64", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ctpop.i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ctpop.v2i64", type = !llvm.func (vector<2xi64>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @ctpop_bitreverse(%arg0: i32) -> i32 { + %0 = llvm.intr.bitreverse(%arg0) : (i32) -> i32 + %1 = llvm.intr.ctpop(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @ctpop_bitreverse_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.intr.bitreverse(%arg0) : (vector<2xi64>) -> vector<2xi64> + %1 = llvm.intr.ctpop(%0) : (vector<2xi64>) -> vector<2xi64> + llvm.return %1 : vector<2xi64> + } + llvm.func @ctpop_bswap(%arg0: i32) -> i32 { + %0 = llvm.intr.bswap(%arg0) : (i32) -> i32 + %1 = llvm.intr.ctpop(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @ctpop_bswap_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.intr.bswap(%arg0) : (vector<2xi64>) -> vector<2xi64> + %1 = llvm.intr.ctpop(%0) : (vector<2xi64>) -> vector<2xi64> + llvm.return %1 : vector<2xi64> + } +} diff --git a/test/LLVMDialect/InstCombine/ctpop-cttz.ll.mlir b/test/LLVMDialect/InstCombine/ctpop-cttz.ll.mlir new file mode 100644 index 000000000..f3211eb6c --- /dev/null +++ b/test/LLVMDialect/InstCombine/ctpop-cttz.ll.mlir @@ -0,0 +1,91 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @ctpop1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.or %arg0, %2 : i32 + %4 = llvm.intr.ctpop(%3) : (i32) -> i32 + %5 = llvm.sub %1, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @ctpop1v(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %1, %arg0 : vector<2xi32> + %3 = llvm.or %2, %arg0 : vector<2xi32> + %4 = llvm.intr.ctpop(%3) : (vector<2xi32>) -> vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @ctpop1_multiuse(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.or %arg0, %2 : i32 + %4 = llvm.intr.ctpop(%3) : (i32) -> i32 + %5 = llvm.sub %1, %4 : i32 + %6 = llvm.add %5, %3 : i32 + llvm.return %6 : i32 + } + llvm.func @ctpop2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.sub %arg0, %1 : i32 + %4 = llvm.and %3, %2 : i32 + %5 = llvm.intr.ctpop(%4) : (i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @ctpop2v(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.xor %arg0, %0 : vector<2xi32> + %2 = llvm.add %arg0, %0 : vector<2xi32> + %3 = llvm.and %1, %2 : vector<2xi32> + %4 = llvm.intr.ctpop(%3) : (vector<2xi32>) -> vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @ctpop2_multiuse(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.sub %arg0, %1 : i32 + %4 = llvm.and %3, %2 : i32 + %5 = llvm.intr.ctpop(%4) : (i32) -> i32 + %6 = llvm.add %5, %4 : i32 + llvm.return %6 : i32 + } + llvm.func @ctpop3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.intr.ctpop(%4) : (i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @ctpop3v(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.sub %1, %arg0 : vector<2xi32> + %4 = llvm.and %3, %arg0 : vector<2xi32> + %5 = llvm.add %4, %2 : vector<2xi32> + %6 = llvm.intr.ctpop(%5) : (vector<2xi32>) -> vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @ctpop3v_poison(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.constant(-1 : i32) : i32 + %4 = llvm.mlir.undef : vector<2xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi32> + %9 = llvm.sub %1, %arg0 : vector<2xi32> + %10 = llvm.and %9, %arg0 : vector<2xi32> + %11 = llvm.add %10, %8 : vector<2xi32> + %12 = llvm.intr.ctpop(%11) : (vector<2xi32>) -> vector<2xi32> + llvm.return %12 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/ctpop-pow2.ll.mlir b/test/LLVMDialect/InstCombine/ctpop-pow2.ll.mlir new file mode 100644 index 000000000..1b78fb216 --- /dev/null +++ b/test/LLVMDialect/InstCombine/ctpop-pow2.ll.mlir @@ -0,0 +1,90 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @ctpop_x_and_negx(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.sub %0, %arg0 : i16 + %2 = llvm.and %arg0, %1 : i16 + %3 = llvm.intr.ctpop(%2) : (i16) -> i16 + llvm.return %3 : i16 + } + llvm.func @ctpop_x_nz_and_negx(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.sub %1, %2 : i8 + %4 = llvm.and %2, %3 : i8 + %5 = llvm.intr.ctpop(%4) : (i8) -> i8 + llvm.return %5 : i8 + } + llvm.func @ctpop_2_shl(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.shl %0, %arg0 : i32 + %2 = llvm.intr.ctpop(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @ctpop_2_shl_nz(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(30 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.and %0, %arg0 : i32 + %3 = llvm.shl %1, %2 : i32 + %4 = llvm.intr.ctpop(%3) : (i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @ctpop_imin_plus1_lshr_nz(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.lshr %1, %arg0 : i8 + %4 = llvm.intr.ctpop(%3) : (i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @ctpop_x_and_negx_nz(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %0, %arg0 : i64 + %2 = llvm.and %arg0, %1 : i64 + %3 = llvm.icmp "ne" %2, %0 : i64 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.intr.ctpop(%2) : (i64) -> i64 + llvm.return %4 : i64 + } + llvm.func @ctpop_shl2_1_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[2, 1]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.shl %0, %arg0 : vector<2xi32> + %2 = llvm.intr.ctpop(%1) : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @ctpop_lshr_intmin_intmin_plus1_vec_nz(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-2147483648, -2147483647]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.or %arg0, %0 : vector<2xi32> + %3 = llvm.lshr %1, %2 : vector<2xi32> + %4 = llvm.intr.ctpop(%3) : (vector<2xi32>) -> vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @ctpop_shl2_1_vec_nz(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[2, 1]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.shl %1, %2 : vector<2xi32> + %4 = llvm.intr.ctpop(%3) : (vector<2xi32>) -> vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @ctpop_x_and_negx_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sub %1, %arg0 : vector<2xi64> + %3 = llvm.and %2, %arg0 : vector<2xi64> + %4 = llvm.intr.ctpop(%3) : (vector<2xi64>) -> vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @ctpop_x_and_negx_vec_nz(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.or %arg0, %0 : vector<2xi32> + %4 = llvm.sub %2, %3 : vector<2xi32> + %5 = llvm.and %4, %3 : vector<2xi32> + %6 = llvm.intr.ctpop(%5) : (vector<2xi32>) -> vector<2xi32> + llvm.return %6 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/ctpop.ll.mlir b/test/LLVMDialect/InstCombine/ctpop.ll.mlir new file mode 100644 index 000000000..4975a46b6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/ctpop.ll.mlir @@ -0,0 +1,281 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @test1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.intr.ctpop(%2) : (i32) -> i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @test2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.intr.ctpop(%2) : (i32) -> i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @test3(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @test4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.intr.ctpop(%arg0) : (i8) -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @test5(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.intr.ctpop(%1) : (i32) -> i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @test5vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg0, %0 : vector<2xi32> + %2 = llvm.intr.ctpop(%1) : (vector<2xi32>) -> vector<2xi32> + %3 = llvm.icmp "eq" %2, %0 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test6(%arg0: i1) -> i1 { + %0 = llvm.intr.ctpop(%arg0) : (i1) -> i1 + llvm.return %0 : i1 + } + llvm.func @mask_one_bit(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.intr.ctpop(%1) : (i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @mask_one_bit_splat(%arg0: vector<2xi32>, %arg1: !llvm.ptr) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<2048> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg0, %0 : vector<2xi32> + llvm.store %1, %arg1 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + %2 = llvm.intr.ctpop(%1) : (vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @_parity_of_not(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.intr.ctpop(%2) : (i32) -> i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @_parity_of_not_odd_type(%arg0: i7) -> i7 { + %0 = llvm.mlir.constant(-1 : i7) : i7 + %1 = llvm.mlir.constant(1 : i7) : i7 + %2 = llvm.xor %arg0, %0 : i7 + %3 = llvm.intr.ctpop(%2) : (i7) -> i7 + %4 = llvm.and %3, %1 : i7 + llvm.return %4 : i7 + } + llvm.func @_parity_of_not_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.xor %arg0, %0 : vector<2xi32> + %3 = llvm.intr.ctpop(%2) : (vector<2xi32>) -> vector<2xi32> + %4 = llvm.and %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @_parity_of_not_poison(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %8 = llvm.xor %arg0, %6 : vector<2xi32> + %9 = llvm.intr.ctpop(%8) : (vector<2xi32>) -> vector<2xi32> + %10 = llvm.and %9, %7 : vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @_parity_of_not_poison2(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.undef : vector<2xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi32> + %8 = llvm.xor %arg0, %0 : vector<2xi32> + %9 = llvm.intr.ctpop(%8) : (vector<2xi32>) -> vector<2xi32> + %10 = llvm.and %9, %7 : vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @ctpop_add(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.intr.ctpop(%2) : (i32) -> i32 + %4 = llvm.and %arg1, %1 : i32 + %5 = llvm.intr.ctpop(%4) : (i32) -> i32 + %6 = llvm.add %3, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @ctpop_add_no_common_bits(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.shl %arg0, %0 : i32 + %2 = llvm.intr.ctpop(%1) : (i32) -> i32 + %3 = llvm.lshr %arg1, %0 : i32 + %4 = llvm.intr.ctpop(%3) : (i32) -> i32 + %5 = llvm.add %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @ctpop_add_no_common_bits_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.shl %arg0, %0 : vector<2xi32> + %2 = llvm.intr.ctpop(%1) : (vector<2xi32>) -> vector<2xi32> + %3 = llvm.lshr %arg1, %0 : vector<2xi32> + %4 = llvm.intr.ctpop(%3) : (vector<2xi32>) -> vector<2xi32> + %5 = llvm.add %2, %4 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @ctpop_add_no_common_bits_vec_use(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: !llvm.ptr) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.shl %arg0, %0 : vector<2xi32> + %2 = llvm.intr.ctpop(%1) : (vector<2xi32>) -> vector<2xi32> + %3 = llvm.lshr %arg1, %0 : vector<2xi32> + %4 = llvm.intr.ctpop(%3) : (vector<2xi32>) -> vector<2xi32> + llvm.store %4, %arg2 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + %5 = llvm.add %2, %4 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @ctpop_add_no_common_bits_vec_use2(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: !llvm.ptr) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.shl %arg0, %0 : vector<2xi32> + %2 = llvm.intr.ctpop(%1) : (vector<2xi32>) -> vector<2xi32> + llvm.store %2, %arg2 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + %3 = llvm.lshr %arg1, %0 : vector<2xi32> + %4 = llvm.intr.ctpop(%3) : (vector<2xi32>) -> vector<2xi32> + %5 = llvm.add %2, %4 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @ctpop_rotate_left(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.fshl(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %1 = llvm.intr.ctpop(%0) : (i8) -> i8 + llvm.return %1 : i8 + } + llvm.func @ctpop_rotate_right(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.fshr(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %1 = llvm.intr.ctpop(%0) : (i8) -> i8 + llvm.return %1 : i8 + } + llvm.func @sub_ctpop(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(8 : i8) : i8 + %1 = llvm.intr.ctpop(%arg0) : (i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sub_ctpop_wrong_cst(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.intr.ctpop(%arg0) : (i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sub_ctpop_unknown(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.ctpop(%arg0) : (i8) -> i8 + %1 = llvm.sub %arg1, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @sub_ctpop_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.intr.ctpop(%arg0) : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.sub %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @sub_ctpop_vec_extra_use(%arg0: vector<2xi32>, %arg1: !llvm.ptr) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.intr.ctpop(%arg0) : (vector<2xi32>) -> vector<2xi32> + llvm.store %1, %arg1 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + %2 = llvm.sub %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @zext_ctpop(%arg0: i16) -> i32 { + %0 = llvm.zext %arg0 : i16 to i32 + %1 = llvm.intr.ctpop(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @zext_ctpop_vec(%arg0: vector<2xi7>) -> vector<2xi32> { + %0 = llvm.zext %arg0 : vector<2xi7> to vector<2xi32> + %1 = llvm.intr.ctpop(%0) : (vector<2xi32>) -> vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @zext_ctpop_extra_use(%arg0: i16, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.zext %arg0 : i16 to i32 + llvm.store %0, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %1 = llvm.intr.ctpop(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @parity_xor(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %2 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %3 = llvm.xor %2, %1 : i32 + %4 = llvm.and %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @parity_xor_trunc(%arg0: i64, %arg1: i64) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.intr.ctpop(%arg0) : (i64) -> i64 + %2 = llvm.intr.ctpop(%arg1) : (i64) -> i64 + %3 = llvm.xor %2, %1 : i64 + %4 = llvm.trunc %3 : i64 to i32 + %5 = llvm.and %4, %0 : i32 + llvm.return %5 : i32 + } + llvm.func @parity_xor_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.intr.ctpop(%arg0) : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.intr.ctpop(%arg1) : (vector<2xi32>) -> vector<2xi32> + %3 = llvm.xor %2, %1 : vector<2xi32> + %4 = llvm.and %3, %0 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @parity_xor_wrong_cst(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %2 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %3 = llvm.xor %2, %1 : i32 + %4 = llvm.and %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @parity_xor_extra_use(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %2 = llvm.and %1, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %4 = llvm.and %3, %0 : i32 + %5 = llvm.xor %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @parity_xor_extra_use2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %2 = llvm.and %1, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.and %3, %0 : i32 + %5 = llvm.xor %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @select_ctpop_zero(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.select %2, %0, %1 : i1, i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/cttz-abs.ll.mlir b/test/LLVMDialect/InstCombine/cttz-abs.ll.mlir new file mode 100644 index 000000000..8f7a149bc --- /dev/null +++ b/test/LLVMDialect/InstCombine/cttz-abs.ll.mlir @@ -0,0 +1,152 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @cttz_abs(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.select %1, %2, %arg0 : i1, i32 + %4 = "llvm.intr.cttz"(%3) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @cttz_abs_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.icmp "slt" %arg0, %1 : vector<2xi64> + %3 = llvm.sub %1, %arg0 : vector<2xi64> + %4 = llvm.select %2, %3, %arg0 : vector<2xi1>, vector<2xi64> + %5 = "llvm.intr.cttz"(%4) <{is_zero_poison = false}> : (vector<2xi64>) -> vector<2xi64> + llvm.return %5 : vector<2xi64> + } + llvm.func @cttz_abs2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.call @use_cond(%1) : (i1) -> () + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.select %1, %arg0, %2 : i1, i32 + %4 = "llvm.intr.cttz"(%3) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @cttz_abs3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.call @use_cond(%2) : (i1) -> () + %3 = llvm.sub %1, %arg0 : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = "llvm.intr.cttz"(%4) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @cttz_abs4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = "llvm.intr.cttz"(%4) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @cttz_nabs(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.select %1, %arg0, %2 : i1, i32 + %4 = "llvm.intr.cttz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @cttz_nabs_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.icmp "slt" %arg0, %1 : vector<2xi64> + %3 = llvm.sub %1, %arg0 : vector<2xi64> + %4 = llvm.select %2, %arg0, %3 : vector<2xi1>, vector<2xi64> + %5 = "llvm.intr.cttz"(%4) <{is_zero_poison = false}> : (vector<2xi64>) -> vector<2xi64> + llvm.return %5 : vector<2xi64> + } + llvm.func @cttz_abs_64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "slt" %arg0, %0 : i64 + %2 = llvm.sub %0, %arg0 : i64 + %3 = llvm.select %1, %2, %arg0 : i1, i64 + %4 = "llvm.intr.cttz"(%3) <{is_zero_poison = false}> : (i64) -> i64 + llvm.return %4 : i64 + } + llvm.func @cttz_abs_multiuse(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + llvm.call @use_abs(%4) : (i32) -> () + %5 = "llvm.intr.cttz"(%4) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @cttz_nabs_multiuse(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + llvm.call @use_abs(%4) : (i32) -> () + %5 = "llvm.intr.cttz"(%4) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @no_cttz_abs(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = "llvm.intr.cttz"(%4) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @no_cttz_abs2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = "llvm.intr.cttz"(%4) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @no_cttz_abs3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.call @use_cond(%2) : (i1) -> () + %3 = llvm.sub %1, %arg0 : i32 + %4 = llvm.select %2, %arg0, %3 : i1, i32 + %5 = "llvm.intr.cttz"(%4) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @no_cttz_abs_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[2, 1]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<[1, 0]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.icmp "slt" %arg0, %0 : vector<2xi64> + %3 = llvm.sub %1, %arg0 : vector<2xi64> + %4 = llvm.select %2, %3, %arg0 : vector<2xi1>, vector<2xi64> + %5 = "llvm.intr.cttz"(%4) <{is_zero_poison = false}> : (vector<2xi64>) -> vector<2xi64> + llvm.return %5 : vector<2xi64> + } + llvm.func @no_cttz_nabs_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[2, 1]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<[1, 0]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.icmp "slt" %arg0, %0 : vector<2xi64> + %3 = llvm.sub %1, %arg0 : vector<2xi64> + %4 = llvm.select %2, %arg0, %3 : vector<2xi1>, vector<2xi64> + %5 = "llvm.intr.cttz"(%4) <{is_zero_poison = false}> : (vector<2xi64>) -> vector<2xi64> + llvm.return %5 : vector<2xi64> + } + llvm.func @cttz_abs_intrin(%arg0: i32) -> i32 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i32) -> i32 + %1 = "llvm.intr.cttz"(%0) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @cttz_nabs_intrin(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i32) -> i32 + %2 = llvm.sub %0, %1 : i32 + %3 = "llvm.intr.cttz"(%2) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @use_cond(i1) + llvm.func @use_abs(i32) +} diff --git a/test/LLVMDialect/InstCombine/cttz-negative.ll.mlir b/test/LLVMDialect/InstCombine/cttz-negative.ll.mlir new file mode 100644 index 000000000..6b964e93a --- /dev/null +++ b/test/LLVMDialect/InstCombine/cttz-negative.ll.mlir @@ -0,0 +1,47 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @cttz_neg_value(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @cttz_neg_value_multiuse(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @cttz_neg_value_64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %0, %arg0 : i64 + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = true}> : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @cttz_neg_value2_64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %0, %arg0 : i64 + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = false}> : (i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @cttz_neg_value_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sub %1, %arg0 : vector<2xi64> + %3 = "llvm.intr.cttz"(%2) <{is_zero_poison = false}> : (vector<2xi64>) -> vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @cttz_nonneg_value(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @cttz_nonneg_value_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[1, 0]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.sub %0, %arg0 : vector<2xi64> + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = false}> : (vector<2xi64>) -> vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @use(i32) +} diff --git a/test/LLVMDialect/InstCombine/cttz.ll.mlir b/test/LLVMDialect/InstCombine/cttz.ll.mlir index 6caff3c5e..ce78be05c 100644 --- a/test/LLVMDialect/InstCombine/cttz.ll.mlir +++ b/test/LLVMDialect/InstCombine/cttz.ll.mlir @@ -1,81 +1,154 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.cttz.i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.cttz.v2i64", type = !llvm.func (vector<2xi64>, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.zext"(%arg0) : (i16) -> i32 - %2 = "llvm.call"(%1, %0) {callee = @llvm.cttz.i32, fastmathFlags = #llvm.fastmath<>} : (i32, i1) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "cttz_zext_zero_undef", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.zext"(%arg0) : (i16) -> i32 - %2 = "llvm.call"(%1, %0) {callee = @llvm.cttz.i32, fastmathFlags = #llvm.fastmath<>} : (i32, i1) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "cttz_zext_zero_def", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.zext"(%arg0) : (i16) -> i32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %2 = "llvm.call"(%1, %0) {callee = @llvm.cttz.i32, fastmathFlags = #llvm.fastmath<>} : (i32, i1) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "cttz_zext_zero_undef_extra_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.zext"(%arg0) : (vector<2xi32>) -> vector<2xi64> - %2 = "llvm.call"(%1, %0) {callee = @llvm.cttz.v2i64, fastmathFlags = #llvm.fastmath<>} : (vector<2xi64>, i1) -> vector<2xi64> - "llvm.return"(%2) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "cttz_zext_zero_undef_vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.zext"(%arg0) : (vector<2xi32>) -> vector<2xi64> - %2 = "llvm.call"(%1, %0) {callee = @llvm.cttz.v2i64, fastmathFlags = #llvm.fastmath<>} : (vector<2xi64>, i1) -> vector<2xi64> - "llvm.return"(%2) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "cttz_zext_zero_def_vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.sext"(%arg0) : (i16) -> i32 - %2 = "llvm.call"(%1, %0) {callee = @llvm.cttz.i32, fastmathFlags = #llvm.fastmath<>} : (i32, i1) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "cttz_sext_zero_undef", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.sext"(%arg0) : (i16) -> i32 - %2 = "llvm.call"(%1, %0) {callee = @llvm.cttz.i32, fastmathFlags = #llvm.fastmath<>} : (i32, i1) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "cttz_sext_zero_def", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.sext"(%arg0) : (i16) -> i32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %2 = "llvm.call"(%1, %0) {callee = @llvm.cttz.i32, fastmathFlags = #llvm.fastmath<>} : (i32, i1) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "cttz_sext_zero_undef_extra_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.sext"(%arg0) : (vector<2xi32>) -> vector<2xi64> - %2 = "llvm.call"(%1, %0) {callee = @llvm.cttz.v2i64, fastmathFlags = #llvm.fastmath<>} : (vector<2xi64>, i1) -> vector<2xi64> - "llvm.return"(%2) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "cttz_sext_zero_undef_vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.sext"(%arg0) : (vector<2xi32>) -> vector<2xi64> - %2 = "llvm.call"(%1, %0) {callee = @llvm.cttz.v2i64, fastmathFlags = #llvm.fastmath<>} : (vector<2xi64>, i1) -> vector<2xi64> - "llvm.return"(%2) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "cttz_sext_zero_def_vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @cttz_zext_zero_undef(%arg0: i16) -> i32 { + %0 = llvm.zext %arg0 : i16 to i32 + %1 = "llvm.intr.cttz"(%0) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @cttz_zext_zero_def(%arg0: i16) -> i32 { + %0 = llvm.zext %arg0 : i16 to i32 + %1 = "llvm.intr.cttz"(%0) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @cttz_zext_zero_undef_extra_use(%arg0: i16) -> i32 { + %0 = llvm.zext %arg0 : i16 to i32 + llvm.call @use(%0) : (i32) -> () + %1 = "llvm.intr.cttz"(%0) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @cttz_zext_zero_undef_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.zext %arg0 : vector<2xi32> to vector<2xi64> + %1 = "llvm.intr.cttz"(%0) <{is_zero_poison = true}> : (vector<2xi64>) -> vector<2xi64> + llvm.return %1 : vector<2xi64> + } + llvm.func @cttz_zext_zero_def_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.zext %arg0 : vector<2xi32> to vector<2xi64> + %1 = "llvm.intr.cttz"(%0) <{is_zero_poison = false}> : (vector<2xi64>) -> vector<2xi64> + llvm.return %1 : vector<2xi64> + } + llvm.func @cttz_sext_zero_undef(%arg0: i16) -> i32 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = "llvm.intr.cttz"(%0) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @cttz_sext_zero_def(%arg0: i16) -> i32 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = "llvm.intr.cttz"(%0) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @cttz_sext_zero_undef_extra_use(%arg0: i16) -> i32 { + %0 = llvm.sext %arg0 : i16 to i32 + llvm.call @use(%0) : (i32) -> () + %1 = "llvm.intr.cttz"(%0) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @cttz_sext_zero_undef_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.sext %arg0 : vector<2xi32> to vector<2xi64> + %1 = "llvm.intr.cttz"(%0) <{is_zero_poison = true}> : (vector<2xi64>) -> vector<2xi64> + llvm.return %1 : vector<2xi64> + } + llvm.func @cttz_sext_zero_def_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.sext %arg0 : vector<2xi32> to vector<2xi64> + %1 = "llvm.intr.cttz"(%0) <{is_zero_poison = false}> : (vector<2xi64>) -> vector<2xi64> + llvm.return %1 : vector<2xi64> + } + llvm.func @cttz_of_lowest_set_bit(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = "llvm.intr.cttz"(%2) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @cttz_of_lowest_set_bit_commuted(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.sub %1, %2 : i32 + %4 = llvm.and %2, %3 : i32 + %5 = "llvm.intr.cttz"(%4) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @cttz_of_lowest_set_bit_poison_flag(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = "llvm.intr.cttz"(%2) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @cttz_of_lowest_set_bit_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sub %1, %arg0 : vector<2xi64> + %3 = llvm.and %2, %arg0 : vector<2xi64> + %4 = "llvm.intr.cttz"(%3) <{is_zero_poison = false}> : (vector<2xi64>) -> vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @cttz_of_lowest_set_bit_vec_undef(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sub %1, %arg0 : vector<2xi64> + %3 = llvm.and %2, %arg0 : vector<2xi64> + %4 = "llvm.intr.cttz"(%3) <{is_zero_poison = false}> : (vector<2xi64>) -> vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @cttz_of_lowest_set_bit_wrong_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = "llvm.intr.cttz"(%2) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @cttz_of_lowest_set_bit_wrong_operand(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = "llvm.intr.cttz"(%2) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @cttz_of_lowest_set_bit_wrong_intrinsic(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = "llvm.intr.ctlz"(%2) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @cttz_of_power_of_two(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.lshr %0, %arg0 : i32 + %3 = llvm.add %2, %1 : i32 + %4 = "llvm.intr.cttz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @cttz_of_power_of_two_zero_poison(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.lshr %0, %arg0 : i32 + %3 = llvm.add %2, %1 : i32 + %4 = "llvm.intr.cttz"(%3) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @cttz_of_power_of_two_wrong_intrinsic(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.lshr %0, %arg0 : i32 + %3 = llvm.add %2, %1 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @cttz_of_power_of_two_wrong_constant_1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.lshr %0, %arg0 : i32 + %3 = llvm.add %2, %1 : i32 + %4 = "llvm.intr.cttz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @cttz_of_power_of_two_wrong_constant_2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.lshr %0, %arg0 : i32 + %2 = llvm.add %1, %0 : i32 + %3 = "llvm.intr.cttz"(%2) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/dbg-scalable-store-fixed-frag.ll.mlir b/test/LLVMDialect/InstCombine/dbg-scalable-store-fixed-frag.ll.mlir new file mode 100644 index 000000000..60fa8621c --- /dev/null +++ b/test/LLVMDialect/InstCombine/dbg-scalable-store-fixed-frag.ll.mlir @@ -0,0 +1,28 @@ +#di_basic_type = #llvm.di_basic_type +#di_file = #llvm.di_file<"u.cpp" in "/path/to/test"> +#di_null_type = #llvm.di_null_type +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C_plus_plus_14, file = #di_file, producer = "clang version 17.0.0 (git@github.com:llvm/llvm-project.git a489e11439e36c7e0ec83b28a6fb1596a5c21faa)", isOptimized = true, emissionKind = Full> +#di_composite_type = #llvm.di_composite_type +#di_subroutine_type = #llvm.di_subroutine_type +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "foo", linkageName = "foo", file = #di_file, line = 2, scopeLine = 2, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#di_subprogram1 = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "foo2", linkageName = "foo2", file = #di_file, line = 5, scopeLine = 5, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#di_local_variable = #llvm.di_local_variable +#di_local_variable1 = #llvm.di_local_variable +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: !llvm.vec) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.dbg.declare #di_local_variable = %1 : !llvm.ptr + llvm.store %arg0, %1 {alignment = 4 : i64} : !llvm.vec, !llvm.ptr + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %2 : i32 + } + llvm.func @foo2(%arg0: !llvm.vec) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.array<4 x i32> {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.dbg.declare #di_local_variable1 = %1 : !llvm.ptr + llvm.store %arg0, %1 {alignment = 4 : i64} : !llvm.vec, !llvm.ptr + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/dbg-simplify-alloca-size.ll.mlir b/test/LLVMDialect/InstCombine/dbg-simplify-alloca-size.ll.mlir new file mode 100644 index 000000000..50c0abdd9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/dbg-simplify-alloca-size.ll.mlir @@ -0,0 +1,16 @@ +#di_basic_type = #llvm.di_basic_type +#di_file = #llvm.di_file<"test.cpp" in "/path/to/test_cpp"> +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C_plus_plus_14, file = #di_file, producer = "clang version 11.1.0", isOptimized = false, emissionKind = Full> +#di_subroutine_type = #llvm.di_subroutine_type +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "toplevel", linkageName = "_Z8toplevelv", file = #di_file, line = 9, scopeLine = 9, subprogramFlags = Definition, type = #di_subroutine_type> +#di_local_variable = #llvm.di_local_variable +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(!llvm.ptr) + llvm.func @toplevel() { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.intr.dbg.declare #di_local_variable = %1 : !llvm.ptr + llvm.call @foo(%1) : (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/dce-iterate.ll.mlir b/test/LLVMDialect/InstCombine/dce-iterate.ll.mlir index f9724e11c..b8eb7b404 100644 --- a/test/LLVMDialect/InstCombine/dce-iterate.ll.mlir +++ b/test/LLVMDialect/InstCombine/dce-iterate.ll.mlir @@ -1,25 +1,23 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 640 : i960} : () -> i960 - %1 = "llvm.mlir.constant"() {value = 320 : i960} : () -> i960 - %2 = "llvm.bitcast"(%arg0) : (f64) -> i64 - %3 = "llvm.zext"(%2) : (i64) -> i960 - %4 = "llvm.bitcast"(%arg1) : (f64) -> i64 - %5 = "llvm.zext"(%4) : (i64) -> i960 - %6 = "llvm.shl"(%5, %1) : (i960, i960) -> i960 - %7 = "llvm.or"(%3, %6) : (i960, i960) -> i960 - %8 = "llvm.bitcast"(%arg2) : (f64) -> i64 - %9 = "llvm.zext"(%8) : (i64) -> i960 - %10 = "llvm.shl"(%9, %0) : (i960, i960) -> i960 - %11 = "llvm.or"(%7, %10) : (i960, i960) -> i960 - %12 = "llvm.trunc"(%11) : (i960) -> i64 - %13 = "llvm.bitcast"(%12) : (i64) -> f64 - %14 = "llvm.lshr"(%11, %1) : (i960, i960) -> i960 - %15 = "llvm.trunc"(%14) : (i960) -> i64 - %16 = "llvm.bitcast"(%15) : (i64) -> f64 - %17 = "llvm.fadd"(%13, %16) : (f64, f64) -> f64 - "llvm.return"(%16) : (f64) -> () - }) {linkage = 1 : i64, sym_name = "ScaleObjectAdd", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func internal @ScaleObjectAdd(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 attributes {dso_local, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(320 : i960) : i960 + %1 = llvm.mlir.constant(640 : i960) : i960 + %2 = llvm.bitcast %arg0 : f64 to i64 + %3 = llvm.zext %2 : i64 to i960 + %4 = llvm.bitcast %arg1 : f64 to i64 + %5 = llvm.zext %4 : i64 to i960 + %6 = llvm.shl %5, %0 : i960 + %7 = llvm.or %3, %6 : i960 + %8 = llvm.bitcast %arg2 : f64 to i64 + %9 = llvm.zext %8 : i64 to i960 + %10 = llvm.shl %9, %1 : i960 + %11 = llvm.or %7, %10 : i960 + %12 = llvm.trunc %11 : i960 to i64 + %13 = llvm.bitcast %12 : i64 to f64 + %14 = llvm.lshr %11, %0 : i960 + %15 = llvm.trunc %14 : i960 to i64 + %16 = llvm.bitcast %15 : i64 to f64 + %17 = llvm.fadd %13, %16 : f64 + llvm.return %16 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/deadcode.ll.mlir b/test/LLVMDialect/InstCombine/deadcode.ll.mlir index a5851fe6f..c7be7cd0b 100644 --- a/test/LLVMDialect/InstCombine/deadcode.ll.mlir +++ b/test/LLVMDialect/InstCombine/deadcode.ll.mlir @@ -1,34 +1,24 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.or"(%1, %1) : (i1, i1) -> i1 - "llvm.cond_br"(%2, %arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.or %0, %0 : i1 + llvm.cond_br %2, ^bb1, ^bb2(%arg0 : i32) ^bb1: // pred: ^bb0 - %3 = "llvm.add"(%arg0, %0) : (i32, i32) -> i32 - "llvm.br"(%3)[^bb2] : (i32) -> () + %3 = llvm.add %arg0, %1 : i32 + llvm.br ^bb2(%3 : i32) ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"() {callee = @llvm.stacksave, fastmathFlags = #llvm.fastmath<>} : () -> !llvm.ptr - %1 = "llvm.alloca"(%arg0) : (i32) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.stacksave", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.lifetime.start.p0i8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.lifetime.end.p0i8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.undef"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = -1 : i64} : () -> i64 - "llvm.call"(%1, %0) {callee = @llvm.lifetime.start.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.call"(%1, %0) {callee = @llvm.lifetime.end.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %4 : i32 + } + llvm.func @test2(%arg0: i32) -> !llvm.ptr { + %0 = llvm.intr.stacksave : !llvm.ptr + %1 = llvm.alloca %arg0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test3() { + %0 = llvm.mlir.undef : !llvm.ptr + llvm.intr.lifetime.start -1, %0 : !llvm.ptr + llvm.intr.lifetime.end -1, %0 : !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/debug-line.ll.mlir b/test/LLVMDialect/InstCombine/debug-line.ll.mlir index 06a8fde06..5cd126e5d 100644 --- a/test/LLVMDialect/InstCombine/debug-line.ll.mlir +++ b/test/LLVMDialect/InstCombine/debug-line.ll.mlir @@ -1,15 +1,11 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str", type = !llvm.array<3 x i8>, value = "%c\00"} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 97 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "printf", type = !llvm.func, ...)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private constant @".str"("%c\00") {addr_space = 0 : i32, dso_local} + llvm.func @foo() attributes {passthrough = ["nounwind", "ssp"]} { + %0 = llvm.mlir.constant("%c\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.constant(97 : i32) : i32 + %3 = llvm.call @printf(%1, %2) vararg(!llvm.func) : (!llvm.ptr, i32) -> i32 + llvm.return + } + llvm.func @printf(!llvm.ptr, ...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/debuginfo-dce.ll.mlir b/test/LLVMDialect/InstCombine/debuginfo-dce.ll.mlir new file mode 100644 index 000000000..d0ffea338 --- /dev/null +++ b/test/LLVMDialect/InstCombine/debuginfo-dce.ll.mlir @@ -0,0 +1,67 @@ +#di_file = #llvm.di_file<"test.c" in "/"> +#di_null_type = #llvm.di_null_type +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C99, file = #di_file, producer = "clang version 5.0.0 (trunk 297628) (llvm/trunk 297643)", isOptimized = true, emissionKind = Full> +#di_composite_type = #llvm.di_composite_type +#di_derived_type = #llvm.di_derived_type +#di_subroutine_type = #llvm.di_subroutine_type +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "scan", file = #di_file, line = 4, scopeLine = 5, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#di_subprogram1 = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "scan", file = #di_file, line = 4, scopeLine = 5, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#di_subprogram2 = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "scan", file = #di_file, line = 4, scopeLine = 5, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#di_subprogram3 = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "scan", file = #di_file, line = 4, scopeLine = 5, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#di_subprogram4 = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "scan", file = #di_file, line = 4, scopeLine = 5, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#di_local_variable = #llvm.di_local_variable +#di_local_variable1 = #llvm.di_local_variable +#di_local_variable2 = #llvm.di_local_variable +#di_local_variable3 = #llvm.di_local_variable +#di_local_variable4 = #llvm.di_local_variable +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func local_unnamed_addr @salvage_load(%arg0: !llvm.ptr) attributes {passthrough = ["nounwind", "ssp", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + %2 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %3 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.intr.dbg.value #di_local_variable #llvm.di_expression<[DW_OP_plus_uconst(0)]> = %3 : !llvm.ptr + llvm.store %3, %1 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func local_unnamed_addr @salvage_bitcast(%arg0: !llvm.ptr) attributes {passthrough = ["nounwind", "ssp", ["uwtable", "2"]]} { + llvm.intr.dbg.value #di_local_variable1 #llvm.di_expression<[DW_OP_plus_uconst(0)]> = %arg0 : !llvm.ptr + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %1 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func local_unnamed_addr @salvage_gep0(%arg0: !llvm.ptr, %arg1: !llvm.ptr) attributes {passthrough = ["nounwind", "ssp", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.getelementptr inbounds %arg0[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.entry", (ptr)> + %5 = llvm.getelementptr inbounds %arg0[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.entry", (ptr)> + llvm.intr.dbg.value #di_local_variable2 #llvm.di_expression<[DW_OP_plus_uconst(0)]> = %5 : !llvm.ptr + llvm.store %5, %3 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func local_unnamed_addr @salvage_gep1(%arg0: !llvm.ptr, %arg1: !llvm.ptr) attributes {passthrough = ["nounwind", "ssp", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.getelementptr inbounds %arg0[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.entry", (ptr)> + %5 = llvm.getelementptr inbounds %arg0[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.entry", (ptr)> + llvm.intr.dbg.value #di_local_variable3 #llvm.di_expression<[DW_OP_LLVM_fragment(0, 32)]> = %5 : !llvm.ptr + llvm.store %5, %3 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func local_unnamed_addr @salvage_gep2(%arg0: !llvm.ptr, %arg1: !llvm.ptr) attributes {passthrough = ["nounwind", "ssp", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.getelementptr inbounds %arg0[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.entry", (ptr)> + %5 = llvm.getelementptr inbounds %arg0[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.entry", (ptr)> + llvm.intr.dbg.value #di_local_variable4 #llvm.di_expression<[DW_OP_stack_value]> = %5 : !llvm.ptr + llvm.store %5, %3 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/debuginfo-dce2.ll.mlir b/test/LLVMDialect/InstCombine/debuginfo-dce2.ll.mlir new file mode 100644 index 000000000..6498ee513 --- /dev/null +++ b/test/LLVMDialect/InstCombine/debuginfo-dce2.ll.mlir @@ -0,0 +1,19 @@ +#di_basic_type = #llvm.di_basic_type +#di_derived_type = #llvm.di_derived_type +#di_file = #llvm.di_file<"t.c" in "C:\\src\\llvm-project\\build"> +#di_null_type = #llvm.di_null_type +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C99, file = #di_file, producer = "clang version 6.0.0 ", isOptimized = true, emissionKind = Full> +#di_derived_type1 = #llvm.di_derived_type +#di_subroutine_type = #llvm.di_subroutine_type +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "f", file = #di_file, line = 2, scopeLine = 2, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#di_local_variable = #llvm.di_local_variable +#di_local_variable1 = #llvm.di_local_variable +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @f(%arg0: !llvm.ptr) { + llvm.intr.dbg.value #di_local_variable = %arg0 : !llvm.ptr + llvm.intr.dbg.value #di_local_variable1 = %arg0 : !llvm.ptr + llvm.call @use_as_void(%arg0) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @use_as_void(!llvm.ptr) +} diff --git a/test/LLVMDialect/InstCombine/debuginfo-scalable-typesize.ll.mlir b/test/LLVMDialect/InstCombine/debuginfo-scalable-typesize.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/debuginfo-sink.ll.mlir b/test/LLVMDialect/InstCombine/debuginfo-sink.ll.mlir new file mode 100644 index 000000000..dc52f450b --- /dev/null +++ b/test/LLVMDialect/InstCombine/debuginfo-sink.ll.mlir @@ -0,0 +1,42 @@ +#di_basic_type = #llvm.di_basic_type +#di_file = #llvm.di_file<"a.c" in "."> +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C99, file = #di_file, producer = "clang", isOptimized = false, emissionKind = Full> +#di_subroutine_type = #llvm.di_subroutine_type +#di_subroutine_type1 = #llvm.di_subroutine_type +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "foo", file = #di_file, line = 2, scopeLine = 3, subprogramFlags = Definition, type = #di_subroutine_type> +#di_subprogram1 = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "bar", file = #di_file, line = 2, scopeLine = 3, subprogramFlags = Definition, type = #di_subroutine_type1> +#di_subprogram2 = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "baz", file = #di_file, line = 2, scopeLine = 3, subprogramFlags = Definition, type = #di_subroutine_type> +#di_local_variable = #llvm.di_local_variable +#di_local_variable1 = #llvm.di_local_variable +#di_local_variable2 = #llvm.di_local_variable +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.intr.dbg.value #di_local_variable = %1 : !llvm.ptr + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %2 : i32 + } + llvm.func @bar(%arg0: !llvm.ptr, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.vec + llvm.intr.dbg.value #di_local_variable1 = %1 : !llvm.ptr + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + %2 = llvm.load %1 {alignment = 16 : i64} : !llvm.ptr -> !llvm.vec + %3 = llvm.extractelement %2[%0 : i32] : !llvm.vec + llvm.return %3 : i32 + } + llvm.func @baz(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.intr.dbg.value #di_local_variable2 #llvm.di_expression<[DW_OP_plus_uconst(5)]> = %1 : !llvm.ptr + llvm.intr.dbg.value #di_local_variable2 = %1 : !llvm.ptr + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/debuginfo-skip.ll.mlir b/test/LLVMDialect/InstCombine/debuginfo-skip.ll.mlir new file mode 100644 index 000000000..d33957850 --- /dev/null +++ b/test/LLVMDialect/InstCombine/debuginfo-skip.ll.mlir @@ -0,0 +1,19 @@ +#di_basic_type = #llvm.di_basic_type +#di_file = #llvm.di_file<"a.c" in "/tmp"> +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C99, file = #di_file, producer = "clang 5.0.0", isOptimized = false, emissionKind = Full> +#di_subroutine_type = #llvm.di_subroutine_type +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "foo", file = #di_file, line = 2, scopeLine = 3, subprogramFlags = Definition, type = #di_subroutine_type> +#di_local_variable = #llvm.di_local_variable +#di_local_variable1 = #llvm.di_local_variable +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + llvm.intr.dbg.value #di_local_variable = %1 : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.dbg.declare #di_local_variable1 = %2 : !llvm.ptr + llvm.store %arg0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/debuginfo-variables.ll.mlir b/test/LLVMDialect/InstCombine/debuginfo-variables.ll.mlir new file mode 100644 index 000000000..290c7b9eb --- /dev/null +++ b/test/LLVMDialect/InstCombine/debuginfo-variables.ll.mlir @@ -0,0 +1,80 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @escape32(i32) + llvm.func @test_sext_zext(%arg0: i16) -> i64 { + %0 = llvm.zext %arg0 : i16 to i32 + %1 = llvm.sext %0 : i32 to i64 + llvm.return %1 : i64 + } + llvm.func @test_used_sext_zext(%arg0: i16) -> i64 { + %0 = llvm.zext %arg0 : i16 to i32 + %1 = llvm.sext %0 : i32 to i64 + llvm.call @escape32(%0) : (i32) -> () + llvm.return %1 : i64 + } + llvm.func @test_cast_select(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(3 : i16) : i16 + %1 = llvm.mlir.constant(5 : i16) : i16 + %2 = llvm.select %arg0, %0, %1 : i1, i16 + %3 = llvm.zext %2 : i16 to i32 + llvm.return %3 : i32 + } + llvm.func @test_or(%arg0: i64) { + %0 = llvm.mlir.constant(256 : i64) : i64 + %1 = llvm.or %arg0, %0 : i64 + llvm.return + } + llvm.func @test_xor(%arg0: i32) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + llvm.return + } + llvm.func @test_sub_neg(%arg0: i64) { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.sub %arg0, %0 : i64 + llvm.return + } + llvm.func @test_sub_pos(%arg0: i64) { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.sub %arg0, %0 : i64 + llvm.return + } + llvm.func @test_shl(%arg0: i64) { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + llvm.return + } + llvm.func @test_lshr(%arg0: i64) { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.lshr %arg0, %0 : i64 + llvm.return + } + llvm.func @test_ashr(%arg0: i64) { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.ashr %arg0, %0 : i64 + llvm.return + } + llvm.func @test_mul(%arg0: i64) { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.mul %arg0, %0 : i64 + llvm.return + } + llvm.func @test_sdiv(%arg0: i64) { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.sdiv %arg0, %0 : i64 + llvm.return + } + llvm.func @test_srem(%arg0: i64) { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.srem %arg0, %0 : i64 + llvm.return + } + llvm.func @test_ptrtoint(%arg0: !llvm.ptr) { + %0 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + llvm.return + } + llvm.func @test_and(%arg0: i64) { + %0 = llvm.mlir.constant(256 : i64) : i64 + %1 = llvm.and %arg0, %0 : i64 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/debuginfo.ll.mlir b/test/LLVMDialect/InstCombine/debuginfo.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/debuginfo_add.ll.mlir b/test/LLVMDialect/InstCombine/debuginfo_add.ll.mlir new file mode 100644 index 000000000..ed33c42d4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/debuginfo_add.ll.mlir @@ -0,0 +1,55 @@ +#di_basic_type = #llvm.di_basic_type +#di_basic_type1 = #llvm.di_basic_type +#di_file = #llvm.di_file<"test.i" in "/Data/radar/31209283"> +#di_null_type = #llvm.di_null_type +#loc = loc("test.i":11:5) +#loc1 = loc("test.i":14:3) +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C99, file = #di_file, producer = "clang version 6.0.0 (trunk 317434) (llvm/trunk 317437)", isOptimized = true, emissionKind = Full> +#di_derived_type = #llvm.di_derived_type +#di_derived_type1 = #llvm.di_derived_type +#di_composite_type = #llvm.di_composite_type +#di_derived_type2 = #llvm.di_derived_type +#di_derived_type3 = #llvm.di_derived_type +#di_subroutine_type = #llvm.di_subroutine_type +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "f", file = #di_file, line = 6, scopeLine = 6, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#di_lexical_block = #llvm.di_lexical_block +#di_local_variable = #llvm.di_local_variable +#di_local_variable1 = #llvm.di_local_variable +#di_local_variable2 = #llvm.di_local_variable +#di_local_variable3 = #llvm.di_local_variable +#di_local_variable4 = #llvm.di_local_variable +#loc2 = loc(fused<#di_lexical_block>[#loc]) +#loc3 = loc(fused<#di_lexical_block>[#loc1]) +#loop_annotation = #llvm.loop_annotation +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 32 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func local_unnamed_addr @f(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg2: i1) attributes {passthrough = ["nounwind", "ssp"]} { + llvm.intr.dbg.value #di_local_variable = %arg1 : !llvm.ptr + llvm.intr.dbg.value #di_local_variable1 = %arg0 : !llvm.ptr + %0 = llvm.mlir.constant(-4096 : i64) : i64 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.addressof @use : !llvm.ptr + %3 = llvm.mlir.constant(-4096 : i32) : i32 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.undef : i32 + llvm.intr.dbg.value #di_local_variable2 = %5 : i32 + %6 = llvm.load %arg1 {alignment = 4 : i64} : !llvm.ptr -> i64 + llvm.intr.dbg.value #di_local_variable3 = %6 : i64 + %7 = llvm.add %6, %0 : i64 + llvm.intr.dbg.value #di_local_variable4 = %7 : i64 + llvm.cond_br %arg2, ^bb3, ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%7, %1 : i64, i32) + ^bb2(%8: i64, %9: i32): // 2 preds: ^bb1, ^bb2 + llvm.intr.dbg.value #di_local_variable2 = %9 : i32 + %10 = llvm.call %2(%8, %arg0) : !llvm.ptr, (i64, !llvm.ptr) -> i32 + %11 = llvm.add %9, %3 : i32 + llvm.intr.dbg.value #di_local_variable2 = %11 : i32 + %12 = llvm.add %8, %0 : i64 + llvm.intr.dbg.value #di_local_variable4 = %12 : i64 + %13 = llvm.icmp "eq" %11, %4 : i32 + llvm.cond_br %13, ^bb3, ^bb2(%12, %11 : i64, i32) {loop_annotation = #loop_annotation} + ^bb3: // 2 preds: ^bb0, ^bb2 + llvm.return + } + llvm.func local_unnamed_addr @use(...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/default-alignment.ll.mlir b/test/LLVMDialect/InstCombine/default-alignment.ll.mlir index 58ebac356..5d0ed2300 100644 --- a/test/LLVMDialect/InstCombine/default-alignment.ll.mlir +++ b/test/LLVMDialect/InstCombine/default-alignment.ll.mlir @@ -1,10 +1,6 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.getelementptr"(%arg0, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %2 = "llvm.load"(%1) : (!llvm.ptr) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t", type = !llvm.func>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %0 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/demand_shrink_nsw.ll.mlir b/test/LLVMDialect/InstCombine/demand_shrink_nsw.ll.mlir index 48b3aa67f..0cba07870 100644 --- a/test/LLVMDialect/InstCombine/demand_shrink_nsw.ll.mlir +++ b/test/LLVMDialect/InstCombine/demand_shrink_nsw.ll.mlir @@ -1,28 +1,26 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 749011377 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -2147483648 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1533579450 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 221 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 1874836915 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = -784568073 : i32} : () -> i32 - %7 = "llvm.mlir.constant"() {value = 29 : i32} : () -> i32 - %8 = "llvm.mlir.constant"() {value = 223 : i32} : () -> i32 - %9 = "llvm.and"(%arg0, %8) : (i32, i32) -> i32 - %10 = "llvm.xor"(%9, %7) : (i32, i32) -> i32 - %11 = "llvm.add"(%10, %6) : (i32, i32) -> i32 - %12 = "llvm.or"(%10, %5) : (i32, i32) -> i32 - %13 = "llvm.and"(%10, %4) : (i32, i32) -> i32 - %14 = "llvm.xor"(%13, %5) : (i32, i32) -> i32 - %15 = "llvm.xor"(%12, %14) : (i32, i32) -> i32 - %16 = "llvm.shl"(%15, %3) : (i32, i32) -> i32 - %17 = "llvm.sub"(%11, %16) : (i32, i32) -> i32 - %18 = "llvm.add"(%17, %2) : (i32, i32) -> i32 - %19 = "llvm.or"(%18, %1) : (i32, i32) -> i32 - %20 = "llvm.xor"(%19, %0) : (i32, i32) -> i32 - "llvm.return"(%20) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(223 : i32) : i32 + %1 = llvm.mlir.constant(29 : i32) : i32 + %2 = llvm.mlir.constant(-784568073 : i32) : i32 + %3 = llvm.mlir.constant(1874836915 : i32) : i32 + %4 = llvm.mlir.constant(221 : i32) : i32 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.mlir.constant(1533579450 : i32) : i32 + %7 = llvm.mlir.constant(-2147483648 : i32) : i32 + %8 = llvm.mlir.constant(749011377 : i32) : i32 + %9 = llvm.and %arg0, %0 : i32 + %10 = llvm.xor %9, %1 : i32 + %11 = llvm.add %10, %2 overflow : i32 + %12 = llvm.or %10, %3 : i32 + %13 = llvm.and %10, %4 : i32 + %14 = llvm.xor %13, %3 : i32 + %15 = llvm.xor %12, %14 : i32 + %16 = llvm.shl %15, %5 overflow : i32 + %17 = llvm.sub %11, %16 : i32 + %18 = llvm.add %17, %6 overflow : i32 + %19 = llvm.or %18, %7 : i32 + %20 = llvm.xor %19, %8 : i32 + llvm.return %20 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/demorgan-sink-not-into-xor.ll.mlir b/test/LLVMDialect/InstCombine/demorgan-sink-not-into-xor.ll.mlir index 40c01391b..629280a23 100644 --- a/test/LLVMDialect/InstCombine/demorgan-sink-not-into-xor.ll.mlir +++ b/test/LLVMDialect/InstCombine/demorgan-sink-not-into-xor.ll.mlir @@ -1,79 +1,69 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 0 : i16} : () -> i16 - %3 = "llvm.icmp"(%arg0, %2) {predicate = 2 : i64} : (i16, i16) -> i1 - %4 = "llvm.icmp"(%arg1, %1) {predicate = 2 : i64} : (i8, i8) -> i1 - %5 = "llvm.xor"(%4, %3) : (i1, i1) -> i1 - %6 = "llvm.xor"(%5, %0) : (i1, i1) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "positive_easyinvert", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %2 = "llvm.call"() {callee = @gen1, fastmathFlags = #llvm.fastmath<>} : () -> i1 - %3 = "llvm.icmp"(%arg0, %1) {predicate = 2 : i64} : (i8, i8) -> i1 - %4 = "llvm.xor"(%3, %2) : (i1, i1) -> i1 - %5 = "llvm.xor"(%4, %0) : (i1, i1) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "positive_easyinvert0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %2 = "llvm.call"() {callee = @gen1, fastmathFlags = #llvm.fastmath<>} : () -> i1 - %3 = "llvm.icmp"(%arg0, %1) {predicate = 2 : i64} : (i8, i8) -> i1 - %4 = "llvm.xor"(%2, %3) : (i1, i1) -> i1 - %5 = "llvm.xor"(%4, %0) : (i1, i1) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "positive_easyinvert1", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %2 = "llvm.call"() {callee = @gen1, fastmathFlags = #llvm.fastmath<>} : () -> i1 - %3 = "llvm.icmp"(%arg0, %1) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.call"(%3) {callee = @use1, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %4 = "llvm.xor"(%2, %3) : (i1, i1) -> i1 - %5 = "llvm.xor"(%4, %0) : (i1, i1) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "oneuse_easyinvert_0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %2 = "llvm.call"() {callee = @gen1, fastmathFlags = #llvm.fastmath<>} : () -> i1 - %3 = "llvm.icmp"(%arg0, %1) {predicate = 2 : i64} : (i8, i8) -> i1 - %4 = "llvm.xor"(%2, %3) : (i1, i1) -> i1 - "llvm.call"(%4) {callee = @use1, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %5 = "llvm.xor"(%4, %0) : (i1, i1) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "oneuse_easyinvert_1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %2 = "llvm.call"() {callee = @gen1, fastmathFlags = #llvm.fastmath<>} : () -> i1 - %3 = "llvm.icmp"(%arg0, %1) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.call"(%3) {callee = @use1, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %4 = "llvm.xor"(%2, %3) : (i1, i1) -> i1 - "llvm.call"(%4) {callee = @use1, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %5 = "llvm.xor"(%4, %0) : (i1, i1) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "oneuse_easyinvert_2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.xor"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.xor"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "negative", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @gen1() -> i1 + llvm.func @positive_easyinvert(%arg0: i16, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "slt" %arg0, %0 : i16 + %4 = llvm.icmp "slt" %arg1, %1 : i8 + %5 = llvm.xor %4, %3 : i1 + %6 = llvm.xor %5, %2 : i1 + llvm.return %6 : i1 + } + llvm.func @positive_easyinvert0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.call @gen1() : () -> i1 + %3 = llvm.icmp "slt" %arg0, %0 : i8 + %4 = llvm.xor %3, %2 : i1 + %5 = llvm.xor %4, %1 : i1 + llvm.return %5 : i1 + } + llvm.func @positive_easyinvert1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.call @gen1() : () -> i1 + %3 = llvm.icmp "slt" %arg0, %0 : i8 + %4 = llvm.xor %2, %3 : i1 + %5 = llvm.xor %4, %1 : i1 + llvm.return %5 : i1 + } + llvm.func @use1(i1) + llvm.func @oneuse_easyinvert_0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.call @gen1() : () -> i1 + %3 = llvm.icmp "slt" %arg0, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.xor %2, %3 : i1 + %5 = llvm.xor %4, %1 : i1 + llvm.return %5 : i1 + } + llvm.func @oneuse_easyinvert_1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.call @gen1() : () -> i1 + %3 = llvm.icmp "slt" %arg0, %0 : i8 + %4 = llvm.xor %2, %3 : i1 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.xor %4, %1 : i1 + llvm.return %5 : i1 + } + llvm.func @oneuse_easyinvert_2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.call @gen1() : () -> i1 + %3 = llvm.icmp "slt" %arg0, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.xor %2, %3 : i1 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.xor %4, %1 : i1 + llvm.return %5 : i1 + } + llvm.func @negative(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/demorgan.ll.mlir b/test/LLVMDialect/InstCombine/demorgan.ll.mlir new file mode 100644 index 000000000..8b76a6971 --- /dev/null +++ b/test/LLVMDialect/InstCombine/demorgan.ll.mlir @@ -0,0 +1,292 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @demorgan_or_apint1(%arg0: i43, %arg1: i43) -> i43 { + %0 = llvm.mlir.constant(-1 : i43) : i43 + %1 = llvm.xor %arg0, %0 : i43 + %2 = llvm.xor %arg1, %0 : i43 + %3 = llvm.or %1, %2 : i43 + llvm.return %3 : i43 + } + llvm.func @demorgan_or_apint2(%arg0: i129, %arg1: i129) -> i129 { + %0 = llvm.mlir.constant(-1 : i129) : i129 + %1 = llvm.xor %arg0, %0 : i129 + %2 = llvm.xor %arg1, %0 : i129 + %3 = llvm.or %1, %2 : i129 + llvm.return %3 : i129 + } + llvm.func @demorgan_and_apint1(%arg0: i477, %arg1: i477) -> i477 { + %0 = llvm.mlir.constant(-1 : i477) : i477 + %1 = llvm.xor %arg0, %0 : i477 + %2 = llvm.xor %arg1, %0 : i477 + %3 = llvm.and %1, %2 : i477 + llvm.return %3 : i477 + } + llvm.func @demorgan_and_apint2(%arg0: i129, %arg1: i129) -> i129 { + %0 = llvm.mlir.constant(-1 : i129) : i129 + %1 = llvm.xor %arg0, %0 : i129 + %2 = llvm.xor %arg1, %0 : i129 + %3 = llvm.and %1, %2 : i129 + llvm.return %3 : i129 + } + llvm.func @demorgan_and_apint3(%arg0: i65, %arg1: i65) -> i65 { + %0 = llvm.mlir.constant(-1 : i65) : i65 + %1 = llvm.xor %arg0, %0 : i65 + %2 = llvm.xor %0, %arg1 : i65 + %3 = llvm.and %1, %2 : i65 + llvm.return %3 : i65 + } + llvm.func @demorgan_and_apint4(%arg0: i66, %arg1: i66) -> i66 { + %0 = llvm.mlir.constant(-1 : i66) : i66 + %1 = llvm.xor %arg0, %0 : i66 + %2 = llvm.xor %arg1, %0 : i66 + %3 = llvm.and %1, %2 : i66 + llvm.return %3 : i66 + } + llvm.func @demorgan_and_apint5(%arg0: i47, %arg1: i47) -> i47 { + %0 = llvm.mlir.constant(-1 : i47) : i47 + %1 = llvm.xor %arg0, %0 : i47 + %2 = llvm.xor %arg1, %0 : i47 + %3 = llvm.and %1, %2 : i47 + llvm.return %3 : i47 + } + llvm.func @test3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.and %1, %2 : i32 + %4 = llvm.xor %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @test4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.xor %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @test5(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.or %1, %2 : i32 + %4 = llvm.xor %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @test3_apint(%arg0: i47, %arg1: i47) -> i47 { + %0 = llvm.mlir.constant(-1 : i47) : i47 + %1 = llvm.xor %arg0, %0 : i47 + %2 = llvm.xor %arg1, %0 : i47 + %3 = llvm.and %1, %2 : i47 + %4 = llvm.xor %3, %0 : i47 + llvm.return %4 : i47 + } + llvm.func @test4_apint(%arg0: i61) -> i61 { + %0 = llvm.mlir.constant(-1 : i61) : i61 + %1 = llvm.mlir.constant(5 : i61) : i61 + %2 = llvm.xor %arg0, %0 : i61 + %3 = llvm.and %2, %1 : i61 + %4 = llvm.xor %3, %0 : i61 + llvm.return %3 : i61 + } + llvm.func @test5_apint(%arg0: i71, %arg1: i71) -> i71 { + %0 = llvm.mlir.constant(-1 : i71) : i71 + %1 = llvm.xor %arg0, %0 : i71 + %2 = llvm.xor %arg1, %0 : i71 + %3 = llvm.or %1, %2 : i71 + %4 = llvm.xor %3, %0 : i71 + llvm.return %4 : i71 + } + llvm.func @demorgan_nand(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.and %1, %arg1 : i8 + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @demorgan_nand_apint1(%arg0: i7, %arg1: i7) -> i7 { + %0 = llvm.mlir.constant(-1 : i7) : i7 + %1 = llvm.xor %arg0, %0 : i7 + %2 = llvm.and %1, %arg1 : i7 + %3 = llvm.xor %2, %0 : i7 + llvm.return %3 : i7 + } + llvm.func @demorgan_nand_apint2(%arg0: i117, %arg1: i117) -> i117 { + %0 = llvm.mlir.constant(-1 : i117) : i117 + %1 = llvm.xor %arg0, %0 : i117 + %2 = llvm.and %1, %arg1 : i117 + %3 = llvm.xor %2, %0 : i117 + llvm.return %3 : i117 + } + llvm.func @demorgan_nor(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.or %1, %arg1 : i8 + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @demorgan_nor_use2a(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(23 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.mul %2, %1 : i8 + %4 = llvm.or %2, %arg1 : i8 + %5 = llvm.xor %4, %0 : i8 + %6 = llvm.sdiv %5, %3 : i8 + llvm.return %6 : i8 + } + llvm.func @demorgan_nor_use2b(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(23 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mul %arg1, %0 : i8 + %3 = llvm.xor %arg0, %1 : i8 + %4 = llvm.or %3, %arg1 : i8 + %5 = llvm.xor %4, %1 : i8 + %6 = llvm.sdiv %5, %2 : i8 + llvm.return %6 : i8 + } + llvm.func @demorgan_nor_use2c(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(23 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.or %2, %arg1 : i8 + %4 = llvm.mul %3, %1 : i8 + %5 = llvm.xor %3, %0 : i8 + %6 = llvm.sdiv %5, %4 : i8 + llvm.return %6 : i8 + } + llvm.func @demorgan_nor_use2ab(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(23 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(17 : i8) : i8 + %3 = llvm.mul %arg1, %0 : i8 + %4 = llvm.xor %arg0, %1 : i8 + %5 = llvm.mul %4, %2 : i8 + %6 = llvm.or %4, %arg1 : i8 + %7 = llvm.xor %6, %1 : i8 + %8 = llvm.sdiv %7, %3 : i8 + %9 = llvm.sdiv %8, %5 : i8 + llvm.return %9 : i8 + } + llvm.func @demorgan_nor_use2ac(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(17 : i8) : i8 + %2 = llvm.mlir.constant(23 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.mul %3, %1 : i8 + %5 = llvm.or %3, %arg1 : i8 + %6 = llvm.mul %5, %2 : i8 + %7 = llvm.xor %5, %0 : i8 + %8 = llvm.sdiv %7, %6 : i8 + %9 = llvm.sdiv %8, %4 : i8 + llvm.return %9 : i8 + } + llvm.func @demorgan_nor_use2bc(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(23 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mul %arg1, %0 : i8 + %3 = llvm.xor %arg0, %1 : i8 + %4 = llvm.or %3, %arg1 : i8 + %5 = llvm.mul %4, %0 : i8 + %6 = llvm.xor %4, %1 : i8 + %7 = llvm.sdiv %6, %5 : i8 + %8 = llvm.sdiv %7, %2 : i8 + llvm.return %8 : i8 + } + llvm.func @demorganize_constant1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.xor %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @demorganize_constant2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.xor %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @demorgan_or_zext(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.or %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @demorgan_and_zext(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.and %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @demorgan_or_zext_vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.zext %arg1 : vector<2xi1> to vector<2xi32> + %3 = llvm.xor %1, %0 : vector<2xi32> + %4 = llvm.xor %2, %0 : vector<2xi32> + %5 = llvm.or %3, %4 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @demorgan_and_zext_vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.zext %arg1 : vector<2xi1> to vector<2xi32> + %3 = llvm.xor %1, %0 : vector<2xi32> + %4 = llvm.xor %2, %0 : vector<2xi32> + %5 = llvm.and %3, %4 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @PR28476(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + %3 = llvm.icmp "ne" %arg1, %0 : i32 + %4 = llvm.and %2, %3 : i1 + %5 = llvm.zext %4 : i1 to i32 + %6 = llvm.xor %5, %1 : i32 + llvm.return %6 : i32 + } + llvm.func @PR28476_logical(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.icmp "ne" %arg0, %0 : i32 + %4 = llvm.icmp "ne" %arg1, %0 : i32 + %5 = llvm.select %3, %4, %1 : i1, i1 + %6 = llvm.zext %5 : i1 to i32 + %7 = llvm.xor %6, %2 : i32 + llvm.return %7 : i32 + } + llvm.func @demorgan_plus_and_to_xor(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg1, %arg0 : i32 + %4 = llvm.or %3, %2 : i32 + %5 = llvm.xor %4, %0 : i32 + llvm.return %5 : i32 + } + llvm.func @demorgan_plus_and_to_xor_vec(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.or %arg0, %arg1 : vector<4xi32> + %2 = llvm.xor %1, %0 : vector<4xi32> + %3 = llvm.and %arg0, %arg1 : vector<4xi32> + %4 = llvm.or %3, %2 : vector<4xi32> + %5 = llvm.xor %4, %0 : vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @PR45984(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.or %arg1, %arg0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.or %1, %3 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/dependent-ivs.ll.mlir b/test/LLVMDialect/InstCombine/dependent-ivs.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/deref-alloc-fns.ll.mlir b/test/LLVMDialect/InstCombine/deref-alloc-fns.ll.mlir new file mode 100644 index 000000000..94de048a2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/deref-alloc-fns.ll.mlir @@ -0,0 +1,223 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private unnamed_addr constant @".str"("hello\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.func @malloc(i64) -> (!llvm.ptr {llvm.noalias}) attributes {passthrough = [["allockind", "9"], ["allocsize", "4294967295"], ["alloc-family", "malloc"]]} + llvm.func @calloc(i64, i64) -> (!llvm.ptr {llvm.noalias}) attributes {passthrough = [["allockind", "17"], ["allocsize", "1"], ["alloc-family", "malloc"]]} + llvm.func @realloc(!llvm.ptr {llvm.nocapture}, i64) -> (!llvm.ptr {llvm.noalias}) attributes {passthrough = [["allockind", "2"], ["allocsize", "8589934591"], ["alloc-family", "malloc"]]} + llvm.func @_Znam(i64) -> (!llvm.ptr {llvm.noalias, llvm.nonnull}) + llvm.func @_Znwm(i64) -> (!llvm.ptr {llvm.noalias, llvm.nonnull}) + llvm.func @strdup(!llvm.ptr) -> (!llvm.ptr {llvm.noalias}) + llvm.func @aligned_alloc(i64 {llvm.allocalign}, i64) -> (!llvm.ptr {llvm.noalias}) attributes {passthrough = [["allockind", "41"], ["allocsize", "8589934591"], ["alloc-family", "malloc"]]} + llvm.func @memalign(i64 {llvm.allocalign}, i64) -> (!llvm.ptr {llvm.align = 16 : i64, llvm.noalias}) attributes {passthrough = [["allocsize", "8589934591"]]} + llvm.func @_ZnamSt11align_val_t(i64, i64) -> (!llvm.ptr {llvm.noalias}) + llvm.func @my_malloc(i64) -> !llvm.ptr attributes {passthrough = [["allocsize", "4294967295"]]} + llvm.func @my_calloc(i64, i64) -> !llvm.ptr attributes {passthrough = [["allocsize", "1"]]} + llvm.func @malloc_nonconstant_size(%arg0: i64) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.call @malloc(%arg0) : (i64) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @malloc_constant_size() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(40 : i64) : i64 + %1 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @aligned_alloc_constant_size() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(512 : i64) : i64 + %2 = llvm.call @aligned_alloc(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @aligned_alloc_unknown_size_nonzero(%arg0: i1) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.mlir.constant(128 : i64) : i64 + %2 = llvm.mlir.constant(32 : i64) : i64 + %3 = llvm.select %arg0, %0, %1 : i1, i64 + %4 = llvm.call @aligned_alloc(%2, %3) : (i64, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @aligned_alloc_unknown_size_possibly_zero(%arg0: i1) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(32 : i64) : i64 + %3 = llvm.select %arg0, %0, %1 : i1, i64 + %4 = llvm.call @aligned_alloc(%2, %3) : (i64, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @aligned_alloc_unknown_align(%arg0: i64) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(128 : i64) : i64 + %1 = llvm.call @aligned_alloc(%arg0, %0) : (i64, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @foo(!llvm.ptr, !llvm.ptr, !llvm.ptr) -> (!llvm.ptr {llvm.noalias}) + llvm.func @aligned_alloc_dynamic_args(%arg0: i64, %arg1: i64) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(1024 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(32 : i64) : i64 + %3 = llvm.call @aligned_alloc(%arg0, %0) : (i64, i64) -> !llvm.ptr + %4 = llvm.call @aligned_alloc(%1, %0) : (i64, i64) -> !llvm.ptr + %5 = llvm.call @aligned_alloc(%2, %arg1) : (i64, i64) -> !llvm.ptr + %6 = llvm.call @foo(%3, %4, %5) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @memalign_constant_size() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(512 : i64) : i64 + %2 = llvm.call @memalign(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @memalign_unknown_size_nonzero(%arg0: i1) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.mlir.constant(128 : i64) : i64 + %2 = llvm.mlir.constant(32 : i64) : i64 + %3 = llvm.select %arg0, %0, %1 : i1, i64 + %4 = llvm.call @memalign(%2, %3) : (i64, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memalign_unknown_size_possibly_zero(%arg0: i1) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(32 : i64) : i64 + %3 = llvm.select %arg0, %0, %1 : i1, i64 + %4 = llvm.call @memalign(%2, %3) : (i64, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memalign_unknown_align(%arg0: i64) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(128 : i64) : i64 + %1 = llvm.call @memalign(%arg0, %0) : (i64, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @malloc_constant_size2() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(40 : i64) : i64 + %1 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @malloc_constant_size3() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(40 : i64) : i64 + %1 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @malloc_constant_zero_size() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @realloc_nonconstant_size(%arg0: !llvm.ptr, %arg1: i64) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.call @realloc(%arg0, %arg1) : (!llvm.ptr, i64) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @realloc_constant_zero_size(%arg0: !llvm.ptr) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @realloc(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @realloc_constant_size(%arg0: !llvm.ptr) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(40 : i64) : i64 + %1 = llvm.call @realloc(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @calloc_nonconstant_size(%arg0: i64) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.call @calloc(%0, %arg0) : (i64, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @calloc_nonconstant_size2(%arg0: i64) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @calloc(%arg0, %0) : (i64, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @calloc_nonconstant_size3(%arg0: i64) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.call @calloc(%arg0, %arg0) : (i64, i64) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @calloc_constant_zero_size() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @calloc(%0, %0) : (i64, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @calloc_constant_zero_size2(%arg0: i64) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @calloc(%arg0, %0) : (i64, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @calloc_constant_zero_size3(%arg0: i64) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @calloc(%0, %arg0) : (i64, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @calloc_constant_zero_size4(%arg0: i64) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.call @calloc(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @calloc_constant_zero_size5(%arg0: i64) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.call @calloc(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @calloc_constant_size() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(8 : i64) : i64 + %2 = llvm.call @calloc(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @calloc_constant_size_overflow() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(2000000000000 : i64) : i64 + %1 = llvm.mlir.constant(80000000000 : i64) : i64 + %2 = llvm.call @calloc(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @op_new_nonconstant_size(%arg0: i64) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.call @_Znam(%arg0) : (i64) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @op_new_constant_size() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(40 : i64) : i64 + %1 = llvm.call @_Znam(%0) : (i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @op_new_constant_size2() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(40 : i64) : i64 + %1 = llvm.call @_Znwm(%0) : (i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @op_new_constant_zero_size() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @_Znam(%0) : (i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @strdup_constant_str() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.call @strdup(%1) : (!llvm.ptr) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @strdup_notconstant_str(%arg0: !llvm.ptr) -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.call @strdup(%arg0) : (!llvm.ptr) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @ossfuzz_23214() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %2 = llvm.mlir.constant(512 : i64) : i64 + %3 = llvm.and %0, %1 : i64 + %4 = llvm.call @aligned_alloc(%3, %2) : (i64, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @op_new_align() -> (!llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.call @_ZnamSt11align_val_t(%0, %0) : (i64, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @my_malloc_constant_size() -> !llvm.ptr { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.call @my_malloc(%0) : (i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @my_calloc_constant_size() -> !llvm.ptr { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(4 : i64) : i64 + %2 = llvm.call @my_calloc(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/disable-builtin.ll.mlir b/test/LLVMDialect/InstCombine/disable-builtin.ll.mlir new file mode 100644 index 000000000..efb4b4d9e --- /dev/null +++ b/test/LLVMDialect/InstCombine/disable-builtin.ll.mlir @@ -0,0 +1,11 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.mlir.global external constant @empty(dense<0> : tensor<1xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<1 x i8> + llvm.func @strcat(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @test_strcat(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @empty : !llvm.ptr + %3 = llvm.call @strcat(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/disable-simplify-libcalls.ll.mlir b/test/LLVMDialect/InstCombine/disable-simplify-libcalls.ll.mlir new file mode 100644 index 000000000..d1c639827 --- /dev/null +++ b/test/LLVMDialect/InstCombine/disable-simplify-libcalls.ll.mlir @@ -0,0 +1,260 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @".str"(dense<0> : tensor<1xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<1 x i8> + llvm.mlir.global external constant @".str1"("hello, world\00") {addr_space = 0 : i32, alignment = 1 : i64} + llvm.mlir.global external constant @".str2"("foo\00") {addr_space = 0 : i32, alignment = 1 : i64} + llvm.mlir.global external constant @".str3"("bar\00") {addr_space = 0 : i32, alignment = 1 : i64} + llvm.mlir.global external constant @".str4"("123.4\00") {addr_space = 0 : i32, alignment = 1 : i64} + llvm.mlir.global external constant @".str5"("1234\00") {addr_space = 0 : i32, alignment = 1 : i64} + llvm.mlir.global external constant @empty(dense<0> : tensor<1xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<1 x i8> + llvm.func @ceil(f64) -> f64 + llvm.func @copysign(f64, f64) -> f64 + llvm.func @cos(f64) -> f64 + llvm.func @fabs(f64) -> f64 + llvm.func @floor(f64) -> f64 + llvm.func @strcat(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @strncat(!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.func @strchr(!llvm.ptr, i32) -> !llvm.ptr + llvm.func @strrchr(!llvm.ptr, i32) -> !llvm.ptr + llvm.func @strcmp(!llvm.ptr, !llvm.ptr) -> i32 + llvm.func @strncmp(!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.func @strcpy(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @stpcpy(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @strncpy(!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.func @strlen(!llvm.ptr) -> i64 + llvm.func @strpbrk(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @strspn(!llvm.ptr, !llvm.ptr) -> i64 + llvm.func @strtod(!llvm.ptr, !llvm.ptr) -> f64 + llvm.func @strtof(!llvm.ptr, !llvm.ptr) -> f32 + llvm.func @strtold(!llvm.ptr, !llvm.ptr) -> f80 + llvm.func @strtol(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @strtoll(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @strtoul(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @strtoull(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @strcspn(!llvm.ptr, !llvm.ptr) -> i64 + llvm.func @abs(i32) -> i32 + llvm.func @ffs(i32) -> i32 + llvm.func @ffsl(i64) -> i32 + llvm.func @ffsll(i64) -> i32 + llvm.func @fprintf(!llvm.ptr, !llvm.ptr) -> i32 + llvm.func @isascii(i32) -> i32 + llvm.func @isdigit(i32) -> i32 + llvm.func @toascii(i32) -> i32 + llvm.func @labs(i64) -> i64 + llvm.func @llabs(i64) -> i64 + llvm.func @printf(!llvm.ptr) -> i32 + llvm.func @sprintf(!llvm.ptr, !llvm.ptr) -> i32 + llvm.func @t1(%arg0: f64) -> f64 { + %0 = llvm.call @ceil(%arg0) : (f64) -> f64 + llvm.return %0 : f64 + } + llvm.func @t2(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.call @copysign(%arg0, %arg1) : (f64, f64) -> f64 + llvm.return %0 : f64 + } + llvm.func @t3(%arg0: f64) -> f64 { + %0 = llvm.call @cos(%arg0) : (f64) -> f64 + llvm.return %0 : f64 + } + llvm.func @t4(%arg0: f64) -> f64 { + %0 = llvm.call @fabs(%arg0) : (f64) -> f64 + llvm.return %0 : f64 + } + llvm.func @t5(%arg0: f64) -> f64 { + %0 = llvm.call @floor(%arg0) : (f64) -> f64 + llvm.return %0 : f64 + } + llvm.func @t6(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @empty : !llvm.ptr + %3 = llvm.call @strcat(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @t7(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @empty : !llvm.ptr + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.call @strncat(%arg0, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @t8() -> !llvm.ptr { + %0 = llvm.mlir.constant("hello, world\00") : !llvm.array<13 x i8> + %1 = llvm.mlir.addressof @".str1" : !llvm.ptr + %2 = llvm.mlir.constant(119 : i32) : i32 + %3 = llvm.call @strchr(%1, %2) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @t9() -> !llvm.ptr { + %0 = llvm.mlir.constant("hello, world\00") : !llvm.array<13 x i8> + %1 = llvm.mlir.addressof @".str1" : !llvm.ptr + %2 = llvm.mlir.constant(119 : i32) : i32 + %3 = llvm.call @strrchr(%1, %2) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @t10() -> i32 { + %0 = llvm.mlir.constant("foo\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @".str2" : !llvm.ptr + %2 = llvm.mlir.constant("bar\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.addressof @".str3" : !llvm.ptr + %4 = llvm.call @strcmp(%1, %3) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %4 : i32 + } + llvm.func @t11() -> i32 { + %0 = llvm.mlir.constant("foo\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @".str2" : !llvm.ptr + %2 = llvm.mlir.constant("bar\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.addressof @".str3" : !llvm.ptr + %4 = llvm.mlir.constant(3 : i64) : i64 + %5 = llvm.call @strncmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %5 : i32 + } + llvm.func @t12(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("foo\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @".str2" : !llvm.ptr + %2 = llvm.call @strcpy(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @t13(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("foo\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @".str2" : !llvm.ptr + %2 = llvm.call @stpcpy(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @t14(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("foo\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @".str2" : !llvm.ptr + %2 = llvm.mlir.constant(3 : i64) : i64 + %3 = llvm.call @strncpy(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @t15() -> i64 { + %0 = llvm.mlir.constant("foo\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @".str2" : !llvm.ptr + %2 = llvm.call @strlen(%1) : (!llvm.ptr) -> i64 + llvm.return %2 : i64 + } + llvm.func @t16(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @".str" : !llvm.ptr + %3 = llvm.call @strpbrk(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @t17(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @".str" : !llvm.ptr + %3 = llvm.call @strspn(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> i64 + llvm.return %3 : i64 + } + llvm.func @t18(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant("123.4\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @".str4" : !llvm.ptr + %2 = llvm.call @strtod(%1, %arg0) : (!llvm.ptr, !llvm.ptr) -> f64 + llvm.return %2 : f64 + } + llvm.func @t19(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant("123.4\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @".str4" : !llvm.ptr + %2 = llvm.call @strtof(%1, %arg0) : (!llvm.ptr, !llvm.ptr) -> f32 + llvm.return %2 : f32 + } + llvm.func @t20(%arg0: !llvm.ptr) -> f80 { + %0 = llvm.mlir.constant("123.4\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @".str4" : !llvm.ptr + %2 = llvm.call @strtold(%1, %arg0) : (!llvm.ptr, !llvm.ptr) -> f80 + llvm.return %2 : f80 + } + llvm.func @t21(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @".str5" : !llvm.ptr + %2 = llvm.mlir.constant(10 : i32) : i32 + %3 = llvm.call @strtol(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %3 : i64 + } + llvm.func @t22(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @".str5" : !llvm.ptr + %2 = llvm.mlir.constant(10 : i32) : i32 + %3 = llvm.call @strtoll(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %3 : i64 + } + llvm.func @t23(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @".str5" : !llvm.ptr + %2 = llvm.mlir.constant(10 : i32) : i32 + %3 = llvm.call @strtoul(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %3 : i64 + } + llvm.func @t24(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @".str5" : !llvm.ptr + %2 = llvm.mlir.constant(10 : i32) : i32 + %3 = llvm.call @strtoull(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %3 : i64 + } + llvm.func @t25(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @empty : !llvm.ptr + %3 = llvm.call @strcspn(%2, %arg0) : (!llvm.ptr, !llvm.ptr) -> i64 + llvm.return %3 : i64 + } + llvm.func @t26(%arg0: i32) -> i32 { + %0 = llvm.call @abs(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } + llvm.func @t27(%arg0: i32) -> i32 { + %0 = llvm.call @ffs(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } + llvm.func @t28(%arg0: i64) -> i32 { + %0 = llvm.call @ffsl(%arg0) : (i64) -> i32 + llvm.return %0 : i32 + } + llvm.func @t29(%arg0: i64) -> i32 { + %0 = llvm.call @ffsll(%arg0) : (i64) -> i32 + llvm.return %0 : i32 + } + llvm.func @t30() { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant("hello, world\00") : !llvm.array<13 x i8> + %2 = llvm.mlir.addressof @".str1" : !llvm.ptr + %3 = llvm.call @fprintf(%0, %2) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @t31(%arg0: i32) -> i32 { + %0 = llvm.call @isascii(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } + llvm.func @t32(%arg0: i32) -> i32 { + %0 = llvm.call @isdigit(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } + llvm.func @t33(%arg0: i32) -> i32 { + %0 = llvm.call @toascii(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } + llvm.func @t34(%arg0: i64) -> i64 { + %0 = llvm.call @labs(%arg0) : (i64) -> i64 + llvm.return %0 : i64 + } + llvm.func @t35(%arg0: i64) -> i64 { + %0 = llvm.call @llabs(%arg0) : (i64) -> i64 + llvm.return %0 : i64 + } + llvm.func @t36() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @empty : !llvm.ptr + %3 = llvm.call @printf(%2) : (!llvm.ptr) -> i32 + llvm.return + } + llvm.func @t37(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("hello, world\00") : !llvm.array<13 x i8> + %1 = llvm.mlir.addressof @".str1" : !llvm.ptr + %2 = llvm.call @sprintf(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/distribute.ll.mlir b/test/LLVMDialect/InstCombine/distribute.ll.mlir index eea2819dd..f5b678306 100644 --- a/test/LLVMDialect/InstCombine/distribute.ll.mlir +++ b/test/LLVMDialect/InstCombine/distribute.ll.mlir @@ -1,56 +1,49 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.or"(%arg0, %0) : (i32, i32) -> i32 - %4 = "llvm.and"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "factorize", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %2 = "llvm.mul"(%1, %arg0) : (i32, i32) -> i32 - %3 = "llvm.mul"(%0, %arg0) : (i32, i32) -> i32 - %4 = "llvm.sub"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "factorize2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.or"(%arg1, %arg2) : (i32, i32) -> i32 - %1 = "llvm.or"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.or"(%arg0, %arg2) : (i32, i32) -> i32 - %3 = "llvm.and"(%1, %2) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "factorize3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.shl"(%arg1, %0) : (i32, i32) -> i32 - %2 = "llvm.mul"(%1, %arg0) : (i32, i32) -> i32 - %3 = "llvm.mul"(%arg0, %arg1) : (i32, i32) -> i32 - %4 = "llvm.sub"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "factorize4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.mul"(%arg1, %0) : (i32, i32) -> i32 - %2 = "llvm.mul"(%1, %arg0) : (i32, i32) -> i32 - %3 = "llvm.mul"(%arg0, %arg1) : (i32, i32) -> i32 - %4 = "llvm.sub"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "factorize5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.or"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.and"(%3, %1) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "expand", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @factorize(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.or %arg0, %1 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @factorize2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mul %0, %arg0 : i32 + %3 = llvm.mul %1, %arg0 : i32 + %4 = llvm.sub %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @factorize3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.or %arg1, %arg2 : i32 + %1 = llvm.or %arg0, %0 : i32 + %2 = llvm.or %arg0, %arg2 : i32 + %3 = llvm.and %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @factorize4(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %arg1, %0 : i32 + %2 = llvm.mul %1, %arg0 : i32 + %3 = llvm.mul %arg0, %arg1 : i32 + %4 = llvm.sub %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @factorize5(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mul %arg1, %0 : i32 + %2 = llvm.mul %1, %arg0 : i32 + %3 = llvm.mul %arg0, %arg1 : i32 + %4 = llvm.sub %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @expand(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.or %2, %1 : i32 + %4 = llvm.and %3, %0 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/div-by-0-guard-before-smul_ov-not.ll.mlir b/test/LLVMDialect/InstCombine/div-by-0-guard-before-smul_ov-not.ll.mlir new file mode 100644 index 000000000..437a0a5bd --- /dev/null +++ b/test/LLVMDialect/InstCombine/div-by-0-guard-before-smul_ov-not.ll.mlir @@ -0,0 +1,63 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_umul(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i4 + %3 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.xor %4, %1 : i1 + %6 = llvm.select %2, %1, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t1_commutative(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i4 + %3 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.xor %4, %1 : i1 + %6 = llvm.select %5, %1, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @n2_wrong_size(%arg0: i4, %arg1: i4, %arg2: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg1, %0 : i4 + %3 = "llvm.intr.smul.with.overflow"(%arg0, %arg2) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.xor %4, %1 : i1 + %6 = llvm.select %2, %1, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @n3_wrong_pred(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i4 + %3 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.xor %4, %1 : i1 + %6 = llvm.select %2, %1, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @n4_not_and(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "eq" %arg0, %0 : i4 + %4 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %5 = llvm.extractvalue %4[1] : !llvm.struct<(i4, i1)> + %6 = llvm.xor %5, %1 : i1 + %7 = llvm.select %3, %6, %2 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @n5_not_zero(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i4 + %3 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.xor %4, %1 : i1 + %6 = llvm.select %2, %1, %5 : i1, i1 + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/div-by-0-guard-before-smul_ov.ll.mlir b/test/LLVMDialect/InstCombine/div-by-0-guard-before-smul_ov.ll.mlir new file mode 100644 index 000000000..dac9c9461 --- /dev/null +++ b/test/LLVMDialect/InstCombine/div-by-0-guard-before-smul_ov.ll.mlir @@ -0,0 +1,56 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_smul(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i4 + %3 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.select %4, %2, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t1_commutative(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i4 + %3 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.select %2, %4, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @n2_wrong_size(%arg0: i4, %arg1: i4, %arg2: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ne" %arg1, %0 : i4 + %3 = "llvm.intr.smul.with.overflow"(%arg0, %arg2) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.select %4, %2, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @n3_wrong_pred(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i4 + %3 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.select %4, %2, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @n4_not_and(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i4 + %3 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.select %4, %1, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @n5_not_zero(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i4 + %3 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.select %4, %2, %1 : i1, i1 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/div-by-0-guard-before-umul_ov-not.ll.mlir b/test/LLVMDialect/InstCombine/div-by-0-guard-before-umul_ov-not.ll.mlir new file mode 100644 index 000000000..902acb2aa --- /dev/null +++ b/test/LLVMDialect/InstCombine/div-by-0-guard-before-umul_ov-not.ll.mlir @@ -0,0 +1,63 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_umul(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i4 + %3 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.xor %4, %1 : i1 + %6 = llvm.select %2, %1, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t1_commutative(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i4 + %3 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.xor %4, %1 : i1 + %6 = llvm.select %5, %1, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @n2_wrong_size(%arg0: i4, %arg1: i4, %arg2: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg1, %0 : i4 + %3 = "llvm.intr.umul.with.overflow"(%arg0, %arg2) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.xor %4, %1 : i1 + %6 = llvm.select %2, %1, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @n3_wrong_pred(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i4 + %3 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.xor %4, %1 : i1 + %6 = llvm.select %2, %1, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @n4_not_and(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "eq" %arg0, %0 : i4 + %4 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %5 = llvm.extractvalue %4[1] : !llvm.struct<(i4, i1)> + %6 = llvm.xor %5, %1 : i1 + %7 = llvm.select %3, %6, %2 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @n5_not_zero(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i4 + %3 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.xor %4, %1 : i1 + %6 = llvm.select %2, %1, %5 : i1, i1 + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/div-by-0-guard-before-umul_ov.ll.mlir b/test/LLVMDialect/InstCombine/div-by-0-guard-before-umul_ov.ll.mlir new file mode 100644 index 000000000..5babb3114 --- /dev/null +++ b/test/LLVMDialect/InstCombine/div-by-0-guard-before-umul_ov.ll.mlir @@ -0,0 +1,56 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_umul(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i4 + %3 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.select %4, %2, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t1_commutative(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i4 + %3 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.select %2, %4, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @n2_wrong_size(%arg0: i4, %arg1: i4, %arg2: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ne" %arg1, %0 : i4 + %3 = "llvm.intr.umul.with.overflow"(%arg0, %arg2) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.select %4, %2, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @n3_wrong_pred(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i4 + %3 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.select %4, %2, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @n4_not_and(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i4 + %3 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.select %4, %1, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @n5_not_zero(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i4 + %3 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i4, i4) -> !llvm.struct<(i4, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i4, i1)> + %5 = llvm.select %4, %2, %1 : i1, i1 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/div-i1.ll.mlir b/test/LLVMDialect/InstCombine/div-i1.ll.mlir new file mode 100644 index 000000000..93932744f --- /dev/null +++ b/test/LLVMDialect/InstCombine/div-i1.ll.mlir @@ -0,0 +1,84 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @sdiv_by_zero_indirect_is_poison(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.and %arg2, %0 : i1 + llvm.br ^bb3(%1 : i1) + ^bb2: // pred: ^bb0 + %2 = llvm.and %arg2, %0 : i1 + llvm.br ^bb3(%2 : i1) + ^bb3(%3: i1): // 2 preds: ^bb1, ^bb2 + %4 = llvm.sdiv %arg1, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @udiv_by_zero_indirect_is_poison(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.and %arg2, %0 : i1 + llvm.br ^bb3(%1 : i1) + ^bb2: // pred: ^bb0 + %2 = llvm.and %arg2, %0 : i1 + llvm.br ^bb3(%2 : i1) + ^bb3(%3: i1): // 2 preds: ^bb1, ^bb2 + %4 = llvm.udiv %arg1, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @srem_by_zero_indirect_is_poison(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.and %arg2, %0 : i1 + llvm.br ^bb3(%1 : i1) + ^bb2: // pred: ^bb0 + %2 = llvm.and %arg2, %0 : i1 + llvm.br ^bb3(%2 : i1) + ^bb3(%3: i1): // 2 preds: ^bb1, ^bb2 + %4 = llvm.srem %arg1, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @urem_by_zero_indirect_is_poison(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.and %arg2, %0 : i1 + llvm.br ^bb3(%1 : i1) + ^bb2: // pred: ^bb0 + %2 = llvm.and %arg2, %0 : i1 + llvm.br ^bb3(%2 : i1) + ^bb3(%3: i1): // 2 preds: ^bb1, ^bb2 + %4 = llvm.urem %arg1, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @sdiv_i1_is_op0(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.sdiv %arg0, %arg1 : i1 + llvm.return %0 : i1 + } + llvm.func @udiv_i1_is_op0(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.udiv %arg0, %arg1 : i1 + llvm.return %0 : i1 + } + llvm.func @srem_i1_is_zero(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.srem %arg0, %arg1 : i1 + llvm.return %0 : i1 + } + llvm.func @urem_i1_is_zero(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.urem %arg0, %arg1 : i1 + llvm.return %0 : i1 + } + llvm.func @pt62607() -> i1 { + %0 = llvm.mlir.constant(109 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.trunc %0 : i8 to i1 + llvm.br ^bb1(%1 : i1) + ^bb1(%4: i1): // 2 preds: ^bb0, ^bb1 + %5 = llvm.add %4, %2 : i1 + "llvm.intr.assume"(%5) : (i1) -> () + %6 = llvm.udiv %3, %4 : i1 + llvm.cond_br %6, ^bb1(%5 : i1), ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/div-shift-crash.ll.mlir b/test/LLVMDialect/InstCombine/div-shift-crash.ll.mlir new file mode 100644 index 000000000..6b7bbc33c --- /dev/null +++ b/test/LLVMDialect/InstCombine/div-shift-crash.ll.mlir @@ -0,0 +1,72 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "big">>} { + llvm.func @main(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1, %arg5: i1, %arg6: i1, %arg7: i1, %arg8: i1, %arg9: i1) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.constant(-701565022 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(-7 : i32) : i32 + %5 = llvm.mlir.constant(-1 : i32) : i32 + %6 = llvm.alloca %0 x !llvm.struct<"struct.S0.0.1.2.3.4.13.22.31.44.48.53.54.55.56.58.59.60.66.68.70.74.77.106.107.108.109.110.113.117.118.128.129", packed (i64)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb2, ^bb4 + llvm.cond_br %arg1, ^bb4, ^bb5 + ^bb4: // pred: ^bb3 + llvm.br ^bb3 + ^bb5: // pred: ^bb3 + llvm.cond_br %arg2, ^bb6, ^bb7 + ^bb6: // pred: ^bb5 + llvm.br ^bb7 + ^bb7: // 2 preds: ^bb5, ^bb6 + llvm.br ^bb8 + ^bb8: // 2 preds: ^bb7, ^bb9 + llvm.cond_br %arg3, ^bb9, ^bb10 + ^bb9: // pred: ^bb8 + llvm.br ^bb8 + ^bb10: // pred: ^bb8 + %7 = llvm.load %6 {alignment = 1 : i64} : !llvm.ptr -> i64 + llvm.br ^bb11 + ^bb11: // 2 preds: ^bb10, ^bb18 + llvm.cond_br %arg4, ^bb12(%1 : i32), ^bb19 + ^bb12(%8: i32): // 2 preds: ^bb11, ^bb15 + llvm.cond_br %arg5, ^bb13, ^bb16 + ^bb13: // 2 preds: ^bb12, ^bb14 + llvm.cond_br %arg6, ^bb14, ^bb15 + ^bb14: // pred: ^bb13 + llvm.br ^bb13 + ^bb15: // pred: ^bb13 + %9 = llvm.add %3, %5 overflow : i32 + llvm.br ^bb12(%9 : i32) + ^bb16: // pred: ^bb12 + %10 = llvm.trunc %7 : i64 to i32 + %11 = llvm.xor %8, %2 : i32 + %12 = llvm.sub %3, %8 overflow : i32 + %13 = llvm.xor %12, %8 : i32 + %14 = llvm.and %11, %13 : i32 + %15 = llvm.icmp "slt" %14, %3 : i32 + %16 = llvm.sub %2, %8 overflow : i32 + %17 = llvm.select %15, %2, %16 : i1, i32 + llvm.cond_br %arg7, ^bb18(%10 : i32), ^bb17 + ^bb17: // pred: ^bb16 + %18 = llvm.udiv %10, %17 : i32 + llvm.br ^bb18(%18 : i32) + ^bb18(%19: i32): // 2 preds: ^bb16, ^bb17 + %20 = llvm.icmp "ne" %19, %4 : i32 + llvm.br ^bb11 + ^bb19: // pred: ^bb11 + llvm.cond_br %arg8, ^bb20, ^bb21 + ^bb20: // pred: ^bb19 + llvm.unreachable + ^bb21: // pred: ^bb19 + llvm.br ^bb22 + ^bb22: // 2 preds: ^bb21, ^bb23 + llvm.cond_br %arg9, ^bb23, ^bb24 + ^bb23: // pred: ^bb22 + llvm.br ^bb22 + ^bb24: // pred: ^bb22 + llvm.unreachable + } +} diff --git a/test/LLVMDialect/InstCombine/div-shift.ll.mlir b/test/LLVMDialect/InstCombine/div-shift.ll.mlir new file mode 100644 index 000000000..8b103804f --- /dev/null +++ b/test/LLVMDialect/InstCombine/div-shift.ll.mlir @@ -0,0 +1,602 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @a() {addr_space = 0 : i32} : i32 + llvm.func @use(i8) + llvm.func @use32(i32) + llvm.func @t1(%arg0: i16 {llvm.zeroext}, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.sdiv %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @t1vec(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %2 = llvm.shl %0, %arg1 : vector<2xi32> + %3 = llvm.sdiv %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @t2(%arg0: i64, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.zext %1 : i32 to i64 + %3 = llvm.udiv %arg0, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @t3(%arg0: i64, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.zext %1 : i32 to i64 + %3 = llvm.udiv %arg0, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @t4(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %1, %2 : i1, i32 + %5 = llvm.udiv %arg0, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @t5(%arg0: i1, %arg1: i1, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(64 : i32) : i32 + %3 = llvm.shl %0, %arg2 : i32 + %4 = llvm.select %arg0, %1, %2 : i1, i32 + %5 = llvm.select %arg1, %4, %3 : i1, i32 + %6 = llvm.udiv %arg2, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @t6(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.select %2, %1, %arg0 : i1, i32 + %4 = llvm.udiv %arg1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @udiv_umin(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.shl %0, %arg2 : i8 + %3 = llvm.intr.umin(%1, %2) : (i8, i8) -> i8 + %4 = llvm.udiv %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @udiv_umax(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.shl %0, %arg2 : i8 + %3 = llvm.intr.umax(%1, %2) : (i8, i8) -> i8 + %4 = llvm.udiv %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @udiv_umin_(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.intr.umin(%1, %arg2) : (i8, i8) -> i8 + %3 = llvm.udiv %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @udiv_umin_extra_use(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.shl %0, %arg2 : i8 + %3 = llvm.intr.umin(%1, %2) : (i8, i8) -> i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.udiv %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @udiv_smin(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.shl %0, %arg2 : i8 + %3 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + %4 = llvm.udiv %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @udiv_smax(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.shl %0, %arg2 : i8 + %3 = llvm.intr.smax(%1, %2) : (i8, i8) -> i8 + %4 = llvm.udiv %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @t7(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.shl %arg0, %0 overflow : i32 + %2 = llvm.sdiv %1, %arg0 : i32 + llvm.return %2 : i32 + } + llvm.func @t8(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.shl %arg0, %0 : i32 + %2 = llvm.sdiv %1, %arg0 : i32 + llvm.return %2 : i32 + } + llvm.func @t9(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[2, 3]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.shl %arg0, %0 overflow : vector<2xi32> + %2 = llvm.sdiv %1, %arg0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @t10(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.sdiv %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @t11(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.shl %arg0, %arg1 overflow : vector<2xi32> + %1 = llvm.sdiv %0, %arg0 : vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @t12(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.shl %arg0, %0 overflow : i32 + %2 = llvm.udiv %1, %arg0 : i32 + llvm.return %2 : i32 + } + llvm.func @t13(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.shl %arg0, %0 : i32 + %2 = llvm.udiv %1, %arg0 : i32 + llvm.return %2 : i32 + } + llvm.func @t14(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[2, 3]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.shl %arg0, %0 overflow : vector<2xi32> + %2 = llvm.udiv %1, %arg0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @t15(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.udiv %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @t16(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.shl %arg0, %arg1 overflow : vector<2xi32> + %1 = llvm.udiv %0, %arg0 : vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @sdiv_mul_shl_nsw(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.mul %arg0, %arg1 overflow : i5 + %1 = llvm.shl %arg0, %arg2 overflow : i5 + %2 = llvm.sdiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @sdiv_mul_shl_nsw_exact_commute1(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.mul %arg1, %arg0 overflow : i5 + %1 = llvm.shl %arg0, %arg2 overflow : i5 + %2 = llvm.sdiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @sdiv_mul_shl_nsw_commute2(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.mul %arg1, %arg0 overflow : i5 + %1 = llvm.shl %arg2, %arg0 overflow : i5 + %2 = llvm.sdiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @sdiv_mul_shl_nsw_use1(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mul %arg0, %arg1 overflow : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.shl %arg0, %arg2 overflow : i8 + %2 = llvm.sdiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sdiv_mul_shl_nsw_use2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mul %arg0, %arg1 overflow : i8 + %1 = llvm.shl %arg0, %arg2 overflow : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.sdiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sdiv_mul_shl_nsw_use3(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mul %arg0, %arg1 overflow : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.shl %arg0, %arg2 overflow : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.sdiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sdiv_shl_mul_nsw(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.shl %arg2, %arg0 overflow : i5 + %1 = llvm.mul %arg0, %arg1 overflow : i5 + %2 = llvm.sdiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @sdiv_mul_shl_missing_nsw1(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.mul %arg0, %arg1 overflow : i5 + %1 = llvm.shl %arg1, %arg2 overflow : i5 + %2 = llvm.sdiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @sdiv_mul_shl_missing_nsw2(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.mul %arg0, %arg1 overflow : i5 + %1 = llvm.shl %arg1, %arg2 overflow : i5 + %2 = llvm.sdiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @udiv_mul_shl_nuw(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.mul %arg0, %arg1 overflow : i5 + %1 = llvm.shl %arg0, %arg2 overflow : i5 + %2 = llvm.udiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @udiv_mul_shl_nuw_exact_commute1(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.mul %arg1, %arg0 overflow : i5 + %1 = llvm.shl %arg0, %arg2 overflow : i5 + %2 = llvm.udiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @udiv_mul_shl_nuw_commute2(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.mul %arg0, %arg1 overflow : i5 + %1 = llvm.shl %arg2, %arg0 overflow : i5 + %2 = llvm.udiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @udiv_mul_shl_nsw_use1(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mul %arg0, %arg1 overflow : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.shl %arg0, %arg2 overflow : i8 + %2 = llvm.udiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_mul_shl_nsw_use2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mul %arg0, %arg1 overflow : i8 + %1 = llvm.shl %arg0, %arg2 overflow : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.udiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_mul_shl_nsw_use3(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mul %arg0, %arg1 overflow : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.shl %arg0, %arg2 overflow : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.udiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_shl_mul_nuw(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.shl %arg0, %arg2 overflow : i5 + %1 = llvm.mul %arg0, %arg1 overflow : i5 + %2 = llvm.udiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @udiv_shl_mul_nuw_swap(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.shl %arg0, %arg2 overflow : i5 + %1 = llvm.mul %arg1, %arg0 overflow : i5 + %2 = llvm.udiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @udiv_shl_mul_nuw_exact(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.shl %arg0, %arg2 overflow : i5 + %1 = llvm.mul %arg0, %arg1 overflow : i5 + %2 = llvm.udiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @udiv_shl_mul_nuw_vec(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.shl %arg0, %arg2 overflow : vector<2xi4> + %1 = llvm.mul %arg1, %arg0 overflow : vector<2xi4> + %2 = llvm.udiv %0, %1 : vector<2xi4> + llvm.return %2 : vector<2xi4> + } + llvm.func @udiv_shl_mul_nuw_extra_use_of_shl(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.mul %arg1, %arg0 overflow : i8 + %2 = llvm.udiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_shl_mul_nuw_extra_use_of_mul(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + %1 = llvm.mul %arg1, %arg0 overflow : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.udiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_shl_mul_nuw_extra_use(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.mul %arg1, %arg0 overflow : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.udiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sdiv_shl_mul_nuw(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.shl %arg0, %arg2 overflow : i5 + %1 = llvm.mul %arg0, %arg1 overflow : i5 + %2 = llvm.sdiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @udiv_mul_shl_missing_nsw1(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.mul %arg0, %arg1 overflow : i5 + %1 = llvm.shl %arg1, %arg2 overflow : i5 + %2 = llvm.udiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @udiv_mul_shl_missing_nsw2(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.mul %arg0, %arg1 overflow : i5 + %1 = llvm.shl %arg1, %arg2 overflow : i5 + %2 = llvm.udiv %0, %1 : i5 + llvm.return %2 : i5 + } + llvm.func @udiv_shl_nuw(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg1, %arg2 overflow : i8 + %1 = llvm.udiv %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @udiv_shl_nuw_exact(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.shl %arg1, %arg2 overflow : vector<2xi4> + %1 = llvm.udiv %arg0, %0 : vector<2xi4> + llvm.return %1 : vector<2xi4> + } + llvm.func @udiv_shl(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg1, %arg2 : i8 + %1 = llvm.udiv %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @udiv_shl_nuw_use(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg1, %arg2 overflow : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.udiv %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @udiv_lshr_mul_nuw(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mul %arg0, %arg1 overflow : i8 + %1 = llvm.lshr %0, %arg2 : i8 + %2 = llvm.udiv %1, %arg0 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_lshr_mul_nuw_exact_commute1(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mul %arg1, %arg0 overflow : vector<2xi4> + %1 = llvm.lshr %0, %arg2 : vector<2xi4> + %2 = llvm.udiv %1, %arg0 : vector<2xi4> + llvm.return %2 : vector<2xi4> + } + llvm.func @udiv_lshr_mul_nuw_commute2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mul %arg1, %arg0 overflow : i8 + %1 = llvm.lshr %arg2, %0 : i8 + %2 = llvm.udiv %1, %arg0 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_lshr_mul_nuw_use1(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mul %arg0, %arg1 overflow : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.lshr %0, %arg2 : i8 + %2 = llvm.udiv %1, %arg0 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_lshr_mul_nuw_use2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mul %arg0, %arg1 overflow : i8 + %1 = llvm.lshr %0, %arg2 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.udiv %1, %arg0 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_lshr_mul_nuw_use3(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mul %arg0, %arg1 overflow : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.lshr %0, %arg2 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.udiv %1, %arg0 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_lshr_mul_nsw(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mul %arg0, %arg1 overflow : i8 + %1 = llvm.lshr %0, %arg2 : i8 + %2 = llvm.udiv %1, %arg0 : i8 + llvm.return %2 : i8 + } + llvm.func @sdiv_lshr_mul_nsw(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mul %arg0, %arg1 overflow : i8 + %1 = llvm.lshr %0, %arg2 : i8 + %2 = llvm.sdiv %1, %arg0 : i8 + llvm.return %2 : i8 + } + llvm.func @sdiv_shl_shl_nsw2_nuw(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + %1 = llvm.shl %arg1, %arg2 overflow : i8 + %2 = llvm.sdiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sdiv_shl_shl_nsw2_nuw_exact_use(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.shl %arg1, %arg2 overflow : i8 + %2 = llvm.sdiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sdiv_shl_shl_nsw_nuw2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + %1 = llvm.shl %arg1, %arg2 overflow : i8 + %2 = llvm.sdiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sdiv_shl_shl_nsw_nuw(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + %1 = llvm.shl %arg1, %arg2 overflow : i8 + %2 = llvm.sdiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sdiv_shl_shl_nuw_nsw2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + %1 = llvm.shl %arg1, %arg2 overflow : i8 + %2 = llvm.sdiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_shl_shl_nuw2(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.shl %arg0, %arg2 overflow : vector<2xi8> + %1 = llvm.shl %arg1, %arg2 overflow : vector<2xi8> + %2 = llvm.udiv %0, %1 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @udiv_shl_shl_nuw2_exact_use2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.shl %arg1, %arg2 overflow : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.udiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_shl_shl_nuw_nsw(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + %1 = llvm.shl %arg1, %arg2 overflow : i8 + %2 = llvm.udiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_shl_shl_nsw_nuw(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + %1 = llvm.shl %arg1, %arg2 overflow : i8 + %2 = llvm.udiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_shl_shl_nuw_nsw2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + %1 = llvm.shl %arg1, %arg2 overflow : i8 + %2 = llvm.udiv %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @udiv_shl_nuw_divisor(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg1, %arg2 overflow : i8 + %1 = llvm.udiv %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @udiv_fail_shl_overflow(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.intr.umax(%2, %1) : (i8, i8) -> i8 + %4 = llvm.udiv %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @udiv_shl_no_overflow(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.shl %0, %arg1 overflow : i8 + %3 = llvm.intr.umax(%2, %1) : (i8, i8) -> i8 + %4 = llvm.udiv %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @sdiv_shl_pair_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.shl %arg0, %0 overflow : i32 + %3 = llvm.shl %arg0, %1 overflow : i32 + %4 = llvm.sdiv %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @udiv_shl_pair_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.shl %arg0, %0 overflow : i32 + %3 = llvm.shl %arg0, %1 overflow : i32 + %4 = llvm.udiv %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @sdiv_shl_pair1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.shl %arg0, %arg2 overflow : i32 + %2 = llvm.sdiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @sdiv_shl_pair2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.shl %arg0, %arg2 overflow : i32 + %2 = llvm.sdiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @sdiv_shl_pair3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.shl %arg0, %arg2 overflow : i32 + %2 = llvm.sdiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @sdiv_shl_no_pair_fail(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.shl %arg0, %arg2 overflow : i32 + %1 = llvm.shl %arg1, %arg3 overflow : i32 + %2 = llvm.sdiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @udiv_shl_pair1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.shl %arg0, %arg2 overflow : i32 + %2 = llvm.udiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @udiv_shl_pair2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.shl %arg0, %arg2 overflow : i32 + %2 = llvm.udiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @udiv_shl_pair3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.shl %arg0, %arg2 overflow : i32 + %2 = llvm.udiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @sdiv_shl_pair_overflow_fail1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.shl %arg0, %arg2 overflow : i32 + %2 = llvm.sdiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @sdiv_shl_pair_overflow_fail2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.shl %arg0, %arg2 overflow : i32 + %2 = llvm.sdiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @udiv_shl_pair_overflow_fail1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.shl %arg0, %arg2 overflow : i32 + %2 = llvm.udiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @udiv_shl_pair_overflow_fail2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.shl %arg0, %arg2 : i32 + %2 = llvm.udiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @udiv_shl_pair_overflow_fail3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.shl %arg0, %arg2 : i32 + %2 = llvm.udiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @sdiv_shl_pair_multiuse1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + llvm.call @use32(%0) : (i32) -> () + %1 = llvm.shl %arg0, %arg2 overflow : i32 + %2 = llvm.sdiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @sdiv_shl_pair_multiuse2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.shl %arg0, %arg2 overflow : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.sdiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @sdiv_shl_pair_multiuse3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.shl %arg0, %arg2 overflow : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.sdiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @pr69291() -> i32 { + %0 = llvm.mlir.addressof @a : !llvm.ptr + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.load %0 {alignment = 1 : i64} : !llvm.ptr -> i32 + %3 = llvm.shl %2, %1 overflow : i32 + %4 = llvm.shl %2, %1 overflow : i32 + %5 = llvm.sdiv %3, %4 : i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/div.ll.mlir b/test/LLVMDialect/InstCombine/div.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/dont-distribute-phi.ll.mlir b/test/LLVMDialect/InstCombine/dont-distribute-phi.ll.mlir new file mode 100644 index 000000000..2281b6117 --- /dev/null +++ b/test/LLVMDialect/InstCombine/dont-distribute-phi.ll.mlir @@ -0,0 +1,40 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant(37 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + %2 = llvm.mlir.undef : i1 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.icmp "eq" %arg0, %0 : i32 + llvm.cond_br %4, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @bar() : () -> () + llvm.br ^bb3(%2 : i1) + ^bb2: // pred: ^bb0 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + llvm.br ^bb3(%5 : i1) + ^bb3(%6: i1): // 2 preds: ^bb1, ^bb2 + %7 = llvm.xor %4, %3 : i1 + %8 = llvm.and %6, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo_logical(%arg0: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant(37 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + %2 = llvm.mlir.undef : i1 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.icmp "eq" %arg0, %0 : i32 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @bar() : () -> () + llvm.br ^bb3(%2 : i1) + ^bb2: // pred: ^bb0 + %6 = llvm.icmp "slt" %arg0, %1 : i32 + llvm.br ^bb3(%6 : i1) + ^bb3(%7: i1): // 2 preds: ^bb1, ^bb2 + %8 = llvm.xor %5, %3 : i1 + %9 = llvm.select %7, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @bar() +} diff --git a/test/LLVMDialect/InstCombine/double-float-shrink-1.ll.mlir b/test/LLVMDialect/InstCombine/double-float-shrink-1.ll.mlir index f3103c4b9..a5e0b334c 100644 --- a/test/LLVMDialect/InstCombine/double-float-shrink-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/double-float-shrink-1.ll.mlir @@ -1,340 +1,271 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @acos, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "acos_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @acos, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "acos_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @acosh, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "acosh_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @acosh, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "acosh_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @asin, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "asin_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @asin, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "asin_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @asinh, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "asinh_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @asinh, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "asinh_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @atan, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "atan_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @atan, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "atan_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @atanh, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "atanh_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @atanh, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "atanh_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @cbrt, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "cbrt_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @cbrt, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "cbrt_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @exp, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "exp_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @exp, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @expm1, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "expm1_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @expm1, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "expm1_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @exp10, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "exp10_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @exp10, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp10_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @log, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "log_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @log, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "log_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @log10, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "log10_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @log10, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "log10_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @log1p, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "log1p_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @log1p, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "log1p_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @log2, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "log2_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @log2, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "log2_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @logb, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "logb_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @logb, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "logb_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.fpext"(%arg1) : (f32) -> f64 - %2 = "llvm.call"(%0, %1) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %3 = "llvm.fptrunc"(%2) : (f64) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "pow_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.fpext"(%arg1) : (f32) -> f64 - %2 = "llvm.call"(%0, %1) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @sin, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "sin_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @sin, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "sin_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @sqrt, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @sqrt, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_int_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_int_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @tan, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "tan_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @tan, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "tan_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @tanh, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "tanh_test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @tanh, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "tanh_test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.fpext"(%arg1) : (f32) -> f64 - %2 = "llvm.call"(%0, %1) {callee = @fmax, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %3 = "llvm.fptrunc"(%2) : (f64) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "max1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f128 - %1 = "llvm.fpext"(%arg1) : (f32) -> f128 - %2 = "llvm.call"(%0, %1) {callee = @fmin, fastmathFlags = #llvm.fastmath<>} : (f128, f128) -> f128 - %3 = "llvm.fptrunc"(%2) : (f128) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fake_fmin", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fmin", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fmax", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "tanh", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "tan", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sqrt", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.sqrt.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sin", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "pow", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "log2", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "log1p", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "log10", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "log", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "logb", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp10", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "expm1", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "cbrt", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atanh", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atan", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "acos", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "acosh", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "asin", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "asinh", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @acos_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @acos(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @acos_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @acos(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @acosh_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @acosh(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @acosh_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @acosh(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @asin_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @asin(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @asin_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @asin(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @asinh_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @asinh(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @asinh_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @asinh(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @atan_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @atan(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @atan_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @atan(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @atanh_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @atanh(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @atanh_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @atanh(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @cbrt_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @cbrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @cbrt_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @cbrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @exp_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @exp(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @exp_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @exp(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @expm1_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @expm1(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @expm1_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @expm1(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @exp10_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @exp10(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @exp10_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @exp10(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @log_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @log(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @log_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @log(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @log10_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @log10(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @log10_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @log10(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @log1p_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @log1p(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @log1p_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @log1p(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @log2_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @log2(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @log2_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @log2(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @logb_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @logb(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @logb_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @logb(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_test1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @pow_test2(%arg0: f32, %arg1: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @sin_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @sin(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @sin_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @sin(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sqrt_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @sqrt(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @sqrt_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @sqrt(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sqrt_int_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.sqrt(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @sqrt_int_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.sqrt(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @tan_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @tan(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @tan_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @tan(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @tanh_test1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @tanh(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @tanh_test2(%arg0: f32) -> f64 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @tanh(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @max1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @fmax(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @fake_fmin(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f128 + %1 = llvm.fpext %arg1 : f32 to f128 + %2 = llvm.call @fmin(%0, %1) : (f128, f128) -> f128 + %3 = llvm.fptrunc %2 : f128 to f32 + llvm.return %3 : f32 + } + llvm.func @fmin(f128, f128) -> f128 + llvm.func @fmax(f64, f64) -> f64 + llvm.func @tanh(f64) -> f64 + llvm.func @tan(f64) -> f64 + llvm.func @sqrt(f64) -> f64 + llvm.func @sin(f64) -> f64 + llvm.func @pow(f64, f64) -> f64 + llvm.func @log2(f64) -> f64 + llvm.func @log1p(f64) -> f64 + llvm.func @log10(f64) -> f64 + llvm.func @log(f64) -> f64 + llvm.func @logb(f64) -> f64 + llvm.func @exp10(f64) -> f64 + llvm.func @expm1(f64) -> f64 + llvm.func @exp(f64) -> f64 + llvm.func @cbrt(f64) -> f64 + llvm.func @atanh(f64) -> f64 + llvm.func @atan(f64) -> f64 + llvm.func @acos(f64) -> f64 + llvm.func @acosh(f64) -> f64 + llvm.func @asin(f64) -> f64 + llvm.func @asinh(f64) -> f64 +} diff --git a/test/LLVMDialect/InstCombine/double-float-shrink-2.ll.mlir b/test/LLVMDialect/InstCombine/double-float-shrink-2.ll.mlir index ff3581c6c..d28226500 100644 --- a/test/LLVMDialect/InstCombine/double-float-shrink-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/double-float-shrink-2.ll.mlir @@ -1,453 +1,360 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "floor", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "ceil", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "round", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "roundeven", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "nearbyint", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "trunc", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fabs", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ceil.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ceil.v2f64", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.fabs.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.fabs.v2f64", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.floor.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.floor.v2f64", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.nearbyint.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.nearbyint.v2f64", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.rint.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.rint.v2f32", type = !llvm.func (vector<2xf32>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.round.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.round.v2f64", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.roundeven.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.roundeven.v2f64", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.trunc.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.trunc.v2f64", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @floor, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_libcall_floor", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @ceil, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_libcall_ceil", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @round, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_libcall_round", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @roundeven, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_libcall_roundeven", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @nearbyint, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_libcall_nearbyint", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @trunc, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_libcall_trunc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @fabs, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_libcall_fabs", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @fabs, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_libcall_fabs_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.ceil.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_ceil", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_fabs", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.floor.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_floor", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.nearbyint.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_nearbyint", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f16): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f16) -> f32 - %1 = "llvm.call"(%0) {callee = @llvm.rint.f32, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %2 = "llvm.fptrunc"(%1) : (f32) -> f16 - "llvm.return"(%2) : (f16) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_rint", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.round.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_round", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.roundeven.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_roundeven", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.trunc.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_trunc", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use_v2f64", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use_v2f32", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>): // no predecessors - %0 = "llvm.fpext"(%arg0) : (vector<2xf32>) -> vector<2xf64> - %1 = "llvm.call"(%0) {callee = @llvm.ceil.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> vector<2xf64> - %2 = "llvm.fptrunc"(%1) : (vector<2xf64>) -> vector<2xf32> - "llvm.call"(%0) {callee = @use_v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> () - "llvm.return"(%2) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_ceil_multi_use", type = !llvm.func (vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>): // no predecessors - %0 = "llvm.fpext"(%arg0) : (vector<2xf32>) -> vector<2xf64> - %1 = "llvm.call"(%0) {callee = @llvm.fabs.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> vector<2xf64> - %2 = "llvm.fptrunc"(%1) : (vector<2xf64>) -> vector<2xf32> - "llvm.call"(%1) {callee = @use_v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> () - "llvm.return"(%2) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_fabs_multi_use", type = !llvm.func (vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>): // no predecessors - %0 = "llvm.fpext"(%arg0) : (vector<2xf32>) -> vector<2xf64> - %1 = "llvm.call"(%0) {callee = @llvm.floor.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> vector<2xf64> - %2 = "llvm.fptrunc"(%1) : (vector<2xf64>) -> vector<2xf32> - "llvm.call"(%0) {callee = @use_v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> () - "llvm.call"(%1) {callee = @use_v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> () - "llvm.return"(%2) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_floor_multi_use", type = !llvm.func (vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>): // no predecessors - %0 = "llvm.fpext"(%arg0) : (vector<2xf32>) -> vector<2xf64> - %1 = "llvm.call"(%0) {callee = @llvm.nearbyint.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> vector<2xf64> - %2 = "llvm.fptrunc"(%1) : (vector<2xf64>) -> vector<2xf32> - "llvm.call"(%0) {callee = @use_v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> () - "llvm.return"(%2) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_nearbyint_multi_use", type = !llvm.func (vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf16>): // no predecessors - %0 = "llvm.fpext"(%arg0) : (vector<2xf16>) -> vector<2xf32> - %1 = "llvm.call"(%0) {callee = @llvm.rint.v2f32, fastmathFlags = #llvm.fastmath<>} : (vector<2xf32>) -> vector<2xf32> - %2 = "llvm.fptrunc"(%1) : (vector<2xf32>) -> vector<2xf16> - "llvm.call"(%1) {callee = @use_v2f32, fastmathFlags = #llvm.fastmath<>} : (vector<2xf32>) -> () - "llvm.return"(%2) : (vector<2xf16>) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_rint_multi_use", type = !llvm.func (vector<2xf16>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>): // no predecessors - %0 = "llvm.fpext"(%arg0) : (vector<2xf32>) -> vector<2xf64> - %1 = "llvm.call"(%0) {callee = @llvm.round.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> vector<2xf64> - %2 = "llvm.fptrunc"(%1) : (vector<2xf64>) -> vector<2xf32> - "llvm.call"(%0) {callee = @use_v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> () - "llvm.call"(%1) {callee = @use_v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> () - "llvm.return"(%2) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_round_multi_use", type = !llvm.func (vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>): // no predecessors - %0 = "llvm.fpext"(%arg0) : (vector<2xf32>) -> vector<2xf64> - %1 = "llvm.call"(%0) {callee = @llvm.roundeven.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> vector<2xf64> - %2 = "llvm.fptrunc"(%1) : (vector<2xf64>) -> vector<2xf32> - "llvm.call"(%0) {callee = @use_v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> () - "llvm.call"(%1) {callee = @use_v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> () - "llvm.return"(%2) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_roundeven_multi_use", type = !llvm.func (vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>): // no predecessors - %0 = "llvm.fpext"(%arg0) : (vector<2xf32>) -> vector<2xf64> - %1 = "llvm.call"(%0) {callee = @llvm.trunc.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> vector<2xf64> - %2 = "llvm.fptrunc"(%1) : (vector<2xf64>) -> vector<2xf32> - "llvm.call"(%0) {callee = @use_v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> () - "llvm.return"(%2) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_trunc_multi_use", type = !llvm.func (vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_fabs_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.floor.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_no_shrink_intrin_floor", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.ceil.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_no_shrink_intrin_ceil", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.round.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_no_shrink_intrin_round", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.roundeven.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_no_shrink_intrin_roundeven", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.nearbyint.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_no_shrink_intrin_nearbyint", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.trunc.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_no_shrink_intrin_trunc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_fabs_double_src", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_fabs_fast_double_src", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 2.100000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.floor.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_float_convertible_constant_intrin_floor", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 2.100000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.ceil.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_float_convertible_constant_intrin_ceil", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 2.100000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.round.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_float_convertible_constant_intrin_round", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 2.100000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.roundeven.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_float_convertible_constant_intrin_roundeven", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 2.100000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.nearbyint.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_float_convertible_constant_intrin_nearbyint", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 2.100000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.trunc.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_float_convertible_constant_intrin_trunc", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 2.100000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_float_convertible_constant_intrin_fabs", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 2.100000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_float_convertible_constant_intrin_fabs_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.floor.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f16 - "llvm.return"(%1) : (f16) -> () - }) {linkage = 10 : i64, sym_name = "test_no_shrink_mismatched_type_intrin_floor", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.ceil.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f16 - "llvm.return"(%1) : (f16) -> () - }) {linkage = 10 : i64, sym_name = "test_no_shrink_mismatched_type_intrin_ceil", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.round.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f16 - "llvm.return"(%1) : (f16) -> () - }) {linkage = 10 : i64, sym_name = "test_no_shrink_mismatched_type_intrin_round", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.roundeven.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f16 - "llvm.return"(%1) : (f16) -> () - }) {linkage = 10 : i64, sym_name = "test_no_shrink_mismatched_type_intrin_roundeven", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.nearbyint.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f16 - "llvm.return"(%1) : (f16) -> () - }) {linkage = 10 : i64, sym_name = "test_no_shrink_mismatched_type_intrin_nearbyint", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.trunc.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f16 - "llvm.return"(%1) : (f16) -> () - }) {linkage = 10 : i64, sym_name = "test_no_shrink_mismatched_type_intrin_trunc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f16 - "llvm.return"(%1) : (f16) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_mismatched_type_intrin_fabs_double_src", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fptrunc"(%0) : (f64) -> f16 - "llvm.return"(%1) : (f16) -> () - }) {linkage = 10 : i64, sym_name = "test_mismatched_type_intrin_fabs_fast_double_src", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf16>): // no predecessors - %0 = "llvm.fpext"(%arg0) : (vector<2xf16>) -> vector<2xf64> - %1 = "llvm.call"(%0) {callee = @llvm.floor.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> vector<2xf64> - "llvm.return"(%1) : (vector<2xf64>) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_floor_fp16_vec", type = !llvm.func (vector<2xf16>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f16): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f16) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.ceil.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_ceil_fp16_src", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf16>): // no predecessors - %0 = "llvm.fpext"(%arg0) : (vector<2xf16>) -> vector<2xf64> - %1 = "llvm.call"(%0) {callee = @llvm.round.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> vector<2xf64> - "llvm.return"(%1) : (vector<2xf64>) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_round_fp16_vec", type = !llvm.func (vector<2xf16>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf16>): // no predecessors - %0 = "llvm.fpext"(%arg0) : (vector<2xf16>) -> vector<2xf64> - %1 = "llvm.call"(%0) {callee = @llvm.roundeven.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> vector<2xf64> - "llvm.return"(%1) : (vector<2xf64>) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_roundeven_fp16_vec", type = !llvm.func (vector<2xf16>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f16): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f16) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.nearbyint.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_nearbyint_fp16_src", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf16>): // no predecessors - %0 = "llvm.fpext"(%arg0) : (vector<2xf16>) -> vector<2xf64> - %1 = "llvm.call"(%0) {callee = @llvm.trunc.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> vector<2xf64> - "llvm.return"(%1) : (vector<2xf64>) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_trunc_fp16_src", type = !llvm.func (vector<2xf16>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f16): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f16) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_fabs_fp16_src", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f16): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f16) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_shrink_intrin_fabs_fast_fp16_src", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f16): // no predecessors - %0 = "llvm.mlir.undef"() : () -> !llvm.ptr - %1 = "llvm.fpext"(%arg0) : (f16) -> f64 - "llvm.store"(%1, %0) : (f64, !llvm.ptr) -> () - %2 = "llvm.call"(%1) {callee = @llvm.floor.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %3 = "llvm.fptrunc"(%2) : (f64) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_no_shrink_intrin_floor_multi_use_fpext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f16): // no predecessors - %0 = "llvm.mlir.undef"() : () -> !llvm.ptr - %1 = "llvm.fpext"(%arg0) : (f16) -> f64 - "llvm.store"(%1, %0) : (f64, !llvm.ptr) -> () - %2 = "llvm.call"(%1) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %3 = "llvm.fptrunc"(%2) : (f64) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_no_shrink_intrin_fabs_multi_use_fpext", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @floor(f64) -> f64 + llvm.func @ceil(f64) -> f64 + llvm.func @round(f64) -> f64 + llvm.func @roundeven(f64) -> f64 + llvm.func @nearbyint(f64) -> f64 + llvm.func @trunc(f64) -> f64 + llvm.func @fabs(f64) -> f64 + llvm.func @test_shrink_libcall_floor(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @floor(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_libcall_ceil(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @ceil(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_libcall_round(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @round(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_libcall_roundeven(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @roundeven(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_libcall_nearbyint(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @nearbyint(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_libcall_trunc(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @trunc(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_libcall_fabs(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @fabs(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_libcall_fabs_fast(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @fabs(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_intrin_ceil(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.ceil(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_intrin_fabs(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.fabs(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_intrin_floor(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.floor(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_intrin_nearbyint(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.nearbyint(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_intrin_rint(%arg0: f16) -> f16 { + %0 = llvm.fpext %arg0 : f16 to f32 + %1 = llvm.intr.rint(%0) : (f32) -> f32 + %2 = llvm.fptrunc %1 : f32 to f16 + llvm.return %2 : f16 + } + llvm.func @test_shrink_intrin_round(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.round(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_intrin_roundeven(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.roundeven(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_intrin_trunc(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.trunc(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @use_v2f64(vector<2xf64>) + llvm.func @use_v2f32(vector<2xf32>) + llvm.func @test_shrink_intrin_ceil_multi_use(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %1 = llvm.intr.ceil(%0) : (vector<2xf64>) -> vector<2xf64> + %2 = llvm.fptrunc %1 : vector<2xf64> to vector<2xf32> + llvm.call @use_v2f64(%0) : (vector<2xf64>) -> () + llvm.return %2 : vector<2xf32> + } + llvm.func @test_shrink_intrin_fabs_multi_use(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %1 = llvm.intr.fabs(%0) : (vector<2xf64>) -> vector<2xf64> + %2 = llvm.fptrunc %1 : vector<2xf64> to vector<2xf32> + llvm.call @use_v2f64(%1) : (vector<2xf64>) -> () + llvm.return %2 : vector<2xf32> + } + llvm.func @test_shrink_intrin_floor_multi_use(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %1 = llvm.intr.floor(%0) : (vector<2xf64>) -> vector<2xf64> + %2 = llvm.fptrunc %1 : vector<2xf64> to vector<2xf32> + llvm.call @use_v2f64(%0) : (vector<2xf64>) -> () + llvm.call @use_v2f64(%1) : (vector<2xf64>) -> () + llvm.return %2 : vector<2xf32> + } + llvm.func @test_shrink_intrin_nearbyint_multi_use(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %1 = llvm.intr.nearbyint(%0) : (vector<2xf64>) -> vector<2xf64> + %2 = llvm.fptrunc %1 : vector<2xf64> to vector<2xf32> + llvm.call @use_v2f64(%0) : (vector<2xf64>) -> () + llvm.return %2 : vector<2xf32> + } + llvm.func @test_shrink_intrin_rint_multi_use(%arg0: vector<2xf16>) -> vector<2xf16> { + %0 = llvm.fpext %arg0 : vector<2xf16> to vector<2xf32> + %1 = llvm.intr.rint(%0) : (vector<2xf32>) -> vector<2xf32> + %2 = llvm.fptrunc %1 : vector<2xf32> to vector<2xf16> + llvm.call @use_v2f32(%1) : (vector<2xf32>) -> () + llvm.return %2 : vector<2xf16> + } + llvm.func @test_shrink_intrin_round_multi_use(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %1 = llvm.intr.round(%0) : (vector<2xf64>) -> vector<2xf64> + %2 = llvm.fptrunc %1 : vector<2xf64> to vector<2xf32> + llvm.call @use_v2f64(%0) : (vector<2xf64>) -> () + llvm.call @use_v2f64(%1) : (vector<2xf64>) -> () + llvm.return %2 : vector<2xf32> + } + llvm.func @test_shrink_intrin_roundeven_multi_use(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %1 = llvm.intr.roundeven(%0) : (vector<2xf64>) -> vector<2xf64> + %2 = llvm.fptrunc %1 : vector<2xf64> to vector<2xf32> + llvm.call @use_v2f64(%0) : (vector<2xf64>) -> () + llvm.call @use_v2f64(%1) : (vector<2xf64>) -> () + llvm.return %2 : vector<2xf32> + } + llvm.func @test_shrink_intrin_trunc_multi_use(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %1 = llvm.intr.trunc(%0) : (vector<2xf64>) -> vector<2xf64> + %2 = llvm.fptrunc %1 : vector<2xf64> to vector<2xf32> + llvm.call @use_v2f64(%0) : (vector<2xf64>) -> () + llvm.return %2 : vector<2xf32> + } + llvm.func @test_shrink_intrin_fabs_fast(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_no_shrink_intrin_floor(%arg0: f64) -> f32 { + %0 = llvm.intr.floor(%arg0) : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f32 + llvm.return %1 : f32 + } + llvm.func @test_no_shrink_intrin_ceil(%arg0: f64) -> f32 { + %0 = llvm.intr.ceil(%arg0) : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f32 + llvm.return %1 : f32 + } + llvm.func @test_no_shrink_intrin_round(%arg0: f64) -> f32 { + %0 = llvm.intr.round(%arg0) : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f32 + llvm.return %1 : f32 + } + llvm.func @test_no_shrink_intrin_roundeven(%arg0: f64) -> f32 { + %0 = llvm.intr.roundeven(%arg0) : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f32 + llvm.return %1 : f32 + } + llvm.func @test_no_shrink_intrin_nearbyint(%arg0: f64) -> f32 { + %0 = llvm.intr.nearbyint(%arg0) : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f32 + llvm.return %1 : f32 + } + llvm.func @test_no_shrink_intrin_trunc(%arg0: f64) -> f32 { + %0 = llvm.intr.trunc(%arg0) : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f32 + llvm.return %1 : f32 + } + llvm.func @test_shrink_intrin_fabs_double_src(%arg0: f64) -> f32 { + %0 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f32 + llvm.return %1 : f32 + } + llvm.func @test_shrink_intrin_fabs_fast_double_src(%arg0: f64) -> f32 { + %0 = llvm.intr.fabs(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f32 + llvm.return %1 : f32 + } + llvm.func @test_shrink_float_convertible_constant_intrin_floor() -> f32 { + %0 = llvm.mlir.constant(2.100000e+00 : f64) : f64 + %1 = llvm.intr.floor(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_float_convertible_constant_intrin_ceil() -> f32 { + %0 = llvm.mlir.constant(2.100000e+00 : f64) : f64 + %1 = llvm.intr.ceil(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_float_convertible_constant_intrin_round() -> f32 { + %0 = llvm.mlir.constant(2.100000e+00 : f64) : f64 + %1 = llvm.intr.round(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_float_convertible_constant_intrin_roundeven() -> f32 { + %0 = llvm.mlir.constant(2.100000e+00 : f64) : f64 + %1 = llvm.intr.roundeven(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_float_convertible_constant_intrin_nearbyint() -> f32 { + %0 = llvm.mlir.constant(2.100000e+00 : f64) : f64 + %1 = llvm.intr.nearbyint(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_float_convertible_constant_intrin_trunc() -> f32 { + %0 = llvm.mlir.constant(2.100000e+00 : f64) : f64 + %1 = llvm.intr.trunc(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_float_convertible_constant_intrin_fabs() -> f32 { + %0 = llvm.mlir.constant(2.100000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_float_convertible_constant_intrin_fabs_fast() -> f32 { + %0 = llvm.mlir.constant(2.100000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_no_shrink_mismatched_type_intrin_floor(%arg0: f64) -> f16 { + %0 = llvm.intr.floor(%arg0) : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f16 + llvm.return %1 : f16 + } + llvm.func @test_no_shrink_mismatched_type_intrin_ceil(%arg0: f64) -> f16 { + %0 = llvm.intr.ceil(%arg0) : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f16 + llvm.return %1 : f16 + } + llvm.func @test_no_shrink_mismatched_type_intrin_round(%arg0: f64) -> f16 { + %0 = llvm.intr.round(%arg0) : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f16 + llvm.return %1 : f16 + } + llvm.func @test_no_shrink_mismatched_type_intrin_roundeven(%arg0: f64) -> f16 { + %0 = llvm.intr.roundeven(%arg0) : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f16 + llvm.return %1 : f16 + } + llvm.func @test_no_shrink_mismatched_type_intrin_nearbyint(%arg0: f64) -> f16 { + %0 = llvm.intr.nearbyint(%arg0) : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f16 + llvm.return %1 : f16 + } + llvm.func @test_no_shrink_mismatched_type_intrin_trunc(%arg0: f64) -> f16 { + %0 = llvm.intr.trunc(%arg0) : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f16 + llvm.return %1 : f16 + } + llvm.func @test_shrink_mismatched_type_intrin_fabs_double_src(%arg0: f64) -> f16 { + %0 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f16 + llvm.return %1 : f16 + } + llvm.func @test_mismatched_type_intrin_fabs_fast_double_src(%arg0: f64) -> f16 { + %0 = llvm.intr.fabs(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.fptrunc %0 : f64 to f16 + llvm.return %1 : f16 + } + llvm.func @test_shrink_intrin_floor_fp16_vec(%arg0: vector<2xf16>) -> vector<2xf64> { + %0 = llvm.fpext %arg0 : vector<2xf16> to vector<2xf64> + %1 = llvm.intr.floor(%0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @test_shrink_intrin_ceil_fp16_src(%arg0: f16) -> f32 { + %0 = llvm.fpext %arg0 : f16 to f64 + %1 = llvm.intr.ceil(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_intrin_round_fp16_vec(%arg0: vector<2xf16>) -> vector<2xf64> { + %0 = llvm.fpext %arg0 : vector<2xf16> to vector<2xf64> + %1 = llvm.intr.round(%0) : (vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @test_shrink_intrin_roundeven_fp16_vec(%arg0: vector<2xf16>) -> vector<2xf64> { + %0 = llvm.fpext %arg0 : vector<2xf16> to vector<2xf64> + %1 = llvm.intr.roundeven(%0) : (vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @test_shrink_intrin_nearbyint_fp16_src(%arg0: f16) -> f32 { + %0 = llvm.fpext %arg0 : f16 to f64 + %1 = llvm.intr.nearbyint(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_intrin_trunc_fp16_src(%arg0: vector<2xf16>) -> vector<2xf64> { + %0 = llvm.fpext %arg0 : vector<2xf16> to vector<2xf64> + %1 = llvm.intr.trunc(%0) : (vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @test_shrink_intrin_fabs_fp16_src(%arg0: f16) -> f32 { + %0 = llvm.fpext %arg0 : f16 to f64 + %1 = llvm.intr.fabs(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_shrink_intrin_fabs_fast_fp16_src(%arg0: f16) -> f32 { + %0 = llvm.fpext %arg0 : f16 to f64 + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test_no_shrink_intrin_floor_multi_use_fpext(%arg0: f16) -> f32 { + %0 = llvm.mlir.undef : !llvm.ptr + %1 = llvm.fpext %arg0 : f16 to f64 + llvm.store volatile %1, %0 {alignment = 8 : i64} : f64, !llvm.ptr + %2 = llvm.intr.floor(%1) : (f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test_no_shrink_intrin_fabs_multi_use_fpext(%arg0: f16) -> f32 { + %0 = llvm.mlir.undef : !llvm.ptr + %1 = llvm.fpext %arg0 : f16 to f64 + llvm.store volatile %1, %0 {alignment = 8 : i64} : f64, !llvm.ptr + %2 = llvm.intr.fabs(%1) : (f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/early_constfold_changes_IR.ll.mlir b/test/LLVMDialect/InstCombine/early_constfold_changes_IR.ll.mlir index 710f453d1..c3bddddca 100644 --- a/test/LLVMDialect/InstCombine/early_constfold_changes_IR.ll.mlir +++ b/test/LLVMDialect/InstCombine/early_constfold_changes_IR.ll.mlir @@ -1,11 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.or"(%1, %0) : (i32, i32) -> i32 - %3 = "llvm.and"(%arg0, %2) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.or %0, %1 : i32 + %3 = llvm.and %arg0, %2 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/early_dce_clobbers_callgraph.ll.mlir b/test/LLVMDialect/InstCombine/early_dce_clobbers_callgraph.ll.mlir index 9873b57d4..6a16a06af 100644 --- a/test/LLVMDialect/InstCombine/early_dce_clobbers_callgraph.ll.mlir +++ b/test/LLVMDialect/InstCombine/early_dce_clobbers_callgraph.ll.mlir @@ -1,11 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.call"() {callee = @bar, fastmathFlags = #llvm.fastmath<>} : () -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 1 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo() { + %0 = llvm.call @bar() : () -> i32 + llvm.return + } + llvm.func internal @bar() -> i32 attributes {dso_local} { + %0 = llvm.mlir.constant(42 : i32) : i32 + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/element-atomic-memintrins.ll.mlir b/test/LLVMDialect/InstCombine/element-atomic-memintrins.ll.mlir index 7f4b60f68..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/element-atomic-memintrins.ll.mlir +++ b/test/LLVMDialect/InstCombine/element-atomic-memintrins.ll.mlir @@ -1,320 +0,0 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "gconst", type = !llvm.array<32 x i8>, value = "0123456789012345678901234567890\00"} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - "llvm.call"(%arg0, %2, %1, %0) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memset_zero_length", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - "llvm.call"(%arg0, %5, %4, %4) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %3, %4) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %2, %4) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %1, %4) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %0, %4) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memset_to_store", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - "llvm.call"(%arg0, %5, %4, %4) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %3, %3) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %2, %3) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %1, %3) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %0, %3) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memset_to_store_2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - "llvm.call"(%arg0, %5, %4, %4) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %3, %3) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %2, %2) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %1, %2) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %0, %2) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memset_to_store_4", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - "llvm.call"(%arg0, %5, %4, %4) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %3, %3) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %2, %2) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %1, %1) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %0, %1) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memset_to_store_8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - "llvm.call"(%arg0, %5, %4, %4) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %3, %3) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %2, %2) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %1, %1) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %5, %0, %0) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memset_to_store_16", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memset.element.unordered.atomic.p0i8.i32", type = !llvm.func, i8, i32, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 32 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @gconst} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - "llvm.call"(%arg0, %4, %1, %0) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memmove_to_memcpy", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %5, %4) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %5, %3) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %5, %2) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %5, %1) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %5, %0) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memmove_zero_length", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - "llvm.call"(%arg0, %arg0, %arg1, %4) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg0, %arg1, %3) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg0, %arg1, %2) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg0, %arg1, %1) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg0, %arg1, %0) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memmove_removed", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %4, %4) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %3, %4) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %2, %4) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %1, %4) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %0, %4) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memmove_loadstore", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %4, %4) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %3, %3) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %2, %3) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %1, %3) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %0, %3) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memmove_loadstore_2", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %4, %4) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %3, %3) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %2, %2) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %1, %2) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %0, %2) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memmove_loadstore_4", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %4, %4) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %3, %3) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %2, %2) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %1, %1) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %0, %1) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memmove_loadstore_8", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %4, %4) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %3, %3) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %2, %2) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %1, %1) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %0, %0) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memmove_loadstore_16", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32", type = !llvm.func, ptr, i32, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %5, %4) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %5, %3) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %5, %2) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %5, %1) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %5, %0) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memcpy_zero_length", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - "llvm.call"(%arg0, %arg0, %arg1, %4) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg0, %arg1, %3) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg0, %arg1, %2) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg0, %arg1, %1) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg0, %arg1, %0) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memcpy_removed", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %4, %4) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %3, %4) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %2, %4) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %1, %4) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %0, %4) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memcpy_loadstore", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %4, %4) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %3, %3) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %2, %3) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %1, %3) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %0, %3) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memcpy_loadstore_2", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %4, %4) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %3, %3) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %2, %2) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %1, %2) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %0, %2) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memcpy_loadstore_4", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %4, %4) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %3, %3) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %2, %2) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %1, %1) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %0, %1) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memcpy_loadstore_8", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %4, %4) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %3, %3) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %2, %2) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %1, %1) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %0, %0) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_memcpy_loadstore_16", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = -8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - "llvm.cond_br"(%arg2)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () - ^bb1: // pred: ^bb0 - "llvm.call"(%arg0, %arg1, %3, %2) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %1, %2) {callee = @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %3, %2) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %arg1, %1, %2) {callee = @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i32) -> () - "llvm.call"(%arg0, %0, %3, %2) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.call"(%arg0, %0, %1, %2) {callee = @llvm.memset.element.unordered.atomic.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i32) -> () - "llvm.br"()[^bb2] : () -> () - ^bb2: // 2 preds: ^bb0, ^bb1 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_undefined", type = !llvm.func, ptr, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32", type = !llvm.func, ptr, i32, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/enforce-known-alignment.ll.mlir b/test/LLVMDialect/InstCombine/enforce-known-alignment.ll.mlir index c2338cf10..53769d57b 100644 --- a/test/LLVMDialect/InstCombine/enforce-known-alignment.ll.mlir +++ b/test/LLVMDialect/InstCombine/enforce-known-alignment.ll.mlir @@ -1,37 +1,30 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i16} : () -> i16 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>)>>> - %4 = "llvm.getelementptr"(%3, %1, %1) : (!llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>)>>>, i32, i32) -> !llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>)>> - %5 = "llvm.getelementptr"(%4, %1, %1) : (!llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>)>>, i32, i32) -> !llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>> - %6 = "llvm.getelementptr"(%5, %1, %1) : (!llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>>, i32, i32) -> !llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>> - %7 = "llvm.bitcast"(%6) : (!llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>>) -> !llvm.ptr)>> - %8 = "llvm.getelementptr"(%7, %1, %1) : (!llvm.ptr)>>, i32, i32) -> !llvm.ptr> - %9 = "llvm.getelementptr"(%8, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - "llvm.store"(%0, %9) : (i16, !llvm.ptr) -> () - "llvm.call"(%9) {callee = @bar, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>)>>, 1>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i16} : () -> i16 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.getelementptr"(%arg1, %1, %1) : (!llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>)>>, 1>, i32, i32) -> !llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>)>, 1> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>)>, 1>, i32, i32) -> !llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>, 1> - %4 = "llvm.getelementptr"(%3, %1, %1) : (!llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>, 1>, i32, i32) -> !llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>, 1> - %5 = "llvm.bitcast"(%4) : (!llvm.ptr)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>, 1>) -> !llvm.ptr)>, 1> - %6 = "llvm.getelementptr"(%5, %1, %1) : (!llvm.ptr)>, 1>, i32, i32) -> !llvm.ptr, 1> - %7 = "llvm.getelementptr"(%6, %1, %1) : (!llvm.ptr, 1>, i32, i32) -> !llvm.ptr - "llvm.store"(%0, %7) : (i16, !llvm.ptr) -> () - "llvm.call"(%7) {callee = @bar_as1, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "foo_as1", type = !llvm.func)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>)>>, 1>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bar_as1", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<16> : vector<4xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i32) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i16) : i16 + %3 = llvm.alloca %0 x !llvm.array<3 x struct)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>)>> {alignment = 16 : i64} : (i32) -> !llvm.ptr + %4 = llvm.getelementptr %3[%1, %1] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<3 x struct)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>)>> + %5 = llvm.getelementptr %4[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>)> + %6 = llvm.getelementptr %5[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(struct<(array<2 x struct<(struct<(i32)>)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)> + %7 = llvm.getelementptr %6[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(array<8 x i16>)> + %8 = llvm.getelementptr %7[%1, %1] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<8 x i16> + llvm.store %2, %8 {alignment = 16 : i64} : i16, !llvm.ptr + llvm.call @bar(%8) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @bar(!llvm.ptr) + llvm.func @foo_as1(%arg0: i32, %arg1: !llvm.ptr<1>) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.getelementptr %arg1[%0, %0] : (!llvm.ptr<1>, i32, i32) -> !llvm.ptr<1>, !llvm.array<3 x struct)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>)>> + %3 = llvm.getelementptr %2[%0, 0] : (!llvm.ptr<1>, i32) -> !llvm.ptr<1>, !llvm.struct)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)>)> + %4 = llvm.getelementptr %3[%0, 0] : (!llvm.ptr<1>, i32) -> !llvm.ptr<1>, !llvm.struct<(struct<(array<2 x struct<(struct<(i32)>)>>, array<2 x i8>, struct<(i16)>, array<2 x i8>, i8, i8)>)> + %5 = llvm.getelementptr %4[%0, 0] : (!llvm.ptr<1>, i32) -> !llvm.ptr<1>, !llvm.struct<(array<8 x i16>)> + %6 = llvm.getelementptr %5[%0, %0] : (!llvm.ptr<1>, i32, i32) -> !llvm.ptr<1>, !llvm.array<8 x i16> + llvm.store %1, %6 {alignment = 16 : i64} : i16, !llvm.ptr<1> + llvm.call @bar_as1(%6) : (!llvm.ptr<1>) -> () + llvm.return + } + llvm.func @bar_as1(!llvm.ptr<1>) +} diff --git a/test/LLVMDialect/InstCombine/eq-of-parts.ll.mlir b/test/LLVMDialect/InstCombine/eq-of-parts.ll.mlir new file mode 100644 index 000000000..bb6cb39fa --- /dev/null +++ b/test/LLVMDialect/InstCombine/eq-of-parts.ll.mlir @@ -0,0 +1,881 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use.i32(i32) + llvm.func @use.i8(i8) + llvm.func @use.i1(i1) + llvm.func @eq_10(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.trunc %arg0 : i32 to i8 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.trunc %arg1 : i32 to i8 + %5 = llvm.lshr %arg1, %0 : i32 + %6 = llvm.trunc %5 : i32 to i8 + %7 = llvm.icmp "eq" %1, %4 : i8 + %8 = llvm.icmp "eq" %3, %6 : i8 + %9 = llvm.and %7, %8 : i1 + llvm.return %9 : i1 + } + llvm.func @eq_210(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.trunc %arg0 : i32 to i8 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.lshr %arg0, %1 : i32 + %6 = llvm.trunc %5 : i32 to i8 + %7 = llvm.trunc %arg1 : i32 to i8 + %8 = llvm.lshr %arg1, %0 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.lshr %arg1, %1 : i32 + %11 = llvm.trunc %10 : i32 to i8 + %12 = llvm.icmp "eq" %2, %7 : i8 + %13 = llvm.icmp "eq" %4, %9 : i8 + %14 = llvm.icmp "eq" %6, %11 : i8 + %15 = llvm.and %12, %13 : i1 + %16 = llvm.and %14, %15 : i1 + llvm.return %16 : i1 + } + llvm.func @eq_3210(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(24 : i32) : i32 + %3 = llvm.trunc %arg0 : i32 to i8 + %4 = llvm.lshr %arg0, %0 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg0, %1 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg0, %2 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.trunc %arg1 : i32 to i8 + %11 = llvm.lshr %arg1, %0 : i32 + %12 = llvm.trunc %11 : i32 to i8 + %13 = llvm.lshr %arg1, %1 : i32 + %14 = llvm.trunc %13 : i32 to i8 + %15 = llvm.lshr %arg1, %2 : i32 + %16 = llvm.trunc %15 : i32 to i8 + %17 = llvm.icmp "eq" %3, %10 : i8 + %18 = llvm.icmp "eq" %5, %12 : i8 + %19 = llvm.icmp "eq" %7, %14 : i8 + %20 = llvm.icmp "eq" %9, %16 : i8 + %21 = llvm.and %17, %18 : i1 + %22 = llvm.and %19, %21 : i1 + %23 = llvm.and %20, %22 : i1 + llvm.return %23 : i1 + } + llvm.func @eq_21(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %3, %7 : i8 + %11 = llvm.icmp "eq" %5, %9 : i8 + %12 = llvm.and %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_comm_and(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %3, %7 : i8 + %11 = llvm.icmp "eq" %5, %9 : i8 + %12 = llvm.and %10, %11 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_comm_eq(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %3, %7 : i8 + %11 = llvm.icmp "eq" %9, %5 : i8 + %12 = llvm.and %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_comm_eq2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %7, %3 : i8 + %11 = llvm.icmp "eq" %5, %9 : i8 + %12 = llvm.and %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + %4 = llvm.lshr %arg0, %1 : vector<2xi32> + %5 = llvm.trunc %4 : vector<2xi32> to vector<2xi8> + %6 = llvm.lshr %arg1, %0 : vector<2xi32> + %7 = llvm.trunc %6 : vector<2xi32> to vector<2xi8> + %8 = llvm.lshr %arg1, %1 : vector<2xi32> + %9 = llvm.trunc %8 : vector<2xi32> to vector<2xi8> + %10 = llvm.icmp "eq" %3, %7 : vector<2xi8> + %11 = llvm.icmp "eq" %5, %9 : vector<2xi8> + %12 = llvm.and %11, %10 : vector<2xi1> + llvm.return %12 : vector<2xi1> + } + llvm.func @eq_irregular_bit_widths(%arg0: i31, %arg1: i31) -> i1 { + %0 = llvm.mlir.constant(7 : i31) : i31 + %1 = llvm.mlir.constant(13 : i31) : i31 + %2 = llvm.lshr %arg0, %0 : i31 + %3 = llvm.trunc %2 : i31 to i6 + %4 = llvm.lshr %arg0, %1 : i31 + %5 = llvm.trunc %4 : i31 to i5 + %6 = llvm.lshr %arg1, %0 : i31 + %7 = llvm.trunc %6 : i31 to i6 + %8 = llvm.lshr %arg1, %1 : i31 + %9 = llvm.trunc %8 : i31 to i5 + %10 = llvm.icmp "eq" %3, %7 : i6 + %11 = llvm.icmp "eq" %5, %9 : i5 + %12 = llvm.and %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_extra_use_lshr(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use.i32(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %3, %7 : i8 + %11 = llvm.icmp "eq" %5, %9 : i8 + %12 = llvm.and %10, %11 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_extra_use_trunc(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %3, %7 : i8 + %11 = llvm.icmp "eq" %5, %9 : i8 + %12 = llvm.and %10, %11 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_extra_use_eq1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %3, %7 : i8 + llvm.call @use.i1(%10) : (i1) -> () + %11 = llvm.icmp "eq" %5, %9 : i8 + %12 = llvm.and %10, %11 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_extra_use_eq2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %3, %7 : i8 + %11 = llvm.icmp "eq" %5, %9 : i8 + llvm.call @use.i1(%11) : (i1) -> () + %12 = llvm.and %10, %11 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.lshr %arg0, %1 : i32 + %6 = llvm.trunc %5 : i32 to i8 + %7 = llvm.lshr %arg1, %0 : i32 + %8 = llvm.trunc %7 : i32 to i8 + %9 = llvm.lshr %arg1, %1 : i32 + %10 = llvm.trunc %9 : i32 to i8 + %11 = llvm.icmp "eq" %4, %8 : i8 + %12 = llvm.icmp "eq" %6, %10 : i8 + %13 = llvm.select %12, %11, %2 : i1, i1 + llvm.return %13 : i1 + } + llvm.func @eq_21_wrong_op1(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg2, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %3, %7 : i8 + %11 = llvm.icmp "eq" %5, %9 : i8 + %12 = llvm.and %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_wrong_op2(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg2, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %3, %7 : i8 + %11 = llvm.icmp "eq" %5, %9 : i8 + %12 = llvm.and %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_wrong_op3(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg2, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %3, %7 : i8 + %11 = llvm.icmp "eq" %5, %9 : i8 + %12 = llvm.and %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_wrong_op4(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg2, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %3, %7 : i8 + %11 = llvm.icmp "eq" %5, %9 : i8 + %12 = llvm.and %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_wrong_shift1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.lshr %arg0, %1 : i32 + %6 = llvm.trunc %5 : i32 to i8 + %7 = llvm.lshr %arg1, %2 : i32 + %8 = llvm.trunc %7 : i32 to i8 + %9 = llvm.lshr %arg1, %1 : i32 + %10 = llvm.trunc %9 : i32 to i8 + %11 = llvm.icmp "eq" %4, %8 : i8 + %12 = llvm.icmp "eq" %6, %10 : i8 + %13 = llvm.and %12, %11 : i1 + llvm.return %13 : i1 + } + llvm.func @eq_21_wrong_shift2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.lshr %arg0, %1 : i32 + %6 = llvm.trunc %5 : i32 to i8 + %7 = llvm.lshr %arg1, %0 : i32 + %8 = llvm.trunc %7 : i32 to i8 + %9 = llvm.lshr %arg1, %2 : i32 + %10 = llvm.trunc %9 : i32 to i8 + %11 = llvm.icmp "eq" %4, %8 : i8 + %12 = llvm.icmp "eq" %6, %10 : i8 + %13 = llvm.and %12, %11 : i1 + llvm.return %13 : i1 + } + llvm.func @eq_21_not_adjacent(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %3, %7 : i8 + %11 = llvm.icmp "eq" %5, %9 : i8 + %12 = llvm.and %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_shift_in_zeros(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i24 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i24 + %10 = llvm.icmp "eq" %3, %7 : i8 + %11 = llvm.icmp "eq" %5, %9 : i24 + %12 = llvm.and %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_wrong_pred1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %3, %7 : i8 + %11 = llvm.icmp "ne" %5, %9 : i8 + %12 = llvm.and %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_21_wrong_pred2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %3, %7 : i8 + %11 = llvm.icmp "ne" %5, %9 : i8 + %12 = llvm.and %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_10(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.trunc %arg0 : i32 to i8 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.trunc %arg1 : i32 to i8 + %5 = llvm.lshr %arg1, %0 : i32 + %6 = llvm.trunc %5 : i32 to i8 + %7 = llvm.icmp "ne" %1, %4 : i8 + %8 = llvm.icmp "ne" %3, %6 : i8 + %9 = llvm.or %7, %8 : i1 + llvm.return %9 : i1 + } + llvm.func @ne_210(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.trunc %arg0 : i32 to i8 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.lshr %arg0, %1 : i32 + %6 = llvm.trunc %5 : i32 to i8 + %7 = llvm.trunc %arg1 : i32 to i8 + %8 = llvm.lshr %arg1, %0 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.lshr %arg1, %1 : i32 + %11 = llvm.trunc %10 : i32 to i8 + %12 = llvm.icmp "ne" %2, %7 : i8 + %13 = llvm.icmp "ne" %4, %9 : i8 + %14 = llvm.icmp "ne" %6, %11 : i8 + %15 = llvm.or %12, %13 : i1 + %16 = llvm.or %14, %15 : i1 + llvm.return %16 : i1 + } + llvm.func @ne_3210(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(24 : i32) : i32 + %3 = llvm.trunc %arg0 : i32 to i8 + %4 = llvm.lshr %arg0, %0 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg0, %1 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg0, %2 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.trunc %arg1 : i32 to i8 + %11 = llvm.lshr %arg1, %0 : i32 + %12 = llvm.trunc %11 : i32 to i8 + %13 = llvm.lshr %arg1, %1 : i32 + %14 = llvm.trunc %13 : i32 to i8 + %15 = llvm.lshr %arg1, %2 : i32 + %16 = llvm.trunc %15 : i32 to i8 + %17 = llvm.icmp "ne" %3, %10 : i8 + %18 = llvm.icmp "ne" %5, %12 : i8 + %19 = llvm.icmp "ne" %7, %14 : i8 + %20 = llvm.icmp "ne" %9, %16 : i8 + %21 = llvm.or %17, %18 : i1 + %22 = llvm.or %19, %21 : i1 + %23 = llvm.or %20, %22 : i1 + llvm.return %23 : i1 + } + llvm.func @ne_21(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %3, %7 : i8 + %11 = llvm.icmp "ne" %5, %9 : i8 + %12 = llvm.or %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_comm_or(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %3, %7 : i8 + %11 = llvm.icmp "ne" %5, %9 : i8 + %12 = llvm.or %10, %11 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_comm_ne(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %3, %7 : i8 + %11 = llvm.icmp "ne" %9, %5 : i8 + %12 = llvm.or %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_comm_ne2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %7, %3 : i8 + %11 = llvm.icmp "ne" %5, %9 : i8 + %12 = llvm.or %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + %4 = llvm.lshr %arg0, %1 : vector<2xi32> + %5 = llvm.trunc %4 : vector<2xi32> to vector<2xi8> + %6 = llvm.lshr %arg1, %0 : vector<2xi32> + %7 = llvm.trunc %6 : vector<2xi32> to vector<2xi8> + %8 = llvm.lshr %arg1, %1 : vector<2xi32> + %9 = llvm.trunc %8 : vector<2xi32> to vector<2xi8> + %10 = llvm.icmp "ne" %3, %7 : vector<2xi8> + %11 = llvm.icmp "ne" %5, %9 : vector<2xi8> + %12 = llvm.or %11, %10 : vector<2xi1> + llvm.return %12 : vector<2xi1> + } + llvm.func @ne_irregular_bit_widths(%arg0: i31, %arg1: i31) -> i1 { + %0 = llvm.mlir.constant(7 : i31) : i31 + %1 = llvm.mlir.constant(13 : i31) : i31 + %2 = llvm.lshr %arg0, %0 : i31 + %3 = llvm.trunc %2 : i31 to i6 + %4 = llvm.lshr %arg0, %1 : i31 + %5 = llvm.trunc %4 : i31 to i5 + %6 = llvm.lshr %arg1, %0 : i31 + %7 = llvm.trunc %6 : i31 to i6 + %8 = llvm.lshr %arg1, %1 : i31 + %9 = llvm.trunc %8 : i31 to i5 + %10 = llvm.icmp "ne" %3, %7 : i6 + %11 = llvm.icmp "ne" %5, %9 : i5 + %12 = llvm.or %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_extra_use_lshr(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use.i32(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %3, %7 : i8 + %11 = llvm.icmp "ne" %5, %9 : i8 + %12 = llvm.or %10, %11 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_extra_use_trunc(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %3, %7 : i8 + %11 = llvm.icmp "ne" %5, %9 : i8 + %12 = llvm.or %10, %11 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_extra_use_ne1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %3, %7 : i8 + llvm.call @use.i1(%10) : (i1) -> () + %11 = llvm.icmp "ne" %5, %9 : i8 + %12 = llvm.or %10, %11 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_extra_use_ne2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %3, %7 : i8 + %11 = llvm.icmp "ne" %5, %9 : i8 + llvm.call @use.i1(%11) : (i1) -> () + %12 = llvm.or %10, %11 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.lshr %arg0, %1 : i32 + %6 = llvm.trunc %5 : i32 to i8 + %7 = llvm.lshr %arg1, %0 : i32 + %8 = llvm.trunc %7 : i32 to i8 + %9 = llvm.lshr %arg1, %1 : i32 + %10 = llvm.trunc %9 : i32 to i8 + %11 = llvm.icmp "ne" %4, %8 : i8 + %12 = llvm.icmp "ne" %6, %10 : i8 + %13 = llvm.select %12, %2, %11 : i1, i1 + llvm.return %13 : i1 + } + llvm.func @ne_21_wrong_op1(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg2, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %3, %7 : i8 + %11 = llvm.icmp "ne" %5, %9 : i8 + %12 = llvm.or %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_wrong_op2(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg2, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %3, %7 : i8 + %11 = llvm.icmp "ne" %5, %9 : i8 + %12 = llvm.or %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_wrong_op3(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg2, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %3, %7 : i8 + %11 = llvm.icmp "ne" %5, %9 : i8 + %12 = llvm.or %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_wrong_op4(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg2, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %3, %7 : i8 + %11 = llvm.icmp "ne" %5, %9 : i8 + %12 = llvm.or %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_wrong_shift1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.lshr %arg0, %1 : i32 + %6 = llvm.trunc %5 : i32 to i8 + %7 = llvm.lshr %arg1, %2 : i32 + %8 = llvm.trunc %7 : i32 to i8 + %9 = llvm.lshr %arg1, %1 : i32 + %10 = llvm.trunc %9 : i32 to i8 + %11 = llvm.icmp "ne" %4, %8 : i8 + %12 = llvm.icmp "ne" %6, %10 : i8 + %13 = llvm.or %12, %11 : i1 + llvm.return %13 : i1 + } + llvm.func @ne_21_wrong_shift2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.lshr %arg0, %1 : i32 + %6 = llvm.trunc %5 : i32 to i8 + %7 = llvm.lshr %arg1, %0 : i32 + %8 = llvm.trunc %7 : i32 to i8 + %9 = llvm.lshr %arg1, %2 : i32 + %10 = llvm.trunc %9 : i32 to i8 + %11 = llvm.icmp "ne" %4, %8 : i8 + %12 = llvm.icmp "ne" %6, %10 : i8 + %13 = llvm.or %12, %11 : i1 + llvm.return %13 : i1 + } + llvm.func @ne_21_not_adjacent(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %3, %7 : i8 + %11 = llvm.icmp "ne" %5, %9 : i8 + %12 = llvm.or %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_shift_in_zeros(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i24 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i24 + %10 = llvm.icmp "ne" %3, %7 : i8 + %11 = llvm.icmp "ne" %5, %9 : i24 + %12 = llvm.or %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_wrong_pred1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "ne" %3, %7 : i8 + %11 = llvm.icmp "eq" %5, %9 : i8 + %12 = llvm.or %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @ne_21_wrong_pred2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.lshr %arg1, %0 : i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.lshr %arg1, %1 : i32 + %9 = llvm.trunc %8 : i32 to i8 + %10 = llvm.icmp "eq" %3, %7 : i8 + %11 = llvm.icmp "eq" %5, %9 : i8 + %12 = llvm.or %11, %10 : i1 + llvm.return %12 : i1 + } + llvm.func @eq_optimized_highbits_cmp(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(33554432 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.icmp "ult" %1, %0 : i32 + %3 = llvm.trunc %arg0 : i32 to i25 + %4 = llvm.trunc %arg1 : i32 to i25 + %5 = llvm.icmp "eq" %3, %4 : i25 + %6 = llvm.and %2, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @eq_optimized_highbits_cmp_todo_overlapping(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(16777216 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.icmp "ult" %1, %0 : i32 + %3 = llvm.trunc %arg0 : i32 to i25 + %4 = llvm.trunc %arg1 : i32 to i25 + %5 = llvm.icmp "eq" %3, %4 : i25 + %6 = llvm.and %2, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @eq_optimized_highbits_cmp_fail_not_pow2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(16777215 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.icmp "ult" %1, %0 : i32 + %3 = llvm.trunc %arg0 : i32 to i24 + %4 = llvm.trunc %arg1 : i32 to i24 + %5 = llvm.icmp "eq" %3, %4 : i24 + %6 = llvm.and %2, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @ne_optimized_highbits_cmp(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(16777215 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + %3 = llvm.trunc %arg0 : i32 to i24 + %4 = llvm.trunc %arg1 : i32 to i24 + %5 = llvm.icmp "ne" %3, %4 : i24 + %6 = llvm.or %2, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @ne_optimized_highbits_cmp_fail_not_mask(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(16777216 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + %3 = llvm.trunc %arg0 : i32 to i24 + %4 = llvm.trunc %arg1 : i32 to i24 + %5 = llvm.icmp "ne" %3, %4 : i24 + %6 = llvm.or %2, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @ne_optimized_highbits_cmp_fail_no_combined_int(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(16777215 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + %3 = llvm.trunc %arg0 : i32 to i23 + %4 = llvm.trunc %arg1 : i32 to i23 + %5 = llvm.icmp "ne" %3, %4 : i23 + %6 = llvm.or %2, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @ne_optimized_highbits_cmp_todo_overlapping(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(8388607 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + %3 = llvm.trunc %arg0 : i32 to i24 + %4 = llvm.trunc %arg1 : i32 to i24 + %5 = llvm.icmp "ne" %3, %4 : i24 + %6 = llvm.or %2, %5 : i1 + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/erase-dbg-values-at-dead-alloc-site.ll.mlir b/test/LLVMDialect/InstCombine/erase-dbg-values-at-dead-alloc-site.ll.mlir new file mode 100644 index 000000000..e11140717 --- /dev/null +++ b/test/LLVMDialect/InstCombine/erase-dbg-values-at-dead-alloc-site.ll.mlir @@ -0,0 +1,20 @@ +#di_basic_type = #llvm.di_basic_type +#di_file = #llvm.di_file<"-" in "/"> +#di_file1 = #llvm.di_file<"" in "/"> +#di_null_type = #llvm.di_null_type +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C99, file = #di_file, isOptimized = false, emissionKind = Full> +#di_subroutine_type = #llvm.di_subroutine_type +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file1, name = "t1", file = #di_file1, line = 1, scopeLine = 1, subprogramFlags = Definition, type = #di_subroutine_type> +#di_local_variable = #llvm.di_local_variable +#di_local_variable1 = #llvm.di_local_variable +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t1(%arg0: i32) { + llvm.intr.dbg.value #di_local_variable = %arg0 : i32 + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.dbg.value #di_local_variable1 = %1 : !llvm.ptr + llvm.intr.dbg.value #di_local_variable #llvm.di_expression<[DW_OP_deref]> = %1 : !llvm.ptr + llvm.store %arg0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/err-rep-cold.ll.mlir b/test/LLVMDialect/InstCombine/err-rep-cold.ll.mlir index 9e70f8255..21f19248f 100644 --- a/test/LLVMDialect/InstCombine/err-rep-cold.ll.mlir +++ b/test/LLVMDialect/InstCombine/err-rep-cold.ll.mlir @@ -1,73 +1,60 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "stdout", type = !llvm.ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>>} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "stderr", type = !llvm.ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str", type = !llvm.array<13 x i8>, value = "an error: %d\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str1", type = !llvm.array<9 x i8>, value = "an error\00"} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.mlir.addressof"() {global_name = @stderr} : () -> !llvm.ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>>> - %5 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %7 = "llvm.icmp"(%arg0, %6) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%7, %5)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.mlir.global external @stdout() {addr_space = 0 : i32} : !llvm.ptr + llvm.mlir.global external @stderr() {addr_space = 0 : i32} : !llvm.ptr + llvm.mlir.global private unnamed_addr constant @".str"("an error: %d\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str1"("an error\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.func @test1(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @stderr : !llvm.ptr + %3 = llvm.mlir.constant("an error: %d\00") : !llvm.array<13 x i8> + %4 = llvm.mlir.addressof @".str" : !llvm.ptr + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.cond_br %6, ^bb1, ^bb2(%1 : i32) ^bb1: // pred: ^bb0 - %8 = "llvm.load"(%4) : (!llvm.ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>>>) -> !llvm.ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>> - %9 = "llvm.call"(%8, %3, %arg0) {callee = @fprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>>, !llvm.ptr, i32) -> i32 - "llvm.br"(%0)[^bb2] : (i32) -> () - ^bb2(%10: i32): // 2 preds: ^bb0, ^bb1 - "llvm.return"(%10) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fprintf", type = !llvm.func, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>>, ptr, ...)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %4 = "llvm.mlir.addressof"() {global_name = @".str1"} : () -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %3, %3) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %6 = "llvm.mlir.addressof"() {global_name = @stderr} : () -> !llvm.ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>>> - %7 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %8 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %9 = "llvm.icmp"(%arg0, %8) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%9, %7)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i32) -> () + %7 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %8 = llvm.call @fprintf(%7, %4, %arg0) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.br ^bb2(%5 : i32) + ^bb2(%9: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %9 : i32 + } + llvm.func @fprintf(!llvm.ptr {llvm.nocapture}, !llvm.ptr {llvm.nocapture, llvm.readonly}, ...) -> i32 attributes {passthrough = ["nounwind"]} + llvm.func @test2(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @stderr : !llvm.ptr + %3 = llvm.mlir.constant("an error\00") : !llvm.array<9 x i8> + %4 = llvm.mlir.addressof @".str1" : !llvm.ptr + %5 = llvm.mlir.constant(8 : i64) : i64 + %6 = llvm.mlir.constant(1 : i64) : i64 + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.cond_br %8, ^bb1, ^bb2(%1 : i32) ^bb1: // pred: ^bb0 - %10 = "llvm.load"(%6) : (!llvm.ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>>>) -> !llvm.ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>> - %11 = "llvm.call"(%5, %2, %1, %10) {callee = @fwrite, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64, i64, !llvm.ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>>) -> i64 - "llvm.br"(%0)[^bb2] : (i32) -> () - ^bb2(%12: i32): // 2 preds: ^bb0, ^bb1 - "llvm.return"(%12) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fwrite", type = !llvm.func, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %4 = "llvm.mlir.addressof"() {global_name = @".str1"} : () -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %3, %3) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %6 = "llvm.mlir.addressof"() {global_name = @stdout} : () -> !llvm.ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>>> - %7 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %8 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %9 = "llvm.icmp"(%arg0, %8) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%9, %7)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i32) -> () + %9 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %10 = llvm.call @fwrite(%4, %5, %6, %9) : (!llvm.ptr, i64, i64, !llvm.ptr) -> i64 + llvm.br ^bb2(%7 : i32) + ^bb2(%11: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %11 : i32 + } + llvm.func @fwrite(!llvm.ptr {llvm.nocapture}, i64, i64, !llvm.ptr {llvm.nocapture}) -> i64 attributes {passthrough = ["nounwind"]} + llvm.func @test3(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @stdout : !llvm.ptr + %3 = llvm.mlir.constant("an error\00") : !llvm.array<9 x i8> + %4 = llvm.mlir.addressof @".str1" : !llvm.ptr + %5 = llvm.mlir.constant(8 : i64) : i64 + %6 = llvm.mlir.constant(1 : i64) : i64 + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.cond_br %8, ^bb1, ^bb2(%1 : i32) ^bb1: // pred: ^bb0 - %10 = "llvm.load"(%6) : (!llvm.ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>>>) -> !llvm.ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>> - %11 = "llvm.call"(%5, %2, %1, %10) {callee = @fwrite, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64, i64, !llvm.ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr>, ptr>, i32)>>, ptr>, i32, i32, i64, i16, i8, array<1 x i8>, ptr, i64, ptr, ptr, ptr, ptr, i64, i32, array<20 x i8>)>>) -> i64 - "llvm.br"(%0)[^bb2] : (i32) -> () - ^bb2(%12: i32): // 2 preds: ^bb0, ^bb1 - "llvm.return"(%12) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %9 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %10 = llvm.call @fwrite(%4, %5, %6, %9) : (!llvm.ptr, i64, i64, !llvm.ptr) -> i64 + llvm.br ^bb2(%7 : i32) + ^bb2(%11: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %11 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/exact.ll.mlir b/test/LLVMDialect/InstCombine/exact.ll.mlir new file mode 100644 index 000000000..4ae3c22dc --- /dev/null +++ b/test/LLVMDialect/InstCombine/exact.ll.mlir @@ -0,0 +1,272 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @sdiv1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.sdiv %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @sdiv2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.sdiv %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @sdiv2_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<128> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg0, %0 : vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @sdiv3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.sdiv %arg0, %0 : i32 + %2 = llvm.mul %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @sdiv4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.sdiv %arg0, %0 : i32 + %2 = llvm.mul %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @sdiv5(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(-3 : i32) : i32 + %2 = llvm.sdiv %arg0, %0 : i32 + %3 = llvm.mul %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @sdiv6(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(-3 : i32) : i32 + %2 = llvm.sdiv %arg0, %0 : i32 + %3 = llvm.mul %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @udiv1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.udiv %arg0, %arg1 : i32 + %1 = llvm.mul %0, %arg1 : i32 + llvm.return %1 : i32 + } + llvm.func @udiv2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.udiv %arg0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @ashr1(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.shl %arg0, %0 : i64 + %3 = llvm.ashr %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @ashr1_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<2> : vector<2xi64>) : vector<2xi64> + %2 = llvm.shl %arg0, %0 : vector<2xi64> + %3 = llvm.ashr %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @ashr_icmp1(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.ashr %arg0, %0 : i64 + %3 = llvm.icmp "eq" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @ashr_icmp2(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.constant(4 : i64) : i64 + %2 = llvm.ashr %arg0, %0 : i64 + %3 = llvm.icmp "slt" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @ashr_icmp2_vec(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<4> : vector<2xi64>) : vector<2xi64> + %2 = llvm.ashr %arg0, %0 : vector<2xi64> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi1> + } + llvm.func @pr9998(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(7297771788697658747 : i64) : i64 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.ashr %2, %0 : i32 + %4 = llvm.sext %3 : i32 to i64 + %5 = llvm.icmp "ugt" %4, %1 : i64 + llvm.return %5 : i1 + } + llvm.func @pr9998vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<7297771788697658747> : vector<2xi64>) : vector<2xi64> + %2 = llvm.shl %arg0, %0 : vector<2xi32> + %3 = llvm.ashr %2, %0 : vector<2xi32> + %4 = llvm.sext %3 : vector<2xi32> to vector<2xi64> + %5 = llvm.icmp "ugt" %4, %1 : vector<2xi64> + llvm.return %5 : vector<2xi1> + } + llvm.func @udiv_icmp1(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(5 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.udiv %arg0, %0 : i64 + %3 = llvm.icmp "ne" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @udiv_icmp1_vec(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.udiv %arg0, %0 : vector<2xi64> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi64> + llvm.return %4 : vector<2xi1> + } + llvm.func @udiv_icmp2(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(5 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.udiv %arg0, %0 : i64 + %3 = llvm.icmp "eq" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @udiv_icmp2_vec(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.udiv %arg0, %0 : vector<2xi64> + %4 = llvm.icmp "eq" %3, %2 : vector<2xi64> + llvm.return %4 : vector<2xi1> + } + llvm.func @sdiv_icmp1(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(5 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.sdiv %arg0, %0 : i64 + %3 = llvm.icmp "eq" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @sdiv_icmp1_vec(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.sdiv %arg0, %0 : vector<2xi64> + %4 = llvm.icmp "eq" %3, %2 : vector<2xi64> + llvm.return %4 : vector<2xi1> + } + llvm.func @sdiv_icmp2(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(5 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.sdiv %arg0, %0 : i64 + %3 = llvm.icmp "eq" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @sdiv_icmp2_vec(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<1> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sdiv %arg0, %0 : vector<2xi64> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi1> + } + llvm.func @sdiv_icmp3(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(5 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.sdiv %arg0, %0 : i64 + %3 = llvm.icmp "eq" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @sdiv_icmp3_vec(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sdiv %arg0, %0 : vector<2xi64> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi1> + } + llvm.func @sdiv_icmp4(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(-5 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.sdiv %arg0, %0 : i64 + %3 = llvm.icmp "eq" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @sdiv_icmp4_vec(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-5> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.sdiv %arg0, %0 : vector<2xi64> + %4 = llvm.icmp "eq" %3, %2 : vector<2xi64> + llvm.return %4 : vector<2xi1> + } + llvm.func @sdiv_icmp5(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(-5 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.sdiv %arg0, %0 : i64 + %3 = llvm.icmp "eq" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @sdiv_icmp5_vec(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-5> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<1> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sdiv %arg0, %0 : vector<2xi64> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi1> + } + llvm.func @sdiv_icmp6(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(-5 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.sdiv %arg0, %0 : i64 + %3 = llvm.icmp "eq" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @sdiv_icmp6_vec(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-5> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sdiv %arg0, %0 : vector<2xi64> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi1> + } + llvm.func @mul_of_udiv(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(12 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.udiv %arg0, %0 : i8 + %3 = llvm.mul %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @mul_of_sdiv(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(12 : i8) : i8 + %1 = llvm.mlir.constant(-6 : i8) : i8 + %2 = llvm.sdiv %arg0, %0 : i8 + %3 = llvm.mul %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @mul_of_sdiv_non_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[6, -12]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %2 = llvm.sdiv %arg0, %0 : vector<2xi8> + %3 = llvm.mul %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @mul_of_sdiv_fail_missing_exact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(12 : i8) : i8 + %1 = llvm.mlir.constant(-6 : i8) : i8 + %2 = llvm.sdiv %arg0, %0 : i8 + %3 = llvm.mul %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @mul_of_udiv_fail_bad_remainder(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(11 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.udiv %arg0, %0 : i8 + %3 = llvm.mul %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @mul_of_sdiv_fail_ub(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(-6 : i8) : i8 + %2 = llvm.sdiv %arg0, %0 : i8 + %3 = llvm.mul %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @mul_of_sdiv_fail_ub_non_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[-6, -12]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %2 = llvm.sdiv %arg0, %0 : vector<2xi8> + %3 = llvm.mul %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/exp2-1.ll.mlir b/test/LLVMDialect/InstCombine/exp2-1.ll.mlir index 4af3b7812..143a4db36 100644 --- a/test/LLVMDialect/InstCombine/exp2-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/exp2-1.ll.mlir @@ -1,71 +1,85 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp2", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp2f", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.sitofp"(%arg0) : (i32) -> f64 - %1 = "llvm.call"(%0) {callee = @exp2, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.sitofp"(%arg0) : (i16) -> f64 - %1 = "llvm.call"(%0) {callee = @exp2, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.sitofp"(%arg0) : (i8) -> f64 - %1 = "llvm.call"(%0) {callee = @exp2, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.sitofp"(%arg0) : (i32) -> f32 - %1 = "llvm.call"(%0) {callee = @exp2f, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.uitofp"(%arg0) : (i32) -> f64 - %1 = "llvm.call"(%0) {callee = @exp2, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.uitofp"(%arg0) : (i16) -> f64 - %1 = "llvm.call"(%0) {callee = @exp2, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.uitofp"(%arg0) : (i8) -> f64 - %1 = "llvm.call"(%0) {callee = @exp2, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.uitofp"(%arg0) : (i8) -> f32 - %1 = "llvm.call"(%0) {callee = @exp2f, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify8", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.exp2.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.exp2.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.uitofp"(%arg0) : (i8) -> f64 - %1 = "llvm.call"(%0) {callee = @llvm.exp2.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify9", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.uitofp"(%arg0) : (i8) -> f32 - %1 = "llvm.call"(%0) {callee = @llvm.exp2.f32, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify10", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @exp2(f64) -> f64 + llvm.func @exp2f(f32) -> f32 + llvm.func @exp2l(f128) -> f128 + llvm.func @test_simplify1(%arg0: i32) -> f64 { + %0 = llvm.sitofp %arg0 : i32 to f64 + %1 = llvm.call @exp2(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify2(%arg0: i16 {llvm.signext}) -> f64 { + %0 = llvm.sitofp %arg0 : i16 to f64 + %1 = llvm.call @exp2(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify3(%arg0: i8 {llvm.signext}) -> f64 { + %0 = llvm.sitofp %arg0 : i8 to f64 + %1 = llvm.call @exp2(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify4(%arg0: i32) -> f32 { + %0 = llvm.sitofp %arg0 : i32 to f32 + %1 = llvm.call @exp2f(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_no_simplify1(%arg0: i32) -> f64 { + %0 = llvm.uitofp %arg0 : i32 to f64 + %1 = llvm.call @exp2(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify6(%arg0: i16 {llvm.zeroext}) -> f64 { + %0 = llvm.uitofp %arg0 : i16 to f64 + %1 = llvm.call @exp2(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify7(%arg0: i8 {llvm.zeroext}) -> f64 { + %0 = llvm.uitofp %arg0 : i8 to f64 + %1 = llvm.call @exp2(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify8(%arg0: i8 {llvm.zeroext}) -> f32 { + %0 = llvm.uitofp %arg0 : i8 to f32 + %1 = llvm.call @exp2f(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify9(%arg0: i8 {llvm.zeroext}) -> f64 { + %0 = llvm.uitofp %arg0 : i8 to f64 + %1 = llvm.intr.exp2(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify10(%arg0: i8 {llvm.zeroext}) -> f32 { + %0 = llvm.uitofp %arg0 : i8 to f32 + %1 = llvm.intr.exp2(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @sitofp_scalar_intrinsic_with_FMF(%arg0: i8) -> f32 { + %0 = llvm.sitofp %arg0 : i8 to f32 + %1 = llvm.intr.exp2(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @sitofp_vector_intrinsic_with_FMF(%arg0: vector<2xi8>) -> vector<2xf32> { + %0 = llvm.sitofp %arg0 : vector<2xi8> to vector<2xf32> + %1 = llvm.intr.exp2(%0) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @test_readonly_exp2_f64_of_sitofp(%arg0: i32) -> f64 { + %0 = llvm.sitofp %arg0 : i32 to f64 + %1 = llvm.call @exp2(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_readonly_exp2f_f32_of_sitofp(%arg0: i32) -> f32 { + %0 = llvm.sitofp %arg0 : i32 to f32 + %1 = llvm.call @exp2f(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_readonly_exp2l_fp128_of_sitofp(%arg0: i32) -> f128 { + %0 = llvm.sitofp %arg0 : i32 to f128 + %1 = llvm.call @exp2l(%0) : (f128) -> f128 + llvm.return %1 : f128 + } + llvm.func @test_readonly_exp2f_f32_of_sitofp_flags(%arg0: i32) -> f32 { + %0 = llvm.sitofp %arg0 : i32 to f32 + %1 = llvm.call @exp2f(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/exp2-2.ll.mlir b/test/LLVMDialect/InstCombine/exp2-2.ll.mlir index 15a735620..830d1bbee 100644 --- a/test/LLVMDialect/InstCombine/exp2-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/exp2-2.ll.mlir @@ -1,11 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.sitofp"(%arg0) : (i32) -> f64 - %1 = "llvm.call"(%0) {callee = @exp2, fastmathFlags = #llvm.fastmath<>} : (f64) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @exp2(f64) -> f32 + llvm.func @test_no_simplify1(%arg0: i32) -> f32 { + %0 = llvm.sitofp %arg0 : i32 to f64 + %1 = llvm.call @exp2(%0) : (f64) -> f32 + llvm.return %1 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/exp2-to-ldexp.ll.mlir b/test/LLVMDialect/InstCombine/exp2-to-ldexp.ll.mlir new file mode 100644 index 000000000..55bc49467 --- /dev/null +++ b/test/LLVMDialect/InstCombine/exp2-to-ldexp.ll.mlir @@ -0,0 +1,42 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @exp2_f32_sitofp_i8(%arg0: i8) -> f32 { + %0 = llvm.sitofp %arg0 : i8 to f32 + %1 = llvm.intr.exp2(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @exp2_f32_sitofp_i8_flags(%arg0: i8) -> f32 { + %0 = llvm.sitofp %arg0 : i8 to f32 + %1 = llvm.intr.exp2(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @exp2_v2f32_sitofp_v2i8(%arg0: vector<2xi8>) -> vector<2xf32> { + %0 = llvm.sitofp %arg0 : vector<2xi8> to vector<2xf32> + %1 = llvm.intr.exp2(%0) : (vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @exp2_f32_uitofp_i8(%arg0: i8) -> f32 { + %0 = llvm.uitofp %arg0 : i8 to f32 + %1 = llvm.intr.exp2(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @exp2_f16_sitofp_i8(%arg0: i8) -> f16 { + %0 = llvm.sitofp %arg0 : i8 to f16 + %1 = llvm.intr.exp2(%0) : (f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @exp2_f64_sitofp_i8(%arg0: i8) -> f64 { + %0 = llvm.sitofp %arg0 : i8 to f64 + %1 = llvm.intr.exp2(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @exp2_fp128_sitofp_i8(%arg0: i8) -> f128 { + %0 = llvm.sitofp %arg0 : i8 to f128 + %1 = llvm.intr.exp2(%0) : (f128) -> f128 + llvm.return %1 : f128 + } + llvm.func @exp2_nxv4f32_sitofp_i8(%arg0: !llvm.vec) -> !llvm.vec { + %0 = llvm.sitofp %arg0 : !llvm.vec to !llvm.vec + %1 = llvm.intr.exp2(%0) : (!llvm.vec) -> !llvm.vec + llvm.return %1 : !llvm.vec + } +} diff --git a/test/LLVMDialect/InstCombine/extract-select-agg.ll.mlir b/test/LLVMDialect/InstCombine/extract-select-agg.ll.mlir new file mode 100644 index 000000000..62b887f3a --- /dev/null +++ b/test/LLVMDialect/InstCombine/extract-select-agg.ll.mlir @@ -0,0 +1,65 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_select_agg_constant_agg(%arg0: i64, %arg1: i1) -> i64 { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.undef : !llvm.struct<(i64, i64)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<(i64, i64)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<(i64, i64)> + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.constant(0 : i64) : i64 + %7 = llvm.mlir.undef : !llvm.struct<(i64, i64)> + %8 = llvm.insertvalue %6, %7[0] : !llvm.struct<(i64, i64)> + %9 = llvm.insertvalue %5, %8[1] : !llvm.struct<(i64, i64)> + %10 = llvm.select %arg1, %4, %9 : i1, !llvm.struct<(i64, i64)> + %11 = llvm.extractvalue %10[0] : !llvm.struct<(i64, i64)> + llvm.return %11 : i64 + } + llvm.func @test_select_agg_constant_agg_multiuse(%arg0: i64, %arg1: i1) { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.undef : !llvm.struct<(i64, i64)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<(i64, i64)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<(i64, i64)> + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.constant(0 : i64) : i64 + %7 = llvm.mlir.undef : !llvm.struct<(i64, i64)> + %8 = llvm.insertvalue %6, %7[0] : !llvm.struct<(i64, i64)> + %9 = llvm.insertvalue %5, %8[1] : !llvm.struct<(i64, i64)> + %10 = llvm.select %arg1, %4, %9 : i1, !llvm.struct<(i64, i64)> + %11 = llvm.extractvalue %10[0] : !llvm.struct<(i64, i64)> + llvm.call @use(%11) : (i64) -> () + %12 = llvm.extractvalue %10[1] : !llvm.struct<(i64, i64)> + llvm.call @use(%12) : (i64) -> () + llvm.return + } + llvm.func @test_select_agg_constant(%arg0: i64, %arg1: i1) -> i64 { + %0 = llvm.mlir.poison : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.undef : !llvm.struct<(i64, i64)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<(i64, i64)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<(i64, i64)> + %5 = llvm.mlir.constant(0 : i64) : i64 + %6 = llvm.mlir.undef : !llvm.struct<(i64, i64)> + %7 = llvm.insertvalue %5, %6[0] : !llvm.struct<(i64, i64)> + %8 = llvm.insertvalue %0, %7[1] : !llvm.struct<(i64, i64)> + %9 = llvm.insertvalue %arg0, %4[1] : !llvm.struct<(i64, i64)> + %10 = llvm.insertvalue %arg0, %8[1] : !llvm.struct<(i64, i64)> + %11 = llvm.select %arg1, %9, %10 : i1, !llvm.struct<(i64, i64)> + %12 = llvm.extractvalue %11[0] : !llvm.struct<(i64, i64)> + llvm.return %12 : i64 + } + llvm.func @test_select_agg_multiuse(%arg0: i1, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64) { + %0 = llvm.mlir.poison : !llvm.struct<(i64, i64)> + %1 = llvm.insertvalue %arg1, %0[0] : !llvm.struct<(i64, i64)> + %2 = llvm.insertvalue %arg2, %1[1] : !llvm.struct<(i64, i64)> + %3 = llvm.insertvalue %arg3, %0[0] : !llvm.struct<(i64, i64)> + %4 = llvm.insertvalue %arg4, %3[1] : !llvm.struct<(i64, i64)> + %5 = llvm.select %arg0, %2, %4 : i1, !llvm.struct<(i64, i64)> + %6 = llvm.extractvalue %5[0] : !llvm.struct<(i64, i64)> + llvm.call @use(%6) : (i64) -> () + %7 = llvm.extractvalue %5[1] : !llvm.struct<(i64, i64)> + llvm.call @use(%7) : (i64) -> () + llvm.return + } + llvm.func @use(i64) +} diff --git a/test/LLVMDialect/InstCombine/extractelement-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/extractelement-inseltpoison.ll.mlir new file mode 100644 index 000000000..67c02d14a --- /dev/null +++ b/test/LLVMDialect/InstCombine/extractelement-inseltpoison.ll.mlir @@ -0,0 +1,200 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @extractelement_out_of_range(%arg0: vector<2xi32>) -> i32 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.extractelement %arg0[%0 : i8] : vector<2xi32> + llvm.return %1 : i32 + } + llvm.func @extractelement_type_out_of_range(%arg0: vector<2xi32>) -> i32 { + %0 = llvm.mlir.constant(0 : i128) : i128 + %1 = llvm.extractelement %arg0[%0 : i128] : vector<2xi32> + llvm.return %1 : i32 + } + llvm.func @bitcasted_inselt_equal_num_elts(%arg0: f32) -> i32 { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %3 = llvm.bitcast %2 : vector<4xf32> to vector<4xi32> + %4 = llvm.extractelement %3[%1 : i32] : vector<4xi32> + llvm.return %4 : i32 + } + llvm.func @test2(%arg0: i64) -> i64 { + %0 = llvm.mlir.poison : vector<8xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1, 2, 3, 4, 5, 6, 7]> : vector<8xi64>) : vector<8xi64> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<8xi64> + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0, 0, 0, 0, 0] : vector<8xi64> + %5 = llvm.add %4, %2 : vector<8xi64> + %6 = llvm.extractelement %5[%1 : i32] : vector<8xi64> + llvm.return %6 : i64 + } + llvm.func @bitcasted_inselt_wide_source_zero_elt(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %arg0, %1[%2 : i32] : vector<2xi64> + %4 = llvm.bitcast %3 : vector<2xi64> to vector<4xi32> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xi32> + llvm.return %5 : i32 + } + llvm.func @bitcasted_inselt_wide_source_modulo_elt(%arg0: i64) -> i16 { + %0 = llvm.mlir.poison : vector<2xi64> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi64> + %4 = llvm.bitcast %3 : vector<2xi64> to vector<8xi16> + %5 = llvm.extractelement %4[%2 : i32] : vector<8xi16> + llvm.return %5 : i16 + } + llvm.func @bitcasted_inselt_wide_source_not_modulo_elt(%arg0: i64) -> i32 { + %0 = llvm.mlir.poison : vector<2xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi64> + %4 = llvm.bitcast %3 : vector<2xi64> to vector<4xi32> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xi32> + llvm.return %5 : i32 + } + llvm.func @bitcasted_inselt_wide_source_not_modulo_elt_not_half(%arg0: i32) -> i8 { + %0 = llvm.mlir.poison : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi32> + %4 = llvm.bitcast %3 : vector<2xi32> to vector<8xi8> + %5 = llvm.extractelement %4[%2 : i32] : vector<8xi8> + llvm.return %5 : i8 + } + llvm.func @bitcasted_inselt_wide_source_not_modulo_elt_not_half_weird_types(%arg0: i15) -> i3 { + %0 = llvm.mlir.poison : vector<3xi15> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<3xi15> + %4 = llvm.bitcast %3 : vector<3xi15> to vector<15xi3> + %5 = llvm.extractelement %4[%2 : i32] : vector<15xi3> + llvm.return %5 : i3 + } + llvm.func @bitcasted_inselt_wide_source_wrong_insert(%arg0: vector<2xi32>, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg1, %arg0[%0 : i32] : vector<2xi32> + %3 = llvm.bitcast %2 : vector<2xi32> to vector<8xi8> + %4 = llvm.extractelement %3[%1 : i32] : vector<8xi8> + llvm.return %4 : i8 + } + llvm.func @use(vector<8xi8>) + llvm.func @bitcasted_inselt_wide_source_uses(%arg0: i32) -> i8 { + %0 = llvm.mlir.poison : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi32> + %4 = llvm.bitcast %3 : vector<2xi32> to vector<8xi8> + llvm.call @use(%4) : (vector<8xi8>) -> () + %5 = llvm.extractelement %4[%2 : i32] : vector<8xi8> + llvm.return %5 : i8 + } + llvm.func @bitcasted_inselt_to_FP(%arg0: i64) -> f32 { + %0 = llvm.mlir.poison : vector<2xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi64> + %4 = llvm.bitcast %3 : vector<2xi64> to vector<4xf32> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xf32> + llvm.return %5 : f32 + } + llvm.func @use_v2i128(vector<2xi128>) + llvm.func @use_v8f32(vector<8xf32>) + llvm.func @bitcasted_inselt_to_FP_uses(%arg0: i128) -> f32 { + %0 = llvm.mlir.poison : vector<2xi128> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi128> + llvm.call @use_v2i128(%3) : (vector<2xi128>) -> () + %4 = llvm.bitcast %3 : vector<2xi128> to vector<8xf32> + %5 = llvm.extractelement %4[%2 : i32] : vector<8xf32> + llvm.return %5 : f32 + } + llvm.func @bitcasted_inselt_to_FP_uses2(%arg0: i128) -> f32 { + %0 = llvm.mlir.poison : vector<2xi128> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi128> + %4 = llvm.bitcast %3 : vector<2xi128> to vector<8xf32> + llvm.call @use_v8f32(%4) : (vector<8xf32>) -> () + %5 = llvm.extractelement %4[%2 : i32] : vector<8xf32> + llvm.return %5 : f32 + } + llvm.func @bitcasted_inselt_from_FP(%arg0: f64) -> i32 { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf64> + %4 = llvm.bitcast %3 : vector<2xf64> to vector<4xi32> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xi32> + llvm.return %5 : i32 + } + llvm.func @use_v2f64(vector<2xf64>) + llvm.func @use_v8i16(vector<8xi16>) + llvm.func @bitcasted_inselt_from_FP_uses(%arg0: f64) -> i16 { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf64> + llvm.call @use_v2f64(%3) : (vector<2xf64>) -> () + %4 = llvm.bitcast %3 : vector<2xf64> to vector<8xi16> + %5 = llvm.extractelement %4[%2 : i32] : vector<8xi16> + llvm.return %5 : i16 + } + llvm.func @bitcasted_inselt_from_FP_uses2(%arg0: f64) -> i16 { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf64> + %4 = llvm.bitcast %3 : vector<2xf64> to vector<8xi16> + llvm.call @use_v8i16(%4) : (vector<8xi16>) -> () + %5 = llvm.extractelement %4[%2 : i32] : vector<8xi16> + llvm.return %5 : i16 + } + llvm.func @bitcasted_inselt_to_and_from_FP(%arg0: f64) -> f32 { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf64> + %4 = llvm.bitcast %3 : vector<2xf64> to vector<4xf32> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xf32> + llvm.return %5 : f32 + } + llvm.func @bitcasted_inselt_to_and_from_FP_uses(%arg0: f64) -> f32 { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf64> + llvm.call @use_v2f64(%3) : (vector<2xf64>) -> () + %4 = llvm.bitcast %3 : vector<2xf64> to vector<4xf32> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xf32> + llvm.return %5 : f32 + } + llvm.func @use_v4f32(vector<4xf32>) + llvm.func @bitcasted_inselt_to_and_from_FP_uses2(%arg0: f64) -> f32 { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf64> + %4 = llvm.bitcast %3 : vector<2xf64> to vector<4xf32> + llvm.call @use_v4f32(%4) : (vector<4xf32>) -> () + %5 = llvm.extractelement %4[%2 : i32] : vector<4xf32> + llvm.return %5 : f32 + } + llvm.func @invalid_extractelement(%arg0: vector<2xf64>, %arg1: vector<4xf64>, %arg2: !llvm.ptr) -> vector<4xf64> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.extractelement %arg0[%0 : i32] : vector<2xf64> + %6 = llvm.insertelement %5, %arg1[%1 : i32] : vector<4xf64> + %7 = llvm.extractelement %6[%2 : i32] : vector<4xf64> + llvm.store %7, %arg2 {alignment = 8 : i64} : f64, !llvm.ptr + %8 = llvm.extractelement %arg0[%3 : i32] : vector<2xf64> + %9 = llvm.insertelement %8, %6[%4 : i64] : vector<4xf64> + llvm.return %9 : vector<4xf64> + } +} diff --git a/test/LLVMDialect/InstCombine/extractelement.ll.mlir b/test/LLVMDialect/InstCombine/extractelement.ll.mlir new file mode 100644 index 000000000..15a216414 --- /dev/null +++ b/test/LLVMDialect/InstCombine/extractelement.ll.mlir @@ -0,0 +1,457 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @extractelement_out_of_range(%arg0: vector<2xi32>) -> i32 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.extractelement %arg0[%0 : i8] : vector<2xi32> + llvm.return %1 : i32 + } + llvm.func @extractelement_type_out_of_range(%arg0: vector<2xi32>) -> i32 { + %0 = llvm.mlir.constant(0 : i128) : i128 + %1 = llvm.extractelement %arg0[%0 : i128] : vector<2xi32> + llvm.return %1 : i32 + } + llvm.func @bitcasted_inselt_equal_num_elts(%arg0: f32) -> i32 { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %3 = llvm.bitcast %2 : vector<4xf32> to vector<4xi32> + %4 = llvm.extractelement %3[%1 : i32] : vector<4xi32> + llvm.return %4 : i32 + } + llvm.func @test2(%arg0: i64) -> i64 { + %0 = llvm.mlir.undef : vector<8xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1, 2, 3, 4, 5, 6, 7]> : vector<8xi64>) : vector<8xi64> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<8xi64> + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0, 0, 0, 0, 0] : vector<8xi64> + %5 = llvm.add %4, %2 : vector<8xi64> + %6 = llvm.extractelement %5[%1 : i32] : vector<8xi64> + llvm.return %6 : i64 + } + llvm.func @bitcasted_inselt_wide_source_zero_elt(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %arg0, %1[%2 : i32] : vector<2xi64> + %4 = llvm.bitcast %3 : vector<2xi64> to vector<4xi32> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xi32> + llvm.return %5 : i32 + } + llvm.func @bitcasted_inselt_wide_source_modulo_elt(%arg0: i64) -> i16 { + %0 = llvm.mlir.undef : vector<2xi64> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi64> + %4 = llvm.bitcast %3 : vector<2xi64> to vector<8xi16> + %5 = llvm.extractelement %4[%2 : i32] : vector<8xi16> + llvm.return %5 : i16 + } + llvm.func @bitcasted_inselt_wide_source_not_modulo_elt(%arg0: i64) -> i32 { + %0 = llvm.mlir.undef : vector<2xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi64> + %4 = llvm.bitcast %3 : vector<2xi64> to vector<4xi32> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xi32> + llvm.return %5 : i32 + } + llvm.func @bitcasted_inselt_wide_source_not_modulo_elt_not_half(%arg0: i32) -> i8 { + %0 = llvm.mlir.undef : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi32> + %4 = llvm.bitcast %3 : vector<2xi32> to vector<8xi8> + %5 = llvm.extractelement %4[%2 : i32] : vector<8xi8> + llvm.return %5 : i8 + } + llvm.func @bitcasted_inselt_wide_source_not_modulo_elt_not_half_weird_types(%arg0: i15) -> i3 { + %0 = llvm.mlir.undef : vector<3xi15> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<3xi15> + %4 = llvm.bitcast %3 : vector<3xi15> to vector<15xi3> + %5 = llvm.extractelement %4[%2 : i32] : vector<15xi3> + llvm.return %5 : i3 + } + llvm.func @bitcasted_inselt_wide_source_wrong_insert(%arg0: vector<2xi32>, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg1, %arg0[%0 : i32] : vector<2xi32> + %3 = llvm.bitcast %2 : vector<2xi32> to vector<8xi8> + %4 = llvm.extractelement %3[%1 : i32] : vector<8xi8> + llvm.return %4 : i8 + } + llvm.func @use(vector<8xi8>) + llvm.func @bitcasted_inselt_wide_source_uses(%arg0: i32) -> i8 { + %0 = llvm.mlir.undef : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi32> + %4 = llvm.bitcast %3 : vector<2xi32> to vector<8xi8> + llvm.call @use(%4) : (vector<8xi8>) -> () + %5 = llvm.extractelement %4[%2 : i32] : vector<8xi8> + llvm.return %5 : i8 + } + llvm.func @bitcasted_inselt_to_FP(%arg0: i64) -> f32 { + %0 = llvm.mlir.undef : vector<2xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi64> + %4 = llvm.bitcast %3 : vector<2xi64> to vector<4xf32> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xf32> + llvm.return %5 : f32 + } + llvm.func @use_v2i128(vector<2xi128>) + llvm.func @use_v8f32(vector<8xf32>) + llvm.func @bitcasted_inselt_to_FP_uses(%arg0: i128) -> f32 { + %0 = llvm.mlir.undef : vector<2xi128> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi128> + llvm.call @use_v2i128(%3) : (vector<2xi128>) -> () + %4 = llvm.bitcast %3 : vector<2xi128> to vector<8xf32> + %5 = llvm.extractelement %4[%2 : i32] : vector<8xf32> + llvm.return %5 : f32 + } + llvm.func @bitcasted_inselt_to_FP_uses2(%arg0: i128) -> f32 { + %0 = llvm.mlir.undef : vector<2xi128> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi128> + %4 = llvm.bitcast %3 : vector<2xi128> to vector<8xf32> + llvm.call @use_v8f32(%4) : (vector<8xf32>) -> () + %5 = llvm.extractelement %4[%2 : i32] : vector<8xf32> + llvm.return %5 : f32 + } + llvm.func @bitcasted_inselt_from_FP(%arg0: f64) -> i32 { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf64> + %4 = llvm.bitcast %3 : vector<2xf64> to vector<4xi32> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xi32> + llvm.return %5 : i32 + } + llvm.func @use_v2f64(vector<2xf64>) + llvm.func @use_v8i16(vector<8xi16>) + llvm.func @bitcasted_inselt_from_FP_uses(%arg0: f64) -> i16 { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf64> + llvm.call @use_v2f64(%3) : (vector<2xf64>) -> () + %4 = llvm.bitcast %3 : vector<2xf64> to vector<8xi16> + %5 = llvm.extractelement %4[%2 : i32] : vector<8xi16> + llvm.return %5 : i16 + } + llvm.func @bitcasted_inselt_from_FP_uses2(%arg0: f64) -> i16 { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf64> + %4 = llvm.bitcast %3 : vector<2xf64> to vector<8xi16> + llvm.call @use_v8i16(%4) : (vector<8xi16>) -> () + %5 = llvm.extractelement %4[%2 : i32] : vector<8xi16> + llvm.return %5 : i16 + } + llvm.func @bitcasted_inselt_to_and_from_FP(%arg0: f64) -> f32 { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf64> + %4 = llvm.bitcast %3 : vector<2xf64> to vector<4xf32> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xf32> + llvm.return %5 : f32 + } + llvm.func @bitcasted_inselt_to_and_from_FP_uses(%arg0: f64) -> f32 { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf64> + llvm.call @use_v2f64(%3) : (vector<2xf64>) -> () + %4 = llvm.bitcast %3 : vector<2xf64> to vector<4xf32> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xf32> + llvm.return %5 : f32 + } + llvm.func @use_v4f32(vector<4xf32>) + llvm.func @bitcasted_inselt_to_and_from_FP_uses2(%arg0: f64) -> f32 { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf64> + %4 = llvm.bitcast %3 : vector<2xf64> to vector<4xf32> + llvm.call @use_v4f32(%4) : (vector<4xf32>) -> () + %5 = llvm.extractelement %4[%2 : i32] : vector<4xf32> + llvm.return %5 : f32 + } + llvm.func @invalid_extractelement(%arg0: vector<2xf64>, %arg1: vector<4xf64>, %arg2: !llvm.ptr) -> vector<4xf64> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.extractelement %arg0[%0 : i32] : vector<2xf64> + %6 = llvm.insertelement %5, %arg1[%1 : i32] : vector<4xf64> + %7 = llvm.extractelement %6[%2 : i32] : vector<4xf64> + llvm.store %7, %arg2 {alignment = 8 : i64} : f64, !llvm.ptr + %8 = llvm.extractelement %arg0[%3 : i32] : vector<2xf64> + %9 = llvm.insertelement %8, %6[%4 : i64] : vector<4xf64> + llvm.return %9 : vector<4xf64> + } + llvm.func @bitcast_scalar_supported_type_index0(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i32 to vector<4xi8> + %2 = llvm.extractelement %1[%0 : i8] : vector<4xi8> + llvm.return %2 : i8 + } + llvm.func @bitcast_scalar_supported_type_index2(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.bitcast %arg0 : i32 to vector<4xi8> + %2 = llvm.extractelement %1[%0 : i64] : vector<4xi8> + llvm.return %2 : i8 + } + llvm.func @bitcast_scalar_legal_type_index3(%arg0: i64) -> i4 { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.bitcast %arg0 : i64 to vector<16xi4> + %2 = llvm.extractelement %1[%0 : i64] : vector<16xi4> + llvm.return %2 : i4 + } + llvm.func @bitcast_scalar_illegal_type_index1(%arg0: i128) -> i8 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.bitcast %arg0 : i128 to vector<16xi8> + %2 = llvm.extractelement %1[%0 : i64] : vector<16xi8> + llvm.return %2 : i8 + } + llvm.func @bitcast_fp_index0(%arg0: f32) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : f32 to vector<4xi8> + %2 = llvm.extractelement %1[%0 : i8] : vector<4xi8> + llvm.return %2 : i8 + } + llvm.func @bitcast_fp16vec_index0(%arg0: i32) -> f16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i32 to vector<2xf16> + %2 = llvm.extractelement %1[%0 : i8] : vector<2xf16> + llvm.return %2 : f16 + } + llvm.func @bitcast_fp16vec_index1(%arg0: i32) -> f16 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.bitcast %arg0 : i32 to vector<2xf16> + %2 = llvm.extractelement %1[%0 : i8] : vector<2xf16> + llvm.return %2 : f16 + } + llvm.func @bitcast_bfp16vec_index0(%arg0: i32) -> bf16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i32 to vector<2xbf16> + %2 = llvm.extractelement %1[%0 : i8] : vector<2xbf16> + llvm.return %2 : bf16 + } + llvm.func @bitcast_bfp16vec_index1(%arg0: i32) -> bf16 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.bitcast %arg0 : i32 to vector<2xbf16> + %2 = llvm.extractelement %1[%0 : i8] : vector<2xbf16> + llvm.return %2 : bf16 + } + llvm.func @bitcast_fp32vec_index0(%arg0: i64) -> f32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i64 to vector<2xf32> + %2 = llvm.extractelement %1[%0 : i8] : vector<2xf32> + llvm.return %2 : f32 + } + llvm.func @bitcast_fp32vec_index1(%arg0: i64) -> f32 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.bitcast %arg0 : i64 to vector<2xf32> + %2 = llvm.extractelement %1[%0 : i8] : vector<2xf32> + llvm.return %2 : f32 + } + llvm.func @bitcast_fp64vec64_index0(%arg0: i64) -> f64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i64 to vector<1xf64> + %2 = llvm.extractelement %1[%0 : i8] : vector<1xf64> + llvm.return %2 : f64 + } + llvm.func @bitcast_fp64vec_index0(%arg0: i128) -> f64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i128 to vector<2xf64> + %2 = llvm.extractelement %1[%0 : i8] : vector<2xf64> + llvm.return %2 : f64 + } + llvm.func @bitcast_fp64vec_index1(%arg0: i128) -> f64 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.bitcast %arg0 : i128 to vector<2xf64> + %2 = llvm.extractelement %1[%0 : i8] : vector<2xf64> + llvm.return %2 : f64 + } + llvm.func @bitcast_x86fp80vec_index0(%arg0: i160) -> f80 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i160 to vector<2xf80> + %2 = llvm.extractelement %1[%0 : i8] : vector<2xf80> + llvm.return %2 : f80 + } + llvm.func @bitcast_x86fp80vec_index1(%arg0: i160) -> f80 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.bitcast %arg0 : i160 to vector<2xf80> + %2 = llvm.extractelement %1[%0 : i8] : vector<2xf80> + llvm.return %2 : f80 + } + llvm.func @bitcast_fp128vec_index0(%arg0: i256) -> f128 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i256 to vector<2xf128> + %2 = llvm.extractelement %1[%0 : i8] : vector<2xf128> + llvm.return %2 : f128 + } + llvm.func @bitcast_fp128vec_index1(%arg0: i256) -> f128 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.bitcast %arg0 : i256 to vector<2xf128> + %2 = llvm.extractelement %1[%0 : i8] : vector<2xf128> + llvm.return %2 : f128 + } + llvm.func @bitcast_ppcfp128vec_index0(%arg0: i256) -> !llvm.ppc_fp128 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.bitcast %arg0 : i256 to !llvm.vec<2 x ppc_fp128> + %2 = llvm.extractelement %1[%0 : i8] : !llvm.vec<2 x ppc_fp128> + llvm.return %2 : !llvm.ppc_fp128 + } + llvm.func @bitcast_ppcfp128vec_index1(%arg0: i256) -> !llvm.ppc_fp128 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.bitcast %arg0 : i256 to !llvm.vec<2 x ppc_fp128> + %2 = llvm.extractelement %1[%0 : i8] : !llvm.vec<2 x ppc_fp128> + llvm.return %2 : !llvm.ppc_fp128 + } + llvm.func @bitcast_scalar_index_variable(%arg0: i32, %arg1: i64) -> i8 { + %0 = llvm.bitcast %arg0 : i32 to vector<4xi8> + %1 = llvm.extractelement %0[%arg1 : i64] : vector<4xi8> + llvm.return %1 : i8 + } + llvm.func @bitcast_scalar_index0_use(%arg0: i64) -> i8 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.bitcast %arg0 : i64 to vector<8xi8> + llvm.call @use(%1) : (vector<8xi8>) -> () + %2 = llvm.extractelement %1[%0 : i64] : vector<8xi8> + llvm.return %2 : i8 + } + llvm.func @bit_extract_cmp(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.bitcast %arg0 : i64 to vector<2xf32> + %3 = llvm.extractelement %2[%0 : i8] : vector<2xf32> + %4 = llvm.fcmp "oeq" %3, %1 : f32 + llvm.return %4 : i1 + } + llvm.func @extelt_select_const_operand_vector(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7]> : vector<3xi32>) : vector<3xi32> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, vector<3xi32> + %4 = llvm.extractelement %3[%2 : i32] : vector<3xi32> + llvm.return %4 : i32 + } + llvm.func @extelt_select_const_operand_vector_float(%arg0: i1) -> f32 { + %0 = llvm.mlir.constant(dense<[2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00]> : vector<3xf32>) : vector<3xf32> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, vector<3xf32> + %4 = llvm.extractelement %3[%2 : i32] : vector<3xf32> + llvm.return %4 : f32 + } + llvm.func @extelt_vecselect_const_operand_vector(%arg0: vector<3xi1>) -> i32 { + %0 = llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7]> : vector<3xi32>) : vector<3xi32> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : vector<3xi1>, vector<3xi32> + %4 = llvm.extractelement %3[%2 : i32] : vector<3xi32> + llvm.return %4 : i32 + } + llvm.func @extelt_select_const_operand_extractelt_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7]> : vector<3xi32>) : vector<3xi32> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.select %arg0, %0, %1 : i1, vector<3xi32> + %5 = llvm.extractelement %4[%2 : i32] : vector<3xi32> + %6 = llvm.mul %5, %2 : i32 + %7 = llvm.mul %5, %3 : i32 + %8 = llvm.mul %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @extelt_select_const_operand_select_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7]> : vector<3xi32>) : vector<3xi32> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.select %arg0, %0, %1 : i1, vector<3xi32> + %5 = llvm.extractelement %4[%2 : i32] : vector<3xi32> + %6 = llvm.extractelement %4[%3 : i32] : vector<3xi32> + %7 = llvm.mul %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @extelt_select_const_operand_vector_cond_index(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi32>) : vector<3xi32> + %3 = llvm.mlir.constant(dense<[5, 6, 7]> : vector<3xi32>) : vector<3xi32> + %4 = llvm.select %arg0, %0, %1 : i1, i32 + %5 = llvm.select %arg0, %2, %3 : i1, vector<3xi32> + %6 = llvm.extractelement %5[%4 : i32] : vector<3xi32> + llvm.return %6 : i32 + } + llvm.func @extelt_select_const_operand_vector_var_index(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7]> : vector<3xi32>) : vector<3xi32> + %2 = llvm.select %arg0, %0, %1 : i1, vector<3xi32> + %3 = llvm.extractelement %2[%arg1 : i32] : vector<3xi32> + llvm.return %3 : i32 + } + llvm.func @extelt_select_var_const_operand_vector(%arg0: i1, %arg1: vector<3xi32>) -> i32 { + %0 = llvm.mlir.constant(dense<[5, 6, 7]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.select %arg0, %arg1, %0 : i1, vector<3xi32> + %3 = llvm.extractelement %2[%1 : i32] : vector<3xi32> + llvm.return %3 : i32 + } + llvm.func @extelt_select_const_var_operand_vector(%arg0: i1, %arg1: vector<3xi32>) -> i32 { + %0 = llvm.mlir.constant(dense<[5, 6, 7]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.select %arg0, %0, %arg1 : i1, vector<3xi32> + %3 = llvm.extractelement %2[%1 : i32] : vector<3xi32> + llvm.return %3 : i32 + } + llvm.func @use_select(vector<3xi32>) + llvm.func @extelt_select_const_var_operands_vector_extra_use(%arg0: i1, %arg1: vector<3xi32>) -> i32 { + %0 = llvm.mlir.constant(dense<[42, 5, 4]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.select %arg0, %0, %arg1 : i1, vector<3xi32> + llvm.call @use_select(%2) : (vector<3xi32>) -> () + %3 = llvm.extractelement %2[%1 : i64] : vector<3xi32> + llvm.return %3 : i32 + } + llvm.func @extelt_select_const_operands_vector_extra_use_2(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(dense<[42, 5, 4]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7]> : vector<3xi32>) : vector<3xi32> + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.select %arg0, %0, %1 : i1, vector<3xi32> + llvm.call @use_select(%3) : (vector<3xi32>) -> () + %4 = llvm.extractelement %3[%2 : i64] : vector<3xi32> + llvm.return %4 : i32 + } + llvm.func @crash_4b8320(%arg0: vector<2xf32>, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %4 = llvm.mlir.constant(1 : i64) : i64 + %5 = llvm.mlir.constant(2 : i64) : i64 + %6 = llvm.fmul %1, %arg0 : vector<2xf32> + %7 = llvm.fmul %1, %6 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %8 = llvm.extractelement %7[%2 : i64] : vector<2xf32> + %9 = llvm.extractelement %7[%2 : i64] : vector<2xf32> + %10 = llvm.insertelement %8, %3[%2 : i64] : vector<4xf32> + %11 = llvm.insertelement %9, %10[%4 : i64] : vector<4xf32> + %12 = llvm.insertelement %arg1, %11[%5 : i64] : vector<4xf32> + %13 = llvm.shufflevector %12, %3 [1, 1, 1, 1] : vector<4xf32> + %14 = llvm.fadd %13, %12 : vector<4xf32> + %15 = llvm.shufflevector %12, %3 [3, 3, 3, 3] : vector<4xf32> + %16 = llvm.fadd %14, %15 : vector<4xf32> + %17 = llvm.extractelement %16[%2 : i64] : vector<4xf32> + llvm.return %17 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/extractinsert-tbaa.ll.mlir b/test/LLVMDialect/InstCombine/extractinsert-tbaa.ll.mlir new file mode 100644 index 000000000..a6b4e77f7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/extractinsert-tbaa.ll.mlir @@ -0,0 +1,29 @@ +#tbaa_root = #llvm.tbaa_root +#tbaa_type_desc = #llvm.tbaa_type_desc}> +#tbaa_tag = #llvm.tbaa_tag +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @teststructextract(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.load %arg0 {alignment = 8 : i64, tbaa = [#tbaa_tag]} : !llvm.ptr -> !llvm.struct<"Complex", (f64, f64)> + %1 = llvm.extractvalue %0[0] : !llvm.struct<"Complex", (f64, f64)> + llvm.return %1 : f64 + } + llvm.func @testarrayextract(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.load %arg0 {alignment = 8 : i64, tbaa = [#tbaa_tag]} : !llvm.ptr -> !llvm.array<2 x f64> + %1 = llvm.extractvalue %0[0] : !llvm.array<2 x f64> + llvm.return %1 : f64 + } + llvm.func @teststructinsert(%arg0: !llvm.ptr, %arg1: f64, %arg2: f64) { + %0 = llvm.mlir.undef : !llvm.struct<"Complex", (f64, f64)> + %1 = llvm.insertvalue %arg1, %0[0] : !llvm.struct<"Complex", (f64, f64)> + %2 = llvm.insertvalue %arg2, %1[1] : !llvm.struct<"Complex", (f64, f64)> + llvm.store %2, %arg0 {alignment = 8 : i64, tbaa = [#tbaa_tag]} : !llvm.struct<"Complex", (f64, f64)>, !llvm.ptr + llvm.return + } + llvm.func @testarrayinsert(%arg0: !llvm.ptr, %arg1: f64, %arg2: f64) { + %0 = llvm.mlir.undef : !llvm.array<2 x f64> + %1 = llvm.insertvalue %arg1, %0[0] : !llvm.array<2 x f64> + %2 = llvm.insertvalue %arg2, %1[1] : !llvm.array<2 x f64> + llvm.store %2, %arg0 {alignment = 8 : i64, tbaa = [#tbaa_tag]} : !llvm.array<2 x f64>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/extractvalue.ll.mlir b/test/LLVMDialect/InstCombine/extractvalue.ll.mlir new file mode 100644 index 000000000..30a527a7b --- /dev/null +++ b/test/LLVMDialect/InstCombine/extractvalue.ll.mlir @@ -0,0 +1,58 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bar(!llvm.struct<(i32, i32)>) + llvm.func @baz(i32) -> i32 + llvm.func @foo(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.mlir.undef : !llvm.struct<(i32, struct<(i32, i32)>)> + %2 = llvm.insertvalue %arg0, %0[0] : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %arg1, %2[1] : !llvm.struct<(i32, i32)> + %4 = llvm.extractvalue %3[0] : !llvm.struct<(i32, i32)> + %5 = llvm.extractvalue %3[1] : !llvm.struct<(i32, i32)> + %6 = llvm.insertvalue %4, %1[0] : !llvm.struct<(i32, struct<(i32, i32)>)> + %7 = llvm.insertvalue %4, %6[1, 0] : !llvm.struct<(i32, struct<(i32, i32)>)> + %8 = llvm.insertvalue %5, %7[1, 1] : !llvm.struct<(i32, struct<(i32, i32)>)> + %9 = llvm.extractvalue %8[1] : !llvm.struct<(i32, struct<(i32, i32)>)> + %10 = llvm.extractvalue %8[1, 1] : !llvm.struct<(i32, struct<(i32, i32)>)> + llvm.call @bar(%9) : (!llvm.struct<(i32, i32)>) -> () + %11 = llvm.extractvalue %8[1] : !llvm.struct<(i32, struct<(i32, i32)>)> + %12 = llvm.extractvalue %11[1] : !llvm.struct<(i32, i32)> + llvm.call @bar(%11) : (!llvm.struct<(i32, i32)>) -> () + %13 = llvm.insertvalue %10, %0[0] : !llvm.struct<(i32, i32)> + %14 = llvm.insertvalue %12, %13[1] : !llvm.struct<(i32, i32)> + %15 = llvm.insertvalue %14, %1[1] : !llvm.struct<(i32, struct<(i32, i32)>)> + %16 = llvm.extractvalue %15[1, 1] : !llvm.struct<(i32, struct<(i32, i32)>)> + llvm.return %16 : i32 + } + llvm.func @extract2gep(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> !llvm.struct<(i16, i32)> + llvm.store %0, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb1 + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i16, i32)> + %3 = llvm.call @baz(%2) : (i32) -> i32 + llvm.store %3, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.cond_br %4, ^bb2, ^bb1 + ^bb2: // pred: ^bb1 + llvm.return %2 : i32 + } + llvm.func @doubleextract2gep(%arg0: !llvm.ptr) -> i16 { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> !llvm.struct<(i16, struct<(i32, i16)>)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i16, struct<(i32, i16)>)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i32, i16)> + llvm.return %2 : i16 + } + llvm.func @"nogep-multiuse"(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load volatile %arg0 {alignment = 4 : i64} : !llvm.ptr -> !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %0[1] : !llvm.struct<(i32, i32)> + %3 = llvm.add %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @"nogep-volatile"(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load volatile %arg0 {alignment = 4 : i64} : !llvm.ptr -> !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i32, i32)> + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/fabs-as-int.ll.mlir b/test/LLVMDialect/InstCombine/fabs-as-int.ll.mlir new file mode 100644 index 000000000..772bce15b --- /dev/null +++ b/test/LLVMDialect/InstCombine/fabs-as-int.ll.mlir @@ -0,0 +1,161 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fabs_as_int_f32_castback_noimplicitfloat(%arg0: f32) -> f32 attributes {passthrough = ["noimplicitfloat"]} { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @fabs_as_int_v2f32_noimplicitfloat(%arg0: vector<2xf32>) -> vector<2xi32> attributes {passthrough = ["noimplicitfloat"]} { + %0 = llvm.mlir.constant(dense<2147483647> : vector<2xi32>) : vector<2xi32> + %1 = llvm.bitcast %arg0 : vector<2xf32> to vector<2xi32> + %2 = llvm.and %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @fabs_as_int_f32_castback(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @not_fabs_as_int_f32_castback_wrongconst(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @fabs_as_int_f32_castback_multi_use(%arg0: f32, %arg1: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.and %1, %0 : i32 + llvm.store %2, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @fabs_as_int_f64(%arg0: f64) -> i64 { + %0 = llvm.mlir.constant(9223372036854775807 : i64) : i64 + %1 = llvm.bitcast %arg0 : f64 to i64 + %2 = llvm.and %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @fabs_as_int_v2f64(%arg0: vector<2xf64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<9223372036854775807> : vector<2xi64>) : vector<2xi64> + %1 = llvm.bitcast %arg0 : vector<2xf64> to vector<2xi64> + %2 = llvm.and %1, %0 : vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @fabs_as_int_f64_swap(%arg0: f64) -> i64 { + %0 = llvm.mlir.constant(9223372036854775807 : i64) : i64 + %1 = llvm.bitcast %arg0 : f64 to i64 + %2 = llvm.and %0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @fabs_as_int_f32(%arg0: f32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.and %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @fabs_as_int_v2f32(%arg0: vector<2xf32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<2147483647> : vector<2xi32>) : vector<2xi32> + %1 = llvm.bitcast %arg0 : vector<2xf32> to vector<2xi32> + %2 = llvm.and %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @not_fabs_as_int_v2f32_nonsplat(%arg0: vector<2xf32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[2147483647, 2147483646]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.bitcast %arg0 : vector<2xf32> to vector<2xi32> + %2 = llvm.and %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @fabs_as_int_v3f32_poison(%arg0: vector<3xf32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.bitcast %arg0 : vector<3xf32> to vector<3xi32> + %10 = llvm.and %9, %8 : vector<3xi32> + llvm.return %10 : vector<3xi32> + } + llvm.func @fabs_as_int_f64_not_bitcast(%arg0: f64) -> i64 { + %0 = llvm.mlir.constant(9223372036854775807 : i64) : i64 + %1 = llvm.fptoui %arg0 : f64 to i64 + %2 = llvm.and %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @not_fabs_as_int_f32_bitcast_from_v2f16(%arg0: vector<2xf16>) -> f32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.bitcast %arg0 : vector<2xf16> to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @not_fabs_as_int_f32_bitcast_from_v2i16(%arg0: vector<2xi16>) -> f32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.bitcast %arg0 : vector<2xi16> to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @fabs_as_int_fp128_f64_mask(%arg0: f128) -> i128 { + %0 = llvm.mlir.constant(170141183460469231731687303715884105727 : i128) : i128 + %1 = llvm.bitcast %arg0 : f128 to i128 + %2 = llvm.and %1, %0 : i128 + llvm.return %2 : i128 + } + llvm.func @fabs_as_int_fp128_f128_mask(%arg0: f128) -> i128 { + %0 = llvm.mlir.constant(170141183460469231731687303715884105727 : i128) : i128 + %1 = llvm.bitcast %arg0 : f128 to i128 + %2 = llvm.and %1, %0 : i128 + llvm.return %2 : i128 + } + llvm.func @fabs_as_int_f16(%arg0: f16) -> i16 { + %0 = llvm.mlir.constant(32767 : i16) : i16 + %1 = llvm.bitcast %arg0 : f16 to i16 + %2 = llvm.and %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @fabs_as_int_v2f16(%arg0: vector<2xf16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<32767> : vector<2xi16>) : vector<2xi16> + %1 = llvm.bitcast %arg0 : vector<2xf16> to vector<2xi16> + %2 = llvm.and %1, %0 : vector<2xi16> + llvm.return %2 : vector<2xi16> + } + llvm.func @fabs_as_int_bf16(%arg0: bf16) -> i16 { + %0 = llvm.mlir.constant(32767 : i16) : i16 + %1 = llvm.bitcast %arg0 : bf16 to i16 + %2 = llvm.and %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @fabs_as_int_v2bf16(%arg0: vector<2xbf16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<32767> : vector<2xi16>) : vector<2xi16> + %1 = llvm.bitcast %arg0 : vector<2xbf16> to vector<2xi16> + %2 = llvm.and %1, %0 : vector<2xi16> + llvm.return %2 : vector<2xi16> + } + llvm.func @fabs_as_int_x86_fp80_f64_mask(%arg0: f80) -> i80 { + %0 = llvm.mlir.constant(9223372036854775807 : i80) : i80 + %1 = llvm.bitcast %arg0 : f80 to i80 + %2 = llvm.and %1, %0 : i80 + llvm.return %2 : i80 + } + llvm.func @fabs_as_int_ppc_fp128_f64_mask(%arg0: !llvm.ppc_fp128) -> i128 { + %0 = llvm.mlir.constant(9223372036854775807 : i128) : i128 + %1 = llvm.bitcast %arg0 : !llvm.ppc_fp128 to i128 + %2 = llvm.and %1, %0 : i128 + llvm.return %2 : i128 + } + llvm.func @fabs_as_int_ppc_fp128_f128_mask(%arg0: !llvm.ppc_fp128) -> i128 { + %0 = llvm.mlir.constant(170141183460469231731687303715884105727 : i128) : i128 + %1 = llvm.bitcast %arg0 : !llvm.ppc_fp128 to i128 + %2 = llvm.and %1, %0 : i128 + llvm.return %2 : i128 + } +} diff --git a/test/LLVMDialect/InstCombine/fabs-copysign.ll.mlir b/test/LLVMDialect/InstCombine/fabs-copysign.ll.mlir index 1892e4112..ab9ee4c5d 100644 --- a/test/LLVMDialect/InstCombine/fabs-copysign.ll.mlir +++ b/test/LLVMDialect/InstCombine/fabs-copysign.ll.mlir @@ -1,76 +1,54 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.fabs.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.fabs.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.fabs.v4f64", type = !llvm.func (vector<4xf64>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.copysign.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.copysign.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fdiv"(%arg0, %0) : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fabs_copysign", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fdiv"(%0, %arg0) : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fabs_copysign_commuted", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf64>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.fabs.v4f64, fastmathFlags = #llvm.fastmath<>} : (vector<4xf64>) -> vector<4xf64> - %1 = "llvm.fdiv"(%arg0, %0) : (vector<4xf64>, vector<4xf64>) -> vector<4xf64> - "llvm.return"(%1) : (vector<4xf64>) -> () - }) {linkage = 10 : i64, sym_name = "fabs_copysign_vec", type = !llvm.func (vector<4xf64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf64>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.fabs.v4f64, fastmathFlags = #llvm.fastmath<>} : (vector<4xf64>) -> vector<4xf64> - %1 = "llvm.fdiv"(%0, %arg0) : (vector<4xf64>, vector<4xf64>) -> vector<4xf64> - "llvm.return"(%1) : (vector<4xf64>) -> () - }) {linkage = 10 : i64, sym_name = "fabs_copysign_vec_commuted", type = !llvm.func (vector<4xf64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.fabs.f32, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %1 = "llvm.fdiv"(%arg0, %0) : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fabs_copysignf", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - %1 = "llvm.fdiv"(%arg0, %0) : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fabs_copysign_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg1) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fdiv"(%arg0, %0) : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fabs_copysign_mismatch", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg1) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fdiv"(%0, %arg0) : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fabs_copysign_commuted_mismatch", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fdiv"(%arg0, %0) : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fabs_copysign_no_nnan", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.fabs.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fdiv"(%arg0, %0) : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fabs_copysign_no_ninf", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(f64) + llvm.func @fabs_copysign(%arg0: f64) -> f64 { + %0 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %1 = llvm.fdiv %arg0, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %1 : f64 + } + llvm.func @fabs_copysign_commuted(%arg0: f64) -> f64 { + %0 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %1 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %1 : f64 + } + llvm.func @fabs_copysign_vec(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.intr.fabs(%arg0) : (vector<4xf64>) -> vector<4xf64> + %1 = llvm.fdiv %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf64> + llvm.return %1 : vector<4xf64> + } + llvm.func @fabs_copysign_vec_commuted(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.intr.fabs(%arg0) : (vector<4xf64>) -> vector<4xf64> + %1 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<4xf64> + llvm.return %1 : vector<4xf64> + } + llvm.func @fabs_copysignf(%arg0: f32) -> f32 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fdiv %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @fabs_copysign_use(%arg0: f64) -> f64 { + %0 = llvm.intr.fabs(%arg0) : (f64) -> f64 + llvm.call @use(%0) : (f64) -> () + %1 = llvm.fdiv %arg0, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %1 : f64 + } + llvm.func @fabs_copysign_mismatch(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.fabs(%arg1) : (f64) -> f64 + %1 = llvm.fdiv %arg0, %0 : f64 + llvm.return %1 : f64 + } + llvm.func @fabs_copysign_commuted_mismatch(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.fabs(%arg1) : (f64) -> f64 + %1 = llvm.fdiv %0, %arg0 : f64 + llvm.return %1 : f64 + } + llvm.func @fabs_copysign_no_nnan(%arg0: f64) -> f64 { + %0 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %1 = llvm.fdiv %arg0, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %1 : f64 + } + llvm.func @fabs_copysign_no_ninf(%arg0: f64) -> f64 { + %0 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %1 = llvm.fdiv %arg0, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %1 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/fabs-fneg-fold.ll.mlir b/test/LLVMDialect/InstCombine/fabs-fneg-fold.ll.mlir new file mode 100644 index 000000000..65948872b --- /dev/null +++ b/test/LLVMDialect/InstCombine/fabs-fneg-fold.ll.mlir @@ -0,0 +1,92 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fabs_fneg_basic(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.intr.fabs(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fabs_fneg_v2f32(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fneg %arg0 : vector<2xf32> + %1 = llvm.intr.fabs(%0) : (vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @fabs_fneg_f64(%arg0: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.intr.fabs(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @fabs_fneg_v4f64(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.fneg %arg0 : vector<4xf64> + %1 = llvm.intr.fabs(%0) : (vector<4xf64>) -> vector<4xf64> + llvm.return %1 : vector<4xf64> + } + llvm.func @fabs_fneg_f16(%arg0: f16) -> f16 { + %0 = llvm.fneg %arg0 : f16 + %1 = llvm.intr.fabs(%0) : (f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @fabs_copysign_nnan(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fabs_copysign_ninf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fabs_copysign_nsz(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fabs_copysign_nnan_negative(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fabs_copysign_ninf_negative(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fabs_copysign_nsz_negative(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.copysign(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.fabs(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fabs_fneg_no_fabs(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + llvm.return %0 : f32 + } + llvm.func @fabs_fneg_splat_v2f32(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-2.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fneg %0 : vector<2xf32> + %2 = llvm.intr.fabs(%1) : (vector<2xf32>) -> vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fabs_fneg_splat_poison_v2f32(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.poison : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.undef : vector<2xf32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf32> + %7 = llvm.fneg %6 : vector<2xf32> + %8 = llvm.intr.fabs(%7) : (vector<2xf32>) -> vector<2xf32> + llvm.return %8 : vector<2xf32> + } + llvm.func @fabs_fneg_non_splat_v2f32(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[2.000000e+00, 3.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fneg %0 : vector<2xf32> + %2 = llvm.intr.fabs(%1) : (vector<2xf32>) -> vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @use(f32) + llvm.func @fabs_fneg_multi_use(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + llvm.call @use(%0) : (f32) -> () + %1 = llvm.intr.fabs(%0) : (f32) -> f32 + llvm.return %1 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/fabs-libcall.ll.mlir b/test/LLVMDialect/InstCombine/fabs-libcall.ll.mlir index 491c5863f..f965598ca 100644 --- a/test/LLVMDialect/InstCombine/fabs-libcall.ll.mlir +++ b/test/LLVMDialect/InstCombine/fabs-libcall.ll.mlir @@ -1,15 +1,11 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fabsl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f80): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @fabsl, fastmathFlags = #llvm.fastmath<>} : (f80) -> f80 - "llvm.return"(%0) : (f80) -> () - }) {linkage = 10 : i64, sym_name = "replace_fabs_call_f80", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f80): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @fabsl, fastmathFlags = #llvm.fastmath<>} : (f80) -> f80 - "llvm.return"(%0) : (f80) -> () - }) {linkage = 10 : i64, sym_name = "fmf_replace_fabs_call_f80", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fabsl(f80) -> f80 + llvm.func @replace_fabs_call_f80(%arg0: f80) -> f80 { + %0 = llvm.call @fabsl(%arg0) : (f80) -> f80 + llvm.return %0 : f80 + } + llvm.func @fmf_replace_fabs_call_f80(%arg0: f80) -> f80 { + %0 = llvm.call @fabsl(%arg0) {fastmathFlags = #llvm.fastmath} : (f80) -> f80 + llvm.return %0 : f80 + } +} diff --git a/test/LLVMDialect/InstCombine/fabs.ll.mlir b/test/LLVMDialect/InstCombine/fabs.ll.mlir new file mode 100644 index 000000000..3b8f22495 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fabs.ll.mlir @@ -0,0 +1,692 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fabsf(f32) -> f32 + llvm.func @fabs(f64) -> f64 + llvm.func @fabsl(f128) -> f128 + llvm.func @use(f32) + llvm.func @usebool(i1) + llvm.func @replace_fabs_call_f32(%arg0: f32) -> f32 { + %0 = llvm.call @fabsf(%arg0) : (f32) -> f32 + llvm.return %0 : f32 + } + llvm.func @replace_fabs_call_f64(%arg0: f64) -> f64 { + %0 = llvm.call @fabs(%arg0) : (f64) -> f64 + llvm.return %0 : f64 + } + llvm.func @replace_fabs_call_f128(%arg0: f128) -> f128 { + %0 = llvm.call @fabsl(%arg0) : (f128) -> f128 + llvm.return %0 : f128 + } + llvm.func @fmf_replace_fabs_call_f32(%arg0: f32) -> f32 { + %0 = llvm.call @fabsf(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %0 : f32 + } + llvm.func @square_fabs_intrinsic_f32(%arg0: f32) -> f32 { + %0 = llvm.fmul %arg0, %arg0 : f32 + %1 = llvm.intr.fabs(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @square_fabs_intrinsic_f64(%arg0: f64) -> f64 { + %0 = llvm.fmul %arg0, %arg0 : f64 + %1 = llvm.intr.fabs(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @square_fabs_intrinsic_f128(%arg0: f128) -> f128 { + %0 = llvm.fmul %arg0, %arg0 : f128 + %1 = llvm.intr.fabs(%0) : (f128) -> f128 + llvm.return %1 : f128 + } + llvm.func @square_nnan_fabs_intrinsic_f32(%arg0: f32) -> f32 { + %0 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.intr.fabs(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @square_fabs_shrink_call1(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fmul %0, %0 : f64 + %2 = llvm.call @fabs(%1) : (f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @square_fabs_shrink_call2(%arg0: f32) -> f32 { + %0 = llvm.fmul %arg0, %arg0 : f32 + %1 = llvm.fpext %0 : f32 to f64 + %2 = llvm.call @fabs(%1) : (f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @fabs_select_constant_negative_positive(%arg0: i32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.select %3, %1, %2 : i1, f32 + %5 = llvm.intr.fabs(%4) : (f32) -> f32 + llvm.return %5 : f32 + } + llvm.func @fabs_select_constant_positive_negative(%arg0: i32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(-2.000000e+00 : f32) : f32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.select %3, %1, %2 : i1, f32 + %5 = llvm.intr.fabs(%4) : (f32) -> f32 + llvm.return %5 : f32 + } + llvm.func @fabs_select_constant_negative_negative(%arg0: i32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(-2.000000e+00 : f32) : f32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.select %3, %1, %2 : i1, f32 + %5 = llvm.intr.fabs(%4) : (f32) -> f32 + llvm.return %5 : f32 + } + llvm.func @fabs_select_constant_neg0(%arg0: i32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.select %3, %1, %2 : i1, f32 + %5 = llvm.intr.fabs(%4) : (f32) -> f32 + llvm.return %5 : f32 + } + llvm.func @fabs_select_var_constant_negative(%arg0: i32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, f32 + %4 = llvm.intr.fabs(%3) : (f32) -> f32 + llvm.return %4 : f32 + } + llvm.func @square_fma_fabs_intrinsic_f32(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.fma(%arg0, %arg0, %0) : (f32, f32, f32) -> f32 + %2 = llvm.intr.fabs(%1) : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @square_nnan_fma_fabs_intrinsic_f32(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.fma(%arg0, %arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + %2 = llvm.intr.fabs(%1) : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @square_fmuladd_fabs_intrinsic_f32(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.fmuladd(%arg0, %arg0, %0) : (f32, f32, f32) -> f32 + %2 = llvm.intr.fabs(%1) : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @square_nnan_fmuladd_fabs_intrinsic_f32(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.fmuladd(%arg0, %arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + %2 = llvm.intr.fabs(%1) : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @multi_use_fabs_fpext(%arg0: f32) -> f64 { + %0 = llvm.mlir.undef : !llvm.ptr + %1 = llvm.fpext %arg0 : f32 to f64 + %2 = llvm.intr.fabs(%1) : (f64) -> f64 + llvm.store volatile %1, %0 {alignment = 8 : i64} : f64, !llvm.ptr + llvm.return %2 : f64 + } + llvm.func @select_fcmp_ole_zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ole" %arg0, %0 : f64 + %2 = llvm.fsub %0, %arg0 : f64 + %3 = llvm.select %1, %2, %arg0 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_fcmp_nnan_ole_zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ole" %arg0, %0 : f64 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %arg0 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nnan_fcmp_nnan_ole_zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ole" %arg0, %0 : f64 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_fcmp_nnan_ule_zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ule" %arg0, %0 : f64 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %arg0 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_fcmp_nnan_olt_zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "olt" %arg0, %0 : f64 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %arg0 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_fcmp_nnan_ole_negzero(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.poison : f32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.mlir.undef : vector<2xf32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xf32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xf32> + %8 = llvm.fcmp "ole" %arg0, %0 : vector<2xf32> + %9 = llvm.fsub %7, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %10 = llvm.select %8, %9, %arg0 : vector<2xi1>, vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @select_nnan_fcmp_nnan_ole_negzero(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.poison : f32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.mlir.undef : vector<2xf32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xf32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xf32> + %8 = llvm.fcmp "ole" %arg0, %0 : vector<2xf32> + %9 = llvm.fsub %7, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %10 = llvm.select %8, %9, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xi1>, vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @select_fcmp_ogt_zero(%arg0: f128) -> f128 { + %0 = llvm.mlir.constant(0.000000e+00 : f128) : f128 + %1 = llvm.fcmp "ogt" %arg0, %0 : f128 + %2 = llvm.fsub %0, %arg0 : f128 + %3 = llvm.select %1, %arg0, %2 : i1, f128 + llvm.return %3 : f128 + } + llvm.func @select_nsz_fcmp_ogt_fneg(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fcmp "ogt" %arg0, %0 : f32 + %2 = llvm.select %1, %arg0, %0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %2 : f32 + } + llvm.func @select_nsz_nnan_fcmp_ogt_fneg(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fcmp "ogt" %arg0, %0 : f32 + %2 = llvm.select %1, %arg0, %0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %2 : f32 + } + llvm.func @select_fcmp_nnan_ogt_zero(%arg0: f128) -> f128 { + %0 = llvm.mlir.constant(0.000000e+00 : f128) : f128 + %1 = llvm.fcmp "ogt" %arg0, %0 : f128 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f128 + %3 = llvm.select %1, %arg0, %2 : i1, f128 + llvm.return %3 : f128 + } + llvm.func @select_nnan_fcmp_nnan_ogt_zero(%arg0: f128) -> f128 { + %0 = llvm.mlir.constant(0.000000e+00 : f128) : f128 + %1 = llvm.fcmp "ogt" %arg0, %0 : f128 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f128 + %3 = llvm.select %1, %arg0, %2 {fastmathFlags = #llvm.fastmath} : i1, f128 + llvm.return %3 : f128 + } + llvm.func @select_fcmp_nnan_ogt_negzero(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(-0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %2 = llvm.fcmp "ogt" %arg0, %0 : f16 + %3 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f16 + %4 = llvm.select %2, %arg0, %3 : i1, f16 + llvm.return %4 : f16 + } + llvm.func @select_nnan_fcmp_nnan_ogt_negzero(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(-0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %2 = llvm.fcmp "ogt" %arg0, %0 : f16 + %3 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f16 + %4 = llvm.select %2, %arg0, %3 {fastmathFlags = #llvm.fastmath} : i1, f16 + llvm.return %4 : f16 + } + llvm.func @select_fcmp_nnan_ugt_negzero(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(-0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %2 = llvm.fcmp "ugt" %arg0, %0 : f16 + %3 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f16 + %4 = llvm.select %2, %arg0, %3 : i1, f16 + llvm.return %4 : f16 + } + llvm.func @select_fcmp_nnan_oge_negzero(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(-0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %2 = llvm.fcmp "oge" %arg0, %0 : f16 + %3 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f16 + %4 = llvm.select %2, %arg0, %3 : i1, f16 + llvm.return %4 : f16 + } + llvm.func @select_nsz_fcmp_olt_zero_unary_fneg(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "olt" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nnan_fcmp_olt_zero_unary_fneg(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "olt" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_fcmp_nnan_nsz_olt_zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %2 = llvm.fcmp "olt" %arg0, %0 : f64 + %3 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %4 = llvm.select %2, %3, %arg0 : i1, f64 + llvm.return %4 : f64 + } + llvm.func @select_nnan_nsz_fcmp_nnan_nsz_olt_zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %2 = llvm.fcmp "olt" %arg0, %0 : f64 + %3 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %4 = llvm.select %2, %3, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %4 : f64 + } + llvm.func @select_fcmp_nnan_nsz_ult_zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %2 = llvm.fcmp "ult" %arg0, %0 : f64 + %3 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %4 = llvm.select %2, %3, %arg0 : i1, f64 + llvm.return %4 : f64 + } + llvm.func @select_fcmp_nnan_nsz_olt_zero_unary_fneg(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "olt" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %arg0 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_fcmp_nnan_nsz_ult_zero_unary_fneg(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ult" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %arg0 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_fcmp_nnan_nsz_olt_negzero(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "olt" %arg0, %0 : f32 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg0 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_nnan_ninf_nsz_fcmp_nnan_nsz_olt_negzero(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "olt" %arg0, %0 : f32 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fcmp_nnan_nsz_ult_negzero(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ult" %arg0, %0 : f32 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg0 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fcmp_nnan_nsz_olt_negzero_unary_fneg(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "olt" %arg0, %0 : f32 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg0 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fcmp_nnan_nsz_ult_negzero_unary_fneg(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ult" %arg0, %0 : f32 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg0 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fcmp_nnan_nsz_ole_zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %2 = llvm.fcmp "ole" %arg0, %0 : f64 + %3 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %4 = llvm.select %2, %3, %arg0 : i1, f64 + llvm.return %4 : f64 + } + llvm.func @select_fast_fcmp_nnan_nsz_ole_zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %2 = llvm.fcmp "ole" %arg0, %0 : f64 + %3 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %4 = llvm.select %2, %3, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %4 : f64 + } + llvm.func @select_fcmp_nnan_nsz_ule_zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %2 = llvm.fcmp "ule" %arg0, %0 : f64 + %3 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %4 = llvm.select %2, %3, %arg0 : i1, f64 + llvm.return %4 : f64 + } + llvm.func @select_fcmp_nnan_nsz_ole_zero_unary_fneg(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ole" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %arg0 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_fcmp_nnan_nsz_ule_zero_unary_fneg(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ule" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %arg0 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_fcmp_nnan_nsz_ole_negzero(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ole" %arg0, %0 : f32 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg0 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_nnan_nsz_fcmp_nnan_nsz_ole_negzero(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ole" %arg0, %0 : f32 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fcmp_nnan_nsz_ule_negzero(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ule" %arg0, %0 : f32 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg0 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fcmp_nnan_nsz_ole_negzero_unary_fneg(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ole" %arg0, %0 : f32 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg0 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fcmp_nnan_nsz_ule_negzero_unary_fneg(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ule" %arg0, %0 : f32 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg0 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_nsz_fcmp_ogt_zero_unary_fneg(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.fcmp "ogt" %arg0, %1 : vector<2xf32> + %3 = llvm.fneg %arg0 : vector<2xf32> + %4 = llvm.select %2, %arg0, %3 {fastmathFlags = #llvm.fastmath} : vector<2xi1>, vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @select_nsz_nnan_fcmp_ogt_zero_unary_fneg(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.fcmp "ogt" %arg0, %1 : vector<2xf32> + %3 = llvm.fneg %arg0 : vector<2xf32> + %4 = llvm.select %2, %arg0, %3 {fastmathFlags = #llvm.fastmath} : vector<2xi1>, vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @select_fcmp_nnan_nsz_ogt_zero(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %3 = llvm.fcmp "ogt" %arg0, %1 : vector<2xf32> + %4 = llvm.fsub %2, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %5 = llvm.select %3, %arg0, %4 : vector<2xi1>, vector<2xf32> + llvm.return %5 : vector<2xf32> + } + llvm.func @select_fcmp_nnan_nsz_ugt_zero(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %3 = llvm.fcmp "ugt" %arg0, %1 : vector<2xf32> + %4 = llvm.fsub %2, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %5 = llvm.select %3, %arg0, %4 : vector<2xi1>, vector<2xf32> + llvm.return %5 : vector<2xf32> + } + llvm.func @select_fcmp_nnan_nsz_ogt_zero_unary_fneg(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.fcmp "ogt" %arg0, %1 : vector<2xf32> + %3 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %4 = llvm.select %2, %arg0, %3 : vector<2xi1>, vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @select_fcmp_nnan_nsz_ugt_zero_unary_fneg(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.fcmp "ugt" %arg0, %1 : vector<2xf32> + %3 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %4 = llvm.select %2, %arg0, %3 : vector<2xi1>, vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @select_fcmp_nnan_nsz_ogt_negzero(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(-0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %2 = llvm.fcmp "ogt" %arg0, %0 : f16 + %3 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f16 + %4 = llvm.select %2, %arg0, %3 : i1, f16 + llvm.return %4 : f16 + } + llvm.func @select_fcmp_nnan_nsz_ugt_negzero(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(-0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %2 = llvm.fcmp "ugt" %arg0, %0 : f16 + %3 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f16 + %4 = llvm.select %2, %arg0, %3 : i1, f16 + llvm.return %4 : f16 + } + llvm.func @select_fcmp_nnan_nsz_oge_zero(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf64>) : vector<2xf64> + %3 = llvm.fcmp "oge" %arg0, %1 : vector<2xf64> + %4 = llvm.fsub %2, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %5 = llvm.select %3, %arg0, %4 : vector<2xi1>, vector<2xf64> + llvm.return %5 : vector<2xf64> + } + llvm.func @select_fcmp_nnan_nsz_uge_zero(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf64>) : vector<2xf64> + %3 = llvm.fcmp "uge" %arg0, %1 : vector<2xf64> + %4 = llvm.fsub %2, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %5 = llvm.select %3, %arg0, %4 : vector<2xi1>, vector<2xf64> + llvm.return %5 : vector<2xf64> + } + llvm.func @select_fcmp_nnan_nsz_oge_zero_unary_fneg(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.fcmp "oge" %arg0, %1 : vector<2xf64> + %3 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %4 = llvm.select %2, %arg0, %3 : vector<2xi1>, vector<2xf64> + llvm.return %4 : vector<2xf64> + } + llvm.func @select_fcmp_nnan_nsz_uge_zero_unary_fneg(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.fcmp "uge" %arg0, %1 : vector<2xf64> + %3 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %4 = llvm.select %2, %arg0, %3 : vector<2xi1>, vector<2xf64> + llvm.return %4 : vector<2xf64> + } + llvm.func @select_fcmp_nnan_nsz_oge_negzero(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(-0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "oge" %arg0, %0 : f16 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f16 + %3 = llvm.select %1, %arg0, %2 : i1, f16 + llvm.return %3 : f16 + } + llvm.func @select_fcmp_nnan_nsz_uge_negzero(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(-0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "uge" %arg0, %0 : f16 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f16 + %3 = llvm.select %1, %arg0, %2 : i1, f16 + llvm.return %3 : f16 + } + llvm.func @select_fcmp_nnan_nsz_oge_negzero_unary_fneg(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(-0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "oge" %arg0, %0 : f16 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f16 + %3 = llvm.select %1, %arg0, %2 : i1, f16 + llvm.return %3 : f16 + } + llvm.func @select_fcmp_nnan_nsz_uge_negzero_unary_fneg(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(-0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "uge" %arg0, %0 : f16 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f16 + %3 = llvm.select %1, %arg0, %2 : i1, f16 + llvm.return %3 : f16 + } + llvm.func @select_fneg(%arg0: i1, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg1 : f32 + %1 = llvm.select %arg0, %0, %arg1 : i1, f32 + %2 = llvm.intr.fabs(%1) : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @select_fneg_use1(%arg0: i1, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg1 : f32 + llvm.call @use(%0) : (f32) -> () + %1 = llvm.select %arg0, %arg1, %0 : i1, f32 + %2 = llvm.intr.fabs(%1) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @select_fneg_use2(%arg0: i1, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %arg0, %0, %arg1 : i1, f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.intr.fabs(%1) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @select_fneg_vec(%arg0: vector<2xi1>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fneg %arg1 : vector<2xf32> + %1 = llvm.select %arg0, %arg1, %0 {fastmathFlags = #llvm.fastmath} : vector<2xi1>, vector<2xf32> + %2 = llvm.intr.fabs(%1) : (vector<2xf32>) -> vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @test_select_neg_negx_x(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.select %2, %3, %arg0 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @test_select_nneg_negx_x(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.select %2, %3, %arg0 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @test_select_neg_x_negx(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.select %2, %arg0, %3 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @test_select_nneg_x_negx(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.select %2, %arg0, %3 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @test_select_neg_negx_x_multiuse1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.call @usebool(%2) : (i1) -> () + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.select %2, %3, %arg0 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @test_select_neg_negx_x_multiuse2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + %3 = llvm.fneg %arg0 : f32 + llvm.call @use(%3) : (f32) -> () + %4 = llvm.select %2, %3, %arg0 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @test_select_neg_negx_x_multiuse3(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.call @usebool(%2) : (i1) -> () + %3 = llvm.fneg %arg0 : f32 + llvm.call @use(%3) : (f32) -> () + %4 = llvm.select %2, %3, %arg0 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @test_select_neg_negx_x_fmf(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.select %2, %3, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %4 : f32 + } + llvm.func @test_select_nneg_negx_x_fmf(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.select %2, %3, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %4 : f32 + } + llvm.func @test_select_nneg_negx_x_multiuse4(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + llvm.call @usebool(%2) : (i1) -> () + %3 = llvm.fneg %arg0 : f32 + llvm.call @use(%3) : (f32) -> () + %4 = llvm.select %2, %3, %arg0 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @test_select_neg_negx_x_mismatched1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg1 : f32 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.select %2, %3, %arg0 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @test_select_neg_negx_x_mismatched2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + %3 = llvm.fneg %arg1 : f32 + %4 = llvm.select %2, %3, %arg0 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @test_select_neg_negx_x_mismatched3(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.select %2, %3, %arg1 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @test_select_neg_negx_x_wrong_type(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.bitcast %arg0 : vector<2xf32> to i64 + %2 = llvm.icmp "slt" %1, %0 : i64 + %3 = llvm.fneg %arg0 : vector<2xf32> + %4 = llvm.select %2, %3, %arg0 : i1, vector<2xf32> + llvm.return %4 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/fadd-fsub-factor.ll.mlir b/test/LLVMDialect/InstCombine/fadd-fsub-factor.ll.mlir index 0bf3898dc..689f2bbc7 100644 --- a/test/LLVMDialect/InstCombine/fadd-fsub-factor.ll.mlir +++ b/test/LLVMDialect/InstCombine/fadd-fsub-factor.ll.mlir @@ -1,335 +1,292 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fmul"(%arg0, %arg2) : (f32, f32) -> f32 - %1 = "llvm.fmul"(%arg1, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fadd"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fadd", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>): // no predecessors - %0 = "llvm.fmul"(%arg2, %arg0) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %1 = "llvm.fmul"(%arg2, %arg1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %2 = "llvm.fadd"(%0, %1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - "llvm.return"(%2) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fadd_commute1_vec", type = !llvm.func (vector<2xf32>, vector<2xf32>, vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>): // no predecessors - %0 = "llvm.fmul"(%arg0, %arg2) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %1 = "llvm.fmul"(%arg2, %arg1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %2 = "llvm.fadd"(%0, %1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - "llvm.return"(%2) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fadd_commute2_vec", type = !llvm.func (vector<2xf32>, vector<2xf32>, vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64): // no predecessors - %0 = "llvm.fmul"(%arg2, %arg0) : (f64, f64) -> f64 - %1 = "llvm.fmul"(%arg1, %arg2) : (f64, f64) -> f64 - %2 = "llvm.fadd"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fadd_commute3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fmul"(%arg0, %arg2) : (f32, f32) -> f32 - %1 = "llvm.fmul"(%arg1, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fadd"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fadd_not_enough_FMF", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fmul"(%arg2, %arg0) : (f32, f32) -> f32 - %1 = "llvm.fmul"(%arg1, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fadd"(%0, %1) : (f32, f32) -> f32 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fadd_uses1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fmul"(%arg2, %arg0) : (f32, f32) -> f32 - %1 = "llvm.fmul"(%arg2, %arg1) : (f32, f32) -> f32 - %2 = "llvm.fadd"(%0, %1) : (f32, f32) -> f32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fadd_uses2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fmul"(%arg0, %arg2) : (f32, f32) -> f32 - %1 = "llvm.fmul"(%arg2, %arg1) : (f32, f32) -> f32 - %2 = "llvm.fadd"(%0, %1) : (f32, f32) -> f32 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fadd_uses3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f16, %arg1: f16, %arg2: f16): // no predecessors - %0 = "llvm.fmul"(%arg0, %arg2) : (f16, f16) -> f16 - %1 = "llvm.fmul"(%arg1, %arg2) : (f16, f16) -> f16 - %2 = "llvm.fsub"(%0, %1) : (f16, f16) -> f16 - "llvm.return"(%2) : (f16) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fsub", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>): // no predecessors - %0 = "llvm.fmul"(%arg2, %arg0) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %1 = "llvm.fmul"(%arg1, %arg2) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %2 = "llvm.fsub"(%0, %1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - "llvm.return"(%2) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fsub_commute1_vec", type = !llvm.func (vector<2xf32>, vector<2xf32>, vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>): // no predecessors - %0 = "llvm.fmul"(%arg0, %arg2) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %1 = "llvm.fmul"(%arg2, %arg1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %2 = "llvm.fsub"(%0, %1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - "llvm.return"(%2) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fsub_commute2_vec", type = !llvm.func (vector<2xf32>, vector<2xf32>, vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64): // no predecessors - %0 = "llvm.fmul"(%arg2, %arg0) : (f64, f64) -> f64 - %1 = "llvm.fmul"(%arg2, %arg1) : (f64, f64) -> f64 - %2 = "llvm.fsub"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fsub_commute3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fmul"(%arg2, %arg0) : (f32, f32) -> f32 - %1 = "llvm.fmul"(%arg1, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fsub"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fsub_not_enough_FMF", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fmul"(%arg0, %arg2) : (f32, f32) -> f32 - %1 = "llvm.fmul"(%arg1, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fsub"(%0, %1) : (f32, f32) -> f32 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fsub_uses1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fmul"(%arg2, %arg0) : (f32, f32) -> f32 - %1 = "llvm.fmul"(%arg2, %arg1) : (f32, f32) -> f32 - %2 = "llvm.fsub"(%0, %1) : (f32, f32) -> f32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fsub_uses2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fmul"(%arg0, %arg2) : (f32, f32) -> f32 - %1 = "llvm.fmul"(%arg1, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fsub"(%0, %1) : (f32, f32) -> f32 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fmul_fsub_uses3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64): // no predecessors - %0 = "llvm.fdiv"(%arg0, %arg2) : (f64, f64) -> f64 - %1 = "llvm.fdiv"(%arg1, %arg2) : (f64, f64) -> f64 - %2 = "llvm.fadd"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_fadd", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fdiv"(%arg0, %arg2) : (f32, f32) -> f32 - %1 = "llvm.fdiv"(%arg1, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fsub"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_fsub", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf64>, %arg1: vector<2xf64>, %arg2: vector<2xf64>): // no predecessors - %0 = "llvm.fdiv"(%arg0, %arg2) : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> - %1 = "llvm.fdiv"(%arg1, %arg2) : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> - %2 = "llvm.fadd"(%0, %1) : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> - "llvm.return"(%2) : (vector<2xf64>) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_fadd_vec", type = !llvm.func (vector<2xf64>, vector<2xf64>, vector<2xf64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>): // no predecessors - %0 = "llvm.fdiv"(%arg0, %arg2) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %1 = "llvm.fdiv"(%arg1, %arg2) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %2 = "llvm.fsub"(%0, %1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - "llvm.return"(%2) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_fsub_vec", type = !llvm.func (vector<2xf32>, vector<2xf32>, vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fdiv"(%arg2, %arg1) : (f32, f32) -> f32 - %1 = "llvm.fdiv"(%arg2, %arg0) : (f32, f32) -> f32 - %2 = "llvm.fadd"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_fadd_commute1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fdiv"(%arg2, %arg1) : (f32, f32) -> f32 - %1 = "llvm.fdiv"(%arg0, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fsub"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_fsub_commute2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fdiv"(%arg1, %arg0) : (f32, f32) -> f32 - %1 = "llvm.fdiv"(%arg2, %arg0) : (f32, f32) -> f32 - %2 = "llvm.fadd"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_fadd_not_enough_FMF", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fdiv"(%arg1, %arg0) : (f32, f32) -> f32 - %1 = "llvm.fdiv"(%arg2, %arg0) : (f32, f32) -> f32 - %2 = "llvm.fsub"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_fsub_not_enough_FMF", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fdiv"(%arg0, %arg2) : (f32, f32) -> f32 - %1 = "llvm.fdiv"(%arg1, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fadd"(%0, %1) : (f32, f32) -> f32 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_fadd_uses1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fdiv"(%arg0, %arg2) : (f32, f32) -> f32 - %1 = "llvm.fdiv"(%arg1, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fsub"(%0, %1) : (f32, f32) -> f32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_fsub_uses2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.fdiv"(%arg0, %arg2) : (f32, f32) -> f32 - %1 = "llvm.fdiv"(%arg1, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fsub"(%0, %1) : (f32, f32) -> f32 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_fsub_uses3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.87747175E-39 : f32} : () -> f32 - %1 = "llvm.mlir.constant"() {value = 1.17549435E-38 : f32} : () -> f32 - %2 = "llvm.fdiv"(%1, %arg0) : (f32, f32) -> f32 - %3 = "llvm.fdiv"(%0, %arg0) : (f32, f32) -> f32 - %4 = "llvm.fadd"(%2, %3) : (f32, f32) -> f32 - "llvm.return"(%4) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_fadd_not_denorm", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.87747175E-39 : f32} : () -> f32 - %1 = "llvm.mlir.constant"() {value = -1.17549435E-38 : f32} : () -> f32 - %2 = "llvm.fdiv"(%1, %arg0) : (f32, f32) -> f32 - %3 = "llvm.fdiv"(%0, %arg0) : (f32, f32) -> f32 - %4 = "llvm.fadd"(%2, %3) : (f32, f32) -> f32 - "llvm.return"(%4) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_fadd_denorm", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.87747175E-39 : f32} : () -> f32 - %1 = "llvm.mlir.constant"() {value = 1.17549435E-38 : f32} : () -> f32 - %2 = "llvm.fdiv"(%1, %arg0) : (f32, f32) -> f32 - %3 = "llvm.fdiv"(%0, %arg0) : (f32, f32) -> f32 - %4 = "llvm.fsub"(%2, %3) : (f32, f32) -> f32 - "llvm.return"(%4) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_fsub_denorm", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f32} : () -> f32 - %1 = "llvm.fsub"(%0, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fmul"(%1, %arg0) : (f32, f32) -> f32 - %3 = "llvm.fmul"(%arg2, %arg1) : (f32, f32) -> f32 - %4 = "llvm.fadd"(%2, %3) : (f32, f32) -> f32 - "llvm.return"(%4) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "lerp_commute0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1.000000e+00> : vector<2xf32>} : () -> vector<2xf32> - %1 = "llvm.fsub"(%0, %arg2) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %2 = "llvm.fmul"(%1, %arg0) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %3 = "llvm.fmul"(%arg2, %arg1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %4 = "llvm.fadd"(%3, %2) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - "llvm.return"(%4) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "lerp_commute1", type = !llvm.func (vector<2xf32>, vector<2xf32>, vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f32} : () -> f32 - %1 = "llvm.fsub"(%0, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fmul"(%1, %arg0) : (f32, f32) -> f32 - %3 = "llvm.fmul"(%arg1, %arg2) : (f32, f32) -> f32 - %4 = "llvm.fadd"(%2, %3) : (f32, f32) -> f32 - "llvm.return"(%4) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "lerp_commute2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f32} : () -> f32 - %1 = "llvm.fsub"(%0, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fmul"(%1, %arg0) : (f32, f32) -> f32 - %3 = "llvm.fmul"(%arg1, %arg2) : (f32, f32) -> f32 - %4 = "llvm.fadd"(%3, %2) : (f32, f32) -> f32 - "llvm.return"(%4) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "lerp_commute3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.fsub"(%0, %arg2) : (f64, f64) -> f64 - %2 = "llvm.fmul"(%arg0, %1) : (f64, f64) -> f64 - %3 = "llvm.fmul"(%arg2, %arg1) : (f64, f64) -> f64 - %4 = "llvm.fadd"(%2, %3) : (f64, f64) -> f64 - "llvm.return"(%4) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "lerp_commute4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.fsub"(%0, %arg2) : (f64, f64) -> f64 - %2 = "llvm.fmul"(%arg0, %1) : (f64, f64) -> f64 - %3 = "llvm.fmul"(%arg2, %arg1) : (f64, f64) -> f64 - %4 = "llvm.fadd"(%3, %2) : (f64, f64) -> f64 - "llvm.return"(%4) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "lerp_commute5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f16, %arg1: f16, %arg2: f16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f32} : () -> f16 - %1 = "llvm.fsub"(%0, %arg2) : (f16, f16) -> f16 - %2 = "llvm.fmul"(%arg0, %1) : (f16, f16) -> f16 - %3 = "llvm.fmul"(%arg1, %arg2) : (f16, f16) -> f16 - %4 = "llvm.fadd"(%2, %3) : (f16, f16) -> f16 - "llvm.return"(%4) : (f16) -> () - }) {linkage = 10 : i64, sym_name = "lerp_commute6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f16, %arg1: f16, %arg2: f16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f32} : () -> f16 - %1 = "llvm.fsub"(%0, %arg2) : (f16, f16) -> f16 - %2 = "llvm.fmul"(%arg0, %1) : (f16, f16) -> f16 - %3 = "llvm.fmul"(%arg1, %arg2) : (f16, f16) -> f16 - %4 = "llvm.fadd"(%3, %2) : (f16, f16) -> f16 - "llvm.return"(%4) : (f16) -> () - }) {linkage = 10 : i64, sym_name = "lerp_commute7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f32} : () -> f32 - %1 = "llvm.fsub"(%0, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fmul"(%arg0, %1) : (f32, f32) -> f32 - %3 = "llvm.fmul"(%arg1, %arg2) : (f32, f32) -> f32 - "llvm.call"(%3) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - %4 = "llvm.fadd"(%3, %2) : (f32, f32) -> f32 - "llvm.return"(%4) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "lerp_extra_use1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f32} : () -> f32 - %1 = "llvm.fsub"(%0, %arg2) : (f32, f32) -> f32 - %2 = "llvm.fmul"(%arg0, %1) : (f32, f32) -> f32 - "llvm.call"(%2) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - %3 = "llvm.fmul"(%arg1, %arg2) : (f32, f32) -> f32 - %4 = "llvm.fadd"(%3, %2) : (f32, f32) -> f32 - "llvm.return"(%4) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "lerp_extra_use2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f32} : () -> f32 - %1 = "llvm.fsub"(%0, %arg2) : (f32, f32) -> f32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - %2 = "llvm.fmul"(%arg0, %1) : (f32, f32) -> f32 - %3 = "llvm.fmul"(%arg1, %arg2) : (f32, f32) -> f32 - %4 = "llvm.fadd"(%3, %2) : (f32, f32) -> f32 - "llvm.return"(%4) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "lerp_extra_use3", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fmul_fadd(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fmul %arg0, %arg2 : f32 + %1 = llvm.fmul %arg1, %arg2 : f32 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fmul_fadd_commute1_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fmul %arg2, %arg0 : vector<2xf32> + %1 = llvm.fmul %arg2, %arg1 : vector<2xf32> + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fmul_fadd_commute2_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fmul %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %1 = llvm.fmul %arg2, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fmul_fadd_commute3(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fmul %arg2, %arg0 : f64 + %1 = llvm.fmul %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fmul_fadd_not_enough_FMF(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fmul %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fmul %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @use(f32) + llvm.func @fmul_fadd_uses1(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fmul %arg2, %arg0 : f32 + %1 = llvm.fmul %arg1, %arg2 : f32 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%0) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @fmul_fadd_uses2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fmul %arg2, %arg0 : f32 + %1 = llvm.fmul %arg2, %arg1 : f32 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%1) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @fmul_fadd_uses3(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fmul %arg0, %arg2 : f32 + %1 = llvm.fmul %arg2, %arg1 : f32 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%0) : (f32) -> () + llvm.call @use(%1) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @fmul_fsub(%arg0: f16, %arg1: f16, %arg2: f16) -> f16 { + %0 = llvm.fmul %arg0, %arg2 : f16 + %1 = llvm.fmul %arg1, %arg2 : f16 + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %2 : f16 + } + llvm.func @fmul_fsub_commute1_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fmul %arg2, %arg0 : vector<2xf32> + %1 = llvm.fmul %arg1, %arg2 : vector<2xf32> + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fmul_fsub_commute2_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fmul %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %1 = llvm.fmul %arg2, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fmul_fsub_commute3(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fmul %arg2, %arg0 : f64 + %1 = llvm.fmul %arg2, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fmul_fsub_not_enough_FMF(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fmul %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fmul %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fmul_fsub_uses1(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fmul %arg0, %arg2 : f32 + %1 = llvm.fmul %arg1, %arg2 : f32 + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%0) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @fmul_fsub_uses2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fmul %arg2, %arg0 : f32 + %1 = llvm.fmul %arg2, %arg1 : f32 + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%1) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @fmul_fsub_uses3(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fmul %arg0, %arg2 : f32 + %1 = llvm.fmul %arg1, %arg2 : f32 + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%0) : (f32) -> () + llvm.call @use(%1) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @fdiv_fadd(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fdiv %arg0, %arg2 : f64 + %1 = llvm.fdiv %arg1, %arg2 : f64 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_fsub(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fdiv %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fdiv_fadd_vec(%arg0: vector<2xf64>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.fdiv %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %1 = llvm.fdiv %arg1, %arg2 : vector<2xf64> + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fdiv_fsub_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fdiv %arg0, %arg2 : vector<2xf32> + %1 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fdiv_fadd_commute1(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fdiv %arg2, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fdiv %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fdiv_fsub_commute2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fdiv %arg2, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fdiv %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fdiv_fadd_not_enough_FMF(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fdiv %arg1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fdiv %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fdiv_fsub_not_enough_FMF(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fdiv %arg1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fdiv %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fdiv_fadd_uses1(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fdiv %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%0) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @fdiv_fsub_uses2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fdiv %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%1) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @fdiv_fsub_uses3(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fdiv %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%0) : (f32) -> () + llvm.call @use(%1) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @fdiv_fadd_not_denorm(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.17549435E-38 : f32) : f32 + %1 = llvm.mlir.constant(5.87747175E-39 : f32) : f32 + %2 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fdiv %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @fdiv_fadd_denorm(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-1.17549435E-38 : f32) : f32 + %1 = llvm.mlir.constant(5.87747175E-39 : f32) : f32 + %2 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fdiv %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @fdiv_fsub_denorm(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.17549435E-38 : f32) : f32 + %1 = llvm.mlir.constant(5.87747175E-39 : f32) : f32 + %2 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fdiv %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fsub %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @lerp_commute0(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fmul %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %arg2, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @lerp_commute1(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<1.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg2 : vector<2xf32> + %2 = llvm.fmul %1, %arg0 : vector<2xf32> + %3 = llvm.fmul %arg2, %arg1 : vector<2xf32> + %4 = llvm.fadd %3, %2 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @lerp_commute2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg2 : f32 + %2 = llvm.fmul %1, %arg0 : f32 + %3 = llvm.fmul %arg1, %arg2 : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @lerp_commute3(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fmul %1, %arg0 : f32 + %3 = llvm.fmul %arg1, %arg2 : f32 + %4 = llvm.fadd %3, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @lerp_commute4(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fmul %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fmul %arg2, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %4 : f64 + } + llvm.func @lerp_commute5(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fmul %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fmul %arg2, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %4 = llvm.fadd %3, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %4 : f64 + } + llvm.func @lerp_commute6(%arg0: f16, %arg1: f16, %arg2: f16) -> f16 { + %0 = llvm.mlir.constant(1.000000e+00 : f16) : f16 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f16 + %2 = llvm.fmul %arg0, %1 {fastmathFlags = #llvm.fastmath} : f16 + %3 = llvm.fmul %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f16 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %4 : f16 + } + llvm.func @lerp_commute7(%arg0: f16, %arg1: f16, %arg2: f16) -> f16 { + %0 = llvm.mlir.constant(1.000000e+00 : f16) : f16 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f16 + %2 = llvm.fmul %arg0, %1 {fastmathFlags = #llvm.fastmath} : f16 + %3 = llvm.fmul %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f16 + %4 = llvm.fadd %3, %2 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %4 : f16 + } + llvm.func @lerp_extra_use1(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fmul %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%3) : (f32) -> () + %4 = llvm.fadd %3, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @lerp_extra_use2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fmul %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%2) : (f32) -> () + %3 = llvm.fmul %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %3, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @lerp_extra_use3(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fmul %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %3, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/fadd-maximum-minimum.ll.mlir b/test/LLVMDialect/InstCombine/fadd-maximum-minimum.ll.mlir new file mode 100644 index 000000000..382b61aa5 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fadd-maximum-minimum.ll.mlir @@ -0,0 +1,44 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.minimum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maximum(%arg0, %arg1) : (f32, f32) -> f32 + %2 = llvm.fadd %0, %1 : f32 + llvm.return %2 : f32 + } + llvm.func @test_comm1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.minimum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maximum(%arg0, %arg1) : (f32, f32) -> f32 + %2 = llvm.fadd %1, %0 : f32 + llvm.return %2 : f32 + } + llvm.func @test_comm2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.minimum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maximum(%arg1, %arg0) : (f32, f32) -> f32 + %2 = llvm.fadd %0, %1 : f32 + llvm.return %2 : f32 + } + llvm.func @test_comm3(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.minimum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maximum(%arg1, %arg0) : (f32, f32) -> f32 + %2 = llvm.fadd %1, %0 : f32 + llvm.return %2 : f32 + } + llvm.func @test_vect(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.intr.minimum(%arg0, %arg1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> + %1 = llvm.intr.maximum(%arg1, %arg0) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> + %2 = llvm.fadd %0, %1 : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @test_flags(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.minimum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maximum(%arg0, %arg1) : (f32, f32) -> f32 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @test_flags2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.minimum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maximum(%arg0, %arg1) : (f32, f32) -> f32 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/fadd.ll.mlir b/test/LLVMDialect/InstCombine/fadd.ll.mlir new file mode 100644 index 000000000..d525d184f --- /dev/null +++ b/test/LLVMDialect/InstCombine/fadd.ll.mlir @@ -0,0 +1,627 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(f32) + llvm.func @use_vec(vector<2xf32>) + llvm.func @fneg_op0(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fadd %1, %arg1 : f32 + llvm.return %2 : f32 + } + llvm.func @fneg_op1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg1 : f32 + %2 = llvm.fadd %arg0, %1 : f32 + llvm.return %2 : f32 + } + llvm.func @fdiv_fneg1(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.mlir.constant(4.200000e+01 : f64) : f64 + %1 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %2 = llvm.frem %0, %arg2 : f64 + %3 = llvm.fsub %1, %arg0 : f64 + %4 = llvm.fdiv %3, %arg1 : f64 + %5 = llvm.fadd %2, %4 : f64 + llvm.return %5 : f64 + } + llvm.func @fdiv_fneg2(%arg0: vector<2xf64>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[4.200000e+01, 8.000000e+00]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.frem %0, %arg2 : vector<2xf64> + %3 = llvm.fsub %1, %arg0 : vector<2xf64> + %4 = llvm.fdiv %arg1, %3 : vector<2xf64> + %5 = llvm.fadd %2, %4 : vector<2xf64> + llvm.return %5 : vector<2xf64> + } + llvm.func @fmul_fneg1(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.mlir.constant(4.200000e+01 : f64) : f64 + %1 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %2 = llvm.frem %0, %arg2 : f64 + %3 = llvm.fsub %1, %arg0 : f64 + %4 = llvm.fmul %3, %arg1 : f64 + %5 = llvm.fadd %2, %4 : f64 + llvm.return %5 : f64 + } + llvm.func @fmul_fneg2(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.mlir.constant(-4.200000e+01 : f64) : f64 + %1 = llvm.mlir.constant(4.200000e+01 : f64) : f64 + %2 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %3 = llvm.frem %0, %arg1 : f64 + %4 = llvm.frem %1, %arg2 : f64 + %5 = llvm.fsub %2, %arg0 : f64 + %6 = llvm.fmul %3, %5 : f64 + %7 = llvm.fadd %4, %6 : f64 + llvm.return %7 : f64 + } + llvm.func @fdiv_fneg1_commute(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.mlir.constant(4.200000e+01 : f64) : f64 + %1 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %2 = llvm.frem %0, %arg2 : f64 + %3 = llvm.fsub %1, %arg0 : f64 + %4 = llvm.fdiv %3, %arg1 : f64 + %5 = llvm.fadd %4, %2 : f64 + llvm.return %5 : f64 + } + llvm.func @fdiv_fneg2_commute(%arg0: vector<2xf64>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[4.200000e+01, 8.000000e+00]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.frem %0, %arg2 : vector<2xf64> + %3 = llvm.fsub %1, %arg0 : vector<2xf64> + %4 = llvm.fdiv %arg1, %3 : vector<2xf64> + %5 = llvm.fadd %4, %2 : vector<2xf64> + llvm.return %5 : vector<2xf64> + } + llvm.func @fmul_fneg1_commute(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.mlir.constant(4.200000e+01 : f64) : f64 + %1 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %2 = llvm.frem %0, %arg2 : f64 + %3 = llvm.fsub %1, %arg0 : f64 + %4 = llvm.fmul %3, %arg1 : f64 + %5 = llvm.fadd %4, %2 : f64 + llvm.return %5 : f64 + } + llvm.func @fmul_fneg2_commute(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.mlir.constant(4.100000e+01 : f64) : f64 + %1 = llvm.mlir.constant(4.200000e+01 : f64) : f64 + %2 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %3 = llvm.frem %0, %arg1 : f64 + %4 = llvm.frem %1, %arg2 : f64 + %5 = llvm.fsub %2, %arg0 : f64 + %6 = llvm.fmul %3, %5 : f64 + %7 = llvm.fadd %6, %4 : f64 + llvm.return %7 : f64 + } + llvm.func @fdiv_fneg1_extra_use(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.frem %0, %arg2 : f32 + %3 = llvm.fsub %1, %arg0 : f32 + %4 = llvm.fdiv %3, %arg1 : f32 + llvm.call @use(%4) : (f32) -> () + %5 = llvm.fadd %2, %4 : f32 + llvm.return %5 : f32 + } + llvm.func @fdiv_fneg2_extra_use(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %2 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %3 = llvm.frem %0, %arg1 : f32 + %4 = llvm.frem %1, %arg2 : f32 + %5 = llvm.fsub %2, %arg0 : f32 + %6 = llvm.fdiv %3, %5 : f32 + llvm.call @use(%6) : (f32) -> () + %7 = llvm.fadd %4, %6 : f32 + llvm.return %7 : f32 + } + llvm.func @fmul_fneg1_extra_use(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[4.200000e+01, -1.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.frem %0, %arg2 : vector<2xf32> + %3 = llvm.fsub %1, %arg0 : vector<2xf32> + %4 = llvm.fmul %3, %arg1 : vector<2xf32> + llvm.call @use_vec(%4) : (vector<2xf32>) -> () + %5 = llvm.fadd %2, %4 : vector<2xf32> + llvm.return %5 : vector<2xf32> + } + llvm.func @fmul_fneg2_extra_use(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %2 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %3 = llvm.frem %0, %arg1 : f32 + %4 = llvm.frem %1, %arg2 : f32 + %5 = llvm.fsub %2, %arg0 : f32 + %6 = llvm.fmul %3, %5 : f32 + llvm.call @use(%6) : (f32) -> () + %7 = llvm.fadd %4, %6 : f32 + llvm.return %7 : f32 + } + llvm.func @fdiv_fneg1_extra_use2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fdiv %1, %arg1 : f32 + %3 = llvm.fadd %2, %arg2 : f32 + llvm.return %3 : f32 + } + llvm.func @fdiv_fneg2_extra_use2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fdiv %arg1, %1 : f32 + %3 = llvm.fadd %2, %arg2 : f32 + llvm.return %3 : f32 + } + llvm.func @fmul_fneg1_extra_use2(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 : vector<2xf32> + llvm.call @use_vec(%1) : (vector<2xf32>) -> () + %2 = llvm.fmul %1, %arg1 : vector<2xf32> + %3 = llvm.fadd %2, %arg2 : vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @fmul_fneg2_extra_use2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.frem %0, %arg1 : f32 + %3 = llvm.fsub %1, %arg0 : f32 + llvm.call @use(%3) : (f32) -> () + %4 = llvm.fmul %2, %3 : f32 + %5 = llvm.fadd %4, %arg2 : f32 + llvm.return %5 : f32 + } + llvm.func @fdiv_fneg1_extra_use3(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fdiv %1, %arg1 : f32 + llvm.call @use(%2) : (f32) -> () + %3 = llvm.fadd %2, %arg2 : f32 + llvm.return %3 : f32 + } + llvm.func @fdiv_fneg2_extra_use3(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fdiv %arg1, %1 : f32 + llvm.call @use(%2) : (f32) -> () + %3 = llvm.fadd %2, %arg2 : f32 + llvm.return %3 : f32 + } + llvm.func @fmul_fneg1_extra_use3(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 : vector<2xf32> + llvm.call @use_vec(%1) : (vector<2xf32>) -> () + %2 = llvm.fmul %1, %arg1 : vector<2xf32> + llvm.call @use_vec(%2) : (vector<2xf32>) -> () + %3 = llvm.fadd %2, %arg2 : vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @fmul_fneg2_extra_use3(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.frem %0, %arg1 : f32 + %3 = llvm.fsub %1, %arg0 : f32 + llvm.call @use(%3) : (f32) -> () + %4 = llvm.fmul %2, %3 : f32 + llvm.call @use(%4) : (f32) -> () + %5 = llvm.fadd %4, %arg2 : f32 + llvm.return %5 : f32 + } + llvm.func @fadd_rdx(%arg0: f32, %arg1: vector<4xf32>) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = "llvm.intr.vector.reduce.fadd"(%0, %arg1) <{fastmathFlags = #llvm.fastmath}> : (f32, vector<4xf32>) -> f32 + %2 = llvm.fadd %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fadd_rdx_commute(%arg0: f32, %arg1: vector<4xf32>) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.fdiv %0, %arg0 : f32 + %3 = "llvm.intr.vector.reduce.fadd"(%1, %arg1) <{fastmathFlags = #llvm.fastmath}> : (f32, vector<4xf32>) -> f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @fadd_rdx_fmf(%arg0: f32, %arg1: vector<4xf32>) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = "llvm.intr.vector.reduce.fadd"(%0, %arg1) <{fastmathFlags = #llvm.fastmath}> : (f32, vector<4xf32>) -> f32 + %2 = llvm.fadd %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fadd_rdx_extra_use(%arg0: f32, %arg1: vector<4xf32>) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = "llvm.intr.vector.reduce.fadd"(%0, %arg1) <{fastmathFlags = #llvm.fastmath}> : (f32, vector<4xf32>) -> f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fadd %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fadd_rdx_nonzero_start_const_op(%arg0: vector<4xf32>) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(-9.000000e+00 : f32) : f32 + %2 = "llvm.intr.vector.reduce.fadd"(%0, %arg0) <{fastmathFlags = #llvm.fastmath}> : (f32, vector<4xf32>) -> f32 + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fadd_rdx_nonzero_start_variable_op(%arg0: f32, %arg1: vector<4xf32>) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = "llvm.intr.vector.reduce.fadd"(%0, %arg1) <{fastmathFlags = #llvm.fastmath}> : (f32, vector<4xf32>) -> f32 + %2 = llvm.fadd %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fadd_fmul_common_op(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fadd_fmul_common_op_vec(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<4.200000e+01> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %2 = llvm.fadd %1, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fadd_fmul_common_op_commute_vec(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[4.200000e+01, -4.300000e+01]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fmul %arg0, %arg0 : vector<2xf32> + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %3 = llvm.fadd %1, %2 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @fadd_fmul_common_op_use(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fadd %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fadd_fmul_common_op_wrong_fmf(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fadd_fneg_reass_commute0(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%0) : (f32) -> () + %1 = llvm.fsub %0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %1, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fadd_fneg_reass_commute1(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + llvm.call @use(%0) : (f32) -> () + %1 = llvm.fsub %0, %arg1 : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fadd %arg0, %arg2 : f32 + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fadd_fneg_reass_commute2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + llvm.call @use(%0) : (f32) -> () + %1 = llvm.fsub %0, %arg1 : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fadd %arg2, %arg0 : f32 + llvm.call @use(%2) : (f32) -> () + %3 = llvm.fadd %1, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fadd_fneg_reass_commute3(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.call @use_vec(%0) : (vector<2xf32>) -> () + %1 = llvm.fsub %0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %2 = llvm.fadd %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @fadd_fneg_commute0(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + llvm.call @use(%0) : (f32) -> () + %1 = llvm.fsub %0, %arg1 : f32 + %2 = llvm.fadd %arg0, %arg2 : f32 + %3 = llvm.fadd %1, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varA(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg0 : f32 + %2 = llvm.fmul %arg0, %0 : f32 + %3 = llvm.fadd %2, %arg1 : f32 + %4 = llvm.fmul %3, %arg1 : f32 + %5 = llvm.fadd %4, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varA_order2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg0 : f32 + %2 = llvm.fmul %arg0, %0 : f32 + %3 = llvm.fadd %2, %arg1 : f32 + %4 = llvm.fmul %3, %arg1 : f32 + %5 = llvm.fadd %1, %4 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varA_order3(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg0 : f32 + %2 = llvm.fmul %arg0, %0 : f32 + %3 = llvm.fadd %2, %arg1 : f32 + %4 = llvm.fmul %arg1, %3 : f32 + %5 = llvm.fadd %4, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varA_order4(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg0 : f32 + %2 = llvm.fmul %arg0, %0 : f32 + %3 = llvm.fadd %arg1, %2 : f32 + %4 = llvm.fmul %3, %arg1 : f32 + %5 = llvm.fadd %4, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varA_order5(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg0 : f32 + %2 = llvm.fmul %0, %arg0 : f32 + %3 = llvm.fadd %2, %arg1 : f32 + %4 = llvm.fmul %3, %arg1 : f32 + %5 = llvm.fadd %4, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg1 : f32 + %2 = llvm.fmul %1, %0 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB_order1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg1 : f32 + %2 = llvm.fmul %1, %0 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %5, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB_order2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg1 : f32 + %2 = llvm.fmul %1, %0 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %4, %3 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB_order3(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg1, %arg0 : f32 + %2 = llvm.fmul %0, %1 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %0 : f32 + %2 = llvm.fmul %1, %arg1 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB2_order1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %0 : f32 + %2 = llvm.fmul %1, %arg1 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %5, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB2_order2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %0 : f32 + %2 = llvm.fmul %arg1, %1 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB2_order3(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %0, %arg0 : f32 + %2 = llvm.fmul %1, %arg1 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varA_not_one_use1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg0 : f32 + %2 = llvm.fmul %arg0, %0 : f32 + %3 = llvm.fadd %2, %arg1 : f32 + %4 = llvm.fmul %3, %arg1 : f32 + %5 = llvm.fadd %4, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @fake_func(%4) : (f32) -> () + llvm.return %5 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varA_not_one_use2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg0 : f32 + %2 = llvm.fmul %arg0, %0 : f32 + %3 = llvm.fadd %2, %arg1 : f32 + %4 = llvm.fmul %3, %arg1 : f32 + %5 = llvm.fadd %4, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @fake_func(%1) : (f32) -> () + llvm.return %5 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB_not_one_use1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg1 : f32 + %2 = llvm.fmul %1, %0 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @fake_func(%2) : (f32) -> () + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB_not_one_use2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg1 : f32 + %2 = llvm.fmul %1, %0 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @fake_func(%5) : (f32) -> () + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB2_not_one_use(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %0 : f32 + %2 = llvm.fmul %1, %arg1 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @fake_func(%2) : (f32) -> () + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varA_invalid1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg0 : f32 + %2 = llvm.fmul %arg0, %0 : f32 + %3 = llvm.fadd %2, %arg1 : f32 + %4 = llvm.fmul %3, %arg0 : f32 + %5 = llvm.fadd %4, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varA_invalid2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg0 : f32 + %2 = llvm.fmul %arg0, %0 : f32 + %3 = llvm.fadd %2, %arg0 : f32 + %4 = llvm.fmul %3, %arg1 : f32 + %5 = llvm.fadd %4, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varA_invalid3(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.100000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg0 : f32 + %2 = llvm.fmul %arg0, %0 : f32 + %3 = llvm.fadd %2, %arg1 : f32 + %4 = llvm.fmul %3, %arg1 : f32 + %5 = llvm.fadd %4, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varA_invalid4(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg0 : f32 + %2 = llvm.fmul %arg1, %0 : f32 + %3 = llvm.fadd %2, %arg1 : f32 + %4 = llvm.fmul %3, %arg1 : f32 + %5 = llvm.fadd %4, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varA_invalid5(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg1 : f32 + %2 = llvm.fmul %arg0, %0 : f32 + %3 = llvm.fadd %2, %arg1 : f32 + %4 = llvm.fmul %3, %arg1 : f32 + %5 = llvm.fadd %4, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB_invalid1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg1 : f32 + %2 = llvm.fmul %1, %0 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg0 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB_invalid2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg1 : f32 + %2 = llvm.fmul %1, %0 : f32 + %3 = llvm.fmul %arg0, %arg1 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB_invalid3(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.100000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg1 : f32 + %2 = llvm.fmul %1, %0 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB_invalid4(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %arg0 : f32 + %2 = llvm.fmul %1, %0 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB_invalid5(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg1, %arg1 : f32 + %2 = llvm.fmul %1, %0 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB2_invalid1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %0 : f32 + %2 = llvm.fmul %1, %arg0 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB2_invalid2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.100000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %0 : f32 + %2 = llvm.fmul %1, %arg1 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fadd_reduce_sqr_sum_varB2_invalid3(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg1, %0 : f32 + %2 = llvm.fmul %1, %arg1 : f32 + %3 = llvm.fmul %arg0, %arg0 : f32 + %4 = llvm.fmul %arg1, %arg1 : f32 + %5 = llvm.fadd %3, %4 : f32 + %6 = llvm.fadd %2, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @fake_func(f32) +} diff --git a/test/LLVMDialect/InstCombine/fast-basictest.ll.mlir b/test/LLVMDialect/InstCombine/fast-basictest.ll.mlir new file mode 100644 index 000000000..70604ce1a --- /dev/null +++ b/test/LLVMDialect/InstCombine/fast-basictest.ll.mlir @@ -0,0 +1,390 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-1.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1.200000e+01 : f32) : f32 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @test1_minimal(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-1.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1.200000e+01 : f32) : f32 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @test1_reassoc(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-1.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1.200000e+01 : f32) : f32 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @test2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-3.000000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3.000000e+01 : f32) : f32 + %2 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %3, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @test2_no_FMF(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-3.000000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3.000000e+01 : f32) : f32 + %2 = llvm.fadd %arg0, %0 : f32 + %3 = llvm.fadd %2, %arg1 : f32 + %4 = llvm.fadd %3, %1 : f32 + llvm.return %4 : f32 + } + llvm.func @test2_reassoc(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-3.000000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3.000000e+01 : f32) : f32 + %2 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %3, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @test7(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fmul %1, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @test7_unary_fneg(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fmul %0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @test7_reassoc_nsz(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fmul %1, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @test7_reassoc(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fmul %1, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @test8(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(4.700000e+01 : f32) : f32 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @test8_reassoc_nsz(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(4.700000e+01 : f32) : f32 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @test8_reassoc(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(4.700000e+01 : f32) : f32 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @test9(%arg0: f32) -> f32 { + %0 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fadd %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @test9_reassoc_nsz(%arg0: f32) -> f32 { + %0 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fadd %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @test9_reassoc(%arg0: f32) -> f32 { + %0 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fadd %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @test10(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.270000e+02 : f32) : f32 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @test10_reassoc_nsz(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.270000e+02 : f32) : f32 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @test10_reassoc(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.270000e+02 : f32) : f32 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @test11(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %3 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.fsub %2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %6 = llvm.fadd %3, %4 {fastmathFlags = #llvm.fastmath} : f32 + %7 = llvm.fadd %6, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %7 : f32 + } + llvm.func @test11_reassoc_nsz(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %3 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.fsub %2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %6 = llvm.fadd %3, %4 {fastmathFlags = #llvm.fastmath} : f32 + %7 = llvm.fadd %6, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %7 : f32 + } + llvm.func @test11_reassoc(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %3 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.fsub %2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %6 = llvm.fadd %3, %4 {fastmathFlags = #llvm.fastmath} : f32 + %7 = llvm.fadd %6, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %7 : f32 + } + llvm.func @test12(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fmul %1, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @test12_unary_fneg(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fmul %0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fmul %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %1, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @test12_reassoc_nsz(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fmul %1, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @test12_reassoc(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fmul %1, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @test13(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(4.700000e+01 : f32) : f32 + %1 = llvm.mlir.constant(-4.700000e+01 : f32) : f32 + %2 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %arg1, %1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @test13_reassoc_nsz(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(4.700000e+01 : f32) : f32 + %1 = llvm.mlir.constant(-4.700000e+01 : f32) : f32 + %2 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %arg1, %1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @test13_reassoc(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(4.700000e+01 : f32) : f32 + %1 = llvm.mlir.constant(-4.700000e+01 : f32) : f32 + %2 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %arg1, %1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @test14(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.200000e+01 : f32) : f32 + %1 = llvm.fmul %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @test14_reassoc(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.200000e+01 : f32) : f32 + %1 = llvm.fmul %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @test15(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.234000e+03 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fadd %arg1, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %arg0, %2 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fsub %1, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.fadd %3, %4 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @test15_unary_fneg(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.234000e+03 : f32) : f32 + %1 = llvm.fadd %arg1, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fneg %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @test15_reassoc_nsz(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.234000e+03 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fadd %arg1, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %arg0, %2 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fsub %1, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.fadd %3, %4 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @test15_reassoc(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.234000e+03 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fadd %arg1, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %arg0, %2 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fsub %1, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.fadd %3, %4 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @test16(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.234500e+04 : f32) : f32 + %2 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fmul %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.fmul %4, %1 {fastmathFlags = #llvm.fastmath} : f32 + %6 = llvm.fsub %0, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @test16_unary_fneg(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(1.234500e+04 : f32) : f32 + %1 = llvm.fneg %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fmul %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %1, %2 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fmul %3, %0 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.fneg %4 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @test16_reassoc_nsz(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.234500e+04 : f32) : f32 + %2 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fmul %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.fmul %4, %1 {fastmathFlags = #llvm.fastmath} : f32 + %6 = llvm.fsub %0, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @test16_reassoc(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.234500e+04 : f32) : f32 + %2 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fmul %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.fmul %4, %1 {fastmathFlags = #llvm.fastmath} : f32 + %6 = llvm.fsub %0, %5 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %6 : f32 + } + llvm.func @test17(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+01 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fmul %arg2, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fsub %1, %2 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fmul %arg0, %3 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.fsub %1, %4 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @test17_unary_fneg(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+01 : f32) : f32 + %1 = llvm.fmul %arg2, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fneg %1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %arg0, %2 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fneg %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @test17_reassoc_nsz(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+01 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fmul %arg2, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fsub %1, %2 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fmul %arg0, %3 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.fsub %1, %4 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @test17_reassoc(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+01 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fmul %arg2, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fsub %1, %2 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fmul %arg0, %3 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.fsub %1, %4 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %5 : f32 + } + llvm.func @test17_unary_fneg_no_FMF(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+01 : f32) : f32 + %1 = llvm.fmul %arg2, %0 : f32 + %2 = llvm.fneg %1 : f32 + %3 = llvm.fmul %arg0, %2 : f32 + %4 = llvm.fneg %3 : f32 + llvm.return %4 : f32 + } + llvm.func @test17_reassoc_unary_fneg(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+01 : f32) : f32 + %1 = llvm.fmul %arg2, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fneg %1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %arg0, %2 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fneg %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @test18(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-1.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1.200000e+01 : f32) : f32 + %2 = llvm.fadd %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fsub %2, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %3, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @test18_reassoc(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-1.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1.200000e+01 : f32) : f32 + %2 = llvm.fadd %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fsub %2, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %3, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @test19(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @test19_reassoc_nsz(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @test19_reassoc(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/fast-math.ll.mlir b/test/LLVMDialect/InstCombine/fast-math.ll.mlir new file mode 100644 index 000000000..806dfe89b --- /dev/null +++ b/test/LLVMDialect/InstCombine/fast-math.ll.mlir @@ -0,0 +1,459 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fold(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.200000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.300000e+00 : f32) : f32 + %2 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @notfold(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.200000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.300000e+00 : f32) : f32 + %2 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fmul %2, %1 : f32 + llvm.return %3 : f32 + } + llvm.func @fold2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.200000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.300000e+00 : f32) : f32 + %2 = llvm.fmul %arg0, %0 : f32 + %3 = llvm.fmul %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fold3(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e+00 : f64) : f64 + %1 = llvm.fmul %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fadd %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fold3_reassoc_nsz(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e+00 : f64) : f64 + %1 = llvm.fmul %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fadd %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fold3_reassoc(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e+00 : f64) : f64 + %1 = llvm.fmul %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fadd %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fold4(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %2 = llvm.fsub %0, %arg0 : f32 + %3 = llvm.fsub %1, %arg1 : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @fold4_reassoc_nsz(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %2 = llvm.fsub %0, %arg0 : f32 + %3 = llvm.fsub %1, %arg1 : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @fold4_reassoc(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %2 = llvm.fsub %0, %arg0 : f32 + %3 = llvm.fsub %1, %arg1 : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @fold5(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %2 = llvm.fadd %arg0, %0 : f32 + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fold5_reassoc_nsz(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %2 = llvm.fadd %arg0, %0 : f32 + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fold5_reassoc(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %2 = llvm.fadd %arg0, %0 : f32 + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fold6(%arg0: f32) -> f32 { + %0 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fold6_reassoc_nsz(%arg0: f32) -> f32 { + %0 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fold6_reassoc(%arg0: f32) -> f32 { + %0 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fold7(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %1, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fold7_reassoc_nsz(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %1, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fold7_reassoc(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %1, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fold8(%arg0: f32) -> f32 { + %0 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fold8_reassoc_nsz(%arg0: f32) -> f32 { + %0 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fold8_reassoc(%arg0: f32) -> f32 { + %0 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fadd %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fsub_fadd_common_op_fneg(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fadd %arg0, %arg1 : f32 + %1 = llvm.fsub %arg1, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @fsub_fadd_common_op_fneg_reassoc_nsz(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fadd %arg0, %arg1 : f32 + %1 = llvm.fsub %arg1, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @fsub_fadd_common_op_fneg_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fadd %arg0, %arg1 : vector<2xf32> + %1 = llvm.fsub %arg1, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @fsub_fadd_common_op_fneg_commute(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fadd %arg1, %arg0 : f32 + %1 = llvm.fsub %arg1, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @fsub_fadd_common_op_fneg_commute_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fadd %arg1, %arg0 : vector<2xf32> + %1 = llvm.fsub %arg1, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @fsub_fsub_common_op_fneg(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fsub %arg1, %arg0 : f32 + %1 = llvm.fsub %0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @fsub_fsub_common_op_fneg_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fsub %arg1, %arg0 : vector<2xf32> + %1 = llvm.fsub %0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @fold9_reassoc(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fadd %arg0, %arg1 : f32 + %1 = llvm.fsub %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @fold10(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %2 = llvm.fadd %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fsub %arg1, %1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @fold10_reassoc_nsz(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %2 = llvm.fadd %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fsub %arg1, %1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @fold10_reassoc(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %2 = llvm.fadd %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fsub %arg1, %1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @fail1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %1, %1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fadd %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fail2(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fadd %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fsub_op0_fmul_const(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %0 : f32 + %2 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fsub_op0_fmul_const_vec(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[7.000000e+00, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fmul %arg0, %0 : vector<2xf32> + %2 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fsub_op1_fmul_const(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %0 : f32 + %2 = llvm.fsub %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fsub_op1_fmul_const_vec(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[7.000000e+00, 0.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fmul %arg0, %0 : vector<2xf32> + %2 = llvm.fsub %arg0, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fsub_op0_fmul_const_wrong_FMF(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fold16(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "ogt" %arg0, %arg1 : f32 + %1 = llvm.fadd %arg0, %arg1 : f32 + %2 = llvm.fsub %arg0, %arg1 : f32 + %3 = llvm.select %0, %1, %2 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @fneg1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fsub %0, %arg0 : f32 + %3 = llvm.fsub %1, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.fmul %2, %3 : f32 + llvm.return %4 : f32 + } + llvm.func @fneg2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @fneg2_vec_poison(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.poison : f32 + %2 = llvm.mlir.undef : vector<2xf32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf32> + %7 = llvm.fsub %6, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %7 : vector<2xf32> + } + llvm.func @fdiv1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.200000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.300000e+00 : f32) : f32 + %2 = llvm.fdiv %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fdiv %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fdiv2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.200000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.300000e+00 : f32) : f32 + %2 = llvm.fmul %arg0, %0 : f32 + %3 = llvm.fdiv %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fdiv2_vec(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[6.000000e+00, 9.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.constant(dense<[2.000000e+00, 3.000000e+00]> : vector<2xf32>) : vector<2xf32> + %2 = llvm.fmul %arg0, %0 : vector<2xf32> + %3 = llvm.fdiv %2, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @fdiv3(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(3.40282347E+38 : f32) : f32 + %1 = llvm.mlir.constant(2.300000e+00 : f32) : f32 + %2 = llvm.fdiv %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fdiv %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fdiv4(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(3.40282347E+38 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e-01 : f32) : f32 + %2 = llvm.fmul %arg0, %0 : f32 + %3 = llvm.fdiv %2, %1 : f32 + llvm.return %3 : f32 + } + llvm.func @sqrt_intrinsic_arg_squared(%arg0: f64) -> f64 { + %0 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sqrt_intrinsic_three_args1(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fmul %arg1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fmul %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.intr.sqrt(%1) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_intrinsic_three_args2(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fmul %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fmul %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.intr.sqrt(%1) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_intrinsic_three_args3(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fmul %0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.intr.sqrt(%1) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_intrinsic_three_args4(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fmul %arg1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.intr.sqrt(%1) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_intrinsic_three_args5(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fmul %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.intr.sqrt(%1) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_intrinsic_three_args6(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fmul %arg1, %0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.intr.sqrt(%1) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_intrinsic_not_so_fast(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fmul %arg0, %arg0 : f64 + %1 = llvm.fmul %0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.intr.sqrt(%1) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_intrinsic_arg_4th(%arg0: f64) -> f64 { + %0 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fmul %0, %0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.intr.sqrt(%1) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_intrinsic_arg_5th(%arg0: f64) -> f64 { + %0 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fmul %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.intr.sqrt(%2) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %3 : f64 + } + llvm.func @sqrtf(f32) -> f32 + llvm.func @sqrt(f64) -> f64 + llvm.func @sqrtl(f128) -> f128 + llvm.func @sqrt_call_squared_f32(%arg0: f32) -> f32 { + %0 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.call @sqrtf(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @sqrt_call_squared_f64(%arg0: f64) -> f64 { + %0 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.call @sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sqrt_call_squared_f128(%arg0: f128) -> f128 { + %0 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f128 + %1 = llvm.call @sqrtl(%0) {fastmathFlags = #llvm.fastmath} : (f128) -> f128 + llvm.return %1 : f128 + } + llvm.func @fmax(f64, f64) -> f64 + llvm.func @fmin(f64, f64) -> f64 + llvm.func @fmaxf(f32, f32) -> f32 + llvm.func @fminf(f32, f32) -> f32 + llvm.func @fmaxl(f128, f128) -> f128 + llvm.func @fminl(f128, f128) -> f128 + llvm.func @max1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @fmax(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @fmax_no_fmf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.call @fmaxf(%arg0, %arg1) : (f32, f32) -> f32 + llvm.return %0 : f32 + } + llvm.func @max2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.call @fmaxf(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %0 : f32 + } + llvm.func @max3(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.call @fmax(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %0 : f64 + } + llvm.func @max4(%arg0: f128, %arg1: f128) -> f128 { + %0 = llvm.call @fmaxl(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f128, f128) -> f128 + llvm.return %0 : f128 + } + llvm.func @min1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @fmin(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @fmin_no_fmf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.call @fminf(%arg0, %arg1) : (f32, f32) -> f32 + llvm.return %0 : f32 + } + llvm.func @min2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.call @fminf(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %0 : f32 + } + llvm.func @min3(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.call @fmin(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %0 : f64 + } + llvm.func @min4(%arg0: f128, %arg1: f128) -> f128 { + %0 = llvm.call @fminl(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f128, f128) -> f128 + llvm.return %0 : f128 + } + llvm.func @test55(%arg0: i1, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + llvm.cond_br %arg0, ^bb2(%0 : f32), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1 : f32) + ^bb2(%2: f32): // 2 preds: ^bb0, ^bb1 + %3 = llvm.fadd %2, %1 : f32 + llvm.return %3 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/fcmp-denormals-are-zero.ll.mlir b/test/LLVMDialect/InstCombine/fcmp-denormals-are-zero.ll.mlir new file mode 100644 index 000000000..d430b2bc8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fcmp-denormals-are-zero.ll.mlir @@ -0,0 +1,211 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @var() {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.func @denormal_input_preserve_sign_fcmp_olt_smallest_normalized(%arg0: f32, %arg1: f64, %arg2: f16) attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(1.17549435E-38 : f32) : f32 + %1 = llvm.mlir.addressof @var : !llvm.ptr + %2 = llvm.mlir.constant(2.2250738585072014E-308 : f64) : f64 + %3 = llvm.mlir.constant(6.103520e-05 : f16) : f16 + %4 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %5 = llvm.fcmp "olt" %4, %0 : f32 + llvm.store volatile %5, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %6 = llvm.intr.fabs(%arg1) : (f64) -> f64 + %7 = llvm.fcmp "olt" %6, %2 : f64 + llvm.store volatile %7, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %8 = llvm.intr.fabs(%arg2) : (f16) -> f16 + %9 = llvm.fcmp "olt" %8, %3 : f16 + llvm.store volatile %9, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %10 = llvm.intr.fabs(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %11 = llvm.fcmp "olt" %10, %0 : f32 + llvm.store volatile %11, %1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return + } + llvm.func @denormal_input_preserve_sign_fcmp_uge_smallest_normalized(%arg0: f32, %arg1: f64, %arg2: f16) attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(1.17549435E-38 : f32) : f32 + %1 = llvm.mlir.addressof @var : !llvm.ptr + %2 = llvm.mlir.constant(2.2250738585072014E-308 : f64) : f64 + %3 = llvm.mlir.constant(6.103520e-05 : f16) : f16 + %4 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %5 = llvm.fcmp "uge" %4, %0 : f32 + llvm.store volatile %5, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %6 = llvm.intr.fabs(%arg1) : (f64) -> f64 + %7 = llvm.fcmp "uge" %6, %2 : f64 + llvm.store volatile %7, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %8 = llvm.intr.fabs(%arg2) : (f16) -> f16 + %9 = llvm.fcmp "uge" %8, %3 : f16 + llvm.store volatile %9, %1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return + } + llvm.func @denormal_input_preserve_sign_fcmp_oge_smallest_normalized(%arg0: f32, %arg1: f64, %arg2: f16) attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(1.17549435E-38 : f32) : f32 + %1 = llvm.mlir.addressof @var : !llvm.ptr + %2 = llvm.mlir.constant(2.2250738585072014E-308 : f64) : f64 + %3 = llvm.mlir.constant(6.103520e-05 : f16) : f16 + %4 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %5 = llvm.fcmp "oge" %4, %0 : f32 + llvm.store volatile %5, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %6 = llvm.intr.fabs(%arg1) : (f64) -> f64 + %7 = llvm.fcmp "oge" %6, %2 : f64 + llvm.store volatile %7, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %8 = llvm.intr.fabs(%arg2) : (f16) -> f16 + %9 = llvm.fcmp "oge" %8, %3 : f16 + llvm.store volatile %9, %1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return + } + llvm.func @denormal_input_preserve_sign_fcmp_ult_smallest_normalized(%arg0: f32, %arg1: f64, %arg2: f16) attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(1.17549435E-38 : f32) : f32 + %1 = llvm.mlir.addressof @var : !llvm.ptr + %2 = llvm.mlir.constant(2.2250738585072014E-308 : f64) : f64 + %3 = llvm.mlir.constant(6.103520e-05 : f16) : f16 + %4 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %5 = llvm.fcmp "ult" %4, %0 : f32 + llvm.store volatile %5, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %6 = llvm.intr.fabs(%arg1) : (f64) -> f64 + %7 = llvm.fcmp "ult" %6, %2 : f64 + llvm.store volatile %7, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %8 = llvm.intr.fabs(%arg2) : (f16) -> f16 + %9 = llvm.fcmp "ult" %8, %3 : f16 + llvm.store volatile %9, %1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return + } + llvm.func @denormal_input_preserve_sign_vector_fcmp_olt_smallest_normalized(%arg0: vector<2xf32>, %arg1: vector<2xf64>, %arg2: vector<2xf16>) attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(dense<1.17549435E-38> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.addressof @var : !llvm.ptr + %2 = llvm.mlir.constant(dense<2.2250738585072014E-308> : vector<2xf64>) : vector<2xf64> + %3 = llvm.mlir.constant(dense<6.103520e-05> : vector<2xf16>) : vector<2xf16> + %4 = llvm.intr.fabs(%arg0) : (vector<2xf32>) -> vector<2xf32> + %5 = llvm.fcmp "olt" %4, %0 : vector<2xf32> + llvm.store volatile %5, %1 {alignment = 1 : i64} : vector<2xi1>, !llvm.ptr + %6 = llvm.intr.fabs(%arg1) : (vector<2xf64>) -> vector<2xf64> + %7 = llvm.fcmp "olt" %6, %2 : vector<2xf64> + llvm.store volatile %7, %1 {alignment = 1 : i64} : vector<2xi1>, !llvm.ptr + %8 = llvm.intr.fabs(%arg2) : (vector<2xf16>) -> vector<2xf16> + %9 = llvm.fcmp "olt" %8, %3 : vector<2xf16> + llvm.store volatile %9, %1 {alignment = 1 : i64} : vector<2xi1>, !llvm.ptr + llvm.return + } + llvm.func @denormal_input_preserve_sign_vector_fcmp_uge_smallest_normalized(%arg0: vector<2xf32>, %arg1: vector<2xf64>, %arg2: vector<2xf16>) attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(dense<1.17549435E-38> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.addressof @var : !llvm.ptr + %2 = llvm.mlir.constant(dense<2.2250738585072014E-308> : vector<2xf64>) : vector<2xf64> + %3 = llvm.mlir.constant(dense<6.103520e-05> : vector<2xf16>) : vector<2xf16> + %4 = llvm.intr.fabs(%arg0) : (vector<2xf32>) -> vector<2xf32> + %5 = llvm.fcmp "uge" %4, %0 : vector<2xf32> + llvm.store volatile %5, %1 {alignment = 1 : i64} : vector<2xi1>, !llvm.ptr + %6 = llvm.intr.fabs(%arg1) : (vector<2xf64>) -> vector<2xf64> + %7 = llvm.fcmp "uge" %6, %2 : vector<2xf64> + llvm.store volatile %7, %1 {alignment = 1 : i64} : vector<2xi1>, !llvm.ptr + %8 = llvm.intr.fabs(%arg2) : (vector<2xf16>) -> vector<2xf16> + %9 = llvm.fcmp "uge" %8, %3 : vector<2xf16> + llvm.store volatile %9, %1 {alignment = 1 : i64} : vector<2xi1>, !llvm.ptr + llvm.return + } + llvm.func @denormal_input_preserve_sign_vector_fcmp_oge_smallest_normalized(%arg0: vector<2xf32>, %arg1: vector<2xf64>, %arg2: vector<2xf16>) attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(dense<1.17549435E-38> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.addressof @var : !llvm.ptr + %2 = llvm.mlir.constant(dense<2.2250738585072014E-308> : vector<2xf64>) : vector<2xf64> + %3 = llvm.mlir.constant(dense<6.103520e-05> : vector<2xf16>) : vector<2xf16> + %4 = llvm.intr.fabs(%arg0) : (vector<2xf32>) -> vector<2xf32> + %5 = llvm.fcmp "oge" %4, %0 : vector<2xf32> + llvm.store volatile %5, %1 {alignment = 1 : i64} : vector<2xi1>, !llvm.ptr + %6 = llvm.intr.fabs(%arg1) : (vector<2xf64>) -> vector<2xf64> + %7 = llvm.fcmp "oge" %6, %2 : vector<2xf64> + llvm.store volatile %7, %1 {alignment = 1 : i64} : vector<2xi1>, !llvm.ptr + %8 = llvm.intr.fabs(%arg2) : (vector<2xf16>) -> vector<2xf16> + %9 = llvm.fcmp "oge" %8, %3 : vector<2xf16> + llvm.store volatile %9, %1 {alignment = 1 : i64} : vector<2xi1>, !llvm.ptr + llvm.return + } + llvm.func @denormal_input_preserve_sign_vector_fcmp_ult_smallest_normalized(%arg0: vector<2xf32>, %arg1: vector<2xf64>, %arg2: vector<2xf16>) attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(dense<1.17549435E-38> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.addressof @var : !llvm.ptr + %2 = llvm.mlir.constant(dense<2.2250738585072014E-308> : vector<2xf64>) : vector<2xf64> + %3 = llvm.mlir.constant(dense<6.103520e-05> : vector<2xf16>) : vector<2xf16> + %4 = llvm.intr.fabs(%arg0) : (vector<2xf32>) -> vector<2xf32> + %5 = llvm.fcmp "ult" %4, %0 : vector<2xf32> + llvm.store volatile %5, %1 {alignment = 1 : i64} : vector<2xi1>, !llvm.ptr + %6 = llvm.intr.fabs(%arg1) : (vector<2xf64>) -> vector<2xf64> + %7 = llvm.fcmp "ult" %6, %2 : vector<2xf64> + llvm.store volatile %7, %1 {alignment = 1 : i64} : vector<2xi1>, !llvm.ptr + %8 = llvm.intr.fabs(%arg2) : (vector<2xf16>) -> vector<2xf16> + %9 = llvm.fcmp "ult" %8, %3 : vector<2xf16> + llvm.store volatile %9, %1 {alignment = 1 : i64} : vector<2xi1>, !llvm.ptr + llvm.return + } + llvm.func @denormal_input_positive_zero_fcmp_olt_smallest_normalized(%arg0: f32, %arg1: f64, %arg2: f16) attributes {passthrough = [["denormal-fp-math", "ieee,positive-zero"]]} { + %0 = llvm.mlir.constant(1.17549435E-38 : f32) : f32 + %1 = llvm.mlir.addressof @var : !llvm.ptr + %2 = llvm.mlir.constant(2.2250738585072014E-308 : f64) : f64 + %3 = llvm.mlir.constant(6.103520e-05 : f16) : f16 + %4 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %5 = llvm.fcmp "olt" %4, %0 : f32 + llvm.store volatile %5, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %6 = llvm.intr.fabs(%arg1) : (f64) -> f64 + %7 = llvm.fcmp "olt" %6, %2 : f64 + llvm.store volatile %7, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %8 = llvm.intr.fabs(%arg2) : (f16) -> f16 + %9 = llvm.fcmp "olt" %8, %3 : f16 + llvm.store volatile %9, %1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return + } + llvm.func @denormal_input_ieee(%arg0: f32, %arg1: f64, %arg2: f16) attributes {passthrough = [["denormal-fp-math", "ieee,iee"]]} { + %0 = llvm.mlir.constant(1.17549435E-38 : f32) : f32 + %1 = llvm.mlir.addressof @var : !llvm.ptr + %2 = llvm.mlir.constant(2.2250738585072014E-308 : f64) : f64 + %3 = llvm.mlir.constant(6.103520e-05 : f16) : f16 + %4 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %5 = llvm.fcmp "olt" %4, %0 : f32 + llvm.store volatile %5, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %6 = llvm.intr.fabs(%arg1) : (f64) -> f64 + %7 = llvm.fcmp "olt" %6, %2 : f64 + llvm.store volatile %7, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %8 = llvm.intr.fabs(%arg2) : (f16) -> f16 + %9 = llvm.fcmp "olt" %8, %3 : f16 + llvm.store volatile %9, %1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return + } + llvm.func @denormal_input_preserve_sign_f32_only(%arg0: f32, %arg1: f64, %arg2: f16) attributes {passthrough = [["denormal-fp-math-f32", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(1.17549435E-38 : f32) : f32 + %1 = llvm.mlir.addressof @var : !llvm.ptr + %2 = llvm.mlir.constant(2.2250738585072014E-308 : f64) : f64 + %3 = llvm.mlir.constant(6.103520e-05 : f16) : f16 + %4 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %5 = llvm.fcmp "olt" %4, %0 : f32 + llvm.store volatile %5, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %6 = llvm.intr.fabs(%arg1) : (f64) -> f64 + %7 = llvm.fcmp "olt" %6, %2 : f64 + llvm.store volatile %7, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %8 = llvm.intr.fabs(%arg2) : (f16) -> f16 + %9 = llvm.fcmp "olt" %8, %3 : f16 + llvm.store volatile %9, %1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return + } + llvm.func @wrong_fcmp_type_ole(%arg0: f32, %arg1: f64, %arg2: f16) attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(1.17549435E-38 : f32) : f32 + %1 = llvm.mlir.addressof @var : !llvm.ptr + %2 = llvm.mlir.constant(2.2250738585072014E-308 : f64) : f64 + %3 = llvm.mlir.constant(6.103520e-05 : f16) : f16 + %4 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %5 = llvm.fcmp "ole" %4, %0 : f32 + llvm.store volatile %5, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %6 = llvm.intr.fabs(%arg1) : (f64) -> f64 + %7 = llvm.fcmp "ole" %6, %2 : f64 + llvm.store volatile %7, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %8 = llvm.intr.fabs(%arg2) : (f16) -> f16 + %9 = llvm.fcmp "ole" %8, %3 : f16 + llvm.store volatile %9, %1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return + } + llvm.func @missing_fabs(%arg0: f32, %arg1: f64, %arg2: f16) attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = llvm.mlir.constant(1.17549435E-38 : f32) : f32 + %1 = llvm.mlir.addressof @var : !llvm.ptr + %2 = llvm.mlir.constant(2.2250738585072014E-308 : f64) : f64 + %3 = llvm.mlir.constant(6.103520e-05 : f16) : f16 + %4 = llvm.fcmp "olt" %arg0, %0 : f32 + llvm.store volatile %4, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %5 = llvm.fcmp "olt" %arg1, %2 : f64 + llvm.store volatile %5, %1 {alignment = 1 : i64} : i1, !llvm.ptr + %6 = llvm.fcmp "olt" %arg2, %3 : f16 + llvm.store volatile %6, %1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/fcmp-range-check-idiom.ll.mlir b/test/LLVMDialect/InstCombine/fcmp-range-check-idiom.ll.mlir new file mode 100644 index 000000000..0d069aae3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fcmp-range-check-idiom.ll.mlir @@ -0,0 +1,239 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i1) + llvm.func @test_and_olt(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.fcmp "ogt" %arg0, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_ole(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "ole" %arg0, %0 : f32 + %3 = llvm.fcmp "oge" %arg0, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_or_ogt(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "ogt" %arg0, %0 : f32 + %3 = llvm.fcmp "olt" %arg0, %1 : f32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_or_oge(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "oge" %arg0, %0 : f32 + %3 = llvm.fcmp "ole" %arg0, %1 : f32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_ult(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "ult" %arg0, %0 : f32 + %3 = llvm.fcmp "ugt" %arg0, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_ule(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "ule" %arg0, %0 : f32 + %3 = llvm.fcmp "uge" %arg0, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_or_ugt(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "ugt" %arg0, %0 : f32 + %3 = llvm.fcmp "ult" %arg0, %1 : f32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_or_uge(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "uge" %arg0, %0 : f32 + %3 = llvm.fcmp "ule" %arg0, %1 : f32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_olt_commuted(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.fcmp "ogt" %arg0, %1 : f32 + %4 = llvm.and %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_olt_subnormal(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.401300e-45 : f32) : f32 + %1 = llvm.mlir.constant(-1.401300e-45 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.fcmp "ogt" %arg0, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_olt_infinity(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %1 = llvm.mlir.constant(0xFF800000 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.fcmp "ogt" %arg0, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_olt_zero(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.fcmp "ogt" %arg0, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_ole_zero(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ole" %arg0, %0 : f32 + %3 = llvm.fcmp "oge" %arg0, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_olt_logical(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.fcmp "olt" %arg0, %0 : f32 + %4 = llvm.fcmp "ogt" %arg0, %1 : f32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @test_and_olt_poison(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.poison : f32 + %1 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %2 = llvm.mlir.undef : vector<2xf32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %8 = llvm.mlir.undef : vector<2xf32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xf32> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xf32> + %13 = llvm.fcmp "olt" %arg0, %6 : vector<2xf32> + %14 = llvm.fcmp "ogt" %arg0, %12 : vector<2xf32> + %15 = llvm.and %13, %14 : vector<2xi1> + llvm.return %15 : vector<2xi1> + } + llvm.func @test_and_olt_nan(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.mlir.constant(0xFFC00000 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.fcmp "ogt" %arg0, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_ult_nan(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0x7F800001 : f32) : f32 + %1 = llvm.mlir.constant(0xFF800001 : f32) : f32 + %2 = llvm.fcmp "ult" %arg0, %0 : f32 + %3 = llvm.fcmp "ugt" %arg0, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_or_ogt_nan(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0x7F800001 : f32) : f32 + %1 = llvm.mlir.constant(0xFF800001 : f32) : f32 + %2 = llvm.fcmp "ogt" %arg0, %0 : f32 + %3 = llvm.fcmp "olt" %arg0, %1 : f32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_or_ugt_nan(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0x7F800001 : f32) : f32 + %1 = llvm.mlir.constant(0xFF800001 : f32) : f32 + %2 = llvm.fcmp "ugt" %arg0, %0 : f32 + %3 = llvm.fcmp "ult" %arg0, %1 : f32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_ogt(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "ogt" %arg0, %0 : f32 + %3 = llvm.fcmp "olt" %arg0, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_or_olt(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.fcmp "ogt" %arg0, %1 : f32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_olt_multiuse(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.fcmp "ogt" %arg0, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_olt_mismatched_lhs(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.fcmp "ogt" %arg1, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_olt_same_sign(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.fcmp "olt" %arg0, %0 : f32 + %2 = llvm.fcmp "ogt" %arg0, %0 : f32 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @test_and_olt_mismatched_mag(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2.77555756E-17 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.fcmp "ogt" %arg0, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_olt_wrong_pred2(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.fcmp "oge" %arg0, %1 : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_olt_fmf_propagation(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fcmp "ogt" %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test_and_olt_fmf_propagation_union(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.08420217E-19 : f32) : f32 + %1 = llvm.mlir.constant(-1.08420217E-19 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fcmp "ogt" %arg0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/fcmp-select.ll.mlir b/test/LLVMDialect/InstCombine/fcmp-select.ll.mlir new file mode 100644 index 000000000..04fb2c4cb --- /dev/null +++ b/test/LLVMDialect/InstCombine/fcmp-select.ll.mlir @@ -0,0 +1,152 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i1) + llvm.func @usef64(f64) + llvm.func @oeq(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(4.200000e+01 : f64) : f64 + %1 = llvm.fcmp "oeq" %arg0, %0 : f64 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.select %1, %arg0, %0 : i1, f64 + llvm.return %2 : f64 + } + llvm.func @oeq_swapped(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.select %1, %0, %arg0 : i1, f32 + llvm.return %2 : f32 + } + llvm.func @une(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(4.200000e+01 : f64) : f64 + %1 = llvm.fcmp "une" %arg0, %0 : f64 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.select %1, %arg0, %0 : i1, f64 + llvm.return %2 : f64 + } + llvm.func @une_swapped(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(4.200000e+01 : f64) : f64 + %1 = llvm.fcmp "une" %arg0, %0 : f64 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.select %1, %0, %arg0 : i1, f64 + llvm.return %2 : f64 + } + llvm.func @une_could_be_negzero(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + llvm.call @use(%0) : (i1) -> () + %1 = llvm.select %0, %arg0, %arg1 : i1, f64 + llvm.return %1 : f64 + } + llvm.func @une_swapped_could_be_negzero(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + llvm.call @use(%0) : (i1) -> () + %1 = llvm.select %0, %arg1, %arg0 : i1, f64 + llvm.return %1 : f64 + } + llvm.func @one(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-1.000000e+00 : f64) : f64 + %1 = llvm.fcmp "one" %arg0, %0 : f64 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.select %1, %arg0, %0 : i1, f64 + llvm.return %2 : f64 + } + llvm.func @one_swapped(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-1.000000e+00 : f64) : f64 + %1 = llvm.fcmp "one" %arg0, %0 : f64 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.select %1, %0, %arg0 : i1, f64 + llvm.return %2 : f64 + } + llvm.func @fcmp_oeq_select(%arg0: i1, %arg1: f32, %arg2: f32) -> i1 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, f32 + %1 = llvm.select %arg0, %arg2, %arg1 : i1, f32 + %2 = llvm.fcmp "oeq" %0, %1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_uno_select(%arg0: i1, %arg1: f32, %arg2: f32) -> i1 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, f32 + %1 = llvm.select %arg0, %arg2, %arg1 : i1, f32 + %2 = llvm.fcmp "uno" %0, %1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_ogt_select(%arg0: i1, %arg1: f32, %arg2: f32) -> i1 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, f32 + %1 = llvm.select %arg0, %arg2, %arg1 : i1, f32 + %2 = llvm.fcmp "ogt" %0, %1 : f32 + llvm.return %2 : i1 + } + llvm.func @test_fcmp_select_const_const(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(0xFFFFFFFFFFFFFFFF : f64) : f64 + %2 = llvm.fcmp "ord" %arg0, %0 : f64 + %3 = llvm.select %2, %1, %0 : i1, f64 + %4 = llvm.fcmp "oeq" %3, %0 : f64 + llvm.return %4 : i1 + } + llvm.func @test_fcmp_select_var_const(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(1.1920928955078125E-7 : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.fcmp "ogt" %arg0, %0 : f64 + %3 = llvm.select %2, %arg1, %1 : i1, f64 + %4 = llvm.fcmp "olt" %3, %0 : f64 + llvm.return %4 : i1 + } + llvm.func @test_fcmp_select_var_const_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(1.1920928955078125E-7 : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.fcmp "ogt" %arg0, %0 : f64 + %3 = llvm.select %2, %arg1, %1 : i1, f64 + %4 = llvm.fcmp "olt" %3, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %4 : i1 + } + llvm.func @test_fcmp_select_const_const_vec(%arg0: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.mlir.constant(dense<0xFFFFFFFFFFFFFFFF> : vector<2xf64>) : vector<2xf64> + %3 = llvm.fcmp "ord" %arg0, %1 : vector<2xf64> + %4 = llvm.select %3, %2, %1 : vector<2xi1>, vector<2xf64> + %5 = llvm.fcmp "oeq" %4, %1 : vector<2xf64> + llvm.return %5 : vector<2xi1> + } + llvm.func @test_fcmp_select_clamp(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(9.000000e-01 : f64) : f64 + %1 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %2 = llvm.fcmp "ogt" %arg0, %0 : f64 + %3 = llvm.select %2, %0, %arg0 : i1, f64 + %4 = llvm.fcmp "olt" %3, %1 : f64 + %5 = llvm.select %4, %1, %3 : i1, f64 + llvm.return %5 : f64 + } + llvm.func @test_fcmp_select_maxnum(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(2.550000e+02 : f64) : f64 + %2 = llvm.fcmp "ogt" %arg0, %0 : f64 + %3 = llvm.select %2, %arg0, %0 {fastmathFlags = #llvm.fastmath} : i1, f64 + %4 = llvm.fcmp "olt" %3, %1 : f64 + %5 = llvm.select %4, %3, %1 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %5 : f64 + } + llvm.func @test_fcmp_select_const_const_multiuse(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(0xFFFFFFFFFFFFFFFF : f64) : f64 + %2 = llvm.fcmp "ord" %arg0, %0 : f64 + %3 = llvm.select %2, %1, %0 : i1, f64 + llvm.call @usef64(%3) : (f64) -> () + %4 = llvm.fcmp "oeq" %3, %0 : f64 + llvm.return %4 : i1 + } + llvm.func @test_fcmp_select_const_const_unordered(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(0xFFFFFFFFFFFFFFFF : f64) : f64 + %2 = llvm.fcmp "uno" %arg0, %0 : f64 + %3 = llvm.select %2, %1, %0 : i1, f64 + %4 = llvm.fcmp "oeq" %3, %0 : f64 + llvm.return %4 : i1 + } + llvm.func @test_fcmp_select_var_const_unordered(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(1.1920928955078125E-7 : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.fcmp "ult" %arg0, %0 : f64 + %3 = llvm.select %2, %arg1, %1 : i1, f64 + %4 = llvm.fcmp "ugt" %3, %0 : f64 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/fcmp-special.ll.mlir b/test/LLVMDialect/InstCombine/fcmp-special.ll.mlir new file mode 100644 index 000000000..a723fe211 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fcmp-special.ll.mlir @@ -0,0 +1,143 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @oeq_self(%arg0: f64) -> i1 { + %0 = llvm.fcmp "oeq" %arg0, %arg0 : f64 + llvm.return %0 : i1 + } + llvm.func @une_self(%arg0: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg0 : f64 + llvm.return %0 : i1 + } + llvm.func @ord_zero(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ord" %arg0, %0 : f32 + llvm.return %1 : i1 + } + llvm.func @ord_nonzero(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(3.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ord" %arg0, %0 : f64 + llvm.return %1 : i1 + } + llvm.func @ord_self(%arg0: f32) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg0 : f32 + llvm.return %0 : i1 + } + llvm.func @uno_zero(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "uno" %arg0, %0 : f64 + llvm.return %1 : i1 + } + llvm.func @uno_nonzero(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %1 = llvm.fcmp "uno" %arg0, %0 : f32 + llvm.return %1 : i1 + } + llvm.func @uno_self(%arg0: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg0 : f64 + llvm.return %0 : i1 + } + llvm.func @ord_zero_vec(%arg0: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.fcmp "ord" %arg0, %1 : vector<2xf64> + llvm.return %2 : vector<2xi1> + } + llvm.func @ord_nonzero_vec(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3.000000e+00, 5.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fcmp "ord" %arg0, %0 : vector<2xf32> + llvm.return %1 : vector<2xi1> + } + llvm.func @ord_self_vec(%arg0: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.fcmp "ord" %arg0, %arg0 : vector<2xf64> + llvm.return %0 : vector<2xi1> + } + llvm.func @uno_zero_vec(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.fcmp "uno" %arg0, %1 : vector<2xf32> + llvm.return %2 : vector<2xi1> + } + llvm.func @uno_nonzero_vec(%arg0: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3.000000e+00, 5.000000e+00]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fcmp "uno" %arg0, %0 : vector<2xf64> + llvm.return %1 : vector<2xi1> + } + llvm.func @uno_self_vec(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.fcmp "uno" %arg0, %arg0 : vector<2xf32> + llvm.return %0 : vector<2xi1> + } + llvm.func @uno_vec_with_nan(%arg0: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3.000000e+00, 0x7FF00000FFFFFFFF]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fcmp "uno" %arg0, %0 : vector<2xf64> + llvm.return %1 : vector<2xi1> + } + llvm.func @uno_vec_with_poison(%arg0: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.poison : f64 + %1 = llvm.mlir.constant(3.000000e+00 : f64) : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.fcmp "uno" %arg0, %6 : vector<2xf64> + llvm.return %7 : vector<2xi1> + } + llvm.func @ord_vec_with_poison(%arg0: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.poison : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.fcmp "ord" %arg0, %6 : vector<2xf64> + llvm.return %7 : vector<2xi1> + } + llvm.func @nnan_ops_to_fcmp_ord(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fmul %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fdiv %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fcmp "ord" %0, %1 : f32 + llvm.return %2 : i1 + } + llvm.func @nnan_ops_to_fcmp_uno(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fmul %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fdiv %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fcmp "uno" %0, %1 : f32 + llvm.return %2 : i1 + } + llvm.func @negative_zero_oeq(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + llvm.return %1 : i1 + } + llvm.func @negative_zero_oge(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "oge" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %1 : i1 + } + llvm.func @negative_zero_uge(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "uge" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %1 : i1 + } + llvm.func @negative_zero_olt_vec(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fcmp "olt" %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %1 : vector<2xi1> + } + llvm.func @negative_zero_une_vec_poison(%arg0: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.poison : f64 + %1 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.fcmp "une" %arg0, %6 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + llvm.return %7 : vector<2xi1> + } + llvm.func @negative_zero_ule_vec_mixed(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[0.000000e+00, -0.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fcmp "ule" %arg0, %0 : vector<2xf32> + llvm.return %1 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/fcmp.ll.mlir b/test/LLVMDialect/InstCombine/fcmp.ll.mlir new file mode 100644 index 000000000..646fd9280 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fcmp.ll.mlir @@ -0,0 +1,1298 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(f32) + llvm.func @fpext_fpext(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.fcmp "ogt" %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : i1 + } + llvm.func @fpext_constant(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.fpext %arg0 : f32 to f64 + %2 = llvm.fcmp "ogt" %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : i1 + } + llvm.func @fpext_constant_vec_splat(%arg0: vector<2xf16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4.200000e+01> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fpext %arg0 : vector<2xf16> to vector<2xf64> + %2 = llvm.fcmp "ole" %1, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + llvm.return %2 : vector<2xi1> + } + llvm.func @fpext_constant_lossy(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.0000000000000002 : f64) : f64 + %1 = llvm.fpext %arg0 : f32 to f64 + %2 = llvm.fcmp "ogt" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @fpext_constant_denorm(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.4012984643248171E-45 : f64) : f64 + %1 = llvm.fpext %arg0 : f32 to f64 + %2 = llvm.fcmp "ogt" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @fneg_constant_swap_pred(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fsub %0, %arg0 : f32 + %3 = llvm.fcmp "ogt" %2, %1 : f32 + llvm.return %3 : i1 + } + llvm.func @unary_fneg_constant_swap_pred(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fneg %arg0 : f32 + %2 = llvm.fcmp "ogt" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @fneg_constant_swap_pred_vec(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00]> : vector<2xf32>) : vector<2xf32> + %2 = llvm.fsub %0, %arg0 : vector<2xf32> + %3 = llvm.fcmp "ogt" %2, %1 : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @unary_fneg_constant_swap_pred_vec(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fneg %arg0 : vector<2xf32> + %2 = llvm.fcmp "ogt" %1, %0 : vector<2xf32> + llvm.return %2 : vector<2xi1> + } + llvm.func @fneg_constant_swap_pred_vec_poison(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.poison : f32 + %2 = llvm.mlir.undef : vector<2xf32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00]> : vector<2xf32>) : vector<2xf32> + %8 = llvm.fsub %6, %arg0 : vector<2xf32> + %9 = llvm.fcmp "ogt" %8, %7 : vector<2xf32> + llvm.return %9 : vector<2xi1> + } + llvm.func @fneg_fmf(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fcmp "oeq" %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : i1 + } + llvm.func @unary_fneg_fmf(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fcmp "oeq" %1, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fneg_fmf_vec(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.constant(dense<[4.200000e+01, -1.900000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.fsub %1, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %4 = llvm.fcmp "uge" %3, %2 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %4 : vector<2xi1> + } + llvm.func @fneg_fneg_swap_pred(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fsub %0, %arg1 : f32 + %3 = llvm.fcmp "olt" %1, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : i1 + } + llvm.func @unary_fneg_unary_fneg_swap_pred(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fneg %arg1 : f32 + %2 = llvm.fcmp "olt" %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : i1 + } + llvm.func @unary_fneg_fneg_swap_pred(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fneg %arg0 : f32 + %2 = llvm.fsub %0, %arg1 : f32 + %3 = llvm.fcmp "olt" %1, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : i1 + } + llvm.func @fneg_unary_fneg_swap_pred(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fneg %arg1 : f32 + %3 = llvm.fcmp "olt" %1, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : i1 + } + llvm.func @fneg_fneg_swap_pred_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 : vector<2xf32> + %2 = llvm.fsub %0, %arg1 : vector<2xf32> + %3 = llvm.fcmp "olt" %1, %2 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @unary_fneg_unary_fneg_swap_pred_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.fneg %arg0 : vector<2xf32> + %1 = llvm.fneg %arg1 : vector<2xf32> + %2 = llvm.fcmp "olt" %0, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %2 : vector<2xi1> + } + llvm.func @unary_fneg_fneg_swap_pred_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fneg %arg0 : vector<2xf32> + %2 = llvm.fsub %0, %arg1 : vector<2xf32> + %3 = llvm.fcmp "olt" %1, %2 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fneg_unary_fneg_swap_pred_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 : vector<2xf32> + %2 = llvm.fneg %arg1 : vector<2xf32> + %3 = llvm.fcmp "olt" %1, %2 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fneg_fneg_swap_pred_vec_poison(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.poison : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.mlir.undef : vector<2xf32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.undef : vector<2xf32> + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<2xf32> + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<2xf32> + %12 = llvm.fsub %6, %arg0 : vector<2xf32> + %13 = llvm.fsub %11, %arg1 : vector<2xf32> + %14 = llvm.fcmp "olt" %12, %13 : vector<2xf32> + llvm.return %14 : vector<2xi1> + } + llvm.func @unary_fneg_fneg_swap_pred_vec_poison(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.poison : f32 + %2 = llvm.mlir.undef : vector<2xf32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf32> + %7 = llvm.fneg %arg0 : vector<2xf32> + %8 = llvm.fsub %6, %arg1 : vector<2xf32> + %9 = llvm.fcmp "olt" %7, %8 : vector<2xf32> + llvm.return %9 : vector<2xi1> + } + llvm.func @fneg_unary_fneg_swap_pred_vec_poison(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.poison : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.mlir.undef : vector<2xf32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf32> + %7 = llvm.fsub %6, %arg0 : vector<2xf32> + %8 = llvm.fneg %arg1 : vector<2xf32> + %9 = llvm.fcmp "olt" %7, %8 : vector<2xf32> + llvm.return %9 : vector<2xi1> + } + llvm.func @test7(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f128) : !llvm.ppc_fp128 + %1 = llvm.fpext %arg0 : f32 to !llvm.ppc_fp128 + %2 = llvm.fcmp "ogt" %1, %0 : !llvm.ppc_fp128 + llvm.return %2 : i1 + } + llvm.func @test8(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fpext %arg0 : f32 to f64 + %2 = llvm.fcmp "olt" %1, %0 : f64 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.sitofp %3 : i32 to f32 + llvm.return %4 : f32 + } + llvm.func @fabs_uge(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %2 = llvm.fcmp "uge" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @fabs_olt(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %2 = llvm.fcmp "olt" %1, %0 : f16 + llvm.return %2 : i1 + } + llvm.func @fabs_ole(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.intr.fabs(%arg0) : (vector<2xf32>) -> vector<2xf32> + %3 = llvm.fcmp "ole" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fabs_ule(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.intr.fabs(%arg0) : (vector<2xf32>) -> vector<2xf32> + %3 = llvm.fcmp "ule" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fabs_ogt(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %2 = llvm.fcmp "ogt" %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : i1 + } + llvm.func @fabs_ugt(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %2 = llvm.fcmp "ugt" %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : i1 + } + llvm.func @fabs_oge(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %2 = llvm.fcmp "oge" %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : i1 + } + llvm.func @fabs_ult(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %2 = llvm.fcmp "ult" %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : i1 + } + llvm.func @fabs_ult_nnan(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.intr.fabs(%arg0) : (vector<2xf32>) -> vector<2xf32> + %3 = llvm.fcmp "ult" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fabs_une(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %2 = llvm.fcmp "une" %1, %0 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %2 : i1 + } + llvm.func @fabs_oeq(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %2 = llvm.fcmp "oeq" %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : i1 + } + llvm.func @fabs_one(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %2 = llvm.fcmp "one" %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : i1 + } + llvm.func @fabs_ueq(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.intr.fabs(%arg0) : (vector<2xf32>) -> vector<2xf32> + %3 = llvm.fcmp "ueq" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fabs_ord(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.intr.fabs(%arg0) : (vector<2xf32>) -> vector<2xf32> + %3 = llvm.fcmp "ord" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fabs_uno(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.intr.fabs(%arg0) : (vector<2xf32>) -> vector<2xf32> + %3 = llvm.fcmp "uno" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test17(%arg0: f64, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.call %arg1(%arg0) : !llvm.ptr, (f64) -> f64 + %2 = llvm.fcmp "ueq" %1, %0 : f64 + %3 = llvm.zext %2 : i1 to i32 + llvm.return %3 : i32 + } + llvm.func @test18_undef_unordered(%arg0: f32) -> i32 { + %0 = llvm.mlir.undef : f32 + %1 = llvm.fcmp "ueq" %arg0, %0 : f32 + %2 = llvm.zext %1 : i1 to i32 + llvm.return %2 : i32 + } + llvm.func @test18_undef_ordered(%arg0: f32) -> i32 { + %0 = llvm.mlir.undef : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.zext %1 : i1 to i32 + llvm.return %2 : i32 + } + llvm.func @test19_undef_unordered() -> i1 { + %0 = llvm.mlir.undef : f32 + %1 = llvm.fcmp "ueq" %0, %0 : f32 + llvm.return %1 : i1 + } + llvm.func @test19_undef_ordered() -> i1 { + %0 = llvm.mlir.undef : f32 + %1 = llvm.fcmp "oeq" %0, %0 : f32 + llvm.return %1 : i1 + } + llvm.func @test20_recipX_olt_0(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fcmp "olt" %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : i1 + } + llvm.func @test21_recipX_ole_0(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(-2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fcmp "ole" %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : i1 + } + llvm.func @test22_recipX_ogt_0(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fcmp "ogt" %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : i1 + } + llvm.func @test23_recipX_oge_0(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fcmp "oge" %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : i1 + } + llvm.func @test24_recipX_noninf_cmp(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fcmp "ogt" %2, %1 : f32 + llvm.return %3 : i1 + } + llvm.func @test25_recipX_noninf_div(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fdiv %0, %arg0 : f32 + %3 = llvm.fcmp "ogt" %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : i1 + } + llvm.func @test26_recipX_unorderd(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fcmp "ugt" %2, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : i1 + } + llvm.func @test27_recipX_gt_vecsplat(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %3 = llvm.fcmp "ogt" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @is_signbit_set(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.intr.copysign(%0, %arg0) : (f64, f64) -> f64 + %3 = llvm.fcmp "olt" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @is_signbit_set_1(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.intr.copysign(%0, %arg0) : (f64, f64) -> f64 + %3 = llvm.fcmp "ult" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @is_signbit_set_2(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.intr.copysign(%0, %arg0) : (f64, f64) -> f64 + %3 = llvm.fcmp "ole" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @is_signbit_set_3(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.intr.copysign(%0, %arg0) : (f64, f64) -> f64 + %3 = llvm.fcmp "ule" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @is_signbit_set_anyzero(%arg0: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4.200000e+01> : vector<2xf64>) : vector<2xf64> + %1 = llvm.mlir.constant(dense<[-0.000000e+00, 0.000000e+00]> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.copysign(%0, %arg0) : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + %3 = llvm.fcmp "olt" %2, %1 : vector<2xf64> + llvm.return %3 : vector<2xi1> + } + llvm.func @is_signbit_clear(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(-4.200000e+01 : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.intr.copysign(%0, %arg0) : (f64, f64) -> f64 + %3 = llvm.fcmp "ogt" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @is_signbit_clear_1(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(-4.200000e+01 : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.intr.copysign(%0, %arg0) : (f64, f64) -> f64 + %3 = llvm.fcmp "ugt" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @is_signbit_clear_2(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(-4.200000e+01 : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.intr.copysign(%0, %arg0) : (f64, f64) -> f64 + %3 = llvm.fcmp "oge" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @is_signbit_clear_3(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(-4.200000e+01 : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.intr.copysign(%0, %arg0) : (f64, f64) -> f64 + %3 = llvm.fcmp "uge" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @is_signbit_set_extra_use(%arg0: f64, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.intr.copysign(%0, %arg0) : (f64, f64) -> f64 + llvm.store %2, %arg1 {alignment = 8 : i64} : f64, !llvm.ptr + %3 = llvm.fcmp "olt" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @is_signbit_clear_nonzero(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(-4.200000e+01 : f64) : f64 + %1 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %2 = llvm.intr.copysign(%0, %arg0) : (f64, f64) -> f64 + %3 = llvm.fcmp "ogt" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @is_signbit_set_simplify_zero(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.copysign(%0, %arg0) : (f64, f64) -> f64 + %2 = llvm.fcmp "ogt" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @is_signbit_set_simplify_nan(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(0xFFFFFFFFFFFFFFFF : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.intr.copysign(%0, %arg0) : (f64, f64) -> f64 + %3 = llvm.fcmp "ogt" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @lossy_oeq(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1.000000e-01> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %2 = llvm.fcmp "oeq" %1, %0 : vector<2xf64> + llvm.return %2 : vector<2xi1> + } + llvm.func @lossy_one(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1.000000e-01 : f64) : f64 + %1 = llvm.fpext %arg0 : f32 to f64 + llvm.store %1, %arg1 {alignment = 8 : i64} : f64, !llvm.ptr + %2 = llvm.fcmp "one" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @lossy_ueq(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(6.553600e+04 : f64) : f64 + %1 = llvm.fpext %arg0 : f16 to f64 + %2 = llvm.fcmp "ueq" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @lossy_une(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(2.049000e+03 : f32) : f32 + %1 = llvm.fpext %arg0 : f16 to f32 + %2 = llvm.fcmp "une" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @lossy_ogt(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1.000000e-01> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %2 = llvm.fcmp "ogt" %1, %0 : vector<2xf64> + llvm.return %2 : vector<2xi1> + } + llvm.func @lossy_oge(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1.000000e-01 : f64) : f64 + %1 = llvm.fpext %arg0 : f32 to f64 + llvm.store %1, %arg1 {alignment = 8 : i64} : f64, !llvm.ptr + %2 = llvm.fcmp "oge" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @lossy_olt(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(6.553600e+04 : f64) : f64 + %1 = llvm.fpext %arg0 : f16 to f64 + %2 = llvm.fcmp "olt" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @lossy_ole(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(2.049000e+03 : f32) : f32 + %1 = llvm.fpext %arg0 : f16 to f32 + %2 = llvm.fcmp "ole" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @lossy_ugt(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1.000000e-01> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %2 = llvm.fcmp "ugt" %1, %0 : vector<2xf64> + llvm.return %2 : vector<2xi1> + } + llvm.func @lossy_uge(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1.000000e-01 : f64) : f64 + %1 = llvm.fpext %arg0 : f32 to f64 + llvm.store %1, %arg1 {alignment = 8 : i64} : f64, !llvm.ptr + %2 = llvm.fcmp "uge" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @lossy_ult(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(6.553600e+04 : f64) : f64 + %1 = llvm.fpext %arg0 : f16 to f64 + %2 = llvm.fcmp "ult" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @lossy_ule(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(2.049000e+03 : f32) : f32 + %1 = llvm.fpext %arg0 : f16 to f32 + %2 = llvm.fcmp "ule" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @lossy_ord(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(6.553600e+04 : f64) : f64 + %1 = llvm.fpext %arg0 : f16 to f64 + %2 = llvm.fcmp "ord" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @lossy_uno(%arg0: f16) -> i1 { + %0 = llvm.mlir.constant(2.049000e+03 : f32) : f32 + %1 = llvm.fpext %arg0 : f16 to f32 + %2 = llvm.fcmp "uno" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @fneg_oeq(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fcmp "oeq" %0, %arg0 : f32 + llvm.return %1 : i1 + } + llvm.func @fneg_ogt(%arg0: f16) -> i1 { + %0 = llvm.fneg %arg0 : f16 + %1 = llvm.fcmp "ogt" %0, %arg0 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %1 : i1 + } + llvm.func @fneg_oge(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %1 = llvm.fcmp "oge" %0, %arg0 : vector<2xf32> + llvm.return %1 : vector<2xi1> + } + llvm.func @fneg_olt(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.fneg %arg0 : f32 + llvm.store %0, %arg1 {alignment = 4 : i64} : f32, !llvm.ptr + %1 = llvm.fcmp "olt" %0, %arg0 : f32 + llvm.return %1 : i1 + } + llvm.func @fneg_ole(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fcmp "ole" %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : i1 + } + llvm.func @fneg_one(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fcmp "one" %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : i1 + } + llvm.func @fneg_ord(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fcmp "ord" %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : i1 + } + llvm.func @fneg_uno(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fcmp "uno" %0, %arg0 : f32 + llvm.return %1 : i1 + } + llvm.func @fneg_ueq(%arg0: f16) -> i1 { + %0 = llvm.fneg %arg0 : f16 + %1 = llvm.fcmp "ueq" %0, %arg0 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %1 : i1 + } + llvm.func @fneg_ugt(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %1 = llvm.fcmp "ugt" %0, %arg0 : vector<2xf32> + llvm.return %1 : vector<2xi1> + } + llvm.func @fneg_uge(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.fneg %arg0 : f32 + llvm.store %0, %arg1 {alignment = 4 : i64} : f32, !llvm.ptr + %1 = llvm.fcmp "uge" %0, %arg0 : f32 + llvm.return %1 : i1 + } + llvm.func @fneg_ult(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fcmp "ult" %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : i1 + } + llvm.func @fneg_ule(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fcmp "ule" %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : i1 + } + llvm.func @fneg_une(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fcmp "une" %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : i1 + } + llvm.func @fneg_oeq_swap(%arg0: f32) -> i1 { + %0 = llvm.fadd %arg0, %arg0 : f32 + %1 = llvm.fneg %0 : f32 + %2 = llvm.fcmp "oeq" %0, %1 : f32 + llvm.return %2 : i1 + } + llvm.func @fneg_ogt_swap(%arg0: f16) -> i1 { + %0 = llvm.fadd %arg0, %arg0 : f16 + %1 = llvm.fneg %0 : f16 + %2 = llvm.fcmp "ogt" %0, %1 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %2 : i1 + } + llvm.func @fneg_oge_swap(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.fadd %arg0, %arg0 : vector<2xf32> + %1 = llvm.fneg %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %2 = llvm.fcmp "oge" %0, %1 : vector<2xf32> + llvm.return %2 : vector<2xi1> + } + llvm.func @fneg_olt_swap(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.fadd %arg0, %arg0 : f32 + %1 = llvm.fneg %0 : f32 + llvm.store %1, %arg1 {alignment = 4 : i64} : f32, !llvm.ptr + %2 = llvm.fcmp "olt" %0, %1 : f32 + llvm.return %2 : i1 + } + llvm.func @fneg_ole_swap(%arg0: f32) -> i1 { + %0 = llvm.fadd %arg0, %arg0 : f32 + %1 = llvm.fneg %0 : f32 + %2 = llvm.fcmp "ole" %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : i1 + } + llvm.func @fneg_one_swap(%arg0: f32) -> i1 { + %0 = llvm.fadd %arg0, %arg0 : f32 + %1 = llvm.fneg %0 : f32 + %2 = llvm.fcmp "one" %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : i1 + } + llvm.func @fneg_ord_swap(%arg0: f32) -> i1 { + %0 = llvm.fadd %arg0, %arg0 : f32 + %1 = llvm.fneg %0 : f32 + %2 = llvm.fcmp "ord" %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : i1 + } + llvm.func @fneg_uno_swap(%arg0: f32) -> i1 { + %0 = llvm.fadd %arg0, %arg0 : f32 + %1 = llvm.fneg %0 : f32 + %2 = llvm.fcmp "uno" %0, %1 : f32 + llvm.return %2 : i1 + } + llvm.func @fneg_ueq_swap(%arg0: f16) -> i1 { + %0 = llvm.fadd %arg0, %arg0 : f16 + %1 = llvm.fneg %0 : f16 + %2 = llvm.fcmp "ueq" %0, %1 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %2 : i1 + } + llvm.func @fneg_ugt_swap(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.fadd %arg0, %arg0 : vector<2xf32> + %1 = llvm.fneg %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %2 = llvm.fcmp "ugt" %0, %1 : vector<2xf32> + llvm.return %2 : vector<2xi1> + } + llvm.func @fneg_uge_swap(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.fadd %arg0, %arg0 : f32 + %1 = llvm.fneg %0 : f32 + llvm.store %1, %arg1 {alignment = 4 : i64} : f32, !llvm.ptr + %2 = llvm.fcmp "uge" %0, %1 : f32 + llvm.return %2 : i1 + } + llvm.func @fneg_ult_swap(%arg0: f32) -> i1 { + %0 = llvm.fadd %arg0, %arg0 : f32 + %1 = llvm.fneg %0 : f32 + %2 = llvm.fcmp "ult" %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : i1 + } + llvm.func @fneg_ule_swap(%arg0: f32) -> i1 { + %0 = llvm.fadd %arg0, %arg0 : f32 + %1 = llvm.fneg %0 : f32 + %2 = llvm.fcmp "ule" %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : i1 + } + llvm.func @fneg_une_swap(%arg0: f32) -> i1 { + %0 = llvm.fadd %arg0, %arg0 : f32 + %1 = llvm.fneg %0 : f32 + %2 = llvm.fcmp "une" %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : i1 + } + llvm.func @bitcast_eq0(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.bitcast %arg0 : i32 to f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @bitcast_ne0(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.bitcast %arg0 : vector<2xi32> to vector<2xf32> + %3 = llvm.fcmp "une" %2, %1 : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @bitcast_eq0_use(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.bitcast %arg0 : i32 to f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @bitcast_nonint_eq0(%arg0: vector<2xi16>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.bitcast %arg0 : vector<2xi16> to f32 + %2 = llvm.fcmp "ogt" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @bitcast_gt0(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.bitcast %arg0 : i32 to f32 + %2 = llvm.fcmp "ogt" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @bitcast_1vec_eq0(%arg0: i32) -> vector<1xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<1xf32>) : vector<1xf32> + %2 = llvm.bitcast %arg0 : i32 to vector<1xf32> + %3 = llvm.fcmp "oeq" %2, %1 : vector<1xf32> + llvm.return %3 : vector<1xi1> + } + llvm.func @fcmp_fadd_zero_ugt(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "ugt" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_uge(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "uge" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_ogt(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "ogt" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_oge(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "oge" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_ult(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "ult" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_ule(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "ule" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_olt(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "olt" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_ole(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "ole" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_oeq(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "oeq" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_one(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "one" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_ueq(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "ueq" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_une(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "une" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_ord(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "ord" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_uno(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "uno" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_neg_zero(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "ugt" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_switched(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg1, %0 : f32 + %2 = llvm.fcmp "ugt" %arg0, %1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_zero_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[0.000000e+00, -0.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fadd %arg0, %0 : vector<2xf32> + %2 = llvm.fcmp "ugt" %1, %arg1 : vector<2xf32> + llvm.return %2 : vector<2xi1> + } + llvm.func @fcmp_fast_fadd_fast_zero(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fcmp "ugt" %1, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fast_fadd_zero(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 : f32 + %2 = llvm.fcmp "ugt" %1, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_fadd_fast_zero(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fcmp "ugt" %1, %arg1 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_ueq_sel_x_negx(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ueq" %arg0, %0 : f32 + %2 = llvm.fneg %arg0 : f32 + %3 = llvm.select %1, %arg0, %2 : i1, f32 + %4 = llvm.fcmp "ueq" %3, %0 : f32 + llvm.return %4 : i1 + } + llvm.func @fcmp_une_sel_x_negx(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "une" %arg0, %0 : f32 + %2 = llvm.fneg %arg0 : f32 + %3 = llvm.select %1, %arg0, %2 : i1, f32 + %4 = llvm.fcmp "une" %3, %0 : f32 + llvm.return %4 : i1 + } + llvm.func @fcmp_oeq_sel_x_negx(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fneg %arg0 : f32 + %3 = llvm.select %1, %arg0, %2 : i1, f32 + %4 = llvm.fcmp "oeq" %3, %0 : f32 + llvm.return %4 : i1 + } + llvm.func @fcmp_one_sel_x_negx(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "one" %arg0, %0 : f32 + %2 = llvm.fneg %arg0 : f32 + %3 = llvm.select %1, %arg0, %2 : i1, f32 + %4 = llvm.fcmp "one" %3, %0 : f32 + llvm.return %4 : i1 + } + llvm.func @fcmp_ueq_sel_x_negx_nzero(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ueq" %arg0, %0 : f32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.select %2, %arg0, %3 : i1, f32 + %5 = llvm.fcmp "ueq" %4, %1 : f32 + llvm.return %5 : i1 + } + llvm.func @fcmp_une_sel_x_negx_nzero(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "une" %arg0, %0 : f32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.select %2, %arg0, %3 : i1, f32 + %5 = llvm.fcmp "une" %4, %1 : f32 + llvm.return %5 : i1 + } + llvm.func @fcmp_oeq_sel_x_negx_nzero(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "oeq" %arg0, %0 : f32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.select %2, %arg0, %3 : i1, f32 + %5 = llvm.fcmp "oeq" %4, %1 : f32 + llvm.return %5 : i1 + } + llvm.func @fcmp_one_sel_x_negx_nzero(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "one" %arg0, %0 : f32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.select %2, %arg0, %3 : i1, f32 + %5 = llvm.fcmp "one" %4, %1 : f32 + llvm.return %5 : i1 + } + llvm.func @fcmp_ueq_sel_x_negx_vec(%arg0: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fcmp "ueq" %arg0, %1 : vector<8xf32> + %3 = llvm.fneg %arg0 : vector<8xf32> + %4 = llvm.select %2, %arg0, %3 : vector<8xi1>, vector<8xf32> + %5 = llvm.fcmp "ueq" %4, %1 : vector<8xf32> + llvm.return %5 : vector<8xi1> + } + llvm.func @fcmp_une_sel_x_negx_vec(%arg0: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fcmp "une" %arg0, %1 : vector<8xf32> + %3 = llvm.fneg %arg0 : vector<8xf32> + %4 = llvm.select %2, %arg0, %3 : vector<8xi1>, vector<8xf32> + %5 = llvm.fcmp "une" %4, %1 : vector<8xf32> + llvm.return %5 : vector<8xi1> + } + llvm.func @fcmp_oeq_sel_x_negx_vec(%arg0: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fcmp "oeq" %arg0, %1 : vector<8xf32> + %3 = llvm.fneg %arg0 : vector<8xf32> + %4 = llvm.select %2, %arg0, %3 : vector<8xi1>, vector<8xf32> + %5 = llvm.fcmp "oeq" %4, %1 : vector<8xf32> + llvm.return %5 : vector<8xi1> + } + llvm.func @fcmp_one_sel_x_negx_vec(%arg0: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fcmp "one" %arg0, %1 : vector<8xf32> + %3 = llvm.fneg %arg0 : vector<8xf32> + %4 = llvm.select %2, %arg0, %3 : vector<8xi1>, vector<8xf32> + %5 = llvm.fcmp "one" %4, %1 : vector<8xf32> + llvm.return %5 : vector<8xi1> + } + llvm.func @fcmp_oeq_sel_x_negx_with_any_fpzero_ninf_vec(%arg0: vector<2xi1>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[0.000000e+00, -0.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fneg %arg1 : vector<2xf32> + %2 = llvm.select %arg0, %arg1, %1 : vector<2xi1>, vector<2xf32> + %3 = llvm.fcmp "oeq" %2, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fcmp_one_sel_x_negx_with_any_fpzero_ninf_vec(%arg0: vector<2xi1>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[0.000000e+00, -0.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fneg %arg1 : vector<2xf32> + %2 = llvm.select %arg0, %arg1, %1 : vector<2xi1>, vector<2xf32> + %3 = llvm.fcmp "one" %2, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fcmp_ueq_sel_x_negx_with_any_fpzero_ninf_vec(%arg0: vector<2xi1>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[0.000000e+00, -0.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fneg %arg1 : vector<2xf32> + %2 = llvm.select %arg0, %arg1, %1 : vector<2xi1>, vector<2xf32> + %3 = llvm.fcmp "ueq" %2, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fcmp_une_sel_x_negx_with_any_fpzero_ninf_vec(%arg0: vector<2xi1>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[0.000000e+00, -0.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fneg %arg1 : vector<2xf32> + %2 = llvm.select %arg0, %arg1, %1 : vector<2xi1>, vector<2xf32> + %3 = llvm.fcmp "une" %2, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fcmp_oeq_sel_x_negx_with_any_fpzero_nnan_vec(%arg0: vector<2xi1>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[0.000000e+00, -0.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fneg %arg1 : vector<2xf32> + %2 = llvm.select %arg0, %arg1, %1 : vector<2xi1>, vector<2xf32> + %3 = llvm.fcmp "oeq" %2, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fcmp_one_sel_x_negx_with_any_fpzero_nnan_vec(%arg0: vector<2xi1>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[0.000000e+00, -0.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fneg %arg1 : vector<2xf32> + %2 = llvm.select %arg0, %arg1, %1 : vector<2xi1>, vector<2xf32> + %3 = llvm.fcmp "one" %2, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fcmp_ueq_sel_x_negx_with_any_fpzero_nnan_vec(%arg0: vector<2xi1>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[0.000000e+00, -0.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fneg %arg1 : vector<2xf32> + %2 = llvm.select %arg0, %arg1, %1 : vector<2xi1>, vector<2xf32> + %3 = llvm.fcmp "ueq" %2, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fcmp_une_sel_x_negx_with_any_fpzero_nnan_vec(%arg0: vector<2xi1>, %arg1: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[0.000000e+00, -0.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fneg %arg1 : vector<2xf32> + %2 = llvm.select %arg0, %arg1, %1 : vector<2xi1>, vector<2xf32> + %3 = llvm.fcmp "une" %2, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xi1> + } + llvm.func @fcmp_ueq_fsub_nnan_const_extra_use(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fcmp "ueq" %1, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_oeq_fsub_ninf_const_extra_use(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fcmp "oeq" %1, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_oeq_fsub_const(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 : f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_oge_fsub_const(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 : f32 + %2 = llvm.fcmp "oge" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_ole_fsub_const(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 : f32 + %2 = llvm.fcmp "ole" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_ueq_fsub_const(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 : f32 + %2 = llvm.fcmp "ueq" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_uge_fsub_const(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 : f32 + %2 = llvm.fcmp "uge" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_ule_fsub_const(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 : f32 + %2 = llvm.fcmp "ule" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_ugt_fsub_const(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 : f32 + %2 = llvm.fcmp "ugt" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_ult_fsub_const(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 : f32 + %2 = llvm.fcmp "ult" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_une_fsub_const(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 : f32 + %2 = llvm.fcmp "une" %1, %0 : f32 + llvm.return %2 : i1 + } + llvm.func @fcmp_uge_fsub_const_ninf_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "uge" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_ule_fsub_const_ninf_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "ule" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_ueq_fsub_const_ninf_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "ueq" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_oge_fsub_const_ninf_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "oge" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_ole_fsub_const_ninf_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "ole" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_oeq_fsub_const_ninf_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "oeq" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_ogt_fsub_const_ninf_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "ogt" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_olt_fsub_const_ninf_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "olt" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_one_fsub_const_ninf_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "one" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_ugt_fsub_const_ninf_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "ugt" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_ult_fsub_const_ninf_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "ult" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_une_fsub_const_ninf_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "une" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_uge_fsub_const_nnan_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "uge" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_ule_fsub_const_nnan_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "ule" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_ueq_fsub_const_nnan_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "ueq" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_oge_fsub_const_nnan_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "oge" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_ole_fsub_const_nnan_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "ole" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_oeq_fsub_const_nnan_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "oeq" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_ogt_fsub_const_nnan_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "ogt" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_olt_fsub_const_nnan_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "olt" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_one_fsub_const_nnan_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "one" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_ugt_fsub_const_nnan_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "ugt" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_ult_fsub_const_nnan_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "ult" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_une_fsub_const_nnan_vec(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + %3 = llvm.fcmp "une" %2, %1 {fastmathFlags = #llvm.fastmath} : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @"fcmp_ugt_fsub_const_vec_denormal_positive-zero"(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> attributes {passthrough = [["denormal-fp-math", "positive-zero,positive-zero"]]} { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 : vector<8xf32> + %3 = llvm.fcmp "ogt" %2, %1 : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @fcmp_ogt_fsub_const_vec_denormal_dynamic(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> attributes {passthrough = [["denormal-fp-math", "dynamic,dynamic"]]} { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 : vector<8xf32> + %3 = llvm.fcmp "ogt" %2, %1 : vector<8xf32> + llvm.return %3 : vector<8xi1> + } + llvm.func @"fcmp_ogt_fsub_const_vec_denormal_preserve-sign"(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xi1> attributes {passthrough = [["denormal-fp-math", "preserve-sign,preserve-sign"]]} { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fsub %arg0, %arg1 : vector<8xf32> + %3 = llvm.fcmp "ogt" %2, %1 : vector<8xf32> + llvm.return %3 : vector<8xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/fdiv-cos-sin.ll.mlir b/test/LLVMDialect/InstCombine/fdiv-cos-sin.ll.mlir index 26fad3bf6..51492e99e 100644 --- a/test/LLVMDialect/InstCombine/fdiv-cos-sin.ll.mlir +++ b/test/LLVMDialect/InstCombine/fdiv-cos-sin.ll.mlir @@ -1,85 +1,58 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.cos.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.sin.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_cos_sin", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.cos.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.sin.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_strict_cos_strict_sin_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.cos.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.sin.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_reassoc_cos_strict_sin_strict", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.cos.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.sin.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_reassoc_cos_reassoc_sin_strict", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.cos.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.sin.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_cos_sin_reassoc_multiple_uses", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.cos.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.sin.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_cos_sin_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f16): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.cos.f16, fastmathFlags = #llvm.fastmath<>} : (f16) -> f16 - %1 = "llvm.call"(%arg0) {callee = @llvm.sin.f16, fastmathFlags = #llvm.fastmath<>} : (f16) -> f16 - %2 = "llvm.fdiv"(%0, %1) : (f16, f16) -> f16 - "llvm.return"(%2) : (f16) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_cosf16_sinf16_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.cos.f32, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %1 = "llvm.call"(%arg0) {callee = @llvm.sin.f32, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %2 = "llvm.fdiv"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_cosf_sinf_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f128): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.cos.f128, fastmathFlags = #llvm.fastmath<>} : (f128) -> f128 - %1 = "llvm.call"(%arg0) {callee = @llvm.sin.f128, fastmathFlags = #llvm.fastmath<>} : (f128) -> f128 - %2 = "llvm.fdiv"(%0, %1) : (f128, f128) -> f128 - "llvm.return"(%2) : (f128) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_cosfp128_sinfp128_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.cos.f16", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.cos.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.cos.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.sin.f16", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.sin.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.sin.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.cos.f128", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.sin.f128", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fdiv_cos_sin(%arg0: f64) -> f64 { + %0 = llvm.intr.cos(%arg0) : (f64) -> f64 + %1 = llvm.intr.sin(%arg0) : (f64) -> f64 + %2 = llvm.fdiv %0, %1 : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_strict_cos_strict_sin_reassoc(%arg0: f64) -> f64 { + %0 = llvm.intr.cos(%arg0) : (f64) -> f64 + %1 = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %0, %1 : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_reassoc_cos_strict_sin_strict(%arg0: f64, %arg1: !llvm.ptr {llvm.dereferenceable = 2 : i64}) -> f64 { + %0 = llvm.intr.cos(%arg0) : (f64) -> f64 + %1 = llvm.intr.sin(%arg0) : (f64) -> f64 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_reassoc_cos_reassoc_sin_strict(%arg0: f64) -> f64 { + %0 = llvm.intr.cos(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.intr.sin(%arg0) : (f64) -> f64 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_cos_sin_reassoc_multiple_uses(%arg0: f64) -> f64 { + %0 = llvm.intr.cos(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @fdiv_cos_sin_reassoc(%arg0: f64) -> f64 { + %0 = llvm.intr.cos(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_cosf16_sinf16_reassoc(%arg0: f16) -> f16 { + %0 = llvm.intr.cos(%arg0) {fastmathFlags = #llvm.fastmath} : (f16) -> f16 + %1 = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath} : (f16) -> f16 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f16 + llvm.return %2 : f16 + } + llvm.func @fdiv_cosf_sinf_reassoc(%arg0: f32) -> f32 { + %0 = llvm.intr.cos(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %1 = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fdiv_cosfp128_sinfp128_reassoc(%arg0: f128) -> f128 { + %0 = llvm.intr.cos(%arg0) {fastmathFlags = #llvm.fastmath} : (f128) -> f128 + %1 = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath} : (f128) -> f128 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f128 + llvm.return %2 : f128 + } + llvm.func @use(f64) +} diff --git a/test/LLVMDialect/InstCombine/fdiv-sin-cos.ll.mlir b/test/LLVMDialect/InstCombine/fdiv-sin-cos.ll.mlir index 42b6cf962..0cf5b4993 100644 --- a/test/LLVMDialect/InstCombine/fdiv-sin-cos.ll.mlir +++ b/test/LLVMDialect/InstCombine/fdiv-sin-cos.ll.mlir @@ -1,74 +1,52 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sin.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.cos.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_sin_cos", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sin.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.cos.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_strict_sin_strict_cos_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sin.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.cos.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_reassoc_sin_strict_cos_strict", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sin.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.cos.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_reassoc_sin_reassoc_cos_strict", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sin.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.cos.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_sin_cos_reassoc_multiple_uses", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sin.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.cos.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_sin_cos_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sin.f32, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %1 = "llvm.call"(%arg0) {callee = @llvm.cos.f32, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %2 = "llvm.fdiv"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_sinf_cosf_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f128): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sin.f128, fastmathFlags = #llvm.fastmath<>} : (f128) -> f128 - %1 = "llvm.call"(%arg0) {callee = @llvm.cos.f128, fastmathFlags = #llvm.fastmath<>} : (f128) -> f128 - %2 = "llvm.fdiv"(%0, %1) : (f128, f128) -> f128 - "llvm.return"(%2) : (f128) -> () - }) {linkage = 10 : i64, sym_name = "fdiv_sinfp128_cosfp128_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.sin.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.sin.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.cos.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.cos.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.sin.f128", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.cos.f128", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fdiv_sin_cos(%arg0: f64) -> f64 { + %0 = llvm.intr.sin(%arg0) : (f64) -> f64 + %1 = llvm.intr.cos(%arg0) : (f64) -> f64 + %2 = llvm.fdiv %0, %1 : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_strict_sin_strict_cos_reassoc(%arg0: f64) -> f64 { + %0 = llvm.intr.sin(%arg0) : (f64) -> f64 + %1 = llvm.intr.cos(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %0, %1 : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_reassoc_sin_strict_cos_strict(%arg0: f64, %arg1: !llvm.ptr {llvm.dereferenceable = 2 : i64}) -> f64 { + %0 = llvm.intr.sin(%arg0) : (f64) -> f64 + %1 = llvm.intr.cos(%arg0) : (f64) -> f64 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_reassoc_sin_reassoc_cos_strict(%arg0: f64) -> f64 { + %0 = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.intr.cos(%arg0) : (f64) -> f64 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_sin_cos_reassoc_multiple_uses(%arg0: f64) -> f64 { + %0 = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.intr.cos(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @fdiv_sin_cos_reassoc(%arg0: f64) -> f64 { + %0 = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.intr.cos(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_sinf_cosf_reassoc(%arg0: f32) -> f32 { + %0 = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %1 = llvm.intr.cos(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fdiv_sinfp128_cosfp128_reassoc(%arg0: f128) -> f128 { + %0 = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath} : (f128) -> f128 + %1 = llvm.intr.cos(%arg0) {fastmathFlags = #llvm.fastmath} : (f128) -> f128 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f128 + llvm.return %2 : f128 + } + llvm.func @use(f64) +} diff --git a/test/LLVMDialect/InstCombine/fdiv-sqrt.ll.mlir b/test/LLVMDialect/InstCombine/fdiv-sqrt.ll.mlir new file mode 100644 index 000000000..2d6491d59 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fdiv-sqrt.ll.mlir @@ -0,0 +1,78 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @sqrt_div_fast(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_div(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fdiv %arg1, %arg2 : f64 + %1 = llvm.intr.sqrt(%0) : (f64) -> f64 + %2 = llvm.fdiv %arg0, %1 : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_div_reassoc_arcp(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_div_reassoc_missing(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_div_reassoc_missing2(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_div_reassoc_missing3(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_div_arcp_missing(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_div_arcp_missing2(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_div_arcp_missing3(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @use(f64) + llvm.func @sqrt_div_fast_multiple_uses_1(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%0) : (f64) -> () + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_div_fast_multiple_uses_2(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.call @use(%1) : (f64) -> () + %2 = llvm.fdiv %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_non_div_operator(%arg0: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/fdiv.ll.mlir b/test/LLVMDialect/InstCombine/fdiv.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/ffs-1.ll.mlir b/test/LLVMDialect/InstCombine/ffs-1.ll.mlir index 2c8cdc630..02381b131 100644 --- a/test/LLVMDialect/InstCombine/ffs-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/ffs-1.ll.mlir @@ -1,84 +1,77 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "ffs", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "ffsl", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "ffsll", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @ffs, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify1", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @ffsl, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify2", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.call"(%0) {callee = @ffsll, fastmathFlags = #llvm.fastmath<>} : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify3", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @ffs, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify4", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 2048 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @ffs, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify5", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 65536 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @ffs, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify6", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 65536 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @ffsl, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify7", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1024 : i64} : () -> i64 - %1 = "llvm.call"(%0) {callee = @ffsll, fastmathFlags = #llvm.fastmath<>} : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify8", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 65536 : i64} : () -> i64 - %1 = "llvm.call"(%0) {callee = @ffsll, fastmathFlags = #llvm.fastmath<>} : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify9", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 17179869184 : i64} : () -> i64 - %1 = "llvm.call"(%0) {callee = @ffsll, fastmathFlags = #llvm.fastmath<>} : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify10", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 281474976710656 : i64} : () -> i64 - %1 = "llvm.call"(%0) {callee = @ffsll, fastmathFlags = #llvm.fastmath<>} : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify11", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1152921504606846976 : i64} : () -> i64 - %1 = "llvm.call"(%0) {callee = @ffsll, fastmathFlags = #llvm.fastmath<>} : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @ffs, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @ffsl, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @ffsll, fastmathFlags = #llvm.fastmath<>} : (i64) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify15", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @ffs(i32) -> i32 + llvm.func @ffsl(i32) -> i32 + llvm.func @ffsll(i64) -> i32 + llvm.func @test_simplify1() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @ffs(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify2() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @ffsl(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify3() -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @ffsll(%0) : (i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify4() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.call @ffs(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify5() -> i32 { + %0 = llvm.mlir.constant(2048 : i32) : i32 + %1 = llvm.call @ffs(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify6() -> i32 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.call @ffs(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify7() -> i32 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.call @ffsl(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify8() -> i32 { + %0 = llvm.mlir.constant(1024 : i64) : i64 + %1 = llvm.call @ffsll(%0) : (i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify9() -> i32 { + %0 = llvm.mlir.constant(65536 : i64) : i64 + %1 = llvm.call @ffsll(%0) : (i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify10() -> i32 { + %0 = llvm.mlir.constant(17179869184 : i64) : i64 + %1 = llvm.call @ffsll(%0) : (i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify11() -> i32 { + %0 = llvm.mlir.constant(281474976710656 : i64) : i64 + %1 = llvm.call @ffsll(%0) : (i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify12() -> i32 { + %0 = llvm.mlir.constant(1152921504606846976 : i64) : i64 + %1 = llvm.call @ffsll(%0) : (i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify13(%arg0: i32) -> i32 { + %0 = llvm.call @ffs(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } + llvm.func @test_simplify14(%arg0: i32) -> i32 { + %0 = llvm.call @ffsl(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } + llvm.func @test_simplify15(%arg0: i64) -> i32 { + %0 = llvm.call @ffsll(%arg0) : (i64) -> i32 + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/ffs-i16.ll.mlir b/test/LLVMDialect/InstCombine/ffs-i16.ll.mlir index 7d71e72d7..90a2854a9 100644 --- a/test/LLVMDialect/InstCombine/ffs-i16.ll.mlir +++ b/test/LLVMDialect/InstCombine/ffs-i16.ll.mlir @@ -1,19 +1,15 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "ffs", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sink", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i16} : () -> i16 - %1 = "llvm.mlir.constant"() {value = 0 : i16} : () -> i16 - %2 = "llvm.call"(%1) {callee = @ffs, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%2) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %3 = "llvm.call"(%0) {callee = @ffs, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%3) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %4 = "llvm.call"(%arg0) {callee = @ffs, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%4) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_ffs", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @ffs(i16) -> i16 + llvm.func @sink(i16) + llvm.func @fold_ffs(%arg0: i16) { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(1 : i16) : i16 + %2 = llvm.call @ffs(%0) : (i16) -> i16 + llvm.call @sink(%2) : (i16) -> () + %3 = llvm.call @ffs(%1) : (i16) -> i16 + llvm.call @sink(%3) : (i16) -> () + %4 = llvm.call @ffs(%arg0) : (i16) -> i16 + llvm.call @sink(%4) : (i16) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/float-shrink-compare.ll.mlir b/test/LLVMDialect/InstCombine/float-shrink-compare.ll.mlir new file mode 100644 index 000000000..a56fd4a27 --- /dev/null +++ b/test/LLVMDialect/InstCombine/float-shrink-compare.ll.mlir @@ -0,0 +1,286 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @test1(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @ceil(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test1_intrin(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.ceil(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test2(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @fabs(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test2_intrin(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.fabs(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @fmf_test2(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @fabs(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test3(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @floor(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test3_intrin(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.floor(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test4(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @nearbyint(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @shrink_nearbyint_intrin(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.nearbyint(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test5(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @rint(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test6(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @round(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test6_intrin(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.round(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test6a(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @roundeven(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test6a_intrin(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.roundeven(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test7(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @trunc(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test7_intrin(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.intr.trunc(%0) : (f64) -> f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test8(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @ceil(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test8_intrin(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.ceil(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test9(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @fabs(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test9_intrin(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.fabs(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test10(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @floor(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @test10_intrin(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.floor(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @test11(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @nearbyint(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @test11_intrin(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.nearbyint(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %2, %1 : f64 + llvm.return %3 : i1 + } + llvm.func @test12(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @rint(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test13(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @round(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test13_intrin(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.round(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test13a(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @roundeven(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test13a_intrin(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.roundeven(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test14(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @trunc(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test14_intrin(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.trunc(%0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %1, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @test15(%arg0: f32, %arg1: f32, %arg2: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @fmin(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fpext %arg2 : f32 to f64 + %4 = llvm.fcmp "oeq" %2, %3 : f64 + llvm.return %4 : i1 + } + llvm.func @test16(%arg0: f32, %arg1: f32, %arg2: f32) -> i1 { + %0 = llvm.fpext %arg2 : f32 to f64 + %1 = llvm.fpext %arg0 : f32 to f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.call @fmin(%1, %2) : (f64, f64) -> f64 + %4 = llvm.fcmp "oeq" %0, %3 : f64 + llvm.return %4 : i1 + } + llvm.func @test17(%arg0: f32, %arg1: f32, %arg2: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @fmax(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fpext %arg2 : f32 to f64 + %4 = llvm.fcmp "oeq" %2, %3 : f64 + llvm.return %4 : i1 + } + llvm.func @test18(%arg0: f32, %arg1: f32, %arg2: f32) -> i1 { + %0 = llvm.fpext %arg2 : f32 to f64 + %1 = llvm.fpext %arg0 : f32 to f64 + %2 = llvm.fpext %arg1 : f32 to f64 + %3 = llvm.call @fmax(%1, %2) : (f64, f64) -> f64 + %4 = llvm.fcmp "oeq" %0, %3 : f64 + llvm.return %4 : i1 + } + llvm.func @test19(%arg0: f32, %arg1: f32, %arg2: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @copysign(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fpext %arg2 : f32 to f64 + %4 = llvm.fcmp "oeq" %2, %3 : f64 + llvm.return %4 : i1 + } + llvm.func @test20(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.fpext %arg0 : f32 to f64 + %3 = llvm.call @fmin(%0, %2) : (f64, f64) -> f64 + %4 = llvm.fcmp "oeq" %1, %3 : f64 + llvm.return %4 : i1 + } + llvm.func @test21(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(1.300000e+00 : f64) : f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.fpext %arg0 : f32 to f64 + %3 = llvm.call @fmin(%0, %2) : (f64, f64) -> f64 + %4 = llvm.fcmp "oeq" %1, %3 : f64 + llvm.return %4 : i1 + } + llvm.func @fabs(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @ceil(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @copysign(f64, f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @floor(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @nearbyint(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @rint(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @round(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @roundeven(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @trunc(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @fmin(f64, f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @fmax(f64, f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} +} diff --git a/test/LLVMDialect/InstCombine/fls-i16.ll.mlir b/test/LLVMDialect/InstCombine/fls-i16.ll.mlir index 96b705272..14d68496d 100644 --- a/test/LLVMDialect/InstCombine/fls-i16.ll.mlir +++ b/test/LLVMDialect/InstCombine/fls-i16.ll.mlir @@ -1,19 +1,15 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fls", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sink", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i16} : () -> i16 - %1 = "llvm.mlir.constant"() {value = 0 : i16} : () -> i16 - %2 = "llvm.call"(%1) {callee = @fls, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%2) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %3 = "llvm.call"(%0) {callee = @fls, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%3) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %4 = "llvm.call"(%arg0) {callee = @fls, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%4) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_fls", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fls(i16) -> i16 + llvm.func @sink(i16) + llvm.func @fold_fls(%arg0: i16) { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(1 : i16) : i16 + %2 = llvm.call @fls(%0) : (i16) -> i16 + llvm.call @sink(%2) : (i16) -> () + %3 = llvm.call @fls(%1) : (i16) -> i16 + llvm.call @sink(%3) : (i16) -> () + %4 = llvm.call @fls(%arg0) : (i16) -> i16 + llvm.call @sink(%4) : (i16) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/fls.ll.mlir b/test/LLVMDialect/InstCombine/fls.ll.mlir index 4a868e17e..6e66df3df 100644 --- a/test/LLVMDialect/InstCombine/fls.ll.mlir +++ b/test/LLVMDialect/InstCombine/fls.ll.mlir @@ -1,34 +1,29 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @fls, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "myfls", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 42 : i64} : () -> i64 - %1 = "llvm.call"(%0) {callee = @flsl, fastmathFlags = #llvm.fastmath<>} : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "myflsl", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 42 : i64} : () -> i64 - %1 = "llvm.call"(%0) {callee = @flsll, fastmathFlags = #llvm.fastmath<>} : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "myflsll", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @flsl, fastmathFlags = #llvm.fastmath<>} : (i64) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "flsnotconst", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @fls, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "flszero", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fls", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "flsl", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "flsll", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @myfls() -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.call @fls(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @myflsl() -> i32 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.call @flsl(%0) : (i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @myflsll() -> i32 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.call @flsll(%0) : (i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @flsnotconst(%arg0: i64) -> i32 { + %0 = llvm.call @flsl(%arg0) : (i64) -> i32 + llvm.return %0 : i32 + } + llvm.func @flszero() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @fls(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @fls(i32) -> i32 + llvm.func @flsl(i64) -> i32 + llvm.func @flsll(i64) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/fma.ll.mlir b/test/LLVMDialect/InstCombine/fma.ll.mlir new file mode 100644 index 000000000..9aa79a6d5 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fma.ll.mlir @@ -0,0 +1,556 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @external() {addr_space = 0 : i32} : i32 + llvm.func @use_vec(vector<2xf32>) + llvm.func @use_vec3(vector<3xf32>) + llvm.func @fma_fneg_x_fneg_y(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fsub %0, %arg1 : f32 + %3 = llvm.intr.fma(%1, %2, %arg2) : (f32, f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @fma_unary_fneg_x_unary_fneg_y(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fneg %arg1 : f32 + %2 = llvm.intr.fma(%0, %1, %arg2) : (f32, f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @fma_fneg_x_fneg_y_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 : vector<2xf32> + %2 = llvm.fsub %0, %arg1 : vector<2xf32> + %3 = llvm.intr.fma(%1, %2, %arg2) : (vector<2xf32>, vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @fma_unary_fneg_x_unary_fneg_y_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fneg %arg0 : vector<2xf32> + %1 = llvm.fneg %arg1 : vector<2xf32> + %2 = llvm.intr.fma(%0, %1, %arg2) : (vector<2xf32>, vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fma_fneg_x_fneg_y_vec_poison(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.poison : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.mlir.undef : vector<2xf32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.undef : vector<2xf32> + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<2xf32> + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<2xf32> + %12 = llvm.fsub %6, %arg0 : vector<2xf32> + %13 = llvm.fsub %11, %arg1 : vector<2xf32> + %14 = llvm.intr.fma(%12, %13, %arg2) : (vector<2xf32>, vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %14 : vector<2xf32> + } + llvm.func @fma_fneg_x_fneg_y_fast(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fsub %0, %arg1 : f32 + %3 = llvm.intr.fma(%1, %2, %arg2) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @fma_unary_fneg_x_unary_fneg_y_fast(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fneg %arg1 : f32 + %2 = llvm.intr.fma(%0, %1, %arg2) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @fma_fneg_const_fneg_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.addressof @external : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.bitcast %2 : i32 to f32 + %4 = llvm.fsub %0, %arg0 : f32 + %5 = llvm.fsub %0, %3 : f32 + %6 = llvm.intr.fma(%5, %4, %arg1) : (f32, f32, f32) -> f32 + llvm.return %6 : f32 + } + llvm.func @fma_unary_fneg_const_unary_fneg_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.addressof @external : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i32 + %2 = llvm.bitcast %1 : i32 to f32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.fneg %2 : f32 + %5 = llvm.intr.fma(%4, %3, %arg1) : (f32, f32, f32) -> f32 + llvm.return %5 : f32 + } + llvm.func @fma_fneg_x_fneg_const(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.addressof @external : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.bitcast %2 : i32 to f32 + %4 = llvm.fsub %0, %arg0 : f32 + %5 = llvm.fsub %0, %3 : f32 + %6 = llvm.intr.fma(%4, %5, %arg1) : (f32, f32, f32) -> f32 + llvm.return %6 : f32 + } + llvm.func @fma_unary_fneg_x_unary_fneg_const(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.addressof @external : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i32 + %2 = llvm.bitcast %1 : i32 to f32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.fneg %2 : f32 + %5 = llvm.intr.fma(%3, %4, %arg1) : (f32, f32, f32) -> f32 + llvm.return %5 : f32 + } + llvm.func @fma_fabs_x_fabs_y(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.intr.fabs(%arg1) : (f32) -> f32 + %2 = llvm.intr.fma(%0, %1, %arg2) : (f32, f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @fma_fabs_x_fabs_x(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.intr.fma(%0, %0, %arg1) : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fma_fabs_x_fabs_x_fast(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.intr.fma(%0, %0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fmuladd_fneg_x_fneg_y(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fsub %0, %arg1 : f32 + %3 = llvm.intr.fmuladd(%1, %2, %arg2) : (f32, f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @fmuladd_unary_fneg_x_unary_fneg_y(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fneg %arg1 : f32 + %2 = llvm.intr.fmuladd(%0, %1, %arg2) : (f32, f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @fmuladd_fneg_x_fneg_y_fast(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fsub %0, %arg1 : f32 + %3 = llvm.intr.fmuladd(%1, %2, %arg2) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @fmuladd_unfold(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.intr.fmuladd(%arg0, %arg1, %arg2) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + llvm.return %0 : f32 + } + llvm.func @fmuladd_unfold_vec(%arg0: vector<8xf16>, %arg1: vector<8xf16>, %arg2: vector<8xf16>) -> vector<8xf16> { + %0 = llvm.intr.fmuladd(%arg0, %arg1, %arg2) {fastmathFlags = #llvm.fastmath} : (vector<8xf16>, vector<8xf16>, vector<8xf16>) -> vector<8xf16> + llvm.return %0 : vector<8xf16> + } + llvm.func @fmuladd_unary_fneg_x_unary_fneg_y_fast(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fneg %arg1 : f32 + %2 = llvm.intr.fmuladd(%0, %1, %arg2) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @fmuladd_fneg_const_fneg_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.addressof @external : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.bitcast %2 : i32 to f32 + %4 = llvm.fsub %0, %arg0 : f32 + %5 = llvm.fsub %0, %3 : f32 + %6 = llvm.intr.fmuladd(%5, %4, %arg1) : (f32, f32, f32) -> f32 + llvm.return %6 : f32 + } + llvm.func @fmuladd_unary_fneg_const_unary_fneg_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.addressof @external : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i32 + %2 = llvm.bitcast %1 : i32 to f32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.fneg %2 : f32 + %5 = llvm.intr.fmuladd(%4, %3, %arg1) : (f32, f32, f32) -> f32 + llvm.return %5 : f32 + } + llvm.func @fmuladd_fneg_x_fneg_const(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.addressof @external : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.bitcast %2 : i32 to f32 + %4 = llvm.fsub %0, %arg0 : f32 + %5 = llvm.fsub %0, %3 : f32 + %6 = llvm.intr.fmuladd(%4, %5, %arg1) : (f32, f32, f32) -> f32 + llvm.return %6 : f32 + } + llvm.func @fmuladd_unary_fneg_x_unary_fneg_const(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.addressof @external : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i32 + %2 = llvm.bitcast %1 : i32 to f32 + %3 = llvm.fneg %arg0 : f32 + %4 = llvm.fneg %2 : f32 + %5 = llvm.intr.fmuladd(%3, %4, %arg1) : (f32, f32, f32) -> f32 + llvm.return %5 : f32 + } + llvm.func @fmuladd_fabs_x_fabs_y(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.intr.fabs(%arg1) : (f32) -> f32 + %2 = llvm.intr.fmuladd(%0, %1, %arg2) : (f32, f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @fmuladd_fabs_x_fabs_x(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.intr.fmuladd(%0, %0, %arg1) : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fmuladd_fabs_x_fabs_x_fast(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.intr.fmuladd(%0, %0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fma_k_y_z(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %1 = llvm.intr.fma(%0, %arg0, %arg1) : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fma_k_y_z_fast(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %1 = llvm.intr.fma(%0, %arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fmuladd_k_y_z_fast(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %1 = llvm.intr.fmuladd(%0, %arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fma_1_y_z(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.fma(%0, %arg0, %arg1) : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fma_x_1_z(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.fma(%arg0, %0, %arg1) : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fma_x_1_z_v2f32(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<1.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.intr.fma(%arg0, %0, %arg1) : (vector<2xf32>, vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @fma_x_1_2_z_v2f32(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.intr.fma(%arg0, %0, %arg1) : (vector<2xf32>, vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @fma_x_1_z_fast(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.fma(%arg0, %0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fma_1_1_z(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.fma(%0, %0, %arg0) : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fma_x_y_0(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.intr.fma(%arg0, %arg1, %0) : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fma_x_y_0_nsz(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.intr.fma(%arg0, %arg1, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fma_x_y_0_v(%arg0: vector<8xf16>, %arg1: vector<8xf16>) -> vector<8xf16> { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf16>) : vector<8xf16> + %2 = llvm.intr.fma(%arg0, %arg1, %1) : (vector<8xf16>, vector<8xf16>, vector<8xf16>) -> vector<8xf16> + llvm.return %2 : vector<8xf16> + } + llvm.func @fma_x_y_0_nsz_v(%arg0: vector<8xf16>, %arg1: vector<8xf16>) -> vector<8xf16> { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf16>) : vector<8xf16> + %2 = llvm.intr.fma(%arg0, %arg1, %1) {fastmathFlags = #llvm.fastmath} : (vector<8xf16>, vector<8xf16>, vector<8xf16>) -> vector<8xf16> + llvm.return %2 : vector<8xf16> + } + llvm.func @fmuladd_x_y_0(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.intr.fmuladd(%arg0, %arg1, %0) : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fmuladd_x_y_0_nsz(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.intr.fmuladd(%arg0, %arg1, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fma_x_y_m0(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.intr.fma(%arg0, %arg1, %0) : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fma_x_y_m0_v(%arg0: vector<8xf16>, %arg1: vector<8xf16>) -> vector<8xf16> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<8xf16>) : vector<8xf16> + %1 = llvm.intr.fma(%arg0, %arg1, %0) : (vector<8xf16>, vector<8xf16>, vector<8xf16>) -> vector<8xf16> + llvm.return %1 : vector<8xf16> + } + llvm.func @fmuladd_x_y_m0(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.intr.fmuladd(%arg0, %arg1, %0) : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fmuladd_x_1_z_fast(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.fmuladd(%arg0, %0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @fmuladd_a_0_b(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fmuladd(%arg0, %1, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fmuladd_0_a_b(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fmuladd(%1, %arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fmuladd_a_0_b_missing_flags(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fmuladd(%arg0, %1, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fma_a_0_b(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fma(%arg0, %1, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fma_0_a_b(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fma(%1, %arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fma_0_a_b_missing_flags(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fma(%1, %arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fma_sqrt(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.intr.sqrt(%arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>) -> vector<2xf64> + %1 = llvm.intr.fma(%0, %0, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fma_const_fmul(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[1123123.0099110012, 9999.0000001000008]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.mlir.constant(dense<[1.291820e-08, 9.123000e-06]> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fma(%0, %1, %arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fma_const_fmul_zero(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.mlir.constant(dense<[1123123.0099110012, 9999.0000001000008]> : vector<2xf64>) : vector<2xf64> + %3 = llvm.intr.fma(%1, %2, %arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @fma_const_fmul_zero2(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[1123123.0099110012, 9999.0000001000008]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %3 = llvm.intr.fma(%0, %2, %arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @fma_const_fmul_one(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<1.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.mlir.constant(dense<[1123123.0099110012, 9999.0000001000008]> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fma(%0, %1, %arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fma_const_fmul_one2(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[1123123.0099110012, 9999.0000001000008]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.mlir.constant(dense<1.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fma(%0, %1, %arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fma_nan_and_const_0(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<0x7FF8000000000000> : vector<2xf64>) : vector<2xf64> + %1 = llvm.mlir.constant(dense<[1.291820e-08, 9.123000e-06]> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fma(%0, %1, %arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fma_nan_and_const_1(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[1.291820e-08, 9.123000e-06]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.mlir.constant(dense<0x7FF8000000000000> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fma(%0, %1, %arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fma_nan_and_const_2(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[1.291820e-08, 9.123000e-06]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.mlir.constant(dense<0x7FF8000000000000> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fma(%0, %arg0, %1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fma_undef_0(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.intr.fma(%0, %arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fma_undef_1(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.intr.fma(%arg0, %0, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fma_undef_2(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.intr.fma(%arg0, %arg1, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fma_partial_undef_0(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(199.00122999999999 : f64) : f64 + %1 = llvm.mlir.undef : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.intr.fma(%6, %arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %7 : vector<2xf64> + } + llvm.func @fma_partial_undef_1(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.undef : f64 + %1 = llvm.mlir.constant(199.00122999999999 : f64) : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.intr.fma(%arg0, %6, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %7 : vector<2xf64> + } + llvm.func @fma_partial_undef_2(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.undef : f64 + %1 = llvm.mlir.constant(199.00122999999999 : f64) : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.intr.fma(%arg0, %arg1, %6) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %7 : vector<2xf64> + } + llvm.func @fma_nan_0(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<0x7FF8000000000000> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.fma(%0, %arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fma_nan_1(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<0x7FF8000000000000> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.fma(%arg0, %0, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fma_nan_2(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<0x7FF8000000000000> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.fma(%arg0, %arg1, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fmuladd_const_fmul(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[1123123.0099110012, 9999.0000001000008]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.mlir.constant(dense<[1.291820e-08, 9.123000e-06]> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fmuladd(%0, %1, %arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fmuladd_nan_and_const_0(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<0x7FF8000000000000> : vector<2xf64>) : vector<2xf64> + %1 = llvm.mlir.constant(dense<[1.291820e-08, 9.123000e-06]> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fmuladd(%0, %1, %arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fmuladd_nan_and_const_1(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[1.291820e-08, 9.123000e-06]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.mlir.constant(dense<0x7FF8000000000000> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fmuladd(%0, %1, %arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fmuladd_nan_and_const_2(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[1.291820e-08, 9.123000e-06]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.mlir.constant(dense<0x7FF8000000000000> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.fmuladd(%0, %arg0, %1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @fmuladd_nan_0(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<0x7FF8000000000000> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.fmuladd(%0, %arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fmuladd_nan_1(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<0x7FF8000000000000> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.fmuladd(%arg0, %0, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fmuladd_undef_0(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.intr.fmuladd(%0, %arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fmuladd_undef_1(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.intr.fmuladd(%arg0, %0, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fmuladd_undef_2(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<0x7FF8000000000000> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.fmuladd(%arg0, %arg1, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fma_unary_shuffle_ops(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.shufflevector %arg0, %0 [1, 0] : vector<2xf32> + %2 = llvm.shufflevector %arg1, %0 [1, 0] : vector<2xf32> + %3 = llvm.shufflevector %arg2, %0 [1, 0] : vector<2xf32> + %4 = llvm.intr.fma(%1, %2, %3) : (vector<2xf32>, vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fma_unary_shuffle_ops_widening(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<3xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.shufflevector %arg0, %0 [1, 0, 1] : vector<2xf32> + llvm.call @use_vec3(%1) : (vector<3xf32>) -> () + %2 = llvm.shufflevector %arg1, %0 [1, 0, 1] : vector<2xf32> + %3 = llvm.shufflevector %arg2, %0 [1, 0, 1] : vector<2xf32> + %4 = llvm.intr.fma(%1, %2, %3) {fastmathFlags = #llvm.fastmath} : (vector<3xf32>, vector<3xf32>, vector<3xf32>) -> vector<3xf32> + llvm.return %4 : vector<3xf32> + } + llvm.func @fma_unary_shuffle_ops_narrowing(%arg0: vector<3xf32>, %arg1: vector<3xf32>, %arg2: vector<3xf32>) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<3xf32> + %1 = llvm.shufflevector %arg0, %0 [1, 0] : vector<3xf32> + %2 = llvm.shufflevector %arg1, %0 [1, 0] : vector<3xf32> + llvm.call @use_vec(%2) : (vector<2xf32>) -> () + %3 = llvm.shufflevector %arg2, %0 [1, 0] : vector<3xf32> + %4 = llvm.intr.fma(%1, %2, %3) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>, vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fma_unary_shuffle_ops_unshuffled(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.shufflevector %arg0, %0 [1, 0] : vector<2xf32> + %2 = llvm.shufflevector %arg1, %0 [1, 0] : vector<2xf32> + %3 = llvm.intr.fma(%1, %2, %arg2) : (vector<2xf32>, vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @fma_unary_shuffle_ops_wrong_mask(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.shufflevector %arg0, %0 [1, 0] : vector<2xf32> + %2 = llvm.shufflevector %arg1, %0 [0, 0] : vector<2xf32> + %3 = llvm.shufflevector %arg2, %0 [1, 0] : vector<2xf32> + %4 = llvm.intr.fma(%1, %2, %3) : (vector<2xf32>, vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fma_unary_shuffle_ops_uses(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.shufflevector %arg0, %0 [1, 0] : vector<2xf32> + llvm.call @use_vec(%1) : (vector<2xf32>) -> () + %2 = llvm.shufflevector %arg1, %0 [1, 0] : vector<2xf32> + llvm.call @use_vec(%2) : (vector<2xf32>) -> () + %3 = llvm.shufflevector %arg2, %0 [1, 0] : vector<2xf32> + llvm.call @use_vec(%3) : (vector<2xf32>) -> () + %4 = llvm.intr.fma(%1, %2, %3) : (vector<2xf32>, vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %4 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/fmul-bool.ll.mlir b/test/LLVMDialect/InstCombine/fmul-bool.ll.mlir new file mode 100644 index 000000000..b00a2cacc --- /dev/null +++ b/test/LLVMDialect/InstCombine/fmul-bool.ll.mlir @@ -0,0 +1,18 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fmul_bool(%arg0: f32, %arg1: i1) -> f32 { + %0 = llvm.uitofp %arg1 : i1 to f32 + %1 = llvm.fmul %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @fmul_bool_vec(%arg0: vector<2xf32>, %arg1: vector<2xi1>) -> vector<2xf32> { + %0 = llvm.uitofp %arg1 : vector<2xi1> to vector<2xf32> + %1 = llvm.fmul %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @fmul_bool_vec_commute(%arg0: vector<2xf32>, %arg1: vector<2xi1>) -> vector<2xf32> { + %0 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %1 = llvm.uitofp %arg1 : vector<2xi1> to vector<2xf32> + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %2 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/fmul-exp.ll.mlir b/test/LLVMDialect/InstCombine/fmul-exp.ll.mlir index 0423ff528..4e374d28b 100644 --- a/test/LLVMDialect/InstCombine/fmul-exp.ll.mlir +++ b/test/LLVMDialect/InstCombine/fmul-exp.ll.mlir @@ -1,62 +1,51 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.exp.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.exp.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.exp.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp_a_exp_b", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.exp.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.exp.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp_a_exp_b_multiple_uses", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.exp.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.exp.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp_a_exp_b_multiple_uses_both", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.exp.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.exp.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp_a_exp_b_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.exp.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fmul"(%0, %0) : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp_a_a", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.exp.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - %1 = "llvm.fmul"(%0, %0) : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp_a_a_extra_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.exp.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.exp.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - %3 = "llvm.call"(%arg2) {callee = @llvm.exp.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %4 = "llvm.fmul"(%2, %3) : (f64, f64) -> f64 - %5 = "llvm.call"(%arg3) {callee = @llvm.exp.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %6 = "llvm.fmul"(%4, %5) : (f64, f64) -> f64 - "llvm.return"(%6) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp_a_exp_b_exp_c_exp_d_fast", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(f64) + llvm.func @exp_a_exp_b(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.exp(%arg0) : (f64) -> f64 + %1 = llvm.intr.exp(%arg1) : (f64) -> f64 + %2 = llvm.fmul %0, %1 : f64 + llvm.return %2 : f64 + } + llvm.func @exp_a_exp_b_multiple_uses(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.exp(%arg0) : (f64) -> f64 + %1 = llvm.intr.exp(%arg1) : (f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @exp_a_exp_b_multiple_uses_both(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.exp(%arg0) : (f64) -> f64 + %1 = llvm.intr.exp(%arg1) : (f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%0) : (f64) -> () + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @exp_a_exp_b_reassoc(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.exp(%arg0) : (f64) -> f64 + %1 = llvm.intr.exp(%arg1) : (f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @exp_a_a(%arg0: f64) -> f64 { + %0 = llvm.intr.exp(%arg0) : (f64) -> f64 + %1 = llvm.fmul %0, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %1 : f64 + } + llvm.func @exp_a_a_extra_use(%arg0: f64) -> f64 { + %0 = llvm.intr.exp(%arg0) : (f64) -> f64 + llvm.call @use(%0) : (f64) -> () + %1 = llvm.fmul %0, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %1 : f64 + } + llvm.func @exp_a_exp_b_exp_c_exp_d_fast(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: f64) -> f64 { + %0 = llvm.intr.exp(%arg0) : (f64) -> f64 + %1 = llvm.intr.exp(%arg1) : (f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.intr.exp(%arg2) : (f64) -> f64 + %4 = llvm.fmul %2, %3 {fastmathFlags = #llvm.fastmath} : f64 + %5 = llvm.intr.exp(%arg3) : (f64) -> f64 + %6 = llvm.fmul %4, %5 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %6 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/fmul-exp2.ll.mlir b/test/LLVMDialect/InstCombine/fmul-exp2.ll.mlir index f842619dc..aba8f2804 100644 --- a/test/LLVMDialect/InstCombine/fmul-exp2.ll.mlir +++ b/test/LLVMDialect/InstCombine/fmul-exp2.ll.mlir @@ -1,55 +1,45 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.exp2.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.exp2.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.exp2.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp2_a_exp2_b", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.exp2.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.exp2.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp2_a_exp2_b_multiple_uses", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.exp2.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fmul"(%0, %0) : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp2_a_a", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.exp2.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.exp2.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp2_a_exp2_b_multiple_uses_both", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.exp2.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.exp2.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp2_a_exp2_b_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.exp2.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.exp2.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - %3 = "llvm.call"(%arg2) {callee = @llvm.exp2.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %4 = "llvm.fmul"(%2, %3) : (f64, f64) -> f64 - %5 = "llvm.call"(%arg3) {callee = @llvm.exp2.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %6 = "llvm.fmul"(%4, %5) : (f64, f64) -> f64 - "llvm.return"(%6) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "exp2_a_exp2_b_exp2_c_exp2_d", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(f64) + llvm.func @exp2_a_exp2_b(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.exp2(%arg0) : (f64) -> f64 + %1 = llvm.intr.exp2(%arg1) : (f64) -> f64 + %2 = llvm.fmul %0, %1 : f64 + llvm.return %2 : f64 + } + llvm.func @exp2_a_exp2_b_multiple_uses(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.exp2(%arg0) : (f64) -> f64 + %1 = llvm.intr.exp2(%arg1) : (f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @exp2_a_a(%arg0: f64) -> f64 { + %0 = llvm.intr.exp2(%arg0) : (f64) -> f64 + %1 = llvm.fmul %0, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %1 : f64 + } + llvm.func @exp2_a_exp2_b_multiple_uses_both(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.exp2(%arg0) : (f64) -> f64 + %1 = llvm.intr.exp2(%arg1) : (f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%0) : (f64) -> () + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @exp2_a_exp2_b_reassoc(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.exp2(%arg0) : (f64) -> f64 + %1 = llvm.intr.exp2(%arg1) : (f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @exp2_a_exp2_b_exp2_c_exp2_d(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: f64) -> f64 { + %0 = llvm.intr.exp2(%arg0) : (f64) -> f64 + %1 = llvm.intr.exp2(%arg1) : (f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.intr.exp2(%arg2) : (f64) -> f64 + %4 = llvm.fmul %2, %3 {fastmathFlags = #llvm.fastmath} : f64 + %5 = llvm.intr.exp2(%arg3) : (f64) -> f64 + %6 = llvm.fmul %4, %5 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %6 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/fmul-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/fmul-inseltpoison.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/fmul-maximum-minimum.ll.mlir b/test/LLVMDialect/InstCombine/fmul-maximum-minimum.ll.mlir new file mode 100644 index 000000000..827ec7524 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fmul-maximum-minimum.ll.mlir @@ -0,0 +1,44 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.minimum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maximum(%arg0, %arg1) : (f32, f32) -> f32 + %2 = llvm.fmul %0, %1 : f32 + llvm.return %2 : f32 + } + llvm.func @test_comm1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.minimum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maximum(%arg0, %arg1) : (f32, f32) -> f32 + %2 = llvm.fmul %1, %0 : f32 + llvm.return %2 : f32 + } + llvm.func @test_comm2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.minimum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maximum(%arg1, %arg0) : (f32, f32) -> f32 + %2 = llvm.fmul %0, %1 : f32 + llvm.return %2 : f32 + } + llvm.func @test_comm3(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.minimum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maximum(%arg1, %arg0) : (f32, f32) -> f32 + %2 = llvm.fmul %1, %0 : f32 + llvm.return %2 : f32 + } + llvm.func @test_vect(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.intr.minimum(%arg0, %arg1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> + %1 = llvm.intr.maximum(%arg1, %arg0) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> + %2 = llvm.fmul %0, %1 : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @test_flags(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.minimum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maximum(%arg0, %arg1) : (f32, f32) -> f32 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @test_flags2(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.minimum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maximum(%arg0, %arg1) : (f32, f32) -> f32 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/fmul-pow.ll.mlir b/test/LLVMDialect/InstCombine/fmul-pow.ll.mlir index a2fa3365d..10d2628a0 100644 --- a/test/LLVMDialect/InstCombine/fmul-pow.ll.mlir +++ b/test/LLVMDialect/InstCombine/fmul-pow.ll.mlir @@ -1,85 +1,144 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %1 = "llvm.fmul"(%0, %arg0) : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ab_a", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %1 = "llvm.fmul"(%0, %arg0) : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ab_a_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.fdiv"(%0, %arg0) : (f64, f64) -> f64 - %2 = "llvm.call"(%arg0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %3 = "llvm.fmul"(%1, %2) : (f64, f64) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ab_a_reassoc_commute", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %1 = "llvm.call"(%arg2, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %2 = "llvm.fmul"(%1, %0) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ab_pow_cb", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %1 = "llvm.call"(%arg2, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %2 = "llvm.fmul"(%1, %0) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ab_pow_cb_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %1 = "llvm.call"(%arg0, %arg2) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %2 = "llvm.fmul"(%1, %0) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ab_pow_ac", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %1 = "llvm.call"(%arg0, %arg2) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %2 = "llvm.fmul"(%1, %0) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ab_x_pow_ac_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %1 = "llvm.fmul"(%0, %0) : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ab_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %1 = "llvm.fmul"(%0, %0) : (f64, f64) -> f64 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ab_reassoc_extra_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %1 = "llvm.call"(%arg0, %arg2) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ab_x_pow_ac_reassoc_extra_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %1 = "llvm.call"(%arg0, %arg2) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ab_x_pow_ac_reassoc_multiple_uses", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(f64) + llvm.func @pow_ab_a(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.fmul %0, %arg0 : f64 + llvm.return %1 : f64 + } + llvm.func @pow_ab_a_reassoc(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.fmul %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %1 : f64 + } + llvm.func @pow_ab_a_reassoc_commute(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(4.200000e+01 : f64) : f64 + %1 = llvm.fadd %arg0, %0 : f64 + %2 = llvm.intr.pow(%1, %arg1) : (f64, f64) -> f64 + %3 = llvm.fmul %1, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %3 : f64 + } + llvm.func @pow_ab_a_reassoc_use(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.fmul %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%0) : (f64) -> () + llvm.return %1 : f64 + } + llvm.func @pow_ab_recip_a(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.fdiv %0, %arg0 : f64 + %2 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %3 = llvm.fmul %1, %2 : f64 + llvm.return %3 : f64 + } + llvm.func @pow_ab_recip_a_reassoc(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.intr.pow(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fmul %1, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %3 : f64 + } + llvm.func @pow_ab_recip_a_reassoc_commute(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.intr.pow(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fmul %2, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %3 : f64 + } + llvm.func @pow_ab_recip_a_reassoc_use1(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.intr.pow(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fmul %1, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%1) : (f64) -> () + llvm.return %3 : f64 + } + llvm.func @pow_ab_recip_a_reassoc_use2(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.intr.pow(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fmul %1, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%2) : (f64) -> () + llvm.return %3 : f64 + } + llvm.func @pow_ab_recip_a_reassoc_use3(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.intr.pow(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fmul %1, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%1) : (f64) -> () + llvm.call @use(%2) : (f64) -> () + llvm.return %3 : f64 + } + llvm.func @pow_ab_pow_cb(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.intr.pow(%arg2, %arg1) : (f64, f64) -> f64 + %2 = llvm.fmul %1, %0 : f64 + llvm.return %2 : f64 + } + llvm.func @pow_ab_pow_cb_reassoc(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.intr.pow(%arg2, %arg1) : (f64, f64) -> f64 + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @pow_ab_pow_cb_reassoc_use1(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.intr.pow(%arg2, %arg1) : (f64, f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%0) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @pow_ab_pow_cb_reassoc_use2(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.intr.pow(%arg2, %arg1) : (f64, f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @pow_ab_pow_cb_reassoc_use3(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.intr.pow(%arg2, %arg1) : (f64, f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%0) : (f64) -> () + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @pow_ab_pow_ac(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.intr.pow(%arg0, %arg2) : (f64, f64) -> f64 + %2 = llvm.fmul %1, %0 : f64 + llvm.return %2 : f64 + } + llvm.func @pow_ab_x_pow_ac_reassoc(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.intr.pow(%arg0, %arg2) : (f64, f64) -> f64 + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @pow_ab_reassoc(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.fmul %0, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %1 : f64 + } + llvm.func @pow_ab_reassoc_extra_use(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.fmul %0, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%0) : (f64) -> () + llvm.return %1 : f64 + } + llvm.func @pow_ab_x_pow_ac_reassoc_extra_use(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.intr.pow(%arg0, %arg2) : (f64, f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%0) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @pow_ab_x_pow_ac_reassoc_multiple_uses(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.intr.pow(%arg0, %arg2) : (f64, f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%0) : (f64) -> () + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/fmul-sqrt.ll.mlir b/test/LLVMDialect/InstCombine/fmul-sqrt.ll.mlir index ac8dcc9b6..d2bc5f781 100644 --- a/test/LLVMDialect/InstCombine/fmul-sqrt.ll.mlir +++ b/test/LLVMDialect/InstCombine/fmul-sqrt.ll.mlir @@ -1,122 +1,102 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.sqrt.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.sqrt.v2f32", type = !llvm.func (vector<2xf32>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_a_sqrt_b", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_a_sqrt_b_multiple_uses", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_a_sqrt_b_reassoc_nnan", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_a_sqrt_b_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg1) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.call"(%arg2) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %3 = "llvm.call"(%arg3) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %4 = "llvm.fmul"(%0, %1) : (f64, f64) -> f64 - %5 = "llvm.fmul"(%4, %2) : (f64, f64) -> f64 - %6 = "llvm.fmul"(%5, %3) : (f64, f64) -> f64 - "llvm.return"(%6) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_a_sqrt_b_sqrt_c_sqrt_d_reassoc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - %3 = "llvm.fmul"(%2, %2) : (f64, f64) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "rsqrt_squared", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - %3 = "llvm.fmul"(%2, %arg0) : (f64, f64) -> f64 - "llvm.store"(%2, %arg1) : (f64, !llvm.ptr) -> () - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "rsqrt_x_reassociate_extra_use", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1.000000e+00> : vector<2xf32>} : () -> vector<2xf32> - %1 = "llvm.fadd"(%arg0, %arg1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %2 = "llvm.call"(%1) {callee = @llvm.sqrt.v2f32, fastmathFlags = #llvm.fastmath<>} : (vector<2xf32>) -> vector<2xf32> - %3 = "llvm.fdiv"(%0, %2) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %4 = "llvm.fmul"(%1, %3) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - "llvm.store"(%3, %arg2) : (vector<2xf32>, !llvm.ptr>) -> () - "llvm.return"(%4) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "x_add_y_rsqrt_reassociate_extra_use", type = !llvm.func (vector<2xf32>, vector<2xf32>, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fdiv"(%arg1, %0) : (f64, f64) -> f64 - %2 = "llvm.fmul"(%1, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_divisor_squared", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>, %arg1: vector<2xf32>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sqrt.v2f32, fastmathFlags = #llvm.fastmath<>} : (vector<2xf32>) -> vector<2xf32> - %1 = "llvm.fdiv"(%0, %arg1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - %2 = "llvm.fmul"(%1, %1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - "llvm.return"(%2) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_dividend_squared", type = !llvm.func (vector<2xf32>, vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fdiv"(%arg1, %0) : (f64, f64) -> f64 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - %2 = "llvm.fmul"(%1, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_divisor_squared_extra_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - %1 = "llvm.fdiv"(%0, %arg1) : (f64, f64) -> f64 - %2 = "llvm.fmul"(%1, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_dividend_squared_extra_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.fdiv"(%arg1, %0) : (f64, f64) -> f64 - %2 = "llvm.fmul"(%1, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_divisor_not_enough_FMF", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%arg0) {callee = @llvm.sqrt.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fdiv"(%0, %1) : (f64, f64) -> f64 - "llvm.call"(%2) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - %3 = "llvm.fmul"(%2, %2) : (f64, f64) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "rsqrt_squared_extra_use", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(f64) + llvm.func @sqrt_a_sqrt_b(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.sqrt(%arg0) : (f64) -> f64 + %1 = llvm.intr.sqrt(%arg1) : (f64) -> f64 + %2 = llvm.fmul %0, %1 : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_a_sqrt_b_multiple_uses(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.sqrt(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.intr.sqrt(%arg1) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @sqrt_a_sqrt_b_reassoc_nnan(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.sqrt(%arg0) : (f64) -> f64 + %1 = llvm.intr.sqrt(%arg1) : (f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_a_sqrt_b_reassoc(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.sqrt(%arg0) : (f64) -> f64 + %1 = llvm.intr.sqrt(%arg1) : (f64) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_a_sqrt_b_sqrt_c_sqrt_d_reassoc(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: f64) -> f64 { + %0 = llvm.intr.sqrt(%arg0) : (f64) -> f64 + %1 = llvm.intr.sqrt(%arg1) : (f64) -> f64 + %2 = llvm.intr.sqrt(%arg2) : (f64) -> f64 + %3 = llvm.intr.sqrt(%arg3) : (f64) -> f64 + %4 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + %5 = llvm.fmul %4, %2 {fastmathFlags = #llvm.fastmath} : f64 + %6 = llvm.fmul %5, %3 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %6 : f64 + } + llvm.func @rsqrt_squared(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.intr.sqrt(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fmul %2, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %3 : f64 + } + llvm.func @rsqrt_x_reassociate_extra_use(%arg0: f64, %arg1: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.intr.sqrt(%arg0) : (f64) -> f64 + %2 = llvm.fdiv %0, %1 : f64 + %3 = llvm.fmul %2, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.store %2, %arg1 {alignment = 8 : i64} : f64, !llvm.ptr + llvm.return %3 : f64 + } + llvm.func @x_add_y_rsqrt_reassociate_extra_use(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: !llvm.ptr) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<1.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fadd %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %2 = llvm.intr.sqrt(%1) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> vector<2xf32> + %3 = llvm.fdiv %0, %2 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %4 = llvm.fmul %1, %3 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.store %3, %arg2 {alignment = 8 : i64} : vector<2xf32>, !llvm.ptr + llvm.return %4 : vector<2xf32> + } + llvm.func @sqrt_divisor_squared(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.sqrt(%arg0) : (f64) -> f64 + %1 = llvm.fdiv %arg1, %0 : f64 + %2 = llvm.fmul %1, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_dividend_squared(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.intr.sqrt(%arg0) : (vector<2xf32>) -> vector<2xf32> + %1 = llvm.fdiv %0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %2 = llvm.fmul %1, %1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @sqrt_divisor_squared_extra_use(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.sqrt(%arg0) : (f64) -> f64 + %1 = llvm.fdiv %arg1, %0 : f64 + llvm.call @use(%1) : (f64) -> () + %2 = llvm.fmul %1, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_dividend_squared_extra_use(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.sqrt(%arg0) : (f64) -> f64 + llvm.call @use(%0) : (f64) -> () + %1 = llvm.fdiv %0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fmul %1, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @sqrt_divisor_not_enough_FMF(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.sqrt(%arg0) : (f64) -> f64 + %1 = llvm.fdiv %arg1, %0 : f64 + %2 = llvm.fmul %1, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @rsqrt_squared_extra_use(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.intr.sqrt(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%2) : (f64) -> () + %3 = llvm.fmul %2, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %3 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/fmul.ll.mlir b/test/LLVMDialect/InstCombine/fmul.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/fneg-as-int.ll.mlir b/test/LLVMDialect/InstCombine/fneg-as-int.ll.mlir new file mode 100644 index 000000000..1d9fdc28c --- /dev/null +++ b/test/LLVMDialect/InstCombine/fneg-as-int.ll.mlir @@ -0,0 +1,161 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fneg_as_int_f32_castback_noimplicitfloat(%arg0: f32) -> f32 attributes {passthrough = ["noimplicitfloat"]} { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @fneg_as_int_v2f32_noimplicitfloat(%arg0: vector<2xf32>) -> vector<2xi32> attributes {passthrough = ["noimplicitfloat"]} { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %1 = llvm.bitcast %arg0 : vector<2xf32> to vector<2xi32> + %2 = llvm.xor %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @fneg_as_int_f32_castback(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @not_fneg_as_int_f32_castback_wrongconst(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-2147483647 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @fneg_as_int_f32_castback_multi_use(%arg0: f32, %arg1: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.xor %1, %0 : i32 + llvm.store %2, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @fneg_as_int_f64(%arg0: f64) -> i64 { + %0 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %1 = llvm.bitcast %arg0 : f64 to i64 + %2 = llvm.xor %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @fneg_as_int_v2f64(%arg0: vector<2xf64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-9223372036854775808> : vector<2xi64>) : vector<2xi64> + %1 = llvm.bitcast %arg0 : vector<2xf64> to vector<2xi64> + %2 = llvm.xor %1, %0 : vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @fneg_as_int_f64_swap(%arg0: f64) -> i64 { + %0 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %1 = llvm.bitcast %arg0 : f64 to i64 + %2 = llvm.xor %0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @fneg_as_int_f32(%arg0: f32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.xor %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @fneg_as_int_v2f32(%arg0: vector<2xf32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %1 = llvm.bitcast %arg0 : vector<2xf32> to vector<2xi32> + %2 = llvm.xor %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @not_fneg_as_int_v2f32_nonsplat(%arg0: vector<2xf32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[-2147483648, -2147483647]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.bitcast %arg0 : vector<2xf32> to vector<2xi32> + %2 = llvm.xor %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @fneg_as_int_v3f32_poison(%arg0: vector<3xf32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.bitcast %arg0 : vector<3xf32> to vector<3xi32> + %10 = llvm.xor %9, %8 : vector<3xi32> + llvm.return %10 : vector<3xi32> + } + llvm.func @fneg_as_int_f64_not_bitcast(%arg0: f64) -> i64 { + %0 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %1 = llvm.fptoui %arg0 : f64 to i64 + %2 = llvm.xor %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @not_fneg_as_int_f32_bitcast_from_v2f16(%arg0: vector<2xf16>) -> f32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.bitcast %arg0 : vector<2xf16> to i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @not_fneg_as_int_f32_bitcast_from_v2i16(%arg0: vector<2xi16>) -> f32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.bitcast %arg0 : vector<2xi16> to i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @fneg_as_int_fp128_f64_mask(%arg0: f128) -> i128 { + %0 = llvm.mlir.constant(-9223372036854775808 : i128) : i128 + %1 = llvm.bitcast %arg0 : f128 to i128 + %2 = llvm.xor %1, %0 : i128 + llvm.return %2 : i128 + } + llvm.func @fneg_as_int_fp128_f128_mask(%arg0: f128) -> i128 { + %0 = llvm.mlir.constant(-170141183460469231731687303715884105728 : i128) : i128 + %1 = llvm.bitcast %arg0 : f128 to i128 + %2 = llvm.xor %1, %0 : i128 + llvm.return %2 : i128 + } + llvm.func @fneg_as_int_f16(%arg0: f16) -> i16 { + %0 = llvm.mlir.constant(-32768 : i16) : i16 + %1 = llvm.bitcast %arg0 : f16 to i16 + %2 = llvm.xor %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @fneg_as_int_v2f16(%arg0: vector<2xf16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<-32768> : vector<2xi16>) : vector<2xi16> + %1 = llvm.bitcast %arg0 : vector<2xf16> to vector<2xi16> + %2 = llvm.xor %1, %0 : vector<2xi16> + llvm.return %2 : vector<2xi16> + } + llvm.func @fneg_as_int_bf16(%arg0: bf16) -> i16 { + %0 = llvm.mlir.constant(-32768 : i16) : i16 + %1 = llvm.bitcast %arg0 : bf16 to i16 + %2 = llvm.xor %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @fneg_as_int_v2bf16(%arg0: vector<2xbf16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<-32768> : vector<2xi16>) : vector<2xi16> + %1 = llvm.bitcast %arg0 : vector<2xbf16> to vector<2xi16> + %2 = llvm.xor %1, %0 : vector<2xi16> + llvm.return %2 : vector<2xi16> + } + llvm.func @fneg_as_int_x86_fp80_f64_mask(%arg0: f80) -> i80 { + %0 = llvm.mlir.constant(-604462909807314587353088 : i80) : i80 + %1 = llvm.bitcast %arg0 : f80 to i80 + %2 = llvm.xor %1, %0 : i80 + llvm.return %2 : i80 + } + llvm.func @fneg_as_int_ppc_fp128_f64_mask(%arg0: !llvm.ppc_fp128) -> i128 { + %0 = llvm.mlir.constant(-9223372036854775808 : i128) : i128 + %1 = llvm.bitcast %arg0 : !llvm.ppc_fp128 to i128 + %2 = llvm.xor %1, %0 : i128 + llvm.return %2 : i128 + } + llvm.func @fneg_as_int_ppc_fp128_f128_mask(%arg0: !llvm.ppc_fp128) -> i128 { + %0 = llvm.mlir.constant(-170141183460469231731687303715884105728 : i128) : i128 + %1 = llvm.bitcast %arg0 : !llvm.ppc_fp128 to i128 + %2 = llvm.xor %1, %0 : i128 + llvm.return %2 : i128 + } +} diff --git a/test/LLVMDialect/InstCombine/fneg-fabs-as-int.ll.mlir b/test/LLVMDialect/InstCombine/fneg-fabs-as-int.ll.mlir new file mode 100644 index 000000000..196a7cd00 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fneg-fabs-as-int.ll.mlir @@ -0,0 +1,169 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fneg_fabs_as_int_f32_noimplicitfloat(%arg0: f32) -> i32 attributes {passthrough = ["noimplicitfloat"]} { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.or %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @fneg_fabs_as_int_v2f32_noimplicitfloat(%arg0: vector<2xf32>) -> vector<2xi32> attributes {passthrough = ["noimplicitfloat"]} { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %1 = llvm.bitcast %arg0 : vector<2xf32> to vector<2xi32> + %2 = llvm.or %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @fneg_fabs_fabs_as_int_f32_and_or(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.bitcast %arg0 : f32 to i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.or %3, %1 : i32 + %5 = llvm.bitcast %4 : i32 to f32 + llvm.return %5 : f32 + } + llvm.func @fneg_fabs_as_int_f32_castback(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.or %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @not_fneg_fabs_as_int_f32_castback_wrongconst(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-2147483647 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.or %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @fneg_fabs_as_int_f32_castback_multi_use(%arg0: f32, %arg1: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.or %1, %0 : i32 + llvm.store %2, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @fneg_fabs_as_int_f64(%arg0: f64) -> i64 { + %0 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %1 = llvm.bitcast %arg0 : f64 to i64 + %2 = llvm.or %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @fneg_fabs_as_int_v2f64(%arg0: vector<2xf64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-9223372036854775808> : vector<2xi64>) : vector<2xi64> + %1 = llvm.bitcast %arg0 : vector<2xf64> to vector<2xi64> + %2 = llvm.or %1, %0 : vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @fneg_fabs_as_int_f64_swap(%arg0: f64) -> i64 { + %0 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %1 = llvm.bitcast %arg0 : f64 to i64 + %2 = llvm.or %0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @fneg_fabs_as_int_f32(%arg0: f32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.or %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @fneg_fabs_as_int_v2f32(%arg0: vector<2xf32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %1 = llvm.bitcast %arg0 : vector<2xf32> to vector<2xi32> + %2 = llvm.or %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @not_fneg_fabs_as_int_v2f32_nonsplat(%arg0: vector<2xf32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[-2147483648, -2147483647]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.bitcast %arg0 : vector<2xf32> to vector<2xi32> + %2 = llvm.or %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @fneg_fabs_as_int_v3f32_poison(%arg0: vector<3xf32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.bitcast %arg0 : vector<3xf32> to vector<3xi32> + %10 = llvm.or %9, %8 : vector<3xi32> + llvm.return %10 : vector<3xi32> + } + llvm.func @fneg_fabs_as_int_f64_not_bitcast(%arg0: f64) -> i64 { + %0 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %1 = llvm.fptoui %arg0 : f64 to i64 + %2 = llvm.or %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @not_fneg_fabs_as_int_f32_bitcast_from_v2f16(%arg0: vector<2xf16>) -> f32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.bitcast %arg0 : vector<2xf16> to i32 + %2 = llvm.or %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @not_fneg_fabs_as_int_f32_bitcast_from_v2i16(%arg0: vector<2xi16>) -> f32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.bitcast %arg0 : vector<2xi16> to i32 + %2 = llvm.or %1, %0 : i32 + %3 = llvm.bitcast %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @fneg_fabs_as_int_fp128_f64_mask(%arg0: f128) -> i128 { + %0 = llvm.mlir.constant(-9223372036854775808 : i128) : i128 + %1 = llvm.bitcast %arg0 : f128 to i128 + %2 = llvm.or %1, %0 : i128 + llvm.return %2 : i128 + } + llvm.func @fneg_fabs_as_int_fp128_f128_mask(%arg0: f128) -> i128 { + %0 = llvm.mlir.constant(-170141183460469231731687303715884105728 : i128) : i128 + %1 = llvm.bitcast %arg0 : f128 to i128 + %2 = llvm.or %1, %0 : i128 + llvm.return %2 : i128 + } + llvm.func @fneg_fabs_as_int_f16(%arg0: f16) -> i16 { + %0 = llvm.mlir.constant(-32768 : i16) : i16 + %1 = llvm.bitcast %arg0 : f16 to i16 + %2 = llvm.or %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @fneg_fabs_as_int_v2f16(%arg0: vector<2xf16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<-32768> : vector<2xi16>) : vector<2xi16> + %1 = llvm.bitcast %arg0 : vector<2xf16> to vector<2xi16> + %2 = llvm.or %1, %0 : vector<2xi16> + llvm.return %2 : vector<2xi16> + } + llvm.func @fneg_fabs_as_int_bf16(%arg0: bf16) -> i16 { + %0 = llvm.mlir.constant(-32768 : i16) : i16 + %1 = llvm.bitcast %arg0 : bf16 to i16 + %2 = llvm.or %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @fneg_fabs_as_int_v2bf16(%arg0: vector<2xbf16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<-32768> : vector<2xi16>) : vector<2xi16> + %1 = llvm.bitcast %arg0 : vector<2xbf16> to vector<2xi16> + %2 = llvm.or %1, %0 : vector<2xi16> + llvm.return %2 : vector<2xi16> + } + llvm.func @fneg_fabs_as_int_x86_fp80_f64_mask(%arg0: f80) -> i80 { + %0 = llvm.mlir.constant(-604462909807314587353088 : i80) : i80 + %1 = llvm.bitcast %arg0 : f80 to i80 + %2 = llvm.or %1, %0 : i80 + llvm.return %2 : i80 + } + llvm.func @fneg_fabs_as_int_ppc_fp128_f64_mask(%arg0: !llvm.ppc_fp128) -> i128 { + %0 = llvm.mlir.constant(-9223372036854775808 : i128) : i128 + %1 = llvm.bitcast %arg0 : !llvm.ppc_fp128 to i128 + %2 = llvm.or %1, %0 : i128 + llvm.return %2 : i128 + } + llvm.func @fneg_fabs_as_int_ppc_fp128_f128_mask(%arg0: !llvm.ppc_fp128) -> i128 { + %0 = llvm.mlir.constant(-170141183460469231731687303715884105728 : i128) : i128 + %1 = llvm.bitcast %arg0 : !llvm.ppc_fp128 to i128 + %2 = llvm.or %1, %0 : i128 + llvm.return %2 : i128 + } +} diff --git a/test/LLVMDialect/InstCombine/fneg-fabs.ll.mlir b/test/LLVMDialect/InstCombine/fneg-fabs.ll.mlir new file mode 100644 index 000000000..939b2c505 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fneg-fabs.ll.mlir @@ -0,0 +1,177 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @select_noFMF_nfabs_lt(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "olt" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %arg0, %2 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nfabs_lt_fmfProp(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "olt" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %arg0, %2 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nnan_nfabs_lt_fmfProp(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "olt" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %arg0, %2 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nfabs_ult(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ult" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %arg0, %2 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nnan_nfabs_ult(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ult" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %arg0, %2 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nfabs_ole(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ole" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %arg0, %2 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nnan_nfabs_ole(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ole" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %arg0, %2 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nfabs_ule(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ule" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %arg0, %2 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nnan_nfabs_ule(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ule" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %arg0, %2 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_noFMF_nfabs_gt(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ogt" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %2, %arg0 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nfabs_gt_fmfProp(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ogt" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nnan_nfabs_gt_fmfProp(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ogt" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nfabs_ogt(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ogt" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nnan_nfabs_ogt(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ogt" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nfabs_ugt(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ugt" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nnan_nfabs_ugt(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ugt" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nfabs_oge(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "oge" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nnan_nfabs_oge(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "oge" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nfabs_uge(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "uge" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_nnan_nfabs_uge(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "uge" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 : f64 + %3 = llvm.select %1, %2, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_noFMF_fsubfabs_le(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ole" %arg0, %0 : f64 + %2 = llvm.fsub %0, %arg0 : f64 + %3 = llvm.select %1, %arg0, %2 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_noFMF_fsubfabs_olt(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "olt" %arg0, %0 : f64 + %2 = llvm.fsub %0, %arg0 : f64 + %3 = llvm.select %1, %arg0, %2 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_noFMF_fsubfabs_ult(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ult" %arg0, %0 : f64 + %2 = llvm.fsub %0, %arg0 : f64 + %3 = llvm.select %1, %arg0, %2 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_fnegfabs_olt(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "olt" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %arg0, %2 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @select_nsz_fnegfabs_ult(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "ult" %arg0, %0 : f64 + %2 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %arg0, %2 : i1, f64 + llvm.return %3 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/fneg.ll.mlir b/test/LLVMDialect/InstCombine/fneg.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/fold-a-or-b-zero.ll.mlir b/test/LLVMDialect/InstCombine/fold-a-or-b-zero.ll.mlir new file mode 100644 index 000000000..133ff9b1d --- /dev/null +++ b/test/LLVMDialect/InstCombine/fold-a-or-b-zero.ll.mlir @@ -0,0 +1,82 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i1) + llvm.func @a_or_b(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.icmp "ne" %arg1, %0 : i32 + %3 = llvm.and %1, %2 : i1 + %4 = llvm.icmp "ne" %arg0, %0 : i32 + %5 = llvm.icmp "eq" %arg1, %0 : i32 + %6 = llvm.and %4, %5 : i1 + %7 = llvm.or %3, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @a_or_b_not_inv(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.icmp "ne" %arg1, %0 : i32 + %4 = llvm.and %2, %3 : i1 + %5 = llvm.icmp "ne" %arg0, %0 : i32 + %6 = llvm.icmp "eq" %arg1, %1 : i32 + %7 = llvm.and %5, %6 : i1 + %8 = llvm.or %4, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @a_or_b_const(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.icmp "eq" %arg0, %arg2 : i32 + %1 = llvm.icmp "ne" %arg1, %arg2 : i32 + %2 = llvm.and %0, %1 : i1 + %3 = llvm.icmp "ne" %arg0, %arg2 : i32 + %4 = llvm.icmp "eq" %arg1, %arg2 : i32 + %5 = llvm.and %3, %4 : i1 + %6 = llvm.or %2, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @a_or_b_const2(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.icmp "eq" %arg0, %arg2 : i32 + %1 = llvm.icmp "ne" %arg1, %arg3 : i32 + %2 = llvm.and %0, %1 : i1 + %3 = llvm.icmp "ne" %arg0, %arg2 : i32 + %4 = llvm.icmp "eq" %arg1, %arg3 : i32 + %5 = llvm.and %3, %4 : i1 + %6 = llvm.or %2, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @a_or_b_nullptr(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %2 = llvm.icmp "eq" %arg1, %0 : !llvm.ptr + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %4 = llvm.icmp "ne" %arg1, %0 : !llvm.ptr + %5 = llvm.and %1, %4 : i1 + %6 = llvm.and %3, %2 : i1 + %7 = llvm.or %5, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @a_or_b_multiple_uses(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.icmp "ne" %arg1, %0 : i32 + %3 = llvm.and %1, %2 : i1 + %4 = llvm.icmp "ne" %arg0, %0 : i32 + %5 = llvm.icmp "eq" %arg1, %0 : i32 + %6 = llvm.and %4, %5 : i1 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.or %3, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @a_or_b_multiple_uses_2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.icmp "ne" %arg1, %0 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.and %1, %2 : i1 + %4 = llvm.icmp "ne" %arg0, %0 : i32 + %5 = llvm.icmp "eq" %arg1, %0 : i32 + %6 = llvm.and %4, %5 : i1 + llvm.call @use(%3) : (i1) -> () + %7 = llvm.or %3, %6 : i1 + llvm.return %7 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/fold-bin-operand.ll.mlir b/test/LLVMDialect/InstCombine/fold-bin-operand.ll.mlir new file mode 100644 index 000000000..5922efb2f --- /dev/null +++ b/test/LLVMDialect/InstCombine/fold-bin-operand.ll.mlir @@ -0,0 +1,74 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "big">>} { + llvm.func @f(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.inttoptr %0 : i32 to !llvm.ptr + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.inttoptr %2 : i32 to !llvm.ptr + %4 = llvm.icmp "eq" %1, %3 : !llvm.ptr + %5 = llvm.and %arg0, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @f_logical(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.inttoptr %0 : i32 to !llvm.ptr + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.inttoptr %2 : i32 to !llvm.ptr + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.icmp "eq" %1, %3 : !llvm.ptr + %6 = llvm.select %arg0, %5, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @g(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.inttoptr %0 : i32 to !llvm.ptr + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.inttoptr %2 : i32 to !llvm.ptr + %4 = llvm.icmp "eq" %1, %3 : !llvm.ptr + %5 = llvm.zext %4 : i1 to i32 + %6 = llvm.add %arg0, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @h(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.select %arg0, %0, %arg1 : i1, i32 + %3 = llvm.add %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @h1(%arg0: i1, %arg1: vector<4xi32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.select %arg0, %0, %arg1 : i1, vector<4xi32> + %2 = llvm.bitcast %1 : vector<4xi32> to vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @h2(%arg0: i1, %arg1: !llvm.vec) -> !llvm.vec { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.vec + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.insertelement %0, %5[%6 : i32] : !llvm.vec + %8 = llvm.mlir.constant(3 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : !llvm.vec + %10 = llvm.select %arg0, %9, %arg1 : i1, !llvm.vec + %11 = llvm.bitcast %10 : !llvm.vec to !llvm.vec + llvm.return %11 : !llvm.vec + } + llvm.func @h3(%arg0: i1, %arg1: !llvm.vec) -> !llvm.vec { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.vec + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.insertelement %0, %5[%6 : i32] : !llvm.vec + %8 = llvm.mlir.constant(3 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : !llvm.vec + %10 = llvm.select %arg0, %9, %arg1 : i1, !llvm.vec + %11 = llvm.bitcast %10 : !llvm.vec to !llvm.vec + llvm.return %11 : !llvm.vec + } +} diff --git a/test/LLVMDialect/InstCombine/fold-calls.ll.mlir b/test/LLVMDialect/InstCombine/fold-calls.ll.mlir index c4bfb2146..c61251a5e 100644 --- a/test/LLVMDialect/InstCombine/fold-calls.ll.mlir +++ b/test/LLVMDialect/InstCombine/fold-calls.ll.mlir @@ -1,15 +1,13 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0x7FF0000000000000 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @sin, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @sin, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sin", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo() -> f64 { + %0 = llvm.mlir.constant(0x7FF0000000000000 : f64) : f64 + %1 = llvm.call @sin(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @bar() -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.call @sin(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sin(f64) -> f64 +} diff --git a/test/LLVMDialect/InstCombine/fold-ctpop-of-not.ll.mlir b/test/LLVMDialect/InstCombine/fold-ctpop-of-not.ll.mlir new file mode 100644 index 000000000..53328e774 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fold-ctpop-of-not.ll.mlir @@ -0,0 +1,143 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use.i8(i8) + llvm.func @fold_sub_c_ctpop(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(12 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.intr.ctpop(%2) : (i8) -> i8 + %4 = llvm.sub %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @fold_sub_var_ctpop_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.intr.ctpop(%1) : (i8) -> i8 + %3 = llvm.sub %arg1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @fold_sub_ctpop_c(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[63, 64]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.xor %arg0, %0 : vector<2xi8> + %3 = llvm.intr.ctpop(%2) : (vector<2xi8>) -> vector<2xi8> + %4 = llvm.sub %3, %1 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @fold_add_ctpop_c(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(63 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.intr.ctpop(%2) : (i8) -> i8 + %4 = llvm.add %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @fold_distjoint_or_ctpop_c(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.intr.ctpop(%2) : (i8) -> i8 + %4 = llvm.or %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @fold_or_ctpop_c_fail(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(65 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.intr.ctpop(%2) : (i8) -> i8 + %4 = llvm.or %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @fold_add_ctpop_var_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.intr.ctpop(%1) : (i8) -> i8 + %3 = llvm.add %2, %arg1 : i8 + llvm.return %3 : i8 + } + llvm.func @fold_icmp_sgt_ctpop_c_i2_fail(%arg0: i2, %arg1: i2) -> i1 { + %0 = llvm.mlir.constant(-1 : i2) : i2 + %1 = llvm.mlir.constant(1 : i2) : i2 + %2 = llvm.xor %arg0, %0 : i2 + %3 = llvm.intr.ctpop(%2) : (i2) -> i2 + %4 = llvm.icmp "sgt" %3, %1 : i2 + llvm.return %4 : i1 + } + llvm.func @fold_cmp_eq_ctpop_c(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.intr.ctpop(%2) : (i8) -> i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @fold_cmp_eq_ctpop_c_multiuse_fail(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.intr.ctpop(%2) : (i8) -> i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.call @use.i8(%3) : (i8) -> () + llvm.return %4 : i1 + } + llvm.func @fold_cmp_ne_ctpop_c(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[44, 3]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.xor %arg0, %0 : vector<2xi8> + %3 = llvm.intr.ctpop(%2) : (vector<2xi8>) -> vector<2xi8> + %4 = llvm.icmp "ne" %3, %1 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @fold_cmp_ne_ctpop_var_fail(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg0, %0 : vector<2xi8> + %2 = llvm.intr.ctpop(%1) : (vector<2xi8>) -> vector<2xi8> + %3 = llvm.icmp "ne" %2, %arg1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @fold_cmp_ult_ctpop_c(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.mlir.constant(5 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.add %arg1, %1 : i8 + %5 = llvm.select %arg2, %3, %4 : i1, i8 + %6 = llvm.intr.ctpop(%5) : (i8) -> i8 + %7 = llvm.icmp "ult" %6, %2 : i8 + llvm.return %7 : i1 + } + llvm.func @fold_cmp_sle_ctpop_c(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.add %arg1, %1 : i8 + %5 = llvm.select %arg2, %3, %4 : i1, i8 + %6 = llvm.intr.ctpop(%5) : (i8) -> i8 + %7 = llvm.icmp "sle" %6, %2 : i8 + llvm.return %7 : i1 + } + llvm.func @fold_cmp_ult_ctpop_c_no_not_inst_save_fail(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.intr.ctpop(%2) : (i8) -> i8 + %4 = llvm.icmp "ult" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @fold_cmp_ugt_ctpop_c(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[8, 6]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.xor %arg0, %0 : vector<2xi8> + %3 = llvm.intr.ctpop(%2) : (vector<2xi8>) -> vector<2xi8> + %4 = llvm.icmp "ugt" %3, %1 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @fold_cmp_ugt_ctpop_c_out_of_range_fail(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[2, 10]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.xor %arg0, %0 : vector<2xi8> + %3 = llvm.intr.ctpop(%2) : (vector<2xi8>) -> vector<2xi8> + %4 = llvm.icmp "ugt" %3, %1 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/fold-ext-eq-c-with-op.ll.mlir b/test/LLVMDialect/InstCombine/fold-ext-eq-c-with-op.ll.mlir new file mode 100644 index 000000000..19425bad8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fold-ext-eq-c-with-op.ll.mlir @@ -0,0 +1,34 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use.i8(i8) + llvm.func @fold_add_zext_eq_0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.zext %1 : i1 to i8 + %3 = llvm.add %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @fold_add_sext_eq_4_6(%arg0: vector<2xi6>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[4, -127]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.zext %arg0 : vector<2xi6> to vector<2xi8> + %2 = llvm.icmp "eq" %1, %0 : vector<2xi8> + %3 = llvm.sext %2 : vector<2xi1> to vector<2xi8> + %4 = llvm.add %3, %1 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @fold_add_zext_eq_0_fail_multiuse_exp(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.zext %1 : i1 to i8 + %3 = llvm.add %arg0, %2 : i8 + llvm.call @use.i8(%2) : (i8) -> () + llvm.return %3 : i8 + } + llvm.func @fold_add_sext_eq_4_fail_wrong_cond(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.icmp "eq" %arg1, %0 : i8 + %2 = llvm.sext %1 : i1 to i8 + %3 = llvm.add %arg0, %2 : i8 + llvm.call @use.i8(%2) : (i8) -> () + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/fold-fops-into-selects.ll.mlir b/test/LLVMDialect/InstCombine/fold-fops-into-selects.ll.mlir new file mode 100644 index 000000000..aec93090c --- /dev/null +++ b/test/LLVMDialect/InstCombine/fold-fops-into-selects.ll.mlir @@ -0,0 +1,51 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i1) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.select %arg0, %0, %1 : i1, f32 + %3 = llvm.fsub %0, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @test2(%arg0: i1, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.select %arg0, %0, %arg1 : i1, f32 + %3 = llvm.fadd %1, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @test3(%arg0: i1, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.select %arg0, %0, %arg1 : i1, f32 + %3 = llvm.fsub %1, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @test4(%arg0: i1, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.select %arg0, %0, %arg1 : i1, f32 + %3 = llvm.fmul %1, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @test5(%arg0: i1, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.select %arg0, %0, %arg1 : i1, f32 + %3 = llvm.fdiv %1, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @test6(%arg0: i1, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.select %arg0, %0, %arg1 : i1, f32 + %3 = llvm.fdiv %2, %1 : f32 + llvm.return %3 : f32 + } + llvm.func @test7(%arg0: i1, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %2 = llvm.select %arg0, %0, %arg1 : i1, f32 + %3 = llvm.fdiv %2, %1 : f32 + llvm.return %3 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/fold-inc-of-add-of-not-x-and-y-to-sub-x-from-y.ll.mlir b/test/LLVMDialect/InstCombine/fold-inc-of-add-of-not-x-and-y-to-sub-x-from-y.ll.mlir new file mode 100644 index 000000000..129bfa17a --- /dev/null +++ b/test/LLVMDialect/InstCombine/fold-inc-of-add-of-not-x-and-y-to-sub-x-from-y.ll.mlir @@ -0,0 +1,159 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.add %2, %arg1 : i32 + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @t1_vec_splat(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %2 = llvm.xor %arg0, %0 : vector<4xi32> + %3 = llvm.add %2, %arg1 : vector<4xi32> + %4 = llvm.add %3, %1 : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @t2_vec_poison0(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %12 = llvm.xor %arg0, %10 : vector<4xi32> + %13 = llvm.add %12, %arg1 : vector<4xi32> + %14 = llvm.add %13, %11 : vector<4xi32> + llvm.return %14 : vector<4xi32> + } + llvm.func @t3_vec_poison1(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %2, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<4xi32> + %12 = llvm.xor %arg0, %0 : vector<4xi32> + %13 = llvm.add %12, %arg1 : vector<4xi32> + %14 = llvm.add %13, %11 : vector<4xi32> + llvm.return %14 : vector<4xi32> + } + llvm.func @t4_vec_poison2(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.mlir.undef : vector<4xi32> + %13 = llvm.mlir.constant(0 : i32) : i32 + %14 = llvm.insertelement %11, %12[%13 : i32] : vector<4xi32> + %15 = llvm.mlir.constant(1 : i32) : i32 + %16 = llvm.insertelement %11, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(2 : i32) : i32 + %18 = llvm.insertelement %1, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(3 : i32) : i32 + %20 = llvm.insertelement %11, %18[%19 : i32] : vector<4xi32> + %21 = llvm.xor %arg0, %10 : vector<4xi32> + %22 = llvm.add %21, %arg1 : vector<4xi32> + %23 = llvm.add %22, %20 : vector<4xi32> + llvm.return %23 : vector<4xi32> + } + llvm.func @use32(i32) + llvm.func @t5(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.add %2, %arg1 : i32 + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @t6(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.add %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @t7(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.add %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @gen32() -> i32 + llvm.func @t8_commutative0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.call @gen32() : () -> i32 + %3 = llvm.xor %arg0, %0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.add %2, %3 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.add %4, %1 : i32 + llvm.return %5 : i32 + } + llvm.func @t9_commutative1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.add %2, %1 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.add %3, %arg1 : i32 + llvm.return %4 : i32 + } + llvm.func @t10_commutative2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.call @gen32() : () -> i32 + %3 = llvm.xor %arg0, %0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.add %3, %1 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.add %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @n11(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.add %2, %arg1 : i32 + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @n12(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.add %2, %arg1 : i32 + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/fold-log2-ceil-idiom.ll.mlir b/test/LLVMDialect/InstCombine/fold-log2-ceil-idiom.ll.mlir new file mode 100644 index 000000000..b33b5944f --- /dev/null +++ b/test/LLVMDialect/InstCombine/fold-log2-ceil-idiom.ll.mlir @@ -0,0 +1,191 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @log2_ceil_idiom(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + %6 = llvm.zext %5 : i1 to i32 + %7 = llvm.add %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @log2_ceil_idiom_trunc(%arg0: i32) -> i5 { + %0 = llvm.mlir.constant(-1 : i5) : i5 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %3 = llvm.trunc %2 : i32 to i5 + %4 = llvm.xor %3, %0 : i5 + %5 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %6 = llvm.icmp "ugt" %5, %1 : i32 + %7 = llvm.zext %6 : i1 to i5 + %8 = llvm.add %4, %7 : i5 + llvm.return %8 : i5 + } + llvm.func @log2_ceil_idiom_zext(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.zext %3 : i32 to i64 + %5 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %6 = llvm.icmp "ugt" %5, %1 : i32 + %7 = llvm.zext %6 : i1 to i64 + %8 = llvm.add %4, %7 : i64 + llvm.return %8 : i64 + } + llvm.func @log2_ceil_idiom_power2_test2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.zext %5 : i1 to i32 + %7 = llvm.add %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @log2_ceil_idiom_commuted(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + %6 = llvm.zext %5 : i1 to i32 + %7 = llvm.add %6, %3 : i32 + llvm.return %7 : i32 + } + llvm.func @log2_ceil_idiom_multiuse1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.icmp "ugt" %4, %1 : i32 + %6 = llvm.zext %5 : i1 to i32 + %7 = llvm.add %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @log2_ceil_idiom_x_may_be_zero(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + %6 = llvm.zext %5 : i1 to i32 + %7 = llvm.add %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @log2_ceil_idiom_trunc_too_short(%arg0: i32) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %3 = llvm.trunc %2 : i32 to i4 + %4 = llvm.xor %3, %0 : i4 + %5 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %6 = llvm.icmp "ugt" %5, %1 : i32 + %7 = llvm.zext %6 : i1 to i4 + %8 = llvm.add %4, %7 : i4 + llvm.return %8 : i4 + } + llvm.func @log2_ceil_idiom_mismatched_operands(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + %6 = llvm.zext %5 : i1 to i32 + %7 = llvm.add %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @log2_ceil_idiom_wrong_constant(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(30 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + %6 = llvm.zext %5 : i1 to i32 + %7 = llvm.add %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @log2_ceil_idiom_not_a_power2_test1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.zext %5 : i1 to i32 + %7 = llvm.add %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @log2_ceil_idiom_not_a_power2_test2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + %6 = llvm.zext %5 : i1 to i32 + %7 = llvm.add %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @log2_ceil_idiom_multiuse2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + %6 = llvm.zext %5 : i1 to i32 + %7 = llvm.add %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @log2_ceil_idiom_multiuse3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %3 = llvm.xor %2, %0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + %6 = llvm.zext %5 : i1 to i32 + %7 = llvm.add %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @log2_ceil_idiom_trunc_multiuse4(%arg0: i32) -> i5 { + %0 = llvm.mlir.constant(-1 : i5) : i5 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %3 = llvm.trunc %2 : i32 to i5 + llvm.call @use5(%3) : (i5) -> () + %4 = llvm.xor %3, %0 : i5 + %5 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %6 = llvm.icmp "ugt" %5, %1 : i32 + %7 = llvm.zext %6 : i1 to i5 + %8 = llvm.add %4, %7 : i5 + llvm.return %8 : i5 + } + llvm.func @log2_ceil_idiom_zext_multiuse5(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.zext %3 : i32 to i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %6 = llvm.icmp "ugt" %5, %1 : i32 + %7 = llvm.zext %6 : i1 to i64 + %8 = llvm.add %4, %7 : i64 + llvm.return %8 : i64 + } + llvm.func @use5(i5) + llvm.func @use32(i32) + llvm.func @use64(i64) +} diff --git a/test/LLVMDialect/InstCombine/fold-minmax-i1.ll.mlir b/test/LLVMDialect/InstCombine/fold-minmax-i1.ll.mlir new file mode 100644 index 000000000..60d726121 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fold-minmax-i1.ll.mlir @@ -0,0 +1,34 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @umin_scalar(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.intr.umin(%arg0, %arg1) : (i1, i1) -> i1 + llvm.return %0 : i1 + } + llvm.func @smin_scalar(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.intr.smin(%arg0, %arg1) : (i1, i1) -> i1 + llvm.return %0 : i1 + } + llvm.func @umax_scalar(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.intr.umax(%arg0, %arg1) : (i1, i1) -> i1 + llvm.return %0 : i1 + } + llvm.func @smax_scalar(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.intr.smax(%arg0, %arg1) : (i1, i1) -> i1 + llvm.return %0 : i1 + } + llvm.func @umin_vector(%arg0: vector<4xi1>, %arg1: vector<4xi1>) -> vector<4xi1> { + %0 = llvm.intr.umin(%arg0, %arg1) : (vector<4xi1>, vector<4xi1>) -> vector<4xi1> + llvm.return %0 : vector<4xi1> + } + llvm.func @smin_vector(%arg0: vector<4xi1>, %arg1: vector<4xi1>) -> vector<4xi1> { + %0 = llvm.intr.smin(%arg0, %arg1) : (vector<4xi1>, vector<4xi1>) -> vector<4xi1> + llvm.return %0 : vector<4xi1> + } + llvm.func @umax_vector(%arg0: vector<4xi1>, %arg1: vector<4xi1>) -> vector<4xi1> { + %0 = llvm.intr.umax(%arg0, %arg1) : (vector<4xi1>, vector<4xi1>) -> vector<4xi1> + llvm.return %0 : vector<4xi1> + } + llvm.func @smax_vector(%arg0: vector<4xi1>, %arg1: vector<4xi1>) -> vector<4xi1> { + %0 = llvm.intr.smax(%arg0, %arg1) : (vector<4xi1>, vector<4xi1>) -> vector<4xi1> + llvm.return %0 : vector<4xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/fold-phi-load-metadata.ll.mlir b/test/LLVMDialect/InstCombine/fold-phi-load-metadata.ll.mlir index 3dcfbd27f..5d69917d0 100644 --- a/test/LLVMDialect/InstCombine/fold-phi-load-metadata.ll.mlir +++ b/test/LLVMDialect/InstCombine/fold-phi-load-metadata.ll.mlir @@ -1,29 +1,40 @@ -"module"() ( { - "llvm.mlir.global"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 5 : i64, sym_name = "g1", type = !llvm.ptr} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>, %arg2: i32, %arg3: !llvm.ptr>, %arg4: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @g1} : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.icmp"(%arg2, %3) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%4)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +#alias_scope_domain = #llvm.alias_scope_domain, description = "some domain"> +#tbaa_root = #llvm.tbaa_root +#alias_scope = #llvm.alias_scope, domain = #alias_scope_domain, description = "scope0"> +#alias_scope1 = #llvm.alias_scope, domain = #alias_scope_domain, description = "scope1"> +#alias_scope2 = #llvm.alias_scope, domain = #alias_scope_domain, description = "scope2"> +#alias_scope3 = #llvm.alias_scope, domain = #alias_scope_domain, description = "scope3"> +#tbaa_type_desc = #llvm.tbaa_type_desc}> +#tbaa_type_desc1 = #llvm.tbaa_type_desc}> +#tbaa_type_desc2 = #llvm.tbaa_type_desc}> +#tbaa_type_desc3 = #llvm.tbaa_type_desc, <#tbaa_type_desc2, 4>}> +#tbaa_type_desc4 = #llvm.tbaa_type_desc, <#tbaa_type_desc1, 4>}> +#tbaa_tag = #llvm.tbaa_tag +#tbaa_tag1 = #llvm.tbaa_tag +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @g1() {addr_space = 0 : i32, alignment = 8 : i64} : !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @phi_load_metadata(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32, %arg3: !llvm.ptr, %arg4: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.mlir.addressof @g1 : !llvm.ptr + %5 = llvm.icmp "eq" %arg2, %0 : i32 + llvm.cond_br %5, ^bb2, ^bb1 ^bb1: // pred: ^bb0 - %5 = "llvm.getelementptr"(%arg1, %2, %1) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - %6 = "llvm.load"(%5) : (!llvm.ptr) -> i32 - %7 = "llvm.load"(%arg3) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%6, %7)[^bb3] : (i32, !llvm.ptr) -> () + %6 = llvm.getelementptr inbounds %arg1[%1, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct.S2", (f32, i32)> + %7 = llvm.load %6 invariant {alias_scopes = [#alias_scope, #alias_scope1], alignment = 4 : i64, noalias_scopes = [#alias_scope2, #alias_scope3], tbaa = [#tbaa_tag]} : !llvm.ptr -> i32 + %8 = llvm.load %arg3 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%7, %8 : i32, !llvm.ptr) ^bb2: // pred: ^bb0 - %8 = "llvm.getelementptr"(%arg0, %2, %3) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - %9 = "llvm.load"(%8) : (!llvm.ptr) -> i32 - %10 = "llvm.load"(%arg4) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%9, %10)[^bb3] : (i32, !llvm.ptr) -> () - ^bb3(%11: i32, %12: !llvm.ptr): // 2 preds: ^bb1, ^bb2 - "llvm.store"(%12, %0) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.return"(%11) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "phi_load_metadata", type = !llvm.func>, ptr>, i32, ptr>, ptr>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %9 = llvm.load %arg0 invariant {alias_scopes = [#alias_scope, #alias_scope2], alignment = 4 : i64, noalias_scopes = [#alias_scope1, #alias_scope3], tbaa = [#tbaa_tag1]} : !llvm.ptr -> i32 + %10 = llvm.load %arg4 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%9, %10 : i32, !llvm.ptr) + ^bb3(%11: i32, %12: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.store %12, %4 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return %11 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/fold-phi.ll.mlir b/test/LLVMDialect/InstCombine/fold-phi.ll.mlir index bc466ebe1..dc06d280f 100644 --- a/test/LLVMDialect/InstCombine/fold-phi.ll.mlir +++ b/test/LLVMDialect/InstCombine/fold-phi.ll.mlir @@ -1,31 +1,28 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.000000e+00 : f32} : () -> f32 - "llvm.br"(%0)[^bb1] : (f32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @no_crash(%arg0: f32, %arg1: i1) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + llvm.br ^bb1(%0 : f32) ^bb1(%1: f32): // 2 preds: ^bb0, ^bb2 - %2 = "llvm.fadd"(%1, %arg0) : (f32, f32) -> f32 - "llvm.cond_br"(%arg1)[^bb2, ^bb3] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %2 = llvm.fadd %1, %arg0 : f32 + llvm.cond_br %arg1, ^bb2, ^bb3 ^bb2: // pred: ^bb1 - "llvm.br"(%2)[^bb1] : (f32) -> () + llvm.br ^bb1(%2 : f32) ^bb3: // pred: ^bb1 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "no_crash", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4294967295 : i64} : () -> i64 - %1 = "llvm.mlir.undef"() : () -> i64 - "llvm.br"(%1)[^bb1] : (i64) -> () + llvm.return %2 : f32 + } + llvm.func @pr21377(%arg0: i32, %arg1: i1) { + %0 = llvm.mlir.poison : i64 + %1 = llvm.mlir.constant(4294967295 : i64) : i64 + llvm.br ^bb1(%0 : i64) ^bb1(%2: i64): // 2 preds: ^bb0, ^bb3 - %3 = "llvm.zext"(%arg0) : (i32) -> i64 - "llvm.cond_br"(%arg1, %1)[^bb3, ^bb2] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i64) -> () + %3 = llvm.zext %arg0 : i32 to i64 + llvm.cond_br %arg1, ^bb3(%0 : i64), ^bb2 ^bb2: // pred: ^bb1 - %4 = "llvm.or"(%2, %3) : (i64, i64) -> i64 - %5 = "llvm.and"(%4, %0) : (i64, i64) -> i64 - "llvm.br"(%5)[^bb3] : (i64) -> () + %4 = llvm.or %2, %3 : i64 + %5 = llvm.and %4, %1 : i64 + llvm.br ^bb3(%5 : i64) ^bb3(%6: i64): // 2 preds: ^bb1, ^bb2 - %7 = "llvm.or"(%6, %3) : (i64, i64) -> i64 - "llvm.br"(%7)[^bb1] : (i64) -> () - }) {linkage = 10 : i64, sym_name = "pr21377", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %7 = llvm.or %6, %3 : i64 + llvm.br ^bb1(%7 : i64) + } +} diff --git a/test/LLVMDialect/InstCombine/fold-select-fmul-if-zero.ll.mlir b/test/LLVMDialect/InstCombine/fold-select-fmul-if-zero.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/fold-signbit-test-power2.ll.mlir b/test/LLVMDialect/InstCombine/fold-signbit-test-power2.ll.mlir new file mode 100644 index 000000000..45923d13c --- /dev/null +++ b/test/LLVMDialect/InstCombine/fold-signbit-test-power2.ll.mlir @@ -0,0 +1,98 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @use_i1(i1) + llvm.func @use_i1_vec(vector<2xi1>) + llvm.func @pow2_or_zero_is_negative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.and %arg0, %2 : i8 + %4 = llvm.icmp "slt" %3, %0 : i8 + %5 = llvm.icmp "ugt" %3, %1 : i8 + llvm.call @use_i1(%5) : (i1) -> () + llvm.return %4 : i1 + } + llvm.func @pow2_or_zero_is_negative_commute(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mul %0, %arg0 : i8 + %3 = llvm.sub %1, %2 : i8 + %4 = llvm.and %3, %2 : i8 + %5 = llvm.icmp "slt" %4, %1 : i8 + llvm.return %5 : i1 + } + llvm.func @pow2_or_zero_is_negative_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %3 = llvm.sub %1, %arg0 : vector<2xi8> + %4 = llvm.and %arg0, %3 : vector<2xi8> + %5 = llvm.icmp "slt" %4, %1 : vector<2xi8> + %6 = llvm.icmp "ugt" %4, %2 : vector<2xi8> + llvm.call @use_i1_vec(%6) : (vector<2xi1>) -> () + llvm.return %5 : vector<2xi1> + } + llvm.func @pow2_or_zero_is_negative_vec_commute(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mul %0, %arg0 : vector<2xi8> + %4 = llvm.sub %2, %3 : vector<2xi8> + %5 = llvm.and %4, %3 : vector<2xi8> + %6 = llvm.icmp "slt" %5, %2 : vector<2xi8> + llvm.return %6 : vector<2xi1> + } + llvm.func @pow2_or_zero_is_not_negative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = llvm.sub %0, %arg0 : i8 + %4 = llvm.and %arg0, %3 : i8 + %5 = llvm.icmp "sgt" %4, %1 : i8 + %6 = llvm.icmp "ult" %4, %2 : i8 + llvm.call @use_i1(%6) : (i1) -> () + llvm.return %5 : i1 + } + llvm.func @pow2_or_zero_is_not_negative_commute(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.mul %0, %arg0 : i8 + %4 = llvm.sub %1, %3 : i8 + %5 = llvm.and %4, %3 : i8 + %6 = llvm.icmp "sgt" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @pow2_or_zero_is_not_negative_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %4 = llvm.sub %1, %arg0 : vector<2xi8> + %5 = llvm.and %arg0, %4 : vector<2xi8> + %6 = llvm.icmp "sgt" %5, %2 : vector<2xi8> + %7 = llvm.icmp "ult" %5, %3 : vector<2xi8> + llvm.call @use_i1_vec(%7) : (vector<2xi1>) -> () + llvm.return %6 : vector<2xi1> + } + llvm.func @pow2_or_zero_is_not_negative_vec_commute(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %4 = llvm.mul %0, %arg0 : vector<2xi8> + %5 = llvm.sub %2, %4 : vector<2xi8> + %6 = llvm.and %5, %4 : vector<2xi8> + %7 = llvm.icmp "sgt" %6, %3 : vector<2xi8> + llvm.return %7 : vector<2xi1> + } + llvm.func @pow2_or_zero_is_negative_extra_use(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.and %arg0, %1 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "slt" %2, %0 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/fold-sqrt-sqrtf.ll.mlir b/test/LLVMDialect/InstCombine/fold-sqrt-sqrtf.ll.mlir index 406069656..fa3d7a965 100644 --- a/test/LLVMDialect/InstCombine/fold-sqrt-sqrtf.ll.mlir +++ b/test/LLVMDialect/InstCombine/fold-sqrt-sqrtf.ll.mlir @@ -1,12 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @sqrt, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sqrt", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: f32) -> f32 attributes {passthrough = ["ssp", ["uwtable", "2"]]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @sqrt(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @sqrt(f64) -> f64 +} diff --git a/test/LLVMDialect/InstCombine/fold-sub-of-not-to-inc-of-add.ll.mlir b/test/LLVMDialect/InstCombine/fold-sub-of-not-to-inc-of-add.ll.mlir new file mode 100644 index 000000000..5664a81d8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fold-sub-of-not-to-inc-of-add.ll.mlir @@ -0,0 +1,64 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0_scalar(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.sub %arg1, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @p0_scalar_not_truly_negatable(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(45 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.xor %arg1, %1 : i8 + %4 = llvm.sub %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @p1_vector_splat(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.xor %arg0, %0 : vector<4xi32> + %2 = llvm.sub %arg1, %1 : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @p2_vector_poison(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.xor %arg0, %10 : vector<4xi32> + %12 = llvm.sub %arg1, %11 : vector<4xi32> + llvm.return %12 : vector<4xi32> + } + llvm.func @use32(i32) + llvm.func @p3_oneuse(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.sub %arg1, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @n4(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.sub %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @n5_is_not_not(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.sub %arg1, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @n5_is_not_not_vec_splat(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<2147483647> : vector<2xi32>) : vector<2xi32> + %1 = llvm.xor %arg0, %0 : vector<2xi32> + %2 = llvm.sub %arg1, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/fold-vector-select.ll.mlir b/test/LLVMDialect/InstCombine/fold-vector-select.ll.mlir new file mode 100644 index 000000000..f726f04b6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fold-vector-select.ll.mlir @@ -0,0 +1,217 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr, %arg8: !llvm.ptr, %arg9: !llvm.ptr, %arg10: !llvm.ptr, %arg11: !llvm.ptr, %arg12: !llvm.ptr, %arg13: !llvm.ptr, %arg14: !llvm.ptr, %arg15: !llvm.ptr, %arg16: !llvm.ptr, %arg17: !llvm.ptr, %arg18: !llvm.ptr, %arg19: !llvm.ptr, %arg20: !llvm.ptr, %arg21: !llvm.ptr, %arg22: !llvm.ptr, %arg23: !llvm.ptr, %arg24: !llvm.ptr, %arg25: !llvm.ptr, %arg26: !llvm.ptr, %arg27: !llvm.ptr, %arg28: !llvm.ptr, %arg29: !llvm.ptr, %arg30: !llvm.ptr, %arg31: !llvm.ptr, %arg32: !llvm.ptr, %arg33: !llvm.ptr, %arg34: !llvm.ptr, %arg35: !llvm.ptr, %arg36: !llvm.ptr, %arg37: !llvm.ptr, %arg38: !llvm.ptr, %arg39: !llvm.ptr, %arg40: !llvm.ptr, %arg41: !llvm.ptr, %arg42: !llvm.ptr, %arg43: !llvm.ptr, %arg44: !llvm.ptr, %arg45: !llvm.ptr, %arg46: !llvm.ptr, %arg47: !llvm.ptr, %arg48: !llvm.ptr, %arg49: !llvm.ptr, %arg50: !llvm.ptr, %arg51: !llvm.ptr, %arg52: !llvm.ptr, %arg53: !llvm.ptr, %arg54: !llvm.ptr, %arg55: !llvm.ptr, %arg56: !llvm.ptr, %arg57: !llvm.ptr, %arg58: !llvm.ptr, %arg59: !llvm.ptr, %arg60: !llvm.ptr, %arg61: !llvm.ptr, %arg62: !llvm.ptr, %arg63: !llvm.ptr) { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %4 = llvm.mlir.constant(dense<[9, 87, 57, 8]> : vector<4xi32>) : vector<4xi32> + %5 = llvm.mlir.constant(true) : i1 + %6 = llvm.mlir.constant(dense<[true, false, false, false]> : vector<4xi1>) : vector<4xi1> + %7 = llvm.mlir.constant(dense<[44, 99, 49, 29]> : vector<4xi32>) : vector<4xi32> + %8 = llvm.mlir.constant(dense<[false, true, false, false]> : vector<4xi1>) : vector<4xi1> + %9 = llvm.mlir.constant(dense<[15, 18, 53, 84]> : vector<4xi32>) : vector<4xi32> + %10 = llvm.mlir.constant(dense<[true, true, false, false]> : vector<4xi1>) : vector<4xi1> + %11 = llvm.mlir.constant(dense<[29, 82, 45, 16]> : vector<4xi32>) : vector<4xi32> + %12 = llvm.mlir.constant(dense<[false, false, true, false]> : vector<4xi1>) : vector<4xi1> + %13 = llvm.mlir.constant(dense<[11, 15, 32, 99]> : vector<4xi32>) : vector<4xi32> + %14 = llvm.mlir.constant(dense<[true, false, true, false]> : vector<4xi1>) : vector<4xi1> + %15 = llvm.mlir.constant(dense<[19, 86, 29, 33]> : vector<4xi32>) : vector<4xi32> + %16 = llvm.mlir.constant(dense<[false, true, true, false]> : vector<4xi1>) : vector<4xi1> + %17 = llvm.mlir.constant(dense<[44, 10, 26, 45]> : vector<4xi32>) : vector<4xi32> + %18 = llvm.mlir.constant(dense<[true, true, true, false]> : vector<4xi1>) : vector<4xi1> + %19 = llvm.mlir.constant(dense<[88, 70, 90, 48]> : vector<4xi32>) : vector<4xi32> + %20 = llvm.mlir.constant(dense<[false, false, false, true]> : vector<4xi1>) : vector<4xi1> + %21 = llvm.mlir.constant(dense<[30, 53, 42, 12]> : vector<4xi32>) : vector<4xi32> + %22 = llvm.mlir.constant(dense<[true, false, false, true]> : vector<4xi1>) : vector<4xi1> + %23 = llvm.mlir.constant(dense<[46, 24, 93, 26]> : vector<4xi32>) : vector<4xi32> + %24 = llvm.mlir.constant(dense<[false, true, false, true]> : vector<4xi1>) : vector<4xi1> + %25 = llvm.mlir.constant(dense<[33, 99, 15, 57]> : vector<4xi32>) : vector<4xi32> + %26 = llvm.mlir.constant(dense<[true, true, false, true]> : vector<4xi1>) : vector<4xi1> + %27 = llvm.mlir.constant(dense<[51, 60, 60, 50]> : vector<4xi32>) : vector<4xi32> + %28 = llvm.mlir.constant(dense<[false, false, true, true]> : vector<4xi1>) : vector<4xi1> + %29 = llvm.mlir.constant(dense<[50, 12, 7, 45]> : vector<4xi32>) : vector<4xi32> + %30 = llvm.mlir.constant(dense<[true, false, true, true]> : vector<4xi1>) : vector<4xi1> + %31 = llvm.mlir.constant(dense<[15, 65, 36, 36]> : vector<4xi32>) : vector<4xi32> + %32 = llvm.mlir.constant(dense<[false, true, true, true]> : vector<4xi1>) : vector<4xi1> + %33 = llvm.mlir.constant(dense<[54, 0, 17, 78]> : vector<4xi32>) : vector<4xi32> + %34 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %35 = llvm.mlir.constant(dense<[56, 13, 64, 48]> : vector<4xi32>) : vector<4xi32> + %36 = llvm.mlir.constant(dense<[52, 69, 88, 11]> : vector<4xi32>) : vector<4xi32> + %37 = llvm.mlir.constant(dense<[5, 87, 68, 14]> : vector<4xi32>) : vector<4xi32> + %38 = llvm.mlir.constant(dense<[47, 17, 66, 63]> : vector<4xi32>) : vector<4xi32> + %39 = llvm.mlir.constant(dense<[64, 25, 73, 81]> : vector<4xi32>) : vector<4xi32> + %40 = llvm.mlir.constant(dense<[51, 41, 61, 63]> : vector<4xi32>) : vector<4xi32> + %41 = llvm.mlir.constant(dense<[39, 59, 17, 0]> : vector<4xi32>) : vector<4xi32> + %42 = llvm.mlir.constant(dense<[91, 99, 97, 29]> : vector<4xi32>) : vector<4xi32> + %43 = llvm.mlir.constant(dense<[89, 45, 89, 10]> : vector<4xi32>) : vector<4xi32> + %44 = llvm.mlir.constant(dense<[25, 70, 21, 27]> : vector<4xi32>) : vector<4xi32> + %45 = llvm.mlir.constant(dense<[40, 12, 27, 88]> : vector<4xi32>) : vector<4xi32> + %46 = llvm.mlir.constant(dense<[36, 35, 90, 23]> : vector<4xi32>) : vector<4xi32> + %47 = llvm.mlir.constant(dense<[83, 3, 64, 82]> : vector<4xi32>) : vector<4xi32> + %48 = llvm.mlir.constant(dense<[15, 72, 2, 54]> : vector<4xi32>) : vector<4xi32> + %49 = llvm.mlir.constant(dense<[32, 47, 100, 84]> : vector<4xi32>) : vector<4xi32> + %50 = llvm.mlir.constant(dense<[92, 57, 82, 1]> : vector<4xi32>) : vector<4xi32> + %51 = llvm.mlir.constant(dense<[42, 14, 22, 89]> : vector<4xi32>) : vector<4xi32> + %52 = llvm.mlir.constant(dense<[33, 10, 67, 66]> : vector<4xi32>) : vector<4xi32> + %53 = llvm.mlir.constant(dense<[42, 91, 47, 40]> : vector<4xi32>) : vector<4xi32> + %54 = llvm.mlir.constant(dense<[8, 13, 48, 0]> : vector<4xi32>) : vector<4xi32> + %55 = llvm.mlir.constant(dense<[84, 66, 87, 84]> : vector<4xi32>) : vector<4xi32> + %56 = llvm.mlir.constant(dense<[85, 96, 1, 94]> : vector<4xi32>) : vector<4xi32> + %57 = llvm.mlir.constant(dense<[54, 57, 7, 92]> : vector<4xi32>) : vector<4xi32> + %58 = llvm.mlir.constant(dense<[55, 21, 92, 68]> : vector<4xi32>) : vector<4xi32> + %59 = llvm.mlir.constant(dense<[51, 61, 62, 39]> : vector<4xi32>) : vector<4xi32> + %60 = llvm.mlir.constant(dense<[42, 18, 77, 74]> : vector<4xi32>) : vector<4xi32> + %61 = llvm.mlir.constant(dense<[82, 33, 30, 7]> : vector<4xi32>) : vector<4xi32> + %62 = llvm.mlir.constant(dense<[80, 92, 61, 84]> : vector<4xi32>) : vector<4xi32> + %63 = llvm.mlir.constant(dense<[43, 89, 92, 6]> : vector<4xi32>) : vector<4xi32> + %64 = llvm.mlir.constant(dense<[49, 14, 62, 62]> : vector<4xi32>) : vector<4xi32> + %65 = llvm.mlir.constant(dense<[35, 33, 92, 59]> : vector<4xi32>) : vector<4xi32> + %66 = llvm.mlir.constant(dense<[3, 97, 49, 18]> : vector<4xi32>) : vector<4xi32> + %67 = llvm.mlir.constant(dense<[56, 64, 19, 75]> : vector<4xi32>) : vector<4xi32> + %68 = llvm.mlir.constant(dense<[91, 57, 0, 1]> : vector<4xi32>) : vector<4xi32> + %69 = llvm.mlir.constant(dense<[43, 63, 64, 11]> : vector<4xi32>) : vector<4xi32> + %70 = llvm.mlir.constant(dense<[41, 65, 18, 11]> : vector<4xi32>) : vector<4xi32> + %71 = llvm.mlir.constant(dense<[86, 26, 31, 3]> : vector<4xi32>) : vector<4xi32> + %72 = llvm.mlir.constant(dense<[31, 46, 32, 68]> : vector<4xi32>) : vector<4xi32> + %73 = llvm.mlir.constant(dense<[100, 59, 62, 6]> : vector<4xi32>) : vector<4xi32> + %74 = llvm.mlir.constant(dense<[76, 67, 87, 7]> : vector<4xi32>) : vector<4xi32> + %75 = llvm.mlir.constant(dense<[63, 48, 97, 24]> : vector<4xi32>) : vector<4xi32> + %76 = llvm.mlir.constant(dense<[83, 89, 19, 4]> : vector<4xi32>) : vector<4xi32> + %77 = llvm.mlir.constant(dense<[21, 2, 40, 21]> : vector<4xi32>) : vector<4xi32> + %78 = llvm.mlir.constant(dense<[45, 76, 81, 100]> : vector<4xi32>) : vector<4xi32> + %79 = llvm.mlir.constant(dense<[65, 26, 100, 46]> : vector<4xi32>) : vector<4xi32> + %80 = llvm.mlir.constant(dense<[16, 75, 31, 17]> : vector<4xi32>) : vector<4xi32> + %81 = llvm.mlir.constant(dense<[37, 66, 86, 65]> : vector<4xi32>) : vector<4xi32> + %82 = llvm.mlir.constant(dense<[13, 25, 43, 59]> : vector<4xi32>) : vector<4xi32> + %83 = llvm.mlir.constant(dense<[82, 78, 60, 52]> : vector<4xi32>) : vector<4xi32> + %84 = llvm.select %1, %3, %4 : vector<4xi1>, vector<4xi32> + %85 = llvm.select %6, %3, %7 : vector<4xi1>, vector<4xi32> + %86 = llvm.select %8, %3, %9 : vector<4xi1>, vector<4xi32> + %87 = llvm.select %10, %3, %11 : vector<4xi1>, vector<4xi32> + %88 = llvm.select %12, %3, %13 : vector<4xi1>, vector<4xi32> + %89 = llvm.select %14, %3, %15 : vector<4xi1>, vector<4xi32> + %90 = llvm.select %16, %3, %17 : vector<4xi1>, vector<4xi32> + %91 = llvm.select %18, %3, %19 : vector<4xi1>, vector<4xi32> + %92 = llvm.select %20, %3, %21 : vector<4xi1>, vector<4xi32> + %93 = llvm.select %22, %3, %23 : vector<4xi1>, vector<4xi32> + %94 = llvm.select %24, %3, %25 : vector<4xi1>, vector<4xi32> + %95 = llvm.select %26, %3, %27 : vector<4xi1>, vector<4xi32> + %96 = llvm.select %28, %3, %29 : vector<4xi1>, vector<4xi32> + %97 = llvm.select %30, %3, %31 : vector<4xi1>, vector<4xi32> + %98 = llvm.select %32, %3, %33 : vector<4xi1>, vector<4xi32> + %99 = llvm.select %34, %3, %35 : vector<4xi1>, vector<4xi32> + %100 = llvm.select %1, %36, %3 : vector<4xi1>, vector<4xi32> + %101 = llvm.select %6, %37, %3 : vector<4xi1>, vector<4xi32> + %102 = llvm.select %8, %38, %3 : vector<4xi1>, vector<4xi32> + %103 = llvm.select %10, %39, %3 : vector<4xi1>, vector<4xi32> + %104 = llvm.select %12, %40, %3 : vector<4xi1>, vector<4xi32> + %105 = llvm.select %14, %41, %3 : vector<4xi1>, vector<4xi32> + %106 = llvm.select %16, %42, %3 : vector<4xi1>, vector<4xi32> + %107 = llvm.select %18, %43, %3 : vector<4xi1>, vector<4xi32> + %108 = llvm.select %20, %44, %3 : vector<4xi1>, vector<4xi32> + %109 = llvm.select %22, %45, %3 : vector<4xi1>, vector<4xi32> + %110 = llvm.select %24, %46, %3 : vector<4xi1>, vector<4xi32> + %111 = llvm.select %26, %47, %3 : vector<4xi1>, vector<4xi32> + %112 = llvm.select %28, %48, %3 : vector<4xi1>, vector<4xi32> + %113 = llvm.select %30, %49, %3 : vector<4xi1>, vector<4xi32> + %114 = llvm.select %32, %50, %3 : vector<4xi1>, vector<4xi32> + %115 = llvm.select %34, %51, %3 : vector<4xi1>, vector<4xi32> + %116 = llvm.select %1, %52, %53 : vector<4xi1>, vector<4xi32> + %117 = llvm.select %6, %54, %55 : vector<4xi1>, vector<4xi32> + %118 = llvm.select %8, %56, %57 : vector<4xi1>, vector<4xi32> + %119 = llvm.select %10, %58, %59 : vector<4xi1>, vector<4xi32> + %120 = llvm.select %12, %60, %61 : vector<4xi1>, vector<4xi32> + %121 = llvm.select %14, %62, %63 : vector<4xi1>, vector<4xi32> + %122 = llvm.select %16, %64, %65 : vector<4xi1>, vector<4xi32> + %123 = llvm.select %18, %66, %67 : vector<4xi1>, vector<4xi32> + %124 = llvm.select %20, %68, %69 : vector<4xi1>, vector<4xi32> + %125 = llvm.select %22, %70, %71 : vector<4xi1>, vector<4xi32> + %126 = llvm.select %24, %72, %73 : vector<4xi1>, vector<4xi32> + %127 = llvm.select %26, %74, %75 : vector<4xi1>, vector<4xi32> + %128 = llvm.select %28, %76, %77 : vector<4xi1>, vector<4xi32> + %129 = llvm.select %30, %78, %79 : vector<4xi1>, vector<4xi32> + %130 = llvm.select %32, %80, %81 : vector<4xi1>, vector<4xi32> + %131 = llvm.select %34, %82, %83 : vector<4xi1>, vector<4xi32> + %132 = llvm.select %1, %3, %3 : vector<4xi1>, vector<4xi32> + %133 = llvm.select %6, %3, %3 : vector<4xi1>, vector<4xi32> + %134 = llvm.select %8, %3, %3 : vector<4xi1>, vector<4xi32> + %135 = llvm.select %10, %3, %3 : vector<4xi1>, vector<4xi32> + %136 = llvm.select %12, %3, %3 : vector<4xi1>, vector<4xi32> + %137 = llvm.select %14, %3, %3 : vector<4xi1>, vector<4xi32> + %138 = llvm.select %16, %3, %3 : vector<4xi1>, vector<4xi32> + %139 = llvm.select %18, %3, %3 : vector<4xi1>, vector<4xi32> + %140 = llvm.select %20, %3, %3 : vector<4xi1>, vector<4xi32> + %141 = llvm.select %22, %3, %3 : vector<4xi1>, vector<4xi32> + %142 = llvm.select %24, %3, %3 : vector<4xi1>, vector<4xi32> + %143 = llvm.select %26, %3, %3 : vector<4xi1>, vector<4xi32> + %144 = llvm.select %28, %3, %3 : vector<4xi1>, vector<4xi32> + %145 = llvm.select %30, %3, %3 : vector<4xi1>, vector<4xi32> + %146 = llvm.select %32, %3, %3 : vector<4xi1>, vector<4xi32> + %147 = llvm.select %34, %3, %3 : vector<4xi1>, vector<4xi32> + llvm.store %84, %arg0 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %85, %arg1 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %86, %arg2 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %87, %arg3 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %88, %arg4 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %89, %arg5 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %90, %arg6 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %91, %arg7 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %92, %arg8 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %93, %arg9 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %94, %arg10 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %95, %arg11 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %96, %arg12 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %97, %arg13 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %98, %arg14 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %99, %arg15 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %100, %arg16 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %101, %arg17 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %102, %arg18 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %103, %arg19 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %104, %arg20 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %105, %arg21 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %106, %arg22 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %107, %arg23 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %108, %arg24 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %109, %arg25 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %110, %arg26 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %111, %arg27 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %112, %arg28 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %113, %arg29 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %114, %arg30 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %115, %arg31 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %116, %arg32 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %117, %arg33 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %118, %arg34 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %119, %arg35 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %120, %arg36 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %121, %arg37 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %122, %arg38 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %123, %arg39 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %124, %arg40 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %125, %arg41 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %126, %arg42 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %127, %arg43 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %128, %arg44 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %129, %arg45 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %130, %arg46 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %131, %arg47 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %132, %arg48 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %133, %arg49 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %134, %arg50 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %135, %arg51 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %136, %arg52 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %137, %arg53 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %138, %arg54 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %139, %arg55 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %140, %arg56 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %141, %arg57 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %142, %arg58 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %143, %arg59 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %144, %arg60 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %145, %arg61 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %146, %arg62 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %147, %arg63 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/fold-vector-zero-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/fold-vector-zero-inseltpoison.ll.mlir new file mode 100644 index 000000000..59f388c3e --- /dev/null +++ b/test/LLVMDialect/InstCombine/fold-vector-zero-inseltpoison.ll.mlir @@ -0,0 +1,41 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(-2222 : i64) : i64 + %2 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %3 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %4 = llvm.mlir.poison : vector<2xi64> + %5 = llvm.mlir.constant(9223372036854775807 : i64) : i64 + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.mlir.constant(16 : i64) : i64 + %10 = llvm.mlir.constant(1 : i64) : i64 + llvm.br ^bb1(%0, %1 : i64, i64) + ^bb1(%11: i64, %12: i64): // 2 preds: ^bb0, ^bb1 + %13 = llvm.add %11, %arg1 : i64 + %14 = llvm.inttoptr %13 : i64 to !llvm.ptr + %15 = llvm.load %14 {alignment = 8 : i64} : !llvm.ptr -> vector<2xf64> + %16 = llvm.bitcast %15 : vector<2xf64> to vector<2xi64> + %17 = llvm.bitcast %3 : vector<2xf64> to vector<2xi64> + %18 = llvm.insertelement %5, %4[%6 : i32] : vector<2xi64> + %19 = llvm.insertelement %7, %4[%6 : i32] : vector<2xi64> + %20 = llvm.insertelement %5, %18[%8 : i32] : vector<2xi64> + %21 = llvm.insertelement %7, %19[%8 : i32] : vector<2xi64> + %22 = llvm.and %16, %20 : vector<2xi64> + %23 = llvm.and %17, %21 : vector<2xi64> + %24 = llvm.or %22, %23 : vector<2xi64> + %25 = llvm.bitcast %24 : vector<2xi64> to vector<2xf64> + %26 = llvm.add %11, %arg0 : i64 + %27 = llvm.inttoptr %26 : i64 to !llvm.ptr + llvm.store %25, %27 {alignment = 8 : i64} : vector<2xf64>, !llvm.ptr + %28 = llvm.add %9, %11 : i64 + %29 = llvm.add %10, %12 : i64 + %30 = llvm.icmp "slt" %29, %0 : i64 + %31 = llvm.zext %30 : i1 to i64 + %32 = llvm.icmp "ne" %31, %0 : i64 + llvm.cond_br %32, ^bb1(%28, %29 : i64, i64), ^bb2 + ^bb2: // pred: ^bb1 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/fold-vector-zero.ll.mlir b/test/LLVMDialect/InstCombine/fold-vector-zero.ll.mlir new file mode 100644 index 000000000..95493a658 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fold-vector-zero.ll.mlir @@ -0,0 +1,41 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(-2222 : i64) : i64 + %2 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %3 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %4 = llvm.mlir.undef : vector<2xi64> + %5 = llvm.mlir.constant(9223372036854775807 : i64) : i64 + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.mlir.constant(16 : i64) : i64 + %10 = llvm.mlir.constant(1 : i64) : i64 + llvm.br ^bb1(%0, %1 : i64, i64) + ^bb1(%11: i64, %12: i64): // 2 preds: ^bb0, ^bb1 + %13 = llvm.add %11, %arg1 : i64 + %14 = llvm.inttoptr %13 : i64 to !llvm.ptr + %15 = llvm.load %14 {alignment = 8 : i64} : !llvm.ptr -> vector<2xf64> + %16 = llvm.bitcast %15 : vector<2xf64> to vector<2xi64> + %17 = llvm.bitcast %3 : vector<2xf64> to vector<2xi64> + %18 = llvm.insertelement %5, %4[%6 : i32] : vector<2xi64> + %19 = llvm.insertelement %7, %4[%6 : i32] : vector<2xi64> + %20 = llvm.insertelement %5, %18[%8 : i32] : vector<2xi64> + %21 = llvm.insertelement %7, %19[%8 : i32] : vector<2xi64> + %22 = llvm.and %16, %20 : vector<2xi64> + %23 = llvm.and %17, %21 : vector<2xi64> + %24 = llvm.or %22, %23 : vector<2xi64> + %25 = llvm.bitcast %24 : vector<2xi64> to vector<2xf64> + %26 = llvm.add %11, %arg0 : i64 + %27 = llvm.inttoptr %26 : i64 to !llvm.ptr + llvm.store %25, %27 {alignment = 8 : i64} : vector<2xf64>, !llvm.ptr + %28 = llvm.add %9, %11 : i64 + %29 = llvm.add %10, %12 : i64 + %30 = llvm.icmp "slt" %29, %0 : i64 + %31 = llvm.zext %30 : i1 to i64 + %32 = llvm.icmp "ne" %31, %0 : i64 + llvm.cond_br %32, ^bb1(%28, %29 : i64, i64), ^bb2 + ^bb2: // pred: ^bb1 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/force-opaque-ptr.ll.mlir b/test/LLVMDialect/InstCombine/force-opaque-ptr.ll.mlir new file mode 100644 index 000000000..828b5026c --- /dev/null +++ b/test/LLVMDialect/InstCombine/force-opaque-ptr.ll.mlir @@ -0,0 +1,36 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g(dense<0> : tensor<16xi16>) {addr_space = 0 : i32} : !llvm.array<16 x i16> + llvm.func @gep_constexpr_gv_1() -> !llvm.ptr { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(0 : i16) : i16 + %3 = llvm.mlir.constant(dense<0> : tensor<16xi16>) : !llvm.array<16 x i16> + %4 = llvm.mlir.addressof @g : !llvm.ptr + %5 = llvm.getelementptr inbounds %4[%1, %0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<16 x i16> + llvm.return %5 : !llvm.ptr + } + llvm.func @gep_constexpr_gv_2() -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.mlir.constant(dense<0> : tensor<16xi16>) : !llvm.array<16 x i16> + %5 = llvm.mlir.addressof @g : !llvm.ptr + %6 = llvm.getelementptr inbounds %5[%2, %1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<16 x i16> + %7 = llvm.getelementptr %6[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %7 : !llvm.ptr + } + llvm.func @gep_constexpr_inttoptr() -> !llvm.ptr { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.mlir.constant(dense<0> : tensor<16xi16>) : !llvm.array<16 x i16> + %5 = llvm.mlir.addressof @g : !llvm.ptr + %6 = llvm.ptrtoint %5 : !llvm.ptr to i64 + %7 = llvm.mul %6, %2 : i64 + %8 = llvm.inttoptr %7 : i64 to !llvm.ptr + %9 = llvm.getelementptr %8[%1, %0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<16 x i16> + llvm.return %9 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/fortify-folding.ll.mlir b/test/LLVMDialect/InstCombine/fortify-folding.ll.mlir new file mode 100644 index 000000000..4214cc129 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fortify-folding.ll.mlir @@ -0,0 +1,339 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @a(dense<0> : tensor<60xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<60 x i8> + llvm.mlir.global common @b(dense<0> : tensor<60xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<60 x i8> + llvm.mlir.global private constant @".str"("abcdefghijk\00") {addr_space = 0 : i32, dso_local} + llvm.func @test_memccpy() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(60 : i64) : i64 + %6 = llvm.mlir.constant(-1 : i64) : i64 + %7 = llvm.call @__memccpy_chk(%2, %3, %4, %5, %6) : (!llvm.ptr, !llvm.ptr, i32, i64, i64) -> !llvm.ptr + llvm.return %7 : !llvm.ptr + } + llvm.func @test_not_memccpy() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(60 : i64) : i64 + %6 = llvm.mlir.constant(59 : i64) : i64 + %7 = llvm.call @__memccpy_chk(%2, %3, %4, %5, %6) : (!llvm.ptr, !llvm.ptr, i32, i64, i64) -> !llvm.ptr + llvm.return %7 : !llvm.ptr + } + llvm.func @test_memccpy_tail() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(60 : i64) : i64 + %6 = llvm.mlir.constant(-1 : i64) : i64 + %7 = llvm.call @__memccpy_chk(%2, %3, %4, %5, %6) : (!llvm.ptr, !llvm.ptr, i32, i64, i64) -> !llvm.ptr + llvm.return %7 : !llvm.ptr + } + llvm.func @test_mempcpy() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(15 : i64) : i64 + %5 = llvm.mlir.constant(-1 : i64) : i64 + %6 = llvm.call @__mempcpy_chk(%2, %3, %4, %5) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @test_not_mempcpy() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(60 : i64) : i64 + %5 = llvm.mlir.constant(59 : i64) : i64 + %6 = llvm.call @__mempcpy_chk(%2, %3, %4, %5) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @test_mempcpy_tail() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(15 : i64) : i64 + %5 = llvm.mlir.constant(-1 : i64) : i64 + %6 = llvm.call @__mempcpy_chk(%2, %3, %4, %5) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @test_snprintf() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(60 : i64) : i64 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(-1 : i64) : i64 + %6 = llvm.mlir.addressof @b : !llvm.ptr + %7 = llvm.call @__snprintf_chk(%2, %3, %4, %5, %6) vararg(!llvm.func) : (!llvm.ptr, i64, i32, i64, !llvm.ptr) -> i32 + llvm.return %7 : i32 + } + llvm.func @test_not_snprintf() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(60 : i64) : i64 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(59 : i64) : i64 + %6 = llvm.mlir.addressof @b : !llvm.ptr + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.mlir.constant(-1 : i64) : i64 + %9 = llvm.call @__snprintf_chk(%2, %3, %4, %5, %6) vararg(!llvm.func) : (!llvm.ptr, i64, i32, i64, !llvm.ptr) -> i32 + %10 = llvm.call @__snprintf_chk(%2, %3, %7, %8, %6) vararg(!llvm.func) : (!llvm.ptr, i64, i32, i64, !llvm.ptr) -> i32 + llvm.return %9 : i32 + } + llvm.func @test_snprintf_tail() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(60 : i64) : i64 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(-1 : i64) : i64 + %6 = llvm.mlir.addressof @b : !llvm.ptr + %7 = llvm.call @__snprintf_chk(%2, %3, %4, %5, %6) vararg(!llvm.func) : (!llvm.ptr, i64, i32, i64, !llvm.ptr) -> i32 + llvm.return %7 : i32 + } + llvm.func @test_sprintf() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(-1 : i64) : i64 + %5 = llvm.mlir.addressof @b : !llvm.ptr + %6 = llvm.call @__sprintf_chk(%2, %3, %4, %5) vararg(!llvm.func) : (!llvm.ptr, i32, i64, !llvm.ptr) -> i32 + llvm.return %6 : i32 + } + llvm.func @test_not_sprintf() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(59 : i64) : i64 + %5 = llvm.mlir.addressof @b : !llvm.ptr + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.mlir.constant(-1 : i64) : i64 + %8 = llvm.call @__sprintf_chk(%2, %3, %4, %5) vararg(!llvm.func) : (!llvm.ptr, i32, i64, !llvm.ptr) -> i32 + %9 = llvm.call @__sprintf_chk(%2, %6, %7, %5) vararg(!llvm.func) : (!llvm.ptr, i32, i64, !llvm.ptr) -> i32 + llvm.return %8 : i32 + } + llvm.func @test_sprintf_tail() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(-1 : i64) : i64 + %5 = llvm.mlir.addressof @b : !llvm.ptr + %6 = llvm.call @__sprintf_chk(%2, %3, %4, %5) vararg(!llvm.func) : (!llvm.ptr, i32, i64, !llvm.ptr) -> i32 + llvm.return %6 : i32 + } + llvm.func @test_strcat() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(-1 : i64) : i64 + %5 = llvm.call @__strcat_chk(%2, %3, %4) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @test_not_strcat() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.call @__strcat_chk(%2, %3, %4) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @test_strcat_tail() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(-1 : i64) : i64 + %5 = llvm.call @__strcat_chk(%2, %3, %4) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @test_strlcat() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(22 : i64) : i64 + %5 = llvm.mlir.constant(-1 : i64) : i64 + %6 = llvm.call @__strlcat_chk(%2, %3, %4, %5) : (!llvm.ptr, !llvm.ptr, i64, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @test_not_strlcat() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(22 : i64) : i64 + %5 = llvm.mlir.constant(0 : i64) : i64 + %6 = llvm.call @__strlcat_chk(%2, %3, %4, %5) : (!llvm.ptr, !llvm.ptr, i64, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @test_strlcat_tail() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(22 : i64) : i64 + %5 = llvm.mlir.constant(-1 : i64) : i64 + %6 = llvm.call @__strlcat_chk(%2, %3, %4, %5) : (!llvm.ptr, !llvm.ptr, i64, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @test_strncat() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(22 : i64) : i64 + %5 = llvm.mlir.constant(-1 : i64) : i64 + %6 = llvm.call @__strncat_chk(%2, %3, %4, %5) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @test_not_strncat() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(22 : i64) : i64 + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.call @__strncat_chk(%2, %3, %4, %5) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @test_strncat_tail() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(22 : i64) : i64 + %5 = llvm.mlir.constant(-1 : i64) : i64 + %6 = llvm.call @__strncat_chk(%2, %3, %4, %5) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @test_strlcpy() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(22 : i64) : i64 + %5 = llvm.mlir.constant(-1 : i64) : i64 + %6 = llvm.call @__strlcpy_chk(%2, %3, %4, %5) : (!llvm.ptr, !llvm.ptr, i64, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @test_not_strlcpy() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(22 : i64) : i64 + %5 = llvm.mlir.constant(2 : i64) : i64 + %6 = llvm.call @__strlcpy_chk(%2, %3, %4, %5) : (!llvm.ptr, !llvm.ptr, i64, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @test_strlcpy_tail() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(22 : i64) : i64 + %5 = llvm.mlir.constant(-1 : i64) : i64 + %6 = llvm.call @__strlcpy_chk(%2, %3, %4, %5) : (!llvm.ptr, !llvm.ptr, i64, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @test_vsnprintf() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(4 : i64) : i64 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(-1 : i64) : i64 + %6 = llvm.mlir.addressof @b : !llvm.ptr + %7 = llvm.mlir.zero : !llvm.ptr + %8 = llvm.call @__vsnprintf_chk(%2, %3, %4, %5, %6, %7) : (!llvm.ptr, i64, i32, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %8 : i32 + } + llvm.func @test_not_vsnprintf() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(4 : i64) : i64 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.addressof @b : !llvm.ptr + %7 = llvm.mlir.zero : !llvm.ptr + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.mlir.constant(-1 : i64) : i64 + %10 = llvm.call @__vsnprintf_chk(%2, %3, %4, %5, %6, %7) : (!llvm.ptr, i64, i32, i64, !llvm.ptr, !llvm.ptr) -> i32 + %11 = llvm.call @__vsnprintf_chk(%2, %3, %8, %9, %6, %7) : (!llvm.ptr, i64, i32, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %10 : i32 + } + llvm.func @test_vsnprintf_tail() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(4 : i64) : i64 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(-1 : i64) : i64 + %6 = llvm.mlir.addressof @b : !llvm.ptr + %7 = llvm.mlir.zero : !llvm.ptr + %8 = llvm.call @__vsnprintf_chk(%2, %3, %4, %5, %6, %7) : (!llvm.ptr, i64, i32, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %8 : i32 + } + llvm.func @test_vsprintf() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(-1 : i64) : i64 + %5 = llvm.mlir.addressof @b : !llvm.ptr + %6 = llvm.mlir.zero : !llvm.ptr + %7 = llvm.call @__vsprintf_chk(%2, %3, %4, %5, %6) : (!llvm.ptr, i32, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %7 : i32 + } + llvm.func @test_not_vsprintf() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(3 : i64) : i64 + %5 = llvm.mlir.addressof @b : !llvm.ptr + %6 = llvm.mlir.zero : !llvm.ptr + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.mlir.constant(-1 : i64) : i64 + %9 = llvm.call @__vsprintf_chk(%2, %3, %4, %5, %6) : (!llvm.ptr, i32, i64, !llvm.ptr, !llvm.ptr) -> i32 + %10 = llvm.call @__vsprintf_chk(%2, %7, %8, %5, %6) : (!llvm.ptr, i32, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %9 : i32 + } + llvm.func @test_vsprintf_tail() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(-1 : i64) : i64 + %5 = llvm.mlir.addressof @b : !llvm.ptr + %6 = llvm.mlir.zero : !llvm.ptr + %7 = llvm.call @__vsprintf_chk(%2, %3, %4, %5, %6) : (!llvm.ptr, i32, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %7 : i32 + } + llvm.func @__mempcpy_chk(!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.func @__memccpy_chk(!llvm.ptr, !llvm.ptr, i32, i64, i64) -> !llvm.ptr + llvm.func @__snprintf_chk(!llvm.ptr, i64, i32, i64, !llvm.ptr, ...) -> i32 + llvm.func @__sprintf_chk(!llvm.ptr, i32, i64, !llvm.ptr, ...) -> i32 + llvm.func @__strcat_chk(!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.func @__strlcat_chk(!llvm.ptr, !llvm.ptr, i64, i64) -> i64 + llvm.func @__strncat_chk(!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.func @__strlcpy_chk(!llvm.ptr, !llvm.ptr, i64, i64) -> i64 + llvm.func @__vsnprintf_chk(!llvm.ptr, i64, i32, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.func @__vsprintf_chk(!llvm.ptr, i32, i64, !llvm.ptr, !llvm.ptr) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/fp-ret-bitcast.ll.mlir b/test/LLVMDialect/InstCombine/fp-ret-bitcast.ll.mlir index 6b4aa385b..5898ed5db 100644 --- a/test/LLVMDialect/InstCombine/fp-ret-bitcast.ll.mlir +++ b/test/LLVMDialect/InstCombine/fp-ret-bitcast.ll.mlir @@ -1,30 +1,26 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 1 : i64, sym_name = "\01L_OBJC_METH_VAR_NAME_112", type = !llvm.array<15 x i8>, value = "whiteComponent\00"} : () -> () - "llvm.mlir.global"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @"\01L_OBJC_METH_VAR_NAME_112"} : () -> !llvm.ptr> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>) -> !llvm.ptr> - "llvm.return"(%1) : (!llvm.ptr>) -> () - }) {linkage = 1 : i64, sym_name = "\01L_OBJC_SELECTOR_REFERENCES_81", type = !llvm.ptr>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @objc_msgSend_fpret} : () -> !llvm.ptr>)>>, ...)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>)>>, ...)>>) -> !llvm.ptr>)>>, ptr>)>> - %2 = "llvm.mlir.addressof"() {global_name = @"\01L_OBJC_SELECTOR_REFERENCES_81"} : () -> !llvm.ptr>> - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.alloca"(%4) : (i32) -> !llvm.ptr>)>)>>> - %6 = "llvm.alloca"(%4) : (i32) -> !llvm.ptr>)>>> - %7 = "llvm.load"(%5) : (!llvm.ptr>)>)>>>) -> !llvm.ptr>)>)>> - %8 = "llvm.getelementptr"(%7, %3, %3) : (!llvm.ptr>)>)>>, i32, i32) -> !llvm.ptr>)>> - "llvm.store"(%8, %6) : (!llvm.ptr>)>>, !llvm.ptr>)>>>) -> () - %9 = "llvm.load"(%2) : (!llvm.ptr>>) -> !llvm.ptr> - %10 = "llvm.load"(%6) : (!llvm.ptr>)>>>) -> !llvm.ptr>)>> - %11 = "llvm.call"(%1, %10, %9) : (!llvm.ptr>)>>, ptr>)>>, !llvm.ptr>)>>, !llvm.ptr>) -> f32 - "llvm.br"()[^bb1] : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "big">>} { + llvm.mlir.global internal @"\01L_OBJC_METH_VAR_NAME_112"("whiteComponent\00") {addr_space = 0 : i32, dso_local, section = "__TEXT,__cstring,cstring_literals"} + llvm.mlir.global internal @"\01L_OBJC_SELECTOR_REFERENCES_81"() {addr_space = 0 : i32, dso_local, section = "__OBJC,__message_refs,literal_pointers,no_dead_strip"} : !llvm.ptr { + %0 = llvm.mlir.constant("whiteComponent\00") : !llvm.array<15 x i8> + %1 = llvm.mlir.addressof @"\01L_OBJC_METH_VAR_NAME_112" : !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @bork() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant("whiteComponent\00") : !llvm.array<15 x i8> + %2 = llvm.mlir.addressof @"\01L_OBJC_METH_VAR_NAME_112" : !llvm.ptr + %3 = llvm.mlir.addressof @"\01L_OBJC_SELECTOR_REFERENCES_81" : !llvm.ptr + %4 = llvm.mlir.addressof @objc_msgSend_fpret : !llvm.ptr + %5 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + %6 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + %7 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store %7, %6 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + %8 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %9 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %10 = llvm.call %4(%9, %8) : !llvm.ptr, (!llvm.ptr, !llvm.ptr) -> f32 + llvm.br ^bb1 ^bb1: // pred: ^bb0 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bork", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "objc_msgSend_fpret", type = !llvm.func>)>>, ...)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } + llvm.func @objc_msgSend_fpret(!llvm.ptr, ...) +} diff --git a/test/LLVMDialect/InstCombine/fpcast.ll.mlir b/test/LLVMDialect/InstCombine/fpcast.ll.mlir new file mode 100644 index 000000000..c2875c22b --- /dev/null +++ b/test/LLVMDialect/InstCombine/fpcast.ll.mlir @@ -0,0 +1,239 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1() -> i8 { + %0 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %1 = llvm.fptoui %0 : f32 to i8 + llvm.return %1 : i8 + } + llvm.func @test2() -> i8 { + %0 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %1 = llvm.fptosi %0 : f32 to i8 + llvm.return %1 : i8 + } + llvm.func @test3(%arg0: f32) -> f16 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fptrunc %0 : f32 to f16 + llvm.return %1 : f16 + } + llvm.func @fneg_fptrunc(%arg0: f32) -> f16 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fptrunc %1 : f32 to f16 + llvm.return %2 : f16 + } + llvm.func @unary_fneg_fptrunc(%arg0: f32) -> f16 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fptrunc %0 : f32 to f16 + llvm.return %1 : f16 + } + llvm.func @fneg_fptrunc_vec_poison(%arg0: vector<2xf32>) -> vector<2xf16> { + %0 = llvm.mlir.poison : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.mlir.undef : vector<2xf32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf32> + %7 = llvm.fsub %6, %arg0 : vector<2xf32> + %8 = llvm.fptrunc %7 : vector<2xf32> to vector<2xf16> + llvm.return %8 : vector<2xf16> + } + llvm.func @unary_fneg_fptrunc_vec(%arg0: vector<2xf32>) -> vector<2xf16> { + %0 = llvm.fneg %arg0 : vector<2xf32> + %1 = llvm.fptrunc %0 : vector<2xf32> to vector<2xf16> + llvm.return %1 : vector<2xf16> + } + llvm.func @"test4-fast"(%arg0: f32) -> f16 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fptrunc %1 : f32 to f16 + llvm.return %2 : f16 + } + llvm.func @"test4_unary_fneg-fast"(%arg0: f32) -> f16 { + %0 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fptrunc %0 : f32 to f16 + llvm.return %1 : f16 + } + llvm.func @test5(%arg0: f32, %arg1: f32, %arg2: f32) -> f16 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f32 + %2 = llvm.select %1, %arg2, %0 : i1, f32 + %3 = llvm.fptrunc %2 : f32 to f16 + llvm.return %3 : f16 + } + llvm.func @test6(%arg0: vector<1xf64>) -> vector<1xf32> { + %0 = llvm.frem %arg0, %arg0 : vector<1xf64> + %1 = llvm.fptrunc %0 : vector<1xf64> to vector<1xf32> + llvm.return %1 : vector<1xf32> + } + llvm.func @test7(%arg0: f64) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.frem %arg0, %0 : f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test8(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e-01 : f64) : f64 + %1 = llvm.fpext %arg0 : f32 to f64 + %2 = llvm.frem %1, %0 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test_fptrunc_fptrunc(%arg0: f64) -> f16 { + %0 = llvm.fptrunc %arg0 : f64 to f32 + %1 = llvm.fptrunc %0 : f32 to f16 + llvm.return %1 : f16 + } + llvm.func @sint_to_fptrunc(%arg0: i32) -> f16 { + %0 = llvm.sitofp %arg0 : i32 to f32 + %1 = llvm.fptrunc %0 : f32 to f16 + llvm.return %1 : f16 + } + llvm.func @masked_sint_to_fptrunc1(%arg0: i32) -> f16 { + %0 = llvm.mlir.constant(16777215 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.sitofp %1 : i32 to f32 + %3 = llvm.fptrunc %2 : f32 to f16 + llvm.return %3 : f16 + } + llvm.func @masked_sint_to_fptrunc2(%arg0: i32) -> f16 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.sitofp %1 : i32 to f32 + %3 = llvm.fptrunc %2 : f32 to f16 + llvm.return %3 : f16 + } + llvm.func @masked_sint_to_fptrunc3(%arg0: i32) -> f16 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.sitofp %1 : i32 to f32 + %3 = llvm.fptrunc %2 : f32 to f16 + llvm.return %3 : f16 + } + llvm.func @sint_to_fpext(%arg0: i32) -> f64 { + %0 = llvm.sitofp %arg0 : i32 to f32 + %1 = llvm.fpext %0 : f32 to f64 + llvm.return %1 : f64 + } + llvm.func @masked_sint_to_fpext1(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(16777215 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.sitofp %1 : i32 to f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @masked_sint_to_fpext2(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.sitofp %1 : i32 to f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @masked_sint_to_fpext3(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.sitofp %1 : i32 to f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @uint_to_fptrunc(%arg0: i32) -> f16 { + %0 = llvm.uitofp %arg0 : i32 to f32 + %1 = llvm.fptrunc %0 : f32 to f16 + llvm.return %1 : f16 + } + llvm.func @masked_uint_to_fptrunc1(%arg0: i32) -> f16 { + %0 = llvm.mlir.constant(16777215 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.uitofp %1 : i32 to f32 + %3 = llvm.fptrunc %2 : f32 to f16 + llvm.return %3 : f16 + } + llvm.func @masked_uint_to_fptrunc2(%arg0: i32) -> f16 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.uitofp %1 : i32 to f32 + %3 = llvm.fptrunc %2 : f32 to f16 + llvm.return %3 : f16 + } + llvm.func @masked_uint_to_fptrunc3(%arg0: i32) -> f16 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.uitofp %1 : i32 to f32 + %3 = llvm.fptrunc %2 : f32 to f16 + llvm.return %3 : f16 + } + llvm.func @uint_to_fpext(%arg0: i32) -> f64 { + %0 = llvm.uitofp %arg0 : i32 to f32 + %1 = llvm.fpext %0 : f32 to f64 + llvm.return %1 : f64 + } + llvm.func @masked_uint_to_fpext1(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(16777215 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.uitofp %1 : i32 to f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @masked_uint_to_fpext2(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.uitofp %1 : i32 to f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @masked_uint_to_fpext3(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.uitofp %1 : i32 to f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @fptosi_nonnorm(%arg0: f32) -> i32 { + %0 = llvm.fptosi %arg0 : f32 to i32 + llvm.return %0 : i32 + } + llvm.func @fptoui_nonnorm(%arg0: f32) -> i32 { + %0 = llvm.fptoui %arg0 : f32 to i32 + llvm.return %0 : i32 + } + llvm.func @fptosi_nonnnorm(%arg0: f32) -> i32 { + %0 = llvm.fptosi %arg0 : f32 to i32 + llvm.return %0 : i32 + } + llvm.func @fptoui_nonnnorm(%arg0: f32) -> i32 { + %0 = llvm.fptoui %arg0 : f32 to i32 + llvm.return %0 : i32 + } + llvm.func @fptosi_nonnorm_copysign(%arg0: f32) -> i32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.intr.copysign(%0, %arg0) : (f32, f32) -> f32 + %2 = llvm.fptosi %1 : f32 to i32 + llvm.return %2 : i32 + } + llvm.func @fptosi_nonnorm_copysign_vec(%arg0: vector<2xf32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.intr.copysign(%1, %arg0) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + %3 = llvm.fptosi %2 : vector<2xf32> to vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @fptosi_nonnorm_fmul(%arg0: f32) -> i32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %0 : f32 + %2 = llvm.fptosi %1 : f32 to i32 + llvm.return %2 : i32 + } + llvm.func @fptosi_select(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %2 = llvm.select %arg0, %0, %1 : i1, f32 + %3 = llvm.fptosi %2 : f32 to i32 + llvm.return %3 : i32 + } + llvm.func @mul_pos_zero_convert(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.fmul %1, %0 : f32 + %3 = llvm.fptosi %2 : f32 to i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/fpclass-check-idioms.ll.mlir b/test/LLVMDialect/InstCombine/fpclass-check-idioms.ll.mlir new file mode 100644 index 000000000..5674a2a84 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fpclass-check-idioms.ll.mlir @@ -0,0 +1,355 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f32_fcnan_fcinf(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @f32_fcnan_fcinf_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @f32_not_fcnan_fcinf(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @f32_not_fcnan_fcinf_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @f64_fcnan_fcinf(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(9218868437227405312 : i64) : i64 + %1 = llvm.bitcast %arg0 : f64 to i64 + %2 = llvm.and %1, %0 : i64 + %3 = llvm.icmp "eq" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @f64_fcnan_fcinf_strictfp(%arg0: f64) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(9218868437227405312 : i64) : i64 + %1 = llvm.bitcast %arg0 : f64 to i64 + %2 = llvm.and %1, %0 : i64 + %3 = llvm.icmp "eq" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @f32_fcinf(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(2139095040 : i32) : i32 + %2 = llvm.bitcast %arg0 : f32 to i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @f32_fcinf_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(2139095040 : i32) : i32 + %2 = llvm.bitcast %arg0 : f32 to i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @f32_fcposinf(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fcposinf_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fcneginf(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(-8388608 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fcneginf_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(-8388608 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fcposzero(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fcposzero_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fcnegzero(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fcnegzero_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fczero(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.bitcast %arg0 : f32 to i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @f32_fczero_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.bitcast %arg0 : f32 to i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @f32_fcnan(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.mlir.constant(8388607 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.bitcast %arg0 : f32 to i32 + %4 = llvm.and %3, %0 : i32 + %5 = llvm.icmp "eq" %4, %0 : i32 + %6 = llvm.and %3, %1 : i32 + %7 = llvm.icmp "ne" %6, %2 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @f32_fcnan_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.mlir.constant(8388607 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.bitcast %arg0 : f32 to i32 + %4 = llvm.and %3, %0 : i32 + %5 = llvm.icmp "eq" %4, %0 : i32 + %6 = llvm.and %3, %1 : i32 + %7 = llvm.icmp "ne" %6, %2 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @f32_fcnan_fcinf_vec(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<2139095040> : vector<2xi32>) : vector<2xi32> + %1 = llvm.bitcast %arg0 : vector<2xf32> to vector<2xi32> + %2 = llvm.and %1, %0 : vector<2xi32> + %3 = llvm.icmp "eq" %2, %0 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @f32_fcnan_fcinf_vec_strictfp(%arg0: vector<2xf32>) -> vector<2xi1> attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(dense<2139095040> : vector<2xi32>) : vector<2xi32> + %1 = llvm.bitcast %arg0 : vector<2xf32> to vector<2xi32> + %2 = llvm.and %1, %0 : vector<2xi32> + %3 = llvm.icmp "eq" %2, %0 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @f32_fcinf_vec(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<2147483647> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<2139095040> : vector<2xi32>) : vector<2xi32> + %2 = llvm.bitcast %arg0 : vector<2xf32> to vector<2xi32> + %3 = llvm.and %2, %0 : vector<2xi32> + %4 = llvm.icmp "eq" %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @f32_fcinf_vec_strictfp(%arg0: vector<2xf32>) -> vector<2xi1> attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(dense<2147483647> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<2139095040> : vector<2xi32>) : vector<2xi32> + %2 = llvm.bitcast %arg0 : vector<2xf32> to vector<2xi32> + %3 = llvm.and %2, %0 : vector<2xi32> + %4 = llvm.icmp "eq" %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @f32_fcnan_fcinf_wrong_mask1(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2139095041 : i32) : i32 + %1 = llvm.mlir.constant(2139095040 : i32) : i32 + %2 = llvm.bitcast %arg0 : f32 to i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @f32_fcnan_fcinf_wrong_mask1_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2139095041 : i32) : i32 + %1 = llvm.mlir.constant(2139095040 : i32) : i32 + %2 = llvm.bitcast %arg0 : f32 to i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @f32_fcnan_fcinf_wrong_mask2(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.mlir.constant(2130706432 : i32) : i32 + %2 = llvm.bitcast %arg0 : f32 to i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @f32_fcnan_fcinf_wrong_mask2_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.mlir.constant(2130706432 : i32) : i32 + %2 = llvm.bitcast %arg0 : f32 to i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @f64_fcnan_fcinf_wrong_mask3(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(2139095040 : i64) : i64 + %1 = llvm.bitcast %arg0 : f64 to i64 + %2 = llvm.and %1, %0 : i64 + %3 = llvm.icmp "eq" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @f64_fcnan_fcinf_wrong_mask3_strictfp(%arg0: f64) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2139095040 : i64) : i64 + %1 = llvm.bitcast %arg0 : f64 to i64 + %2 = llvm.and %1, %0 : i64 + %3 = llvm.icmp "eq" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @f32_fcnan_fcinf_wrong_pred(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @f32_fcnan_fcinf_wrong_pred_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @f32_fcposzero_wrong_pred(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fcposzero_wrong_pred_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fcnan_fcinf_wrong_type1(%arg0: vector<2xf32>) -> i1 { + %0 = llvm.mlir.constant(2139095040 : i64) : i64 + %1 = llvm.bitcast %arg0 : vector<2xf32> to i64 + %2 = llvm.and %1, %0 : i64 + %3 = llvm.icmp "eq" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @f32_fcnan_fcinf_wrong_type1_strictfp(%arg0: vector<2xf32>) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2139095040 : i64) : i64 + %1 = llvm.bitcast %arg0 : vector<2xf32> to i64 + %2 = llvm.and %1, %0 : i64 + %3 = llvm.icmp "eq" %2, %0 : i64 + llvm.return %3 : i1 + } + llvm.func @f32_fcposinf_wrong_type1(%arg0: vector<2xf32>) -> i1 { + %0 = llvm.mlir.constant(2139095040 : i64) : i64 + %1 = llvm.bitcast %arg0 : vector<2xf32> to i64 + %2 = llvm.icmp "eq" %1, %0 : i64 + llvm.return %2 : i1 + } + llvm.func @f32_fcposinf_wrong_type1_strictfp(%arg0: vector<2xf32>) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2139095040 : i64) : i64 + %1 = llvm.bitcast %arg0 : vector<2xf32> to i64 + %2 = llvm.icmp "eq" %1, %0 : i64 + llvm.return %2 : i1 + } + llvm.func @f32_fcnan_fcinf_wrong_type2(%arg0: f80) -> i1 { + %0 = llvm.mlir.constant(2139095040 : i80) : i80 + %1 = llvm.bitcast %arg0 : f80 to i80 + %2 = llvm.and %1, %0 : i80 + %3 = llvm.icmp "eq" %2, %0 : i80 + llvm.return %3 : i1 + } + llvm.func @f32_fcnan_fcinf_wrong_type2_strictfp(%arg0: f80) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2139095040 : i80) : i80 + %1 = llvm.bitcast %arg0 : f80 to i80 + %2 = llvm.and %1, %0 : i80 + %3 = llvm.icmp "eq" %2, %0 : i80 + llvm.return %3 : i1 + } + llvm.func @f32_fcposzero_wrong_type2(%arg0: f80) -> i1 { + %0 = llvm.mlir.constant(0 : i80) : i80 + %1 = llvm.bitcast %arg0 : f80 to i80 + %2 = llvm.icmp "eq" %1, %0 : i80 + llvm.return %2 : i1 + } + llvm.func @f32_fcposzero_wrong_type2_strictfp(%arg0: f80) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(0 : i80) : i80 + %1 = llvm.bitcast %arg0 : f80 to i80 + %2 = llvm.icmp "eq" %1, %0 : i80 + llvm.return %2 : i1 + } + llvm.func @f32_fcnan_fcinf_noimplicitfloat(%arg0: f32) -> i1 attributes {passthrough = ["noimplicitfloat"]} { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @f32_fcnan_fcinf_noimplicitfloat_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["noimplicitfloat", "strictfp"]} { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @f32_fcposinf_noimplicitfloat(%arg0: f32) -> i1 attributes {passthrough = ["noimplicitfloat"]} { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fcposinf_noimplicitfloat_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["noimplicitfloat", "strictfp"]} { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fcposnan(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2139095041 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fcposnan_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2139095041 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fcposinf_multiuse(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + llvm.call @usei32(%1) : (i32) -> () + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @f32_fcposinf_multiuse_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(2139095040 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + llvm.call @usei32(%1) : (i32) -> () + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @usei32(i32) +} diff --git a/test/LLVMDialect/InstCombine/fpclass-from-dom-cond.ll.mlir b/test/LLVMDialect/InstCombine/fpclass-from-dom-cond.ll.mlir new file mode 100644 index 000000000..a7f824685 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fpclass-from-dom-cond.ll.mlir @@ -0,0 +1,217 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.fcmp "ueq" %arg0, %0 : f32 + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i1 + ^bb2: // pred: ^bb0 + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 783 : i32}> : (f32) -> i1 + llvm.return %3 : i1 + } + llvm.func @test2(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(9.9999999747524271E-7 : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.fcmp "olt" %arg0, %0 : f64 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %2 : i1 + ^bb2: // pred: ^bb0 + %4 = llvm.fcmp "oeq" %arg0, %1 : f64 + llvm.return %4 : i1 + } + llvm.func @test3(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %3 = llvm.fcmp "ogt" %arg0, %0 : f32 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %5 = llvm.fcmp "oeq" %4, %2 : f32 + llvm.return %5 : i1 + ^bb2: // pred: ^bb0 + llvm.return %1 : i1 + } + llvm.func @test4(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(9.99999997E-7 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.fcmp "olt" %arg0, %0 : f32 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %2 : f32 + ^bb2: // pred: ^bb0 + %4 = llvm.fcmp "oeq" %arg0, %1 : f32 + %5 = llvm.fdiv %2, %arg0 : f32 + %6 = llvm.select %4, %2, %5 : i1, f32 + llvm.return %6 : f32 + } + llvm.func @test5(%arg0: f64, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(false) : i1 + llvm.cond_br %arg1, ^bb1, ^bb4(%0 : f64) + ^bb1: // pred: ^bb0 + %3 = llvm.fcmp "uno" %arg0, %1 : f64 + llvm.cond_br %3, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.return %2 : i1 + ^bb3: // pred: ^bb1 + llvm.br ^bb4(%arg0 : f64) + ^bb4(%4: f64): // 2 preds: ^bb0, ^bb3 + %5 = "llvm.intr.is.fpclass"(%4) <{bit = 411 : i32}> : (f64) -> i1 + llvm.return %5 : i1 + } + llvm.func @test6(%arg0: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(9218868437227405312 : i64) : i64 + %3 = llvm.fcmp "ogt" %arg0, %0 : f64 + llvm.cond_br %3, ^bb1, ^bb2(%1 : i1) + ^bb1: // pred: ^bb0 + %4 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %5 = llvm.bitcast %4 : f64 to i64 + %6 = llvm.icmp "eq" %5, %2 : i64 + llvm.br ^bb2(%6 : i1) + ^bb2(%7: i1): // 2 preds: ^bb0, ^bb1 + llvm.return %7 : i1 + } + llvm.func @test7(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 345 : i32}> : (f32) -> i1 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 456 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + ^bb2: // pred: ^bb0 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 456 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test8(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %1 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %2 = llvm.fcmp "oeq" %1, %0 : f32 + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 575 : i32}> : (f32) -> i1 + llvm.return %3 : i1 + ^bb2: // pred: ^bb0 + %4 = "llvm.intr.is.fpclass"(%arg0) <{bit = 575 : i32}> : (f32) -> i1 + llvm.return %4 : i1 + } + llvm.func @test9(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %3 = llvm.fcmp "olt" %arg0, %0 : f32 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.fcmp "oeq" %arg0, %2 : f32 + llvm.return %4 : i1 + ^bb2: // pred: ^bb0 + llvm.return %1 : i1 + } + llvm.func @test10(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(0xFF800000 : f32) : f32 + %3 = llvm.fcmp "olt" %arg0, %0 : f32 + %4 = llvm.fneg %arg0 : f32 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %5 = llvm.fcmp "oeq" %4, %2 : f32 + llvm.return %5 : i1 + ^bb2: // pred: ^bb0 + llvm.return %1 : i1 + } + llvm.func @test11_and(%arg0: f32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(0xFF800000 : f32) : f32 + %3 = llvm.fcmp "olt" %arg0, %0 : f32 + %4 = llvm.fneg %arg0 : f32 + %5 = llvm.and %3, %arg1 : i1 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %6 = llvm.fcmp "oeq" %4, %2 : f32 + llvm.return %6 : i1 + ^bb2: // pred: ^bb0 + llvm.return %1 : i1 + } + llvm.func @test12_or(%arg0: f32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.fcmp "ueq" %arg0, %0 : f32 + %3 = llvm.or %2, %arg1 : i1 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i1 + ^bb2: // pred: ^bb0 + %4 = "llvm.intr.is.fpclass"(%arg0) <{bit = 783 : i32}> : (f32) -> i1 + llvm.return %4 : i1 + } + llvm.func @test1_no_dominating(%arg0: f32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(false) : i1 + llvm.cond_br %arg1, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %2 = llvm.fcmp "ueq" %arg0, %0 : f32 + llvm.cond_br %2, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.return %1 : i1 + ^bb3: // 2 preds: ^bb0, ^bb1 + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 783 : i32}> : (f32) -> i1 + llvm.return %3 : i1 + } + llvm.func @test_signbit_check(%arg0: f32, %arg1: i1) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.fneg %arg0 : f32 + llvm.br ^bb4(%3 : f32) + ^bb2: // pred: ^bb0 + llvm.cond_br %arg1, ^bb3, ^bb4(%arg0 : f32) + ^bb3: // pred: ^bb2 + llvm.br ^bb4(%arg0 : f32) + ^bb4(%4: f32): // 3 preds: ^bb1, ^bb2, ^bb3 + %5 = llvm.intr.fabs(%4) : (f32) -> f32 + llvm.return %5 : f32 + } + llvm.func @test_signbit_check_fail(%arg0: f32, %arg1: i1) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : f32 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.fneg %arg0 : f32 + llvm.br ^bb4(%3 : f32) + ^bb2: // pred: ^bb0 + llvm.cond_br %arg1, ^bb3, ^bb4(%arg0 : f32) + ^bb3: // pred: ^bb2 + %4 = llvm.fneg %arg0 : f32 + llvm.br ^bb4(%4 : f32) + ^bb4(%5: f32): // 3 preds: ^bb1, ^bb2, ^bb3 + %6 = llvm.intr.fabs(%5) : (f32) -> f32 + llvm.return %6 : f32 + } + llvm.func @test_signbit_check_wrong_type(%arg0: vector<2xf32>, %arg1: i1) -> vector<2xf32> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.bitcast %arg0 : vector<2xf32> to i64 + %2 = llvm.icmp "slt" %1, %0 : i64 + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.fneg %arg0 : vector<2xf32> + llvm.br ^bb4(%3 : vector<2xf32>) + ^bb2: // pred: ^bb0 + llvm.cond_br %arg1, ^bb3, ^bb4(%arg0 : vector<2xf32>) + ^bb3: // pred: ^bb2 + llvm.br ^bb4(%arg0 : vector<2xf32>) + ^bb4(%4: vector<2xf32>): // 3 preds: ^bb1, ^bb2, ^bb3 + %5 = llvm.intr.fabs(%4) : (vector<2xf32>) -> vector<2xf32> + llvm.return %5 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/fpextend.ll.mlir b/test/LLVMDialect/InstCombine/fpextend.ll.mlir new file mode 100644 index 000000000..ce55ff921 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fpextend.ll.mlir @@ -0,0 +1,235 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: f32) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fpext %arg0 : f32 to f64 + %2 = llvm.fadd %1, %0 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test2(%arg0: f32, %arg1: f32) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.fmul %0, %1 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test3(%arg0: f32, %arg1: f32) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.fdiv %0, %1 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test4(%arg0: f32) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fpext %arg0 : f32 to f64 + %2 = llvm.fsub %0, %1 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test4_unary_fneg(%arg0: f32) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fneg %0 : f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test5(%arg0: vector<2xf32>) -> vector<2xf32> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %3 = llvm.fadd %2, %1 : vector<2xf64> + %4 = llvm.fptrunc %3 : vector<2xf64> to vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @test6(%arg0: vector<2xf32>) -> vector<2xf32> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<[0.000000e+00, -0.000000e+00]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %2 = llvm.fadd %1, %0 : vector<2xf64> + %3 = llvm.fptrunc %2 : vector<2xf64> to vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @test6_undef(%arg0: vector<2xf32>) -> vector<2xf32> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.undef : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %8 = llvm.fadd %7, %6 : vector<2xf64> + %9 = llvm.fptrunc %8 : vector<2xf64> to vector<2xf32> + llvm.return %9 : vector<2xf32> + } + llvm.func @not_half_shrinkable(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[0.000000e+00, 2.049000e+03]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %2 = llvm.fadd %1, %0 : vector<2xf64> + %3 = llvm.fptrunc %2 : vector<2xf64> to vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @test7(%arg0: f32) -> f16 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fptrunc %0 : f64 to f16 + llvm.return %1 : f16 + } + llvm.func @test8(%arg0: f16) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f16 to f64 + %1 = llvm.fptrunc %0 : f64 to f32 + llvm.return %1 : f32 + } + llvm.func @test9(%arg0: f16, %arg1: f16) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f16 to f64 + %1 = llvm.fpext %arg1 : f16 to f64 + %2 = llvm.fmul %0, %1 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test10(%arg0: f16, %arg1: f32) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f16 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.fmul %0, %1 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test11(%arg0: f16) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fpext %arg0 : f16 to f64 + %2 = llvm.fadd %1, %0 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test12(%arg0: f32, %arg1: f16) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f16 to f64 + %2 = llvm.fadd %0, %1 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test13(%arg0: f16, %arg1: f32) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f16 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.fdiv %0, %1 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test14(%arg0: f32, %arg1: f16) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f16 to f64 + %2 = llvm.fdiv %0, %1 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test15(%arg0: f16, %arg1: f16) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f16 to f64 + %1 = llvm.fpext %arg1 : f16 to f64 + %2 = llvm.fdiv %0, %1 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test16(%arg0: f16, %arg1: f32) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f16 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.frem %0, %1 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test17(%arg0: f32, %arg1: f16) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f16 to f64 + %2 = llvm.frem %0, %1 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @test18(%arg0: f16, %arg1: f16) -> f32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f16 to f64 + %1 = llvm.fpext %arg1 : f16 to f64 + %2 = llvm.frem %0, %1 : f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @ItoFtoF_s25_f32_f64(%arg0: i25) -> f64 { + %0 = llvm.sitofp %arg0 : i25 to f32 + %1 = llvm.fpext %0 : f32 to f64 + llvm.return %1 : f64 + } + llvm.func @ItoFtoF_u24_f32_f128(%arg0: i24) -> f128 { + %0 = llvm.uitofp %arg0 : i24 to f32 + %1 = llvm.fpext %0 : f32 to f128 + llvm.return %1 : f128 + } + llvm.func @ItoFtoF_s26_f32_f64(%arg0: i26) -> f64 { + %0 = llvm.sitofp %arg0 : i26 to f32 + %1 = llvm.fpext %0 : f32 to f64 + llvm.return %1 : f64 + } + llvm.func @ItoFtoF_u25_f32_f64(%arg0: i25) -> f64 { + %0 = llvm.uitofp %arg0 : i25 to f32 + %1 = llvm.fpext %0 : f32 to f64 + llvm.return %1 : f64 + } + llvm.func @FtoItoFtoF_f32_s32_f32_f64(%arg0: f32) -> f64 { + %0 = llvm.fptosi %arg0 : f32 to i32 + %1 = llvm.sitofp %0 : i32 to f32 + %2 = llvm.fpext %1 : f32 to f64 + llvm.return %2 : f64 + } + llvm.func @use_i32(i32) + llvm.func @use_f32(f32) + llvm.func @FtoItoFtoF_f32_u32_f32_f64_extra_uses(%arg0: f32) -> f64 { + %0 = llvm.fptoui %arg0 : f32 to i32 + llvm.call @use_i32(%0) : (i32) -> () + %1 = llvm.uitofp %0 : i32 to f32 + llvm.call @use_f32(%1) : (f32) -> () + %2 = llvm.fpext %1 : f32 to f64 + llvm.return %2 : f64 + } + llvm.func @FtoItoFtoF_v3f16_v3s32_v3f32_v3f64(%arg0: vector<3xf16>) -> vector<3xf64> { + %0 = llvm.fptosi %arg0 : vector<3xf16> to vector<3xi32> + %1 = llvm.sitofp %0 : vector<3xi32> to vector<3xf32> + %2 = llvm.fpext %1 : vector<3xf32> to vector<3xf64> + llvm.return %2 : vector<3xf64> + } + llvm.func @FtoItoFtoF_f32_s64_f64_f128(%arg0: f32) -> f128 { + %0 = llvm.fptosi %arg0 : f32 to i64 + %1 = llvm.sitofp %0 : i64 to f64 + %2 = llvm.fpext %1 : f64 to f128 + llvm.return %2 : f128 + } + llvm.func @FtoItoFtoF_f64_u54_f64_f80(%arg0: f64) -> f80 { + %0 = llvm.fptoui %arg0 : f64 to i54 + %1 = llvm.uitofp %0 : i54 to f64 + %2 = llvm.fpext %1 : f64 to f80 + llvm.return %2 : f80 + } + llvm.func @FtoItoFtoF_f64_u54_f64_p128(%arg0: f64) -> !llvm.ppc_fp128 { + %0 = llvm.fptoui %arg0 : f64 to i54 + %1 = llvm.uitofp %0 : i54 to f64 + %2 = llvm.fpext %1 : f64 to !llvm.ppc_fp128 + llvm.return %2 : !llvm.ppc_fp128 + } + llvm.func @FtoItoFtoF_f32_us32_f32_f64(%arg0: f32) -> f64 { + %0 = llvm.fptoui %arg0 : f32 to i32 + %1 = llvm.sitofp %0 : i32 to f32 + %2 = llvm.fpext %1 : f32 to f64 + llvm.return %2 : f64 + } + llvm.func @FtoItoFtoF_f32_su32_f32_f64(%arg0: f32) -> f64 { + %0 = llvm.fptosi %arg0 : f32 to i32 + %1 = llvm.uitofp %0 : i32 to f32 + %2 = llvm.fpext %1 : f32 to f64 + llvm.return %2 : f64 + } + llvm.func @bf16_to_f32_to_f16(%arg0: bf16) -> f16 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : bf16 to f32 + %1 = llvm.fptrunc %0 : f32 to f16 + llvm.return %1 : f16 + } + llvm.func @bf16_frem(%arg0: bf16) -> bf16 { + %0 = llvm.mlir.constant(6.281250e+00 : f32) : f32 + %1 = llvm.fpext %arg0 : bf16 to f32 + %2 = llvm.frem %1, %0 : f32 + %3 = llvm.fptrunc %2 : f32 to bf16 + llvm.return %3 : bf16 + } +} diff --git a/test/LLVMDialect/InstCombine/fpextend_x86.ll.mlir b/test/LLVMDialect/InstCombine/fpextend_x86.ll.mlir index 76df17bae..6c888a9b1 100644 --- a/test/LLVMDialect/InstCombine/fpextend_x86.ll.mlir +++ b/test/LLVMDialect/InstCombine/fpextend_x86.ll.mlir @@ -1,43 +1,37 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f64) -> f80 - %1 = "llvm.fpext"(%arg1) : (f64) -> f80 - %2 = "llvm.fadd"(%0, %1) : (f80, f80) -> f80 - %3 = "llvm.fptrunc"(%2) : (f80) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f64) -> f80 - %1 = "llvm.fpext"(%arg1) : (f64) -> f80 - %2 = "llvm.fsub"(%0, %1) : (f80, f80) -> f80 - %3 = "llvm.fptrunc"(%2) : (f80) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f64) -> f80 - %1 = "llvm.fpext"(%arg1) : (f64) -> f80 - %2 = "llvm.fmul"(%0, %1) : (f80, f80) -> f80 - %3 = "llvm.fptrunc"(%2) : (f80) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f16): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f64) -> f80 - %1 = "llvm.fpext"(%arg1) : (f16) -> f80 - %2 = "llvm.fmul"(%0, %1) : (f80, f80) -> f80 - %3 = "llvm.fptrunc"(%2) : (f80) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f64) -> f80 - %1 = "llvm.fpext"(%arg1) : (f64) -> f80 - %2 = "llvm.fdiv"(%0, %1) : (f80, f80) -> f80 - %3 = "llvm.fptrunc"(%2) : (f80) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: f64, %arg1: f64) -> f64 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f64 to f80 + %1 = llvm.fpext %arg1 : f64 to f80 + %2 = llvm.fadd %0, %1 : f80 + %3 = llvm.fptrunc %2 : f80 to f64 + llvm.return %3 : f64 + } + llvm.func @test2(%arg0: f64, %arg1: f64) -> f64 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f64 to f80 + %1 = llvm.fpext %arg1 : f64 to f80 + %2 = llvm.fsub %0, %1 : f80 + %3 = llvm.fptrunc %2 : f80 to f64 + llvm.return %3 : f64 + } + llvm.func @test3(%arg0: f64, %arg1: f64) -> f64 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f64 to f80 + %1 = llvm.fpext %arg1 : f64 to f80 + %2 = llvm.fmul %0, %1 : f80 + %3 = llvm.fptrunc %2 : f80 to f64 + llvm.return %3 : f64 + } + llvm.func @test4(%arg0: f64, %arg1: f16) -> f64 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f64 to f80 + %1 = llvm.fpext %arg1 : f16 to f80 + %2 = llvm.fmul %0, %1 : f80 + %3 = llvm.fptrunc %2 : f80 to f64 + llvm.return %3 : f64 + } + llvm.func @test5(%arg0: f64, %arg1: f64) -> f64 attributes {passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f64 to f80 + %1 = llvm.fpext %arg1 : f64 to f80 + %2 = llvm.fdiv %0, %1 : f80 + %3 = llvm.fptrunc %2 : f80 to f64 + llvm.return %3 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/fprintf-1.ll.mlir b/test/LLVMDialect/InstCombine/fprintf-1.ll.mlir index 2fb2ccaa5..3ba4bc39e 100644 --- a/test/LLVMDialect/InstCombine/fprintf-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/fprintf-1.ll.mlir @@ -1,94 +1,68 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello_world", type = !llvm.array<13 x i8>, value = "hello world\0A\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "percent_c", type = !llvm.array<3 x i8>, value = "%c\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "percent_d", type = !llvm.array<3 x i8>, value = "%d\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "percent_f", type = !llvm.array<3 x i8>, value = "%f\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "percent_s", type = !llvm.array<3 x i8>, value = "%s\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "percent_m", type = !llvm.array<3 x i8>, value = "%m\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fprintf", type = !llvm.func>, ptr, ...)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @hello_world} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%arg0, %2) {callee = @fprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>, !llvm.ptr) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_simplify1", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 104 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @percent_c} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %0) {callee = @fprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>, !llvm.ptr, i8) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_simplify2", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @hello_world} : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @percent_s} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.getelementptr"(%0, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %3, %4) {callee = @fprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>, !llvm.ptr, !llvm.ptr) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_simplify3", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 187 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @percent_d} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %0) {callee = @fprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>, !llvm.ptr, i32) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_simplify4", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @hello_world} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%arg0, %2) {callee = @fprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>, !llvm.ptr) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_simplify5", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.870000e+00 : f64} : () -> f64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @percent_f} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %0) {callee = @fprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>, !llvm.ptr, f64) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @percent_f} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%arg0, %2, %arg1) {callee = @fprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>, !llvm.ptr, f64) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify2", type = !llvm.func>, f64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @hello_world} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%arg0, %2) {callee = @fprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>, !llvm.ptr) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify3", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @percent_m} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%arg0, %2) {callee = @fprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>, !llvm.ptr) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify4", type = !llvm.func>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello_world("hello world\0A\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent_c("%c\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent_d("%d\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent_f("%f\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent_s("%s\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent_m("%m\00") {addr_space = 0 : i32} + llvm.func @fprintf(!llvm.ptr, !llvm.ptr, ...) -> i32 + llvm.func @test_simplify1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("hello world\0A\00") : !llvm.array<13 x i8> + %1 = llvm.mlir.addressof @hello_world : !llvm.ptr + %2 = llvm.call @fprintf(%arg0, %1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify2(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%c\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_c : !llvm.ptr + %2 = llvm.mlir.constant(104 : i8) : i8 + %3 = llvm.call @fprintf(%arg0, %1, %2) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, i8) -> i32 + llvm.return + } + llvm.func @test_simplify3(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_s : !llvm.ptr + %2 = llvm.mlir.constant("hello world\0A\00") : !llvm.array<13 x i8> + %3 = llvm.mlir.addressof @hello_world : !llvm.ptr + %4 = llvm.call @fprintf(%arg0, %1, %3) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify4(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%d\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_d : !llvm.ptr + %2 = llvm.mlir.constant(187 : i32) : i32 + %3 = llvm.call @fprintf(%arg0, %1, %2) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return + } + llvm.func @test_simplify5(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("hello world\0A\00") : !llvm.array<13 x i8> + %1 = llvm.mlir.addressof @hello_world : !llvm.ptr + %2 = llvm.call @fprintf(%arg0, %1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_no_simplify1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%f\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_f : !llvm.ptr + %2 = llvm.mlir.constant(1.870000e+00 : f64) : f64 + %3 = llvm.call @fprintf(%arg0, %1, %2) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, f64) -> i32 + llvm.return + } + llvm.func @test_no_simplify2(%arg0: !llvm.ptr, %arg1: f64) { + %0 = llvm.mlir.constant("%f\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_f : !llvm.ptr + %2 = llvm.call @fprintf(%arg0, %1, %arg1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, f64) -> i32 + llvm.return + } + llvm.func @test_no_simplify3(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant("hello world\0A\00") : !llvm.array<13 x i8> + %1 = llvm.mlir.addressof @hello_world : !llvm.ptr + %2 = llvm.call @fprintf(%arg0, %1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %2 : i32 + } + llvm.func @test_no_simplify4(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%m\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_m : !llvm.ptr + %2 = llvm.call @fprintf(%arg0, %1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/fprintf-wrong-sig.ll.mlir b/test/LLVMDialect/InstCombine/fprintf-wrong-sig.ll.mlir new file mode 100644 index 000000000..785abbb78 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fprintf-wrong-sig.ll.mlir @@ -0,0 +1,11 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private constant @".str"("an error: %d\00") {addr_space = 0 : i32, dso_local} + llvm.func @fprintf(!llvm.ptr, ...) -> i32 + llvm.func @test1() -> i32 { + %0 = llvm.mlir.constant("an error: %d\00") : !llvm.array<13 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @fprintf(%1) vararg(!llvm.func) : (!llvm.ptr) -> i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/fptrunc.ll.mlir b/test/LLVMDialect/InstCombine/fptrunc.ll.mlir new file mode 100644 index 000000000..94e944c77 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fptrunc.ll.mlir @@ -0,0 +1,91 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fadd_fpext_op0(%arg0: f32, %arg1: f64) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fadd %0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @fsub_fpext_op1(%arg0: f16, %arg1: f64) -> f16 { + %0 = llvm.fpext %arg0 : f16 to f64 + %1 = llvm.fsub %arg1, %0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fptrunc %1 : f64 to f16 + llvm.return %2 : f16 + } + llvm.func @fdiv_constant_op0(%arg0: vector<2xf64>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[4.210000e+01, -1.000000e-01]> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %2 = llvm.fptrunc %1 : vector<2xf64> to vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fmul_constant_op1(%arg0: vector<2xf32>) -> vector<2xf16> { + %0 = llvm.mlir.constant(dense<[3.40282347E+38, 5.000000e-01]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %2 = llvm.fptrunc %1 : vector<2xf32> to vector<2xf16> + llvm.return %2 : vector<2xf16> + } + llvm.func @fptrunc_select_true_val(%arg0: f32, %arg1: f64, %arg2: i1) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.select %arg2, %arg1, %0 {fastmathFlags = #llvm.fastmath} : i1, f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @fptrunc_select_false_val(%arg0: vector<2xf32>, %arg1: vector<2xf64>, %arg2: vector<2xi1>) -> vector<2xf32> { + %0 = llvm.fpext %arg0 : vector<2xf32> to vector<2xf64> + %1 = llvm.select %arg2, %0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xi1>, vector<2xf64> + %2 = llvm.fptrunc %1 : vector<2xf64> to vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @use(f32) + llvm.func @fptrunc_select_true_val_extra_use(%arg0: f16, %arg1: f32, %arg2: i1) -> f16 { + %0 = llvm.fpext %arg0 : f16 to f32 + llvm.call @use(%0) : (f32) -> () + %1 = llvm.select %arg2, %arg1, %0 {fastmathFlags = #llvm.fastmath} : i1, f32 + %2 = llvm.fptrunc %1 : f32 to f16 + llvm.return %2 : f16 + } + llvm.func @fptrunc_select_true_val_extra_use_2(%arg0: f16, %arg1: f32, %arg2: i1) -> f16 { + %0 = llvm.fpext %arg0 : f16 to f32 + %1 = llvm.select %arg2, %arg1, %0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fptrunc %1 : f32 to f16 + llvm.return %2 : f16 + } + llvm.func @fptrunc_select_true_val_type_mismatch(%arg0: f16, %arg1: f64, %arg2: i1) -> f32 { + %0 = llvm.fpext %arg0 : f16 to f64 + %1 = llvm.select %arg2, %arg1, %0 : i1, f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @fptrunc_select_true_val_type_mismatch_fast(%arg0: f16, %arg1: f64, %arg2: i1) -> f32 { + %0 = llvm.fpext %arg0 : f16 to f64 + %1 = llvm.select %arg2, %arg1, %0 {fastmathFlags = #llvm.fastmath} : i1, f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @ItoFtoF_s54_f64_f32(%arg0: vector<2xi54>) -> vector<2xf32> { + %0 = llvm.sitofp %arg0 : vector<2xi54> to vector<2xf64> + %1 = llvm.fptrunc %0 : vector<2xf64> to vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @ItoFtoF_u24_f32_f16(%arg0: i24) -> f16 { + %0 = llvm.uitofp %arg0 : i24 to f32 + llvm.call @use(%0) : (f32) -> () + %1 = llvm.fptrunc %0 : f32 to f16 + llvm.return %1 : f16 + } + llvm.func @ItoFtoF_s55_f64_f32(%arg0: i55) -> f32 { + %0 = llvm.sitofp %arg0 : i55 to f64 + %1 = llvm.fptrunc %0 : f64 to f32 + llvm.return %1 : f32 + } + llvm.func @ItoFtoF_u25_f32_f16(%arg0: i25) -> f16 { + %0 = llvm.uitofp %arg0 : i25 to f32 + %1 = llvm.fptrunc %0 : f32 to f16 + llvm.return %1 : f16 + } + llvm.func @fptrunc_to_bfloat_bitcast_to_half(%arg0: f32) -> f16 { + %0 = llvm.fptrunc %arg0 : f32 to bf16 + %1 = llvm.bitcast %0 : bf16 to f16 + llvm.return %1 : f16 + } +} diff --git a/test/LLVMDialect/InstCombine/fputs-1.ll.mlir b/test/LLVMDialect/InstCombine/fputs-1.ll.mlir new file mode 100644 index 000000000..a8ec9877c --- /dev/null +++ b/test/LLVMDialect/InstCombine/fputs-1.ll.mlir @@ -0,0 +1,25 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @empty(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external constant @A("A\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hello("hello\0A\00") {addr_space = 0 : i32} + llvm.func @fputs(!llvm.ptr, !llvm.ptr) -> i32 + llvm.func @test_simplify1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @empty : !llvm.ptr + %3 = llvm.call @fputs(%2, %arg0) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify2(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("A\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @A : !llvm.ptr + %2 = llvm.call @fputs(%1, %arg0) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify3(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("hello\0A\00") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.call @fputs(%1, %arg0) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/fputs-opt-size.ll.mlir b/test/LLVMDialect/InstCombine/fputs-opt-size.ll.mlir new file mode 100644 index 000000000..e8d93e66c --- /dev/null +++ b/test/LLVMDialect/InstCombine/fputs-opt-size.ll.mlir @@ -0,0 +1,31 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private unnamed_addr constant @".str"("mylog.txt\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.1"("a\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.2"("Hello world this is a test\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.func local_unnamed_addr @main() -> i32 attributes {passthrough = ["nounwind", "optsize"]} { + %0 = llvm.mlir.constant("mylog.txt\00") : !llvm.array<10 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.constant("a\00") : !llvm.array<2 x i8> + %3 = llvm.mlir.addressof @".str.1" : !llvm.ptr + %4 = llvm.mlir.constant("Hello world this is a test\00") : !llvm.array<27 x i8> + %5 = llvm.mlir.addressof @".str.2" : !llvm.ptr + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.call @fopen(%1, %3) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + %8 = llvm.call @fputs(%5, %7) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %6 : i32 + } + llvm.func local_unnamed_addr @fopen(!llvm.ptr {llvm.nocapture, llvm.readonly}, !llvm.ptr {llvm.nocapture, llvm.readonly}) -> (!llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind", "optsize"]} + llvm.func local_unnamed_addr @fputs(!llvm.ptr {llvm.nocapture, llvm.readonly}, !llvm.ptr {llvm.nocapture}) -> i32 attributes {passthrough = ["nounwind", "optsize"]} + llvm.func local_unnamed_addr @main_pgso() -> i32 attributes {function_entry_count = 0 : i64} { + %0 = llvm.mlir.constant("mylog.txt\00") : !llvm.array<10 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.constant("a\00") : !llvm.array<2 x i8> + %3 = llvm.mlir.addressof @".str.1" : !llvm.ptr + %4 = llvm.mlir.constant("Hello world this is a test\00") : !llvm.array<27 x i8> + %5 = llvm.mlir.addressof @".str.2" : !llvm.ptr + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.call @fopen(%1, %3) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + %8 = llvm.call @fputs(%5, %7) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/free-inversion.ll.mlir b/test/LLVMDialect/InstCombine/free-inversion.ll.mlir new file mode 100644 index 000000000..896b0ba14 --- /dev/null +++ b/test/LLVMDialect/InstCombine/free-inversion.ll.mlir @@ -0,0 +1,438 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use.i8(i8) + llvm.func @use.i1(i1) + llvm.func @xor_1(%arg0: i8, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.xor %arg2, %0 : i8 + %3 = llvm.xor %arg3, %1 : i8 + %4 = llvm.select %arg1, %2, %3 : i1, i8 + %5 = llvm.xor %4, %arg0 : i8 + %6 = llvm.xor %5, %0 : i8 + llvm.return %6 : i8 + } + llvm.func @xor_2(%arg0: i8, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.xor %arg2, %0 : i8 + %3 = llvm.xor %arg3, %1 : i8 + %4 = llvm.select %arg1, %2, %3 : i1, i8 + %5 = llvm.xor %arg0, %4 : i8 + %6 = llvm.xor %5, %0 : i8 + llvm.return %6 : i8 + } + llvm.func @xor_fail(%arg0: i8, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg2, %0 : i8 + %2 = llvm.select %arg1, %1, %arg3 : i1, i8 + %3 = llvm.xor %arg0, %2 : i8 + %4 = llvm.xor %3, %0 : i8 + llvm.return %4 : i8 + } + llvm.func @add_1(%arg0: i8, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.xor %arg2, %0 : i8 + %3 = llvm.xor %arg3, %1 : i8 + %4 = llvm.select %arg1, %2, %3 : i1, i8 + %5 = llvm.add %4, %arg0 : i8 + %6 = llvm.xor %5, %0 : i8 + llvm.return %6 : i8 + } + llvm.func @add_2(%arg0: i8, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.xor %arg2, %0 : i8 + %3 = llvm.xor %arg3, %1 : i8 + %4 = llvm.select %arg1, %2, %3 : i1, i8 + %5 = llvm.add %arg0, %4 : i8 + %6 = llvm.xor %5, %0 : i8 + llvm.return %6 : i8 + } + llvm.func @add_fail(%arg0: i8, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.xor %arg2, %arg0 : i8 + %3 = llvm.xor %arg3, %0 : i8 + %4 = llvm.select %arg1, %2, %3 : i1, i8 + %5 = llvm.add %arg0, %4 : i8 + %6 = llvm.xor %5, %1 : i8 + llvm.return %6 : i8 + } + llvm.func @sub_1(%arg0: i8, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.xor %arg2, %0 : i8 + %3 = llvm.xor %arg3, %1 : i8 + %4 = llvm.select %arg1, %2, %3 : i1, i8 + %5 = llvm.sub %4, %arg0 : i8 + %6 = llvm.xor %5, %0 : i8 + llvm.return %6 : i8 + } + llvm.func @sub_2(%arg0: i8, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.xor %arg2, %0 : i8 + %3 = llvm.xor %arg3, %1 : i8 + %4 = llvm.select %arg1, %2, %3 : i1, i8 + %5 = llvm.sub %arg0, %4 : i8 + %6 = llvm.xor %5, %0 : i8 + llvm.return %6 : i8 + } + llvm.func @sub_3(%arg0: i128, %arg1: i1, %arg2: i128, %arg3: i128) -> i128 { + %0 = llvm.mlir.constant(-1 : i128) : i128 + %1 = llvm.mlir.constant(123 : i128) : i128 + %2 = llvm.xor %arg2, %0 : i128 + %3 = llvm.xor %arg3, %1 : i128 + %4 = llvm.select %arg1, %2, %3 : i1, i128 + %5 = llvm.sub %arg0, %4 : i128 + %6 = llvm.xor %5, %0 : i128 + llvm.return %6 : i128 + } + llvm.func @sub_fail(%arg0: i8, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.xor %arg2, %0 : i8 + %3 = llvm.xor %arg3, %1 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %4 = llvm.select %arg1, %2, %3 : i1, i8 + %5 = llvm.sub %4, %arg0 : i8 + %6 = llvm.xor %5, %0 : i8 + llvm.return %6 : i8 + } + llvm.func @ashr_1(%arg0: i8, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.xor %arg2, %0 : i8 + %3 = llvm.xor %arg3, %1 : i8 + %4 = llvm.select %arg1, %2, %3 : i1, i8 + %5 = llvm.ashr %4, %arg0 : i8 + %6 = llvm.xor %5, %0 : i8 + llvm.return %6 : i8 + } + llvm.func @ashr_2_fail(%arg0: i8, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.xor %arg2, %0 : i8 + %3 = llvm.xor %arg3, %1 : i8 + %4 = llvm.select %arg1, %2, %3 : i1, i8 + %5 = llvm.ashr %arg0, %4 : i8 + %6 = llvm.xor %5, %0 : i8 + llvm.return %6 : i8 + } + llvm.func @select_1(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i1, %arg4: i8, %arg5: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.mlir.constant(45 : i8) : i8 + %3 = llvm.xor %arg4, %0 : i8 + %4 = llvm.xor %arg5, %1 : i8 + %5 = llvm.select %arg3, %3, %4 : i1, i8 + %6 = llvm.xor %arg1, %2 : i8 + %7 = llvm.xor %arg2, %6 : i8 + %8 = llvm.select %arg0, %7, %5 : i1, i8 + %9 = llvm.xor %8, %0 : i8 + llvm.return %9 : i8 + } + llvm.func @select_2(%arg0: i1, %arg1: i8, %arg2: i1, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.mlir.constant(45 : i8) : i8 + %3 = llvm.xor %arg3, %0 : i8 + %4 = llvm.xor %arg4, %1 : i8 + %5 = llvm.select %arg2, %3, %4 : i1, i8 + %6 = llvm.xor %arg1, %2 : i8 + %7 = llvm.select %arg0, %5, %6 : i1, i8 + %8 = llvm.xor %7, %0 : i8 + llvm.return %8 : i8 + } + llvm.func @select_logic_or_fail(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i8) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.xor %arg2, %0 : i1 + %4 = llvm.icmp "eq" %arg3, %1 : i8 + %5 = llvm.select %arg1, %3, %4 : i1, i1 + %6 = llvm.select %arg0, %5, %2 : i1, i1 + %7 = llvm.xor %6, %0 : i1 + llvm.return %7 : i1 + } + llvm.func @select_logic_and_fail(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i8) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.icmp "eq" %arg3, %1 : i8 + %4 = llvm.select %arg1, %2, %3 : i1, i1 + %5 = llvm.select %arg0, %0, %4 : i1, i1 + %6 = llvm.xor %5, %0 : i1 + llvm.return %6 : i1 + } + llvm.func @smin_1(%arg0: i8, %arg1: i8, %arg2: i1, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.xor %arg3, %0 : i8 + %3 = llvm.xor %arg4, %1 : i8 + %4 = llvm.select %arg2, %2, %3 : i1, i8 + %5 = llvm.xor %arg1, %0 : i8 + %6 = llvm.add %arg0, %5 : i8 + %7 = llvm.intr.smin(%6, %4) : (i8, i8) -> i8 + %8 = llvm.xor %7, %0 : i8 + llvm.return %8 : i8 + } + llvm.func @smin_1_fail(%arg0: i8, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.xor %arg2, %0 : i8 + %3 = llvm.xor %arg3, %1 : i8 + %4 = llvm.select %arg1, %2, %3 : i1, i8 + %5 = llvm.intr.smin(%arg0, %4) : (i8, i8) -> i8 + %6 = llvm.xor %5, %0 : i8 + llvm.return %6 : i8 + } + llvm.func @umin_1_fail(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(85 : i8) : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.select %arg0, %2, %arg2 : i1, i8 + %4 = llvm.intr.umin(%3, %1) : (i8, i8) -> i8 + %5 = llvm.xor %4, %0 : i8 + llvm.return %5 : i8 + } + llvm.func @smax_1(%arg0: i8, %arg1: i8, %arg2: i1, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.xor %arg3, %0 : i8 + %3 = llvm.xor %arg4, %1 : i8 + %4 = llvm.select %arg2, %2, %3 : i1, i8 + %5 = llvm.xor %arg1, %0 : i8 + %6 = llvm.sub %5, %arg0 : i8 + %7 = llvm.intr.smax(%6, %4) : (i8, i8) -> i8 + %8 = llvm.xor %7, %0 : i8 + llvm.return %8 : i8 + } + llvm.func @smax_1_fail(%arg0: i8, %arg1: i8, %arg2: i1, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.xor %arg3, %0 : i8 + %3 = llvm.xor %arg4, %1 : i8 + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.select %arg2, %2, %3 : i1, i8 + %5 = llvm.xor %arg1, %0 : i8 + %6 = llvm.sub %5, %arg0 : i8 + %7 = llvm.intr.smax(%6, %4) : (i8, i8) -> i8 + %8 = llvm.xor %7, %0 : i8 + llvm.return %8 : i8 + } + llvm.func @umax_1(%arg0: i8, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.mlir.constant(85 : i8) : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.xor %arg3, %1 : i8 + %5 = llvm.select %arg1, %3, %4 : i1, i8 + %6 = llvm.intr.umax(%5, %2) : (i8, i8) -> i8 + %7 = llvm.xor %6, %0 : i8 + llvm.return %7 : i8 + } + llvm.func @umax_1_fail(%arg0: i8, %arg1: i1, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.mlir.constant(85 : i8) : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.xor %arg3, %1 : i8 + %5 = llvm.select %arg1, %3, %4 : i1, i8 + llvm.call @use.i8(%5) : (i8) -> () + %6 = llvm.intr.umax(%5, %2) : (i8, i8) -> i8 + %7 = llvm.xor %6, %0 : i8 + llvm.return %7 : i8 + } + llvm.func @sub_both_freely_invertable_always(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(45 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.xor %arg1, %1 : i8 + %4 = llvm.sub %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @add_both_freely_invertable_always(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(45 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.xor %arg1, %1 : i8 + %4 = llvm.add %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @xor_both_freely_invertable_always(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(45 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.add %arg1, %1 : i8 + %4 = llvm.xor %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @ashr_both_freely_invertable_always(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(45 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.xor %arg1, %1 : i8 + %4 = llvm.ashr %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @select_both_freely_invertable_always(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(45 : i8) : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %1 : i8 + %4 = llvm.select %arg0, %2, %3 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @umin_both_freely_invertable_always(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(45 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.xor %arg1, %1 : i8 + %4 = llvm.intr.umin(%2, %3) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @umax_both_freely_invertable_always(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(45 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.xor %arg1, %1 : i8 + %4 = llvm.intr.umax(%2, %3) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @smin_both_freely_invertable_always(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(45 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.xor %arg1, %1 : i8 + %4 = llvm.intr.smin(%2, %3) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @smax_both_freely_invertable_always(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(45 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.xor %arg1, %1 : i8 + %4 = llvm.intr.smax(%2, %3) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @lshr_nneg(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.xor %arg0, %1 : i8 + %4 = llvm.lshr %3, %arg1 : i8 + %5 = llvm.xor %4, %1 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_not_nneg(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.lshr %1, %arg1 : i8 + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @lshr_not_nneg2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.lshr %2, %1 : i8 + %4 = llvm.xor %3, %0 : i8 + llvm.return %4 : i8 + } + llvm.func @test_inv_free(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg1, ^bb4(%1 : i1), ^bb3 + ^bb2: // pred: ^bb0 + llvm.br ^bb4(%0 : i1) + ^bb3: // pred: ^bb1 + %2 = llvm.xor %arg2, %1 : i1 + llvm.br ^bb4(%2 : i1) + ^bb4(%3: i1): // 3 preds: ^bb1, ^bb2, ^bb3 + %4 = llvm.xor %arg3, %1 : i1 + %5 = llvm.or %3, %4 : i1 + llvm.cond_br %5, ^bb5, ^bb6 + ^bb5: // pred: ^bb4 + llvm.return %1 : i1 + ^bb6: // pred: ^bb4 + llvm.return %0 : i1 + } + llvm.func @test_inv_free_i32(%arg0: i1, %arg1: i1, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg1, ^bb4(%1 : i32), ^bb3 + ^bb2: // pred: ^bb0 + llvm.br ^bb4(%0 : i32) + ^bb3: // pred: ^bb1 + %2 = llvm.xor %arg2, %1 : i32 + llvm.br ^bb4(%2 : i32) + ^bb4(%3: i32): // 3 preds: ^bb1, ^bb2, ^bb3 + %4 = llvm.xor %arg3, %1 : i32 + %5 = llvm.xor %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test_inv_free_multiuse(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg1, ^bb4(%1 : i1), ^bb3 + ^bb2: // pred: ^bb0 + llvm.br ^bb4(%0 : i1) + ^bb3: // pred: ^bb1 + %2 = llvm.xor %arg2, %1 : i1 + llvm.br ^bb4(%2 : i1) + ^bb4(%3: i1): // 3 preds: ^bb1, ^bb2, ^bb3 + llvm.call @use.i1(%3) : (i1) -> () + %4 = llvm.xor %arg3, %1 : i1 + %5 = llvm.or %3, %4 : i1 + llvm.cond_br %5, ^bb5, ^bb6 + ^bb5: // pred: ^bb4 + llvm.return %1 : i1 + ^bb6: // pred: ^bb4 + llvm.return %0 : i1 + } + llvm.func @test_inv_free_i32_newinst(%arg0: i1, %arg1: i1, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(-8 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg1, ^bb4(%1 : i32), ^bb3 + ^bb2: // pred: ^bb0 + llvm.br ^bb4(%0 : i32) + ^bb3: // pred: ^bb1 + %3 = llvm.ashr %2, %arg2 : i32 + llvm.br ^bb4(%3 : i32) + ^bb4(%4: i32): // 3 preds: ^bb1, ^bb2, ^bb3 + %5 = llvm.xor %arg3, %1 : i32 + %6 = llvm.xor %4, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @test_inv_free_loop(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg1, ^bb4(%1 : i1), ^bb3 + ^bb2: // pred: ^bb0 + llvm.br ^bb4(%0 : i1) + ^bb3: // pred: ^bb1 + %2 = llvm.xor %arg2, %1 : i1 + llvm.br ^bb4(%2 : i1) + ^bb4(%3: i1): // 4 preds: ^bb1, ^bb2, ^bb3, ^bb4 + %4 = llvm.xor %arg3, %1 : i1 + %5 = llvm.or %3, %4 : i1 + %6 = llvm.xor %3, %1 : i1 + llvm.cond_br %5, ^bb4(%6 : i1), ^bb5 + ^bb5: // pred: ^bb4 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/freeze-fp-ops.ll.mlir b/test/LLVMDialect/InstCombine/freeze-fp-ops.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/freeze-integer-intrinsics.ll.mlir b/test/LLVMDialect/InstCombine/freeze-integer-intrinsics.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/freeze-landingpad.ll.mlir b/test/LLVMDialect/InstCombine/freeze-landingpad.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/freeze-phi.ll.mlir b/test/LLVMDialect/InstCombine/freeze-phi.ll.mlir new file mode 100644 index 000000000..fd9ef2891 --- /dev/null +++ b/test/LLVMDialect/InstCombine/freeze-phi.ll.mlir @@ -0,0 +1,123 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @glb(0 : i8) {addr_space = 0 : i32} : i8 + llvm.func @const(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + %3 = llvm.freeze %2 : i32 + llvm.return %3 : i32 + } + llvm.func @vec(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[2, 3]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi32>) : vector<2xi32> + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : vector<2xi32>) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : vector<2xi32>) + ^bb3(%2: vector<2xi32>): // 2 preds: ^bb1, ^bb2 + %3 = llvm.freeze %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @vec_undef(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi32>) : vector<2xi32> + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%7 : vector<2xi32>) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%6 : vector<2xi32>) + ^bb3(%8: vector<2xi32>): // 2 preds: ^bb1, ^bb2 + %9 = llvm.freeze %8 : vector<2xi32> + llvm.return %9 : vector<2xi32> + } + llvm.func @one(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%0 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%arg1 : i32) + ^bb3(%1: i32): // 2 preds: ^bb1, ^bb2 + %2 = llvm.freeze %1 : i32 + llvm.return %2 : i32 + } + llvm.func @two(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%arg1 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%arg2 : i32) + ^bb3(%0: i32): // 2 preds: ^bb1, ^bb2 + %1 = llvm.freeze %0 : i32 + llvm.return %1 : i32 + } + llvm.func @two_undef(%arg0: i8, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : i32 + llvm.switch %arg0 : i8, ^bb1 [ + 0: ^bb2, + 1: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb4(%1 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb4(%arg1 : i32) + ^bb3: // pred: ^bb0 + llvm.br ^bb4(%0 : i32) + ^bb4(%2: i32): // 3 preds: ^bb1, ^bb2, ^bb3 + %3 = llvm.freeze %2 : i32 + llvm.return %3 : i32 + } + llvm.func @one_undef(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.undef : i32 + llvm.switch %arg0 : i8, ^bb1 [ + 0: ^bb2, + 1: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb4(%2 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb4(%1 : i32) + ^bb3: // pred: ^bb0 + llvm.br ^bb4(%0 : i32) + ^bb4(%3: i32): // 3 preds: ^bb1, ^bb2, ^bb3 + %4 = llvm.freeze %3 : i32 + llvm.return %4 : i32 + } + llvm.func @one_constexpr(%arg0: i8, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.mlir.addressof @glb : !llvm.ptr + %5 = llvm.getelementptr inbounds %4[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %6 = llvm.ptrtoint %5 : !llvm.ptr to i32 + llvm.switch %arg0 : i8, ^bb1 [ + 0: ^bb2, + 1: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb4(%6 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb4(%1 : i32) + ^bb3: // pred: ^bb0 + llvm.br ^bb4(%0 : i32) + ^bb4(%7: i32): // 3 preds: ^bb1, ^bb2, ^bb3 + %8 = llvm.freeze %7 : i32 + llvm.return %8 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/freeze.ll.mlir b/test/LLVMDialect/InstCombine/freeze.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/fsh.ll.mlir b/test/LLVMDialect/InstCombine/fsh.ll.mlir new file mode 100644 index 000000000..2b7aa1bd5 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fsh.ll.mlir @@ -0,0 +1,638 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @external_global() {addr_space = 0 : i32} : i8 + llvm.func @use_v2(vector<2xi31>) + llvm.func @use_v3(vector<3xi16>) + llvm.func @fshl_mask_simplify1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.and %arg2, %0 : i32 + %2 = llvm.intr.fshl(%arg0, %arg1, %1) : (i32, i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @fshr_mask_simplify2(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<64> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg2, %0 : vector<2xi32> + %2 = llvm.intr.fshr(%arg0, %arg1, %1) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @fshl_mask_simplify3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.and %arg2, %0 : i32 + %2 = llvm.intr.fshl(%arg0, %arg1, %1) : (i32, i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @fshr_mask_simplify1(%arg0: i33, %arg1: i33, %arg2: i33) -> i33 { + %0 = llvm.mlir.constant(64 : i33) : i33 + %1 = llvm.and %arg2, %0 : i33 + %2 = llvm.intr.fshr(%arg0, %arg1, %1) : (i33, i33, i33) -> i33 + llvm.return %2 : i33 + } + llvm.func @fshl_mask_simplify2(%arg0: vector<2xi31>, %arg1: vector<2xi31>, %arg2: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.constant(32 : i31) : i31 + %1 = llvm.mlir.constant(dense<32> : vector<2xi31>) : vector<2xi31> + %2 = llvm.and %arg2, %1 : vector<2xi31> + %3 = llvm.intr.fshl(%arg0, %arg1, %2) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + llvm.return %3 : vector<2xi31> + } + llvm.func @fshr_mask_simplify3(%arg0: i33, %arg1: i33, %arg2: i33) -> i33 { + %0 = llvm.mlir.constant(32 : i33) : i33 + %1 = llvm.and %arg2, %0 : i33 + %2 = llvm.intr.fshr(%arg0, %arg1, %1) : (i33, i33, i33) -> i33 + llvm.return %2 : i33 + } + llvm.func @fshl_mask_not_required(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.and %arg2, %0 : i32 + %2 = llvm.intr.fshl(%arg0, %arg1, %1) : (i32, i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @fshl_mask_reduce_constant(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(33 : i32) : i32 + %1 = llvm.and %arg2, %0 : i32 + %2 = llvm.intr.fshl(%arg0, %arg1, %1) : (i32, i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @fshl_mask_negative(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.and %arg2, %0 : i32 + %2 = llvm.intr.fshl(%arg0, %arg1, %1) : (i32, i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @fshr_set_but_not_demanded_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.or %arg2, %0 : vector<2xi32> + %2 = llvm.intr.fshr(%arg0, %arg1, %1) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @fshl_set_but_not_demanded_vec(%arg0: vector<2xi31>, %arg1: vector<2xi31>, %arg2: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.constant(32 : i31) : i31 + %1 = llvm.mlir.constant(dense<32> : vector<2xi31>) : vector<2xi31> + %2 = llvm.or %arg2, %1 : vector<2xi31> + %3 = llvm.intr.fshl(%arg0, %arg1, %2) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + llvm.return %3 : vector<2xi31> + } + llvm.func @fshl_op0_undef(%arg0: i32) -> i32 { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.intr.fshl(%0, %arg0, %1) : (i32, i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @fshl_op0_zero(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.intr.fshl(%0, %arg0, %1) : (i32, i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @fshr_op0_undef(%arg0: i33) -> i33 { + %0 = llvm.mlir.undef : i33 + %1 = llvm.mlir.constant(7 : i33) : i33 + %2 = llvm.intr.fshr(%0, %arg0, %1) : (i33, i33, i33) -> i33 + llvm.return %2 : i33 + } + llvm.func @fshr_op0_zero(%arg0: i33) -> i33 { + %0 = llvm.mlir.constant(0 : i33) : i33 + %1 = llvm.mlir.constant(7 : i33) : i33 + %2 = llvm.intr.fshr(%0, %arg0, %1) : (i33, i33, i33) -> i33 + llvm.return %2 : i33 + } + llvm.func @fshl_op1_undef(%arg0: i32) -> i32 { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.intr.fshl(%arg0, %0, %1) : (i32, i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @fshl_op1_zero(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.intr.fshl(%arg0, %0, %1) : (i32, i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @fshr_op1_undef(%arg0: i33) -> i33 { + %0 = llvm.mlir.undef : i33 + %1 = llvm.mlir.constant(7 : i33) : i33 + %2 = llvm.intr.fshr(%arg0, %0, %1) : (i33, i33, i33) -> i33 + llvm.return %2 : i33 + } + llvm.func @fshr_op1_zero(%arg0: i33) -> i33 { + %0 = llvm.mlir.constant(0 : i33) : i33 + %1 = llvm.mlir.constant(7 : i33) : i33 + %2 = llvm.intr.fshr(%arg0, %0, %1) : (i33, i33, i33) -> i33 + llvm.return %2 : i33 + } + llvm.func @fshl_op0_zero_splat_vec(%arg0: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.constant(0 : i31) : i31 + %1 = llvm.mlir.constant(dense<0> : vector<2xi31>) : vector<2xi31> + %2 = llvm.mlir.constant(7 : i31) : i31 + %3 = llvm.mlir.constant(dense<7> : vector<2xi31>) : vector<2xi31> + %4 = llvm.intr.fshl(%1, %arg0, %3) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + llvm.return %4 : vector<2xi31> + } + llvm.func @fshl_op1_undef_splat_vec(%arg0: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.undef : vector<2xi31> + %1 = llvm.mlir.constant(7 : i31) : i31 + %2 = llvm.mlir.constant(dense<7> : vector<2xi31>) : vector<2xi31> + %3 = llvm.intr.fshl(%arg0, %0, %2) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + llvm.return %3 : vector<2xi31> + } + llvm.func @fshr_op0_undef_splat_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.undef : vector<2xi32> + %1 = llvm.mlir.constant(dense<7> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.fshr(%0, %arg0, %1) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @fshr_op1_zero_splat_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<7> : vector<2xi32>) : vector<2xi32> + %3 = llvm.intr.fshr(%arg0, %1, %2) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @fshl_op0_zero_vec(%arg0: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.constant(0 : i31) : i31 + %1 = llvm.mlir.constant(dense<0> : vector<2xi31>) : vector<2xi31> + %2 = llvm.mlir.constant(33 : i31) : i31 + %3 = llvm.mlir.constant(-1 : i31) : i31 + %4 = llvm.mlir.constant(dense<[-1, 33]> : vector<2xi31>) : vector<2xi31> + %5 = llvm.intr.fshl(%1, %arg0, %4) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + llvm.return %5 : vector<2xi31> + } + llvm.func @fshl_op1_undef_vec(%arg0: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.undef : vector<2xi31> + %1 = llvm.mlir.constant(33 : i31) : i31 + %2 = llvm.mlir.constant(-1 : i31) : i31 + %3 = llvm.mlir.constant(dense<[-1, 33]> : vector<2xi31>) : vector<2xi31> + %4 = llvm.intr.fshl(%arg0, %0, %3) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + llvm.return %4 : vector<2xi31> + } + llvm.func @fshr_op0_undef_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.undef : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-1, 33]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.fshr(%0, %arg0, %1) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @fshr_op1_zero_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[-1, 33]> : vector<2xi32>) : vector<2xi32> + %3 = llvm.intr.fshr(%arg0, %1, %2) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @fshl_only_op0_demanded(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.intr.fshl(%arg0, %arg1, %0) : (i32, i32, i32) -> i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @fshl_only_op1_demanded(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(63 : i32) : i32 + %2 = llvm.intr.fshl(%arg0, %arg1, %0) : (i32, i32, i32) -> i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @fshr_only_op1_demanded(%arg0: i33, %arg1: i33) -> i33 { + %0 = llvm.mlir.constant(7 : i33) : i33 + %1 = llvm.mlir.constant(12392 : i33) : i33 + %2 = llvm.intr.fshr(%arg0, %arg1, %0) : (i33, i33, i33) -> i33 + %3 = llvm.and %2, %1 : i33 + llvm.return %3 : i33 + } + llvm.func @fshr_only_op0_demanded(%arg0: i33, %arg1: i33) -> i33 { + %0 = llvm.mlir.constant(7 : i33) : i33 + %1 = llvm.mlir.constant(30 : i33) : i33 + %2 = llvm.intr.fshr(%arg0, %arg1, %0) : (i33, i33, i33) -> i33 + %3 = llvm.lshr %2, %1 : i33 + llvm.return %3 : i33 + } + llvm.func @fshl_only_op1_demanded_vec_splat(%arg0: vector<2xi31>, %arg1: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.constant(7 : i31) : i31 + %1 = llvm.mlir.constant(dense<7> : vector<2xi31>) : vector<2xi31> + %2 = llvm.mlir.constant(31 : i31) : i31 + %3 = llvm.mlir.constant(63 : i31) : i31 + %4 = llvm.mlir.constant(dense<[63, 31]> : vector<2xi31>) : vector<2xi31> + %5 = llvm.intr.fshl(%arg0, %arg1, %1) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + %6 = llvm.and %5, %4 : vector<2xi31> + llvm.return %6 : vector<2xi31> + } + llvm.func @fshl_constant_shift_amount_modulo_bitwidth(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(33 : i32) : i32 + %1 = llvm.intr.fshl(%arg0, %arg1, %0) : (i32, i32, i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @fshr_constant_shift_amount_modulo_bitwidth(%arg0: i33, %arg1: i33) -> i33 { + %0 = llvm.mlir.constant(34 : i33) : i33 + %1 = llvm.intr.fshr(%arg0, %arg1, %0) : (i33, i33, i33) -> i33 + llvm.return %1 : i33 + } + llvm.func @fshl_undef_shift_amount(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.undef : i32 + %1 = llvm.intr.fshl(%arg0, %arg1, %0) : (i32, i32, i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @fshr_undef_shift_amount(%arg0: i33, %arg1: i33) -> i33 { + %0 = llvm.mlir.undef : i33 + %1 = llvm.intr.fshr(%arg0, %arg1, %0) : (i33, i33, i33) -> i33 + llvm.return %1 : i33 + } + llvm.func @fshr_constant_shift_amount_modulo_bitwidth_constexpr(%arg0: i33, %arg1: i33) -> i33 { + %0 = llvm.mlir.addressof @external_global : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i33 + %2 = llvm.intr.fshr(%arg0, %arg1, %1) : (i33, i33, i33) -> i33 + llvm.return %2 : i33 + } + llvm.func @fshr_constant_shift_amount_modulo_bitwidth_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[34, -1]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.intr.fshr(%arg0, %arg1, %0) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @fshl_constant_shift_amount_modulo_bitwidth_vec(%arg0: vector<2xi31>, %arg1: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.constant(-1 : i31) : i31 + %1 = llvm.mlir.constant(34 : i31) : i31 + %2 = llvm.mlir.constant(dense<[34, -1]> : vector<2xi31>) : vector<2xi31> + %3 = llvm.intr.fshl(%arg0, %arg1, %2) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + llvm.return %3 : vector<2xi31> + } + llvm.func @fshl_constant_shift_amount_modulo_bitwidth_vec_const_expr(%arg0: vector<2xi31>, %arg1: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.addressof @external_global : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i31 + %2 = llvm.mlir.constant(34 : i31) : i31 + %3 = llvm.mlir.undef : vector<2xi31> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi31> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi31> + %8 = llvm.ptrtoint %0 : !llvm.ptr to i31 + %9 = llvm.intr.fshl(%arg0, %arg1, %7) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + llvm.return %9 : vector<2xi31> + } + llvm.func @fshl_undef_shift_amount_vec(%arg0: vector<2xi31>, %arg1: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.undef : vector<2xi31> + %1 = llvm.intr.fshl(%arg0, %arg1, %0) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + llvm.return %1 : vector<2xi31> + } + llvm.func @fshr_undef_shift_amount_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.undef : vector<2xi32> + %1 = llvm.intr.fshr(%arg0, %arg1, %0) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @rotl_common_demanded(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.intr.fshl(%2, %2, %1) : (i32, i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @rotr_common_demanded(%arg0: i33) -> i33 { + %0 = llvm.mlir.constant(2 : i33) : i33 + %1 = llvm.mlir.constant(8 : i33) : i33 + %2 = llvm.xor %arg0, %0 : i33 + %3 = llvm.intr.fshr(%2, %2, %1) : (i33, i33, i33) -> i33 + llvm.return %3 : i33 + } + llvm.func @fshl_only_op1_demanded_vec_nonsplat(%arg0: vector<2xi31>, %arg1: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.constant(38 : i31) : i31 + %1 = llvm.mlir.constant(7 : i31) : i31 + %2 = llvm.mlir.constant(dense<[7, 38]> : vector<2xi31>) : vector<2xi31> + %3 = llvm.mlir.constant(31 : i31) : i31 + %4 = llvm.mlir.constant(63 : i31) : i31 + %5 = llvm.mlir.constant(dense<[63, 31]> : vector<2xi31>) : vector<2xi31> + %6 = llvm.intr.fshl(%arg0, %arg1, %2) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + %7 = llvm.and %6, %5 : vector<2xi31> + llvm.return %7 : vector<2xi31> + } + llvm.func @rotl_constant_shift_amount(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(33 : i32) : i32 + %1 = llvm.intr.fshl(%arg0, %arg0, %0) : (i32, i32, i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @rotl_constant_shift_amount_vec(%arg0: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.constant(-1 : i31) : i31 + %1 = llvm.mlir.constant(32 : i31) : i31 + %2 = llvm.mlir.constant(dense<[32, -1]> : vector<2xi31>) : vector<2xi31> + %3 = llvm.intr.fshl(%arg0, %arg0, %2) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + llvm.return %3 : vector<2xi31> + } + llvm.func @rotr_constant_shift_amount(%arg0: i33) -> i33 { + %0 = llvm.mlir.constant(34 : i33) : i33 + %1 = llvm.intr.fshr(%arg0, %arg0, %0) : (i33, i33, i33) -> i33 + llvm.return %1 : i33 + } + llvm.func @rotr_constant_shift_amount_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[33, -1]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.intr.fshr(%arg0, %arg0, %0) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @fshl_both_ops_demanded(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(192 : i32) : i32 + %2 = llvm.intr.fshl(%arg0, %arg1, %0) : (i32, i32, i32) -> i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @fshr_both_ops_demanded(%arg0: i33, %arg1: i33) -> i33 { + %0 = llvm.mlir.constant(26 : i33) : i33 + %1 = llvm.mlir.constant(192 : i33) : i33 + %2 = llvm.intr.fshr(%arg0, %arg1, %0) : (i33, i33, i33) -> i33 + %3 = llvm.and %2, %1 : i33 + llvm.return %3 : i33 + } + llvm.func @fshl_known_bits(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.mlir.constant(192 : i32) : i32 + %3 = llvm.or %arg0, %0 : i32 + %4 = llvm.lshr %arg1, %0 : i32 + %5 = llvm.intr.fshl(%3, %4, %1) : (i32, i32, i32) -> i32 + %6 = llvm.and %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @fshr_known_bits(%arg0: i33, %arg1: i33) -> i33 { + %0 = llvm.mlir.constant(1 : i33) : i33 + %1 = llvm.mlir.constant(26 : i33) : i33 + %2 = llvm.mlir.constant(192 : i33) : i33 + %3 = llvm.or %arg0, %0 : i33 + %4 = llvm.lshr %arg1, %0 : i33 + %5 = llvm.intr.fshr(%3, %4, %1) : (i33, i33, i33) -> i33 + %6 = llvm.and %5, %2 : i33 + llvm.return %6 : i33 + } + llvm.func @fshr_multi_use(%arg0: i33) -> i33 { + %0 = llvm.mlir.constant(1 : i33) : i33 + %1 = llvm.mlir.constant(23 : i33) : i33 + %2 = llvm.mlir.constant(31 : i33) : i33 + %3 = llvm.intr.fshr(%arg0, %arg0, %0) : (i33, i33, i33) -> i33 + %4 = llvm.lshr %3, %1 : i33 + %5 = llvm.xor %4, %3 : i33 + %6 = llvm.and %5, %2 : i33 + llvm.return %6 : i33 + } + llvm.func @expanded_fshr_multi_use(%arg0: i33) -> i33 { + %0 = llvm.mlir.constant(1 : i33) : i33 + %1 = llvm.mlir.constant(32 : i33) : i33 + %2 = llvm.mlir.constant(23 : i33) : i33 + %3 = llvm.mlir.constant(31 : i33) : i33 + %4 = llvm.lshr %arg0, %0 : i33 + %5 = llvm.shl %arg0, %1 : i33 + %6 = llvm.or %4, %5 : i33 + %7 = llvm.lshr %6, %2 : i33 + %8 = llvm.xor %7, %6 : i33 + %9 = llvm.and %8, %3 : i33 + llvm.return %9 : i33 + } + llvm.func @fshl_bswap(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.intr.fshl(%arg0, %arg0, %0) : (i16, i16, i16) -> i16 + llvm.return %1 : i16 + } + llvm.func @fshr_bswap(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.intr.fshr(%arg0, %arg0, %0) : (i16, i16, i16) -> i16 + llvm.return %1 : i16 + } + llvm.func @fshl_bswap_vector(%arg0: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<8> : vector<3xi16>) : vector<3xi16> + %1 = llvm.intr.fshl(%arg0, %arg0, %0) : (vector<3xi16>, vector<3xi16>, vector<3xi16>) -> vector<3xi16> + llvm.return %1 : vector<3xi16> + } + llvm.func @fshl_bswap_wrong_op(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.intr.fshl(%arg0, %arg1, %0) : (i16, i16, i16) -> i16 + llvm.return %1 : i16 + } + llvm.func @fshr_bswap_wrong_amount(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = llvm.intr.fshr(%arg0, %arg0, %0) : (i16, i16, i16) -> i16 + llvm.return %1 : i16 + } + llvm.func @fshl_bswap_wrong_width(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.intr.fshl(%arg0, %arg0, %0) : (i32, i32, i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @fshl_mask_args_same1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.intr.fshl(%2, %2, %1) : (i32, i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @fshl_mask_args_same2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.intr.fshl(%2, %2, %1) : (i32, i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @fshl_mask_args_same3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.intr.fshl(%2, %2, %1) : (i32, i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @fshl_mask_args_different(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(-16777216 : i32) : i32 + %2 = llvm.mlir.constant(17 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.intr.fshl(%3, %4, %2) : (i32, i32, i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @fsh_andconst_rotate(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.intr.fshl(%2, %2, %1) : (i32, i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @fsh_orconst_rotate(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-268435456 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.intr.fshl(%2, %2, %1) : (i32, i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @fsh_rotate_5(%arg0: i8, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(27 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.or %2, %arg1 : i32 + %4 = llvm.lshr %3, %0 : i32 + %5 = llvm.shl %3, %1 : i32 + %6 = llvm.or %4, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @fsh_rotate_18(%arg0: i8, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(18 : i32) : i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.or %2, %arg1 : i32 + %4 = llvm.lshr %3, %0 : i32 + %5 = llvm.shl %3, %1 : i32 + %6 = llvm.or %4, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @fsh_load_rotate_12(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(16 : i32) : i32 + %3 = llvm.mlir.constant(2 : i64) : i64 + %4 = llvm.mlir.constant(8 : i32) : i32 + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.constant(20 : i32) : i32 + %7 = llvm.mlir.constant(12 : i32) : i32 + %8 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %9 = llvm.zext %8 : i8 to i32 + %10 = llvm.shl %9, %0 overflow : i32 + %11 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %12 = llvm.load %11 {alignment = 1 : i64} : !llvm.ptr -> i8 + %13 = llvm.zext %12 : i8 to i32 + %14 = llvm.shl %13, %2 overflow : i32 + %15 = llvm.or %14, %10 : i32 + %16 = llvm.getelementptr inbounds %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %17 = llvm.load %16 {alignment = 1 : i64} : !llvm.ptr -> i8 + %18 = llvm.zext %17 : i8 to i32 + %19 = llvm.shl %18, %4 overflow : i32 + %20 = llvm.or %15, %19 : i32 + %21 = llvm.getelementptr inbounds %arg0[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %22 = llvm.load %21 {alignment = 1 : i64} : !llvm.ptr -> i8 + %23 = llvm.zext %22 : i8 to i32 + %24 = llvm.or %20, %23 : i32 + %25 = llvm.lshr %24, %6 : i32 + %26 = llvm.shl %24, %7 : i32 + %27 = llvm.or %25, %26 : i32 + llvm.return %27 : i32 + } + llvm.func @fsh_load_rotate_25(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(16 : i32) : i32 + %3 = llvm.mlir.constant(2 : i64) : i64 + %4 = llvm.mlir.constant(8 : i32) : i32 + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.constant(7 : i32) : i32 + %7 = llvm.mlir.constant(25 : i32) : i32 + %8 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %9 = llvm.zext %8 : i8 to i32 + %10 = llvm.shl %9, %0 overflow : i32 + %11 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %12 = llvm.load %11 {alignment = 1 : i64} : !llvm.ptr -> i8 + %13 = llvm.zext %12 : i8 to i32 + %14 = llvm.shl %13, %2 overflow : i32 + %15 = llvm.or %14, %10 : i32 + %16 = llvm.getelementptr inbounds %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %17 = llvm.load %16 {alignment = 1 : i64} : !llvm.ptr -> i8 + %18 = llvm.zext %17 : i8 to i32 + %19 = llvm.shl %18, %4 overflow : i32 + %20 = llvm.or %15, %19 : i32 + %21 = llvm.getelementptr inbounds %arg0[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %22 = llvm.load %21 {alignment = 1 : i64} : !llvm.ptr -> i8 + %23 = llvm.zext %22 : i8 to i32 + %24 = llvm.or %20, %23 : i32 + %25 = llvm.lshr %24, %6 : i32 + %26 = llvm.shl %24, %7 : i32 + %27 = llvm.or %25, %26 : i32 + llvm.return %27 : i32 + } + llvm.func @fshr_mask_args_same_vector(%arg0: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.constant(1000 : i31) : i31 + %1 = llvm.mlir.constant(dense<1000> : vector<2xi31>) : vector<2xi31> + %2 = llvm.mlir.constant(-1 : i31) : i31 + %3 = llvm.mlir.constant(dense<-1> : vector<2xi31>) : vector<2xi31> + %4 = llvm.mlir.constant(10 : i31) : i31 + %5 = llvm.mlir.constant(dense<10> : vector<2xi31>) : vector<2xi31> + %6 = llvm.and %arg0, %1 : vector<2xi31> + %7 = llvm.and %arg0, %3 : vector<2xi31> + %8 = llvm.intr.fshl(%7, %6, %5) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + llvm.return %8 : vector<2xi31> + } + llvm.func @fshr_mask_args_same_vector2(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[1000000, 100000]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<2147483647> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %0 : vector<2xi32> + %4 = llvm.and %arg0, %1 : vector<2xi32> + %5 = llvm.intr.fshr(%3, %3, %2) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @fshr_mask_args_same_vector3_different_but_still_prunable(%arg0: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.constant(1000 : i31) : i31 + %1 = llvm.mlir.constant(dense<1000> : vector<2xi31>) : vector<2xi31> + %2 = llvm.mlir.constant(-1 : i31) : i31 + %3 = llvm.mlir.constant(dense<-1> : vector<2xi31>) : vector<2xi31> + %4 = llvm.mlir.constant(3 : i31) : i31 + %5 = llvm.mlir.constant(10 : i31) : i31 + %6 = llvm.mlir.constant(dense<[10, 3]> : vector<2xi31>) : vector<2xi31> + %7 = llvm.and %arg0, %1 : vector<2xi31> + %8 = llvm.and %arg0, %3 : vector<2xi31> + %9 = llvm.intr.fshl(%8, %7, %6) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + llvm.return %9 : vector<2xi31> + } + llvm.func @fsh_unary_shuffle_ops(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : vector<2xi32> + %1 = llvm.shufflevector %arg0, %0 [1, 0] : vector<2xi32> + %2 = llvm.shufflevector %arg1, %0 [1, 0] : vector<2xi32> + %3 = llvm.shufflevector %arg2, %0 [1, 0] : vector<2xi32> + %4 = llvm.intr.fshr(%1, %2, %3) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @fsh_unary_shuffle_ops_widening(%arg0: vector<2xi16>, %arg1: vector<2xi16>, %arg2: vector<2xi16>) -> vector<3xi16> { + %0 = llvm.mlir.poison : vector<2xi16> + %1 = llvm.shufflevector %arg0, %0 [1, 0, 1] : vector<2xi16> + llvm.call @use_v3(%1) : (vector<3xi16>) -> () + %2 = llvm.shufflevector %arg1, %0 [1, 0, 1] : vector<2xi16> + %3 = llvm.shufflevector %arg2, %0 [1, 0, 1] : vector<2xi16> + %4 = llvm.intr.fshl(%1, %2, %3) : (vector<3xi16>, vector<3xi16>, vector<3xi16>) -> vector<3xi16> + llvm.return %4 : vector<3xi16> + } + llvm.func @fsh_unary_shuffle_ops_narrowing(%arg0: vector<3xi31>, %arg1: vector<3xi31>, %arg2: vector<3xi31>) -> vector<2xi31> { + %0 = llvm.mlir.poison : vector<3xi31> + %1 = llvm.shufflevector %arg0, %0 [1, 0] : vector<3xi31> + %2 = llvm.shufflevector %arg1, %0 [1, 0] : vector<3xi31> + llvm.call @use_v2(%2) : (vector<2xi31>) -> () + %3 = llvm.shufflevector %arg2, %0 [1, 0] : vector<3xi31> + %4 = llvm.intr.fshl(%1, %2, %3) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + llvm.return %4 : vector<2xi31> + } + llvm.func @fsh_unary_shuffle_ops_unshuffled(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : vector<2xi32> + %1 = llvm.shufflevector %arg0, %0 [1, 0] : vector<2xi32> + %2 = llvm.shufflevector %arg1, %0 [1, 0] : vector<2xi32> + %3 = llvm.intr.fshr(%1, %2, %arg2) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @fsh_unary_shuffle_ops_wrong_mask(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : vector<2xi32> + %1 = llvm.shufflevector %arg0, %0 [1, 0] : vector<2xi32> + %2 = llvm.shufflevector %arg1, %0 [0, 0] : vector<2xi32> + %3 = llvm.shufflevector %arg2, %0 [1, 0] : vector<2xi32> + %4 = llvm.intr.fshr(%1, %2, %3) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @fsh_unary_shuffle_ops_uses(%arg0: vector<2xi31>, %arg1: vector<2xi31>, %arg2: vector<2xi31>) -> vector<2xi31> { + %0 = llvm.mlir.poison : vector<2xi31> + %1 = llvm.shufflevector %arg0, %0 [1, 0] : vector<2xi31> + llvm.call @use_v2(%1) : (vector<2xi31>) -> () + %2 = llvm.shufflevector %arg1, %0 [1, 0] : vector<2xi31> + llvm.call @use_v2(%2) : (vector<2xi31>) -> () + %3 = llvm.shufflevector %arg2, %0 [1, 0] : vector<2xi31> + llvm.call @use_v2(%3) : (vector<2xi31>) -> () + %4 = llvm.intr.fshl(%1, %2, %3) : (vector<2xi31>, vector<2xi31>, vector<2xi31>) -> vector<2xi31> + llvm.return %4 : vector<2xi31> + } + llvm.func @fsh_unary_shuffle_ops_partial_widening(%arg0: vector<3xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : vector<3xi32> + %1 = llvm.mlir.poison : vector<2xi32> + %2 = llvm.shufflevector %arg0, %0 [1, 0] : vector<3xi32> + %3 = llvm.shufflevector %arg1, %1 [1, 0] : vector<2xi32> + %4 = llvm.shufflevector %arg2, %1 [1, 0] : vector<2xi32> + %5 = llvm.intr.fshr(%2, %3, %4) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @fshr_vec_zero_elem(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[2, 0]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.intr.fshr(%arg0, %arg1, %0) : (vector<2xi32>, vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %1 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/fsub.ll.mlir b/test/LLVMDialect/InstCombine/fsub.ll.mlir new file mode 100644 index 000000000..c96512729 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fsub.ll.mlir @@ -0,0 +1,495 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @b() {addr_space = 0 : i32, alignment = 1 : i64} : i16 + llvm.func @test1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 : f32 + %2 = llvm.fsub %0, %1 : f32 + llvm.return %2 : f32 + } + llvm.func @test1_unary(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fsub %arg0, %arg1 : f32 + %1 = llvm.fneg %0 : f32 + llvm.return %1 : f32 + } + llvm.func @neg_sub_nsz(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 : f32 + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @unary_neg_sub_nsz(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fsub %arg0, %arg1 : f32 + %1 = llvm.fneg %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @use(f32) + llvm.func @use2(f32, f64) + llvm.func @neg_sub_nsz_extra_use(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 : f32 + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%1) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @unary_neg_sub_nsz_extra_use(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fsub %arg0, %arg1 : f32 + %1 = llvm.fneg %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%0) : (f32) -> () + llvm.return %1 : f32 + } + llvm.func @sub_sub_nsz(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fsub %arg0, %arg1 : f32 + %1 = llvm.fsub %arg2, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @sub_add_neg_x(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.fmul %arg0, %0 : f32 + %2 = llvm.fadd %1, %arg1 : f32 + %3 = llvm.fsub %arg1, %2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @sub_sub_known_not_negzero(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.fsub %arg0, %arg1 : f32 + %2 = llvm.fsub %0, %1 : f32 + llvm.return %2 : f32 + } + llvm.func @test2(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fadd %arg0, %arg1 : f64 + %1 = llvm.fsub %arg0, %0 : f64 + llvm.return %1 : f64 + } + llvm.func @constant_op1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.fsub %arg0, %0 : f32 + llvm.return %1 : f32 + } + llvm.func @constant_op1_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %arg0, %0 : vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @constant_op1_vec_poison(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(-4.200000e+01 : f32) : f32 + %1 = llvm.mlir.poison : f32 + %2 = llvm.mlir.undef : vector<2xf32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf32> + %7 = llvm.fsub %arg0, %6 : vector<2xf32> + llvm.return %7 : vector<2xf32> + } + llvm.func @neg_op1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg1 : f32 + %2 = llvm.fsub %arg0, %1 : f32 + llvm.return %2 : f32 + } + llvm.func @unary_neg_op1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg1 : f32 + %1 = llvm.fsub %arg0, %0 : f32 + llvm.return %1 : f32 + } + llvm.func @neg_op1_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg1 : vector<2xf32> + %2 = llvm.fsub %arg0, %1 : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @unary_neg_op1_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fneg %arg1 : vector<2xf32> + %1 = llvm.fsub %arg0, %0 : vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @neg_op1_vec_poison(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.poison : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.mlir.undef : vector<2xf32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf32> + %7 = llvm.fsub %6, %arg1 : vector<2xf32> + %8 = llvm.fsub %arg0, %7 : vector<2xf32> + llvm.return %8 : vector<2xf32> + } + llvm.func @neg_ext_op1(%arg0: f32, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fpext %1 : f32 to f64 + %3 = llvm.fsub %arg1, %2 : f64 + llvm.return %3 : f64 + } + llvm.func @unary_neg_ext_op1(%arg0: f32, %arg1: f64) -> f64 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fpext %0 : f32 to f64 + %2 = llvm.fsub %arg1, %1 : f64 + llvm.return %2 : f64 + } + llvm.func @neg_trunc_op1(%arg0: vector<2xf64>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fsub %0, %arg0 : vector<2xf64> + %2 = llvm.fptrunc %1 : vector<2xf64> to vector<2xf32> + %3 = llvm.fsub %arg1, %2 : vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @unary_neg_trunc_op1(%arg0: vector<2xf64>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fneg %arg0 : vector<2xf64> + %1 = llvm.fptrunc %0 : vector<2xf64> to vector<2xf32> + %2 = llvm.fsub %arg1, %1 : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @neg_ext_op1_fast(%arg0: f32, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fpext %1 : f32 to f64 + %3 = llvm.fsub %arg1, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %3 : f64 + } + llvm.func @unary_neg_ext_op1_fast(%arg0: f32, %arg1: f64) -> f64 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fpext %0 : f32 to f64 + %2 = llvm.fsub %arg1, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @neg_ext_op1_extra_use(%arg0: f16, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f16) : f16 + %1 = llvm.fsub %0, %arg0 : f16 + %2 = llvm.fpext %1 : f16 to f32 + %3 = llvm.fsub %arg1, %2 : f32 + llvm.call @use(%2) : (f32) -> () + llvm.return %3 : f32 + } + llvm.func @unary_neg_ext_op1_extra_use(%arg0: f16, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 : f16 + %1 = llvm.fpext %0 : f16 to f32 + %2 = llvm.fsub %arg1, %1 : f32 + llvm.call @use(%1) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @neg_trunc_op1_extra_use(%arg0: f64, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.fptrunc %1 : f64 to f32 + %3 = llvm.fsub %arg1, %2 : f32 + llvm.call @use(%2) : (f32) -> () + llvm.return %3 : f32 + } + llvm.func @unary_neg_trunc_op1_extra_use(%arg0: f64, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.fptrunc %0 : f64 to f32 + %2 = llvm.fsub %arg1, %1 : f32 + llvm.call @use(%1) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @neg_trunc_op1_extra_uses(%arg0: f64, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.fptrunc %1 : f64 to f32 + %3 = llvm.fsub %arg1, %2 : f32 + llvm.call @use2(%2, %1) : (f32, f64) -> () + llvm.return %3 : f32 + } + llvm.func @unary_neg_trunc_op1_extra_uses(%arg0: f64, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.fptrunc %0 : f64 to f32 + %2 = llvm.fsub %arg1, %1 : f32 + llvm.call @use2(%1, %0) : (f32, f64) -> () + llvm.return %2 : f32 + } + llvm.func @PR37605(%arg0: f32) -> f32 { + %0 = llvm.mlir.addressof @b : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i32 + %2 = llvm.bitcast %1 : i32 to f32 + %3 = llvm.fsub %arg0, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @fsub_fdiv_fneg1(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.fdiv %1, %arg1 : f64 + %3 = llvm.fsub %arg2, %2 : f64 + llvm.return %3 : f64 + } + llvm.func @fsub_fdiv_fneg2(%arg0: vector<2xf64>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fsub %0, %arg0 : vector<2xf64> + %2 = llvm.fdiv %arg1, %1 : vector<2xf64> + %3 = llvm.fsub %arg2, %2 : vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @fsub_fmul_fneg1(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.fmul %1, %arg1 : f64 + %3 = llvm.fsub %arg2, %2 : f64 + llvm.return %3 : f64 + } + llvm.func @fsub_fmul_fneg2(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.fmul %arg1, %1 : f64 + %3 = llvm.fsub %arg2, %2 : f64 + llvm.return %3 : f64 + } + llvm.func @fsub_fdiv_fneg1_extra_use(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fdiv %1, %arg1 : f32 + llvm.call @use(%2) : (f32) -> () + %3 = llvm.fsub %arg2, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @fsub_fdiv_fneg2_extra_use(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fdiv %arg1, %1 : f32 + llvm.call @use(%2) : (f32) -> () + %3 = llvm.fsub %arg2, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @use_vec(vector<2xf32>) + llvm.func @fsub_fmul_fneg1_extra_use(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 : vector<2xf32> + %2 = llvm.fmul %1, %arg1 : vector<2xf32> + llvm.call @use_vec(%2) : (vector<2xf32>) -> () + %3 = llvm.fsub %arg2, %2 : vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @fsub_fmul_fneg2_extra_use(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fmul %arg1, %1 : f32 + llvm.call @use(%2) : (f32) -> () + %3 = llvm.fsub %arg2, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @fsub_fdiv_fneg1_extra_use2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fdiv %1, %arg1 : f32 + %3 = llvm.fsub %arg2, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @fsub_fdiv_fneg2_extra_use2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fdiv %arg1, %1 : f32 + %3 = llvm.fsub %arg2, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @fsub_fmul_fneg1_extra_use2(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 : vector<2xf32> + llvm.call @use_vec(%1) : (vector<2xf32>) -> () + %2 = llvm.fmul %1, %arg1 : vector<2xf32> + %3 = llvm.fsub %arg2, %2 : vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @fsub_fmul_fneg2_extra_use2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fmul %arg1, %1 : f32 + %3 = llvm.fsub %arg2, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @fsub_fdiv_fneg1_extra_use3(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fdiv %1, %arg1 : f32 + llvm.call @use(%2) : (f32) -> () + %3 = llvm.fsub %arg2, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @fsub_fdiv_fneg2_extra_use3(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fdiv %arg1, %1 : f32 + llvm.call @use(%2) : (f32) -> () + %3 = llvm.fsub %arg2, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @fsub_fmul_fneg1_extra_use3(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 : vector<2xf32> + llvm.call @use_vec(%1) : (vector<2xf32>) -> () + %2 = llvm.fmul %1, %arg1 : vector<2xf32> + llvm.call @use_vec(%2) : (vector<2xf32>) -> () + %3 = llvm.fsub %arg2, %2 : vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @fsub_fmul_fneg2_extra_use3(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fmul %arg1, %1 : f32 + llvm.call @use(%2) : (f32) -> () + %3 = llvm.fsub %arg2, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @fsub_fsub(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fsub %arg0, %arg1 : f32 + %1 = llvm.fsub %0, %arg2 : f32 + llvm.return %1 : f32 + } + llvm.func @fsub_fsub_nsz(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fsub %arg0, %arg1 : f32 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @fsub_fsub_reassoc(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fsub %arg0, %arg1 : f32 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @fsub_fsub_nsz_reassoc(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fsub %arg0, %arg1 : f32 + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @fsub_fsub_fast_vec(%arg0: vector<2xf64>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fsub_fsub_nsz_reassoc_extra_use(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fsub %arg0, %arg1 : f32 + llvm.call @use(%0) : (f32) -> () + %1 = llvm.fsub %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @fneg_fsub(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fsub %0, %arg1 : f32 + llvm.return %1 : f32 + } + llvm.func @fneg_fsub_nsz(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fsub %0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %1 : f32 + } + llvm.func @fake_fneg_fsub_fast(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fsub %1, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fake_fneg_fsub_fast_extra_use(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fsub %1, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fake_fneg_fsub_vec(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 : vector<2xf32> + %2 = llvm.fsub %1, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fneg_fsub_constant(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.fneg %arg0 : f32 + %2 = llvm.fsub %1, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fsub_fadd_fsub_reassoc(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: f32) -> f32 { + %0 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fadd %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %1, %arg3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fsub_fadd_fsub_reassoc_commute(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>, %arg3: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fdiv %arg2, %0 : vector<2xf32> + %2 = llvm.fsub %arg0, %arg1 : vector<2xf32> + %3 = llvm.fadd %1, %2 : vector<2xf32> + %4 = llvm.fsub %3, %arg3 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fsub_fadd_fsub_reassoc_twice(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: f32, %arg4: f32) -> f32 { + %0 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fsub %arg2, %arg3 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fadd %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fsub %2, %arg4 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @fsub_fadd_fsub_not_reassoc(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: f32) -> f32 { + %0 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fadd %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %1, %arg3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fsub_fadd_fsub_reassoc_use1(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: f32) -> f32 { + %0 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%0) : (f32) -> () + %1 = llvm.fadd %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %1, %arg3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fsub_fadd_fsub_reassoc_use2(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: f32) -> f32 { + %0 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fadd %0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fsub %1, %arg3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fmul_c1(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.fmul %arg0, %0 : f32 + %2 = llvm.fsub %arg1, %1 : f32 + llvm.return %2 : f32 + } + llvm.func @fmul_c1_fmf(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[4.200000e+01, 5.000000e-01]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %2 = llvm.fsub %arg1, %1 : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fmul_c1_use(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.fmul %arg0, %0 : f32 + llvm.call @use(%1) : (f32) -> () + %2 = llvm.fsub %arg1, %1 : f32 + llvm.return %2 : f32 + } + llvm.func @fdiv_c0(%arg0: f16, %arg1: f16) -> f16 { + %0 = llvm.mlir.constant(7.000000e+00 : f16) : f16 + %1 = llvm.fdiv %0, %arg0 : f16 + %2 = llvm.fsub %arg1, %1 : f16 + llvm.return %2 : f16 + } + llvm.func @fdiv_c0_fmf(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f64) : f64 + %1 = llvm.fdiv %0, %arg0 : f64 + %2 = llvm.fsub %arg1, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_c1(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[4.270000e+02, -0.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fdiv %arg0, %0 : vector<2xf32> + %2 = llvm.fsub %arg1, %1 : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @fdiv_c1_fmf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(4.270000e+02 : f32) : f32 + %1 = llvm.fdiv %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %arg1, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fdiv_c1_use(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[4.270000e+02, -0.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fdiv %arg0, %0 : vector<2xf32> + llvm.call @use_vec(%1) : (vector<2xf32>) -> () + %2 = llvm.fsub %arg1, %1 : vector<2xf32> + llvm.return %2 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/funnel.ll.mlir b/test/LLVMDialect/InstCombine/funnel.ll.mlir new file mode 100644 index 000000000..df69e8850 --- /dev/null +++ b/test/LLVMDialect/InstCombine/funnel.ll.mlir @@ -0,0 +1,473 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fshl_i32_constant(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(11 : i32) : i32 + %1 = llvm.mlir.constant(21 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.lshr %arg1, %1 : i32 + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @fshr_i42_constant(%arg0: i42, %arg1: i42) -> i42 { + %0 = llvm.mlir.constant(31 : i42) : i42 + %1 = llvm.mlir.constant(11 : i42) : i42 + %2 = llvm.lshr %arg0, %0 : i42 + %3 = llvm.shl %arg1, %1 : i42 + %4 = llvm.or %2, %3 : i42 + llvm.return %4 : i42 + } + llvm.func @fshl_v2i16_constant_splat(%arg0: vector<2xi16>, %arg1: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<15> : vector<2xi16>) : vector<2xi16> + %2 = llvm.shl %arg0, %0 : vector<2xi16> + %3 = llvm.lshr %arg1, %1 : vector<2xi16> + %4 = llvm.or %2, %3 : vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @fshl_v2i16_constant_splat_poison0(%arg0: vector<2xi16>, %arg1: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<2xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi16> + %7 = llvm.mlir.constant(dense<15> : vector<2xi16>) : vector<2xi16> + %8 = llvm.shl %arg0, %6 : vector<2xi16> + %9 = llvm.lshr %arg1, %7 : vector<2xi16> + %10 = llvm.or %8, %9 : vector<2xi16> + llvm.return %10 : vector<2xi16> + } + llvm.func @fshl_v2i16_constant_splat_poison1(%arg0: vector<2xi16>, %arg1: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.constant(15 : i16) : i16 + %3 = llvm.mlir.undef : vector<2xi16> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi16> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi16> + %8 = llvm.shl %arg0, %0 : vector<2xi16> + %9 = llvm.lshr %arg1, %7 : vector<2xi16> + %10 = llvm.or %8, %9 : vector<2xi16> + llvm.return %10 : vector<2xi16> + } + llvm.func @fshr_v2i17_constant_splat(%arg0: vector<2xi17>, %arg1: vector<2xi17>) -> vector<2xi17> { + %0 = llvm.mlir.constant(12 : i17) : i17 + %1 = llvm.mlir.constant(dense<12> : vector<2xi17>) : vector<2xi17> + %2 = llvm.mlir.constant(5 : i17) : i17 + %3 = llvm.mlir.constant(dense<5> : vector<2xi17>) : vector<2xi17> + %4 = llvm.lshr %arg0, %1 : vector<2xi17> + %5 = llvm.shl %arg1, %3 : vector<2xi17> + %6 = llvm.or %4, %5 : vector<2xi17> + llvm.return %6 : vector<2xi17> + } + llvm.func @fshr_v2i17_constant_splat_poison0(%arg0: vector<2xi17>, %arg1: vector<2xi17>) -> vector<2xi17> { + %0 = llvm.mlir.poison : i17 + %1 = llvm.mlir.constant(12 : i17) : i17 + %2 = llvm.mlir.undef : vector<2xi17> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi17> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi17> + %7 = llvm.mlir.constant(5 : i17) : i17 + %8 = llvm.mlir.undef : vector<2xi17> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<2xi17> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %7, %10[%11 : i32] : vector<2xi17> + %13 = llvm.lshr %arg0, %6 : vector<2xi17> + %14 = llvm.shl %arg1, %12 : vector<2xi17> + %15 = llvm.or %13, %14 : vector<2xi17> + llvm.return %15 : vector<2xi17> + } + llvm.func @fshr_v2i17_constant_splat_poison1(%arg0: vector<2xi17>, %arg1: vector<2xi17>) -> vector<2xi17> { + %0 = llvm.mlir.poison : i17 + %1 = llvm.mlir.constant(12 : i17) : i17 + %2 = llvm.mlir.undef : vector<2xi17> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi17> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi17> + %7 = llvm.mlir.constant(5 : i17) : i17 + %8 = llvm.mlir.undef : vector<2xi17> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi17> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi17> + %13 = llvm.lshr %arg0, %6 : vector<2xi17> + %14 = llvm.shl %arg1, %12 : vector<2xi17> + %15 = llvm.or %13, %14 : vector<2xi17> + llvm.return %15 : vector<2xi17> + } + llvm.func @fshr_v2i32_constant_nonsplat(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[17, 19]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[15, 13]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.shl %arg1, %1 : vector<2xi32> + %4 = llvm.or %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @fshr_v2i32_constant_nonsplat_poison0(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(19 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<[15, 13]> : vector<2xi32>) : vector<2xi32> + %8 = llvm.lshr %arg0, %6 : vector<2xi32> + %9 = llvm.shl %arg1, %7 : vector<2xi32> + %10 = llvm.or %9, %8 : vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @fshr_v2i32_constant_nonsplat_poison1(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[17, 19]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.undef : vector<2xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi32> + %8 = llvm.lshr %arg0, %0 : vector<2xi32> + %9 = llvm.shl %arg1, %7 : vector<2xi32> + %10 = llvm.or %9, %8 : vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @fshl_v2i36_constant_nonsplat(%arg0: vector<2xi36>, %arg1: vector<2xi36>) -> vector<2xi36> { + %0 = llvm.mlir.constant(11 : i36) : i36 + %1 = llvm.mlir.constant(21 : i36) : i36 + %2 = llvm.mlir.constant(dense<[21, 11]> : vector<2xi36>) : vector<2xi36> + %3 = llvm.mlir.constant(25 : i36) : i36 + %4 = llvm.mlir.constant(15 : i36) : i36 + %5 = llvm.mlir.constant(dense<[15, 25]> : vector<2xi36>) : vector<2xi36> + %6 = llvm.shl %arg0, %2 : vector<2xi36> + %7 = llvm.lshr %arg1, %5 : vector<2xi36> + %8 = llvm.or %6, %7 : vector<2xi36> + llvm.return %8 : vector<2xi36> + } + llvm.func @fshl_v3i36_constant_nonsplat_poison0(%arg0: vector<3xi36>, %arg1: vector<3xi36>) -> vector<3xi36> { + %0 = llvm.mlir.poison : i36 + %1 = llvm.mlir.constant(11 : i36) : i36 + %2 = llvm.mlir.constant(21 : i36) : i36 + %3 = llvm.mlir.undef : vector<3xi36> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi36> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi36> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi36> + %10 = llvm.mlir.constant(25 : i36) : i36 + %11 = llvm.mlir.constant(15 : i36) : i36 + %12 = llvm.mlir.undef : vector<3xi36> + %13 = llvm.mlir.constant(0 : i32) : i32 + %14 = llvm.insertelement %11, %12[%13 : i32] : vector<3xi36> + %15 = llvm.mlir.constant(1 : i32) : i32 + %16 = llvm.insertelement %10, %14[%15 : i32] : vector<3xi36> + %17 = llvm.mlir.constant(2 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<3xi36> + %19 = llvm.shl %arg0, %9 : vector<3xi36> + %20 = llvm.lshr %arg1, %18 : vector<3xi36> + %21 = llvm.or %19, %20 : vector<3xi36> + llvm.return %21 : vector<3xi36> + } + llvm.func @fshl_sub_mask(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(64 : i64) : i64 + %2 = llvm.and %arg2, %0 : i64 + %3 = llvm.shl %arg0, %2 : i64 + %4 = llvm.sub %1, %2 overflow : i64 + %5 = llvm.lshr %arg1, %4 : i64 + %6 = llvm.or %3, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @fshr_sub_mask(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(64 : i64) : i64 + %2 = llvm.and %arg2, %0 : i64 + %3 = llvm.lshr %arg0, %2 : i64 + %4 = llvm.sub %1, %2 overflow : i64 + %5 = llvm.shl %arg1, %4 : i64 + %6 = llvm.or %5, %3 : i64 + llvm.return %6 : i64 + } + llvm.func @fshr_sub_mask_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>, %arg2: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<63> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<64> : vector<2xi64>) : vector<2xi64> + %2 = llvm.and %arg2, %0 : vector<2xi64> + %3 = llvm.lshr %arg0, %2 : vector<2xi64> + %4 = llvm.sub %1, %2 overflow : vector<2xi64> + %5 = llvm.shl %arg1, %4 : vector<2xi64> + %6 = llvm.or %5, %3 : vector<2xi64> + llvm.return %6 : vector<2xi64> + } + llvm.func @fshl_16bit(%arg0: i16, %arg1: i16, %arg2: i32) -> i16 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.and %arg2, %0 : i32 + %3 = llvm.zext %arg0 : i16 to i32 + %4 = llvm.shl %3, %2 : i32 + %5 = llvm.sub %1, %2 : i32 + %6 = llvm.zext %arg1 : i16 to i32 + %7 = llvm.lshr %6, %5 : i32 + %8 = llvm.or %7, %4 : i32 + %9 = llvm.trunc %8 : i32 to i16 + llvm.return %9 : i16 + } + llvm.func @fshl_commute_16bit_vec(%arg0: vector<2xi16>, %arg1: vector<2xi16>, %arg2: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg2, %0 : vector<2xi32> + %3 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %4 = llvm.shl %3, %2 : vector<2xi32> + %5 = llvm.sub %1, %2 : vector<2xi32> + %6 = llvm.zext %arg1 : vector<2xi16> to vector<2xi32> + %7 = llvm.lshr %6, %5 : vector<2xi32> + %8 = llvm.or %4, %7 : vector<2xi32> + %9 = llvm.trunc %8 : vector<2xi32> to vector<2xi16> + llvm.return %9 : vector<2xi16> + } + llvm.func @fshr_8bit(%arg0: i8, %arg1: i8, %arg2: i3) -> i8 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.zext %arg2 : i3 to i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.lshr %2, %1 : i32 + %4 = llvm.sub %0, %1 : i32 + %5 = llvm.zext %arg1 : i8 to i32 + %6 = llvm.shl %5, %4 : i32 + %7 = llvm.or %6, %3 : i32 + %8 = llvm.trunc %7 : i32 to i8 + llvm.return %8 : i8 + } + llvm.func @fshr_commute_8bit(%arg0: i32, %arg1: i32, %arg2: i32) -> i8 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.and %arg2, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.lshr %4, %3 : i32 + %6 = llvm.sub %2, %3 : i32 + %7 = llvm.and %arg1, %1 : i32 + %8 = llvm.shl %7, %6 : i32 + %9 = llvm.or %5, %8 : i32 + %10 = llvm.trunc %9 : i32 to i8 + llvm.return %10 : i8 + } + llvm.func @fshr_commute_8bit_unmasked_shl(%arg0: i32, %arg1: i32, %arg2: i32) -> i8 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.and %arg2, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.lshr %4, %3 : i32 + %6 = llvm.sub %2, %3 : i32 + %7 = llvm.and %arg1, %1 : i32 + %8 = llvm.shl %arg1, %6 : i32 + %9 = llvm.or %5, %8 : i32 + %10 = llvm.trunc %9 : i32 to i8 + llvm.return %10 : i8 + } + llvm.func @fshr_select(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(8 : i8) : i8 + %2 = llvm.icmp "eq" %arg2, %0 : i8 + %3 = llvm.sub %1, %arg2 : i8 + %4 = llvm.lshr %arg1, %arg2 : i8 + %5 = llvm.shl %arg0, %3 : i8 + %6 = llvm.or %5, %4 : i8 + %7 = llvm.select %2, %arg1, %6 : i1, i8 + llvm.return %7 : i8 + } + llvm.func @fshl_select(%arg0: i16, %arg1: i16, %arg2: i16) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(16 : i16) : i16 + %2 = llvm.icmp "eq" %arg2, %0 : i16 + %3 = llvm.sub %1, %arg2 : i16 + %4 = llvm.lshr %arg1, %3 : i16 + %5 = llvm.shl %arg0, %arg2 : i16 + %6 = llvm.or %4, %5 : i16 + %7 = llvm.select %2, %arg0, %6 : i1, i16 + llvm.return %7 : i16 + } + llvm.func @fshl_select_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>, %arg2: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.constant(dense<64> : vector<2xi64>) : vector<2xi64> + %3 = llvm.icmp "eq" %arg2, %1 : vector<2xi64> + %4 = llvm.sub %2, %arg2 : vector<2xi64> + %5 = llvm.lshr %arg0, %4 : vector<2xi64> + %6 = llvm.shl %arg1, %arg2 : vector<2xi64> + %7 = llvm.or %6, %5 : vector<2xi64> + %8 = llvm.select %3, %arg1, %7 : vector<2xi1>, vector<2xi64> + llvm.return %8 : vector<2xi64> + } + llvm.func @fshl_concat_i8_i24(%arg0: i8, %arg1: i24, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.shl %2, %0 : i32 + %4 = llvm.zext %arg1 : i24 to i32 + %5 = llvm.or %4, %3 : i32 + llvm.store %5, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.shl %4, %1 : i32 + %7 = llvm.or %2, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @fshl_concat_i8_i8(%arg0: i8, %arg1: i8, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(13 : i32) : i32 + %1 = llvm.mlir.constant(19 : i32) : i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.shl %2, %0 : i32 + %4 = llvm.zext %arg1 : i8 to i32 + %5 = llvm.or %4, %3 : i32 + llvm.store %5, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.shl %4, %1 : i32 + %7 = llvm.or %2, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @fshl_concat_i8_i8_overlap(%arg0: i8, %arg1: i8, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(25 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.shl %2, %0 : i32 + %4 = llvm.zext %arg1 : i8 to i32 + %5 = llvm.or %4, %3 : i32 + llvm.store %5, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.shl %4, %1 : i32 + %7 = llvm.or %2, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @fshl_concat_i8_i8_drop(%arg0: i8, %arg1: i8, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(25 : i32) : i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.shl %2, %0 : i32 + %4 = llvm.zext %arg1 : i8 to i32 + %5 = llvm.or %4, %3 : i32 + llvm.store %5, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.shl %4, %1 : i32 + %7 = llvm.or %2, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @fshl_concat_i8_i8_different_slot(%arg0: i8, %arg1: i8, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.mlir.constant(22 : i32) : i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.shl %2, %0 : i32 + %4 = llvm.zext %arg1 : i8 to i32 + %5 = llvm.or %4, %3 : i32 + llvm.store %5, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.shl %4, %1 : i32 + %7 = llvm.or %2, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @fshl_concat_unknown_source(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.shl %arg0, %0 : i32 + %2 = llvm.or %arg1, %1 : i32 + llvm.store %2, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.shl %arg1, %0 : i32 + %4 = llvm.or %arg0, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @fshl_concat_vector(%arg0: vector<2xi8>, %arg1: vector<2xi24>, %arg2: !llvm.ptr) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<24> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + %3 = llvm.shl %2, %0 : vector<2xi32> + %4 = llvm.zext %arg1 : vector<2xi24> to vector<2xi32> + %5 = llvm.or %3, %4 : vector<2xi32> + llvm.store %5, %arg2 {alignment = 4 : i64} : vector<2xi32>, !llvm.ptr + %6 = llvm.shl %4, %1 : vector<2xi32> + %7 = llvm.or %6, %2 : vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @unmasked_shlop_unmasked_shift_amount(%arg0: i32, %arg1: i32, %arg2: i32) -> i8 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.sub %1, %arg2 : i32 + %4 = llvm.shl %arg0, %3 : i32 + %5 = llvm.lshr %2, %arg2 : i32 + %6 = llvm.or %4, %5 : i32 + %7 = llvm.trunc %6 : i32 to i8 + llvm.return %7 : i8 + } + llvm.func @unmasked_shlop_insufficient_mask_shift_amount(%arg0: i16, %arg1: i16, %arg2: i16) -> i8 { + %0 = llvm.mlir.constant(15 : i16) : i16 + %1 = llvm.mlir.constant(255 : i16) : i16 + %2 = llvm.mlir.constant(8 : i16) : i16 + %3 = llvm.and %arg2, %0 : i16 + %4 = llvm.and %arg0, %1 : i16 + %5 = llvm.sub %2, %3 : i16 + %6 = llvm.shl %arg1, %5 : i16 + %7 = llvm.lshr %4, %3 : i16 + %8 = llvm.or %6, %7 : i16 + %9 = llvm.trunc %8 : i16 to i8 + llvm.return %9 : i8 + } + llvm.func @unmasked_shlop_masked_shift_amount(%arg0: i16, %arg1: i16, %arg2: i16) -> i8 { + %0 = llvm.mlir.constant(7 : i16) : i16 + %1 = llvm.mlir.constant(255 : i16) : i16 + %2 = llvm.mlir.constant(8 : i16) : i16 + %3 = llvm.and %arg2, %0 : i16 + %4 = llvm.and %arg0, %1 : i16 + %5 = llvm.sub %2, %3 : i16 + %6 = llvm.shl %arg1, %5 : i16 + %7 = llvm.lshr %4, %3 : i16 + %8 = llvm.or %6, %7 : i16 + %9 = llvm.trunc %8 : i16 to i8 + llvm.return %9 : i8 + } + llvm.func @test_rotl_and_neg(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.lshr %arg0, %4 : i32 + %6 = llvm.or %2, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @test_rotl_and_neg_commuted(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.lshr %arg0, %4 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @test_rotr_and_neg(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.shl %arg0, %4 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @test_fshl_and_neg(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.shl %arg0, %arg2 : i32 + %3 = llvm.sub %0, %arg2 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.lshr %arg1, %4 : i32 + %6 = llvm.or %2, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @test_rotl_and_neg_wrong_mask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.lshr %arg0, %4 : i32 + %6 = llvm.or %2, %5 : i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/fwrite-1.ll.mlir b/test/LLVMDialect/InstCombine/fwrite-1.ll.mlir new file mode 100644 index 000000000..fcf521cf1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/fwrite-1.ll.mlir @@ -0,0 +1,45 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @str(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external constant @empty(dense<0> : tensor<0xi8>) {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.func @fwrite(!llvm.ptr, i64, i64, !llvm.ptr) -> i64 + llvm.func @test_simplify1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @str : !llvm.ptr + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.call @fwrite(%2, %3, %3, %arg0) : (!llvm.ptr, i64, i64, !llvm.ptr) -> i64 + llvm.return + } + llvm.func @test_simplify2(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<0> : tensor<0xi8>) : !llvm.array<0 x i8> + %1 = llvm.mlir.addressof @empty : !llvm.ptr + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.call @fwrite(%1, %2, %3, %arg0) : (!llvm.ptr, i64, i64, !llvm.ptr) -> i64 + llvm.return + } + llvm.func @test_simplify3(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<0> : tensor<0xi8>) : !llvm.array<0 x i8> + %1 = llvm.mlir.addressof @empty : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.call @fwrite(%1, %2, %3, %arg0) : (!llvm.ptr, i64, i64, !llvm.ptr) -> i64 + llvm.return + } + llvm.func @test_no_simplify1(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @str : !llvm.ptr + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.call @fwrite(%2, %3, %3, %arg0) : (!llvm.ptr, i64, i64, !llvm.ptr) -> i64 + llvm.return %4 : i64 + } + llvm.func @test_no_simplify2(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @str : !llvm.ptr + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.call @fwrite(%2, %arg1, %3, %arg0) : (!llvm.ptr, i64, i64, !llvm.ptr) -> i64 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/gc.relocate-verify.ll.mlir b/test/LLVMDialect/InstCombine/gc.relocate-verify.ll.mlir index 9e6f5f2fb..d14b2b79c 100644 --- a/test/LLVMDialect/InstCombine/gc.relocate-verify.ll.mlir +++ b/test/LLVMDialect/InstCombine/gc.relocate-verify.ll.mlir @@ -1,14 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.undef"() : () -> !llvm.metadata - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.return"(%2) : (i32) -> () - ^bb1: // no predecessors - %3 = "llvm.call"(%1, %2, %2) {callee = @llvm.experimental.gc.relocate.p1i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.metadata, i32, i32) -> !llvm.ptr - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "check_verify_undef_token", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.experimental.gc.relocate.p1i32", type = !llvm.func (metadata, i32, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @check_verify_undef_token() -> i32 attributes {garbageCollector = "statepoint-example"} { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.return %0 : i32 + } + llvm.func @llvm.experimental.gc.relocate.p1(!llvm.token, i32, i32) -> !llvm.ptr<1> attributes {memory = #llvm.memory_effects, passthrough = ["nocallback", "nofree", "nosync", "nounwind", "willreturn"]} +} diff --git a/test/LLVMDialect/InstCombine/gc.relocate.ll.mlir b/test/LLVMDialect/InstCombine/gc.relocate.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/gep-addrspace.ll.mlir b/test/LLVMDialect/InstCombine/gep-addrspace.ll.mlir new file mode 100644 index 000000000..771112e39 --- /dev/null +++ b/test/LLVMDialect/InstCombine/gep-addrspace.ll.mlir @@ -0,0 +1,54 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal @array(dense<0.000000e+00> : tensor<256xf32>) {addr_space = 3 : i32, alignment = 4 : i64, dso_local} : !llvm.array<256 x f32> + llvm.mlir.global internal @scalar(0.000000e+00 : f32) {addr_space = 3 : i32, alignment = 4 : i64, dso_local} : f32 + llvm.func @func(%arg0: !llvm.ptr<1> {llvm.nocapture}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.undef : f32 + %4 = llvm.addrspacecast %arg0 : !llvm.ptr<1> to !llvm.ptr + %5 = llvm.getelementptr inbounds %4[%0, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"myStruct", (f32, array<3 x f32>, array<4 x f32>, i32)> + %6 = llvm.getelementptr inbounds %5[%0, %2] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<3 x f32> + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %8 = llvm.fsub %7, %3 : f32 + llvm.return + } + llvm.func @keep_necessary_addrspacecast(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : tensor<256xf32>) : !llvm.array<256 x f32> + %2 = llvm.mlir.addressof @array : !llvm.ptr<3> + %3 = llvm.addrspacecast %2 : !llvm.ptr<3> to !llvm.ptr + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.mlir.addressof @scalar : !llvm.ptr<3> + %6 = llvm.addrspacecast %5 : !llvm.ptr<3> to !llvm.ptr + %7 = llvm.getelementptr %3[%4, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<256 x f32> + %8 = llvm.getelementptr %6[%4, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x f32> + llvm.store %7, %arg1 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.store %8, %arg2 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @escape_alloca(!llvm.ptr) + llvm.func @inbounds_after_addrspacecast() -> !llvm.struct<(i8, i8)> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.mlir.undef : !llvm.struct<(i8, i8)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<(i8, i8)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<(i8, i8)> + %7 = llvm.alloca %0 x i16 {alignment = 2 : i64} : (i32) -> !llvm.ptr + llvm.call @escape_alloca(%7) : (!llvm.ptr) -> () + %8 = llvm.addrspacecast %7 : !llvm.ptr to !llvm.ptr<11> + %9 = llvm.getelementptr %8[%1, %2] : (!llvm.ptr<11>, i64, i64) -> !llvm.ptr<11>, !llvm.array<2 x i8> + %10 = llvm.load %9 {alignment = 1 : i64} : !llvm.ptr<11> -> i8 + %11 = llvm.insertvalue %10, %6[1] : !llvm.struct<(i8, i8)> + llvm.return %11 : !llvm.struct<(i8, i8)> + } + llvm.func spir_funccc @my_extern_func() -> vector<16xi32> + llvm.func @bitcast_after_gep(%arg0: !llvm.ptr) { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr to !llvm.ptr<3> + %1 = llvm.call spir_funccc @my_extern_func() : () -> vector<16xi32> + llvm.store %1, %0 {alignment = 64 : i64} : vector<16xi32>, !llvm.ptr<3> + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/gep-alias.ll.mlir b/test/LLVMDialect/InstCombine/gep-alias.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/gep-can-replace-gep-idx-with-zero-typesize.ll.mlir b/test/LLVMDialect/InstCombine/gep-can-replace-gep-idx-with-zero-typesize.ll.mlir index 82670a0ff..3ce985e9b 100644 --- a/test/LLVMDialect/InstCombine/gep-can-replace-gep-idx-with-zero-typesize.ll.mlir +++ b/test/LLVMDialect/InstCombine/gep-can-replace-gep-idx-with-zero-typesize.ll.mlir @@ -1,12 +1,16 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "do_something", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: !llvm.ptr>, %arg2: i64): // no predecessors - %0 = "llvm.getelementptr"(%arg1, %arg2) : (!llvm.ptr>, i64) -> !llvm.ptr> - %1 = "llvm.load"(%0) : (!llvm.ptr>) -> !llvm.vec - "llvm.call"(%1) {callee = @do_something, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "can_replace_gep_idx_with_zero_typesize", type = !llvm.func>, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @do_something(!llvm.vec) + llvm.func @can_replace_gep_idx_with_zero_typesize(%arg0: i64, %arg1: !llvm.ptr, %arg2: i64) { + %0 = llvm.getelementptr %arg1[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.vec + %1 = llvm.load %0 {alignment = 16 : i64} : !llvm.ptr -> !llvm.vec + llvm.call @do_something(%1) : (!llvm.vec) -> () + llvm.return + } + llvm.func @can_replace_gep_idx_with_zero_typesize_2(%arg0: i64, %arg1: !llvm.ptr, %arg2: i64) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.getelementptr %arg1[%arg2, %0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<2 x vec> + %2 = llvm.load %1 {alignment = 16 : i64} : !llvm.ptr -> !llvm.vec + llvm.call @do_something(%2) : (!llvm.vec) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/gep-canonicalize-constant-indices.ll.mlir b/test/LLVMDialect/InstCombine/gep-canonicalize-constant-indices.ll.mlir new file mode 100644 index 000000000..d4755efe6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/gep-canonicalize-constant-indices.ll.mlir @@ -0,0 +1,63 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i1) + llvm.func @basic(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %2 = llvm.getelementptr inbounds %1[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %3 = llvm.getelementptr inbounds %2[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %3 : !llvm.ptr + } + llvm.func @partialConstant1(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%arg1, %0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i32> + %2 = llvm.getelementptr inbounds %arg0[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %2 : !llvm.ptr + } + llvm.func @partialConstant2(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i32> + %2 = llvm.getelementptr inbounds %arg0[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %2 : !llvm.ptr + } + llvm.func @merge(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %3 = llvm.getelementptr inbounds %2[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %4 = llvm.getelementptr inbounds %3[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @nested(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(4 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, vector<3xi32> + %3 = llvm.getelementptr inbounds %2[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.mul %arg1, %arg2 : i64 + %5 = llvm.getelementptr inbounds %3[%1] : (!llvm.ptr, i64) -> !llvm.ptr, vector<5xi32> + %6 = llvm.getelementptr inbounds %5[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i16 + %7 = llvm.getelementptr inbounds %6[%0] : (!llvm.ptr, i64) -> !llvm.ptr, vector<4xi32> + llvm.return %7 : !llvm.ptr + } + llvm.func @multipleUses1(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %2 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %3 = llvm.getelementptr inbounds %1[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %3 : !llvm.ptr + } + llvm.func @multipleUses2(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.addressof @use : !llvm.ptr + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %3 = llvm.getelementptr inbounds %2[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.call %1(%3) : !llvm.ptr, (!llvm.ptr) -> () + llvm.return %3 : !llvm.ptr + } + llvm.func @multipleUses3(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %2 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %3 = llvm.getelementptr inbounds %1[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %3 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/gep-combine-loop-invariant.ll.mlir b/test/LLVMDialect/InstCombine/gep-combine-loop-invariant.ll.mlir index 9da4f1c2d..973c7fdcf 100644 --- a/test/LLVMDialect/InstCombine/gep-combine-loop-invariant.ll.mlir +++ b/test/LLVMDialect/InstCombine/gep-combine-loop-invariant.ll.mlir @@ -1,188 +1,167 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: !llvm.ptr, %arg5: i32, %arg6: i32, %arg7: !llvm.ptr, %arg8: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = -1 : i64} : () -> i64 - %4 = "llvm.zext"(%arg1) : (i32) -> i64 - %5 = "llvm.getelementptr"(%arg7, %4) : (!llvm.ptr, i64) -> !llvm.ptr - %6 = "llvm.zext"(%arg2) : (i32) -> i64 - %7 = "llvm.getelementptr"(%5, %6) : (!llvm.ptr, i64) -> !llvm.ptr - %8 = "llvm.getelementptr"(%7, %3) : (!llvm.ptr, i64) -> !llvm.ptr - %9 = "llvm.bitcast"(%8) : (!llvm.ptr) -> !llvm.ptr - %10 = "llvm.load"(%9) : (!llvm.ptr) -> i32 - %11 = "llvm.icmp"(%10, %arg3) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%11, %2)[^bb5, ^bb1] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: !llvm.ptr {llvm.nocapture, llvm.readnone}, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg5: i32, %arg6: i32, %arg7: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg8: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(-1 : i32) : i32 + %4 = llvm.zext %arg1 : i32 to i64 + %5 = llvm.getelementptr inbounds %arg7[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %6 = llvm.zext %arg2 : i32 to i64 + %7 = llvm.getelementptr inbounds %5[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %8 = llvm.getelementptr inbounds %7[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %9 = llvm.load %8 {alignment = 4 : i64} : !llvm.ptr -> i32 + %10 = llvm.icmp "eq" %9, %arg3 : i32 + llvm.cond_br %10, ^bb5(%1 : i32), ^bb1 ^bb1: // pred: ^bb0 - "llvm.br"(%arg1, %arg6)[^bb3] : (i32, i32) -> () - ^bb2(%12: i32, %13: i32): // pred: ^bb4 - %14 = "llvm.zext"(%13) : (i32) -> i64 - %15 = "llvm.getelementptr"(%arg7, %14) : (!llvm.ptr, i64) -> !llvm.ptr - %16 = "llvm.getelementptr"(%15, %6) : (!llvm.ptr, i64) -> !llvm.ptr - %17 = "llvm.getelementptr"(%16, %3) : (!llvm.ptr, i64) -> !llvm.ptr - %18 = "llvm.bitcast"(%17) : (!llvm.ptr) -> !llvm.ptr - %19 = "llvm.load"(%18) : (!llvm.ptr) -> i32 - %20 = "llvm.icmp"(%19, %arg3) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%20, %2, %13, %12)[^bb5, ^bb3] {operand_segment_sizes = dense<[1, 1, 2]> : vector<3xi32>} : (i1, i32, i32, i32) -> () - ^bb3(%21: i32, %22: i32): // 2 preds: ^bb1, ^bb2 - %23 = "llvm.and"(%21, %arg8) : (i32, i32) -> i32 - %24 = "llvm.zext"(%23) : (i32) -> i64 - %25 = "llvm.getelementptr"(%arg4, %24) : (!llvm.ptr, i64) -> !llvm.ptr - %26 = "llvm.load"(%25) : (!llvm.ptr) -> i32 - %27 = "llvm.icmp"(%26, %arg5) {predicate = 8 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%27, %1)[^bb4, ^bb5] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i32) -> () + llvm.br ^bb3(%arg1, %arg6 : i32, i32) + ^bb2(%11: i32, %12: i32): // pred: ^bb4 + %13 = llvm.zext %12 : i32 to i64 + %14 = llvm.getelementptr inbounds %arg7[%13] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %15 = llvm.getelementptr inbounds %14[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %16 = llvm.getelementptr inbounds %15[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %17 = llvm.load %16 {alignment = 4 : i64} : !llvm.ptr -> i32 + %18 = llvm.icmp "eq" %17, %arg3 : i32 + llvm.cond_br %18, ^bb5(%1 : i32), ^bb3(%12, %11 : i32, i32) + ^bb3(%19: i32, %20: i32): // 2 preds: ^bb1, ^bb2 + %21 = llvm.and %19, %arg8 : i32 + %22 = llvm.zext %21 : i32 to i64 + %23 = llvm.getelementptr inbounds %arg4[%22] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %24 = llvm.load %23 {alignment = 4 : i64} : !llvm.ptr -> i32 + %25 = llvm.icmp "ugt" %24, %arg5 : i32 + llvm.cond_br %25, ^bb4, ^bb5(%2 : i32) ^bb4: // pred: ^bb3 - %28 = "llvm.add"(%22, %0) : (i32, i32) -> i32 - %29 = "llvm.icmp"(%28, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%29, %1, %28, %26)[^bb5, ^bb2] {operand_segment_sizes = dense<[1, 1, 2]> : vector<3xi32>} : (i1, i32, i32, i32) -> () - ^bb5(%30: i32): // 4 preds: ^bb0, ^bb2, ^bb3, ^bb4 - "llvm.return"(%30) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func, i32, i32, i32, ptr, i32, i32, ptr, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "blackhole", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 80 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = dense<7> : vector<2xi64>} : () -> vector<2xi64> - %2 = "llvm.mlir.constant"() {value = dense<21> : vector<2xi64>} : () -> vector<2xi64> - %3 = "llvm.mlir.constant"() {value = dense<[0, 1]> : vector<2xi64>} : () -> vector<2xi64> - %4 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %6 = "llvm.mlir.undef"() : () -> i64 - "llvm.br"()[^bb1] : () -> () + %26 = llvm.add %20, %3 : i32 + %27 = llvm.icmp "eq" %26, %2 : i32 + llvm.cond_br %27, ^bb5(%2 : i32), ^bb2(%26, %24 : i32, i32) + ^bb5(%28: i32): // 4 preds: ^bb0, ^bb2, ^bb3, ^bb4 + llvm.return %28 : i32 + } + llvm.func @blackhole(!llvm.vec<2 x ptr>) + llvm.func @PR37005(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.undef : i64 + %1 = llvm.mlir.constant(6 : i64) : i64 + %2 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mlir.constant(dense<21> : vector<2xi64>) : vector<2xi64> + %4 = llvm.mlir.constant(dense<7> : vector<2xi64>) : vector<2xi64> + %5 = llvm.mlir.constant(80 : i64) : i64 + llvm.br ^bb1 ^bb1: // 2 preds: ^bb0, ^bb1 - %7 = "llvm.getelementptr"(%arg1, %6) : (!llvm.ptr>, i64) -> !llvm.ptr> - %8 = "llvm.getelementptr"(%7, %5) : (!llvm.ptr>, i64) -> !llvm.ptr> - %9 = "llvm.bitcast"(%8) : (!llvm.ptr>) -> !llvm.ptr>> - %10 = "llvm.getelementptr"(%9, %4, %4) : (!llvm.ptr>>, i64, i64) -> !llvm.ptr> - %11 = "llvm.getelementptr"(%10, %3) : (!llvm.ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>> - %12 = "llvm.ptrtoint"(%11) : (!llvm.vec<2 x ptr>>) -> vector<2xi64> - %13 = "llvm.lshr"(%12, %2) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %14 = "llvm.shl"(%13, %1) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %15 = "llvm.getelementptr"(%arg0, %14) : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr> - %16 = "llvm.getelementptr"(%15, %0) : (!llvm.vec<2 x ptr>, i64) -> !llvm.vec<2 x ptr> - "llvm.call"(%16) {callee = @blackhole, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec<2 x ptr>) -> () - "llvm.br"()[^bb1] : () -> () - }) {linkage = 10 : i64, sym_name = "PR37005", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[80, 60]> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 21 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %4 = "llvm.mlir.undef"() : () -> i64 - "llvm.br"()[^bb1] : () -> () + %6 = llvm.getelementptr inbounds %arg1[%0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr + %7 = llvm.getelementptr inbounds %6[%1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr + %8 = llvm.getelementptr inbounds %7[%2] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, !llvm.ptr + %9 = llvm.ptrtoint %8 : !llvm.vec<2 x ptr> to vector<2xi64> + %10 = llvm.lshr %9, %3 : vector<2xi64> + %11 = llvm.shl %10, %4 overflow : vector<2xi64> + %12 = llvm.getelementptr inbounds %arg0[%11] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, i8 + %13 = llvm.getelementptr inbounds %12[%5] : (!llvm.vec<2 x ptr>, i64) -> !llvm.vec<2 x ptr>, i8 + llvm.call @blackhole(%13) : (!llvm.vec<2 x ptr>) -> () + llvm.br ^bb1 + } + llvm.func @PR37005_2(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.undef : i64 + %1 = llvm.mlir.constant(6 : i64) : i64 + %2 = llvm.mlir.constant(21 : i64) : i64 + %3 = llvm.mlir.constant(7 : i64) : i64 + %4 = llvm.mlir.constant(dense<[80, 60]> : vector<2xi64>) : vector<2xi64> + llvm.br ^bb1 ^bb1: // 2 preds: ^bb0, ^bb1 - %5 = "llvm.getelementptr"(%arg1, %4) : (!llvm.ptr>, i64) -> !llvm.ptr> - %6 = "llvm.getelementptr"(%5, %3) : (!llvm.ptr>, i64) -> !llvm.ptr> - %7 = "llvm.ptrtoint"(%6) : (!llvm.ptr>) -> i64 - %8 = "llvm.lshr"(%7, %2) : (i64, i64) -> i64 - %9 = "llvm.shl"(%8, %1) : (i64, i64) -> i64 - %10 = "llvm.getelementptr"(%arg0, %9) : (!llvm.ptr, i64) -> !llvm.ptr - %11 = "llvm.getelementptr"(%10, %0) : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr> - "llvm.call"(%11) {callee = @blackhole, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec<2 x ptr>) -> () - "llvm.br"()[^bb1] : () -> () - }) {linkage = 10 : i64, sym_name = "PR37005_2", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec<2 x ptr>, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 80 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = dense<7> : vector<2xi64>} : () -> vector<2xi64> - %2 = "llvm.mlir.constant"() {value = dense<21> : vector<2xi64>} : () -> vector<2xi64> - %3 = "llvm.mlir.constant"() {value = dense<[0, 1]> : vector<2xi64>} : () -> vector<2xi64> - %4 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %6 = "llvm.mlir.undef"() : () -> i64 - "llvm.br"()[^bb1] : () -> () + %5 = llvm.getelementptr inbounds %arg1[%0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr + %6 = llvm.getelementptr inbounds %5[%1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr + %7 = llvm.ptrtoint %6 : !llvm.ptr to i64 + %8 = llvm.lshr %7, %2 : i64 + %9 = llvm.shl %8, %3 overflow : i64 + %10 = llvm.getelementptr inbounds %arg0[%9] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %11 = llvm.getelementptr inbounds %10[%4] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, i8 + llvm.call @blackhole(%11) : (!llvm.vec<2 x ptr>) -> () + llvm.br ^bb1 + } + llvm.func @PR37005_3(%arg0: !llvm.vec<2 x ptr>, %arg1: !llvm.ptr) { + %0 = llvm.mlir.undef : i64 + %1 = llvm.mlir.constant(6 : i64) : i64 + %2 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mlir.constant(dense<21> : vector<2xi64>) : vector<2xi64> + %4 = llvm.mlir.constant(dense<7> : vector<2xi64>) : vector<2xi64> + %5 = llvm.mlir.constant(80 : i64) : i64 + llvm.br ^bb1 ^bb1: // 2 preds: ^bb0, ^bb1 - %7 = "llvm.getelementptr"(%arg1, %6) : (!llvm.ptr>, i64) -> !llvm.ptr> - %8 = "llvm.getelementptr"(%7, %5) : (!llvm.ptr>, i64) -> !llvm.ptr> - %9 = "llvm.bitcast"(%8) : (!llvm.ptr>) -> !llvm.ptr>> - %10 = "llvm.getelementptr"(%9, %4, %4) : (!llvm.ptr>>, i64, i64) -> !llvm.ptr> - %11 = "llvm.getelementptr"(%10, %3) : (!llvm.ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>> - %12 = "llvm.ptrtoint"(%11) : (!llvm.vec<2 x ptr>>) -> vector<2xi64> - %13 = "llvm.lshr"(%12, %2) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %14 = "llvm.shl"(%13, %1) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %15 = "llvm.getelementptr"(%arg0, %14) : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr> - %16 = "llvm.getelementptr"(%15, %0) : (!llvm.vec<2 x ptr>, i64) -> !llvm.vec<2 x ptr> - "llvm.call"(%16) {callee = @blackhole, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec<2 x ptr>) -> () - "llvm.br"()[^bb1] : () -> () - }) {linkage = 10 : i64, sym_name = "PR37005_3", type = !llvm.func>, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 80 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @PR51485} : () -> !llvm.ptr)>> - %2 = "llvm.bitcast"(%1) : (!llvm.ptr)>>) -> !llvm.ptr - %3 = "llvm.mlir.constant"() {value = dense<7> : vector<2xi64>} : () -> vector<2xi64> - "llvm.br"()[^bb1] : () -> () + %6 = llvm.getelementptr inbounds %arg1[%0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr + %7 = llvm.getelementptr inbounds %6[%1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr + %8 = llvm.getelementptr inbounds %7[%2] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, !llvm.ptr + %9 = llvm.ptrtoint %8 : !llvm.vec<2 x ptr> to vector<2xi64> + %10 = llvm.lshr %9, %3 : vector<2xi64> + %11 = llvm.shl %10, %4 overflow : vector<2xi64> + %12 = llvm.getelementptr inbounds %arg0[%11] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, i8 + %13 = llvm.getelementptr inbounds %12[%5] : (!llvm.vec<2 x ptr>, i64) -> !llvm.vec<2 x ptr>, i8 + llvm.call @blackhole(%13) : (!llvm.vec<2 x ptr>) -> () + llvm.br ^bb1 + } + llvm.func @PR51485(%arg0: vector<2xi64>) { + %0 = llvm.mlir.constant(dense<7> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.addressof @PR51485 : !llvm.ptr + %2 = llvm.mlir.constant(80 : i64) : i64 + llvm.br ^bb1 ^bb1: // 2 preds: ^bb0, ^bb1 - %4 = "llvm.shl"(%arg0, %3) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %5 = "llvm.getelementptr"(%2, %4) : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr> - %6 = "llvm.getelementptr"(%5, %0) : (!llvm.vec<2 x ptr>, i64) -> !llvm.vec<2 x ptr> - "llvm.call"(%6) {callee = @blackhole, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec<2 x ptr>) -> () - "llvm.br"()[^bb1] : () -> () - }) {linkage = 10 : i64, sym_name = "PR51485", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 0.000000e+00 : f32} : () -> f32 - %3 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %4 = "llvm.load"(%arg0) : (!llvm.ptr) -> i64 - %5 = "llvm.getelementptr"(%arg1, %4) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.br"(%3, %2)[^bb1] : (i64, f32) -> () + %3 = llvm.shl %arg0, %0 overflow : vector<2xi64> + %4 = llvm.getelementptr inbounds %1[%3] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, i8 + %5 = llvm.getelementptr inbounds %4[%2] : (!llvm.vec<2 x ptr>, i64) -> !llvm.vec<2 x ptr>, i8 + llvm.call @blackhole(%5) : (!llvm.vec<2 x ptr>) -> () + llvm.br ^bb1 + } + llvm.func @gep_cross_loop(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(16 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + %5 = llvm.getelementptr inbounds %arg1[%4] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + llvm.br ^bb1(%0, %1 : i64, f32) ^bb1(%6: i64, %7: f32): // 2 preds: ^bb0, ^bb3 - %8 = "llvm.icmp"(%6, %1) {predicate = 7 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%8)[^bb3, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %8 = llvm.icmp "ule" %6, %2 : i64 + llvm.cond_br %8, ^bb3, ^bb2 ^bb2: // pred: ^bb1 - "llvm.return"(%7) : (f32) -> () + llvm.return %7 : f32 ^bb3: // pred: ^bb1 - %9 = "llvm.getelementptr"(%5, %6) : (!llvm.ptr, i64) -> !llvm.ptr - %10 = "llvm.load"(%9) : (!llvm.ptr) -> f32 - %11 = "llvm.fadd"(%7, %10) : (f32, f32) -> f32 - %12 = "llvm.add"(%6, %0) : (i64, i64) -> i64 - "llvm.br"(%12, %11)[^bb1] : (i64, f32) -> () - }) {linkage = 10 : i64, sym_name = "gep_cross_loop", type = !llvm.func, ptr, f32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i1, %arg2: i32, %arg3: i32): // no predecessors - %0 = "llvm.zext"(%arg3) : (i32) -> i64 - "llvm.br"()[^bb1] : () -> () + %9 = llvm.getelementptr inbounds %5[%6] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %10 = llvm.load %9 {alignment = 4 : i64} : !llvm.ptr -> f32 + %11 = llvm.fadd %7, %10 {fastmathFlags = #llvm.fastmath} : f32 + %12 = llvm.add %6, %3 overflow : i64 + llvm.br ^bb1(%12, %11 : i64, f32) + } + llvm.func @use(!llvm.ptr) + llvm.func @only_one_inbounds(%arg0: !llvm.ptr, %arg1: i1, %arg2: i32 {llvm.noundef}, %arg3: i32 {llvm.noundef}) { + %0 = llvm.zext %arg3 : i32 to i64 + llvm.br ^bb1 ^bb1: // 2 preds: ^bb0, ^bb1 - %1 = "llvm.zext"(%arg2) : (i32) -> i64 - %2 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - %3 = "llvm.getelementptr"(%2, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%3) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.cond_br"(%arg1)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %1 = llvm.zext %arg2 : i32 to i64 + %2 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.getelementptr %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call @use(%3) : (!llvm.ptr) -> () + llvm.cond_br %arg1, ^bb1, ^bb2 ^bb2: // pred: ^bb1 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "only_one_inbounds", type = !llvm.func, i1, i32, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i1, %arg2: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i64} : () -> i64 - "llvm.br"()[^bb1] : () -> () + llvm.return + } + llvm.func @both_inbounds_one_neg(%arg0: !llvm.ptr, %arg1: i1, %arg2: i32 {llvm.noundef}) { + %0 = llvm.mlir.constant(-1 : i64) : i64 + llvm.br ^bb1 ^bb1: // 2 preds: ^bb0, ^bb1 - %1 = "llvm.zext"(%arg2) : (i32) -> i64 - %2 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - %3 = "llvm.getelementptr"(%2, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%3) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.cond_br"(%arg1)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %1 = llvm.zext %arg2 : i32 to i64 + %2 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call @use(%3) : (!llvm.ptr) -> () + llvm.cond_br %arg1, ^bb1, ^bb2 ^bb2: // pred: ^bb1 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "both_inbounds_one_neg", type = !llvm.func, i1, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i1, %arg2: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - "llvm.br"()[^bb1] : () -> () + llvm.return + } + llvm.func @both_inbounds_pos(%arg0: !llvm.ptr, %arg1: i1, %arg2: i32 {llvm.noundef}) { + %0 = llvm.mlir.constant(1 : i64) : i64 + llvm.br ^bb1 ^bb1: // 2 preds: ^bb0, ^bb1 - %1 = "llvm.zext"(%arg2) : (i32) -> i64 - %2 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - %3 = "llvm.getelementptr"(%2, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%3) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.cond_br"(%arg1)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %1 = llvm.zext %arg2 : i32 to i64 + %2 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call @use(%3) : (!llvm.ptr) -> () + llvm.cond_br %arg1, ^bb1, ^bb2 ^bb2: // pred: ^bb1 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "both_inbounds_pos", type = !llvm.func, i1, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/gep-custom-dl.ll.mlir b/test/LLVMDialect/InstCombine/gep-custom-dl.ll.mlir new file mode 100644 index 000000000..bba4eb120 --- /dev/null +++ b/test/LLVMDialect/InstCombine/gep-custom-dl.ll.mlir @@ -0,0 +1,134 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @Global() {addr_space = 0 : i32} : !llvm.array<10 x i8> + llvm.mlir.global external @global_as2(0 : i32) {addr_space = 2 : i32} : i32 + llvm.mlir.global external @global_as1_as2_ptr() {addr_space = 1 : i32} : !llvm.struct<"as2_ptr_struct", (ptr<2>)> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @global_as2 : !llvm.ptr<2> + %2 = llvm.mlir.undef : !llvm.struct<"as2_ptr_struct", (ptr<2>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"as2_ptr_struct", (ptr<2>)> + llvm.return %3 : !llvm.struct<"as2_ptr_struct", (ptr<2>)> + } + llvm.mlir.global external @arst() {addr_space = 1 : i32} : !llvm.array<4 x ptr<2>> { + %0 = llvm.mlir.zero : !llvm.ptr<2> + %1 = llvm.mlir.undef : !llvm.array<4 x ptr<2>> + %2 = llvm.insertvalue %0, %1[0] : !llvm.array<4 x ptr<2>> + %3 = llvm.insertvalue %0, %2[1] : !llvm.array<4 x ptr<2>> + %4 = llvm.insertvalue %0, %3[2] : !llvm.array<4 x ptr<2>> + %5 = llvm.insertvalue %0, %4[3] : !llvm.array<4 x ptr<2>> + llvm.return %5 : !llvm.array<4 x ptr<2>> + } + llvm.mlir.global external @G() {addr_space = 0 : i32} : !llvm.array<3 x i8> + llvm.mlir.global external @Array() {addr_space = 0 : i32} : !llvm.array<40 x i32> + llvm.mlir.global external @X_as1(dense<0> : tensor<1000xi8>) {addr_space = 1 : i32, alignment = 16 : i64} : !llvm.array<1000 x i8> + llvm.func @test1(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(17 : i8) : i8 + %1 = llvm.mlir.constant(4 : i16) : i16 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i8) -> !llvm.ptr, i32 + %3 = llvm.getelementptr %2[%1] : (!llvm.ptr, i16) -> !llvm.ptr, i32 + llvm.return %3 : !llvm.ptr + } + llvm.func @test2(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i32)> + llvm.return %1 : !llvm.ptr + } + llvm.func @test3(%arg0: i8) { + %0 = llvm.mlir.addressof @Global : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.getelementptr %0[%1, %2] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<10 x i8> + llvm.store %arg0, %3 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } + llvm.func @test_evaluate_gep_nested_as_ptrs(%arg0: !llvm.ptr<2>) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @global_as2 : !llvm.ptr<2> + %2 = llvm.mlir.undef : !llvm.struct<"as2_ptr_struct", (ptr<2>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"as2_ptr_struct", (ptr<2>)> + %4 = llvm.mlir.addressof @global_as1_as2_ptr : !llvm.ptr<1> + llvm.store %arg0, %4 {alignment = 8 : i64} : !llvm.ptr<2>, !llvm.ptr<1> + llvm.return + } + llvm.func @test_evaluate_gep_as_ptrs_array(%arg0: !llvm.ptr<2>) { + %0 = llvm.mlir.zero : !llvm.ptr<2> + %1 = llvm.mlir.undef : !llvm.array<4 x ptr<2>> + %2 = llvm.insertvalue %0, %1[0] : !llvm.array<4 x ptr<2>> + %3 = llvm.insertvalue %0, %2[1] : !llvm.array<4 x ptr<2>> + %4 = llvm.insertvalue %0, %3[2] : !llvm.array<4 x ptr<2>> + %5 = llvm.insertvalue %0, %4[3] : !llvm.array<4 x ptr<2>> + %6 = llvm.mlir.addressof @arst : !llvm.ptr<1> + %7 = llvm.mlir.constant(0 : i16) : i16 + %8 = llvm.mlir.constant(2 : i16) : i16 + %9 = llvm.getelementptr %6[%7, %8] : (!llvm.ptr<1>, i16, i16) -> !llvm.ptr<1>, !llvm.array<4 x ptr<2>> + llvm.store %arg0, %9 {alignment = 8 : i64} : !llvm.ptr<2>, !llvm.ptr<1> + llvm.return + } + llvm.func @test4(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> !llvm.ptr { + %0 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %1 = llvm.getelementptr %0[%arg2] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.return %1 : !llvm.ptr + } + llvm.func @test5(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.getelementptr %arg0[%0, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i32, i32)> + %3 = llvm.getelementptr %arg1[%0, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i32, i32)> + %4 = llvm.icmp "eq" %2, %3 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @test6(%arg0: vector<2xi32>, %arg1: !llvm.vec<2 x ptr>) -> vector<2xi1> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.getelementptr inbounds %arg1[%1, 1, %arg0] : (!llvm.vec<2 x ptr>, vector<2xi32>, vector<2xi32>) -> !llvm.vec<2 x ptr>, !llvm.struct<"S", (i32, array<100 x i32>)> + %4 = llvm.getelementptr inbounds %arg1[%1, 0] : (!llvm.vec<2 x ptr>, vector<2xi32>) -> !llvm.vec<2 x ptr>, !llvm.struct<"S", (i32, array<100 x i32>)> + %5 = llvm.icmp "eq" %3, %4 : !llvm.vec<2 x ptr> + llvm.return %5 : vector<2xi1> + } + llvm.func @test6b(%arg0: vector<2xi32>, %arg1: !llvm.vec<2 x ptr>) -> vector<2xi1> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.getelementptr inbounds %arg1[%0, 1, %arg0] : (!llvm.vec<2 x ptr>, i32, vector<2xi32>) -> !llvm.vec<2 x ptr>, !llvm.struct<"S", (i32, array<100 x i32>)> + %3 = llvm.getelementptr inbounds %arg1[%0, 0] : (!llvm.vec<2 x ptr>, i32) -> !llvm.vec<2 x ptr>, !llvm.struct<"S", (i32, array<100 x i32>)> + %4 = llvm.icmp "eq" %2, %3 : !llvm.vec<2 x ptr> + llvm.return %4 : vector<2xi1> + } + llvm.func @test7(%arg0: i16) -> !llvm.ptr { + %0 = llvm.mlir.addressof @G : !llvm.ptr + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.getelementptr %0[%1] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + llvm.return %2 : !llvm.ptr + } + llvm.func @test8(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.addressof @Array : !llvm.ptr + %1 = llvm.getelementptr %0[%arg0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.return %1 : !llvm.ptr + } + llvm.func @test9(%arg0: !llvm.ptr, %arg1: i8) -> !llvm.ptr { + %0 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, i8) -> !llvm.ptr, i32 + llvm.return %0 : !llvm.ptr + } + llvm.func @test10() -> i32 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.getelementptr %0[%1, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i32, f64)> + %4 = llvm.ptrtoint %3 : !llvm.ptr to i32 + llvm.return %4 : i32 + } + llvm.func @constant_fold_custom_dl() -> i16 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(dense<0> : tensor<1000xi8>) : !llvm.array<1000 x i8> + %4 = llvm.mlir.addressof @X_as1 : !llvm.ptr<1> + %5 = llvm.getelementptr inbounds %4[%1, %0] : (!llvm.ptr<1>, i64, i64) -> !llvm.ptr<1>, !llvm.array<1000 x i8> + %6 = llvm.mlir.constant(0 : i16) : i16 + %7 = llvm.bitcast %5 : !llvm.ptr<1> to !llvm.ptr<1> + %8 = llvm.ptrtoint %4 : !llvm.ptr<1> to i16 + %9 = llvm.sub %6, %8 : i16 + %10 = llvm.getelementptr %7[%9] : (!llvm.ptr<1>, i16) -> !llvm.ptr<1>, i8 + %11 = llvm.ptrtoint %10 : !llvm.ptr<1> to i16 + llvm.return %11 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/gep-inbounds-null.ll.mlir b/test/LLVMDialect/InstCombine/gep-inbounds-null.ll.mlir new file mode 100644 index 000000000..5fe8db22e --- /dev/null +++ b/test/LLVMDialect/InstCombine/gep-inbounds-null.ll.mlir @@ -0,0 +1,131 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_ne_constants_null() -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "ne" %0, %0 : !llvm.ptr + llvm.return %1 : i1 + } + llvm.func @test_ne_constants_nonnull() -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr inbounds %0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.icmp "ne" %2, %0 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @test_eq_constants_null() -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "eq" %0, %0 : !llvm.ptr + llvm.return %1 : i1 + } + llvm.func @test_eq_constants_nonnull() -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr inbounds %0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.icmp "eq" %2, %0 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @test_ne(%arg0: !llvm.ptr, %arg1: i64) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %2 = llvm.icmp "ne" %1, %0 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @test_eq(%arg0: !llvm.ptr, %arg1: i64) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %2 = llvm.icmp "eq" %1, %0 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @test_vector_base(%arg0: !llvm.vec<2 x ptr>, %arg1: i64) -> vector<2xi1> { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec<2 x ptr> + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec<2 x ptr> + %6 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.vec<2 x ptr>, i64) -> !llvm.vec<2 x ptr>, i8 + %7 = llvm.icmp "eq" %6, %5 : !llvm.vec<2 x ptr> + llvm.return %7 : vector<2xi1> + } + llvm.func @test_vector_index(%arg0: !llvm.ptr, %arg1: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec<2 x ptr> + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec<2 x ptr> + %6 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, i8 + %7 = llvm.icmp "eq" %6, %5 : !llvm.vec<2 x ptr> + llvm.return %7 : vector<2xi1> + } + llvm.func @test_vector_both(%arg0: !llvm.vec<2 x ptr>, %arg1: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec<2 x ptr> + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec<2 x ptr> + %6 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, i8 + %7 = llvm.icmp "eq" %6, %5 : !llvm.vec<2 x ptr> + llvm.return %7 : vector<2xi1> + } + llvm.func @test_eq_pos_idx(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.icmp "eq" %2, %1 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @test_eq_neg_idx(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.icmp "eq" %2, %1 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @test_size0(%arg0: !llvm.ptr, %arg1: i64) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<()> + %2 = llvm.icmp "ne" %1, %0 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @test_size0_nonzero_offset(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(15 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<()> + %3 = llvm.icmp "ne" %2, %1 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @test_index_type(%arg0: !llvm.ptr, %arg1: i64) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.getelementptr inbounds %arg0[%arg1, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<10 x i8> + %2 = llvm.icmp "eq" %1, %0 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @neq_noinbounds(%arg0: !llvm.ptr, %arg1: i64) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %2 = llvm.icmp "ne" %1, %0 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @neg_objectatnull(%arg0: !llvm.ptr<2>, %arg1: i64) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr<2> + %1 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr<2>, i64) -> !llvm.ptr<2>, i8 + %2 = llvm.icmp "eq" %1, %0 : !llvm.ptr<2> + llvm.return %2 : i1 + } + llvm.func @invalid_bitcast_icmp_addrspacecast_as0_null(%arg0: !llvm.ptr<5>) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.addrspacecast %1 : !llvm.ptr to !llvm.ptr<5> + %3 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr<5>, i32) -> !llvm.ptr<5>, i32 + %4 = llvm.icmp "eq" %3, %2 : !llvm.ptr<5> + llvm.return %4 : i1 + } + llvm.func @invalid_bitcast_icmp_addrspacecast_as0_null_var(%arg0: !llvm.ptr<5>, %arg1: i32) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.addrspacecast %0 : !llvm.ptr to !llvm.ptr<5> + %2 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr<5>, i32) -> !llvm.ptr<5>, i32 + %3 = llvm.icmp "eq" %2, %1 : !llvm.ptr<5> + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/gep-merge-constant-indices.ll.mlir b/test/LLVMDialect/InstCombine/gep-merge-constant-indices.ll.mlir new file mode 100644 index 000000000..04e0c3c13 --- /dev/null +++ b/test/LLVMDialect/InstCombine/gep-merge-constant-indices.ll.mlir @@ -0,0 +1,118 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @mergeBasic(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %3 : !llvm.ptr + } + llvm.func @mergeDifferentTypes(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.return %3 : !llvm.ptr + } + llvm.func @mergeReverse(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.return %3 : !llvm.ptr + } + llvm.func @zeroSum(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(-4 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.return %3 : !llvm.ptr + } + llvm.func @array1(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0, %0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<20 x i8> + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.return %3 : !llvm.ptr + } + llvm.func @array2(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + %3 = llvm.getelementptr inbounds %2[%1, %1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<3 x i8> + llvm.return %3 : !llvm.ptr + } + llvm.func @struct1(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct.C", (i8, i32, i32)> + llvm.return %3 : !llvm.ptr + } + llvm.func @struct2(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-128 : i64) : i64 + %3 = llvm.getelementptr inbounds %arg0[%0, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct.A", (array<123 x i8>, i32)> + %4 = llvm.getelementptr inbounds %3[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.return %4 : !llvm.ptr + } + llvm.func @structStruct(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(3 : i64) : i64 + %4 = llvm.mlir.constant(4 : i64) : i64 + %5 = llvm.getelementptr inbounds %arg0[%0, 2, 0, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.struct<"struct.B", (i8, array<3 x i16>, struct<"struct.A", (array<123 x i8>, i32)>, f32)> + %6 = llvm.getelementptr inbounds %5[%0, 0, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.struct<"struct.A", (array<123 x i8>, i32)> + llvm.return %6 : !llvm.ptr + } + llvm.func @appendIndex(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%arg1, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct.B", (i8, array<3 x i16>, struct<"struct.A", (array<123 x i8>, i32)>, f32)> + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %3 : !llvm.ptr + } + llvm.func @notDivisible(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i24 + %2 = llvm.getelementptr inbounds %1[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %2 : !llvm.ptr + } + llvm.func @partialConstant2(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %3 = llvm.getelementptr inbounds %2[%arg1, %1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i64> + llvm.return %3 : !llvm.ptr + } + llvm.func @partialConstant3(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %3 = llvm.ptrtoint %2 : !llvm.ptr to i64 + %4 = llvm.getelementptr inbounds %2[%3, %1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i64> + llvm.return %4 : !llvm.ptr + } + llvm.func @partialConstantMemberAliasing1(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%arg1, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct.C", (i8, i32, i32)> + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %3 : !llvm.ptr + } + llvm.func @partialConstantMemberAliasing2(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%arg1, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct.C", (i8, i32, i32)> + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.return %3 : !llvm.ptr + } + llvm.func @partialConstantMemberAliasing3(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%arg1, 2] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct.C", (i8, i32, i32)> + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %3 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/gep-object-size-less-than-or-equal-typesize.ll.mlir b/test/LLVMDialect/InstCombine/gep-object-size-less-than-or-equal-typesize.ll.mlir new file mode 100644 index 000000000..2aac689cb --- /dev/null +++ b/test/LLVMDialect/InstCombine/gep-object-size-less-than-or-equal-typesize.ll.mlir @@ -0,0 +1,10 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: !llvm.vec, %arg1: i64) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.vec {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %1 {alignment = 1 : i64} : !llvm.vec, !llvm.ptr + %2 = llvm.getelementptr %1[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.load %2 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/gep-sext.ll.mlir b/test/LLVMDialect/InstCombine/gep-sext.ll.mlir index 74223ae86..e2dae2737 100644 --- a/test/LLVMDialect/InstCombine/gep-sext.ll.mlir +++ b/test/LLVMDialect/InstCombine/gep-sext.ll.mlir @@ -1,45 +1,39 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.getelementptr"(%arg0, %arg1) : (!llvm.ptr, i32) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> i32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.zext"(%arg1) : (i32) -> i64 - %1 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - %2 = "llvm.load"(%1) : (!llvm.ptr) -> i32 - "llvm.call"(%2) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 48 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 40 : i64} : () -> i64 - %2 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - %3 = "llvm.getelementptr"(%2, %0) : (!llvm.ptr, i64) -> !llvm.ptr - %4 = "llvm.load"(%3) : (!llvm.ptr) -> i32 - %5 = "llvm.getelementptr"(%2, %4) : (!llvm.ptr, i32) -> !llvm.ptr - %6 = "llvm.load"(%5) : (!llvm.ptr) -> i32 - "llvm.call"(%6) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 48 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 40 : i64} : () -> i64 - %2 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - %3 = "llvm.getelementptr"(%2, %0) : (!llvm.ptr, i64) -> !llvm.ptr - %4 = "llvm.load"(%3) : (!llvm.ptr) -> i32 - %5 = "llvm.sext"(%4) : (i32) -> i64 - %6 = "llvm.getelementptr"(%2, %5) : (!llvm.ptr, i64) -> !llvm.ptr - %7 = "llvm.load"(%6) : (!llvm.ptr) -> i32 - "llvm.call"(%7) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) attributes {memory = #llvm.memory_effects} + llvm.func @test(%arg0: !llvm.ptr, %arg1: i32) { + %0 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %1 = llvm.load %0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.call @use(%1) : (i32) -> () + llvm.return + } + llvm.func @test2(%arg0: !llvm.ptr, %arg1: i32) { + %0 = llvm.zext %arg1 : i32 to i64 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.call @use(%2) : (i32) -> () + llvm.return + } + llvm.func @test3(%arg0: !llvm.ptr, %arg1: i32) { + %0 = llvm.mlir.constant(40 : i64) : i64 + %1 = llvm.mlir.constant(48 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %3 = llvm.getelementptr %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + %5 = llvm.getelementptr %2[%4] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %6 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.call @use(%6) : (i32) -> () + llvm.return + } + llvm.func @test4(%arg0: !llvm.ptr, %arg1: i32) { + %0 = llvm.mlir.constant(40 : i64) : i64 + %1 = llvm.mlir.constant(48 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %3 = llvm.getelementptr %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + %5 = llvm.sext %4 : i32 to i64 + %6 = llvm.getelementptr %2[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.call @use(%7) : (i32) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/gep-vector-indices.ll.mlir b/test/LLVMDialect/InstCombine/gep-vector-indices.ll.mlir new file mode 100644 index 000000000..34a925346 --- /dev/null +++ b/test/LLVMDialect/InstCombine/gep-vector-indices.ll.mlir @@ -0,0 +1,92 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @vector_splat_indices_v2i64_ext0(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(dense<4> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %3 = llvm.extractelement %2[%1 : i32] : !llvm.vec<2 x ptr> + llvm.return %3 : !llvm.ptr + } + llvm.func @vector_splat_indices_nxv2i64_ext0(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(4 : i64) : i64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %1, %0[%2 : i32] : !llvm.vec + %4 = llvm.shufflevector %3, %0 [0, 0] : !llvm.vec + %5 = llvm.getelementptr inbounds %arg0[%4] : (!llvm.ptr, vector<[2]xi64>) -> !llvm.vec, i32 + %6 = llvm.extractelement %5[%2 : i32] : !llvm.vec + llvm.return %6 : !llvm.ptr + } + llvm.func @vector_indices_v2i64_ext0(%arg0: !llvm.ptr, %arg1: vector<2xi64>) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %2 = llvm.extractelement %1[%0 : i32] : !llvm.vec<2 x ptr> + llvm.return %2 : !llvm.ptr + } + llvm.func @vector_indices_nxv1i64_ext0(%arg0: !llvm.ptr, %arg1: !llvm.vec) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, !llvm.vec) -> !llvm.vec, i32 + %2 = llvm.extractelement %1[%0 : i32] : !llvm.vec + llvm.return %2 : !llvm.ptr + } + llvm.func @vector_splat_ptrs_v2i64_ext0(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.poison : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %3 = llvm.shufflevector %2, %0 [0, 0] : !llvm.vec<2 x ptr> + %4 = llvm.getelementptr %3[%arg1] : (!llvm.vec<2 x ptr>, i64) -> !llvm.vec<2 x ptr>, i32 + %5 = llvm.extractelement %4[%1 : i32] : !llvm.vec<2 x ptr> + llvm.return %5 : !llvm.ptr + } + llvm.func @vector_splat_ptrs_nxv2i64_ext0(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec + %3 = llvm.shufflevector %2, %0 [0, 0] : !llvm.vec + %4 = llvm.getelementptr %3[%arg1] : (!llvm.vec, i64) -> !llvm.vec, i32 + %5 = llvm.extractelement %4[%1 : i32] : !llvm.vec + llvm.return %5 : !llvm.ptr + } + llvm.func @vector_struct1_splat_indices_v4i64_ext1(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(dense<4> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.getelementptr %arg0[%0, 0] : (!llvm.ptr, vector<4xi32>) -> !llvm.vec<4 x ptr>, !llvm.struct<(f32, f32)> + %4 = llvm.extractelement %3[%2 : i32] : !llvm.vec<4 x ptr> + llvm.return %4 : !llvm.ptr + } + llvm.func @vector_struct2_splat_indices_v4i64_ext1(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<4> : vector<4xi32>) : vector<4xi32> + %3 = llvm.getelementptr %arg0[%0, 1, %2] : (!llvm.ptr, i32, vector<4xi32>) -> !llvm.vec<4 x ptr>, !llvm.struct<(f32, array<8 x f32>)> + %4 = llvm.extractelement %3[%1 : i32] : !llvm.vec<4 x ptr> + llvm.return %4 : !llvm.ptr + } + llvm.func @vector_indices_nxv2i64_ext3(%arg0: !llvm.ptr, %arg1: !llvm.vec) -> !llvm.ptr { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, !llvm.vec) -> !llvm.vec, i32 + %2 = llvm.extractelement %1[%0 : i32] : !llvm.vec + llvm.return %2 : !llvm.ptr + } + llvm.func @vector_indices_nxv2i64_extN(%arg0: !llvm.ptr, %arg1: !llvm.vec, %arg2: i32) -> !llvm.ptr { + %0 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, !llvm.vec) -> !llvm.vec, i32 + %1 = llvm.extractelement %0[%arg2 : i32] : !llvm.vec + llvm.return %1 : !llvm.ptr + } + llvm.func @vector_indices_nxv2i64_mulitple_use(%arg0: !llvm.ptr, %arg1: !llvm.vec, %arg2: !llvm.ptr, %arg3: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, !llvm.vec) -> !llvm.vec, i32 + %3 = llvm.extractelement %2[%0 : i32] : !llvm.vec + %4 = llvm.extractelement %2[%1 : i32] : !llvm.vec + llvm.store %3, %arg2 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.store %4, %arg3 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @vector_ptrs_and_indices_ext0(%arg0: !llvm.vec, %arg1: !llvm.vec) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.getelementptr %arg0[%arg1] : (!llvm.vec, !llvm.vec) -> !llvm.vec, i32 + %2 = llvm.extractelement %1[%0 : i32] : !llvm.vec + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/gep-vector.ll.mlir b/test/LLVMDialect/InstCombine/gep-vector.ll.mlir new file mode 100644 index 000000000..bc5467b37 --- /dev/null +++ b/test/LLVMDialect/InstCombine/gep-vector.ll.mlir @@ -0,0 +1,84 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @block(dense<0> : tensor<64x8192xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<64 x array<8192 x i8>> + llvm.func @vectorindex1() -> !llvm.vec<2 x ptr> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<8192xi8>) : !llvm.array<8192 x i8> + %2 = llvm.mlir.constant(dense<0> : tensor<64x8192xi8>) : !llvm.array<64 x array<8192 x i8>> + %3 = llvm.mlir.addressof @block : !llvm.ptr + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %6 = llvm.mlir.constant(8192 : i64) : i64 + %7 = llvm.getelementptr inbounds %3[%4, %5, %6] : (!llvm.ptr, i64, vector<2xi64>, i64) -> !llvm.vec<2 x ptr>, !llvm.array<64 x array<8192 x i8>> + llvm.return %7 : !llvm.vec<2 x ptr> + } + llvm.func @vectorindex2() -> !llvm.vec<2 x ptr> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<8192xi8>) : !llvm.array<8192 x i8> + %2 = llvm.mlir.constant(dense<0> : tensor<64x8192xi8>) : !llvm.array<64 x array<8192 x i8>> + %3 = llvm.mlir.addressof @block : !llvm.ptr + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.mlir.constant(1 : i64) : i64 + %6 = llvm.mlir.constant(dense<[8191, 8193]> : vector<2xi64>) : vector<2xi64> + %7 = llvm.getelementptr inbounds %3[%4, %5, %6] : (!llvm.ptr, i64, i64, vector<2xi64>) -> !llvm.vec<2 x ptr>, !llvm.array<64 x array<8192 x i8>> + llvm.return %7 : !llvm.vec<2 x ptr> + } + llvm.func @vectorindex3() -> !llvm.vec<2 x ptr> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<8192xi8>) : !llvm.array<8192 x i8> + %2 = llvm.mlir.constant(dense<0> : tensor<64x8192xi8>) : !llvm.array<64 x array<8192 x i8>> + %3 = llvm.mlir.addressof @block : !llvm.ptr + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %6 = llvm.mlir.constant(dense<[8191, 8193]> : vector<2xi64>) : vector<2xi64> + %7 = llvm.getelementptr inbounds %3[%4, %5, %6] : (!llvm.ptr, i64, vector<2xi64>, vector<2xi64>) -> !llvm.vec<2 x ptr>, !llvm.array<64 x array<8192 x i8>> + llvm.return %7 : !llvm.vec<2 x ptr> + } + llvm.func @bitcast_vec_to_array_gep(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.getelementptr %arg0[%arg1, %arg2] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i32> + llvm.return %0 : !llvm.ptr + } + llvm.func @bitcast_array_to_vec_gep(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.getelementptr inbounds %arg0[%arg1, %arg2] : (!llvm.ptr, i64, i64) -> !llvm.ptr, vector<3xi32> + llvm.return %0 : !llvm.ptr + } + llvm.func @bitcast_vec_to_array_gep_matching_alloc_size(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.getelementptr %arg0[%arg1, %arg2] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i32> + llvm.return %0 : !llvm.ptr + } + llvm.func @bitcast_array_to_vec_gep_matching_alloc_size(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.getelementptr inbounds %arg0[%arg1, %arg2] : (!llvm.ptr, i64, i64) -> !llvm.ptr, vector<4xi32> + llvm.return %0 : !llvm.ptr + } + llvm.func @bitcast_vec_to_array_addrspace(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr<3> { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr to !llvm.ptr<3> + %1 = llvm.getelementptr %0[%arg1, %arg2] : (!llvm.ptr<3>, i64, i64) -> !llvm.ptr<3>, !llvm.array<7 x i32> + llvm.return %1 : !llvm.ptr<3> + } + llvm.func @inbounds_bitcast_vec_to_array_addrspace(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr<3> { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr to !llvm.ptr<3> + %1 = llvm.getelementptr inbounds %0[%arg1, %arg2] : (!llvm.ptr<3>, i64, i64) -> !llvm.ptr<3>, !llvm.array<7 x i32> + llvm.return %1 : !llvm.ptr<3> + } + llvm.func @bitcast_vec_to_array_addrspace_matching_alloc_size(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr<3> { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr to !llvm.ptr<3> + %1 = llvm.getelementptr %0[%arg1, %arg2] : (!llvm.ptr<3>, i64, i64) -> !llvm.ptr<3>, !llvm.array<4 x i32> + llvm.return %1 : !llvm.ptr<3> + } + llvm.func @inbounds_bitcast_vec_to_array_addrspace_matching_alloc_size(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr<3> { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr to !llvm.ptr<3> + %1 = llvm.getelementptr inbounds %0[%arg1, %arg2] : (!llvm.ptr<3>, i64, i64) -> !llvm.ptr<3>, !llvm.array<4 x i32> + llvm.return %1 : !llvm.ptr<3> + } + llvm.func @test_accumulate_constant_offset_vscale_nonzero(%arg0: !llvm.vec, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(4 : i64) : i64 + %2 = llvm.getelementptr %arg1[%0, %1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.vec + llvm.return %2 : !llvm.ptr + } + llvm.func @test_accumulate_constant_offset_vscale_zero(%arg0: !llvm.vec, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(4 : i64) : i64 + %2 = llvm.getelementptr %arg1[%0, %1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.vec + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/gepgep.ll.mlir b/test/LLVMDialect/InstCombine/gepgep.ll.mlir index d364787f2..a5a837371 100644 --- a/test/LLVMDialect/InstCombine/gepgep.ll.mlir +++ b/test/LLVMDialect/InstCombine/gepgep.ll.mlir @@ -1,22 +1,15 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "buffer", type = !llvm.array<64 x f32>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 64 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 63 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @buffer} : () -> !llvm.ptr> - %3 = "llvm.ptrtoint"(%2) : (!llvm.ptr>) -> i64 - %4 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %5 = "llvm.sub"(%4, %3) : (i64, i64) -> i64 - %6 = "llvm.and"(%5, %1) : (i64, i64) -> i64 - %7 = "llvm.add"(%6, %0) : (i64, i64) -> i64 - %8 = "llvm.mlir.addressof"() {global_name = @buffer} : () -> !llvm.ptr> - %9 = "llvm.bitcast"(%8) : (!llvm.ptr>) -> !llvm.ptr - %10 = "llvm.getelementptr"(%9, %7) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%10) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @buffer() {addr_space = 0 : i32} : !llvm.array<64 x f32> + llvm.func @use(!llvm.ptr) + llvm.func @f() { + %0 = llvm.mlir.constant(127 : i64) : i64 + %1 = llvm.mlir.addressof @buffer : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.sub %3, %2 : i64 + %5 = llvm.add %4, %0 : i64 + %6 = llvm.getelementptr %1[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call @use(%6) : (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/gepofconstgepi8.ll.mlir b/test/LLVMDialect/InstCombine/gepofconstgepi8.ll.mlir new file mode 100644 index 000000000..5235cf1d3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/gepofconstgepi8.ll.mlir @@ -0,0 +1,150 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use64(i64) + llvm.func @useptr(!llvm.ptr) + llvm.func @test_zero(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.add %arg1, %1 : i64 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_nonzero(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.add %arg1, %1 : i64 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_or_disjoint(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.or %arg1, %1 : i64 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_zero_multiuse_index(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.add %arg1, %1 : i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_zero_multiuse_ptr(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call @useptr(%2) : (!llvm.ptr) -> () + %3 = llvm.add %arg1, %1 : i64 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_zero_sext_add_nsw(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.add %arg1, %1 overflow : i32 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_zero_trunc_add(%arg0: !llvm.ptr, %arg1: i128) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(1 : i128) : i128 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.add %arg1, %1 : i128 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i128) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_non_i8(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i16 + %3 = llvm.add %arg1, %1 : i64 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_non_const(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.getelementptr %arg0[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %2 = llvm.add %arg1, %0 : i64 + %3 = llvm.getelementptr %1[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %3 : !llvm.ptr + } + llvm.func @test_too_many_indices(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.getelementptr %arg0[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %2 = llvm.add %arg1, %0 : i64 + %3 = llvm.getelementptr %1[%0, %2] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i32> + llvm.return %3 : !llvm.ptr + } + llvm.func @test_wrong_op(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.xor %arg1, %1 : i64 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_sext_add_without_nsw(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.add %arg1, %1 : i32 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_or_without_disjoint(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.or %arg1, %1 : i64 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_smul_overflow(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(9223372036854775806 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.add %arg1, %1 : i64 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_sadd_overflow(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(9223372036854775804 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.add %arg1, %1 : i64 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_nonzero_multiuse_index(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.add %arg1, %1 : i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_nonzero_multiuse_ptr(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call @useptr(%2) : (!llvm.ptr) -> () + %3 = llvm.add %arg1, %1 : i64 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.return %4 : !llvm.ptr + } + llvm.func @test_scalable(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.add %arg1, %1 : i64 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.vec + llvm.return %4 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/gepphigep.ll.mlir b/test/LLVMDialect/InstCombine/gepphigep.ll.mlir index d63ae3a15..a55fbb372 100644 --- a/test/LLVMDialect/InstCombine/gepphigep.ll.mlir +++ b/test/LLVMDialect/InstCombine/gepphigep.ll.mlir @@ -1,146 +1,124 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "_ZTIi", type = !llvm.ptr} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = ".str.4", type = !llvm.array<100 x i8>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, i32, i32, i32)>>, %arg1: i1, %arg2: i64, %arg3: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.getelementptr"(%arg0, %2, %1) : (!llvm.ptr>, i32, i32, i32)>>, i64, i32) -> !llvm.ptr>> - %4 = "llvm.load"(%3) : (!llvm.ptr>>) -> !llvm.ptr> - "llvm.cond_br"(%arg1)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @_ZTIi() {addr_space = 0 : i32} : !llvm.ptr + llvm.mlir.global external unnamed_addr constant @".str.4"() {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<100 x i8> + llvm.func @test1(%arg0: !llvm.ptr, %arg1: i1, %arg2: i64, %arg3: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.cond_br %arg1, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %5 = "llvm.getelementptr"(%4, %arg2) : (!llvm.ptr>, i64) -> !llvm.ptr> - %6 = "llvm.getelementptr"(%5, %2, %1) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - "llvm.store"(%1, %6) : (i32, !llvm.ptr) -> () - "llvm.br"(%5)[^bb3] : (!llvm.ptr>) -> () + %4 = llvm.getelementptr inbounds %3[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct2", (i32, i32)> + llvm.store %0, %4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3(%4 : !llvm.ptr) ^bb2: // pred: ^bb0 - %7 = "llvm.getelementptr"(%4, %arg3) : (!llvm.ptr>, i64) -> !llvm.ptr> - %8 = "llvm.getelementptr"(%7, %2, %1) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - "llvm.store"(%1, %8) : (i32, !llvm.ptr) -> () - "llvm.br"(%7)[^bb3] : (!llvm.ptr>) -> () - ^bb3(%9: !llvm.ptr>): // 2 preds: ^bb1, ^bb2 - %10 = "llvm.getelementptr"(%9, %2, %0) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - %11 = "llvm.load"(%10) : (!llvm.ptr) -> i32 - "llvm.return"(%11) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func>, i32, i32, i32)>>, i1, i64, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, i32, i32, i32)>>, %arg1: i1, %arg2: i64, %arg3: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.getelementptr"(%arg0, %2, %1) : (!llvm.ptr>, i32, i32, i32)>>, i64, i32) -> !llvm.ptr>> - %4 = "llvm.load"(%3) : (!llvm.ptr>>) -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %arg2) : (!llvm.ptr>, i64) -> !llvm.ptr> - %6 = "llvm.getelementptr"(%5, %2, %1) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - "llvm.store"(%1, %6) : (i32, !llvm.ptr) -> () - %7 = "llvm.getelementptr"(%4, %arg3) : (!llvm.ptr>, i64) -> !llvm.ptr> - %8 = "llvm.getelementptr"(%7, %2, %1) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - "llvm.store"(%1, %8) : (i32, !llvm.ptr) -> () - %9 = "llvm.getelementptr"(%5, %2, %0) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - %10 = "llvm.load"(%9) : (!llvm.ptr) -> i32 - "llvm.return"(%10) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func>, i32, i32, i32)>>, i1, i64, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, struct<"struct2", (i32, i32)>)>, struct<"struct4", (struct<"struct2", (i32, i32)>, struct<"struct2", (i32, i32)>)>)>>, %arg1: i1, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @_ZTIi} : () -> !llvm.ptr> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.mlir.constant"() {value = 11 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %6 = "llvm.getelementptr"(%arg0, %5) : (!llvm.ptr, struct<"struct2", (i32, i32)>)>, struct<"struct4", (struct<"struct2", (i32, i32)>, struct<"struct2", (i32, i32)>)>)>>, i64) -> !llvm.ptr, struct<"struct2", (i32, i32)>)>, struct<"struct4", (struct<"struct2", (i32, i32)>, struct<"struct2", (i32, i32)>)>)>> - "llvm.cond_br"(%arg1)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %5 = llvm.getelementptr inbounds %3[%arg3] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct2", (i32, i32)> + llvm.store %0, %5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3(%5 : !llvm.ptr) + ^bb3(%6: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + %7 = llvm.getelementptr inbounds %6[%1, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct2", (i32, i32)> + %8 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %8 : i32 + } + llvm.func @test2(%arg0: !llvm.ptr, %arg1: i1, %arg2: i64, %arg3: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %4 = llvm.getelementptr inbounds %3[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct2", (i32, i32)> + llvm.store %0, %4 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.getelementptr inbounds %3[%arg3] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct2", (i32, i32)> + llvm.store %0, %5 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.getelementptr inbounds %4[%1, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct2", (i32, i32)> + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %7 : i32 + } + llvm.func @test3(%arg0: !llvm.ptr, %arg1: i1, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i32 attributes {personality = @__gxx_personality_v0} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(11 : i32) : i32 + %4 = llvm.mlir.addressof @_ZTIi : !llvm.ptr + llvm.cond_br %arg1, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %7 = "llvm.getelementptr"(%6, %arg3, %4) : (!llvm.ptr, struct<"struct2", (i32, i32)>)>, struct<"struct4", (struct<"struct2", (i32, i32)>, struct<"struct2", (i32, i32)>)>)>>, i64, i32) -> !llvm.ptr, struct<"struct2", (i32, i32)>)>> - %8 = "llvm.getelementptr"(%7, %5, %3, %3) : (!llvm.ptr, struct<"struct2", (i32, i32)>)>>, i64, i32, i32) -> !llvm.ptr - "llvm.store"(%3, %8) : (i32, !llvm.ptr) -> () - "llvm.br"(%7)[^bb3] : (!llvm.ptr, struct<"struct2", (i32, i32)>)>>) -> () + %5 = llvm.getelementptr inbounds %arg0[%arg3, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct3", (i32, struct<"struct4", (struct<"struct2", (i32, i32)>, struct<"struct2", (i32, i32)>)>, struct<"struct4", (struct<"struct2", (i32, i32)>, struct<"struct2", (i32, i32)>)>)> + llvm.store %2, %5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3(%5 : !llvm.ptr) ^bb2: // pred: ^bb0 - %9 = "llvm.getelementptr"(%6, %arg4, %4) : (!llvm.ptr, struct<"struct2", (i32, i32)>)>, struct<"struct4", (struct<"struct2", (i32, i32)>, struct<"struct2", (i32, i32)>)>)>>, i64, i32) -> !llvm.ptr, struct<"struct2", (i32, i32)>)>> - %10 = "llvm.getelementptr"(%9, %5, %3, %4) : (!llvm.ptr, struct<"struct2", (i32, i32)>)>>, i64, i32, i32) -> !llvm.ptr - "llvm.store"(%3, %10) : (i32, !llvm.ptr) -> () - "llvm.br"(%9)[^bb3] : (!llvm.ptr, struct<"struct2", (i32, i32)>)>>) -> () - ^bb3(%11: !llvm.ptr, struct<"struct2", (i32, i32)>)>>): // 2 preds: ^bb1, ^bb2 - %12 = "llvm.invoke"(%2)[^bb4, ^bb5] {callee = @foo1, operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i32) -> i32 + %6 = llvm.getelementptr inbounds %arg0[%arg4, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct3", (i32, struct<"struct4", (struct<"struct2", (i32, i32)>, struct<"struct2", (i32, i32)>)>, struct<"struct4", (struct<"struct2", (i32, i32)>, struct<"struct2", (i32, i32)>)>)> + %7 = llvm.getelementptr inbounds %6[%1, 0, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct4", (struct<"struct2", (i32, i32)>, struct<"struct2", (i32, i32)>)> + llvm.store %2, %7 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3(%6 : !llvm.ptr) + ^bb3(%8: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + %9 = llvm.invoke @foo1(%3) to ^bb4 unwind ^bb5 : (i32) -> i32 ^bb4: // pred: ^bb3 - "llvm.return"(%3) : (i32) -> () + llvm.return %2 : i32 ^bb5: // pred: ^bb3 - %13 = "llvm.landingpad"(%1) : (!llvm.ptr) -> !llvm.struct<(ptr, i32)> - %14 = "llvm.getelementptr"(%11, %arg5, %4) : (!llvm.ptr, struct<"struct2", (i32, i32)>)>>, i64, i32) -> !llvm.ptr> - %15 = "llvm.getelementptr"(%14, %5, %4) : (!llvm.ptr>, i64, i32) -> !llvm.ptr - %16 = "llvm.load"(%15) : (!llvm.ptr) -> i32 - "llvm.return"(%16) : (i32) -> () - }) {linkage = 10 : i64, personality = @__gxx_personality_v0, sym_name = "test3", type = !llvm.func, struct<"struct2", (i32, i32)>)>, struct<"struct4", (struct<"struct2", (i32, i32)>, struct<"struct2", (i32, i32)>)>)>>, i1, i64, i64, i64, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "__gxx_personality_v0", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "foo1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 127 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %3 = "llvm.getelementptr"(%arg1, %2) : (!llvm.ptr, i64) -> !llvm.ptr - %4 = "llvm.icmp"(%arg0, %1) {predicate = 8 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%4, %3)[^bb1, ^bb4] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, !llvm.ptr) -> () + %10 = llvm.landingpad (catch %4 : !llvm.ptr) : !llvm.struct<(ptr, i32)> + %11 = llvm.getelementptr inbounds %8[%arg5, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct4", (struct<"struct2", (i32, i32)>, struct<"struct2", (i32, i32)>)> + %12 = llvm.getelementptr inbounds %11[%1, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct2", (i32, i32)> + %13 = llvm.load %12 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %13 : i32 + } + llvm.func @__gxx_personality_v0(...) -> i32 + llvm.func @foo1(i32) -> i32 + llvm.func @test4(%arg0: i32, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(127 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.getelementptr inbounds %arg1[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.icmp "ugt" %arg0, %1 : i32 + llvm.cond_br %4, ^bb1, ^bb4(%3 : !llvm.ptr) ^bb1: // pred: ^bb0 - "llvm.br"(%3, %arg0)[^bb2] : (!llvm.ptr, i32) -> () - ^bb2(%5: !llvm.ptr, %6: i32): // 2 preds: ^bb1, ^bb2 - %7 = "llvm.lshr"(%6, %0) : (i32, i32) -> i32 - %8 = "llvm.getelementptr"(%5, %2) : (!llvm.ptr, i64) -> !llvm.ptr - %9 = "llvm.icmp"(%7, %1) {predicate = 8 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%9, %8, %7, %8)[^bb2, ^bb3] {operand_segment_sizes = dense<[1, 2, 1]> : vector<3xi32>} : (i1, !llvm.ptr, i32, !llvm.ptr) -> () - ^bb3(%10: !llvm.ptr): // pred: ^bb2 - "llvm.br"(%10)[^bb4] : (!llvm.ptr) -> () - ^bb4(%11: !llvm.ptr): // 2 preds: ^bb0, ^bb3 - %12 = "llvm.getelementptr"(%11, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.return"(%12) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func (i32, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i16} : () -> i16 - %1 = "llvm.mlir.constant"() {value = 2048 : i16} : () -> i16 - %2 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %3 = "llvm.mlir.constant"() {value = 64 : i8} : () -> i8 - %4 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %5 = "llvm.mlir.addressof"() {global_name = @".str.4"} : () -> !llvm.ptr> - %6 = "llvm.getelementptr"(%5, %4, %4) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %7 = "llvm.mlir.constant"() {value = 54 : i8} : () -> i8 - %8 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %9 = "llvm.load"(%arg1) : (!llvm.ptr>) -> !llvm.ptr - %10 = "llvm.getelementptr"(%9, %8) : (!llvm.ptr, i32) -> !llvm.ptr - %11 = "llvm.load"(%10) : (!llvm.ptr) -> i8 - %12 = "llvm.icmp"(%11, %7) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.cond_br"(%12, %10)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, !llvm.ptr) -> () + llvm.br ^bb2(%3, %arg0 : !llvm.ptr, i32) + ^bb2(%5: !llvm.ptr, %6: i32): // 2 preds: ^bb1, ^bb2 + %7 = llvm.lshr %6, %2 : i32 + %8 = llvm.getelementptr inbounds %5[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %9 = llvm.icmp "ugt" %7, %1 : i32 + llvm.cond_br %9, ^bb2(%8, %7 : !llvm.ptr, i32), ^bb3(%8 : !llvm.ptr) + ^bb3(%10: !llvm.ptr): // pred: ^bb2 + llvm.br ^bb4(%10 : !llvm.ptr) + ^bb4(%11: !llvm.ptr): // 2 preds: ^bb0, ^bb3 + %12 = llvm.getelementptr inbounds %11[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.return %12 : !llvm.ptr + } + llvm.func @test5(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(54 : i8) : i8 + %2 = llvm.mlir.addressof @".str.4" : !llvm.ptr + %3 = llvm.mlir.constant(64 : i8) : i8 + %4 = llvm.mlir.constant(0 : i8) : i8 + %5 = llvm.mlir.constant(2048 : i16) : i16 + %6 = llvm.mlir.constant(0 : i16) : i16 + %7 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %8 = llvm.getelementptr inbounds %7[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %9 = llvm.load %8 {alignment = 1 : i64} : !llvm.ptr -> i8 + %10 = llvm.icmp "eq" %9, %1 : i8 + llvm.cond_br %10, ^bb2(%8 : !llvm.ptr), ^bb1 ^bb1: // pred: ^bb0 - "llvm.call"(%6) {callee = @g, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.br"(%10)[^bb2] : (!llvm.ptr) -> () - ^bb2(%13: !llvm.ptr): // 3 preds: ^bb0, ^bb1, ^bb3 - %14 = "llvm.load"(%13) : (!llvm.ptr) -> i8 - %15 = "llvm.and"(%14, %3) : (i8, i8) -> i8 - %16 = "llvm.icmp"(%15, %2) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.cond_br"(%16)[^bb3, ^bb4] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.call @g(%2) : (!llvm.ptr) -> () + llvm.br ^bb2(%8 : !llvm.ptr) + ^bb2(%11: !llvm.ptr): // 3 preds: ^bb0, ^bb1, ^bb3 + %12 = llvm.load %11 {alignment = 1 : i64} : !llvm.ptr -> i8 + %13 = llvm.and %12, %3 : i8 + %14 = llvm.icmp "eq" %13, %4 : i8 + llvm.cond_br %14, ^bb3, ^bb4 ^bb3: // pred: ^bb2 - %17 = "llvm.getelementptr"(%13, %8) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.br"(%17)[^bb2] : (!llvm.ptr) -> () + %15 = llvm.getelementptr inbounds %11[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + llvm.br ^bb2(%15 : !llvm.ptr) ^bb4: // pred: ^bb2 - %18 = "llvm.getelementptr"(%13, %8) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.br"()[^bb5] : () -> () + %16 = llvm.getelementptr inbounds %11[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + llvm.br ^bb5 ^bb5: // 2 preds: ^bb4, ^bb5 - %19 = "llvm.load"(%18) : (!llvm.ptr) -> i8 - %20 = "llvm.zext"(%19) : (i8) -> i32 - %21 = "llvm.getelementptr"(%arg0, %20) : (!llvm.ptr, i32) -> !llvm.ptr - %22 = "llvm.load"(%21) : (!llvm.ptr) -> i16 - %23 = "llvm.and"(%22, %1) : (i16, i16) -> i16 - %24 = "llvm.icmp"(%23, %0) {predicate = 0 : i64} : (i16, i16) -> i1 - "llvm.cond_br"(%24)[^bb6, ^bb5] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %17 = llvm.load %16 {alignment = 1 : i64} : !llvm.ptr -> i8 + %18 = llvm.zext %17 : i8 to i32 + %19 = llvm.getelementptr inbounds %arg0[%18] : (!llvm.ptr, i32) -> !llvm.ptr, i16 + %20 = llvm.load %19 {alignment = 2 : i64} : !llvm.ptr -> i16 + %21 = llvm.and %20, %5 : i16 + %22 = llvm.icmp "eq" %21, %6 : i16 + llvm.cond_br %22, ^bb6, ^bb5 ^bb6: // 2 preds: ^bb5, ^bb6 - "llvm.br"()[^bb6] : () -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "g", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.br ^bb6 + } + llvm.func @g(!llvm.ptr) +} diff --git a/test/LLVMDialect/InstCombine/get-lowbitmask-upto-and-including-bit.ll.mlir b/test/LLVMDialect/InstCombine/get-lowbitmask-upto-and-including-bit.ll.mlir new file mode 100644 index 000000000..91b961077 --- /dev/null +++ b/test/LLVMDialect/InstCombine/get-lowbitmask-upto-and-including-bit.ll.mlir @@ -0,0 +1,203 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @t0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + %3 = llvm.add %2, %1 : i8 + %4 = llvm.or %3, %2 : i8 + llvm.return %4 : i8 + } + llvm.func @t1(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.shl %0, %arg0 : i16 + %3 = llvm.add %2, %1 : i16 + %4 = llvm.or %3, %2 : i16 + llvm.return %4 : i16 + } + llvm.func @t2_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg0 : vector<2xi8> + %3 = llvm.add %2, %1 : vector<2xi8> + %4 = llvm.or %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @t3_vec_poison0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %10 = llvm.shl %8, %arg0 : vector<3xi8> + %11 = llvm.add %10, %9 : vector<3xi8> + %12 = llvm.or %11, %10 : vector<3xi8> + llvm.return %12 : vector<3xi8> + } + llvm.func @t4_vec_poison1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.shl %0, %arg0 : vector<3xi8> + %11 = llvm.add %10, %9 : vector<3xi8> + %12 = llvm.or %11, %10 : vector<3xi8> + llvm.return %12 : vector<3xi8> + } + llvm.func @t5_vec_poison2(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(-1 : i8) : i8 + %10 = llvm.mlir.undef : vector<3xi8> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi8> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<3xi8> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi8> + %17 = llvm.shl %8, %arg0 : vector<3xi8> + %18 = llvm.add %17, %16 : vector<3xi8> + %19 = llvm.or %18, %17 : vector<3xi8> + llvm.return %19 : vector<3xi8> + } + llvm.func @t6_extrause0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.or %3, %2 : i8 + llvm.return %4 : i8 + } + llvm.func @t7_extrause1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + %3 = llvm.add %2, %1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.or %3, %2 : i8 + llvm.return %4 : i8 + } + llvm.func @t8_extrause2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.or %3, %2 : i8 + llvm.return %4 : i8 + } + llvm.func @t9_nocse(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.add %2, %1 : i8 + %5 = llvm.or %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @t10_nocse_extrause0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.add %2, %1 : i8 + %5 = llvm.or %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @t11_nocse_extrause1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + %3 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.add %2, %1 : i8 + %5 = llvm.or %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @t12_nocse_extrause2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.add %2, %1 : i8 + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.or %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @t13_nocse_extrause3(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.add %2, %1 : i8 + %5 = llvm.or %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @t14_nocse_extrause4(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.add %2, %1 : i8 + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.or %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @t15_nocse_extrause5(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + %3 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.add %2, %1 : i8 + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.or %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @t16_nocse_extrause6(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.add %2, %1 : i8 + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.or %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @t17_nocse_mismatching_x(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + %3 = llvm.shl %0, %arg1 : i8 + %4 = llvm.add %2, %1 : i8 + %5 = llvm.or %4, %3 : i8 + llvm.return %5 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/getelementptr-folding.ll.mlir b/test/LLVMDialect/InstCombine/getelementptr-folding.ll.mlir index 78a0f0d78..d2c08e063 100644 --- a/test/LLVMDialect/InstCombine/getelementptr-folding.ll.mlir +++ b/test/LLVMDialect/InstCombine/getelementptr-folding.ll.mlir @@ -1,14 +1,12 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "matrix_identity_float3x3", type = !llvm.struct<"struct.matrix_float3x3", (array<3 x vector<3xf32>>)>} : () -> () - "llvm.mlir.global"() ( { - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %4 = "llvm.mlir.addressof"() {global_name = @matrix_identity_float3x3} : () -> !llvm.ptr>)>> - %5 = "llvm.getelementptr"(%4, %3, %2, %1, %0) : (!llvm.ptr>)>>, i64, i32, i64, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "bbb", type = !llvm.ptr} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.mlir.global external @matrix_identity_float3x3() {addr_space = 0 : i32, alignment = 16 : i64} : !llvm.struct<"struct.matrix_float3x3", (array<3 x vector<3xf32>>)> + llvm.mlir.global external @bbb() {addr_space = 0 : i32} : !llvm.ptr { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.mlir.addressof @matrix_identity_float3x3 : !llvm.ptr + %5 = llvm.getelementptr inbounds %4[%3, 0, %1, %0] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.struct<"struct.matrix_float3x3", (array<3 x vector<3xf32>>)> + llvm.return %5 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/getelementptr.ll.mlir b/test/LLVMDialect/InstCombine/getelementptr.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/high-bit-signmask-with-trunc.ll.mlir b/test/LLVMDialect/InstCombine/high-bit-signmask-with-trunc.ll.mlir new file mode 100644 index 000000000..9d1d37a01 --- /dev/null +++ b/test/LLVMDialect/InstCombine/high-bit-signmask-with-trunc.ll.mlir @@ -0,0 +1,109 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @t1_exact(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @t2(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @t3_exact(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @t4(%arg0: vector<2xi64>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<63> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.lshr %arg0, %0 : vector<2xi64> + %4 = llvm.trunc %3 : vector<2xi64> to vector<2xi32> + %5 = llvm.sub %2, %4 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @t5(%arg0: vector<2xi64>) -> vector<2xi32> { + %0 = llvm.mlir.undef : i64 + %1 = llvm.mlir.constant(63 : i64) : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.mlir.undef : i32 + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.mlir.undef : vector<2xi32> + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.insertelement %8, %9[%10 : i32] : vector<2xi32> + %12 = llvm.mlir.constant(1 : i32) : i32 + %13 = llvm.insertelement %7, %11[%12 : i32] : vector<2xi32> + %14 = llvm.lshr %arg0, %6 : vector<2xi64> + %15 = llvm.trunc %14 : vector<2xi64> to vector<2xi32> + %16 = llvm.sub %13, %15 : vector<2xi32> + llvm.return %16 : vector<2xi32> + } + llvm.func @use64(i64) + llvm.func @use32(i32) + llvm.func @t6(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i64 + llvm.call @use64(%2) : (i64) -> () + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n7(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n8(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i64 + llvm.call @use64(%2) : (i64) -> () + %3 = llvm.trunc %2 : i64 to i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n9(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(62 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n10(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/high-bit-signmask.ll.mlir b/test/LLVMDialect/InstCombine/high-bit-signmask.ll.mlir new file mode 100644 index 000000000..d7b970314 --- /dev/null +++ b/test/LLVMDialect/InstCombine/high-bit-signmask.ll.mlir @@ -0,0 +1,97 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.sub %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @t0_exact(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.sub %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @t2(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.ashr %arg0, %0 : i64 + %3 = llvm.sub %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @t3_exact(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.ashr %arg0, %0 : i64 + %3 = llvm.sub %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @t4(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<63> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.lshr %arg0, %0 : vector<2xi64> + %4 = llvm.sub %2, %3 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @t5(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.undef : i64 + %1 = llvm.mlir.constant(63 : i64) : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.mlir.constant(0 : i64) : i64 + %8 = llvm.mlir.undef : vector<2xi64> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi64> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi64> + %13 = llvm.lshr %arg0, %6 : vector<2xi64> + %14 = llvm.sub %12, %13 : vector<2xi64> + llvm.return %14 : vector<2xi64> + } + llvm.func @use64(i64) + llvm.func @use32(i64) + llvm.func @t6(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + llvm.call @use64(%2) : (i64) -> () + %3 = llvm.sub %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @n7(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + llvm.call @use32(%2) : (i64) -> () + %3 = llvm.sub %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @n8(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + llvm.call @use64(%2) : (i64) -> () + llvm.call @use32(%2) : (i64) -> () + %3 = llvm.sub %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @n9(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(62 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.sub %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @n10(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.sub %1, %2 : i64 + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/hoist-negation-out-of-bias-calculation-with-constant.ll.mlir b/test/LLVMDialect/InstCombine/hoist-negation-out-of-bias-calculation-with-constant.ll.mlir new file mode 100644 index 000000000..d52aa7b48 --- /dev/null +++ b/test/LLVMDialect/InstCombine/hoist-negation-out-of-bias-calculation-with-constant.ll.mlir @@ -0,0 +1,52 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.sub %1, %arg0 : i8 + llvm.return %2 : i8 + } + llvm.func @t1_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.sub %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @t2_vec_undef(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.undef : i8 + %1 = llvm.mlir.constant(42 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.and %arg0, %6 : vector<2xi8> + %8 = llvm.sub %7, %arg0 : vector<2xi8> + llvm.return %8 : vector<2xi8> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[42, 44]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg0, %0 : vector<2xi8> + %2 = llvm.sub %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @use8(i8) + llvm.func @n4_extrause(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %1, %arg0 : i8 + llvm.return %2 : i8 + } + llvm.func @n5(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @n6(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.and %arg1, %0 : i8 + %2 = llvm.sub %1, %arg0 : i8 + llvm.return %2 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/hoist-negation-out-of-bias-calculation.ll.mlir b/test/LLVMDialect/InstCombine/hoist-negation-out-of-bias-calculation.ll.mlir new file mode 100644 index 000000000..38d36894e --- /dev/null +++ b/test/LLVMDialect/InstCombine/hoist-negation-out-of-bias-calculation.ll.mlir @@ -0,0 +1,86 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.sub %2, %arg0 : i8 + llvm.return %3 : i8 + } + llvm.func @gen8() -> i8 + llvm.func @t1_commutative(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.sub %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @t2_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.sub %1, %arg1 : vector<2xi8> + %3 = llvm.and %2, %arg0 : vector<2xi8> + %4 = llvm.sub %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @t3_vec_poison(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.sub %6, %arg1 : vector<2xi8> + %8 = llvm.and %7, %arg0 : vector<2xi8> + %9 = llvm.sub %8, %arg0 : vector<2xi8> + llvm.return %9 : vector<2xi8> + } + llvm.func @use8(i8) + llvm.func @n4_extrause0(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.sub %2, %arg0 : i8 + llvm.return %3 : i8 + } + llvm.func @n5_extrause1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %2, %arg0 : i8 + llvm.return %3 : i8 + } + llvm.func @n6_extrause2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.and %1, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %2, %arg0 : i8 + llvm.return %3 : i8 + } + llvm.func @n7(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @n8(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.sub %2, %arg0 : i8 + llvm.return %3 : i8 + } + llvm.func @n9(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg2 : i8 + %2 = llvm.and %arg1, %1 : i8 + %3 = llvm.sub %2, %arg0 : i8 + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/hoist-not-from-ashr-operand.ll.mlir b/test/LLVMDialect/InstCombine/hoist-not-from-ashr-operand.ll.mlir new file mode 100644 index 000000000..394331122 --- /dev/null +++ b/test/LLVMDialect/InstCombine/hoist-not-from-ashr-operand.ll.mlir @@ -0,0 +1,40 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @t0(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.ashr %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @t1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.ashr %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @t2_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg0, %0 : vector<2xi8> + %2 = llvm.ashr %1, %arg1 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @t3_vec_poison(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.xor %arg0, %6 : vector<2xi8> + %8 = llvm.ashr %7, %arg1 : vector<2xi8> + llvm.return %8 : vector<2xi8> + } + llvm.func @n4(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.ashr %1, %arg1 : i8 + llvm.return %2 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll.mlir b/test/LLVMDialect/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll.mlir new file mode 100644 index 000000000..06a635627 --- /dev/null +++ b/test/LLVMDialect/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll.mlir @@ -0,0 +1,80 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @a(17 : i8) {addr_space = 0 : i32} : i8 + llvm.mlir.global internal @global_constant(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64, dso_local} : i32 + llvm.mlir.global internal @global_constant2(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64, dso_local} : i32 + llvm.mlir.global external @global_constant3() {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<6 x array<1 x i64>> + llvm.mlir.global external @global_constant4() {addr_space = 0 : i32, alignment = 1 : i64} : i64 + llvm.mlir.global external @global_constant5() {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.ptr + llvm.func @gen8() -> i8 + llvm.func @use8(i8) + llvm.func @t0_scalar(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @t1_splatvec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg0, %0 : vector<2xi8> + %2 = llvm.xor %1, %arg1 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @t2_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[42, 24]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg0, %0 : vector<2xi8> + %2 = llvm.xor %1, %arg1 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @t3_vec_undef(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.undef : i8 + %1 = llvm.mlir.constant(42 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.xor %arg0, %6 : vector<2xi8> + %8 = llvm.xor %7, %arg1 : vector<2xi8> + llvm.return %8 : vector<2xi8> + } + llvm.func @t4_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.xor %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @t5_commutativity(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func local_unnamed_addr @constantexpr(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @global_constant2 : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i8 + %3 = llvm.mlir.addressof @global_constant : !llvm.ptr + %4 = llvm.ptrtoint %3 : !llvm.ptr to i8 + %5 = llvm.xor %4, %2 : i8 + %6 = llvm.xor %arg0, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @constantexpr2() -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(5 : i16) : i16 + %2 = llvm.mlir.addressof @global_constant3 : !llvm.ptr + %3 = llvm.getelementptr inbounds %2[%0, %1, %0] : (!llvm.ptr, i16, i16, i16) -> !llvm.ptr, !llvm.array<6 x array<1 x i64>> + %4 = llvm.mlir.addressof @global_constant4 : !llvm.ptr + %5 = llvm.mlir.addressof @global_constant5 : !llvm.ptr + %6 = llvm.mlir.constant(-1 : i16) : i16 + %7 = llvm.icmp "ne" %3, %4 : !llvm.ptr + %8 = llvm.zext %7 : i1 to i16 + %9 = llvm.load %5 {alignment = 1 : i64} : !llvm.ptr -> !llvm.ptr + %10 = llvm.load %9 {alignment = 1 : i64} : !llvm.ptr -> i16 + %11 = llvm.xor %10, %8 : i16 + %12 = llvm.xor %11, %6 : i16 + llvm.return %12 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/hoist_instr.ll.mlir b/test/LLVMDialect/InstCombine/hoist_instr.ll.mlir index 68bb55a8d..0cb121fa1 100644 --- a/test/LLVMDialect/InstCombine/hoist_instr.ll.mlir +++ b/test/LLVMDialect/InstCombine/hoist_instr.ll.mlir @@ -1,14 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 15 : i32} : () -> i32 - "llvm.cond_br"(%arg0, %1)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0 : i32) ^bb1: // pred: ^bb0 - "llvm.br"(%arg1)[^bb2] : (i32) -> () + llvm.br ^bb2(%arg1 : i32) ^bb2(%2: i32): // 2 preds: ^bb0, ^bb1 - %3 = "llvm.sdiv"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %3 = llvm.sdiv %2, %1 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-abs.ll.mlir b/test/LLVMDialect/InstCombine/icmp-abs.ll.mlir new file mode 100644 index 000000000..c6f5ebf0f --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-abs.ll.mlir @@ -0,0 +1,113 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @icmp_sge_abs(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i4) -> i4 + %1 = llvm.icmp "sge" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_sge_abs_false(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i4) -> i4 + %1 = llvm.icmp "sge" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_eq_abs(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i4) -> i4 + %1 = llvm.icmp "eq" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_eq_abs_false(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i4) -> i4 + %1 = llvm.icmp "eq" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_ne_abs(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i4) -> i4 + %1 = llvm.icmp "ne" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_ne_abs_false(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i4) -> i4 + %1 = llvm.icmp "ne" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_sle_abs(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i4) -> i4 + %1 = llvm.icmp "sle" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_sle_abs_false(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i4) -> i4 + %1 = llvm.icmp "sle" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_slt_abs(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i4) -> i4 + %1 = llvm.icmp "slt" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_slt_abs_false(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i4) -> i4 + %1 = llvm.icmp "slt" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_sgt_abs(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i4) -> i4 + %1 = llvm.icmp "sgt" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_sgt_abs_false(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i4) -> i4 + %1 = llvm.icmp "sgt" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_ugt_abs(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i4) -> i4 + %1 = llvm.icmp "ugt" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_ugt_abs_false(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i4) -> i4 + %1 = llvm.icmp "ugt" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_uge_abs(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i4) -> i4 + %1 = llvm.icmp "uge" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_uge_abs_false(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i4) -> i4 + %1 = llvm.icmp "uge" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_ule_abs(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i4) -> i4 + %1 = llvm.icmp "ule" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_ule_abs_false(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i4) -> i4 + %1 = llvm.icmp "ule" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_ult_abs(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i4) -> i4 + %1 = llvm.icmp "ult" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_ult_abs_false(%arg0: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i4) -> i4 + %1 = llvm.icmp "ult" %0, %arg0 : i4 + llvm.return %1 : i1 + } + llvm.func @icmp_sge_abs2(%arg0: i4) -> i1 { + %0 = llvm.mul %arg0, %arg0 : i4 + %1 = "llvm.intr.abs"(%0) <{is_int_min_poison = true}> : (i4) -> i4 + %2 = llvm.icmp "sge" %0, %1 : i4 + llvm.return %2 : i1 + } + llvm.func @icmp_sge_abs_mismatched_op(%arg0: i4, %arg1: i4) -> i1 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i4) -> i4 + %1 = llvm.icmp "sge" %0, %arg1 : i4 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-add.ll.mlir b/test/LLVMDialect/InstCombine/icmp-add.ll.mlir new file mode 100644 index 000000000..1fb7868ca --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-add.ll.mlir @@ -0,0 +1,1833 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @cvt_icmp_0_zext_plus_zext_eq_i16(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.zext %arg1 : i16 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_0_zext_plus_zext_eq_i8(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.zext %arg1 : i8 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_2_zext_plus_zext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_1_zext_plus_zext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_0_zext_plus_zext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_1_zext_plus_zext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_1_zext_plus_zext_eq_vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.zext %arg1 : vector<2xi1> to vector<2xi32> + %3 = llvm.add %2, %1 : vector<2xi32> + %4 = llvm.icmp "eq" %3, %0 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @cvt_icmp_2_zext_plus_zext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_2_sext_plus_sext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_1_sext_plus_sext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_0_sext_plus_sext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_1_sext_plus_sext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_2_sext_plus_sext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_2_sext_plus_zext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_1_sext_plus_zext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_0_sext_plus_zext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_1_sext_plus_zext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_2_sext_plus_zext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_2_zext_plus_zext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_1_zext_plus_zext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_0_zext_plus_zext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_1_zext_plus_zext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_1_zext_plus_zext_ne_extra_use_1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_1_zext_plus_zext_ne_extra_use_2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.zext %arg1 : i1 to i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_2_zext_plus_zext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_2_sext_plus_sext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_1_sext_plus_sext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_0_sext_plus_sext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_1_sext_plus_sext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_2_sext_plus_sext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_2_sext_plus_zext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_1_sext_plus_zext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_0_sext_plus_zext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_1_sext_plus_zext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_2_sext_plus_zext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_2_sext_plus_zext_ne_vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.zext %arg1 : vector<2xi1> to vector<2xi32> + %3 = llvm.add %1, %2 overflow : vector<2xi32> + %4 = llvm.icmp "ne" %3, %0 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @cvt_icmp_neg_2_zext_plus_sext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_2_zext_plus_sext_eq_vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.sext %arg1 : vector<2xi1> to vector<2xi32> + %3 = llvm.add %2, %1 overflow : vector<2xi32> + %4 = llvm.icmp "eq" %3, %0 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @cvt_icmp_neg_1_zext_plus_sext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_0_zext_plus_sext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_1_zext_plus_sext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_2_zext_plus_sext_eq(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_2_zext_plus_sext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_neg_1_zext_plus_sext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_0_zext_plus_sext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_1_zext_plus_sext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @cvt_icmp_2_zext_plus_sext_ne(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp1(%arg0: i1, %arg1: i1, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg0 : i1 to i32 + llvm.store %2, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.load %arg2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %0 : i32 + llvm.return %5 : i1 + } + llvm.func @test_cvt_icmp2(%arg0: i1, %arg1: i1, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg0 : i1 to i32 + llvm.store %2, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.load %arg2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %0 : i32 + llvm.return %5 : i1 + } + llvm.func @test_zext_zext_cvt_neg_2_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_zext_cvt_neg_1_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_zext_cvt_0_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_zext_cvt_2_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_sext_cvt_neg_2_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_sext_cvt_neg_1_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_sext_cvt_0_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_sext_cvt_1_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_sext_cvt_2_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_zext_cvt_neg_2_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_zext_cvt_neg_1_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_zext_cvt_0_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_zext_cvt_2_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_neg_1_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_0_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_1_ult_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp4(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_zext_cvt_neg_2_ugt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_zext_cvt_1_ugt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_zext_cvt_2_ugt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_sext_cvt_neg_2_ugt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_sext_cvt_0_ugt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_sext_cvt_2_ugt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_neg_2_ugt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_neg_1_ugt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_0_ugt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_1_ugt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_2_ugt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp5(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "uge" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp6(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ule" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp7(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_zext_cvt_neg_2_sgt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_zext_cvt_neg_1_sgt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_zext_cvt_2_sgt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_sext_cvt_neg_2_sgt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_sext_cvt_0_sgt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_sext_cvt_2_sgt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_neg_2_sgt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_neg_1_sgt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_0_sgt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_1_sgt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_2_sgt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_zext_cvt_neg_2_slt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_zext_cvt_neg_1_slt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_zext_cvt_2_slt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_sext_cvt_neg_2_slt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_sext_cvt_0_slt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_sext_sext_cvt_2_slt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_neg_2_slt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_neg_1_slt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_0_slt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_1_slt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_zext_sext_cvt_2_slt_icmp(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp8(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sge" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp9(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp10(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sle" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp11(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp12(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "uge" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp13(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp14(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ule" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp15(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp16(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sge" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp17(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp18(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sle" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp19(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp20(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "uge" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp21(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp22(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "ule" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp23(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp24(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sge" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp25(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test_cvt_icmp26(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + %3 = llvm.add %2, %1 : i32 + %4 = llvm.icmp "sle" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ult" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @test1vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.add %arg0, %0 : vector<2xi32> + %2 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @test2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(-5 : i32) : i32 + %2 = llvm.sub %arg0, %0 : i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test2vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-5> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %arg0, %0 : vector<2xi32> + %3 = llvm.icmp "ugt" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test3(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(-2147483644 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test3vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-2147483644> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %arg0, %0 : vector<2xi32> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test4(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483644 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.icmp "sge" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test4multiuse(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(-2147483644 : i32) : i32 + %1 = llvm.mlir.constant(-4 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<(i32, i1)> + %3 = llvm.add %arg0, %0 overflow : i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + %5 = llvm.insertvalue %3, %2[0] : !llvm.struct<(i32, i1)> + %6 = llvm.insertvalue %4, %5[1] : !llvm.struct<(i32, i1)> + llvm.return %6 : !llvm.struct<(i32, i1)> + } + llvm.func @test4vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-2147483644> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %arg0, %0 : vector<2xi32> + %3 = llvm.icmp "sge" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @nsw_slt1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(-27 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nsw_slt1_splat_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<100> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-27> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @nsw_slt2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-100 : i8) : i8 + %1 = llvm.mlir.constant(27 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nsw_slt2_splat_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-100> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<27> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @nsw_slt3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(-26 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nsw_slt4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-100 : i8) : i8 + %1 = llvm.mlir.constant(26 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nsw_sgt1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-100 : i8) : i8 + %1 = llvm.mlir.constant(26 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nsw_sgt1_splat_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-100> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<26> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = llvm.icmp "sgt" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @nsw_sgt2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(-26 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nsw_sgt2_splat_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<100> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-26> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = llvm.icmp "sgt" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @slt_zero_add_nsw(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @slt_zero_add_nsw_splat_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.add %arg0, %0 overflow : vector<2xi8> + %4 = llvm.icmp "slt" %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @nsw_slt3_ov_no(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(-28 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nsw_slt4_ov(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(-29 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nsw_slt5_ov(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-100 : i8) : i8 + %1 = llvm.mlir.constant(28 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @slt_zero_add_nsw_signbit(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @slt_zero_add_nuw_signbit(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @reduce_add_ult(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @reduce_add_ugt(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @reduce_add_ule(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "ule" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @reduce_add_uge(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "uge" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @ult_add_ssubov(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(71 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @ult_add_nonuw(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(71 : i8) : i8 + %1 = llvm.mlir.constant(12 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @uge_add_nonuw(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.icmp "uge" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @op_ugt_sum_commute1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sdiv %0, %arg0 : i8 + %2 = llvm.sdiv %0, %arg1 : i8 + %3 = llvm.add %1, %2 : i8 + %4 = llvm.icmp "ugt" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @op_ugt_sum_vec_commute2(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sdiv %0, %arg0 : vector<2xi8> + %2 = llvm.sdiv %0, %arg1 : vector<2xi8> + %3 = llvm.add %2, %1 : vector<2xi8> + %4 = llvm.icmp "ugt" %1, %3 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @sum_ugt_op_uses(%arg0: i8, %arg1: i8, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sdiv %0, %arg0 : i8 + %2 = llvm.sdiv %0, %arg1 : i8 + %3 = llvm.add %1, %2 : i8 + llvm.store %3, %arg2 {alignment = 1 : i64} : i8, !llvm.ptr + %4 = llvm.icmp "ugt" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @sum_ult_op_vec_commute1(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-42, 42]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.sdiv %0, %arg0 : vector<2xi8> + %3 = llvm.sdiv %1, %arg1 : vector<2xi8> + %4 = llvm.add %2, %3 : vector<2xi8> + %5 = llvm.icmp "ult" %4, %2 : vector<2xi8> + llvm.return %5 : vector<2xi1> + } + llvm.func @sum_ult_op_commute2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sdiv %0, %arg0 : i8 + %2 = llvm.sdiv %0, %arg1 : i8 + %3 = llvm.add %2, %1 : i8 + %4 = llvm.icmp "ult" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @sum_ult_op_uses(%arg0: i8, %arg1: i8, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.add %arg1, %arg0 : i8 + llvm.store %0, %arg2 {alignment = 1 : i64} : i8, !llvm.ptr + %1 = llvm.icmp "ult" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @common_op_nsw(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.add %arg0, %arg2 overflow : i32 + %1 = llvm.add %arg1, %arg2 overflow : i32 + %2 = llvm.icmp "sgt" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @common_op_nsw_extra_uses(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.add %arg0, %arg2 overflow : i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.add %arg1, %arg2 overflow : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.icmp "sgt" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @common_op_nuw(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.add %arg0, %arg2 overflow : i32 + %1 = llvm.add %arg2, %arg1 overflow : i32 + %2 = llvm.icmp "ugt" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @common_op_nuw_extra_uses(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.add %arg0, %arg2 overflow : i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.add %arg2, %arg1 overflow : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.icmp "ugt" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @common_op_nsw_commute(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.add %arg2, %arg0 overflow : i32 + %1 = llvm.add %arg1, %arg2 overflow : i32 + %2 = llvm.icmp "slt" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @common_op_nuw_commute(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.add %arg2, %arg0 overflow : i32 + %1 = llvm.add %arg2, %arg1 overflow : i32 + %2 = llvm.icmp "ult" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @common_op_test29(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.add %arg0, %arg1 overflow : i32 + %1 = llvm.icmp "sgt" %0, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @sum_nuw(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.add %arg0, %arg1 overflow : i32 + %1 = llvm.icmp "ugt" %0, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @sum_nsw_commute(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.add %arg0, %arg1 overflow : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.return %1 : i1 + } + llvm.func @sum_nuw_commute(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.add %arg0, %arg1 overflow : i32 + %1 = llvm.icmp "ugt" %arg0, %0 : i32 + llvm.return %1 : i1 + } + llvm.func @use1(i1) + llvm.func @use8(i8) + llvm.func @bzip1(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.add %arg0, %arg2 : i8 + %1 = llvm.add %arg1, %arg2 : i8 + %2 = llvm.icmp "eq" %0, %1 : i8 + llvm.call @use1(%2) : (i1) -> () + llvm.return + } + llvm.func @bzip2(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.add %arg0, %arg2 : i8 + %1 = llvm.add %arg1, %arg2 : i8 + %2 = llvm.icmp "eq" %0, %1 : i8 + llvm.call @use1(%2) : (i1) -> () + llvm.call @use8(%0) : (i8) -> () + llvm.return + } + llvm.func @icmp_eq_add_undef(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %8 = llvm.add %arg0, %6 : vector<2xi32> + %9 = llvm.icmp "eq" %8, %7 : vector<2xi32> + llvm.return %9 : vector<2xi1> + } + llvm.func @icmp_eq_add_non_splat(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[5, 6]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %arg0, %0 : vector<2xi32> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_eq_add_undef2(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(10 : i32) : i32 + %3 = llvm.mlir.undef : vector<2xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi32> + %8 = llvm.add %arg0, %0 : vector<2xi32> + %9 = llvm.icmp "eq" %8, %7 : vector<2xi32> + llvm.return %9 : vector<2xi1> + } + llvm.func @icmp_eq_add_non_splat2(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[10, 11]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %arg0, %0 : vector<2xi32> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @without_nsw_nuw(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(37 : i8) : i8 + %1 = llvm.mlir.constant(35 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.add %arg1, %1 : i8 + %4 = llvm.icmp "eq" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @with_nsw_nuw(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(37 : i8) : i8 + %1 = llvm.mlir.constant(35 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.add %arg1, %1 : i8 + %4 = llvm.icmp "eq" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @with_nsw_large(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(37 : i8) : i8 + %1 = llvm.mlir.constant(35 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.add %arg1, %1 : i8 + %4 = llvm.icmp "eq" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @with_nsw_small(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(35 : i8) : i8 + %1 = llvm.mlir.constant(37 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.add %arg1, %1 : i8 + %4 = llvm.icmp "eq" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @with_nuw_large(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(37 : i8) : i8 + %1 = llvm.mlir.constant(35 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.add %arg1, %1 : i8 + %4 = llvm.icmp "eq" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @with_nuw_small(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(35 : i8) : i8 + %1 = llvm.mlir.constant(37 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.add %arg1, %1 : i8 + %4 = llvm.icmp "eq" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @with_nuw_large_negative(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-37 : i8) : i8 + %1 = llvm.mlir.constant(-35 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.add %arg1, %1 : i8 + %4 = llvm.icmp "eq" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @ugt_offset(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(124 : i8) : i8 + %1 = llvm.mlir.constant(-5 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ugt_offset_use(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-2147483607 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "ugt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @ugt_offset_splat(%arg0: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.mlir.constant(9 : i5) : i5 + %1 = llvm.mlir.constant(dense<9> : vector<2xi5>) : vector<2xi5> + %2 = llvm.mlir.constant(-8 : i5) : i5 + %3 = llvm.mlir.constant(dense<-8> : vector<2xi5>) : vector<2xi5> + %4 = llvm.add %arg0, %1 : vector<2xi5> + %5 = llvm.icmp "ugt" %4, %3 : vector<2xi5> + llvm.return %5 : vector<2xi1> + } + llvm.func @ugt_wrong_offset(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-5 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ugt_offset_nuw(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(124 : i8) : i8 + %1 = llvm.mlir.constant(-5 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_offset(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-6 : i8) : i8 + %1 = llvm.mlir.constant(122 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_offset_use(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-2147483606 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "ult" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @ult_offset_splat(%arg0: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.mlir.constant(9 : i5) : i5 + %1 = llvm.mlir.constant(dense<9> : vector<2xi5>) : vector<2xi5> + %2 = llvm.mlir.constant(-7 : i5) : i5 + %3 = llvm.mlir.constant(dense<-7> : vector<2xi5>) : vector<2xi5> + %4 = llvm.add %arg0, %1 : vector<2xi5> + %5 = llvm.icmp "ult" %4, %3 : vector<2xi5> + llvm.return %5 : vector<2xi1> + } + llvm.func @ult_wrong_offset(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-6 : i8) : i8 + %1 = llvm.mlir.constant(123 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_offset_nuw(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(-86 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @sgt_offset(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-6 : i8) : i8 + %1 = llvm.mlir.constant(-7 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @sgt_offset_use(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(41 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "sgt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @sgt_offset_splat(%arg0: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.mlir.constant(9 : i5) : i5 + %1 = llvm.mlir.constant(dense<9> : vector<2xi5>) : vector<2xi5> + %2 = llvm.mlir.constant(8 : i5) : i5 + %3 = llvm.mlir.constant(dense<8> : vector<2xi5>) : vector<2xi5> + %4 = llvm.add %arg0, %1 : vector<2xi5> + %5 = llvm.icmp "sgt" %4, %3 : vector<2xi5> + llvm.return %5 : vector<2xi1> + } + llvm.func @sgt_wrong_offset(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-7 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.icmp "sgt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @sgt_offset_nsw(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(41 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @slt_offset(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-6 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.icmp "slt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @slt_offset_use(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @slt_offset_splat(%arg0: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.mlir.constant(9 : i5) : i5 + %1 = llvm.mlir.constant(dense<9> : vector<2xi5>) : vector<2xi5> + %2 = llvm.add %arg0, %1 : vector<2xi5> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi5> + llvm.return %3 : vector<2xi1> + } + llvm.func @slt_wrong_offset(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-6 : i8) : i8 + %1 = llvm.mlir.constant(-7 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @slt_offset_nsw(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.add %arg0, %0 overflow : i8 + %2 = llvm.icmp "slt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @increment_max(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @decrement_max(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @increment_min(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @decrement_min(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @icmp_add_add_C(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.add %1, %0 : i32 + %3 = llvm.icmp "ult" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_add_add_C_pred(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.add %1, %0 : i32 + %3 = llvm.icmp "uge" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_add_add_C_wrong_pred(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.add %1, %0 : i32 + %3 = llvm.icmp "ule" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_add_add_C_wrong_operand(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.add %1, %0 : i32 + %3 = llvm.icmp "ult" %2, %arg2 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_add_add_C_different_const(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.add %1, %0 : i32 + %3 = llvm.icmp "ult" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_add_add_C_vector(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[10, 20]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.add %arg0, %arg1 : vector<2xi8> + %2 = llvm.add %1, %0 : vector<2xi8> + %3 = llvm.icmp "ult" %2, %arg0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_add_add_C_vector_undef(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.undef : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.add %arg0, %arg1 : vector<2xi8> + %8 = llvm.add %7, %6 : vector<2xi8> + %9 = llvm.icmp "ult" %8, %arg0 : vector<2xi8> + llvm.return %9 : vector<2xi1> + } + llvm.func @icmp_add_add_C_comm1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg1, %arg0 : i32 + %2 = llvm.add %1, %0 : i32 + %3 = llvm.icmp "ult" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_add_add_C_comm2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.add %2, %arg1 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.icmp "ugt" %2, %4 : i32 + llvm.return %5 : i1 + } + llvm.func @icmp_add_add_C_comm2_pred(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.add %2, %arg1 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.icmp "ule" %2, %4 : i32 + llvm.return %5 : i1 + } + llvm.func @icmp_add_add_C_comm2_wrong_pred(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.add %2, %arg1 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.icmp "ult" %2, %4 : i32 + llvm.return %5 : i1 + } + llvm.func @icmp_add_add_C_comm3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.add %arg1, %2 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.icmp "ugt" %2, %4 : i32 + llvm.return %5 : i1 + } + llvm.func @icmp_add_add_C_extra_use1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.add %1, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "ult" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_add_add_C_extra_use2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.add %1, %0 : i32 + %3 = llvm.icmp "ult" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_dec_assume_nonzero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.add %arg0, %1 : i8 + %5 = llvm.icmp "ult" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @icmp_dec_sub_assume_nonzero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(11 : i8) : i8 + %3 = llvm.icmp "ne" %arg0, %0 : i8 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.sub %arg0, %1 : i8 + %5 = llvm.icmp "ult" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @icmp_dec_nonzero(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.mlir.constant(7 : i16) : i16 + %3 = llvm.or %arg0, %0 : i16 + %4 = llvm.add %3, %1 : i16 + %5 = llvm.icmp "ult" %4, %2 : i16 + llvm.return %5 : i1 + } + llvm.func @icmp_dec_nonzero_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[15, 17]> : vector<2xi32>) : vector<2xi32> + %3 = llvm.or %arg0, %0 : vector<2xi32> + %4 = llvm.add %3, %1 : vector<2xi32> + %5 = llvm.icmp "ult" %4, %2 : vector<2xi32> + llvm.return %5 : vector<2xi1> + } + llvm.func @icmp_dec_notnonzero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_addnuw_nonzero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.add %arg0, %arg1 overflow : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @icmp_addnuw_nonzero_fail_multiuse(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.add %arg0, %arg1 overflow : i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.call @use(%1) : (i32) -> () + llvm.return %2 : i1 + } + llvm.func @ult_add_C2_pow2_C_neg(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(32 : i8) : i8 + %1 = llvm.mlir.constant(-32 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_add_nsw_C2_pow2_C_neg(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(32 : i8) : i8 + %1 = llvm.mlir.constant(-32 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_add_nuw_nsw_C2_pow2_C_neg(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(32 : i8) : i8 + %1 = llvm.mlir.constant(-32 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_add_C2_neg_C_pow2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-32 : i8) : i8 + %1 = llvm.mlir.constant(32 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_add_C2_pow2_C_neg_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-32> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "ult" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @ult_add_C2_pow2_C_neg_multiuse(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(32 : i8) : i8 + %1 = llvm.mlir.constant(-32 : i8) : i8 + %2 = llvm.mlir.addressof @use : !llvm.ptr + %3 = llvm.add %arg0, %0 : i8 + %4 = llvm.icmp "ult" %3, %1 : i8 + llvm.call %2(%3) : !llvm.ptr, (i8) -> () + llvm.return %4 : i1 + } + llvm.func @uge_add_C2_pow2_C_neg(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(32 : i8) : i8 + %1 = llvm.mlir.constant(-32 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.icmp "uge" %2, %1 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-and-add-sub-xor-p2.ll.mlir b/test/LLVMDialect/InstCombine/icmp-and-add-sub-xor-p2.ll.mlir new file mode 100644 index 000000000..cc84d30d1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-and-add-sub-xor-p2.ll.mlir @@ -0,0 +1,91 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use.i8(i8) + llvm.func @use.v2i8(vector<2xi8>) + llvm.func @src_add_eq_p2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + %2 = llvm.and %1, %arg1 : i8 + %3 = llvm.add %2, %arg0 : i8 + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.and %3, %2 : i8 + %5 = llvm.icmp "eq" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @src_add_eq_p2_fail_multiuse(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + %2 = llvm.and %1, %arg1 : i8 + %3 = llvm.add %arg0, %2 : i8 + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.and %3, %2 : i8 + llvm.call @use.i8(%4) : (i8) -> () + %5 = llvm.icmp "eq" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @src_xor_ne_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + %2 = llvm.and %1, %arg1 : i8 + %3 = llvm.xor %arg0, %2 : i8 + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.and %3, %2 : i8 + %5 = llvm.icmp "ne" %4, %0 : i8 + llvm.return %5 : i1 + } + llvm.func @src_xor_ne_zero_fail_different_p2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.sub %0, %arg1 : i8 + %3 = llvm.and %2, %arg1 : i8 + %4 = llvm.shl %3, %1 : i8 + %5 = llvm.xor %arg0, %3 : i8 + llvm.call @use.i8(%5) : (i8) -> () + %6 = llvm.and %5, %4 : i8 + %7 = llvm.icmp "ne" %6, %0 : i8 + llvm.return %7 : i1 + } + llvm.func @src_sub_ne_p2(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.sub %1, %arg1 : vector<2xi8> + %3 = llvm.and %2, %arg1 : vector<2xi8> + %4 = llvm.sub %arg0, %3 : vector<2xi8> + llvm.call @use.v2i8(%4) : (vector<2xi8>) -> () + %5 = llvm.and %4, %3 : vector<2xi8> + %6 = llvm.icmp "ne" %5, %3 : vector<2xi8> + llvm.return %6 : vector<2xi1> + } + llvm.func @src_sub_eq_zero(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.shl %0, %arg1 : vector<2xi8> + %4 = llvm.sub %arg0, %3 : vector<2xi8> + llvm.call @use.v2i8(%4) : (vector<2xi8>) -> () + %5 = llvm.and %4, %3 : vector<2xi8> + %6 = llvm.icmp "eq" %5, %2 : vector<2xi8> + llvm.return %6 : vector<2xi1> + } + llvm.func @src_sub_eq_zero_fail_commuted(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.shl %0, %arg1 : vector<2xi8> + %4 = llvm.sub %3, %arg0 : vector<2xi8> + llvm.call @use.v2i8(%4) : (vector<2xi8>) -> () + %5 = llvm.and %4, %3 : vector<2xi8> + %6 = llvm.icmp "eq" %5, %2 : vector<2xi8> + llvm.return %6 : vector<2xi1> + } + llvm.func @src_sub_eq_zero_fail_non_p2(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, 3]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.shl %0, %arg1 : vector<2xi8> + %4 = llvm.sub %arg0, %3 : vector<2xi8> + llvm.call @use.v2i8(%4) : (vector<2xi8>) -> () + %5 = llvm.and %4, %3 : vector<2xi8> + %6 = llvm.icmp "eq" %5, %2 : vector<2xi8> + llvm.return %6 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-and-lowbit-mask.ll.mlir b/test/LLVMDialect/InstCombine/icmp-and-lowbit-mask.ll.mlir new file mode 100644 index 000000000..036f6ec8a --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-and-lowbit-mask.ll.mlir @@ -0,0 +1,578 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use.i8(i8) + llvm.func @use.i16(i16) + llvm.func @src_is_mask_zext(%arg0: i16, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i16 + %3 = llvm.lshr %1, %arg1 : i8 + %4 = llvm.zext %3 : i8 to i16 + %5 = llvm.and %2, %4 : i16 + %6 = llvm.icmp "eq" %5, %2 : i16 + llvm.return %6 : i1 + } + llvm.func @src_is_mask_zext_fail_not_mask(%arg0: i16, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i16) : i16 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i16 + %3 = llvm.lshr %1, %arg1 : i8 + %4 = llvm.zext %3 : i8 to i16 + %5 = llvm.and %2, %4 : i16 + %6 = llvm.icmp "eq" %5, %2 : i16 + llvm.return %6 : i1 + } + llvm.func @src_is_mask_sext(%arg0: i16, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i16) : i16 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.xor %arg0, %0 : i16 + %5 = llvm.lshr %1, %arg1 : i8 + %6 = llvm.sext %5 : i8 to i16 + %7 = llvm.xor %6, %2 : i16 + %8 = llvm.and %7, %4 : i16 + %9 = llvm.icmp "eq" %8, %3 : i16 + llvm.return %9 : i1 + } + llvm.func @src_is_mask_sext_fail_multiuse(%arg0: i16, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.xor %arg0, %0 : i16 + %5 = llvm.lshr %1, %arg1 : i8 + %6 = llvm.sext %5 : i8 to i16 + %7 = llvm.xor %6, %2 : i16 + %8 = llvm.and %7, %4 : i16 + llvm.call @use.i16(%8) : (i16) -> () + %9 = llvm.icmp "eq" %8, %3 : i16 + llvm.return %9 : i1 + } + llvm.func @src_is_mask_and(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.ashr %1, %arg1 : i8 + %5 = llvm.lshr %2, %arg2 : i8 + %6 = llvm.and %4, %5 : i8 + %7 = llvm.and %3, %6 : i8 + %8 = llvm.icmp "eq" %3, %7 : i8 + llvm.return %8 : i1 + } + llvm.func @src_is_mask_and_fail_mixed(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-8 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.ashr %1, %arg1 : i8 + %5 = llvm.lshr %2, %arg2 : i8 + %6 = llvm.and %4, %5 : i8 + %7 = llvm.and %3, %6 : i8 + %8 = llvm.icmp "eq" %3, %7 : i8 + llvm.return %8 : i1 + } + llvm.func @src_is_mask_or(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.lshr %1, %arg1 : i8 + %5 = llvm.and %4, %2 : i8 + %6 = llvm.and %5, %3 : i8 + %7 = llvm.icmp "eq" %3, %6 : i8 + llvm.return %7 : i1 + } + llvm.func @src_is_mask_xor(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.add %arg1, %1 : i8 + %4 = llvm.xor %arg1, %3 : i8 + %5 = llvm.and %2, %4 : i8 + %6 = llvm.icmp "ne" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @src_is_mask_xor_fail_notmask(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.add %arg1, %1 : i8 + %4 = llvm.xor %arg1, %3 : i8 + %5 = llvm.xor %4, %1 : i8 + %6 = llvm.and %2, %5 : i8 + %7 = llvm.icmp "ne" %6, %2 : i8 + llvm.return %7 : i1 + } + llvm.func @src_is_mask_select(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(15 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.add %arg1, %1 : i8 + %5 = llvm.xor %arg1, %4 : i8 + %6 = llvm.select %arg2, %5, %2 : i1, i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.icmp "ne" %7, %3 : i8 + llvm.return %8 : i1 + } + llvm.func @src_is_mask_select_fail_wrong_pattern(%arg0: i8, %arg1: i8, %arg2: i1, %arg3: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(15 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.add %arg1, %1 : i8 + %5 = llvm.xor %arg1, %4 : i8 + %6 = llvm.select %arg2, %5, %2 : i1, i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.icmp "ne" %7, %arg3 : i8 + llvm.return %8 : i1 + } + llvm.func @src_is_mask_shl_lshr(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.shl %1, %arg1 : i8 + %5 = llvm.lshr %4, %arg1 : i8 + %6 = llvm.xor %5, %1 : i8 + %7 = llvm.and %3, %6 : i8 + %8 = llvm.icmp "ne" %2, %7 : i8 + llvm.return %8 : i1 + } + llvm.func @src_is_mask_shl_lshr_fail_not_allones(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.xor %arg0, %0 : i8 + %5 = llvm.shl %1, %arg1 : i8 + %6 = llvm.lshr %5, %arg1 : i8 + %7 = llvm.xor %6, %2 : i8 + %8 = llvm.and %4, %7 : i8 + %9 = llvm.icmp "ne" %3, %8 : i8 + llvm.return %9 : i1 + } + llvm.func @src_is_mask_lshr(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i1) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(15 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.add %arg1, %1 : i8 + %5 = llvm.xor %arg1, %4 : i8 + %6 = llvm.select %arg3, %5, %2 : i1, i8 + %7 = llvm.lshr %6, %arg2 : i8 + %8 = llvm.and %7, %3 : i8 + %9 = llvm.icmp "ne" %3, %8 : i8 + llvm.return %9 : i1 + } + llvm.func @src_is_mask_ashr(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i1) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(15 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.add %arg1, %1 : i8 + %5 = llvm.xor %arg1, %4 : i8 + %6 = llvm.select %arg3, %5, %2 : i1, i8 + %7 = llvm.ashr %6, %arg2 : i8 + %8 = llvm.and %3, %7 : i8 + %9 = llvm.icmp "ult" %8, %3 : i8 + llvm.return %9 : i1 + } + llvm.func @src_is_mask_p2_m1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.shl %1, %arg1 : i8 + %5 = llvm.add %4, %2 : i8 + %6 = llvm.and %5, %3 : i8 + %7 = llvm.icmp "ult" %6, %3 : i8 + llvm.return %7 : i1 + } + llvm.func @src_is_mask_umax(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.add %arg1, %1 : i8 + %5 = llvm.xor %arg1, %4 : i8 + %6 = llvm.intr.umax(%5, %2) : (i8, i8) -> i8 + %7 = llvm.and %3, %6 : i8 + %8 = llvm.icmp "ugt" %3, %7 : i8 + llvm.return %8 : i1 + } + llvm.func @src_is_mask_umin(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(15 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.add %arg1, %1 : i8 + %5 = llvm.xor %arg1, %4 : i8 + %6 = llvm.lshr %2, %arg2 : i8 + %7 = llvm.intr.umin(%5, %6) : (i8, i8) -> i8 + %8 = llvm.and %7, %3 : i8 + %9 = llvm.icmp "ugt" %3, %8 : i8 + llvm.return %9 : i1 + } + llvm.func @src_is_mask_umin_fail_mismatch(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(-32 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.add %arg1, %1 : i8 + %5 = llvm.xor %arg1, %4 : i8 + %6 = llvm.intr.umin(%5, %2) : (i8, i8) -> i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.icmp "ugt" %3, %7 : i8 + llvm.return %8 : i1 + } + llvm.func @src_is_mask_smax(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.add %arg1, %1 : i8 + %4 = llvm.xor %arg1, %3 : i8 + %5 = llvm.intr.smax(%4, %1) : (i8, i8) -> i8 + %6 = llvm.and %2, %5 : i8 + %7 = llvm.icmp "uge" %6, %2 : i8 + llvm.return %7 : i1 + } + llvm.func @src_is_mask_smin(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.add %arg1, %1 : i8 + %5 = llvm.xor %arg1, %4 : i8 + %6 = llvm.intr.smin(%5, %2) : (i8, i8) -> i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.icmp "uge" %7, %3 : i8 + llvm.return %8 : i1 + } + llvm.func @src_is_mask_bitreverse_not_mask(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.shl %1, %arg1 : i8 + %4 = llvm.intr.bitreverse(%3) : (i8) -> i8 + %5 = llvm.and %2, %4 : i8 + %6 = llvm.icmp "ule" %2, %5 : i8 + llvm.return %6 : i1 + } + llvm.func @src_is_notmask_sext(%arg0: i16, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i16) : i16 + %1 = llvm.mlir.constant(-8 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.xor %arg0, %0 : i16 + %4 = llvm.shl %1, %arg1 : i8 + %5 = llvm.sext %4 : i8 to i16 + %6 = llvm.xor %5, %2 : i16 + %7 = llvm.and %6, %3 : i16 + %8 = llvm.icmp "ule" %3, %7 : i16 + llvm.return %8 : i1 + } + llvm.func @src_is_notmask_shl(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(-8 : i8) : i8 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.xor %arg0, %0 : i8 + %5 = llvm.shl %1, %arg1 : i8 + %6 = llvm.intr.bitreverse(%5) : (i8) -> i8 + %7 = llvm.xor %6, %1 : i8 + %8 = llvm.select %arg2, %7, %2 : i1, i8 + %9 = llvm.and %4, %8 : i8 + %10 = llvm.icmp "eq" %9, %3 : i8 + llvm.return %10 : i1 + } + llvm.func @src_is_notmask_x_xor_neg_x(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(-8 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.sub %1, %arg1 : i8 + %5 = llvm.xor %arg1, %4 : i8 + %6 = llvm.select %arg2, %5, %2 : i1, i8 + %7 = llvm.and %3, %6 : i8 + %8 = llvm.icmp "eq" %7, %1 : i8 + llvm.return %8 : i1 + } + llvm.func @src_is_notmask_x_xor_neg_x_inv(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(-8 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.sub %1, %arg1 : i8 + %5 = llvm.xor %arg1, %4 : i8 + %6 = llvm.select %arg2, %5, %2 : i1, i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.icmp "eq" %7, %1 : i8 + llvm.return %8 : i1 + } + llvm.func @src_is_notmask_shl_fail_multiuse_invert(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(-8 : i8) : i8 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.xor %arg0, %0 : i8 + %5 = llvm.shl %1, %arg1 : i8 + %6 = llvm.intr.bitreverse(%5) : (i8) -> i8 + %7 = llvm.xor %6, %1 : i8 + %8 = llvm.select %arg2, %7, %2 : i1, i8 + llvm.call @use.i8(%8) : (i8) -> () + %9 = llvm.and %4, %8 : i8 + %10 = llvm.icmp "eq" %9, %3 : i8 + llvm.return %10 : i1 + } + llvm.func @src_is_notmask_lshr_shl(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.lshr %1, %arg1 : i8 + %4 = llvm.shl %3, %arg1 : i8 + %5 = llvm.xor %4, %1 : i8 + %6 = llvm.and %5, %2 : i8 + %7 = llvm.icmp "eq" %6, %2 : i8 + llvm.return %7 : i1 + } + llvm.func @src_is_notmask_lshr_shl_fail_mismatch_shifts(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.lshr %1, %arg1 : i8 + %4 = llvm.shl %3, %arg2 : i8 + %5 = llvm.xor %4, %1 : i8 + %6 = llvm.and %5, %2 : i8 + %7 = llvm.icmp "eq" %6, %2 : i8 + llvm.return %7 : i1 + } + llvm.func @src_is_notmask_ashr(%arg0: i16, %arg1: i8, %arg2: i16) -> i1 { + %0 = llvm.mlir.constant(123 : i16) : i16 + %1 = llvm.mlir.constant(-32 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.xor %arg0, %0 : i16 + %4 = llvm.shl %1, %arg1 : i8 + %5 = llvm.sext %4 : i8 to i16 + %6 = llvm.ashr %5, %arg2 : i16 + %7 = llvm.xor %6, %2 : i16 + %8 = llvm.and %3, %7 : i16 + %9 = llvm.icmp "eq" %3, %8 : i16 + llvm.return %9 : i1 + } + llvm.func @src_is_notmask_neg_p2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.sub %1, %arg1 : i8 + %5 = llvm.and %4, %arg1 : i8 + %6 = llvm.sub %1, %5 : i8 + %7 = llvm.intr.bitreverse(%6) : (i8) -> i8 + %8 = llvm.xor %7, %2 : i8 + %9 = llvm.and %8, %3 : i8 + %10 = llvm.icmp "eq" %1, %9 : i8 + llvm.return %10 : i1 + } + llvm.func @src_is_notmask_neg_p2_fail_not_invertable(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.sub %1, %arg1 : i8 + %4 = llvm.and %3, %arg1 : i8 + %5 = llvm.sub %1, %4 : i8 + %6 = llvm.and %5, %2 : i8 + %7 = llvm.icmp "eq" %1, %6 : i8 + llvm.return %7 : i1 + } + llvm.func @src_is_notmask_xor_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.add %arg1, %1 : i8 + %4 = llvm.xor %arg1, %3 : i8 + %5 = llvm.xor %4, %1 : i8 + %6 = llvm.intr.bitreverse(%5) : (i8) -> i8 + %7 = llvm.and %2, %6 : i8 + %8 = llvm.icmp "slt" %7, %2 : i8 + llvm.return %8 : i1 + } + llvm.func @src_is_mask_const_slt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "slt" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @src_is_mask_const_sgt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "sgt" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @src_is_mask_const_sle(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "sle" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @src_is_mask_const_sge(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "sge" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @src_x_and_mask_slt(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %0, %arg1 : i8 + %3 = llvm.select %arg2, %2, %1 : i1, i8 + %4 = llvm.icmp "sge" %3, %1 : i8 + "llvm.intr.assume"(%4) : (i1) -> () + %5 = llvm.and %arg0, %3 : i8 + %6 = llvm.icmp "slt" %5, %arg0 : i8 + llvm.return %6 : i1 + } + llvm.func @src_x_and_mask_sge(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %0, %arg1 : i8 + %3 = llvm.select %arg2, %2, %1 : i1, i8 + %4 = llvm.icmp "sge" %3, %1 : i8 + "llvm.intr.assume"(%4) : (i1) -> () + %5 = llvm.and %arg0, %3 : i8 + %6 = llvm.icmp "sge" %5, %arg0 : i8 + llvm.return %6 : i1 + } + llvm.func @src_x_and_mask_slt_fail_maybe_neg(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %0, %arg1 : i8 + %3 = llvm.select %arg2, %2, %1 : i1, i8 + %4 = llvm.and %arg0, %3 : i8 + %5 = llvm.icmp "slt" %4, %arg0 : i8 + llvm.return %5 : i1 + } + llvm.func @src_x_and_mask_sge_fail_maybe_neg(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %0, %arg1 : i8 + %3 = llvm.select %arg2, %2, %1 : i1, i8 + %4 = llvm.and %arg0, %3 : i8 + %5 = llvm.icmp "sge" %4, %arg0 : i8 + llvm.return %5 : i1 + } + llvm.func @src_x_and_nmask_eq(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.select %arg2, %2, %1 : i1, i8 + %4 = llvm.and %arg0, %3 : i8 + %5 = llvm.icmp "eq" %3, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @src_x_and_nmask_ne(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.select %arg2, %2, %1 : i1, i8 + %4 = llvm.and %arg0, %3 : i8 + %5 = llvm.icmp "ne" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @src_x_and_nmask_ult(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.select %arg2, %2, %1 : i1, i8 + %4 = llvm.and %arg0, %3 : i8 + %5 = llvm.icmp "ult" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @src_x_and_nmask_uge(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.select %arg2, %2, %1 : i1, i8 + %4 = llvm.and %arg0, %3 : i8 + %5 = llvm.icmp "uge" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @src_x_and_nmask_slt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.and %arg0, %1 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @src_x_and_nmask_sge(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.and %arg0, %1 : i8 + %3 = llvm.icmp "sge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @src_x_and_nmask_slt_fail_maybe_z(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.select %arg2, %2, %1 : i1, i8 + %4 = llvm.and %arg0, %3 : i8 + %5 = llvm.icmp "slt" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @src_x_and_nmask_sge_fail_maybe_z(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.select %arg2, %2, %1 : i1, i8 + %4 = llvm.and %arg0, %3 : i8 + %5 = llvm.icmp "sge" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @src_x_or_mask_eq(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(123 : i8) : i8 + %3 = llvm.mlir.constant(45 : i8) : i8 + %4 = llvm.mlir.constant(12 : i8) : i8 + %5 = llvm.lshr %0, %arg1 : i8 + %6 = llvm.select %arg4, %5, %1 : i1, i8 + %7 = llvm.xor %arg0, %2 : i8 + %8 = llvm.select %arg3, %7, %3 : i1, i8 + %9 = llvm.xor %arg2, %0 : i8 + %10 = llvm.intr.umin(%9, %8) : (i8, i8) -> i8 + %11 = llvm.add %10, %4 : i8 + %12 = llvm.or %11, %6 : i8 + %13 = llvm.icmp "eq" %12, %0 : i8 + llvm.return %13 : i1 + } + llvm.func @src_x_or_mask_ne(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %0, %arg1 : i8 + %3 = llvm.select %arg2, %2, %1 : i1, i8 + %4 = llvm.xor %arg0, %0 : i8 + %5 = llvm.or %3, %4 : i8 + %6 = llvm.icmp "ne" %5, %0 : i8 + llvm.return %6 : i1 + } + llvm.func @src_x_or_mask_ne_fail_multiuse(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %0, %arg1 : i8 + %3 = llvm.select %arg2, %2, %1 : i1, i8 + %4 = llvm.xor %arg0, %0 : i8 + %5 = llvm.or %3, %4 : i8 + llvm.call @use.i8(%5) : (i8) -> () + %6 = llvm.icmp "ne" %5, %0 : i8 + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-and-shift.ll.mlir b/test/LLVMDialect/InstCombine/icmp-and-shift.ll.mlir new file mode 100644 index 000000000..9e255c024 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-and-shift.ll.mlir @@ -0,0 +1,453 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @icmp_eq_and_pow2_shl1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_eq_and_pow2_shl1_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.shl %0, %arg0 : vector<2xi32> + %5 = llvm.and %4, %1 : vector<2xi32> + %6 = llvm.icmp "eq" %5, %3 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi1> to vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @icmp_ne_and_pow2_shl1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "ne" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_ne_and_pow2_shl1_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.shl %0, %arg0 : vector<2xi32> + %5 = llvm.and %4, %1 : vector<2xi32> + %6 = llvm.icmp "ne" %5, %3 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi1> to vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @icmp_eq_and_pow2_shl_pow2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_eq_and_pow2_shl_pow2_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.shl %0, %arg0 : vector<2xi32> + %5 = llvm.and %4, %1 : vector<2xi32> + %6 = llvm.icmp "eq" %5, %3 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi1> to vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @icmp_ne_and_pow2_shl_pow2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "ne" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_ne_and_pow2_shl_pow2_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.shl %0, %arg0 : vector<2xi32> + %5 = llvm.and %4, %1 : vector<2xi32> + %6 = llvm.icmp "ne" %5, %3 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi1> to vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @icmp_eq_and_pow2_shl_pow2_negative1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(11 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_eq_and_pow2_shl_pow2_negative2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(14 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_eq_and_pow2_shl_pow2_negative3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_eq_and_pow2_minus1_shl1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_eq_and_pow2_minus1_shl1_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.shl %0, %arg0 : vector<2xi32> + %5 = llvm.and %4, %1 : vector<2xi32> + %6 = llvm.icmp "eq" %5, %3 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi1> to vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @icmp_ne_and_pow2_minus1_shl1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "ne" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_ne_and_pow2_minus1_shl1_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.shl %0, %arg0 : vector<2xi32> + %5 = llvm.and %4, %1 : vector<2xi32> + %6 = llvm.icmp "ne" %5, %3 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi1> to vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @icmp_eq_and_pow2_minus1_shl_pow2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_eq_and_pow2_minus1_shl_pow2_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.shl %0, %arg0 : vector<2xi32> + %5 = llvm.and %4, %1 : vector<2xi32> + %6 = llvm.icmp "eq" %5, %3 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi1> to vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @icmp_ne_and_pow2_minus1_shl_pow2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "ne" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_ne_and_pow2_minus1_shl_pow2_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.shl %0, %arg0 : vector<2xi32> + %5 = llvm.and %4, %1 : vector<2xi32> + %6 = llvm.icmp "ne" %5, %3 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi1> to vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @icmp_eq_and_pow2_minus1_shl1_negative1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_eq_and_pow2_minus1_shl1_negative2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_eq_and1_lshr_pow2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_eq_and1_lshr_pow2_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.lshr %0, %arg0 : vector<2xi32> + %5 = llvm.and %4, %1 : vector<2xi32> + %6 = llvm.icmp "eq" %5, %3 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi1> to vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @icmp_ne_and1_lshr_pow2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_ne_and1_lshr_pow2_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.lshr %0, %arg0 : vector<2xi32> + %5 = llvm.and %4, %1 : vector<2xi32> + %6 = llvm.icmp "ne" %5, %3 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi1> to vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @icmp_eq_and_pow2_lshr_pow2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_eq_and_pow2_lshr_pow2_case2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_eq_and_pow2_lshr_pow2_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.lshr %0, %arg0 : vector<2xi32> + %5 = llvm.and %4, %1 : vector<2xi32> + %6 = llvm.icmp "eq" %5, %3 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi1> to vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @icmp_ne_and_pow2_lshr_pow2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_ne_and_pow2_lshr_pow2_case2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_ne_and_pow2_lshr_pow2_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.lshr %0, %arg0 : vector<2xi32> + %5 = llvm.and %4, %1 : vector<2xi32> + %6 = llvm.icmp "ne" %5, %3 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi1> to vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @icmp_eq_and1_lshr_pow2_negative1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @icmp_eq_and1_lshr_pow2_negative2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @eq_and_shl_one(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ne_and_shl_one_commute(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.shl %6, %arg1 : vector<2xi8> + %8 = llvm.and %7, %arg0 : vector<2xi8> + %9 = llvm.icmp "ne" %7, %8 : vector<2xi8> + llvm.return %9 : vector<2xi1> + } + llvm.func @ne_and_lshr_minval(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mul %arg0, %arg0 : i8 + %2 = llvm.lshr %0, %arg1 : i8 + %3 = llvm.and %1, %2 : i8 + %4 = llvm.icmp "ne" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @eq_and_lshr_minval_commute(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mul %arg0, %arg0 : i8 + %2 = llvm.lshr %0, %arg1 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.and %1, %2 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.icmp "eq" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @eq_and_shl_two(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.and %arg0, %1 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @slt_and_shl_one(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.and %arg0, %1 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @fold_eq_lhs(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + %3 = llvm.and %2, %arg1 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @fold_eq_lhs_fail_eq_nonzero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + %3 = llvm.and %2, %arg1 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @fold_eq_lhs_fail_multiuse_shl(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.and %2, %arg1 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @fold_ne_rhs(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.xor %arg1, %0 : i8 + %4 = llvm.shl %1, %arg0 : i8 + %5 = llvm.and %3, %4 : i8 + %6 = llvm.icmp "ne" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @fold_ne_rhs_fail_multiuse_and(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.xor %arg1, %0 : i8 + %4 = llvm.shl %1, %arg0 : i8 + %5 = llvm.and %3, %4 : i8 + llvm.call @use(%5) : (i8) -> () + %6 = llvm.icmp "ne" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @fold_ne_rhs_fail_shift_not_1s(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.xor %arg1, %0 : i8 + %4 = llvm.shl %1, %arg0 : i8 + %5 = llvm.and %3, %4 : i8 + %6 = llvm.icmp "ne" %5, %2 : i8 + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-bc-vec-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/icmp-bc-vec-inseltpoison.ll.mlir new file mode 100644 index 000000000..f701e8522 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-bc-vec-inseltpoison.ll.mlir @@ -0,0 +1,88 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_i1_0(%arg0: i1) -> i1 { + %0 = llvm.mlir.poison : vector<4xi1> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i4) : i4 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi1> + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : vector<4xi1> + %5 = llvm.bitcast %4 : vector<4xi1> to i4 + %6 = llvm.icmp "eq" %5, %2 : i4 + llvm.return %6 : i1 + } + llvm.func @test_i1_0_2(%arg0: i1) -> i1 { + %0 = llvm.mlir.poison : vector<4xi1> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i4) : i4 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi1> + %4 = llvm.shufflevector %3, %0 [2, 2, 2, 2] : vector<4xi1> + %5 = llvm.bitcast %4 : vector<4xi1> to i4 + %6 = llvm.icmp "eq" %5, %2 : i4 + llvm.return %6 : i1 + } + llvm.func @test_i1_m1(%arg0: i1) -> i1 { + %0 = llvm.mlir.poison : vector<4xi1> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i4) : i4 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi1> + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : vector<4xi1> + %5 = llvm.bitcast %4 : vector<4xi1> to i4 + %6 = llvm.icmp "eq" %5, %2 : i4 + llvm.return %6 : i1 + } + llvm.func @test_i8_pattern(%arg0: i8) -> i1 { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1212696648 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi8> + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : vector<4xi8> + %5 = llvm.bitcast %4 : vector<4xi8> to i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @test_i8_pattern_2(%arg0: i8) -> i1 { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(1212696648 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi8> + %4 = llvm.shufflevector %3, %0 [2, 2, 2, 2] : vector<4xi8> + %5 = llvm.bitcast %4 : vector<4xi8> to i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @test_i8_pattern_3(%arg0: vector<4xi8>) -> i1 { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(1212696648 : i32) : i32 + %2 = llvm.shufflevector %arg0, %0 [1, 0, 3, 2] : vector<4xi8> + %3 = llvm.bitcast %2 : vector<4xi8> to i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @test_i8_nopattern(%arg0: i8) -> i1 { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1212696647 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi8> + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : vector<4xi8> + %5 = llvm.bitcast %4 : vector<4xi8> to i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @test_i8_ult_pattern(%arg0: i8) -> i1 { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1212696648 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi8> + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : vector<4xi8> + %5 = llvm.bitcast %4 : vector<4xi8> to i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @extending_shuffle_with_weird_types(%arg0: vector<2xi9>) -> i1 { + %0 = llvm.mlir.poison : vector<2xi9> + %1 = llvm.mlir.constant(262657 : i27) : i27 + %2 = llvm.shufflevector %arg0, %0 [0, 0, 0] : vector<2xi9> + %3 = llvm.bitcast %2 : vector<3xi9> to i27 + %4 = llvm.icmp "slt" %3, %1 : i27 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-bc-vec.ll.mlir b/test/LLVMDialect/InstCombine/icmp-bc-vec.ll.mlir new file mode 100644 index 000000000..27838a0cf --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-bc-vec.ll.mlir @@ -0,0 +1,88 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_i1_0(%arg0: i1) -> i1 { + %0 = llvm.mlir.undef : vector<4xi1> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i4) : i4 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi1> + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : vector<4xi1> + %5 = llvm.bitcast %4 : vector<4xi1> to i4 + %6 = llvm.icmp "eq" %5, %2 : i4 + llvm.return %6 : i1 + } + llvm.func @test_i1_0_2(%arg0: i1) -> i1 { + %0 = llvm.mlir.undef : vector<4xi1> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i4) : i4 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi1> + %4 = llvm.shufflevector %3, %0 [2, 2, 2, 2] : vector<4xi1> + %5 = llvm.bitcast %4 : vector<4xi1> to i4 + %6 = llvm.icmp "eq" %5, %2 : i4 + llvm.return %6 : i1 + } + llvm.func @test_i1_m1(%arg0: i1) -> i1 { + %0 = llvm.mlir.undef : vector<4xi1> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i4) : i4 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi1> + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : vector<4xi1> + %5 = llvm.bitcast %4 : vector<4xi1> to i4 + %6 = llvm.icmp "eq" %5, %2 : i4 + llvm.return %6 : i1 + } + llvm.func @test_i8_pattern(%arg0: i8) -> i1 { + %0 = llvm.mlir.undef : vector<4xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1212696648 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi8> + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : vector<4xi8> + %5 = llvm.bitcast %4 : vector<4xi8> to i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @test_i8_pattern_2(%arg0: i8) -> i1 { + %0 = llvm.mlir.undef : vector<4xi8> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(1212696648 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi8> + %4 = llvm.shufflevector %3, %0 [2, 2, 2, 2] : vector<4xi8> + %5 = llvm.bitcast %4 : vector<4xi8> to i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @test_i8_pattern_3(%arg0: vector<4xi8>) -> i1 { + %0 = llvm.mlir.undef : vector<4xi8> + %1 = llvm.mlir.constant(1212696648 : i32) : i32 + %2 = llvm.shufflevector %arg0, %0 [1, 0, 3, 2] : vector<4xi8> + %3 = llvm.bitcast %2 : vector<4xi8> to i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @test_i8_nopattern(%arg0: i8) -> i1 { + %0 = llvm.mlir.undef : vector<4xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1212696647 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi8> + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : vector<4xi8> + %5 = llvm.bitcast %4 : vector<4xi8> to i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @test_i8_ult_pattern(%arg0: i8) -> i1 { + %0 = llvm.mlir.undef : vector<4xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1212696648 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi8> + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : vector<4xi8> + %5 = llvm.bitcast %4 : vector<4xi8> to i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @extending_shuffle_with_weird_types(%arg0: vector<2xi9>) -> i1 { + %0 = llvm.mlir.undef : vector<2xi9> + %1 = llvm.mlir.constant(262657 : i27) : i27 + %2 = llvm.shufflevector %arg0, %0 [0, 0, 0] : vector<2xi9> + %3 = llvm.bitcast %2 : vector<3xi9> to i27 + %4 = llvm.icmp "slt" %3, %1 : i27 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-binop.ll.mlir b/test/LLVMDialect/InstCombine/icmp-binop.ll.mlir new file mode 100644 index 000000000..c99344768 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-binop.ll.mlir @@ -0,0 +1,161 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use64(i64) + llvm.func @mul_unkV_oddC_eq(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @mul_unkV_oddC_eq_nonzero(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @mul_unkV_oddC_ne_vec(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mul %arg0, %0 : vector<2xi64> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi64> + llvm.return %4 : vector<2xi1> + } + llvm.func @mul_assumeoddV_asumeoddV_eq(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.and %arg0, %0 : i16 + %3 = llvm.icmp "ne" %2, %1 : i16 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.and %arg1, %0 : i16 + %5 = llvm.icmp "ne" %4, %1 : i16 + "llvm.intr.assume"(%5) : (i1) -> () + %6 = llvm.mul %arg0, %arg1 : i16 + %7 = llvm.icmp "ne" %6, %1 : i16 + llvm.return %7 : i1 + } + llvm.func @mul_unkV_oddC_sge(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mul %arg0, %0 : i8 + %3 = llvm.icmp "sge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @mul_reused_unkV_oddC_ne(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mul %arg0, %0 : i64 + %3 = llvm.icmp "ne" %2, %1 : i64 + llvm.call @use64(%2) : (i64) -> () + llvm.return %3 : i1 + } + llvm.func @mul_assumeoddV_unkV_eq(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.and %arg1, %0 : i16 + %3 = llvm.icmp "eq" %2, %0 : i16 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.mul %arg0, %arg1 : i16 + %5 = llvm.icmp "eq" %4, %1 : i16 + llvm.return %5 : i1 + } + llvm.func @mul_reusedassumeoddV_unkV_ne(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.icmp "ne" %2, %1 : i64 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.mul %arg0, %arg1 : i64 + %5 = llvm.icmp "ne" %4, %1 : i64 + llvm.call @use64(%4) : (i64) -> () + llvm.return %5 : i1 + } + llvm.func @mul_setoddV_unkV_ne(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.or %arg0, %0 : vector<2xi32> + %4 = llvm.mul %3, %arg1 : vector<2xi32> + %5 = llvm.icmp "ne" %4, %2 : vector<2xi32> + llvm.return %5 : vector<2xi1> + } + llvm.func @mul_broddV_unkV_eq(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.addressof @use64 : !llvm.ptr + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.and %arg1, %0 : i16 + %5 = llvm.icmp "eq" %4, %0 : i16 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %6 = llvm.mul %arg0, %arg1 : i16 + %7 = llvm.icmp "eq" %6, %3 : i16 + llvm.return %7 : i1 + ^bb2: // pred: ^bb0 + llvm.call %1(%arg0) : !llvm.ptr, (i16) -> () + llvm.return %2 : i1 + } + llvm.func @mul_unkV_evenC_ne(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mul %arg0, %0 : i64 + %3 = llvm.icmp "ne" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @mul_assumenzV_asumenzV_eq(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "ne" %arg0, %0 : i64 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.icmp "ne" %arg1, %0 : i64 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.mul %arg0, %arg1 : i64 + %4 = llvm.icmp "eq" %3, %0 : i64 + llvm.return %4 : i1 + } + llvm.func @mul_assumenzV_unkV_nsw_ne(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %0 : i32 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.mul %arg0, %arg1 overflow : i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @mul_selectnzV_unkV_nsw_ne(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.mul %arg0, %arg1 overflow : i8 + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.select %2, %4, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @mul_unkV_unkV_nsw_nuw_ne(%arg0: vector<2xi16>, %arg1: vector<2xi16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : vector<2xi16>) : vector<2xi16> + %2 = llvm.mul %arg0, %arg1 overflow : vector<2xi16> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi1> + } + llvm.func @mul_setnzV_unkV_nuw_eq(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.mul %2, %arg1 overflow : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @mul_brnzV_unkV_nuw_eq(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "ne" %arg1, %0 : i64 + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.mul %arg0, %arg1 overflow : i64 + %4 = llvm.icmp "eq" %3, %0 : i64 + llvm.return %4 : i1 + ^bb2: // pred: ^bb0 + llvm.call @use64(%arg0) : (i64) -> () + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-bitcast-glob.ll.mlir b/test/LLVMDialect/InstCombine/icmp-bitcast-glob.ll.mlir new file mode 100644 index 000000000..9807a4cb4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-bitcast-glob.ll.mlir @@ -0,0 +1,23 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @b() {addr_space = 0 : i32} : i32 + llvm.func @f32(!llvm.ptr, !llvm.ptr) -> i32 + llvm.func @f64(!llvm.ptr, !llvm.ptr) -> i32 + llvm.func @icmp_func() -> i1 { + %0 = llvm.mlir.addressof @f32 : !llvm.ptr + %1 = llvm.mlir.addressof @f64 : !llvm.ptr + %2 = llvm.icmp "eq" %0, %1 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @icmp_fptr(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.addressof @f32 : !llvm.ptr + %1 = llvm.icmp "ne" %0, %arg0 : !llvm.ptr + llvm.return %1 : i1 + } + llvm.func @icmp_glob(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.addressof @icmp_glob : !llvm.ptr + %1 = llvm.mlir.addressof @b : !llvm.ptr + %2 = llvm.icmp "eq" %0, %1 : !llvm.ptr + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-constant-phi.ll.mlir b/test/LLVMDialect/InstCombine/icmp-constant-phi.ll.mlir new file mode 100644 index 000000000..58b92b043 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-constant-phi.ll.mlir @@ -0,0 +1,131 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_eq(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(456 : i32) : i32 + %1 = llvm.mlir.constant(123 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.br ^bb4 + ^bb4: // pred: ^bb3 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @test_slt(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(456 : i32) : i32 + %1 = llvm.mlir.constant(123 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.br ^bb4 + ^bb4: // pred: ^bb3 + %3 = llvm.icmp "slt" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @test_sle(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(456 : i32) : i32 + %1 = llvm.mlir.constant(123 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.br ^bb4 + ^bb4: // pred: ^bb3 + %3 = llvm.icmp "sle" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @test_ne(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(456 : i32) : i32 + %1 = llvm.mlir.constant(123 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.br ^bb4 + ^bb4: // pred: ^bb3 + %3 = llvm.icmp "ne" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @test_ne_undef(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(456 : i32) : i32 + %1 = llvm.mlir.undef : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.br ^bb4 + ^bb4: // pred: ^bb3 + %3 = llvm.icmp "ne" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @test_ne_int_vector(%arg0: i1) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<456> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<123> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[123, 456]> : vector<2xi32>) : vector<2xi32> + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : vector<2xi32>) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : vector<2xi32>) + ^bb3(%3: vector<2xi32>): // 2 preds: ^bb1, ^bb2 + llvm.br ^bb4 + ^bb4: // pred: ^bb3 + %4 = llvm.icmp "ne" %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @test_ne_float(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(1.250000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : f32) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : f32) + ^bb3(%2: f32): // 2 preds: ^bb1, ^bb2 + llvm.br ^bb4 + ^bb4: // pred: ^bb3 + %3 = llvm.fcmp "one" %2, %0 : f32 + llvm.return %3 : i1 + } + llvm.func @test_ne_float_undef(%arg0: i1) -> i1 { + %0 = llvm.mlir.undef : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1.250000e+00 : f32) : f32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : f32) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : f32) + ^bb3(%3: f32): // 2 preds: ^bb1, ^bb2 + llvm.br ^bb4 + ^bb4: // pred: ^bb3 + %4 = llvm.fcmp "one" %3, %2 : f32 + llvm.return %4 : i1 + } + llvm.func @test_ne_float_vector(%arg0: i1) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4.562500e+02> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.constant(dense<1.232500e+02> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.constant(dense<[1.232500e+02, 4.562500e+02]> : vector<2xf32>) : vector<2xf32> + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : vector<2xf32>) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : vector<2xf32>) + ^bb3(%3: vector<2xf32>): // 2 preds: ^bb1, ^bb2 + llvm.br ^bb4 + ^bb4: // pred: ^bb3 + %4 = llvm.fcmp "one" %3, %2 : vector<2xf32> + llvm.return %4 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-custom-dl.ll.mlir b/test/LLVMDialect/InstCombine/icmp-custom-dl.ll.mlir new file mode 100644 index 000000000..bf8b57007 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-custom-dl.ll.mlir @@ -0,0 +1,148 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<16> : vector<4xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<64> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test58_d(i64) -> i32 + llvm.func @test59(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %3 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.icmp "ult" %2, %3 : !llvm.ptr + %5 = llvm.ptrtoint %2 : !llvm.ptr to i64 + %6 = llvm.call @test58_d(%5) : (i64) -> i32 + llvm.return %4 : i1 + } + llvm.func @test59_as1(%arg0: !llvm.ptr<1>) -> i1 { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i32 + %3 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %4 = llvm.icmp "ult" %2, %3 : !llvm.ptr<1> + %5 = llvm.ptrtoint %2 : !llvm.ptr<1> to i64 + %6 = llvm.call @test58_d(%5) : (i64) -> i32 + llvm.return %4 : i1 + } + llvm.func @test60(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i1 { + %0 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %1 = llvm.getelementptr inbounds %arg0[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %2 = llvm.icmp "ult" %0, %1 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @test60_as1(%arg0: !llvm.ptr<1>, %arg1: i64, %arg2: i64) -> i1 { + %0 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i32 + %1 = llvm.getelementptr inbounds %arg0[%arg2] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %2 = llvm.icmp "ult" %0, %1 : !llvm.ptr<1> + llvm.return %2 : i1 + } + llvm.func @test60_addrspacecast(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i1 { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr to !llvm.ptr<3> + %1 = llvm.getelementptr inbounds %0[%arg1] : (!llvm.ptr<3>, i64) -> !llvm.ptr<3>, i32 + %2 = llvm.getelementptr inbounds %arg0[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.addrspacecast %1 : !llvm.ptr<3> to !llvm.ptr + %4 = llvm.icmp "ult" %3, %2 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @test60_addrspacecast_smaller(%arg0: !llvm.ptr, %arg1: i16, %arg2: i64) -> i1 { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr to !llvm.ptr<1> + %1 = llvm.getelementptr inbounds %0[%arg1] : (!llvm.ptr<1>, i16) -> !llvm.ptr<1>, i32 + %2 = llvm.getelementptr inbounds %arg0[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.addrspacecast %1 : !llvm.ptr<1> to !llvm.ptr + %4 = llvm.icmp "ult" %3, %2 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @test60_addrspacecast_larger(%arg0: !llvm.ptr<1>, %arg1: i32, %arg2: i16) -> i1 { + %0 = llvm.addrspacecast %arg0 : !llvm.ptr<1> to !llvm.ptr<2> + %1 = llvm.getelementptr inbounds %0[%arg1] : (!llvm.ptr<2>, i32) -> !llvm.ptr<2>, i32 + %2 = llvm.getelementptr inbounds %arg0[%arg2] : (!llvm.ptr<1>, i16) -> !llvm.ptr<1>, i8 + %3 = llvm.addrspacecast %1 : !llvm.ptr<2> to !llvm.ptr<1> + %4 = llvm.icmp "ult" %3, %2 : !llvm.ptr<1> + llvm.return %4 : i1 + } + llvm.func @test61(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i1 { + %0 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %1 = llvm.getelementptr %arg0[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %2 = llvm.icmp "ult" %0, %1 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @test61_as1(%arg0: !llvm.ptr<1>, %arg1: i16, %arg2: i16) -> i1 { + %0 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr<1>, i16) -> !llvm.ptr<1>, i32 + %1 = llvm.getelementptr %arg0[%arg2] : (!llvm.ptr<1>, i16) -> !llvm.ptr<1>, i8 + %2 = llvm.icmp "ult" %0, %1 : !llvm.ptr<1> + llvm.return %2 : i1 + } + llvm.func @test62(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.icmp "slt" %2, %3 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @test62_as1(%arg0: !llvm.ptr<1>) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %3 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %4 = llvm.icmp "slt" %2, %3 : !llvm.ptr<1> + llvm.return %4 : i1 + } + llvm.func @icmp_and_ashr_multiuse(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.constant(31 : i32) : i32 + %3 = llvm.mlir.constant(14 : i32) : i32 + %4 = llvm.mlir.constant(27 : i32) : i32 + %5 = llvm.ashr %arg0, %0 : i32 + %6 = llvm.and %5, %1 : i32 + %7 = llvm.and %5, %2 : i32 + %8 = llvm.icmp "ne" %6, %3 : i32 + %9 = llvm.icmp "ne" %7, %4 : i32 + %10 = llvm.and %8, %9 : i1 + llvm.return %10 : i1 + } + llvm.func @icmp_and_ashr_multiuse_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.constant(31 : i32) : i32 + %3 = llvm.mlir.constant(14 : i32) : i32 + %4 = llvm.mlir.constant(27 : i32) : i32 + %5 = llvm.mlir.constant(false) : i1 + %6 = llvm.ashr %arg0, %0 : i32 + %7 = llvm.and %6, %1 : i32 + %8 = llvm.and %6, %2 : i32 + %9 = llvm.icmp "ne" %7, %3 : i32 + %10 = llvm.icmp "ne" %8, %4 : i32 + %11 = llvm.select %9, %10, %5 : i1, i1 + llvm.return %11 : i1 + } + llvm.func @icmp_lshr_and_overshift(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.lshr %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.icmp "ne" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @icmp_ashr_and_overshift(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.ashr %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.icmp "ne" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @test71(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.icmp "ugt" %1, %2 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @test71_as1(%arg0: !llvm.ptr<1>) -> i1 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %3 = llvm.icmp "ugt" %1, %2 : !llvm.ptr<1> + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-div-constant.ll.mlir b/test/LLVMDialect/InstCombine/icmp-div-constant.ll.mlir new file mode 100644 index 000000000..173f8b425 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-div-constant.ll.mlir @@ -0,0 +1,292 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @is_rem2_neg_i8(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.srem %arg0, %0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @is_rem2_pos_v2i8(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.srem %arg0, %0 : vector<2xi8> + %4 = llvm.icmp "sgt" %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @is_rem32_pos_i8(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(32 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.srem %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @is_rem4_neg_i16(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.srem %arg0, %0 : i16 + %3 = llvm.icmp "slt" %2, %1 : i16 + llvm.return %3 : i1 + } + llvm.func @use(i32) + llvm.func @is_rem32_neg_i32_extra_use(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "slt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @is_rem8_nonneg_i16(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.srem %arg0, %0 : i16 + %3 = llvm.icmp "sgt" %2, %1 : i16 + llvm.return %3 : i1 + } + llvm.func @is_rem3_neg_i8(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.srem %arg0, %0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @is_rem16_something_i8(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.srem %arg0, %0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_div(%arg0: i16, %arg1: i16) -> i32 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.mlir.constant(-1 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %0 : i16 + llvm.cond_br %4, ^bb1, ^bb2(%1 : i1) + ^bb1: // pred: ^bb0 + %5 = llvm.sdiv %arg1, %2 : i16 + %6 = llvm.icmp "ne" %5, %0 : i16 + llvm.br ^bb2(%6 : i1) + ^bb2(%7: i1): // 2 preds: ^bb0, ^bb1 + %8 = llvm.zext %7 : i1 to i32 + %9 = llvm.add %8, %3 overflow : i32 + llvm.return %9 : i32 + } + llvm.func @icmp_div2(%arg0: i16, %arg1: i16) -> i32 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i16 + llvm.cond_br %3, ^bb1, ^bb2(%1 : i1) + ^bb1: // pred: ^bb0 + %4 = llvm.sdiv %arg1, %0 : i16 + %5 = llvm.icmp "ne" %4, %0 : i16 + llvm.br ^bb2(%5 : i1) + ^bb2(%6: i1): // 2 preds: ^bb0, ^bb1 + %7 = llvm.zext %6 : i1 to i32 + %8 = llvm.add %7, %2 overflow : i32 + llvm.return %8 : i32 + } + llvm.func @icmp_div3(%arg0: i16, %arg1: i16) -> i32 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(1 : i16) : i16 + %3 = llvm.mlir.constant(-1 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %0 : i16 + llvm.cond_br %4, ^bb1, ^bb2(%1 : i1) + ^bb1: // pred: ^bb0 + %5 = llvm.sdiv %arg1, %2 : i16 + %6 = llvm.icmp "ne" %5, %0 : i16 + llvm.br ^bb2(%6 : i1) + ^bb2(%7: i1): // 2 preds: ^bb0, ^bb1 + %8 = llvm.zext %7 : i1 to i32 + %9 = llvm.add %8, %3 overflow : i32 + llvm.return %9 : i32 + } + llvm.func @udiv_eq_umax(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.udiv %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @udiv_ne_umax(%arg0: vector<2xi5>, %arg1: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.mlir.constant(-1 : i5) : i5 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi5>) : vector<2xi5> + %2 = llvm.udiv %arg0, %arg1 : vector<2xi5> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi5> + llvm.return %3 : vector<2xi1> + } + llvm.func @udiv_eq_big(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.udiv %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @udiv_ne_big(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.udiv %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @udiv_eq_not_big(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.udiv %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @udiv_slt_umax(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.udiv %arg0, %arg1 : i8 + %2 = llvm.icmp "slt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @udiv_eq_umax_use(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.udiv %arg0, %arg1 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @sdiv_eq_smin(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.sdiv %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @sdiv_ne_smin(%arg0: vector<2xi5>, %arg1: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.mlir.constant(-16 : i5) : i5 + %1 = llvm.mlir.constant(dense<-16> : vector<2xi5>) : vector<2xi5> + %2 = llvm.sdiv %arg0, %arg1 : vector<2xi5> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi5> + llvm.return %3 : vector<2xi1> + } + llvm.func @sdiv_eq_small(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-127 : i8) : i8 + %1 = llvm.sdiv %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @sdiv_ne_big(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.sdiv %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @sdiv_eq_not_big(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.sdiv %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @sdiv_ult_smin(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.sdiv %arg0, %arg1 : i8 + %2 = llvm.icmp "ult" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @sdiv_eq_smin_use(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.sdiv %arg0, %arg1 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @sdiv_x_by_const_cmp_x(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(13 : i32) : i32 + %1 = llvm.sdiv %arg0, %0 : i32 + %2 = llvm.icmp "eq" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @udiv_x_by_const_cmp_x(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.udiv %arg0, %0 : i32 + %2 = llvm.icmp "slt" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @udiv_x_by_const_cmp_x_non_splat(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[123, -123]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.udiv %arg0, %0 : vector<2xi32> + %2 = llvm.icmp "slt" %1, %arg0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @sdiv_x_by_const_cmp_x_non_splat(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[2, 3]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg0, %0 : vector<2xi32> + %2 = llvm.icmp "eq" %1, %arg0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @lshr_x_by_const_cmp_x(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.icmp "eq" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @lshr_by_const_cmp_sle_value(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi32>) : vector<4xi32> + %1 = llvm.lshr %arg0, %0 : vector<4xi32> + %2 = llvm.icmp "sle" %1, %arg0 : vector<4xi32> + llvm.return %2 : vector<4xi1> + } + llvm.func @lshr_by_const_cmp_sle_value_non_splat(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<[3, 3, 3, 5]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.lshr %arg0, %0 : vector<4xi32> + %2 = llvm.icmp "sle" %1, %arg0 : vector<4xi32> + llvm.return %2 : vector<4xi1> + } + llvm.func @ashr_by_const_cmp_sge_value_non_splat(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.ashr %arg0, %0 : vector<4xi32> + %2 = llvm.icmp "sge" %1, %arg0 : vector<4xi32> + llvm.return %2 : vector<4xi1> + } + llvm.func @lshr_by_const_cmp_sge_value(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.icmp "sge" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ashr_x_by_const_cmp_sge_x(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.ashr %arg0, %0 : i32 + %2 = llvm.icmp "sge" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @udiv_x_by_const_cmp_eq_value_neg(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, 3]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.udiv %arg0, %0 : vector<2xi32> + %2 = llvm.icmp "eq" %1, %arg0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @sdiv_x_by_const_cmp_eq_value_neg(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, 3]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg0, %0 : vector<2xi32> + %2 = llvm.icmp "eq" %1, %arg0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @lshr_x_by_const_cmp_slt_value_neg(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[0, 2]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.lshr %arg0, %0 : vector<2xi32> + %2 = llvm.icmp "slt" %1, %arg0 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @sdiv_x_by_const_cmp_ult_value_neg(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.sdiv %arg0, %0 : i32 + %2 = llvm.icmp "ult" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @sdiv_x_by_const_cmp_sgt_value_neg(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sdiv %arg0, %0 : vector<4xi32> + %2 = llvm.icmp "sgt" %1, %arg0 : vector<4xi32> + llvm.return %2 : vector<4xi1> + } + llvm.func @ashr_x_by_const_cmp_sle_value_neg(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.ashr %arg0, %0 : i32 + %2 = llvm.icmp "sle" %1, %arg0 : i32 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-dom.ll.mlir b/test/LLVMDialect/InstCombine/icmp-dom.ll.mlir new file mode 100644 index 000000000..5bae0a667 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-dom.ll.mlir @@ -0,0 +1,263 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @idom_sign_bit_check_edge_dominates(%arg0: i64) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "slt" %arg0, %0 : i64 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb4 + ^bb2: // pred: ^bb0 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + llvm.cond_br %2, ^bb3, ^bb4 + ^bb3: // pred: ^bb2 + llvm.br ^bb4 + ^bb4: // 3 preds: ^bb1, ^bb2, ^bb3 + llvm.return + } + llvm.func @idom_sign_bit_check_edge_not_dominates(%arg0: i64, %arg1: i1) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "slt" %arg0, %0 : i64 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg1, ^bb4, ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + llvm.cond_br %2, ^bb3, ^bb4 + ^bb3: // pred: ^bb2 + llvm.br ^bb4 + ^bb4: // 3 preds: ^bb1, ^bb2, ^bb3 + llvm.return + } + llvm.func @idom_sign_bit_check_edge_dominates_select(%arg0: i64, %arg1: i64) { + %0 = llvm.mlir.constant(5 : i64) : i64 + %1 = llvm.icmp "slt" %arg0, %0 : i64 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb4 + ^bb2: // pred: ^bb0 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + %3 = llvm.select %2, %arg0, %0 : i1, i64 + %4 = llvm.icmp "ne" %3, %arg1 : i64 + llvm.cond_br %4, ^bb3, ^bb4 + ^bb3: // pred: ^bb2 + llvm.br ^bb4 + ^bb4: // 3 preds: ^bb1, ^bb2, ^bb3 + llvm.return + } + llvm.func @idom_zbranch(%arg0: i64) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "sgt" %arg0, %0 : i64 + llvm.cond_br %1, ^bb3, ^bb1 + ^bb1: // pred: ^bb0 + %2 = llvm.icmp "slt" %arg0, %0 : i64 + llvm.cond_br %2, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.br ^bb3 + ^bb3: // 3 preds: ^bb0, ^bb1, ^bb2 + llvm.return + } + llvm.func @idom_not_zbranch(%arg0: i32, %arg1: i32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.cond_br %1, ^bb3, ^bb1 + ^bb1: // pred: ^bb0 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.icmp "ne" %3, %arg1 : i32 + llvm.cond_br %4, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.br ^bb3 + ^bb3: // 3 preds: ^bb0, ^bb1, ^bb2 + llvm.return + } + llvm.func @trueblock_cmp_eq(%arg0: i32, %arg1: i32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.cond_br %2, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + llvm.cond_br %3, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.br ^bb3 + ^bb3: // 3 preds: ^bb0, ^bb1, ^bb2 + llvm.return + } + llvm.func @trueblock_cmp_is_false(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.icmp "slt" %arg0, %arg1 : i32 + llvm.return %1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %0 : i1 + } + llvm.func @trueblock_cmp_is_false_commute(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "eq" %arg0, %arg1 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.icmp "sgt" %arg1, %arg0 : i32 + llvm.return %1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %0 : i1 + } + llvm.func @trueblock_cmp_is_true(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.icmp "ne" %arg0, %arg1 : i32 + llvm.return %1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %0 : i1 + } + llvm.func @trueblock_cmp_is_true_commute(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ugt" %arg0, %arg1 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.icmp "ne" %arg1, %arg0 : i32 + llvm.return %1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %0 : i1 + } + llvm.func @falseblock_cmp_is_false(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "sle" %arg0, %arg1 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %0 : i1 + ^bb2: // pred: ^bb0 + %1 = llvm.icmp "slt" %arg0, %arg1 : i32 + llvm.return %1 : i1 + } + llvm.func @falseblock_cmp_is_false_commute(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "eq" %arg0, %arg1 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %0 : i1 + ^bb2: // pred: ^bb0 + %1 = llvm.icmp "eq" %arg1, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @falseblock_cmp_is_true(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %0 : i1 + ^bb2: // pred: ^bb0 + %1 = llvm.icmp "uge" %arg0, %arg1 : i32 + llvm.return %1 : i1 + } + llvm.func @falseblock_cmp_is_true_commute(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %0 : i1 + ^bb2: // pred: ^bb0 + %1 = llvm.icmp "sge" %arg1, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @PR48900(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg0, %0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %6 = llvm.icmp "ult" %4, %2 : i32 + %7 = llvm.select %6, %4, %2 : i1, i32 + llvm.return %7 : i32 + ^bb2: // pred: ^bb0 + llvm.return %1 : i32 + } + llvm.func @PR48900_alt(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-127 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(-126 : i8) : i8 + %4 = llvm.icmp "sgt" %arg0, %0 : i8 + %5 = llvm.select %4, %arg0, %0 : i1, i8 + %6 = llvm.icmp "ugt" %5, %1 : i8 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %7 = llvm.icmp "slt" %5, %3 : i8 + %8 = llvm.select %7, %5, %3 : i1, i8 + llvm.return %8 : i8 + ^bb2: // pred: ^bb0 + llvm.return %2 : i8 + } + llvm.func @and_mask1_eq(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %3 : i1 + ^bb2: // pred: ^bb0 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + llvm.return %7 : i1 + } + llvm.func @and_mask1_ne(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %3 : i1 + ^bb2: // pred: ^bb0 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + llvm.return %7 : i1 + } + llvm.func @and_mask2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %3 : i1 + ^bb2: // pred: ^bb0 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + llvm.return %7 : i1 + } + llvm.func @and_mask3(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %3 : i1 + ^bb2: // pred: ^bb0 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + llvm.return %7 : i1 + } + llvm.func @and_mask4(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %3 : i1 + ^bb2: // pred: ^bb0 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + llvm.return %7 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-equality-rotate.ll.mlir b/test/LLVMDialect/InstCombine/icmp-equality-rotate.ll.mlir new file mode 100644 index 000000000..f479e1737 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-equality-rotate.ll.mlir @@ -0,0 +1,81 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use.i8(i8) + llvm.func @cmpeq_rorr_to_rorl(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.intr.fshr(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %1 = llvm.icmp "eq" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @cmpeq_rorr_to_rorl_non_equality_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.intr.fshr(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %1 = llvm.icmp "ult" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @cmpeq_rorr_to_rorl_cmp_against_wrong_val_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.intr.fshr(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %1 = llvm.icmp "ult" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @cmpeq_rorr_to_rorl_non_ror_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.intr.fshr(%arg0, %arg1, %arg1) : (i8, i8, i8) -> i8 + %1 = llvm.icmp "ult" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @cmpeq_rorr_to_rorl_multiuse_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.intr.fshr(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + llvm.call @use.i8(%0) : (i8) -> () + %1 = llvm.icmp "eq" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @cmpne_rorr_rorr(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.intr.fshr(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %1 = llvm.intr.fshr(%arg0, %arg0, %arg2) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "ne" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @cmpne_rorrX_rorrY(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i1 { + %0 = llvm.intr.fshr(%arg0, %arg0, %arg2) : (i8, i8, i8) -> i8 + %1 = llvm.intr.fshr(%arg1, %arg1, %arg3) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "ne" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @cmpne_rorr_rorr_non_equality_fail(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.intr.fshr(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %1 = llvm.intr.fshr(%arg0, %arg0, %arg2) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "sge" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @cmpne_rorr_rorl_todo_mismatch_C(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.intr.fshr(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %2 = llvm.intr.fshl(%arg0, %arg0, %0) : (i8, i8, i8) -> i8 + %3 = llvm.icmp "ne" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @cmpne_rorl_rorl_multiuse1_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.intr.fshl(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %2 = llvm.intr.fshl(%arg0, %arg0, %0) : (i8, i8, i8) -> i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @cmpeq_rorlXC_rorlYC_multiuse1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.intr.fshl(%arg0, %arg0, %0) : (i8, i8, i8) -> i8 + %3 = llvm.intr.fshl(%arg1, %arg1, %1) : (i8, i8, i8) -> i8 + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.icmp "eq" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @cmpeq_rorlC_rorlC_multiuse2_fail(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.intr.fshl(%arg0, %arg0, %0) : (i8, i8, i8) -> i8 + %3 = llvm.intr.fshl(%arg0, %arg0, %1) : (i8, i8, i8) -> i8 + llvm.call @use.i8(%2) : (i8) -> () + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.icmp "eq" %2, %3 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-equality-xor.ll.mlir b/test/LLVMDialect/InstCombine/icmp-equality-xor.ll.mlir new file mode 100644 index 000000000..6fea1c530 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-equality-xor.ll.mlir @@ -0,0 +1,108 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @cmpeq_xor_cst1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.icmp "eq" %1, %arg1 : i32 + llvm.return %2 : i1 + } + llvm.func @cmpeq_xor_cst2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.xor %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @cmpeq_xor_cst3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.icmp "eq" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @cmpne_xor_cst1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.icmp "ne" %1, %arg1 : i32 + llvm.return %2 : i1 + } + llvm.func @cmpne_xor_cst2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.xor %arg0, %arg1 : i32 + %2 = llvm.icmp "ne" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @cmpne_xor_cst3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.icmp "ne" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @cmpeq_xor_cst1_multiuse(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.icmp "eq" %1, %arg1 : i32 + llvm.return %2 : i1 + } + llvm.func @cmpeq_xor_cst1_commuted(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mul %arg1, %arg1 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "eq" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @cmpeq_xor_cst1_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[10, 11]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.xor %arg0, %0 : vector<2xi32> + %2 = llvm.icmp "eq" %arg1, %1 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @foo1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.xor %arg1, %1 : i32 + %4 = llvm.and %3, %0 : i32 + %5 = llvm.icmp "eq" %2, %4 : i32 + llvm.return %5 : i1 + } + llvm.func @foo2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.icmp "eq" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @foo3(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-2, -1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[9, 79]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.xor %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @use.i8(i8) + llvm.func @fold_xorC_eq0_multiuse(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.xor %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.call @use.i8(%1) : (i8) -> () + llvm.return %2 : i1 + } + llvm.func @fold_xorC_eq1_multiuse_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.xor %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.call @use.i8(%1) : (i8) -> () + llvm.return %2 : i1 + } + llvm.func @fold_xorC_neC_multiuse(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(45 : i8) : i8 + %1 = llvm.mlir.constant(67 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.call @use.i8(%2) : (i8) -> () + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-ext-ext.ll.mlir b/test/LLVMDialect/InstCombine/icmp-ext-ext.ll.mlir index 7a4db6a9a..a4542f88d 100644 --- a/test/LLVMDialect/InstCombine/icmp-ext-ext.ll.mlir +++ b/test/LLVMDialect/InstCombine/icmp-ext-ext.ll.mlir @@ -1,232 +1,279 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_zext_sgt", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi32> - %1 = "llvm.zext"(%arg1) : (vector<2xi8>) -> vector<2xi32> - %2 = "llvm.icmp"(%0, %1) {predicate = 8 : i64} : (vector<2xi32>, vector<2xi32>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_zext_ugt", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_zext_eq", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i16): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i32 - %1 = "llvm.zext"(%arg1) : (i16) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 3 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_zext_sle_op0_narrow", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i9, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i9) -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 7 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_zext_ule_op0_wide", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i8) -> i32 - %1 = "llvm.sext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_sext_slt", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i8) -> i32 - %1 = "llvm.sext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 6 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_sext_ult", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i8) -> i32 - %1 = "llvm.sext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_sext_ne", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i5, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i5) -> i32 - %1 = "llvm.sext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 5 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_sext_sge_op0_narrow", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.sext"(%arg0) : (vector<2xi16>) -> vector<2xi32> - %1 = "llvm.sext"(%arg1) : (vector<2xi8>) -> vector<2xi32> - %2 = "llvm.icmp"(%0, %1) {predicate = 9 : i64} : (vector<2xi32>, vector<2xi32>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_sext_uge_op0_wide", type = !llvm.func (vector<2xi16>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i32 - %1 = "llvm.sext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_sext_sgt", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i32 - %1 = "llvm.sext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 8 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_sext_ugt", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i32 - %1 = "llvm.sext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_sext_eq", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i16): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i32 - %1 = "llvm.sext"(%arg1) : (i16) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 3 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_sext_sle_op0_narrow", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i9, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i9) -> i32 - %1 = "llvm.sext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 7 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_sext_ule_op0_wide", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i8) -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_zext_slt", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i8) -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 6 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_zext_ult", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.sext"(%arg0) : (vector<2xi8>) -> vector<2xi32> - %1 = "llvm.zext"(%arg1) : (vector<2xi8>) -> vector<2xi32> - %2 = "llvm.icmp"(%0, %1) {predicate = 1 : i64} : (vector<2xi32>, vector<2xi32>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_zext_ne", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i5, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i5) -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 5 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_zext_sge_op0_narrow", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i16) -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.icmp"(%0, %1) {predicate = 9 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_zext_uge_op0_wide", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 127 : i8} : () -> i8 - %1 = "llvm.udiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.zext"(%1) : (i8) -> i32 - %3 = "llvm.sext"(%arg1) : (i8) -> i32 - %4 = "llvm.icmp"(%2, %3) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_sext_sgt_known_nonneg", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 127 : i8} : () -> i8 - %1 = "llvm.and"(%arg0, %0) : (i8, i8) -> i8 - %2 = "llvm.zext"(%1) : (i8) -> i32 - %3 = "llvm.sext"(%arg1) : (i8) -> i32 - %4 = "llvm.icmp"(%2, %3) {predicate = 8 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_sext_ugt_known_nonneg", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %1 = "llvm.lshr"(%arg0, %0) : (i8, i8) -> i8 - %2 = "llvm.zext"(%1) : (i8) -> i32 - %3 = "llvm.sext"(%arg1) : (i8) -> i32 - %4 = "llvm.icmp"(%2, %3) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_sext_eq_known_nonneg", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 12 : i8} : () -> i8 - %1 = "llvm.and"(%arg0, %0) : (i8, i8) -> i8 - %2 = "llvm.zext"(%1) : (i8) -> i32 - %3 = "llvm.sext"(%arg1) : (i16) -> i32 - %4 = "llvm.icmp"(%2, %3) {predicate = 3 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_sext_sle_known_nonneg_op0_narrow", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i9, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 254 : i9} : () -> i9 - %1 = "llvm.urem"(%arg0, %0) : (i9, i9) -> i9 - %2 = "llvm.zext"(%1) : (i9) -> i32 - %3 = "llvm.sext"(%arg1) : (i8) -> i32 - %4 = "llvm.icmp"(%2, %3) {predicate = 7 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_sext_ule_known_nonneg_op0_wide", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 126 : i8} : () -> i8 - %1 = "llvm.sext"(%arg0) : (i8) -> i32 - %2 = "llvm.and"(%arg1, %0) : (i8, i8) -> i8 - %3 = "llvm.zext"(%2) : (i8) -> i32 - %4 = "llvm.icmp"(%1, %3) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_zext_slt_known_nonneg", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i8} : () -> i8 - %1 = "llvm.sext"(%arg0) : (i8) -> i32 - %2 = "llvm.lshr"(%arg1, %0) : (i8, i8) -> i8 - %3 = "llvm.zext"(%2) : (i8) -> i32 - %4 = "llvm.icmp"(%1, %3) {predicate = 6 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_zext_ult_known_nonneg", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i8} : () -> i8 - %1 = "llvm.sext"(%arg0) : (i8) -> i32 - %2 = "llvm.udiv"(%arg1, %0) : (i8, i8) -> i8 - %3 = "llvm.zext"(%2) : (i8) -> i32 - %4 = "llvm.icmp"(%1, %3) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_zext_ne_known_nonneg", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi5>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.sext"(%arg0) : (vector<2xi5>) -> vector<2xi32> - %1 = "llvm.mul"(%arg1, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %2 = "llvm.zext"(%1) : (vector<2xi8>) -> vector<2xi32> - %3 = "llvm.icmp"(%0, %2) {predicate = 5 : i64} : (vector<2xi32>, vector<2xi32>) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_zext_sge_known_nonneg_op0_narrow", type = !llvm.func (vector<2xi5>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 12 : i8} : () -> i8 - %1 = "llvm.sext"(%arg0) : (i16) -> i32 - %2 = "llvm.and"(%arg1, %0) : (i8, i8) -> i8 - %3 = "llvm.zext"(%2) : (i8) -> i32 - %4 = "llvm.icmp"(%1, %3) {predicate = 9 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_zext_uge_known_nonneg_op0_wide", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @zext_zext_sgt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.icmp "sgt" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_zext_ugt(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + %1 = llvm.zext %arg1 : vector<2xi8> to vector<2xi32> + %2 = llvm.icmp "ugt" %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @zext_zext_eq(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.icmp "eq" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_zext_sle_op0_narrow(%arg0: i8, %arg1: i16) -> i1 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.zext %arg1 : i16 to i32 + %2 = llvm.icmp "sle" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_zext_ule_op0_wide(%arg0: i9, %arg1: i8) -> i1 { + %0 = llvm.zext %arg0 : i9 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.icmp "ule" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @sext_sext_slt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sext %arg0 : i8 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.icmp "slt" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @sext_sext_ult(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sext %arg0 : i8 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.icmp "ult" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @sext_sext_ne(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sext %arg0 : i8 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.icmp "ne" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @sext_sext_sge_op0_narrow(%arg0: i5, %arg1: i8) -> i1 { + %0 = llvm.sext %arg0 : i5 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.icmp "sge" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @sext_sext_uge_op0_wide(%arg0: vector<2xi16>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.sext %arg0 : vector<2xi16> to vector<2xi32> + %1 = llvm.sext %arg1 : vector<2xi8> to vector<2xi32> + %2 = llvm.icmp "uge" %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @zext_sext_sgt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.icmp "sgt" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_nneg_sext_sgt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.icmp "sgt" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_sext_ugt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.icmp "ugt" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_nneg_sext_ugt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.icmp "ugt" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_sext_eq(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.icmp "eq" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_nneg_sext_eq(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.icmp "eq" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_sext_sle_op0_narrow(%arg0: i8, %arg1: i16) -> i1 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.sext %arg1 : i16 to i32 + %2 = llvm.icmp "sle" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_nneg_sext_sle_op0_narrow(%arg0: i8, %arg1: i16) -> i1 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.sext %arg1 : i16 to i32 + %2 = llvm.icmp "sle" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_sext_ule_op0_wide(%arg0: i9, %arg1: i8) -> i1 { + %0 = llvm.zext %arg0 : i9 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.icmp "ule" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_nneg_sext_ule_op0_wide(%arg0: i9, %arg1: i8) -> i1 { + %0 = llvm.zext %arg0 : i9 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.icmp "ule" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @sext_zext_slt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sext %arg0 : i8 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.icmp "slt" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @sext_zext_nneg_slt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sext %arg0 : i8 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.icmp "slt" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @sext_zext_ult(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sext %arg0 : i8 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.icmp "ult" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @sext_zext_nneg_ult(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sext %arg0 : i8 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.icmp "ult" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @sext_zext_ne(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %1 = llvm.zext %arg1 : vector<2xi8> to vector<2xi32> + %2 = llvm.icmp "ne" %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @sext_zext_nneg_ne(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %1 = llvm.zext %arg1 : vector<2xi8> to vector<2xi32> + %2 = llvm.icmp "ne" %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi1> + } + llvm.func @sext_zext_sge_op0_narrow(%arg0: i5, %arg1: i8) -> i1 { + %0 = llvm.sext %arg0 : i5 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.icmp "sge" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @sext_zext_nneg_sge_op0_narrow(%arg0: i5, %arg1: i8) -> i1 { + %0 = llvm.sext %arg0 : i5 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.icmp "sge" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @sext_zext_uge_op0_wide(%arg0: i16, %arg1: i8) -> i1 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.icmp "uge" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @sext_zext_nneg_uge_op0_wide(%arg0: i16, %arg1: i8) -> i1 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.icmp "uge" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_sext_sgt_known_nonneg(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.zext %1 : i8 to i32 + %3 = llvm.sext %arg1 : i8 to i32 + %4 = llvm.icmp "sgt" %2, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @zext_sext_ugt_known_nonneg(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.zext %1 : i8 to i32 + %3 = llvm.sext %arg1 : i8 to i32 + %4 = llvm.icmp "ugt" %2, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @zext_sext_eq_known_nonneg(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.zext %1 : i8 to i32 + %3 = llvm.sext %arg1 : i8 to i32 + %4 = llvm.icmp "eq" %2, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @zext_sext_sle_known_nonneg_op0_narrow(%arg0: i8, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(12 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.zext %1 : i8 to i32 + %3 = llvm.sext %arg1 : i16 to i32 + %4 = llvm.icmp "sle" %2, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @zext_sext_ule_known_nonneg_op0_wide(%arg0: i9, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(254 : i9) : i9 + %1 = llvm.urem %arg0, %0 : i9 + %2 = llvm.zext %1 : i9 to i32 + %3 = llvm.sext %arg1 : i8 to i32 + %4 = llvm.icmp "ule" %2, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @sext_zext_slt_known_nonneg(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(126 : i8) : i8 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.zext %2 : i8 to i32 + %4 = llvm.icmp "slt" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @sext_zext_ult_known_nonneg(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.lshr %arg1, %0 : i8 + %3 = llvm.zext %2 : i8 to i32 + %4 = llvm.icmp "ult" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @sext_zext_ne_known_nonneg(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.udiv %arg1, %0 : i8 + %3 = llvm.zext %2 : i8 to i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @sext_zext_sge_known_nonneg_op0_narrow(%arg0: vector<2xi5>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.sext %arg0 : vector<2xi5> to vector<2xi32> + %1 = llvm.mul %arg1, %arg1 overflow : vector<2xi8> + %2 = llvm.zext %1 : vector<2xi8> to vector<2xi32> + %3 = llvm.icmp "sge" %0, %2 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @sext_zext_uge_known_nonneg_op0_wide(%arg0: i16, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(12 : i8) : i8 + %1 = llvm.sext %arg0 : i16 to i32 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.zext %2 : i8 to i32 + %4 = llvm.icmp "uge" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @zext_eq_sext(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.zext %arg0 : i1 to i32 + %1 = llvm.sext %arg1 : i1 to i32 + %2 = llvm.icmp "eq" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_eq_sext_fail_not_i1(%arg0: i1, %arg1: i8) -> i1 { + %0 = llvm.zext %arg0 : i1 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.icmp "eq" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @zext_ne_sext(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.zext %arg0 : vector<2xi1> to vector<2xi8> + %1 = llvm.sext %arg1 : vector<2xi1> to vector<2xi8> + %2 = llvm.icmp "ne" %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-fold-into-phi.ll.mlir b/test/LLVMDialect/InstCombine/icmp-fold-into-phi.ll.mlir new file mode 100644 index 000000000..780525c6c --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-fold-into-phi.ll.mlir @@ -0,0 +1,40 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @SwitchTest(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + llvm.switch %arg0 : i32, ^bb1 [ + 0: ^bb2(%0 : i32), + 1: ^bb3(%1 : i32) + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%arg1 : i32) + ^bb2(%2: i32): // 2 preds: ^bb0, ^bb1 + llvm.br ^bb3(%2 : i32) + ^bb3(%3: i32): // 2 preds: ^bb0, ^bb2 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @BranchTest(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(134 : i32) : i32 + %3 = llvm.mlir.constant(128 : i32) : i32 + %4 = llvm.mlir.constant(127 : i32) : i32 + %5 = llvm.mlir.constant(126 : i32) : i32 + llvm.cond_br %arg0, ^bb6(%0 : i32), ^bb1 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg1, ^bb6(%1 : i32), ^bb2 + ^bb2: // pred: ^bb1 + llvm.cond_br %arg2, ^bb6(%2 : i32), ^bb3 + ^bb3: // pred: ^bb2 + llvm.cond_br %arg3, ^bb5(%3 : i32), ^bb4 + ^bb4: // pred: ^bb3 + %6 = llvm.select %arg4, %4, %5 : i1, i32 + llvm.br ^bb5(%6 : i32) + ^bb5(%7: i32): // 2 preds: ^bb3, ^bb4 + llvm.br ^bb6(%7 : i32) + ^bb6(%8: i32): // 4 preds: ^bb0, ^bb1, ^bb2, ^bb5 + %9 = llvm.icmp "ult" %8, %1 : i32 + llvm.return %9 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-fsh.ll.mlir b/test/LLVMDialect/InstCombine/icmp-fsh.ll.mlir new file mode 100644 index 000000000..8f5fe3387 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-fsh.ll.mlir @@ -0,0 +1,120 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @rotl_eq_0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.fshl(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @rotl_ne_0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.fshl(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @rotl_eq_n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.intr.fshl(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @rotl_ne_n1(%arg0: vector<2xi5>, %arg1: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.mlir.constant(-1 : i5) : i5 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi5>) : vector<2xi5> + %2 = llvm.intr.fshl(%arg0, %arg0, %arg1) : (vector<2xi5>, vector<2xi5>, vector<2xi5>) -> vector<2xi5> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi5> + llvm.return %3 : vector<2xi1> + } + llvm.func @rotl_ne_n1_poison(%arg0: vector<2xi5>, %arg1: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i5 + %1 = llvm.mlir.constant(-1 : i5) : i5 + %2 = llvm.mlir.undef : vector<2xi5> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi5> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi5> + %7 = llvm.intr.fshl(%arg0, %arg0, %arg1) : (vector<2xi5>, vector<2xi5>, vector<2xi5>) -> vector<2xi5> + %8 = llvm.icmp "ne" %7, %6 : vector<2xi5> + llvm.return %8 : vector<2xi1> + } + llvm.func @rotl_eq_0_poison(%arg0: vector<2xi5>, %arg1: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i5 + %1 = llvm.mlir.constant(0 : i5) : i5 + %2 = llvm.mlir.undef : vector<2xi5> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi5> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi5> + %7 = llvm.intr.fshl(%arg0, %arg0, %arg1) : (vector<2xi5>, vector<2xi5>, vector<2xi5>) -> vector<2xi5> + %8 = llvm.icmp "eq" %7, %6 : vector<2xi5> + llvm.return %8 : vector<2xi1> + } + llvm.func @rotl_eq_1_poison(%arg0: vector<2xi5>, %arg1: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.mlir.constant(1 : i5) : i5 + %1 = llvm.mlir.poison : i5 + %2 = llvm.mlir.undef : vector<2xi5> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi5> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi5> + %7 = llvm.intr.fshl(%arg0, %arg0, %arg1) : (vector<2xi5>, vector<2xi5>, vector<2xi5>) -> vector<2xi5> + %8 = llvm.icmp "eq" %7, %6 : vector<2xi5> + llvm.return %8 : vector<2xi1> + } + llvm.func @rotl_sgt_0_poison(%arg0: vector<2xi5>, %arg1: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i5 + %1 = llvm.mlir.constant(0 : i5) : i5 + %2 = llvm.mlir.undef : vector<2xi5> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi5> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi5> + %7 = llvm.intr.fshl(%arg0, %arg0, %arg1) : (vector<2xi5>, vector<2xi5>, vector<2xi5>) -> vector<2xi5> + %8 = llvm.icmp "sgt" %7, %6 : vector<2xi5> + llvm.return %8 : vector<2xi1> + } + llvm.func @rotr_eq_0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.fshr(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @rotr_ne_0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.fshr(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @rotr_eq_n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.intr.fshr(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @rotr_ne_n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.intr.fshr(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @rotr_ne_1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.intr.fshr(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @rotr_sgt_n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.intr.fshr(%arg0, %arg0, %arg1) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "sgt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @fshr_sgt_n1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.intr.fshr(%arg0, %arg1, %arg2) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-gep.ll.mlir b/test/LLVMDialect/InstCombine/icmp-gep.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/icmp-logical.ll.mlir b/test/LLVMDialect/InstCombine/icmp-logical.ll.mlir new file mode 100644 index 000000000..851566a65 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-logical.ll.mlir @@ -0,0 +1,1528 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @masked_and_notallzeroes(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(39 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_and_notallzeroes_splat(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<39> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.icmp "ne" %4, %2 : vector<2xi32> + %6 = llvm.and %arg0, %3 : vector<2xi32> + %7 = llvm.icmp "ne" %6, %2 : vector<2xi32> + %8 = llvm.and %5, %7 : vector<2xi1> + llvm.return %8 : vector<2xi1> + } + llvm.func @masked_and_notallzeroes_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(39 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.select %5, %7, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_or_allzeroes(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(39 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_or_allzeroes_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(39 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.select %5, %3, %7 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_and_notallones(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(39 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @masked_and_notallones_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(39 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + %5 = llvm.and %arg0, %1 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.select %4, %6, %2 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @masked_or_allones(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(39 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @masked_or_allones_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(39 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + %5 = llvm.and %arg0, %1 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.select %4, %2, %6 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @masked_and_notA(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(78 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %arg0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.icmp "ne" %4, %arg0 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @masked_and_notA_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(78 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %arg0 : i32 + %5 = llvm.and %arg0, %1 : i32 + %6 = llvm.icmp "ne" %5, %arg0 : i32 + %7 = llvm.select %4, %6, %2 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @masked_and_notA_slightly_optimized(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(39 : i32) : i32 + %2 = llvm.icmp "uge" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %arg0 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @masked_and_notA_slightly_optimized_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(39 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "uge" %arg0, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.icmp "ne" %4, %arg0 : i32 + %6 = llvm.select %3, %5, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @masked_or_A(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(78 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %arg0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.icmp "eq" %4, %arg0 : i32 + %6 = llvm.or %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @masked_or_A_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(78 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %arg0 : i32 + %5 = llvm.and %arg0, %1 : i32 + %6 = llvm.icmp "eq" %5, %arg0 : i32 + %7 = llvm.select %4, %2, %6 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @masked_or_A_slightly_optimized(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(39 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "eq" %3, %arg0 : i32 + %5 = llvm.or %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @masked_or_A_slightly_optimized_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(39 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.icmp "eq" %4, %arg0 : i32 + %6 = llvm.select %3, %2, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @masked_or_allzeroes_notoptimised(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(39 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_or_allzeroes_notoptimised_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(39 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.select %5, %3, %7 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @nomask_lhs(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + %5 = llvm.or %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @nomask_lhs_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.icmp "eq" %4, %0 : i32 + %6 = llvm.select %3, %2, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @nomask_rhs(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @nomask_rhs_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.icmp "eq" %arg0, %1 : i32 + %6 = llvm.select %4, %2, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @fold_mask_cmps_to_false(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.icmp "eq" %arg0, %0 : i32 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @fold_mask_cmps_to_false_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.icmp "eq" %arg0, %0 : i32 + %6 = llvm.select %5, %4, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @fold_mask_cmps_to_true(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + %4 = llvm.icmp "ne" %arg0, %0 : i32 + %5 = llvm.or %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @fold_mask_cmps_to_true_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.icmp "ne" %arg0, %0 : i32 + %6 = llvm.select %5, %2, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @nomask_splat_and_B_allones(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<1879048192> : vector<2xi32>) : vector<2xi32> + %8 = llvm.icmp "slt" %arg0, %6 : vector<2xi32> + %9 = llvm.and %arg0, %7 : vector<2xi32> + %10 = llvm.icmp "eq" %9, %7 : vector<2xi32> + %11 = llvm.and %8, %10 : vector<2xi1> + llvm.return %11 : vector<2xi1> + } + llvm.func @nomask_splat_and_B_mixed(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<1879048192> : vector<2xi32>) : vector<2xi32> + %8 = llvm.icmp "sgt" %arg0, %6 : vector<2xi32> + %9 = llvm.and %arg0, %7 : vector<2xi32> + %10 = llvm.icmp "eq" %9, %7 : vector<2xi32> + %11 = llvm.and %8, %10 : vector<2xi1> + llvm.return %11 : vector<2xi1> + } + llvm.func @cmpeq_bitwise(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.xor %arg0, %arg1 : i8 + %2 = llvm.xor %arg2, %arg3 : i8 + %3 = llvm.or %1, %2 : i8 + %4 = llvm.icmp "eq" %3, %0 : i8 + llvm.return %4 : i1 + } + llvm.func @cmpne_bitwise(%arg0: vector<2xi64>, %arg1: vector<2xi64>, %arg2: vector<2xi64>, %arg3: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.xor %arg0, %arg1 : vector<2xi64> + %3 = llvm.xor %arg2, %arg3 : vector<2xi64> + %4 = llvm.or %2, %3 : vector<2xi64> + %5 = llvm.icmp "ne" %4, %1 : vector<2xi64> + llvm.return %5 : vector<2xi1> + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_0(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_0_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.select %6, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_1_vector(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<12> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<7> : vector<2xi32>) : vector<2xi32> + %4 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %5 = llvm.and %arg0, %0 : vector<2xi32> + %6 = llvm.icmp "ne" %5, %2 : vector<2xi32> + %7 = llvm.and %arg0, %3 : vector<2xi32> + %8 = llvm.icmp "eq" %7, %4 : vector<2xi32> + %9 = llvm.and %6, %8 : vector<2xi1> + llvm.return %9 : vector<2xi1> + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.select %6, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_1b(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_1b_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.select %6, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_2_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.select %5, %7, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_3(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_3_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.select %5, %7, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_3b(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_3b_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.select %5, %7, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_4(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_4_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.select %6, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_5(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_5_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %0 : i32 + %7 = llvm.icmp "eq" %6, %2 : i32 + %8 = llvm.select %5, %7, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_6(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_6_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.select %6, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_7(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_7_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.select %6, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_7b(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_7b_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.select %6, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_0(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_0_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.select %6, %4, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.select %6, %4, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_1b(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_1b_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.select %6, %4, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_2_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.select %5, %3, %7 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_3(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_3_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.select %5, %3, %7 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_3b(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_3b_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.select %5, %3, %7 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_4(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_4_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.select %6, %4, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_5(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %2 : i32 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_5_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %0 : i32 + %7 = llvm.icmp "ne" %6, %2 : i32 + %8 = llvm.select %5, %3, %7 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_6(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_6_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.select %6, %4, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_7(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_7_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.select %6, %4, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_7b(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_7b_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.select %6, %4, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_0(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %7, %5 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_0_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.select %8, %6, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %7, %5 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.select %8, %6, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_1b(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %7, %5 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_1b_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.select %8, %6, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %6, %4 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_2_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.select %7, %5, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_3(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %6, %4 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_3_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.select %7, %5, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_3b(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %6, %4 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_3b_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.select %7, %5, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_4(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %7, %5 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_4_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.select %8, %6, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_5(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + %7 = llvm.and %6, %4 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_5_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %0 : i32 + %7 = llvm.icmp "eq" %6, %2 : i32 + %8 = llvm.select %7, %5, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_6(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %7, %5 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_6_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.select %8, %6, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_7(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %7, %5 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_7_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.select %8, %6, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_7b(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.and %7, %5 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_swapped_7b_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + %9 = llvm.select %8, %6, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_0(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.or %7, %5 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_0_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.select %8, %4, %6 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.or %7, %5 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.select %8, %4, %6 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_1b(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.or %7, %5 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_1b_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.select %8, %4, %6 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.or %6, %4 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_2_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.select %7, %3, %5 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_3(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.or %6, %4 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_3_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.select %7, %3, %5 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_3b(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.or %6, %4 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_3b_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.select %7, %3, %5 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_4(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.or %7, %5 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_4_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.select %8, %4, %6 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_5(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ne" %5, %2 : i32 + %7 = llvm.or %6, %4 : i1 + llvm.return %7 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_5_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %0 : i32 + %7 = llvm.icmp "ne" %6, %2 : i32 + %8 = llvm.select %7, %3, %5 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_6(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.or %7, %5 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_6_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.select %8, %4, %6 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_7(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.or %7, %5 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_7_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.select %8, %4, %6 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_7b(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.or %7, %5 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_7b_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %arg0, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.select %8, %4, %6 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @masked_icmps_bmask_notmixed_or(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(255 : i32) : i32 + %3 = llvm.mlir.constant(243 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_bmask_notmixed_or_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<-13> : vector<2xi8>) : vector<2xi8> + %4 = llvm.and %arg0, %0 : vector<2xi8> + %5 = llvm.icmp "eq" %4, %1 : vector<2xi8> + %6 = llvm.and %arg0, %2 : vector<2xi8> + %7 = llvm.icmp "eq" %6, %3 : vector<2xi8> + %8 = llvm.or %5, %7 : vector<2xi1> + llvm.return %8 : vector<2xi1> + } + llvm.func @masked_icmps_bmask_notmixed_or_vec_poison1(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %9 = llvm.mlir.constant(dense<-13> : vector<2xi8>) : vector<2xi8> + %10 = llvm.and %arg0, %0 : vector<2xi8> + %11 = llvm.icmp "eq" %10, %7 : vector<2xi8> + %12 = llvm.and %arg0, %8 : vector<2xi8> + %13 = llvm.icmp "eq" %12, %9 : vector<2xi8> + %14 = llvm.or %11, %13 : vector<2xi1> + llvm.return %14 : vector<2xi1> + } + llvm.func @masked_icmps_bmask_notmixed_or_vec_poison2(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.poison : i8 + %4 = llvm.mlir.constant(-13 : i8) : i8 + %5 = llvm.mlir.undef : vector<2xi8> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %4, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %3, %7[%8 : i32] : vector<2xi8> + %10 = llvm.and %arg0, %0 : vector<2xi8> + %11 = llvm.icmp "eq" %10, %1 : vector<2xi8> + %12 = llvm.and %arg0, %2 : vector<2xi8> + %13 = llvm.icmp "eq" %12, %9 : vector<2xi8> + %14 = llvm.or %11, %13 : vector<2xi1> + llvm.return %14 : vector<2xi1> + } + llvm.func @masked_icmps_bmask_notmixed_or_contradict_notoptimized(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(255 : i32) : i32 + %3 = llvm.mlir.constant(242 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_bmask_notmixed_and(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(255 : i32) : i32 + %3 = llvm.mlir.constant(243 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_bmask_notmixed_and_contradict_notoptimized(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(255 : i32) : i32 + %3 = llvm.mlir.constant(242 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_bmask_notmixed_and_expected_false(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.constant(255 : i32) : i32 + %3 = llvm.mlir.constant(242 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %arg0, %2 : i32 + %7 = llvm.icmp "ne" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @masked_icmps_bmask_notmixed_not_subset_notoptimized(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(254 : i32) : i32 + %1 = llvm.mlir.constant(252 : i32) : i32 + %2 = llvm.mlir.constant(253 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-mul-and.ll.mlir b/test/LLVMDialect/InstCombine/icmp-mul-and.ll.mlir new file mode 100644 index 000000000..ee68fee56 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-mul-and.ll.mlir @@ -0,0 +1,245 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @mul_mask_pow2_eq0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(44 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mul %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.icmp "eq" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @mul_mask_pow2_ne0_use1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(40 : i8) : i8 + %1 = llvm.mlir.constant(8 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mul %arg0, %0 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.and %3, %1 : i8 + %5 = llvm.icmp "ne" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @mul_mask_pow2_ne0_use2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(40 : i8) : i8 + %1 = llvm.mlir.constant(8 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mul %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.icmp "ne" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @mul_mask_pow2_sgt0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(44 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mul %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.icmp "sgt" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @mul_mask_fakepow2_ne0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(44 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mul %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.icmp "ne" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @mul_mask_pow2_eq4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(44 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.mul %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @mul_mask_notpow2_ne(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(60 : i8) : i8 + %1 = llvm.mlir.constant(12 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mul %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.icmp "ne" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @pr40493(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mul %arg0, %0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @pr40493_neg1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(11 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mul %arg0, %0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @pr40493_neg2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mul %arg0, %0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @pr40493_neg3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @pr40493_vec1(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<12> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<4> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %4 = llvm.mul %arg0, %0 : vector<4xi32> + %5 = llvm.and %4, %1 : vector<4xi32> + %6 = llvm.icmp "eq" %5, %3 : vector<4xi32> + llvm.return %6 : vector<4xi1> + } + llvm.func @pr40493_vec2(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(dense<4> : vector<4xi32>) : vector<4xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %14 = llvm.mul %arg0, %10 : vector<4xi32> + %15 = llvm.and %14, %11 : vector<4xi32> + %16 = llvm.icmp "eq" %15, %13 : vector<4xi32> + llvm.return %16 : vector<4xi1> + } + llvm.func @pr40493_vec3(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<12> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %2, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %14 = llvm.mul %arg0, %0 : vector<4xi32> + %15 = llvm.and %14, %11 : vector<4xi32> + %16 = llvm.icmp "eq" %15, %13 : vector<4xi32> + llvm.return %16 : vector<4xi1> + } + llvm.func @pr40493_vec4(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.mlir.undef : vector<4xi32> + %13 = llvm.mlir.constant(0 : i32) : i32 + %14 = llvm.insertelement %11, %12[%13 : i32] : vector<4xi32> + %15 = llvm.mlir.constant(1 : i32) : i32 + %16 = llvm.insertelement %11, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(2 : i32) : i32 + %18 = llvm.insertelement %11, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(3 : i32) : i32 + %20 = llvm.insertelement %0, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(0 : i32) : i32 + %22 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %23 = llvm.mul %arg0, %10 : vector<4xi32> + %24 = llvm.and %23, %20 : vector<4xi32> + %25 = llvm.icmp "eq" %24, %22 : vector<4xi32> + llvm.return %25 : vector<4xi1> + } + llvm.func @pr40493_vec5(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<[12, 12, 20, 20]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[2, 4, 2, 4]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %4 = llvm.mul %arg0, %0 : vector<4xi32> + %5 = llvm.and %4, %1 : vector<4xi32> + %6 = llvm.icmp "eq" %5, %3 : vector<4xi32> + llvm.return %6 : vector<4xi1> + } + llvm.func @pr51551(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-7 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.and %arg1, %0 : i32 + %5 = llvm.or %4, %1 : i32 + %6 = llvm.mul %5, %arg0 overflow : i32 + %7 = llvm.and %6, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + llvm.return %8 : i1 + } + llvm.func @pr51551_2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-7 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.or %3, %1 : i32 + %5 = llvm.mul %4, %arg0 overflow : i32 + %6 = llvm.and %5, %1 : i32 + %7 = llvm.icmp "eq" %6, %2 : i32 + llvm.return %7 : i1 + } + llvm.func @pr51551_neg1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.and %arg1, %0 : i32 + %5 = llvm.or %4, %1 : i32 + %6 = llvm.mul %5, %arg0 overflow : i32 + %7 = llvm.and %6, %2 : i32 + %8 = llvm.icmp "eq" %7, %3 : i32 + llvm.return %8 : i1 + } + llvm.func @pr51551_neg2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-7 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.mul %3, %arg0 overflow : i32 + %5 = llvm.and %4, %1 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @pr51551_demand3bits(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-7 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.or %3, %1 : i32 + %5 = llvm.mul %4, %arg0 overflow : i32 + %6 = llvm.and %5, %2 : i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-mul-zext.ll.mlir b/test/LLVMDialect/InstCombine/icmp-mul-zext.ll.mlir index e4ea836ca..916020574 100644 --- a/test/LLVMDialect/InstCombine/icmp-mul-zext.ll.mlir +++ b/test/LLVMDialect/InstCombine/icmp-mul-zext.ll.mlir @@ -1,84 +1,76 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "glob", type = i16} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i8, %arg2: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = true} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 4294967295 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 1945964878 : i32} : () -> i32 - %4 = "llvm.zext"(%arg0) : (i32) -> i64 - %5 = "llvm.sext"(%arg1) : (i8) -> i32 - %6 = "llvm.mul"(%5, %3) : (i32, i32) -> i32 - %7 = "llvm.trunc"(%arg2) : (i64) -> i32 - %8 = "llvm.lshr"(%6, %7) : (i32, i32) -> i32 - %9 = "llvm.zext"(%8) : (i32) -> i64 - %10 = "llvm.mul"(%4, %9) : (i64, i64) -> i64 - %11 = "llvm.and"(%10, %2) : (i64, i64) -> i64 - %12 = "llvm.icmp"(%11, %10) {predicate = 1 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%12, %1)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @glob() {addr_space = 0 : i32} : i16 + llvm.func @sterix(%arg0: i32, %arg1: i8, %arg2: i64) -> i32 { + %0 = llvm.mlir.constant(1945964878 : i32) : i32 + %1 = llvm.mlir.constant(4294967295 : i64) : i64 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.zext %arg0 : i32 to i64 + %5 = llvm.sext %arg1 : i8 to i32 + %6 = llvm.mul %5, %0 : i32 + %7 = llvm.trunc %arg2 : i64 to i32 + %8 = llvm.lshr %6, %7 : i32 + %9 = llvm.zext %8 : i32 to i64 + %10 = llvm.mul %4, %9 overflow : i64 + %11 = llvm.and %10, %1 : i64 + %12 = llvm.icmp "ne" %11, %10 : i64 + llvm.cond_br %12, ^bb2(%2 : i1), ^bb1 ^bb1: // pred: ^bb0 - %13 = "llvm.and"(%arg2, %10) : (i64, i64) -> i64 - %14 = "llvm.trunc"(%13) : (i64) -> i32 - %15 = "llvm.icmp"(%14, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - %16 = "llvm.xor"(%15, %1) : (i1, i1) -> i1 - "llvm.br"(%16)[^bb2] : (i1) -> () + %13 = llvm.and %arg2, %10 : i64 + %14 = llvm.trunc %13 : i64 to i32 + %15 = llvm.icmp "ne" %14, %3 : i32 + %16 = llvm.xor %15, %2 : i1 + llvm.br ^bb2(%16 : i1) ^bb2(%17: i1): // 2 preds: ^bb0, ^bb1 - %18 = "llvm.zext"(%17) : (i1) -> i32 - "llvm.return"(%18) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sterix", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @glob} : () -> !llvm.ptr - %1 = "llvm.mlir.addressof"() {global_name = @glob} : () -> !llvm.ptr - %2 = "llvm.mlir.constant"() {value = 255 : i32} : () -> i32 - %3 = "llvm.zext"(%arg0) : (i8) -> i32 - %4 = "llvm.mul"(%3, %3) : (i32, i32) -> i32 - %5 = "llvm.and"(%4, %2) : (i32, i32) -> i32 - %6 = "llvm.icmp"(%4, %5) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%6)[^bb1, ^bb1] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %18 = llvm.zext %17 : i1 to i32 + llvm.return %18 : i32 + } + llvm.func @PR33765(%arg0: i8) { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.addressof @glob : !llvm.ptr + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.mul %2, %2 overflow : i32 + %4 = llvm.and %3, %0 : i32 + %5 = llvm.icmp "ne" %3, %4 : i32 + llvm.cond_br %5, ^bb1, ^bb1 ^bb1: // 2 preds: ^bb0, ^bb0 - %7 = "llvm.load"(%1) : (!llvm.ptr) -> i16 - %8 = "llvm.sext"(%7) : (i16) -> i32 - %9 = "llvm.and"(%4, %8) : (i32, i32) -> i32 - %10 = "llvm.trunc"(%9) : (i32) -> i16 - "llvm.store"(%10, %0) : (i16, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "PR33765", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "aux", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 65535 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i16) -> i32 - %2 = "llvm.zext"(%arg1) : (i16) -> i32 - %3 = "llvm.mul"(%1, %2) : (i32, i32) -> i32 - %4 = "llvm.trunc"(%3) : (i32) -> i8 - %5 = "llvm.trunc"(%3) : (i32) -> i16 - %6 = "llvm.icmp"(%3, %0) {predicate = 8 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%6)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %6 = llvm.load %1 {alignment = 2 : i64} : !llvm.ptr -> i16 + %7 = llvm.sext %6 : i16 to i32 + %8 = llvm.and %3, %7 : i32 + %9 = llvm.trunc %8 : i32 to i16 + llvm.store %9, %1 {alignment = 2 : i64} : i16, !llvm.ptr + llvm.return + } + llvm.func @aux(i8) -> i16 + llvm.func @iter_breaker(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.zext %arg1 : i16 to i32 + %3 = llvm.mul %1, %2 : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.trunc %3 : i32 to i16 + %6 = llvm.icmp "ugt" %3, %0 : i32 + llvm.cond_br %6, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %7 = "llvm.call"(%4) {callee = @aux, fastmathFlags = #llvm.fastmath<>} : (i8) -> i16 - "llvm.return"(%7) : (i16) -> () + %7 = llvm.call @aux(%4) : (i8) -> i16 + llvm.return %7 : i16 ^bb2: // pred: ^bb0 - "llvm.return"(%5) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "iter_breaker", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - "llvm.cond_br"(%arg0, %1)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i32) -> () + llvm.return %5 : i16 + } + llvm.func @PR46561(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0 : i32) ^bb1: // pred: ^bb0 - %2 = "llvm.trunc"(%arg3) : (i8) -> i1 - %3 = "llvm.zext"(%arg1) : (i1) -> i32 - %4 = "llvm.zext"(%arg2) : (i1) -> i32 - %5 = "llvm.zext"(%2) : (i1) -> i32 - %6 = "llvm.mul"(%3, %4) : (i32, i32) -> i32 - %7 = "llvm.xor"(%6, %5) : (i32, i32) -> i32 - "llvm.br"(%7)[^bb2] : (i32) -> () + %2 = llvm.trunc %arg3 : i8 to i1 + %3 = llvm.zext %arg1 : i1 to i32 + %4 = llvm.zext %arg2 : i1 to i32 + %5 = llvm.zext %2 : i1 to i32 + %6 = llvm.mul %3, %4 : i32 + %7 = llvm.xor %6, %5 : i32 + llvm.br ^bb2(%7 : i32) ^bb2(%8: i32): // 2 preds: ^bb0, ^bb1 - %9 = "llvm.icmp"(%8, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%9) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "PR46561", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %9 = llvm.icmp "eq" %8, %1 : i32 + llvm.return %9 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-mul.ll.mlir b/test/LLVMDialect/InstCombine/icmp-mul.ll.mlir new file mode 100644 index 000000000..f0e082c46 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-mul.ll.mlir @@ -0,0 +1,766 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global extern_weak @g() {addr_space = 0 : i32} : i32 + llvm.func @use(i8) + llvm.func @usev2xi8(vector<2xi8>) + llvm.func @squared_nsw_eq0(%arg0: i5) -> i1 { + %0 = llvm.mlir.constant(0 : i5) : i5 + %1 = llvm.mul %arg0, %arg0 overflow : i5 + %2 = llvm.icmp "eq" %1, %0 : i5 + llvm.return %2 : i1 + } + llvm.func @squared_nuw_eq0(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mul %arg0, %arg0 overflow : vector<2xi8> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @squared_nsw_nuw_ne0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mul %arg0, %arg0 overflow : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @squared_eq0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mul %arg0, %arg0 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @mul_nsw_eq0(%arg0: i5, %arg1: i5) -> i1 { + %0 = llvm.mlir.constant(0 : i5) : i5 + %1 = llvm.mul %arg0, %arg1 overflow : i5 + %2 = llvm.icmp "eq" %1, %0 : i5 + llvm.return %2 : i1 + } + llvm.func @squared_nsw_eq1(%arg0: i5) -> i1 { + %0 = llvm.mlir.constant(1 : i5) : i5 + %1 = llvm.mul %arg0, %arg0 overflow : i5 + %2 = llvm.icmp "eq" %1, %0 : i5 + llvm.return %2 : i1 + } + llvm.func @squared_nsw_sgt0(%arg0: i5) -> i1 { + %0 = llvm.mlir.constant(0 : i5) : i5 + %1 = llvm.mul %arg0, %arg0 overflow : i5 + %2 = llvm.icmp "sgt" %1, %0 : i5 + llvm.return %2 : i1 + } + llvm.func @slt_positive_multip_rem_zero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @slt_negative_multip_rem_zero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-7 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @slt_positive_multip_rem_nz(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_rem_zero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_rem_zero_nsw(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_rem_nz(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_rem_nz_nsw(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @sgt_positive_multip_rem_zero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @sgt_negative_multip_rem_zero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-7 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @sgt_positive_multip_rem_nz(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ugt_rem_zero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ugt_rem_zero_nsw(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ugt_rem_nz(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ugt_rem_nz_nsw(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @eq_nsw_rem_zero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-5 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ne_nsw_rem_zero(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-30> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mul %arg0, %0 overflow : vector<2xi8> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @ne_nsw_rem_zero_undef1(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.undef : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(dense<-30> : vector<2xi8>) : vector<2xi8> + %8 = llvm.mul %arg0, %6 overflow : vector<2xi8> + %9 = llvm.icmp "ne" %8, %7 : vector<2xi8> + llvm.return %9 : vector<2xi1> + } + llvm.func @ne_nsw_rem_zero_undef2(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.constant(-30 : i8) : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mul %arg0, %0 overflow : vector<2xi8> + %9 = llvm.icmp "ne" %8, %7 : vector<2xi8> + llvm.return %9 : vector<2xi1> + } + llvm.func @eq_nsw_rem_zero_uses(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-5 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @eq_nsw_rem_nz(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-11 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ne_nsw_rem_nz(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-126 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @eq_nuw_rem_zero(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<20> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mul %arg0, %0 overflow : vector<2xi8> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @eq_nuw_rem_zero_undef1(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(dense<20> : vector<2xi8>) : vector<2xi8> + %8 = llvm.mul %arg0, %6 overflow : vector<2xi8> + %9 = llvm.icmp "eq" %8, %7 : vector<2xi8> + llvm.return %9 : vector<2xi1> + } + llvm.func @eq_nuw_rem_zero_undef2(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mul %arg0, %0 overflow : vector<2xi8> + %9 = llvm.icmp "eq" %8, %7 : vector<2xi8> + llvm.return %9 : vector<2xi1> + } + llvm.func @ne_nuw_rem_zero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-126 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ne_nuw_rem_zero_uses(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-126 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @eq_nuw_rem_nz(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-5 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ne_nuw_rem_nz(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-30 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @sgt_positive_multip_rem_zero_nonsw(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_multip_rem_zero_nonsw(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ugt_rem_zero_nonuw(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @sgt_minnum(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ule_bignum(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mul %arg0, %0 : i8 + %3 = llvm.icmp "ule" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @sgt_mulzero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(21 : i8) : i8 + %2 = llvm.mul %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @eq_rem_zero_nonuw(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.mul %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ne_rem_zero_nonuw(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(30 : i8) : i8 + %2 = llvm.mul %arg0, %0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @mul_constant_eq(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.icmp "eq" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @mul_constant_ne_splat(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mul %arg0, %0 : vector<2xi32> + %2 = llvm.mul %arg1, %0 : vector<2xi32> + %3 = llvm.icmp "ne" %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @mul_constant_ne_extra_use1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mul %arg0, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.mul %arg1, %0 : i8 + %3 = llvm.icmp "ne" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @mul_constant_eq_extra_use2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mul %arg0, %0 : i8 + %2 = llvm.mul %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "eq" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @mul_constant_ne_extra_use3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mul %arg0, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.mul %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "ne" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @mul_constant_eq_nsw(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mul %arg0, %0 overflow : i32 + %2 = llvm.mul %arg1, %0 overflow : i32 + %3 = llvm.icmp "eq" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @mul_constant_ne_nsw_splat(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<12> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mul %arg0, %0 overflow : vector<2xi32> + %2 = llvm.mul %arg1, %0 overflow : vector<2xi32> + %3 = llvm.icmp "ne" %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @mul_constant_ne_nsw_extra_use1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(74 : i8) : i8 + %1 = llvm.mul %arg0, %0 overflow : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.mul %arg1, %0 overflow : i8 + %3 = llvm.icmp "ne" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @mul_constant_eq_nsw_extra_use2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(20 : i8) : i8 + %1 = llvm.mul %arg0, %0 overflow : i8 + %2 = llvm.mul %arg1, %0 overflow : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "eq" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @mul_constant_ne_nsw_extra_use3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(24 : i8) : i8 + %1 = llvm.mul %arg0, %0 overflow : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.mul %arg1, %0 overflow : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "ne" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @mul_constant_nuw_eq(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(22 : i32) : i32 + %1 = llvm.mul %arg0, %0 overflow : i32 + %2 = llvm.mul %arg1, %0 overflow : i32 + %3 = llvm.icmp "eq" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @mul_constant_ne_nuw_splat(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mul %arg0, %0 overflow : vector<2xi32> + %2 = llvm.mul %arg1, %0 overflow : vector<2xi32> + %3 = llvm.icmp "ne" %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @mul_constant_ne_nuw_extra_use1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mul %arg0, %0 overflow : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.mul %arg1, %0 overflow : i8 + %3 = llvm.icmp "ne" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @mul_constant_eq_nuw_extra_use2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(36 : i8) : i8 + %1 = llvm.mul %arg0, %0 overflow : i8 + %2 = llvm.mul %arg1, %0 overflow : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "eq" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @mul_constant_ne_nuw_extra_use3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(38 : i8) : i8 + %1 = llvm.mul %arg0, %0 overflow : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.mul %arg1, %0 overflow : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "ne" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @mul_constant_ult(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(47 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.icmp "ult" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @mul_constant_nuw_sgt(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(46 : i32) : i32 + %1 = llvm.mul %arg0, %0 overflow : i32 + %2 = llvm.mul %arg1, %0 overflow : i32 + %3 = llvm.icmp "sgt" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @mul_mismatch_constant_nuw_eq(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(46 : i32) : i32 + %1 = llvm.mlir.constant(44 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.mul %arg1, %1 overflow : i32 + %4 = llvm.icmp "eq" %2, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @mul_constant_partial_nuw_eq(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(44 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 overflow : i32 + %3 = llvm.icmp "eq" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @mul_constant_mismatch_wrap_eq(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(54 : i32) : i32 + %1 = llvm.mul %arg0, %0 overflow : i32 + %2 = llvm.mul %arg1, %0 overflow : i32 + %3 = llvm.icmp "eq" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @eq_mul_constants_with_tz(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.icmp "ne" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @eq_mul_constants_with_tz_splat(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<12> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mul %arg0, %0 : vector<2xi32> + %2 = llvm.mul %arg1, %0 : vector<2xi32> + %3 = llvm.icmp "eq" %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @oss_fuzz_39934(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.addressof @g : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(65537 : i32) : i32 + %4 = llvm.mul %arg0, %0 overflow : i32 + %5 = llvm.icmp "eq" %1, %2 : !llvm.ptr + %6 = llvm.zext %5 : i1 to i32 + %7 = llvm.or %6, %3 : i32 + %8 = llvm.mul %7, %0 : i32 + %9 = llvm.icmp "ne" %8, %4 : i32 + llvm.return %9 : i1 + } + llvm.func @mul_of_bool(%arg0: i32, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.zext %arg1 : i8 to i32 + %4 = llvm.mul %2, %3 : i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @mul_of_bool_commute(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.mul %3, %2 : i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @mul_of_bools(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.mul %2, %3 : i32 + %5 = llvm.icmp "ult" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @not_mul_of_bool(%arg0: i32, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.zext %arg1 : i8 to i32 + %4 = llvm.mul %2, %3 : i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @not_mul_of_bool_commute(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(30 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.mul %3, %2 : i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @mul_of_bool_no_lz_other_op(%arg0: i32, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(127 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.sext %arg1 : i8 to i32 + %4 = llvm.mul %2, %3 overflow : i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @mul_of_pow2(%arg0: i32, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(510 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.zext %arg1 : i8 to i32 + %4 = llvm.mul %2, %3 : i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @mul_of_pow2_commute(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.mlir.constant(1020 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.and %arg1, %1 : i32 + %5 = llvm.mul %4, %3 : i32 + %6 = llvm.icmp "ugt" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @mul_of_pow2s(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.and %arg1, %1 : i32 + %5 = llvm.mul %3, %4 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @not_mul_of_pow2(%arg0: i32, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(1530 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.zext %arg1 : i8 to i32 + %4 = llvm.mul %2, %3 : i32 + %5 = llvm.icmp "ugt" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @not_mul_of_pow2_commute(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.mlir.constant(3060 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.and %arg1, %1 : i32 + %5 = llvm.mul %4, %3 : i32 + %6 = llvm.icmp "ugt" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @mul_of_pow2_no_lz_other_op(%arg0: i32, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(254 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.sext %arg1 : i8 to i32 + %4 = llvm.mul %2, %3 overflow : i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @splat_mul_known_lz(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(18446744078004518913 : i128) : i128 + %1 = llvm.mlir.constant(96 : i128) : i128 + %2 = llvm.mlir.constant(0 : i128) : i128 + %3 = llvm.zext %arg0 : i32 to i128 + %4 = llvm.mul %3, %0 : i128 + %5 = llvm.lshr %4, %1 : i128 + %6 = llvm.icmp "eq" %5, %2 : i128 + llvm.return %6 : i1 + } + llvm.func @splat_mul_unknown_lz(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(18446744078004518913 : i128) : i128 + %1 = llvm.mlir.constant(95 : i128) : i128 + %2 = llvm.mlir.constant(0 : i128) : i128 + %3 = llvm.zext %arg0 : i32 to i128 + %4 = llvm.mul %3, %0 : i128 + %5 = llvm.lshr %4, %1 : i128 + %6 = llvm.icmp "eq" %5, %2 : i128 + llvm.return %6 : i1 + } + llvm.func @mul_oddC_overflow_eq(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(101 : i8) : i8 + %2 = llvm.mul %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @mul_oddC_eq_nomod(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(34 : i8) : i8 + %2 = llvm.mul %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @mul_evenC_ne(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(36 : i8) : i8 + %2 = llvm.mul %arg0, %0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @mul_oddC_ne_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<12> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mul %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @mul_oddC_ne_nosplat_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 5]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[12, 15]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mul %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @mul_nsuw_xy_z_maybe_zero_eq(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mul %arg0, %arg2 overflow : i8 + %1 = llvm.mul %arg1, %arg2 overflow : i8 + %2 = llvm.icmp "eq" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @mul_xy_z_assumenozero_ne(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ne" %arg2, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.mul %arg0, %arg2 : i8 + %3 = llvm.mul %arg1, %arg2 : i8 + %4 = llvm.icmp "ne" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @mul_xy_z_assumeodd_eq(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.and %arg2, %0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.mul %arg0, %arg2 : i8 + %5 = llvm.mul %arg2, %arg1 : i8 + %6 = llvm.icmp "eq" %4, %5 : i8 + llvm.return %6 : i1 + } + llvm.func @reused_mul_nsw_xy_z_setnonzero_vec_ne(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi8>) : vector<2xi8> + %1 = llvm.or %arg2, %0 : vector<2xi8> + %2 = llvm.mul %1, %arg0 overflow : vector<2xi8> + %3 = llvm.mul %arg1, %1 overflow : vector<2xi8> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi8> + llvm.call @usev2xi8(%3) : (vector<2xi8>) -> () + llvm.return %4 : vector<2xi1> + } + llvm.func @mul_mixed_nuw_nsw_xy_z_setodd_ult(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.or %arg2, %0 : i8 + %2 = llvm.mul %arg0, %1 overflow : i8 + %3 = llvm.mul %arg1, %1 overflow : i8 + %4 = llvm.icmp "ult" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @mul_nuw_xy_z_assumenonzero_uge(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ne" %arg2, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.mul %arg0, %arg2 overflow : i8 + %3 = llvm.mul %arg1, %arg2 overflow : i8 + %4 = llvm.icmp "uge" %3, %2 : i8 + llvm.call @use(%2) : (i8) -> () + llvm.return %4 : i1 + } + llvm.func @mul_nuw_xy_z_setnonzero_vec_eq(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[41, 12]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.or %arg2, %0 : vector<2xi8> + %2 = llvm.mul %1, %arg0 overflow : vector<2xi8> + %3 = llvm.mul %1, %arg1 overflow : vector<2xi8> + %4 = llvm.icmp "eq" %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @mul_nuw_xy_z_brnonzero_ult(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ne" %arg2, %0 : i8 + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.mul %arg0, %arg2 overflow : i8 + %4 = llvm.mul %arg1, %arg2 overflow : i8 + %5 = llvm.icmp "ult" %4, %3 : i8 + llvm.return %5 : i1 + ^bb2: // pred: ^bb0 + llvm.call @use(%arg2) : (i8) -> () + llvm.return %1 : i1 + } + llvm.func @reused_mul_nuw_xy_z_selectnonzero_ugt(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ne" %arg2, %0 : i8 + %3 = llvm.mul %arg0, %arg2 overflow : i8 + %4 = llvm.mul %arg1, %arg2 overflow : i8 + %5 = llvm.icmp "ugt" %4, %3 : i8 + %6 = llvm.select %2, %5, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @mul_mixed_nsw_nuw_xy_z_setnonzero_vec_ule(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, 3]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.or %arg2, %0 : vector<2xi8> + %2 = llvm.mul %arg0, %1 overflow : vector<2xi8> + %3 = llvm.mul %1, %arg1 overflow : vector<2xi8> + %4 = llvm.icmp "ule" %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-ne-pow2.ll.mlir b/test/LLVMDialect/InstCombine/icmp-ne-pow2.ll.mlir new file mode 100644 index 000000000..eea137c23 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-ne-pow2.ll.mlir @@ -0,0 +1,311 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pow2_32_assume(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.and %arg0, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @not_pow2_32_assume(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.and %arg0, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @pow2_64_assume(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.icmp "ne" %2, %1 : i64 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.or %arg0, %0 : i64 + llvm.return %4 : i64 + } + llvm.func @not_pow2_64_assume(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.icmp "ne" %2, %1 : i64 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.or %arg0, %0 : i64 + llvm.return %4 : i64 + } + llvm.func @pow2_16_assume(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(16384 : i16) : i16 + %1 = llvm.and %arg0, %0 : i16 + %2 = llvm.icmp "eq" %1, %0 : i16 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.and %arg0, %0 : i16 + llvm.return %3 : i16 + } + llvm.func @not_pow2_16_assume(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(7 : i16) : i16 + %1 = llvm.and %arg0, %0 : i16 + %2 = llvm.icmp "ne" %1, %0 : i16 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.and %arg0, %0 : i16 + llvm.return %3 : i16 + } + llvm.func @pow2_8_assume(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.or %arg0, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @not_pow2_8_assume(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.or %arg0, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @pow2_32_br(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.or %arg0, %0 : i32 + llvm.return %4 : i32 + ^bb2: // pred: ^bb0 + llvm.return %1 : i32 + } + llvm.func @not_pow2_32_br(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.or %arg0, %0 : i32 + llvm.return %4 : i32 + ^bb2: // pred: ^bb0 + llvm.return %1 : i32 + } + llvm.func @pow2_64_br(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.icmp "ne" %2, %1 : i64 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.and %arg0, %0 : i64 + llvm.return %4 : i64 + ^bb2: // pred: ^bb0 + llvm.return %1 : i64 + } + llvm.func @not_pow2_64_br(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.icmp "ne" %2, %1 : i64 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.and %arg0, %0 : i64 + llvm.return %4 : i64 + ^bb2: // pred: ^bb0 + llvm.return %1 : i64 + } + llvm.func @pow2_16_br(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(16384 : i16) : i16 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.and %arg0, %0 : i16 + %3 = llvm.icmp "eq" %2, %0 : i16 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.or %arg0, %0 : i16 + llvm.return %4 : i16 + ^bb2: // pred: ^bb0 + llvm.return %1 : i16 + } + llvm.func @not_pow2_16_br(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(7 : i16) : i16 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.and %arg0, %0 : i16 + %3 = llvm.icmp "ne" %2, %0 : i16 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.or %arg0, %0 : i16 + llvm.return %4 : i16 + ^bb2: // pred: ^bb0 + llvm.return %1 : i16 + } + llvm.func @pow2_8_br(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.and %arg0, %0 : i8 + llvm.return %4 : i8 + ^bb2: // pred: ^bb0 + llvm.return %1 : i8 + } + llvm.func @not_pow2_8_br(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.icmp "ne" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.and %arg0, %0 : i8 + llvm.return %4 : i8 + ^bb2: // pred: ^bb0 + llvm.return %1 : i8 + } + llvm.func @pow2_32_nonconst_assume(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.and %arg0, %arg1 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + "llvm.intr.assume"(%5) : (i1) -> () + %6 = llvm.and %arg0, %arg1 : i32 + llvm.return %6 : i32 + } + llvm.func @pow2_32_gtnonconst_assume(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.icmp "ugt" %arg1, %arg0 : i32 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.and %arg0, %arg1 : i32 + llvm.return %4 : i32 + } + llvm.func @not_pow2_32_nonconst_assume(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.and %arg0, %arg1 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + "llvm.intr.assume"(%5) : (i1) -> () + %6 = llvm.and %arg0, %arg1 : i32 + llvm.return %6 : i32 + } + llvm.func @pow2_or_zero_32_nonconst_assume(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %3 = llvm.icmp "ule" %2, %0 : i32 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.and %arg0, %arg1 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + "llvm.intr.assume"(%5) : (i1) -> () + %6 = llvm.and %arg0, %arg1 : i32 + llvm.return %6 : i32 + } + llvm.func @pow2_32_nonconst_assume_br(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.and %arg0, %arg1 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %6 = llvm.and %arg0, %arg1 : i32 + llvm.return %6 : i32 + ^bb2: // pred: ^bb0 + llvm.return %1 : i32 + } + llvm.func @not_pow2_32_nonconst_assume_br(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.and %arg0, %arg1 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %6 = llvm.and %arg0, %arg1 : i32 + llvm.return %6 : i32 + ^bb2: // pred: ^bb0 + llvm.return %1 : i32 + } + llvm.func @pow2_or_zero_32_nonconst_assume_br(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %3 = llvm.icmp "ule" %2, %0 : i32 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.and %arg0, %arg1 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %6 = llvm.and %arg0, %arg1 : i32 + llvm.return %6 : i32 + ^bb2: // pred: ^bb0 + llvm.return %1 : i32 + } + llvm.func @pow2_32_nonconst_br1_br(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.cond_br %3, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %4 = llvm.and %arg0, %arg1 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + llvm.cond_br %5, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %6 = llvm.and %arg0, %arg1 : i32 + llvm.return %6 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %1 : i32 + } + llvm.func @not_pow2_32_nonconst_br1_br(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + llvm.cond_br %3, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %4 = llvm.and %arg0, %arg1 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + llvm.cond_br %5, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %6 = llvm.and %arg0, %arg1 : i32 + llvm.return %6 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %1 : i32 + } + llvm.func @maybe_pow2_32_noncont(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.icmp "ugt" %arg1, %0 : i32 + llvm.cond_br %4, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %5 = llvm.intr.ctpop(%arg1) : (i32) -> i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + "llvm.intr.assume"(%6) : (i1) -> () + llvm.cond_br %2, ^bb2, ^bb4 + ^bb2: // 2 preds: ^bb0, ^bb1 + %7 = llvm.and %arg0, %arg1 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + llvm.cond_br %8, ^bb3, ^bb4 + ^bb3: // pred: ^bb2 + %9 = llvm.and %arg0, %arg1 : i32 + llvm.return %9 : i32 + ^bb4: // 2 preds: ^bb1, ^bb2 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-not-bool-constant.ll.mlir b/test/LLVMDialect/InstCombine/icmp-not-bool-constant.ll.mlir new file mode 100644 index 000000000..4d253eddc --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-not-bool-constant.ll.mlir @@ -0,0 +1,162 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @eq_t_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.xor %arg0, %1 : vector<2xi1> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @eq_f_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.xor %arg0, %1 : vector<2xi1> + %5 = llvm.icmp "eq" %4, %3 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @ne_t_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.xor %arg0, %1 : vector<2xi1> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @ne_f_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.xor %arg0, %1 : vector<2xi1> + %5 = llvm.icmp "ne" %4, %3 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @ugt_t_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.xor %arg0, %1 : vector<2xi1> + %3 = llvm.icmp "ugt" %2, %1 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @ugt_f_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.xor %arg0, %1 : vector<2xi1> + %5 = llvm.icmp "ugt" %4, %3 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @ult_t_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.xor %arg0, %1 : vector<2xi1> + %3 = llvm.icmp "ult" %2, %1 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @ult_f_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.xor %arg0, %1 : vector<2xi1> + %5 = llvm.icmp "ult" %4, %3 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @sgt_t_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.xor %arg0, %1 : vector<2xi1> + %3 = llvm.icmp "sgt" %2, %1 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @sgt_f_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.xor %arg0, %1 : vector<2xi1> + %5 = llvm.icmp "sgt" %4, %3 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @slt_t_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.xor %arg0, %1 : vector<2xi1> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @slt_f_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.xor %arg0, %1 : vector<2xi1> + %5 = llvm.icmp "slt" %4, %3 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @uge_t_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.xor %arg0, %1 : vector<2xi1> + %3 = llvm.icmp "uge" %2, %1 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @uge_f_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.xor %arg0, %1 : vector<2xi1> + %5 = llvm.icmp "uge" %4, %3 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @ule_t_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.xor %arg0, %1 : vector<2xi1> + %3 = llvm.icmp "ule" %2, %1 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @ule_f_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.xor %arg0, %1 : vector<2xi1> + %5 = llvm.icmp "ule" %4, %3 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @sge_t_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.xor %arg0, %1 : vector<2xi1> + %3 = llvm.icmp "sge" %2, %1 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @sge_f_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.xor %arg0, %1 : vector<2xi1> + %5 = llvm.icmp "sge" %4, %3 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @sle_t_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.xor %arg0, %1 : vector<2xi1> + %3 = llvm.icmp "sle" %2, %1 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @sle_f_not(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.xor %arg0, %1 : vector<2xi1> + %5 = llvm.icmp "sle" %4, %3 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-of-and-x.ll.mlir b/test/LLVMDialect/InstCombine/icmp-of-and-x.ll.mlir new file mode 100644 index 000000000..b0c25896e --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-of-and-x.ll.mlir @@ -0,0 +1,168 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @barrier() -> i1 + llvm.func @use.i8(i8) + llvm.func @icmp_ult_x_y(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.and %arg0, %arg1 : i8 + %1 = llvm.icmp "ult" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @icmp_ult_x_y_2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg0 : i8 + %1 = llvm.and %0, %arg1 : i8 + %2 = llvm.icmp "ugt" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @icmp_uge_x_y(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.and %arg0, %arg1 : vector<2xi8> + %1 = llvm.icmp "uge" %0, %arg0 : vector<2xi8> + llvm.return %1 : vector<2xi1> + } + llvm.func @icmp_uge_x_y_2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg0 : i8 + %1 = llvm.and %0, %arg1 : i8 + %2 = llvm.icmp "ule" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @icmp_sge_x_negy(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg1, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.and %arg0, %arg1 : i8 + %3 = llvm.icmp "sge" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_slt_x_negy(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg1, %0 : i8 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.and %arg0, %arg1 : i8 + %3 = llvm.icmp "slt" %2, %arg0 : i8 + llvm.return %3 : i1 + ^bb2: // pred: ^bb0 + %4 = llvm.call @barrier() : () -> i1 + llvm.return %4 : i1 + } + llvm.func @icmp_slt_x_negy_fail_maybe_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "sle" %arg1, %0 : i8 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.and %arg0, %arg1 : i8 + %3 = llvm.icmp "slt" %2, %arg0 : i8 + llvm.return %3 : i1 + ^bb2: // pred: ^bb0 + %4 = llvm.call @barrier() : () -> i1 + llvm.return %4 : i1 + } + llvm.func @icmp_sle_x_negy(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.or %arg1, %0 : i8 + %2 = llvm.and %1, %arg0 : i8 + %3 = llvm.icmp "sle" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt_x_negy(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.or %arg1, %0 : vector<2xi8> + %2 = llvm.and %1, %arg0 : vector<2xi8> + %3 = llvm.icmp "sgt" %2, %arg0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_sgt_x_negy_fail_partial(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-128, 4]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.or %arg1, %0 : vector<2xi8> + %2 = llvm.and %1, %arg0 : vector<2xi8> + %3 = llvm.icmp "sgt" %2, %arg0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_sle_x_posy(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg1, %0 : vector<2xi8> + %2 = llvm.and %1, %arg0 : vector<2xi8> + %3 = llvm.icmp "sle" %2, %arg0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_sle_x_posy_fail_partial(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[127, -65]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.and %arg1, %0 : vector<2xi8> + %2 = llvm.and %1, %arg0 : vector<2xi8> + %3 = llvm.icmp "sle" %2, %arg0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_sgt_x_posy(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "sge" %arg1, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.and %arg0, %arg1 : i8 + %3 = llvm.icmp "sgt" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt_negx_y(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.or %arg0, %0 : vector<2xi8> + %2 = llvm.and %1, %arg1 : vector<2xi8> + %3 = llvm.icmp "sgt" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_sle_negx_y(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.and %arg0, %arg1 : i8 + %3 = llvm.icmp "sle" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sle_negx_y_fail_maybe_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "sle" %arg0, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.and %arg0, %arg1 : i8 + %3 = llvm.icmp "sle" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_eq_x_invertable_y_todo(%arg0: i8, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(24 : i8) : i8 + %2 = llvm.select %arg1, %0, %1 : i1, i8 + %3 = llvm.and %arg0, %2 : i8 + %4 = llvm.icmp "eq" %arg0, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @icmp_eq_x_invertable_y(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + %2 = llvm.and %arg0, %1 : i8 + %3 = llvm.icmp "eq" %arg0, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_eq_x_invertable_y_fail_multiuse(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + %2 = llvm.and %arg0, %1 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.icmp "eq" %arg0, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_eq_x_invertable_y2_todo(%arg0: i8, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(24 : i8) : i8 + %2 = llvm.select %arg1, %0, %1 : i1, i8 + %3 = llvm.and %arg0, %2 : i8 + %4 = llvm.icmp "eq" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @icmp_eq_x_invertable_y2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + %2 = llvm.and %arg0, %1 : i8 + %3 = llvm.icmp "eq" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_eq_x_invertable_y_fail_immconstant(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-of-or-x.ll.mlir b/test/LLVMDialect/InstCombine/icmp-of-or-x.ll.mlir new file mode 100644 index 000000000..6daf544a0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-of-or-x.ll.mlir @@ -0,0 +1,235 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @barrier() + llvm.func @use.v2i8(vector<2xi8>) + llvm.func @use.i8(i8) + llvm.func @or_ugt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.or %arg0, %arg1 : i8 + %1 = llvm.icmp "ugt" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @or_ule(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.or %arg0, %arg1 : vector<2xi8> + %1 = llvm.icmp "ule" %0, %arg0 : vector<2xi8> + llvm.return %1 : vector<2xi1> + } + llvm.func @or_slt_pos(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.add %arg0, %arg2 : vector<2xi8> + %2 = llvm.and %arg1, %0 : vector<2xi8> + %3 = llvm.or %1, %2 : vector<2xi8> + %4 = llvm.icmp "slt" %1, %3 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @or_sle_pos(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "sge" %arg1, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.or %arg0, %arg1 : i8 + %3 = llvm.icmp "sle" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @or_sle_fail_maybe_neg(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.or %arg0, %arg1 : i8 + %1 = llvm.icmp "sle" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @or_eq_noundef(%arg0: i8, %arg1: i8 {llvm.noundef}) -> i1 { + %0 = llvm.or %arg0, %arg1 : i8 + %1 = llvm.icmp "eq" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @or_eq_notY_eq_0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + %2 = llvm.or %arg0, %1 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @or_eq_notY_eq_0_fail_multiuse(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + %2 = llvm.or %arg0, %1 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @or_ne_notY_eq_1s(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + %2 = llvm.or %arg0, %1 : i8 + %3 = llvm.icmp "ne" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @or_ne_notY_eq_1s_fail_bad_not(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + %2 = llvm.or %arg0, %1 : i8 + %3 = llvm.icmp "ne" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @or_ne_vecC(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[9, 42]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.or %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "ne" %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @or_eq_fail_maybe_undef(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.or %arg0, %arg1 : i8 + %1 = llvm.icmp "eq" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @or_ne_noundef(%arg0: vector<2xi8>, %arg1: vector<2xi8> {llvm.noundef}) -> vector<2xi1> { + %0 = llvm.or %arg0, %arg1 : vector<2xi8> + %1 = llvm.icmp "ne" %0, %arg0 : vector<2xi8> + llvm.return %1 : vector<2xi1> + } + llvm.func @or_ne_noundef_fail_reuse(%arg0: vector<2xi8>, %arg1: vector<2xi8> {llvm.noundef}) -> vector<2xi1> { + %0 = llvm.or %arg0, %arg1 : vector<2xi8> + %1 = llvm.icmp "ne" %0, %arg0 : vector<2xi8> + llvm.call @use.v2i8(%0) : (vector<2xi8>) -> () + llvm.return %1 : vector<2xi1> + } + llvm.func @or_slt_intmin(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.icmp "slt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @or_slt_intmin_2(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.add %arg0, %arg1 : vector<2xi8> + %2 = llvm.or %1, %0 : vector<2xi8> + %3 = llvm.icmp "slt" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @or_sle_intmin_indirect_2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.add %arg0, %arg2 : i8 + %3 = llvm.sub %0, %arg1 : i8 + %4 = llvm.and %arg1, %3 : i8 + %5 = llvm.icmp "slt" %4, %0 : i8 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %6 = llvm.or %2, %4 : i8 + %7 = llvm.icmp "sle" %2, %6 : i8 + llvm.return %7 : i1 + ^bb2: // pred: ^bb0 + llvm.call @barrier() : () -> () + llvm.return %1 : i1 + } + llvm.func @or_sge_intmin(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.icmp "sge" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @or_sgt_intmin_indirect(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.sub %0, %arg1 : i8 + %3 = llvm.and %arg1, %2 : i8 + %4 = llvm.icmp "sge" %3, %0 : i8 + llvm.cond_br %4, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + %5 = llvm.or %arg0, %3 : i8 + %6 = llvm.icmp "sgt" %5, %arg0 : i8 + llvm.return %6 : i1 + ^bb2: // pred: ^bb0 + llvm.call @barrier() : () -> () + llvm.return %1 : i1 + } + llvm.func @or_sgt_intmin_2(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.add %arg0, %arg1 : vector<2xi8> + %2 = llvm.or %1, %0 : vector<2xi8> + %3 = llvm.icmp "sgt" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @or_simplify_ule(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.or %2, %3 : i8 + %5 = llvm.icmp "ule" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @or_simplify_uge(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-127 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.or %2, %3 : i8 + %5 = llvm.icmp "uge" %3, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @or_simplify_ule_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(64 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.or %2, %3 : i8 + %5 = llvm.icmp "ule" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @or_simplify_ugt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.or %2, %3 : i8 + %5 = llvm.icmp "ugt" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @or_simplify_ult(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(36 : i8) : i8 + %1 = llvm.mlir.constant(-5 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.or %2, %3 : i8 + %5 = llvm.icmp "ult" %3, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @or_simplify_ugt_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.or %arg1, %1 : i8 + %4 = llvm.or %2, %3 : i8 + %5 = llvm.icmp "ugt" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @pr64610(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(74 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.load %arg0 {alignment = 2 : i64} : !llvm.ptr -> i1 + %4 = llvm.select %3, %0, %1 : i1, i32 + %5 = llvm.or %4, %2 : i32 + %6 = llvm.icmp "ugt" %5, %4 : i32 + llvm.return %6 : i1 + } + llvm.func @icmp_eq_x_invertable_y2_todo(%arg0: i8, %arg1: i1, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.xor %arg2, %0 : i8 + %3 = llvm.select %arg1, %1, %2 : i1, i8 + %4 = llvm.or %arg0, %3 : i8 + %5 = llvm.icmp "eq" %3, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @icmp_eq_x_invertable_y2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + %2 = llvm.or %arg0, %1 : i8 + %3 = llvm.icmp "eq" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @PR38139(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.icmp "ne" %1, %arg0 : i8 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-of-trunc-ext.ll.mlir b/test/LLVMDialect/InstCombine/icmp-of-trunc-ext.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/icmp-of-xor-x.ll.mlir b/test/LLVMDialect/InstCombine/icmp-of-xor-x.ll.mlir new file mode 100644 index 000000000..4e2b85489 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-of-xor-x.ll.mlir @@ -0,0 +1,258 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @barrier() + llvm.func @use.i8(i8) + llvm.func @test_xor1(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use.i8(%1) : (i8) -> () + %2 = llvm.xor %1, %arg1 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.icmp "slt" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @test_xor2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg2, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.xor %2, %arg0 : i8 + %4 = llvm.icmp "sle" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @test_xor3(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg2, %0 : i8 + %2 = llvm.xor %arg0, %0 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.xor %2, %arg1 : i8 + %4 = llvm.icmp "sgt" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @test_xor_ne(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg2, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %2, %arg0 : i8 + %4 = llvm.icmp "ne" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @test_xor_eq(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg2, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %2, %arg0 : i8 + %4 = llvm.icmp "eq" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @test_xor4(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg2, %0 : i8 + %2 = llvm.xor %arg0, %0 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.xor %2, %arg1 : i8 + %4 = llvm.icmp "sge" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @test_xor5(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg2, %0 : i8 + %2 = llvm.xor %arg0, %0 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.xor %2, %arg1 : i8 + %4 = llvm.icmp "ult" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @test_xor6(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg2, %0 : i8 + %2 = llvm.xor %arg0, %0 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.xor %2, %arg1 : i8 + %4 = llvm.icmp "ule" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @test_xor7(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg2, %0 : i8 + %2 = llvm.xor %arg0, %0 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.xor %2, %arg1 : i8 + %4 = llvm.icmp "ugt" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @test_xor8(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg2, %0 : i8 + %2 = llvm.xor %arg0, %0 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.xor %2, %arg1 : i8 + %4 = llvm.icmp "uge" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @test_slt_xor(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %1, %arg1 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test_sle_xor(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %1, %arg0 : i32 + %3 = llvm.icmp "sle" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test_sgt_xor(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %1, %arg1 : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test_sge_xor(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %1, %arg1 : i32 + %3 = llvm.icmp "sge" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test_ult_xor(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %1, %arg1 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test_ule_xor(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %1, %arg1 : i32 + %3 = llvm.icmp "ule" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test_ugt_xor(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %1, %arg1 : i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test_uge_xor(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %1, %arg1 : i32 + %3 = llvm.icmp "uge" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test_xor1_nofold_multi_use(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %1, %arg1 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.xor %arg2, %0 : i8 + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.icmp "slt" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @xor_uge(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ne" %arg1, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.xor %arg0, %arg1 : i8 + %3 = llvm.icmp "uge" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @xor_uge_fail_maybe_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.xor %arg0, %arg1 : i8 + %1 = llvm.icmp "uge" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @xor_ule_2(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[9, 8]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.or %arg1, %0 : vector<2xi8> + %2 = llvm.xor %1, %arg0 : vector<2xi8> + %3 = llvm.icmp "ule" %2, %arg0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @xor_sle_2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.add %arg0, %arg2 : i8 + %2 = llvm.icmp "ne" %arg1, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.xor %1, %arg1 : i8 + %4 = llvm.icmp "sle" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @xor_sge(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mul %arg0, %arg0 : i8 + %2 = llvm.or %arg1, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.icmp "sge" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @xor_ugt_2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(63 : i8) : i8 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.add %arg0, %arg2 : i8 + %3 = llvm.and %arg1, %0 : i8 + %4 = llvm.or %3, %1 : i8 + %5 = llvm.xor %2, %4 : i8 + %6 = llvm.icmp "ugt" %2, %5 : i8 + llvm.return %6 : i1 + } + llvm.func @xor_ult(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.icmp "ult" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @xor_sgt(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<31> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<64> : vector<2xi8>) : vector<2xi8> + %2 = llvm.and %arg1, %0 : vector<2xi8> + %3 = llvm.or %2, %1 : vector<2xi8> + %4 = llvm.xor %arg0, %3 : vector<2xi8> + %5 = llvm.icmp "sgt" %4, %arg0 : vector<2xi8> + llvm.return %5 : vector<2xi1> + } + llvm.func @xor_sgt_fail_no_known_msb(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<63> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<8> : vector<2xi8>) : vector<2xi8> + %2 = llvm.and %arg1, %0 : vector<2xi8> + %3 = llvm.or %2, %1 : vector<2xi8> + %4 = llvm.xor %arg0, %3 : vector<2xi8> + %5 = llvm.icmp "sgt" %4, %arg0 : vector<2xi8> + llvm.return %5 : vector<2xi1> + } + llvm.func @xor_slt_2(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(88 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.icmp "slt" %arg0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @xor_sgt_intmin_2(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.add %arg0, %arg2 : vector<2xi8> + %2 = llvm.or %arg1, %0 : vector<2xi8> + %3 = llvm.xor %1, %2 : vector<2xi8> + %4 = llvm.icmp "sgt" %1, %3 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @or_slt_intmin_indirect(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg1, %0 : i8 + llvm.cond_br %2, ^bb2, ^bb3 + ^bb1(%3: i1): // 2 preds: ^bb2, ^bb3 + llvm.return %3 : i1 + ^bb2: // pred: ^bb0 + %4 = llvm.xor %arg1, %arg0 : i8 + %5 = llvm.icmp "slt" %4, %arg0 : i8 + llvm.br ^bb1(%5 : i1) + ^bb3: // pred: ^bb0 + llvm.call @barrier() : () -> () + llvm.br ^bb1(%1 : i1) + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-or.ll.mlir b/test/LLVMDialect/InstCombine/icmp-or.ll.mlir new file mode 100644 index 000000000..fd40e4e45 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-or.ll.mlir @@ -0,0 +1,547 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @set_low_bit_mask_eq(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(19 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @set_low_bit_mask_ne(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<19> : vector<2xi8>) : vector<2xi8> + %2 = llvm.or %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @set_low_bit_mask_ugt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(19 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @set_low_bit_mask_ult(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(19 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @set_low_bit_mask_uge(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.icmp "uge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @set_low_bit_mask_ule(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(18 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.icmp "ule" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @set_low_bit_mask_sgt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @set_low_bit_mask_slt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(19 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @set_low_bit_mask_sge(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(31 : i8) : i8 + %1 = llvm.mlir.constant(51 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.icmp "sge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @set_low_bit_mask_sle(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(63 : i8) : i8 + %1 = llvm.mlir.constant(68 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.icmp "sle" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @eq_const_mask(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.or %arg1, %0 : i8 + %3 = llvm.icmp "eq" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @ne_const_mask(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-106, 5]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.or %arg0, %0 : vector<2xi8> + %2 = llvm.or %arg1, %0 : vector<2xi8> + %3 = llvm.icmp "ne" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @eq_const_mask_not_equality(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.or %arg1, %0 : i8 + %3 = llvm.icmp "sgt" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @eq_const_mask_not_same(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.or %arg1, %1 : i8 + %4 = llvm.icmp "eq" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @eq_const_mask_wrong_opcode(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.icmp "eq" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @eq_const_mask_use1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.or %arg1, %0 : i8 + %3 = llvm.icmp "eq" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @eq_const_mask_use2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.or %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "eq" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @decrement_slt_0(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.add %arg0, %0 : vector<2xi8> + %4 = llvm.or %3, %arg0 : vector<2xi8> + %5 = llvm.icmp "slt" %4, %2 : vector<2xi8> + llvm.return %5 : vector<2xi1> + } + llvm.func @decrement_slt_0_commute_use1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mul %arg0, %0 : i8 + %4 = llvm.add %3, %1 : i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.or %3, %4 : i8 + %6 = llvm.icmp "slt" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @decrement_slt_0_use2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.or %2, %arg0 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.icmp "slt" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @decrement_slt_n1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.or %1, %arg0 : i8 + %3 = llvm.icmp "slt" %2, %0 : i8 + llvm.return %3 : i1 + } + llvm.func @not_decrement_slt_0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.or %2, %arg0 : i8 + %4 = llvm.icmp "slt" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @decrement_sgt_n1(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.add %arg0, %0 : vector<2xi8> + %2 = llvm.or %1, %arg0 : vector<2xi8> + %3 = llvm.icmp "sgt" %2, %0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @decrement_sgt_n1_commute_use1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mul %arg0, %0 : i8 + %3 = llvm.add %2, %1 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.or %2, %3 : i8 + %5 = llvm.icmp "sgt" %4, %1 : i8 + llvm.return %5 : i1 + } + llvm.func @decrement_sgt_n1_use2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.or %1, %arg0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "sgt" %2, %0 : i8 + llvm.return %3 : i1 + } + llvm.func @decrement_sgt_0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.or %2, %arg0 : i8 + %4 = llvm.icmp "sgt" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @not_decrement_sgt_n1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.or %2, %arg0 : i8 + %4 = llvm.icmp "sgt" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @icmp_or_xor_2_eq(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.icmp "eq" %3, %0 : i64 + llvm.return %4 : i1 + } + llvm.func @icmp_or_xor_2_ne(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.icmp "ne" %3, %0 : i64 + llvm.return %4 : i1 + } + llvm.func @icmp_or_xor_2_eq_fail(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.icmp "eq" %3, %0 : i64 + llvm.return %4 : i1 + } + llvm.func @icmp_or_xor_2_ne_fail(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.icmp "ne" %3, %0 : i64 + llvm.return %4 : i1 + } + llvm.func @icmp_or_xor_2_3_fail(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.icmp "eq" %3, %0 : i64 + %5 = llvm.icmp "eq" %1, %0 : i64 + %6 = llvm.or %4, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @icmp_or_xor_2_4_fail(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.icmp "eq" %3, %0 : i64 + %5 = llvm.icmp "eq" %2, %0 : i64 + %6 = llvm.or %4, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @icmp_or_xor_3_1(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.xor %arg4, %arg5 : i64 + %5 = llvm.or %3, %4 : i64 + %6 = llvm.icmp "eq" %5, %0 : i64 + llvm.return %6 : i1 + } + llvm.func @icmp_or_xor_3_2_fail(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.and %1, %2 : i64 + %4 = llvm.xor %arg4, %arg5 : i64 + %5 = llvm.or %3, %4 : i64 + %6 = llvm.icmp "eq" %5, %0 : i64 + llvm.return %6 : i1 + } + llvm.func @icmp_or_xor_3_3(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.xor %arg4, %arg5 : i64 + %5 = llvm.or %4, %3 : i64 + %6 = llvm.icmp "eq" %5, %0 : i64 + llvm.return %6 : i1 + } + llvm.func @icmp_or_xor_3_4_fail(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.and %1, %2 : i64 + %4 = llvm.xor %arg4, %arg5 : i64 + %5 = llvm.or %4, %3 : i64 + %6 = llvm.icmp "eq" %5, %0 : i64 + llvm.return %6 : i1 + } + llvm.func @icmp_or_xor_4_1(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64, %arg6: i64, %arg7: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.xor %arg4, %arg5 : i64 + %5 = llvm.xor %arg6, %arg7 : i64 + %6 = llvm.or %4, %5 : i64 + %7 = llvm.or %3, %6 : i64 + %8 = llvm.icmp "eq" %7, %0 : i64 + llvm.return %8 : i1 + } + llvm.func @icmp_or_xor_4_2(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64, %arg6: i64, %arg7: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.xor %arg4, %arg5 : i64 + %5 = llvm.xor %arg6, %arg7 : i64 + %6 = llvm.or %4, %5 : i64 + %7 = llvm.or %6, %3 : i64 + %8 = llvm.icmp "eq" %7, %0 : i64 + llvm.return %8 : i1 + } + llvm.func @icmp_or_sub_2_eq(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.icmp "eq" %3, %0 : i64 + llvm.return %4 : i1 + } + llvm.func @icmp_or_sub_2_ne(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.icmp "ne" %3, %0 : i64 + llvm.return %4 : i1 + } + llvm.func @icmp_or_sub_2_eq_fail(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.sub %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.icmp "eq" %3, %0 : i64 + llvm.return %4 : i1 + } + llvm.func @icmp_or_sub_2_ne_fail(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.sub %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.icmp "ne" %3, %0 : i64 + llvm.return %4 : i1 + } + llvm.func @icmp_or_sub_2_3_fail(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.sub %arg0, %arg1 : i64 + %3 = llvm.sub %arg2, %arg3 : i64 + %4 = llvm.or %2, %3 : i64 + %5 = llvm.icmp "eq" %4, %0 : i64 + %6 = llvm.icmp "eq" %2, %1 : i64 + %7 = llvm.or %5, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @icmp_or_sub_2_4_fail(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.sub %arg0, %arg1 : i64 + %3 = llvm.sub %arg2, %arg3 : i64 + %4 = llvm.or %2, %3 : i64 + %5 = llvm.icmp "eq" %4, %0 : i64 + %6 = llvm.icmp "eq" %3, %1 : i64 + %7 = llvm.or %5, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @icmp_or_sub_3_1(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.sub %arg4, %arg5 : i64 + %5 = llvm.or %3, %4 : i64 + %6 = llvm.icmp "eq" %5, %0 : i64 + llvm.return %6 : i1 + } + llvm.func @icmp_or_sub_3_2_fail(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.and %1, %2 : i64 + %4 = llvm.sub %arg4, %arg5 : i64 + %5 = llvm.or %3, %4 : i64 + %6 = llvm.icmp "eq" %5, %0 : i64 + llvm.return %6 : i1 + } + llvm.func @icmp_or_sub_3_3(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.sub %arg4, %arg5 : i64 + %5 = llvm.or %4, %3 : i64 + %6 = llvm.icmp "eq" %5, %0 : i64 + llvm.return %6 : i1 + } + llvm.func @icmp_or_sub_3_4_fail(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.and %1, %2 : i64 + %4 = llvm.sub %arg4, %arg5 : i64 + %5 = llvm.or %4, %3 : i64 + %6 = llvm.icmp "eq" %5, %0 : i64 + llvm.return %6 : i1 + } + llvm.func @icmp_or_sub_4_1(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64, %arg6: i64, %arg7: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.sub %arg4, %arg5 : i64 + %5 = llvm.sub %arg6, %arg7 : i64 + %6 = llvm.or %4, %5 : i64 + %7 = llvm.or %3, %6 : i64 + %8 = llvm.icmp "eq" %7, %0 : i64 + llvm.return %8 : i1 + } + llvm.func @icmp_or_sub_4_2(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64, %arg6: i64, %arg7: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.sub %arg4, %arg5 : i64 + %5 = llvm.sub %arg6, %arg7 : i64 + %6 = llvm.or %4, %5 : i64 + %7 = llvm.or %6, %3 : i64 + %8 = llvm.icmp "eq" %7, %0 : i64 + llvm.return %8 : i1 + } + llvm.func @icmp_or_xor_with_sub_2_eq(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.icmp "eq" %3, %0 : i64 + llvm.return %4 : i1 + } + llvm.func @icmp_or_xor_with_sub_2_ne(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.icmp "ne" %3, %0 : i64 + llvm.return %4 : i1 + } + llvm.func @icmp_or_xor_with_sub_3_1(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.sub %arg4, %arg5 : i64 + %5 = llvm.or %3, %4 : i64 + %6 = llvm.icmp "eq" %5, %0 : i64 + llvm.return %6 : i1 + } + llvm.func @icmp_or_xor_with_sub_3_2(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.xor %arg4, %arg5 : i64 + %5 = llvm.or %3, %4 : i64 + %6 = llvm.icmp "eq" %5, %0 : i64 + llvm.return %6 : i1 + } + llvm.func @icmp_or_xor_with_sub_3_3(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.xor %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.sub %arg4, %arg5 : i64 + %5 = llvm.or %3, %4 : i64 + %6 = llvm.icmp "eq" %5, %0 : i64 + llvm.return %6 : i1 + } + llvm.func @icmp_or_xor_with_sub_3_4(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.xor %arg4, %arg5 : i64 + %5 = llvm.or %3, %4 : i64 + %6 = llvm.icmp "eq" %5, %0 : i64 + llvm.return %6 : i1 + } + llvm.func @icmp_or_xor_with_sub_3_5(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %arg0, %arg1 : i64 + %2 = llvm.xor %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.sub %arg4, %arg5 : i64 + %5 = llvm.or %3, %4 : i64 + %6 = llvm.icmp "eq" %5, %0 : i64 + llvm.return %6 : i1 + } + llvm.func @icmp_or_xor_with_sub_3_6(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %arg0, %arg1 : i64 + %2 = llvm.sub %arg2, %arg3 : i64 + %3 = llvm.or %1, %2 : i64 + %4 = llvm.xor %arg4, %arg5 : i64 + %5 = llvm.or %3, %4 : i64 + %6 = llvm.icmp "eq" %5, %0 : i64 + llvm.return %6 : i1 + } + llvm.func @or_disjoint_with_constants(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(19 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @or_disjoint_with_constants2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(71 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.call @use(%2) : (i8) -> () + llvm.return %3 : i1 + } + llvm.func @or_disjoint_with_constants_fail_missing_const1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(19 : i8) : i8 + %1 = llvm.or %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @or_disjoint_with_constants_fail_missing_const2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(19 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.icmp "eq" %1, %arg1 : i8 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-power2-and-icmp-shifted-mask.ll.mlir b/test/LLVMDialect/InstCombine/icmp-power2-and-icmp-shifted-mask.ll.mlir new file mode 100644 index 000000000..529b943ca --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-power2-and-icmp-shifted-mask.ll.mlir @@ -0,0 +1,440 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @icmp_power2_and_icmp_shifted_mask_2147483648_1610612736(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(1610612736 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_swapped_2147483648_1610612736(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(1610612736 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_2147483648_2147483647(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_swapped_2147483648_2147483647(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_2147483648_805306368(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1073741824 : i32) : i32 + %1 = llvm.mlir.constant(805306368 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_swapped_2147483648_805306368(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1073741824 : i32) : i32 + %1 = llvm.mlir.constant(805306368 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_1073741824_1073741823(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1073741824 : i32) : i32 + %1 = llvm.mlir.constant(1073741823 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_swapped_1073741824_1073741823(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1073741824 : i32) : i32 + %1 = llvm.mlir.constant(1073741823 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_8_7(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_swapped_8_7(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_8_6(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_swapped_8_6(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_8_5_gap_in_mask_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_swapped_8_5_gap_in_mask_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_8_3_gap_between_masks_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_swapped_8_3_gap_between_masks_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_256_239_gap_in_mask_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(256 : i32) : i32 + %1 = llvm.mlir.constant(239 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_swapped_256_239_gap_in_mask_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(256 : i32) : i32 + %1 = llvm.mlir.constant(239 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_8_112_mask_to_left_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(112 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_swapped_8_112_mask_to_left_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(112 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_8_56_mask_overlap_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(56 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_swapped_8_56_mask_overlap_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(56 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_8_24_mask_overlap_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_swapped_8_24_mask_overlap_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_8_12_mask_overlap_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_swapped_8_12_mask_overlap_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_2147483648_2147483647(%arg0: vector<1xi32>) -> vector<1xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<1xi32>) : vector<1xi32> + %1 = llvm.mlir.constant(dense<2147483647> : vector<1xi32>) : vector<1xi32> + %2 = llvm.icmp "ult" %arg0, %0 : vector<1xi32> + %3 = llvm.and %arg0, %1 : vector<1xi32> + %4 = llvm.icmp "ne" %3, %1 : vector<1xi32> + %5 = llvm.and %2, %4 : vector<1xi1> + llvm.return %5 : vector<1xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_swapped_2147483648_2147483647(%arg0: vector<1xi32>) -> vector<1xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<1xi32>) : vector<1xi32> + %1 = llvm.mlir.constant(dense<2147483647> : vector<1xi32>) : vector<1xi32> + %2 = llvm.icmp "ult" %arg0, %0 : vector<1xi32> + %3 = llvm.and %arg0, %1 : vector<1xi32> + %4 = llvm.icmp "ne" %3, %1 : vector<1xi32> + %5 = llvm.and %4, %2 : vector<1xi1> + llvm.return %5 : vector<1xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_2147483648_1610612736_2147483647(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[1610612736, 2147483647]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg0, %1 : vector<2xi32> + %4 = llvm.icmp "ne" %3, %1 : vector<2xi32> + %5 = llvm.and %2, %4 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_swapped_2147483648_1610612736_2147483647(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[1610612736, 2147483647]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg0, %1 : vector<2xi32> + %4 = llvm.icmp "ne" %3, %1 : vector<2xi32> + %5 = llvm.and %4, %2 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_splat_poison_2147483648_1610612736_2147483647(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<[1610612736, 2147483647]> : vector<2xi32>) : vector<2xi32> + %8 = llvm.icmp "ult" %arg0, %6 : vector<2xi32> + %9 = llvm.and %arg0, %7 : vector<2xi32> + %10 = llvm.icmp "ne" %9, %7 : vector<2xi32> + %11 = llvm.and %8, %10 : vector<2xi1> + llvm.return %11 : vector<2xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_swapped_splat_poison_2147483648_1610612736_2147483647(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<[1610612736, 2147483647]> : vector<2xi32>) : vector<2xi32> + %8 = llvm.icmp "ult" %arg0, %6 : vector<2xi32> + %9 = llvm.and %arg0, %7 : vector<2xi32> + %10 = llvm.icmp "ne" %9, %7 : vector<2xi32> + %11 = llvm.and %10, %8 : vector<2xi1> + llvm.return %11 : vector<2xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_splat_undef_2147483648_1610612736_2147483647(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<[1610612736, 2147483647]> : vector<2xi32>) : vector<2xi32> + %8 = llvm.icmp "ult" %arg0, %6 : vector<2xi32> + %9 = llvm.and %arg0, %7 : vector<2xi32> + %10 = llvm.icmp "ne" %9, %7 : vector<2xi32> + %11 = llvm.and %8, %10 : vector<2xi1> + llvm.return %11 : vector<2xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_swapped_splat_undef_2147483648_1610612736_2147483647(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<[1610612736, 2147483647]> : vector<2xi32>) : vector<2xi32> + %8 = llvm.icmp "ult" %arg0, %6 : vector<2xi32> + %9 = llvm.and %arg0, %7 : vector<2xi32> + %10 = llvm.icmp "ne" %9, %7 : vector<2xi32> + %11 = llvm.and %10, %8 : vector<2xi1> + llvm.return %11 : vector<2xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_128_others(%arg0: vector<7xi8>) -> vector<7xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<7xi8>) : vector<7xi8> + %1 = llvm.mlir.constant(dense<[127, 126, 124, 120, 112, 96, 64]> : vector<7xi8>) : vector<7xi8> + %2 = llvm.icmp "ult" %arg0, %0 : vector<7xi8> + %3 = llvm.and %arg0, %1 : vector<7xi8> + %4 = llvm.icmp "ne" %3, %1 : vector<7xi8> + %5 = llvm.and %2, %4 : vector<7xi1> + llvm.return %5 : vector<7xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_swapped_128_others(%arg0: vector<7xi8>) -> vector<7xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<7xi8>) : vector<7xi8> + %1 = llvm.mlir.constant(dense<[127, 126, 124, 120, 112, 96, 64]> : vector<7xi8>) : vector<7xi8> + %2 = llvm.icmp "ult" %arg0, %0 : vector<7xi8> + %3 = llvm.and %arg0, %1 : vector<7xi8> + %4 = llvm.icmp "ne" %3, %1 : vector<7xi8> + %5 = llvm.and %4, %2 : vector<7xi1> + llvm.return %5 : vector<7xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_64_others(%arg0: vector<6xi8>) -> vector<6xi1> { + %0 = llvm.mlir.constant(dense<64> : vector<6xi8>) : vector<6xi8> + %1 = llvm.mlir.constant(dense<[63, 62, 60, 56, 48, 32]> : vector<6xi8>) : vector<6xi8> + %2 = llvm.icmp "ult" %arg0, %0 : vector<6xi8> + %3 = llvm.and %arg0, %1 : vector<6xi8> + %4 = llvm.icmp "ne" %3, %1 : vector<6xi8> + %5 = llvm.and %2, %4 : vector<6xi1> + llvm.return %5 : vector<6xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_swapped_64_others(%arg0: vector<6xi8>) -> vector<6xi1> { + %0 = llvm.mlir.constant(dense<64> : vector<6xi8>) : vector<6xi8> + %1 = llvm.mlir.constant(dense<[63, 62, 60, 56, 48, 32]> : vector<6xi8>) : vector<6xi8> + %2 = llvm.icmp "ult" %arg0, %0 : vector<6xi8> + %3 = llvm.and %arg0, %1 : vector<6xi8> + %4 = llvm.icmp "ne" %3, %1 : vector<6xi8> + %5 = llvm.and %2, %4 : vector<6xi1> + llvm.return %5 : vector<6xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_2147483648_2147482647_gap_in_mask_fail(%arg0: vector<1xi32>) -> vector<1xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<1xi32>) : vector<1xi32> + %1 = llvm.mlir.constant(dense<2147482647> : vector<1xi32>) : vector<1xi32> + %2 = llvm.icmp "ult" %arg0, %0 : vector<1xi32> + %3 = llvm.and %arg0, %1 : vector<1xi32> + %4 = llvm.icmp "ne" %3, %1 : vector<1xi32> + %5 = llvm.and %2, %4 : vector<1xi1> + llvm.return %5 : vector<1xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_swapped_2147483648_2147482647_gap_in_mask_fail(%arg0: vector<1xi32>) -> vector<1xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<1xi32>) : vector<1xi32> + %1 = llvm.mlir.constant(dense<2147482647> : vector<1xi32>) : vector<1xi32> + %2 = llvm.icmp "ult" %arg0, %0 : vector<1xi32> + %3 = llvm.and %arg0, %1 : vector<1xi32> + %4 = llvm.icmp "ne" %3, %1 : vector<1xi32> + %5 = llvm.and %4, %2 : vector<1xi1> + llvm.return %5 : vector<1xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_2147483648_1073741823_gap_between_masks_fail(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[1610612736, 1073741823]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg0, %1 : vector<2xi32> + %4 = llvm.icmp "ne" %3, %1 : vector<2xi32> + %5 = llvm.and %2, %4 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_swapped_2147483648_1073741823_gap_between_masks_fail(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[1610612736, 1073741823]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg0, %1 : vector<2xi32> + %4 = llvm.icmp "ne" %3, %1 : vector<2xi32> + %5 = llvm.and %4, %2 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_128_1_of_7_fail(%arg0: vector<7xi8>) -> vector<7xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<7xi8>) : vector<7xi8> + %1 = llvm.mlir.constant(dense<[125, 122, 116, 104, 80, 32, 64]> : vector<7xi8>) : vector<7xi8> + %2 = llvm.icmp "ult" %arg0, %0 : vector<7xi8> + %3 = llvm.and %arg0, %1 : vector<7xi8> + %4 = llvm.icmp "ne" %3, %1 : vector<7xi8> + %5 = llvm.and %2, %4 : vector<7xi1> + llvm.return %5 : vector<7xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_swapped_128_1_of_7_fail(%arg0: vector<7xi8>) -> vector<7xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<7xi8>) : vector<7xi8> + %1 = llvm.mlir.constant(dense<[125, 122, 116, 104, 80, 32, 64]> : vector<7xi8>) : vector<7xi8> + %2 = llvm.icmp "ult" %arg0, %0 : vector<7xi8> + %3 = llvm.and %arg0, %1 : vector<7xi8> + %4 = llvm.icmp "ne" %3, %1 : vector<7xi8> + %5 = llvm.and %4, %2 : vector<7xi1> + llvm.return %5 : vector<7xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_128_0_of_6_fail(%arg0: vector<6xi8>) -> vector<6xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<6xi8>) : vector<6xi8> + %1 = llvm.mlir.constant(dense<[125, 122, 116, 104, 80, 32]> : vector<6xi8>) : vector<6xi8> + %2 = llvm.icmp "ult" %arg0, %0 : vector<6xi8> + %3 = llvm.and %arg0, %1 : vector<6xi8> + %4 = llvm.icmp "ne" %3, %1 : vector<6xi8> + %5 = llvm.and %2, %4 : vector<6xi1> + llvm.return %5 : vector<6xi1> + } + llvm.func @icmp_power2_and_icmp_shifted_mask_vector_swapped_128_0_of_6_fail(%arg0: vector<6xi8>) -> vector<6xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<6xi8>) : vector<6xi8> + %1 = llvm.mlir.constant(dense<[125, 122, 116, 104, 80, 32]> : vector<6xi8>) : vector<6xi8> + %2 = llvm.icmp "ult" %arg0, %0 : vector<6xi8> + %3 = llvm.and %arg0, %1 : vector<6xi8> + %4 = llvm.icmp "ne" %3, %1 : vector<6xi8> + %5 = llvm.and %4, %2 : vector<6xi1> + llvm.return %5 : vector<6xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-range.ll.mlir b/test/LLVMDialect/InstCombine/icmp-range.ll.mlir index e48532392..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/icmp-range.ll.mlir +++ b/test/LLVMDialect/InstCombine/icmp-range.ll.mlir @@ -1,346 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use_vec", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_nonzero", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_nonzero2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_nonzero3", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i8 - %2 = "llvm.icmp"(%1, %0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_nonzero4", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i8 - %2 = "llvm.icmp"(%1, %0) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_nonzero5", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i8 - %2 = "llvm.icmp"(%1, %0) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_nonzero6", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_not_in_range", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_in_range", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_range_sgt_constant", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_range_slt_constant", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_multi_range1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_multi_range2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %1 = "llvm.load"(%arg1) : (!llvm.ptr) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_two_ranges", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %1 = "llvm.load"(%arg1) : (!llvm.ptr) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_two_ranges2", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %1 = "llvm.load"(%arg1) : (!llvm.ptr) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 8 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_two_ranges3", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i1) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ugt_zext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi1>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.mul"(%arg1, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %1 = "llvm.zext"(%arg0) : (vector<2xi1>) -> vector<2xi8> - %2 = "llvm.icmp"(%0, %1) {predicate = 6 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ult_zext", type = !llvm.func (vector<2xi1>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i1) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "uge_zext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg1, %arg1) : (i8, i8) -> i8 - %1 = "llvm.zext"(%arg0) : (i1) -> i8 - %2 = "llvm.icmp"(%0, %1) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ule_zext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i1) -> i8 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ugt_zext_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i2, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i2) -> i8 - %1 = "llvm.icmp"(%arg1, %0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ult_zext_not_i1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i1) -> i8 - %1 = "llvm.sub"(%arg1, %arg2) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sub_ult_zext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg1, %arg1) : (i8, i8) -> i8 - %1 = "llvm.zext"(%arg0) : (i1) -> i16 - %2 = "llvm.zext"(%0) : (i8) -> i16 - %3 = "llvm.icmp"(%2, %1) {predicate = 6 : i64} : (i16, i16) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_ult_zext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i4): // no predecessors - %0 = "llvm.zext"(%arg0) : (i1) -> i8 - %1 = "llvm.zext"(%arg1) : (i4) -> i8 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%0, %1) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_ugt_zext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i2, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i2) -> i8 - %1 = "llvm.sub"(%arg1, %arg2) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sub_ult_zext_not_i1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i1) -> i8 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.sub"(%arg1, %arg2) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sub_ult_zext_use1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi1>, %arg1: vector<2xi8>, %arg2: vector<2xi8>): // no predecessors - %0 = "llvm.zext"(%arg0) : (vector<2xi1>) -> vector<2xi8> - %1 = "llvm.sub"(%arg1, %arg2) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.call"(%1) {callee = @use_vec, fastmathFlags = #llvm.fastmath<>} : (vector<2xi8>) -> () - %2 = "llvm.icmp"(%0, %1) {predicate = 8 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "zext_ugt_sub_use2", type = !llvm.func (vector<2xi1>, vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i1) -> i8 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.sub"(%arg1, %arg2) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sub_ult_zext_use3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i1) -> i8 - %1 = "llvm.sub"(%arg1, %arg2) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %0) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sub_ule_zext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.and"(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %2 = "llvm.sub"(%arg1, %arg2) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %3 = "llvm.icmp"(%2, %1) {predicate = 6 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sub_ult_and", type = !llvm.func (vector<2xi8>, vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %1 = "llvm.and"(%arg0, %0) : (i8, i8) -> i8 - %2 = "llvm.sub"(%arg1, %arg2) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%1, %2) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "and_ugt_sub", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i1) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "uge_sext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi1>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.mul"(%arg1, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %1 = "llvm.sext"(%arg0) : (vector<2xi1>) -> vector<2xi8> - %2 = "llvm.icmp"(%0, %1) {predicate = 7 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ule_sext", type = !llvm.func (vector<2xi1>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i1) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ugt_sext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg1, %arg1) : (i8, i8) -> i8 - %1 = "llvm.sext"(%arg0) : (i1) -> i8 - %2 = "llvm.icmp"(%0, %1) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ult_sext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i1) -> i8 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "uge_sext_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i2, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i2) -> i8 - %1 = "llvm.icmp"(%arg1, %0) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ule_sext_not_i1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i1) -> i8 - %1 = "llvm.sub"(%arg1, %arg2) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %0) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sub_ule_sext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg1, %arg1) : (i8, i8) -> i8 - %1 = "llvm.sext"(%arg0) : (i1) -> i16 - %2 = "llvm.sext"(%0) : (i8) -> i16 - %3 = "llvm.icmp"(%2, %1) {predicate = 7 : i64} : (i16, i16) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_ule_sext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i4): // no predecessors - %0 = "llvm.sext"(%arg0) : (i1) -> i8 - %1 = "llvm.sext"(%arg1) : (i4) -> i8 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%0, %1) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_uge_sext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i2, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i2) -> i8 - %1 = "llvm.sub"(%arg1, %arg2) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %0) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sub_ule_sext_not_i1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i1) -> i8 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.sub"(%arg1, %arg2) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %0) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sub_ule_sext_use1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi1>, %arg1: vector<2xi8>, %arg2: vector<2xi8>): // no predecessors - %0 = "llvm.sext"(%arg0) : (vector<2xi1>) -> vector<2xi8> - %1 = "llvm.sub"(%arg1, %arg2) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.call"(%1) {callee = @use_vec, fastmathFlags = #llvm.fastmath<>} : (vector<2xi8>) -> () - %2 = "llvm.icmp"(%0, %1) {predicate = 9 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sext_uge_sub_use2", type = !llvm.func (vector<2xi1>, vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i1) -> i8 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.sub"(%arg1, %arg2) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %0) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sub_ule_sext_use3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.sext"(%arg0) : (i1) -> i8 - %1 = "llvm.sub"(%arg1, %arg2) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sub_ult_sext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<7> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.ashr"(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %2 = "llvm.sub"(%arg1, %arg2) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %3 = "llvm.icmp"(%2, %1) {predicate = 7 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "sub_ule_ashr", type = !llvm.func (vector<2xi8>, vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %1 = "llvm.ashr"(%arg0, %0) : (i8, i8) -> i8 - %2 = "llvm.sub"(%arg1, %arg2) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%1, %2) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_uge_sub", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/icmp-rotate.ll.mlir b/test/LLVMDialect/InstCombine/icmp-rotate.ll.mlir new file mode 100644 index 000000000..65ee496fc --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-rotate.ll.mlir @@ -0,0 +1,138 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @rol_eq(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.intr.fshl(%arg0, %arg0, %arg2) : (i8, i8, i8) -> i8 + %1 = llvm.intr.fshl(%arg1, %arg1, %arg2) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "eq" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @rol_ne(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.intr.fshl(%arg0, %arg0, %arg2) : (i8, i8, i8) -> i8 + %1 = llvm.intr.fshl(%arg1, %arg1, %arg2) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "ne" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @ror_eq(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.intr.fshr(%arg0, %arg0, %arg2) : (i8, i8, i8) -> i8 + %1 = llvm.intr.fshr(%arg1, %arg1, %arg2) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "eq" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @ror_ne(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.intr.fshr(%arg0, %arg0, %arg2) : (i8, i8, i8) -> i8 + %1 = llvm.intr.fshr(%arg1, %arg1, %arg2) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "ne" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @rol_eq_use(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.intr.fshl(%arg0, %arg0, %arg2) : (i8, i8, i8) -> i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.intr.fshl(%arg1, %arg1, %arg2) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "eq" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @rol_eq_uses(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.intr.fshl(%arg0, %arg0, %arg2) : (i8, i8, i8) -> i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.intr.fshl(%arg1, %arg1, %arg2) : (i8, i8, i8) -> i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.icmp "eq" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @rol_eq_vec(%arg0: vector<2xi5>, %arg1: vector<2xi5>, %arg2: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.intr.fshl(%arg0, %arg0, %arg2) : (vector<2xi5>, vector<2xi5>, vector<2xi5>) -> vector<2xi5> + %1 = llvm.intr.fshl(%arg1, %arg1, %arg2) : (vector<2xi5>, vector<2xi5>, vector<2xi5>) -> vector<2xi5> + %2 = llvm.icmp "eq" %0, %1 : vector<2xi5> + llvm.return %2 : vector<2xi1> + } + llvm.func @ror_eq_vec(%arg0: vector<2xi5>, %arg1: vector<2xi5>, %arg2: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.intr.fshr(%arg0, %arg0, %arg2) : (vector<2xi5>, vector<2xi5>, vector<2xi5>) -> vector<2xi5> + %1 = llvm.intr.fshr(%arg1, %arg1, %arg2) : (vector<2xi5>, vector<2xi5>, vector<2xi5>) -> vector<2xi5> + %2 = llvm.icmp "eq" %0, %1 : vector<2xi5> + llvm.return %2 : vector<2xi1> + } + llvm.func @rol_eq_cst(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.intr.fshl(%arg0, %arg0, %0) : (i8, i8, i8) -> i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @rol_ne_cst(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.intr.fshl(%arg0, %arg0, %0) : (i8, i8, i8) -> i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @rol_eq_cst_use(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.intr.fshl(%arg0, %arg0, %0) : (i8, i8, i8) -> i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ror_eq_cst(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.intr.fshr(%arg0, %arg0, %0) : (i8, i8, i8) -> i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ror_ne_cst(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.intr.fshr(%arg0, %arg0, %0) : (i8, i8, i8) -> i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @rol_eq_cst_vec(%arg0: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.mlir.constant(3 : i5) : i5 + %1 = llvm.mlir.constant(dense<3> : vector<2xi5>) : vector<2xi5> + %2 = llvm.mlir.constant(2 : i5) : i5 + %3 = llvm.mlir.constant(dense<2> : vector<2xi5>) : vector<2xi5> + %4 = llvm.intr.fshl(%arg0, %arg0, %1) : (vector<2xi5>, vector<2xi5>, vector<2xi5>) -> vector<2xi5> + %5 = llvm.icmp "eq" %4, %3 : vector<2xi5> + llvm.return %5 : vector<2xi1> + } + llvm.func @rol_eq_cst_undef(%arg0: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.mlir.constant(3 : i5) : i5 + %1 = llvm.mlir.constant(dense<3> : vector<2xi5>) : vector<2xi5> + %2 = llvm.mlir.undef : i5 + %3 = llvm.mlir.constant(2 : i5) : i5 + %4 = llvm.mlir.undef : vector<2xi5> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi5> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi5> + %9 = llvm.intr.fshl(%arg0, %arg0, %1) : (vector<2xi5>, vector<2xi5>, vector<2xi5>) -> vector<2xi5> + %10 = llvm.icmp "eq" %9, %8 : vector<2xi5> + llvm.return %10 : vector<2xi1> + } + llvm.func @no_rotate(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.intr.fshl(%arg0, %arg1, %arg2) : (i8, i8, i8) -> i8 + %1 = llvm.intr.fshl(%arg1, %arg1, %arg2) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "eq" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @wrong_pred(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.intr.fshl(%arg0, %arg0, %arg2) : (i8, i8, i8) -> i8 + %1 = llvm.intr.fshl(%arg1, %arg1, %arg2) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "ult" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @amounts_mismatch(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i1 { + %0 = llvm.intr.fshl(%arg0, %arg0, %arg2) : (i8, i8, i8) -> i8 + %1 = llvm.intr.fshl(%arg1, %arg1, %arg3) : (i8, i8, i8) -> i8 + %2 = llvm.icmp "eq" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @wrong_pred2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(27 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.intr.fshr(%arg0, %arg0, %0) : (i8, i8, i8) -> i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-select-implies-common-op.ll.mlir b/test/LLVMDialect/InstCombine/icmp-select-implies-common-op.ll.mlir new file mode 100644 index 000000000..d79fae37b --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-select-implies-common-op.ll.mlir @@ -0,0 +1,53 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @sgt_3_impliesF_eq_2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.icmp "sgt" %arg0, %0 : i8 + %3 = llvm.select %2, %1, %arg1 : i1, i8 + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @sgt_3_impliesT_sgt_2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.icmp "sgt" %arg0, %0 : i8 + %3 = llvm.select %2, %1, %arg1 : i1, i8 + %4 = llvm.icmp "sgt" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @sgt_x_impliesF_eq_smin_todo(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.icmp "sgt" %arg0, %arg2 : i8 + %2 = llvm.select %1, %0, %arg1 : i1, i8 + %3 = llvm.icmp "eq" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @slt_x_impliesT_ne_smin_todo(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %arg2 : i8 + %2 = llvm.select %1, %0, %arg1 : i1, i8 + %3 = llvm.icmp "ne" %arg0, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_x_impliesT_eq_umax_todo(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ugt" %arg2, %arg0 : i8 + %2 = llvm.select %1, %0, %arg1 : i1, i8 + %3 = llvm.icmp "ne" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_1_impliesF_eq_1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.icmp "ult" %arg0, %0 : i8 + %2 = llvm.select %1, %0, %arg1 : i1, i8 + %3 = llvm.icmp "eq" %arg0, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @ugt_x_impliesF_eq_umin_todo(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ugt" %arg2, %arg0 : i8 + %2 = llvm.select %1, %0, %arg1 : i1, i8 + %3 = llvm.icmp "eq" %arg0, %2 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-select.ll.mlir b/test/LLVMDialect/InstCombine/icmp-select.ll.mlir new file mode 100644 index 000000000..3b45e1384 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-select.ll.mlir @@ -0,0 +1,383 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @use.i1(i1) + llvm.func @icmp_select_const(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.select %1, %0, %arg1 : i1, i8 + %3 = llvm.icmp "eq" %2, %0 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_select_var(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.select %1, %arg2, %arg1 : i1, i8 + %3 = llvm.icmp "eq" %2, %arg2 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_select_var_commuted(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.udiv %0, %arg2 : i8 + %3 = llvm.icmp "eq" %arg0, %1 : i8 + %4 = llvm.select %3, %2, %arg1 : i1, i8 + %5 = llvm.icmp "eq" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @icmp_select_var_select(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.select %arg2, %arg0, %arg1 : i1, i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.select %2, %1, %arg1 : i1, i8 + %4 = llvm.icmp "eq" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @icmp_select_var_both_fold(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.or %arg2, %0 : i8 + %4 = llvm.icmp "eq" %arg0, %1 : i8 + %5 = llvm.select %4, %3, %2 : i1, i8 + %6 = llvm.icmp "eq" %5, %3 : i8 + llvm.return %6 : i1 + } + llvm.func @icmp_select_var_extra_use(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.select %1, %arg2, %arg1 : i1, i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %arg2 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_select_var_both_fold_extra_use(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.or %arg2, %0 : i8 + %4 = llvm.icmp "eq" %arg0, %1 : i8 + %5 = llvm.select %4, %3, %2 : i1, i8 + llvm.call @use(%5) : (i8) -> () + %6 = llvm.icmp "eq" %5, %3 : i8 + llvm.return %6 : i1 + } + llvm.func @icmp_select_var_pred_ne(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.select %1, %arg2, %arg1 : i1, i8 + %3 = llvm.icmp "ne" %2, %arg2 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_select_var_pred_ult(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg2, %0 overflow : i8 + %3 = llvm.icmp "eq" %arg0, %1 : i8 + %4 = llvm.select %3, %arg2, %arg1 : i1, i8 + %5 = llvm.icmp "ult" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @icmp_select_var_pred_uge(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg2, %0 overflow : i8 + %3 = llvm.icmp "eq" %arg0, %1 : i8 + %4 = llvm.select %3, %arg2, %arg1 : i1, i8 + %5 = llvm.icmp "uge" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @icmp_select_var_pred_uge_commuted(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg2, %0 overflow : i8 + %3 = llvm.icmp "eq" %arg0, %1 : i8 + %4 = llvm.select %3, %arg2, %arg1 : i1, i8 + %5 = llvm.icmp "uge" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @icmp_select_implied_cond(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.select %1, %0, %arg1 : i1, i8 + %3 = llvm.icmp "eq" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_select_implied_cond_ne(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.select %1, %0, %arg1 : i1, i8 + %3 = llvm.icmp "ne" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_select_implied_cond_swapped_select(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %0 : i8 + %2 = llvm.select %1, %arg1, %0 : i1, i8 + %3 = llvm.icmp "eq" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_select_implied_cond_swapped_select_with_inv_cond(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "ne" %arg0, %0 : i8 + llvm.call @use.i1(%1) : (i1) -> () + %2 = llvm.select %1, %arg1, %0 : i1, i8 + %3 = llvm.icmp "eq" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_select_implied_cond_relational(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.icmp "ugt" %arg0, %0 : i8 + %2 = llvm.select %1, %0, %arg1 : i1, i8 + %3 = llvm.icmp "ult" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_select_implied_cond_relational_off_by_one(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + llvm.call @use.i1(%2) : (i1) -> () + %3 = llvm.select %2, %1, %arg1 : i1, i8 + %4 = llvm.icmp "ult" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @umin_seq_comparison(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.umin(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.select %2, %0, %1 : i1, i8 + %4 = llvm.icmp "eq" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @select_constants_and_icmp_eq0(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.select %arg0, %0, %1 : i1, i8 + %4 = llvm.select %arg1, %0, %1 : i1, i8 + %5 = llvm.and %3, %4 : i8 + %6 = llvm.icmp "eq" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @select_constants_and_icmp_eq0_uses(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.select %arg0, %0, %1 : i1, i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.select %arg1, %0, %1 : i1, i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.and %3, %4 : i8 + llvm.call @use(%5) : (i8) -> () + %6 = llvm.icmp "eq" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @select_constants_and_icmp_eq0_vec_splat(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(3 : i9) : i9 + %1 = llvm.mlir.constant(dense<3> : vector<2xi9>) : vector<2xi9> + %2 = llvm.mlir.constant(48 : i9) : i9 + %3 = llvm.mlir.constant(dense<48> : vector<2xi9>) : vector<2xi9> + %4 = llvm.mlir.constant(0 : i9) : i9 + %5 = llvm.mlir.constant(dense<0> : vector<2xi9>) : vector<2xi9> + %6 = llvm.select %arg0, %1, %3 : vector<2xi1>, vector<2xi9> + %7 = llvm.select %arg1, %1, %3 : vector<2xi1>, vector<2xi9> + %8 = llvm.and %6, %7 : vector<2xi9> + %9 = llvm.icmp "eq" %8, %5 : vector<2xi9> + llvm.return %9 : vector<2xi1> + } + llvm.func @select_constants_and_icmp_eq0_common_bit(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.select %arg0, %0, %1 : i1, i8 + %4 = llvm.select %arg1, %0, %1 : i1, i8 + %5 = llvm.and %3, %4 : i8 + %6 = llvm.icmp "eq" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @select_constants_and_icmp_eq0_no_common_op1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(24 : i8) : i8 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.select %arg0, %0, %1 : i1, i8 + %5 = llvm.select %arg1, %2, %1 : i1, i8 + %6 = llvm.and %4, %5 : i8 + %7 = llvm.icmp "eq" %6, %3 : i8 + llvm.return %7 : i1 + } + llvm.func @select_constants_and_icmp_eq0_no_common_op2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.select %arg0, %0, %1 : i1, i8 + %5 = llvm.select %arg1, %0, %2 : i1, i8 + %6 = llvm.and %4, %5 : i8 + %7 = llvm.icmp "eq" %6, %3 : i8 + llvm.return %7 : i1 + } + llvm.func @select_constants_and_icmp_eq0_zero_tval(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(12 : i8) : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i8 + %3 = llvm.select %arg1, %0, %1 : i1, i8 + %4 = llvm.and %2, %3 : i8 + %5 = llvm.icmp "eq" %4, %0 : i8 + llvm.return %5 : i1 + } + llvm.func @select_constants_and_icmp_eq0_zero_fval(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(12 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i8 + %3 = llvm.select %arg1, %0, %1 : i1, i8 + %4 = llvm.and %2, %3 : i8 + %5 = llvm.icmp "eq" %4, %1 : i8 + llvm.return %5 : i1 + } + llvm.func @select_constants_and_icmp_eq_tval(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i8 + %3 = llvm.select %arg1, %0, %1 : i1, i8 + %4 = llvm.and %2, %3 : i8 + %5 = llvm.icmp "eq" %4, %0 : i8 + llvm.return %5 : i1 + } + llvm.func @select_constants_and_icmp_eq_fval(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(12 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i8 + %3 = llvm.select %arg1, %0, %1 : i1, i8 + %4 = llvm.and %2, %3 : i8 + %5 = llvm.icmp "eq" %4, %1 : i8 + llvm.return %5 : i1 + } + llvm.func @select_constants_and_icmp_ne0(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.select %arg0, %0, %1 : i1, i8 + %4 = llvm.select %arg1, %0, %1 : i1, i8 + %5 = llvm.and %3, %4 : i8 + %6 = llvm.icmp "ne" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @select_constants_and_icmp_ne0_uses(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.select %arg0, %0, %1 : i1, i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.select %arg1, %0, %1 : i1, i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.and %3, %4 : i8 + %6 = llvm.icmp "ne" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @select_constants_and_icmp_ne0_all_uses(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.select %arg0, %0, %1 : i1, i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.select %arg1, %0, %1 : i1, i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.and %3, %4 : i8 + llvm.call @use(%5) : (i8) -> () + %6 = llvm.icmp "ne" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @select_constants_and_icmp_ne0_vec_splat(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(3 : i9) : i9 + %1 = llvm.mlir.constant(dense<3> : vector<2xi9>) : vector<2xi9> + %2 = llvm.mlir.constant(48 : i9) : i9 + %3 = llvm.mlir.constant(dense<48> : vector<2xi9>) : vector<2xi9> + %4 = llvm.mlir.constant(0 : i9) : i9 + %5 = llvm.mlir.constant(dense<0> : vector<2xi9>) : vector<2xi9> + %6 = llvm.select %arg0, %1, %3 : vector<2xi1>, vector<2xi9> + %7 = llvm.select %arg1, %1, %3 : vector<2xi1>, vector<2xi9> + %8 = llvm.and %6, %7 : vector<2xi9> + %9 = llvm.icmp "ne" %8, %5 : vector<2xi9> + llvm.return %9 : vector<2xi1> + } + llvm.func @select_constants_and_icmp_ne0_common_bit(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.select %arg0, %0, %1 : i1, i8 + %4 = llvm.select %arg1, %0, %1 : i1, i8 + %5 = llvm.and %3, %4 : i8 + %6 = llvm.icmp "ne" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @select_constants_and_icmp_ne0_no_common_op1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(24 : i8) : i8 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.select %arg0, %0, %1 : i1, i8 + %5 = llvm.select %arg1, %2, %1 : i1, i8 + %6 = llvm.and %4, %5 : i8 + %7 = llvm.icmp "ne" %6, %3 : i8 + llvm.return %7 : i1 + } + llvm.func @select_constants_and_icmp_ne0_no_common_op2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.select %arg0, %0, %1 : i1, i8 + %5 = llvm.select %arg1, %0, %2 : i1, i8 + %6 = llvm.and %4, %5 : i8 + %7 = llvm.icmp "ne" %6, %3 : i8 + llvm.return %7 : i1 + } + llvm.func @select_constants_and_icmp_ne0_zero_tval(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(12 : i8) : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i8 + %3 = llvm.select %arg1, %0, %1 : i1, i8 + %4 = llvm.and %2, %3 : i8 + %5 = llvm.icmp "ne" %4, %0 : i8 + llvm.return %5 : i1 + } + llvm.func @select_constants_and_icmp_ne0_zero_fval(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(12 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i8 + %3 = llvm.select %arg1, %0, %1 : i1, i8 + %4 = llvm.and %2, %3 : i8 + %5 = llvm.icmp "ne" %4, %1 : i8 + llvm.return %5 : i1 + } + llvm.func @select_constants_and_icmp_ne_tval(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i8 + %3 = llvm.select %arg1, %0, %1 : i1, i8 + %4 = llvm.and %2, %3 : i8 + %5 = llvm.icmp "ne" %4, %0 : i8 + llvm.return %5 : i1 + } + llvm.func @select_constants_and_icmp_ne_fval(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(12 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i8 + %3 = llvm.select %arg1, %0, %1 : i1, i8 + %4 = llvm.and %2, %3 : i8 + %5 = llvm.icmp "ne" %4, %1 : i8 + llvm.return %5 : i1 + } + llvm.func @icmp_eq_select(%arg0: i1, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, i32 + %1 = llvm.select %arg0, %arg2, %arg1 : i1, i32 + %2 = llvm.icmp "eq" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @icmp_slt_select(%arg0: i1, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, i32 + %1 = llvm.select %arg0, %arg2, %arg1 : i1, i32 + %2 = llvm.icmp "slt" %0, %1 : i32 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-shl-1-overflow.ll.mlir b/test/LLVMDialect/InstCombine/icmp-shl-1-overflow.ll.mlir new file mode 100644 index 000000000..003d95e5d --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-shl-1-overflow.ll.mlir @@ -0,0 +1,117 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use16(i16) + llvm.func @usev4(vector<4xi4>) + llvm.func @icmp_shl_ugt_1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + %2 = llvm.icmp "ugt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @icmp_shl_ugt_2(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %0, %arg0 : vector<2xi32> + %3 = llvm.shl %2, %1 : vector<2xi32> + %4 = llvm.icmp "ugt" %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @icmp_shl_uge_1(%arg0: vector<3xi7>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i7) : i7 + %1 = llvm.mlir.constant(dense<1> : vector<3xi7>) : vector<3xi7> + %2 = llvm.shl %arg0, %1 : vector<3xi7> + %3 = llvm.icmp "uge" %2, %arg0 : vector<3xi7> + llvm.return %3 : vector<3xi1> + } + llvm.func @icmp_shl_uge_2(%arg0: i5) -> i1 { + %0 = llvm.mlir.constant(10 : i5) : i5 + %1 = llvm.mlir.constant(1 : i5) : i5 + %2 = llvm.add %0, %arg0 : i5 + %3 = llvm.shl %2, %1 : i5 + %4 = llvm.icmp "uge" %2, %3 : i5 + llvm.return %4 : i1 + } + llvm.func @icmp_shl_ult_1(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.shl %arg0, %0 : i16 + llvm.call @use16(%1) : (i16) -> () + %2 = llvm.icmp "ult" %1, %arg0 : i16 + llvm.return %2 : i1 + } + llvm.func @icmp_shl_ult_2(%arg0: vector<4xi4>) -> vector<4xi1> { + %0 = llvm.mlir.constant(-6 : i4) : i4 + %1 = llvm.mlir.constant(dense<-6> : vector<4xi4>) : vector<4xi4> + %2 = llvm.mlir.constant(1 : i4) : i4 + %3 = llvm.mlir.constant(dense<1> : vector<4xi4>) : vector<4xi4> + %4 = llvm.add %1, %arg0 : vector<4xi4> + %5 = llvm.shl %4, %3 : vector<4xi4> + llvm.call @usev4(%5) : (vector<4xi4>) -> () + %6 = llvm.icmp "ult" %4, %5 : vector<4xi4> + llvm.return %6 : vector<4xi1> + } + llvm.func @icmp_shl_ule_1(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.shl %arg0, %6 : vector<2xi8> + %8 = llvm.icmp "ule" %7, %arg0 : vector<2xi8> + llvm.return %8 : vector<2xi1> + } + llvm.func @icmp_shl_ule_2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.add %0, %arg0 : i8 + %3 = llvm.shl %2, %1 : i8 + %4 = llvm.icmp "ule" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @icmp_shl_eq_1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + %2 = llvm.icmp "eq" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @icmp_shl_eq_2(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.sdiv %0, %arg0 : vector<2xi8> + %3 = llvm.shl %2, %1 : vector<2xi8> + %4 = llvm.icmp "eq" %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @icmp_shl_ne_1(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %arg0, %0 : vector<2xi8> + %2 = llvm.icmp "ne" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @icmp_shl_ne_2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.sdiv %0, %arg0 : i8 + %3 = llvm.shl %2, %1 : i8 + %4 = llvm.icmp "ne" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @negative_test_signed_pred(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + %2 = llvm.icmp "slt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @negative_test_shl_more_than_1(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(2 : i16) : i16 + %1 = llvm.shl %arg0, %0 : i16 + %2 = llvm.icmp "ult" %1, %arg0 : i16 + llvm.return %2 : i1 + } + llvm.func @negative_test_compare_with_different_value(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.shl %arg0, %0 : i16 + %2 = llvm.icmp "ult" %1, %arg1 : i16 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-shl-nsw.ll.mlir b/test/LLVMDialect/InstCombine/icmp-shl-nsw.ll.mlir new file mode 100644 index 000000000..97b9e1dcb --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-shl-nsw.ll.mlir @@ -0,0 +1,218 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @icmp_shl_nsw_sgt(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(21 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %0 overflow : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_shl_nsw_sge0(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(21 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %0 overflow : i32 + %3 = llvm.icmp "sge" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_shl_nsw_sge1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(21 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.shl %arg0, %0 overflow : i32 + %3 = llvm.icmp "sge" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_shl_nsw_sge1_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<21> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.shl %arg0, %0 overflow : vector<2xi32> + %3 = llvm.icmp "sge" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_shl_nsw_eq(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %0 overflow : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_shl_nsw_eq_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.shl %arg0, %0 overflow : vector<2xi32> + %4 = llvm.icmp "eq" %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @icmp_sgt1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-16 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt5(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %arg0, %0 overflow : i8 + %2 = llvm.icmp "sgt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @icmp_sgt6(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(16 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt7(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(124 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt8(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(125 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt9(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt10(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt11(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt11_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-2> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 overflow : vector<2xi8> + %3 = llvm.icmp "sgt" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_sle1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sle" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sle2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sle" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sle3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-16 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sle" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sle4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sle" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sle5(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %arg0, %0 overflow : i8 + %2 = llvm.icmp "sle" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @icmp_sle6(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(16 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sle" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sle7(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(124 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sle" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sle8(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(125 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sle" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sle9(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sle" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sle10(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sle" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sle11(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "sle" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_eq1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(12 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_ne1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.shl %arg0, %0 overflow : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-shl-nuw.ll.mlir b/test/LLVMDialect/InstCombine/icmp-shl-nuw.ll.mlir index 30952a0f2..0518798df 100644 --- a/test/LLVMDialect/InstCombine/icmp-shl-nuw.ll.mlir +++ b/test/LLVMDialect/InstCombine/icmp-shl-nuw.ll.mlir @@ -1,75 +1,65 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4294967295 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %2 = "llvm.shl"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i64, i64) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "icmp_ugt_32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i128): // no predecessors - %0 = "llvm.mlir.constant"() {value = 18446744073709551615 : i128} : () -> i128 - %1 = "llvm.mlir.constant"() {value = 64 : i128} : () -> i128 - %2 = "llvm.shl"(%arg0, %1) : (i128, i128) -> i128 - %3 = "llvm.icmp"(%2, %0) {predicate = 7 : i64} : (i128, i128) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "icmp_ule_64", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1048575 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %2 = "llvm.shl"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i64, i64) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "icmp_ugt_16", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<65535> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<16> : vector<2xi64>} : () -> vector<2xi64> - %2 = "llvm.shl"(%arg0, %1) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %3 = "llvm.icmp"(%2, %0) {predicate = 7 : i64} : (vector<2xi64>, vector<2xi64>) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "icmp_ule_16x2", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<196608> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<16> : vector<2xi64>} : () -> vector<2xi64> - %2 = "llvm.shl"(%arg0, %1) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %3 = "llvm.icmp"(%2, %0) {predicate = 7 : i64} : (vector<2xi64>, vector<2xi64>) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "icmp_ule_16x2_nonzero", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<12288> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<12> : vector<2xi64>} : () -> vector<2xi64> - %2 = "llvm.shl"(%arg0, %1) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %3 = "llvm.icmp"(%2, %0) {predicate = 7 : i64} : (vector<2xi64>, vector<2xi64>) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "icmp_ule_12x2", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4095 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %2 = "llvm.shl"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i64, i64) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "icmp_ult_8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<4095> : vector<2xi16>} : () -> vector<2xi16> - %1 = "llvm.mlir.constant"() {value = dense<8> : vector<2xi16>} : () -> vector<2xi16> - %2 = "llvm.shl"(%arg0, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> - %3 = "llvm.icmp"(%2, %0) {predicate = 9 : i64} : (vector<2xi16>, vector<2xi16>) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "icmp_uge_8x2", type = !llvm.func (vector<2xi16>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1048575> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.mlir.constant"() {value = dense<16> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.shl"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (vector<2xi32>, vector<2xi32>) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "icmp_ugt_16x2", type = !llvm.func (vector<2xi32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @icmp_ugt_32(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(4294967295 : i64) : i64 + %2 = llvm.shl %arg0, %0 overflow : i64 + %3 = llvm.icmp "ugt" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @icmp_ule_64(%arg0: i128) -> i1 { + %0 = llvm.mlir.constant(64 : i128) : i128 + %1 = llvm.mlir.constant(18446744073709551615 : i128) : i128 + %2 = llvm.shl %arg0, %0 overflow : i128 + %3 = llvm.icmp "ule" %2, %1 : i128 + llvm.return %3 : i1 + } + llvm.func @icmp_ugt_16(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(1048575 : i64) : i64 + %2 = llvm.shl %arg0, %0 overflow : i64 + %3 = llvm.icmp "ugt" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @icmp_ule_16x2(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<65535> : vector<2xi64>) : vector<2xi64> + %2 = llvm.shl %arg0, %0 overflow : vector<2xi64> + %3 = llvm.icmp "ule" %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_ule_16x2_nonzero(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<196608> : vector<2xi64>) : vector<2xi64> + %2 = llvm.shl %arg0, %0 overflow : vector<2xi64> + %3 = llvm.icmp "ule" %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_ule_12x2(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<12> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<12288> : vector<2xi64>) : vector<2xi64> + %2 = llvm.shl %arg0, %0 overflow : vector<2xi64> + %3 = llvm.icmp "ule" %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_ult_8(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(4095 : i64) : i64 + %2 = llvm.shl %arg0, %0 overflow : i64 + %3 = llvm.icmp "ult" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @icmp_uge_8x2(%arg0: vector<2xi16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<4095> : vector<2xi16>) : vector<2xi16> + %2 = llvm.shl %arg0, %0 overflow : vector<2xi16> + %3 = llvm.icmp "uge" %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_ugt_16x2(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1048575> : vector<2xi32>) : vector<2xi32> + %2 = llvm.shl %arg0, %0 overflow : vector<2xi32> + %3 = llvm.icmp "ugt" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-shl.ll.mlir b/test/LLVMDialect/InstCombine/icmp-shl.ll.mlir new file mode 100644 index 000000000..6f3078ae7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-shl.ll.mlir @@ -0,0 +1,111 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @shl_nuw_eq_0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.shl %arg0, %arg1 overflow : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @shl_nsw_ne_0(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %arg1 overflow : vector<2xi8> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @shl_eq_0_fail_missing_flags(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.shl %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @shl_ne_1_fail_nonzero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %arg0, %arg1 overflow : i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @shl_nsw_slt_1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %arg0, %arg1 overflow : i8 + %2 = llvm.icmp "slt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @shl_vec_nsw_slt_1_0_todo_non_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %arg0, %arg1 overflow : vector<2xi8> + %2 = llvm.icmp "slt" %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @shl_nsw_sle_n1(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %arg0, %arg1 overflow : vector<2xi8> + %2 = llvm.icmp "sle" %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @shl_nsw_sge_1(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %arg0, %arg1 overflow : vector<2xi8> + %2 = llvm.icmp "sge" %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @shl_nsw_sgt_n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %arg0, %arg1 overflow : i8 + %2 = llvm.icmp "sgt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @shl_nuw_sgt_n1_fail_wrong_flag(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %arg0, %arg1 overflow : i8 + %2 = llvm.icmp "sgt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @shl_nsw_nuw_ult_Csle0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-19 : i8) : i8 + %1 = llvm.shl %arg0, %arg1 overflow : i8 + %2 = llvm.icmp "ult" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @shl_nsw_ule_Csle0_fail_missing_flag(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-19 : i8) : i8 + %1 = llvm.shl %arg0, %arg1 overflow : i8 + %2 = llvm.icmp "ule" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @shl_nsw_nuw_uge_Csle0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-120 : i8) : i8 + %1 = llvm.shl %arg0, %arg1 overflow : i8 + %2 = llvm.icmp "uge" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @shl_nuw_ugt_Csle0_fail_missing_flag(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-19 : i8) : i8 + %1 = llvm.shl %arg0, %arg1 overflow : i8 + %2 = llvm.icmp "ugt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @shl_nsw_nuw_sgt_Csle0(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %arg0, %arg1 overflow : vector<2xi8> + %2 = llvm.icmp "sgt" %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @shl_nsw_nuw_sge_Csle0_todo_non_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-10, -65]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %arg0, %arg1 overflow : vector<2xi8> + %2 = llvm.icmp "sge" %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @shl_nsw_nuw_sle_Csle0(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-6> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %arg0, %arg1 overflow : vector<2xi8> + %2 = llvm.icmp "sle" %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @shl_nsw_nuw_slt_Csle0_fail_positive(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %arg0, %arg1 overflow : vector<2xi8> + %2 = llvm.icmp "slt" %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-shr-lt-gt.ll.mlir b/test/LLVMDialect/InstCombine/icmp-shr-lt-gt.ll.mlir index 7f42689ac..0ffe67891 100644 --- a/test/LLVMDialect/InstCombine/icmp-shr-lt-gt.ll.mlir +++ b/test/LLVMDialect/InstCombine/icmp-shr-lt-gt.ll.mlir @@ -1,3236 +1,2878 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_00", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.lshr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_01", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_02", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_03", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_04", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_05", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_06", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_07", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_08", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_09", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_00", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_01", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.lshr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_02", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_03", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_04", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_05", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_06", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_07", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_08", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_09", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_00", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_01", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_02", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.lshr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_03", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_04", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_05", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_06", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_07", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_08", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_09", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_00", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.lshr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_01", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_02", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_03", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_04", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_05", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_06", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_07", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_08", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_09", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_00", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_01", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.lshr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_02", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_03", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_04", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_05", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_06", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_07", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_08", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_09", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_00", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_01", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_02", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.lshr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_03", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_04", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_05", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_06", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_07", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_08", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_09", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_00", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.ashr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_01", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_02", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_03", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_04", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_05", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_06", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_07", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_08", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_09", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_00", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_01", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.ashr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_02", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_03", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_04", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_05", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_06", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_07", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_08", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_09", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_00", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_01", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_02", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.ashr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_03", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_04", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_05", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_06", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_07", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_08", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_09", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_00", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.ashr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_01", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_02", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_03", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_04", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_05", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_06", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_07", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_08", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_09", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_00", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_01", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.ashr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_02", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_03", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_04", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_05", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_06", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_07", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_08", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_09", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_00", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_01", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_02", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.ashr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_03", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_04", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_05", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_06", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_07", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_08", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_09", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_00_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.lshr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_01_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_02_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_03_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_04_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_05_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_06_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_07_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_08_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_09_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_10_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_11_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_12_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_13_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_14_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_01_15_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_00_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_01_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.lshr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_02_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_03_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_04_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_05_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_06_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_07_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_08_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_09_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_10_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_11_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_12_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_13_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_14_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_02_15_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_00_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_01_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_02_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.lshr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_03_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_04_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_05_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_06_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_07_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_08_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_09_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_10_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_11_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_12_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_13_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_14_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrugt_03_15_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_eq_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_ne_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_ugt_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_uge_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_ult_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_ule_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_sgt_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 5 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_sge_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_slt_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 3 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_sle_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_eq_noexact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_ne_noexact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_ugt_noexact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_uge_noexact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_ult_noexact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_ule_noexact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_sgt_noexact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 5 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_sge_noexact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_slt_noexact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 3 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_sle_noexact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.store"(%2, %arg1) : (i8, !llvm.ptr) -> () - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_00_00_ashr_extra_use", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<10> : vector<4xi8>} : () -> vector<4xi8> - %1 = "llvm.mlir.constant"() {value = dense<3> : vector<4xi8>} : () -> vector<4xi8> - %2 = "llvm.ashr"(%arg0, %1) : (vector<4xi8>, vector<4xi8>) -> vector<4xi8> - %3 = "llvm.icmp"(%2, %0) {predicate = 7 : i64} : (vector<4xi8>, vector<4xi8>) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_00_00_vec", type = !llvm.func (vector<4xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 63 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %2 = "llvm.ashr"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashr_sgt_overflow", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_00_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.lshr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_01_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_02_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_03_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_04_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_05_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_06_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_07_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_08_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_09_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_10_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_11_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_12_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_13_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_14_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_01_15_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_00_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_01_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.lshr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_02_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_03_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_04_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_05_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_06_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_07_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_08_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_09_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_10_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_11_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_12_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_13_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_14_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_02_15_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_00_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_01_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_02_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.lshr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_03_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_04_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_05_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_06_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_07_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_08_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_09_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_10_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_11_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_12_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_13_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_14_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.lshr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 6 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "lshrult_03_15_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_00_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.ashr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_01_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_02_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_03_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_04_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_05_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_06_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_07_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_08_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_09_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_10_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_11_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_12_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_13_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_14_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_01_15_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_00_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_01_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.ashr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_02_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_03_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_04_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_05_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_06_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_07_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_08_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_09_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_10_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_11_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_12_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_13_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_14_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_02_15_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_00_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_01_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_02_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.ashr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_03_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_04_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_05_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_06_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_07_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_08_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_09_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_10_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_11_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_12_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_13_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_14_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrsgt_03_15_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_00_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.ashr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_01_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_02_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_03_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_04_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_05_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_06_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_07_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_08_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_09_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_10_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_11_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_12_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_13_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_14_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_01_15_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_00_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_01_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.ashr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_02_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_03_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_04_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_05_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_06_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_07_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_08_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_09_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_10_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_11_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_12_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_13_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_14_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_02_15_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_00_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_01_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_02_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %1 = "llvm.ashr"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.icmp"(%1, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_03_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_04_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_05_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_06_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_07_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_08_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -7 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_09_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_10_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_11_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_12_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_13_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_14_exact", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = 3 : i4} : () -> i4 - %2 = "llvm.ashr"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i4, i4) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "ashrslt_03_15_exact", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @lshrugt_01_00(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_01(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.lshr %arg0, %0 : i4 + %2 = llvm.icmp "ugt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @lshrugt_01_02(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_03(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_04(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_05(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_06(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_07(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_08(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_09(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_10(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_11(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_12(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_13(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_14(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_15(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_00(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_01(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_02(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.lshr %arg0, %0 : i4 + %2 = llvm.icmp "ugt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @lshrugt_02_03(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_04(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_05(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_06(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_07(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_08(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_09(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_10(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_11(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_12(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_13(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_14(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_15(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_00(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_01(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_02(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_03(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.lshr %arg0, %0 : i4 + %2 = llvm.icmp "ugt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @lshrugt_03_04(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_05(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_06(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_07(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_08(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_09(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_10(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_11(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_12(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_13(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_14(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_15(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_00(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_01(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.lshr %arg0, %0 : i4 + %2 = llvm.icmp "ult" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @lshrult_01_02(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_03(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_04(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_05(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_06(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_07(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_08(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_09(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_10(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_11(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_12(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_13(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_14(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_15(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_00(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_01(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_02(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.lshr %arg0, %0 : i4 + %2 = llvm.icmp "ult" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @lshrult_02_03(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_04(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_05(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_06(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_07(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_08(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_09(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_10(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_11(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_12(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_13(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_14(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_15(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_00(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_01(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_02(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_03(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.lshr %arg0, %0 : i4 + %2 = llvm.icmp "ult" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @lshrult_03_04(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_05(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_06(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_07(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_08(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_09(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_10(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_11(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_12(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_13(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_14(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_15(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_00(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_00_multiuse(%arg0: i4, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.store %2, %arg1 {alignment = 1 : i64} : i4, !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_01(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.ashr %arg0, %0 : i4 + %2 = llvm.icmp "sgt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @ashrsgt_01_02(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_03(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_04(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_05(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_06(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_07(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_08(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_09(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_10(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_11(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_12(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_13(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_14(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_15(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_00(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_01(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_02(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.ashr %arg0, %0 : i4 + %2 = llvm.icmp "sgt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @ashrsgt_02_03(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_04(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_05(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_06(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_07(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_08(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_09(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_10(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_11(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_12(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_13(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_14(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_15(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_00(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_01(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_02(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_03(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.ashr %arg0, %0 : i4 + %2 = llvm.icmp "sgt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @ashrsgt_03_04(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_05(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_06(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_07(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_08(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_09(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_10(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_11(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_12(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_13(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_14(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_15(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_00(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_01(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.ashr %arg0, %0 : i4 + %2 = llvm.icmp "slt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @ashrslt_01_02(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_03(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_04(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_05(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_06(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_07(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_08(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_09(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_10(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_11(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_12(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_13(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_14(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_15(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_00(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_01(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_02(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.ashr %arg0, %0 : i4 + %2 = llvm.icmp "slt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @ashrslt_02_03(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_04(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_05(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_06(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_07(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_08(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_09(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_10(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_11(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_12(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_13(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_14(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_15(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_00(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_01(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_02(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_03(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.ashr %arg0, %0 : i4 + %2 = llvm.icmp "slt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @ashrslt_03_04(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_05(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_06(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_07(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_08(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_09(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_10(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_11(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_12(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_13(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_14(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_15(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_00_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_01_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.lshr %arg0, %0 : i4 + %2 = llvm.icmp "ugt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @lshrugt_01_02_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_03_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_04_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_05_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_06_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_07_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_08_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_09_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_10_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_11_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_12_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_13_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_14_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_01_15_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_00_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_01_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_02_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.lshr %arg0, %0 : i4 + %2 = llvm.icmp "ugt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @lshrugt_02_03_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_04_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_05_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_06_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_07_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_08_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_09_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_10_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_11_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_12_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_13_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_14_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_02_15_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_00_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_01_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_02_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_03_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.lshr %arg0, %0 : i4 + %2 = llvm.icmp "ugt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @lshrugt_03_04_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_05_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_06_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_07_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_08_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_09_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_10_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_11_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_12_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_13_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_14_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrugt_03_15_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_eq_exact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_ne_exact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_exact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_uge_exact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "uge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_exact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_ule_exact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "ule" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_sgt_exact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_sge_exact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "sge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_slt_exact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_sle_exact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "sle" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_eq_noexact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_ne_noexact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_noexact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_uge_noexact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "uge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_noexact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_ule_noexact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "ule" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_sgt_noexact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_sge_noexact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "sge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_slt_noexact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_sle_noexact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "sle" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_00_00_ashr_extra_use(%arg0: i8, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "ule" %2, %1 : i8 + llvm.store %2, %arg1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @ashr_00_00_vec(%arg0: vector<4xi8>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<10> : vector<4xi8>) : vector<4xi8> + %2 = llvm.ashr %arg0, %0 : vector<4xi8> + %3 = llvm.icmp "ule" %2, %1 : vector<4xi8> + llvm.return %3 : vector<4xi1> + } + llvm.func @ashr_sgt_overflow(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(63 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_00_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_01_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.lshr %arg0, %0 : i4 + %2 = llvm.icmp "ult" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @lshrult_01_02_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_03_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_04_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_05_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_06_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_07_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_08_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_09_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_10_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_11_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_12_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_13_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_14_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_01_15_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_00_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_01_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_02_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.lshr %arg0, %0 : i4 + %2 = llvm.icmp "ult" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @lshrult_02_03_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_04_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_05_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_06_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_07_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_08_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_09_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_10_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_11_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_12_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_13_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_14_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_02_15_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_00_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_01_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_02_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_03_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.lshr %arg0, %0 : i4 + %2 = llvm.icmp "ult" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @lshrult_03_04_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_05_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_06_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_07_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_08_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_09_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_10_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_11_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_12_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_13_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_14_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshrult_03_15_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.lshr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_00_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_01_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.ashr %arg0, %0 : i4 + %2 = llvm.icmp "sgt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @ashrsgt_01_02_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_03_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_04_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_05_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_06_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_07_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_08_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_09_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_10_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_11_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_12_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_13_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_14_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_01_15_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_00_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_01_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_02_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.ashr %arg0, %0 : i4 + %2 = llvm.icmp "sgt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @ashrsgt_02_03_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_04_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_05_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_06_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_07_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_08_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_09_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_10_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_11_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_12_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_13_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_14_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_02_15_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_00_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_01_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_02_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_03_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.ashr %arg0, %0 : i4 + %2 = llvm.icmp "sgt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @ashrsgt_03_04_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_05_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_06_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_07_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_08_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_09_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_10_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_11_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_12_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_13_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_14_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrsgt_03_15_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_00_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_01_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.ashr %arg0, %0 : i4 + %2 = llvm.icmp "slt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @ashrslt_01_02_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_03_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_04_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_05_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_06_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_07_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_08_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_09_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_10_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_11_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_12_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_13_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_14_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_01_15_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_00_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_01_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_02_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.ashr %arg0, %0 : i4 + %2 = llvm.icmp "slt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @ashrslt_02_03_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_04_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_05_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_06_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_07_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_08_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_09_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_10_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_11_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_12_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_13_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_14_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_02_15_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_00_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_01_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_02_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_03_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.ashr %arg0, %0 : i4 + %2 = llvm.icmp "slt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @ashrslt_03_04_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_05_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_06_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_07_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_08_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_09_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_10_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_11_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_12_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_13_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_14_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashrslt_03_15_exact(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "slt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_slt_exact_near_pow2_cmpval(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_exact_near_pow2_cmpval(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @negtest_near_pow2_cmpval_ashr_slt_noexact(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @negtest_near_pow2_cmpval_ashr_wrong_cmp_pred(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @negtest_near_pow2_cmpval_isnt_close_to_pow2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @negtest_near_pow2_cmpval_would_overflow_into_signbit(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(33 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-shr.ll.mlir b/test/LLVMDialect/InstCombine/icmp-shr.ll.mlir new file mode 100644 index 000000000..37db63ccb --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-shr.ll.mlir @@ -0,0 +1,1095 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry, dense<16> : vector<4xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry, dense<64> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @lshr_eq_msb_low_last_zero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_eq_msb_low_last_zero_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.lshr %0, %arg0 : vector<2xi8> + %4 = llvm.icmp "eq" %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @ashr_eq_msb_low_second_zero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_ne_msb_low_last_zero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_ne_msb_low_second_zero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_eq_both_equal(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.ashr %0, %arg0 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @ashr_ne_both_equal(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.ashr %0, %arg0 : i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @lshr_eq_both_equal(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.lshr %0, %arg0 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @lshr_ne_both_equal(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.lshr %0, %arg0 : i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @exact_ashr_eq_both_equal(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.ashr %0, %arg0 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @exact_ashr_ne_both_equal(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.ashr %0, %arg0 : i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @exact_lshr_eq_both_equal(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(126 : i8) : i8 + %1 = llvm.lshr %0, %arg0 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @exact_lshr_ne_both_equal(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(126 : i8) : i8 + %1 = llvm.lshr %0, %arg0 : i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @exact_lshr_eq_opposite_msb(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_eq_opposite_msb(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @exact_lshr_ne_opposite_msb(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_ne_opposite_msb(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @exact_ashr_eq(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @exact_ashr_ne(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @exact_lshr_eq(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @exact_lshr_ne(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_ashr_eq(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_ashr_ne(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_lshr_eq(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_lshr_ne(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @exact_lshr_eq_exactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(80 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @exact_lshr_ne_exactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(80 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_lshr_eq_exactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(80 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_lshr_ne_exactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(80 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @exact_ashr_eq_exactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-80 : i8) : i8 + %1 = llvm.mlir.constant(-5 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @exact_ashr_ne_exactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-80 : i8) : i8 + %1 = llvm.mlir.constant(-5 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_ashr_eq_exactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-80 : i8) : i8 + %1 = llvm.mlir.constant(-5 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_ashr_ne_exactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-80 : i8) : i8 + %1 = llvm.mlir.constant(-5 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @exact_lshr_eq_noexactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(80 : i8) : i8 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @exact_lshr_ne_noexactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(80 : i8) : i8 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_lshr_eq_noexactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(80 : i8) : i8 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_lshr_ne_noexactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(80 : i8) : i8 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @exact_ashr_eq_noexactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-80 : i8) : i8 + %1 = llvm.mlir.constant(-31 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @exact_ashr_ne_noexactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-80 : i8) : i8 + %1 = llvm.mlir.constant(-31 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_ashr_eq_noexactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-80 : i8) : i8 + %1 = llvm.mlir.constant(-31 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_ashr_ne_noexactdiv(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-80 : i8) : i8 + %1 = llvm.mlir.constant(-31 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_lshr_eq_noexactlog(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(90 : i8) : i8 + %1 = llvm.mlir.constant(30 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_lshr_ne_noexactlog(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(90 : i8) : i8 + %1 = llvm.mlir.constant(30 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_ashr_eq_noexactlog(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-90 : i8) : i8 + %1 = llvm.mlir.constant(-30 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @nonexact_ashr_ne_noexactlog(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-90 : i8) : i8 + %1 = llvm.mlir.constant(-30 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @PR20945(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-9 : i32) : i32 + %1 = llvm.mlir.constant(-5 : i32) : i32 + %2 = llvm.ashr %0, %arg0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @PR21222(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-93 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.ashr %0, %arg0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @PR24873(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(-4611686018427387904 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.ashr %0, %arg0 : i64 + %3 = llvm.icmp "eq" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @foo(i32) + llvm.func @exact_multiuse(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(1024 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.call @foo(%2) : (i32) -> () + llvm.return %3 : i1 + } + llvm.func @ashr_exact_eq_0(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.ashr %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @ashr_exact_ne_0_uses(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.ashr %arg0, %arg1 : i32 + llvm.call @foo(%1) : (i32) -> () + %2 = llvm.icmp "ne" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @ashr_exact_eq_0_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.ashr %arg0, %arg1 : vector<2xi32> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @lshr_exact_ne_0(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.lshr %arg0, %arg1 : i32 + %2 = llvm.icmp "ne" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @lshr_exact_eq_0_uses(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.lshr %arg0, %arg1 : i32 + llvm.call @foo(%1) : (i32) -> () + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @lshr_exact_ne_0_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @ashr_ugt_0(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_0_multiuse(%arg0: i4, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.store %2, %arg1 {alignment = 1 : i64} : i4, !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_1(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.ashr %arg0, %0 : i4 + %2 = llvm.icmp "ugt" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @ashr_ugt_2(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_3(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_4(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_5(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_6(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_7(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_8(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_9(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_10(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_11(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_12(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_13(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_14(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ugt_15(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ugt" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_0(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_1(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.ashr %arg0, %0 : i4 + %2 = llvm.icmp "ult" %1, %0 : i4 + llvm.return %2 : i1 + } + llvm.func @ashr_ult_2(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_2_multiuse(%arg0: i4, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.store %2, %arg1 {alignment = 1 : i64} : i4, !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @ashr_ult_3(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_4(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_5(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_6(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_7(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_8(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-8 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_9(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-7 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_10(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_11(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-5 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_12(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_13(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-3 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_14(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @ashr_ult_15(%arg0: i4) -> i1 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.ashr %arg0, %0 : i4 + %3 = llvm.icmp "ult" %2, %1 : i4 + llvm.return %3 : i1 + } + llvm.func @lshr_eq_0_multiuse(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_ne_0_multiuse(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_eq_0_multiuse(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_ne_0_multiuse(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_exact_eq_0_multiuse(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_exact_ne_0_multiuse(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_exact_eq_0_multiuse(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_exact_ne_0_multiuse(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_pow2_ugt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_pow2_ugt_use(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_pow2_ugt_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %0, %arg0 : vector<2xi8> + %3 = llvm.icmp "ugt" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @lshr_not_pow2_ugt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_pow2_ugt1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @ashr_pow2_ugt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(-96 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_pow2_sgt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_pow2_ult(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_pow2_ult_use(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_pow2_ult_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %0, %arg0 : vector<2xi8> + %3 = llvm.icmp "ult" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @lshr_not_pow2_ult(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_pow2_ult_equal_constants(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.lshr %0, %arg0 : i32 + %2 = llvm.icmp "ult" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @lshr_pow2_ult_smin(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.lshr %0, %arg0 : i8 + %2 = llvm.icmp "ult" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @ashr_pow2_ult(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(-96 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_pow2_slt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_neg_sgt_minus_1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_neg_sgt_minus_1_vector(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-17> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %0, %arg0 : vector<2xi8> + %3 = llvm.icmp "sgt" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @lshr_neg_sgt_minus_1_extra_use(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_neg_sgt_minus_2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_neg_slt_minus_1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_neg_slt_zero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_neg_slt_zero_vector(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-17> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.lshr %0, %arg0 : vector<2xi8> + %4 = llvm.icmp "slt" %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @lshr_neg_slt_zero_extra_use(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @"lshr_neg_slt_non-zero"(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @lshr_neg_sgt_zero(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-17 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @exactly_one_set_signbit(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %arg1, %1 : i8 + %4 = llvm.zext %3 : i1 to i8 + %5 = llvm.icmp "eq" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @exactly_one_set_signbit_use1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "sgt" %arg1, %1 : i8 + %4 = llvm.zext %3 : i1 to i8 + %5 = llvm.icmp "eq" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @same_signbit(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "sgt" %arg1, %1 : vector<2xi8> + %4 = llvm.zext %3 : vector<2xi1> to vector<2xi8> + %5 = llvm.icmp "ne" %2, %4 : vector<2xi8> + llvm.return %5 : vector<2xi1> + } + llvm.func @same_signbit_use2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %arg1, %1 : i8 + %4 = llvm.zext %3 : i1 to i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.icmp "ne" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @same_signbit_use3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "sgt" %arg1, %1 : i8 + %4 = llvm.zext %3 : i1 to i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.icmp "ne" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @same_signbit_poison_elts(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(-1 : i8) : i8 + %8 = llvm.mlir.undef : vector<2xi8> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi8> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi8> + %13 = llvm.lshr %arg0, %6 : vector<2xi8> + %14 = llvm.icmp "sgt" %arg1, %12 : vector<2xi8> + %15 = llvm.zext %14 : vector<2xi1> to vector<2xi8> + %16 = llvm.icmp "ne" %13, %15 : vector<2xi8> + llvm.return %16 : vector<2xi1> + } + llvm.func @same_signbit_wrong_type(%arg0: i8, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %arg1, %1 : i32 + %4 = llvm.zext %3 : i1 to i8 + %5 = llvm.icmp "ne" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @exactly_one_set_signbit_wrong_shamt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %arg1, %1 : i8 + %4 = llvm.zext %3 : i1 to i8 + %5 = llvm.icmp "eq" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @exactly_one_set_signbit_wrong_shr(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %arg1, %1 : i8 + %4 = llvm.zext %3 : i1 to i8 + %5 = llvm.icmp "eq" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @exactly_one_set_signbit_wrong_pred(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %arg1, %1 : i8 + %4 = llvm.zext %3 : i1 to i8 + %5 = llvm.icmp "sgt" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @exactly_one_set_signbit_signed(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %arg1, %1 : i8 + %4 = llvm.sext %3 : i1 to i8 + %5 = llvm.icmp "eq" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @exactly_one_set_signbit_use1_signed(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "sgt" %arg1, %1 : i8 + %4 = llvm.sext %3 : i1 to i8 + %5 = llvm.icmp "eq" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @same_signbit_signed(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.ashr %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "sgt" %arg1, %1 : vector<2xi8> + %4 = llvm.sext %3 : vector<2xi1> to vector<2xi8> + %5 = llvm.icmp "ne" %2, %4 : vector<2xi8> + llvm.return %5 : vector<2xi1> + } + llvm.func @same_signbit_use2_signed(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %arg1, %1 : i8 + %4 = llvm.sext %3 : i1 to i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.icmp "ne" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @same_signbit_use3_signed(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.icmp "sgt" %arg1, %1 : i8 + %4 = llvm.sext %3 : i1 to i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.icmp "ne" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @same_signbit_poison_elts_signed(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(-1 : i8) : i8 + %8 = llvm.mlir.undef : vector<2xi8> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi8> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi8> + %13 = llvm.ashr %arg0, %6 : vector<2xi8> + %14 = llvm.icmp "sgt" %arg1, %12 : vector<2xi8> + %15 = llvm.sext %14 : vector<2xi1> to vector<2xi8> + %16 = llvm.icmp "ne" %13, %15 : vector<2xi8> + llvm.return %16 : vector<2xi1> + } + llvm.func @same_signbit_wrong_type_signed(%arg0: i8, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %arg1, %1 : i32 + %4 = llvm.sext %3 : i1 to i8 + %5 = llvm.icmp "ne" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @exactly_one_set_signbit_wrong_shamt_signed(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.icmp "sgt" %arg1, %1 : i8 + %4 = llvm.sext %3 : i1 to i8 + %5 = llvm.icmp "eq" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @slt_zero_ult_i1(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.zext %arg1 : i1 to i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.icmp "ult" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @slt_zero_ult_i1_fail1(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(30 : i32) : i32 + %1 = llvm.zext %arg1 : i1 to i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.icmp "ult" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @slt_zero_ult_i1_fail2(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.zext %arg1 : i1 to i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.icmp "ult" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @slt_zero_slt_i1_fail(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.zext %arg1 : i1 to i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.icmp "slt" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @slt_zero_eq_i1_signed(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sext %arg1 : i1 to i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.icmp "eq" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @slt_zero_eq_i1_fail_signed(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sext %arg1 : i1 to i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.icmp "eq" %1, %2 : i32 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-sub.ll.mlir b/test/LLVMDialect/InstCombine/icmp-sub.ll.mlir new file mode 100644 index 000000000..6348db755 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-sub.ll.mlir @@ -0,0 +1,397 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @use_vec(vector<2xi8>) + llvm.func @test_nuw_and_unsigned_pred(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.sub %0, %arg0 overflow : i64 + %3 = llvm.icmp "ult" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @test_nsw_and_signed_pred(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.sub %0, %arg0 overflow : i64 + %3 = llvm.icmp "sgt" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @test_nuw_nsw_and_unsigned_pred(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.sub %0, %arg0 overflow : i64 + %3 = llvm.icmp "ule" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @test_nuw_nsw_and_signed_pred(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.sub %0, %arg0 overflow : i64 + %3 = llvm.icmp "slt" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @test_negative_nuw_and_signed_pred(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.sub %0, %arg0 overflow : i64 + %3 = llvm.icmp "slt" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @test_negative_nsw_and_unsigned_pred(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.sub %0, %arg0 overflow : i64 + %3 = llvm.icmp "ult" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @test_negative_combined_sub_unsigned_overflow(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(11 : i64) : i64 + %2 = llvm.sub %0, %arg0 overflow : i64 + %3 = llvm.icmp "ult" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @test_negative_combined_sub_signed_overflow(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.sub %0, %arg0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @test_sub_0_Y_eq_0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @test_sub_0_Y_ne_0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @test_sub_4_Y_ne_4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @test_sub_127_Y_eq_127(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @test_sub_255_Y_eq_255(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @test_sub_255_Y_eq_255_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sub %0, %arg0 : vector<2xi8> + %2 = llvm.icmp "eq" %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @icmp_eq_sub_undef(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %8 = llvm.sub %6, %arg0 : vector<2xi32> + %9 = llvm.icmp "eq" %8, %7 : vector<2xi32> + llvm.return %9 : vector<2xi1> + } + llvm.func @icmp_eq_sub_non_splat(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[15, 16]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %0, %arg0 : vector<2xi32> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_eq_sub_undef2(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(10 : i32) : i32 + %3 = llvm.mlir.undef : vector<2xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi32> + %8 = llvm.sub %0, %arg0 : vector<2xi32> + %9 = llvm.icmp "eq" %8, %7 : vector<2xi32> + llvm.return %9 : vector<2xi1> + } + llvm.func @icmp_eq_sub_non_splat2(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[10, 11]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %0, %arg0 : vector<2xi32> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @neg_sgt_42(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @neg_eq_43(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(43 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @neg_ne_44(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(44 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @neg_nsw_eq_45(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(45 : i32) : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @neg_nsw_ne_46(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(46 : i32) : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @subC_eq(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(43 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @subC_ne(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-6, -128]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-44> : vector<2xi8>) : vector<2xi8> + %2 = llvm.sub %0, %arg0 : vector<2xi8> + llvm.call @use_vec(%2) : (vector<2xi8>) -> () + %3 = llvm.icmp "ne" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @subC_nsw_eq(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-100 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @subC_nsw_ne(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483647 : i32) : i32 + %1 = llvm.mlir.constant(46 : i32) : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @neg_slt_42(%arg0: i128) -> i1 { + %0 = llvm.mlir.constant(0 : i128) : i128 + %1 = llvm.mlir.constant(42 : i128) : i128 + %2 = llvm.sub %0, %arg0 : i128 + %3 = llvm.icmp "slt" %2, %1 : i128 + llvm.return %3 : i1 + } + llvm.func @neg_ugt_42_splat(%arg0: vector<2xi7>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i7) : i7 + %1 = llvm.mlir.constant(dense<0> : vector<2xi7>) : vector<2xi7> + %2 = llvm.mlir.constant(42 : i7) : i7 + %3 = llvm.mlir.constant(dense<42> : vector<2xi7>) : vector<2xi7> + %4 = llvm.sub %1, %arg0 : vector<2xi7> + %5 = llvm.icmp "ugt" %4, %3 : vector<2xi7> + llvm.return %5 : vector<2xi1> + } + llvm.func @neg_sgt_42_use(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "sgt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @neg_slt_n1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @neg_slt_0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.icmp "slt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @neg_slt_1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @neg_sgt_n1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @neg_sgt_0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.icmp "sgt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @neg_sgt_1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @neg_nsw_slt_n1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.sub %0, %arg0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @neg_nsw_slt_0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.icmp "slt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @neg_nsw_slt_1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.sub %0, %arg0 overflow : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @neg_nsw_sgt_n1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.sub %0, %arg0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @neg_nsw_sgt_0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.icmp "sgt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @neg_nsw_sgt_1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.sub %0, %arg0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @sub_eq_zero_use(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %arg0, %arg1 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @sub_ne_zero_use(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.sub %arg0, %arg1 : vector<2xi8> + llvm.call @use_vec(%2) : (vector<2xi8>) -> () + %3 = llvm.icmp "eq" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @sub_eq_zero_select(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %arg0, %arg1 : i32 + llvm.store %1, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %2 = llvm.icmp "eq" %1, %0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @PR54558_reduced(%arg0: i32) { + %0 = llvm.mlir.constant(43 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + llvm.br ^bb1(%arg0 : i32) + ^bb1(%2: i32): // 2 preds: ^bb0, ^bb1 + %3 = llvm.intr.umin(%2, %0) : (i32, i32) -> i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.sub %2, %3 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.cond_br %5, ^bb2, ^bb1(%4 : i32) + ^bb2: // pred: ^bb1 + llvm.return + } + llvm.func @PR54558_reduced_more(%arg0: i32, %arg1: i32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.br ^bb1(%arg0 : i32) + ^bb1(%1: i32): // 2 preds: ^bb0, ^bb1 + %2 = llvm.sub %1, %arg1 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.cond_br %3, ^bb2, ^bb1(%2 : i32) + ^bb2: // pred: ^bb1 + llvm.return + } + llvm.func @PR60818_ne(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.icmp "ne" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @PR60818_eq(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.icmp "eq" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @PR60818_eq_commuted(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(43 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.sub %1, %2 : i32 + %4 = llvm.icmp "eq" %2, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @PR60818_ne_vector(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %1, %arg0 : vector<2xi32> + %3 = llvm.icmp "ne" %arg0, %2 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @PR60818_eq_multi_use(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.icmp "eq" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @PR60818_sgt(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.icmp "sgt" %1, %arg0 : i32 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-topbitssame.ll.mlir b/test/LLVMDialect/InstCombine/icmp-topbitssame.ll.mlir index 003abf50d..e688afc15 100644 --- a/test/LLVMDialect/InstCombine/icmp-topbitssame.ll.mlir +++ b/test/LLVMDialect/InstCombine/icmp-topbitssame.ll.mlir @@ -1,154 +1,138 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use16", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 8 : i16} : () -> i16 - %2 = "llvm.lshr"(%arg0, %1) : (i16, i16) -> i16 - %3 = "llvm.trunc"(%2) : (i16) -> i8 - %4 = "llvm.trunc"(%arg0) : (i16) -> i8 - %5 = "llvm.ashr"(%4, %0) : (i8, i8) -> i8 - %6 = "llvm.icmp"(%5, %3) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "testi16i8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 8 : i16} : () -> i16 - %2 = "llvm.lshr"(%arg0, %1) : (i16, i16) -> i16 - %3 = "llvm.trunc"(%2) : (i16) -> i8 - %4 = "llvm.trunc"(%arg0) : (i16) -> i8 - %5 = "llvm.ashr"(%4, %0) : (i8, i8) -> i8 - %6 = "llvm.icmp"(%3, %5) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "testi16i8_com", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 8 : i16} : () -> i16 - %2 = "llvm.lshr"(%arg0, %1) : (i16, i16) -> i16 - %3 = "llvm.trunc"(%2) : (i16) -> i8 - %4 = "llvm.trunc"(%arg0) : (i16) -> i8 - %5 = "llvm.ashr"(%4, %0) : (i8, i8) -> i8 - %6 = "llvm.icmp"(%5, %3) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "testi16i8_ne", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 8 : i16} : () -> i16 - %2 = "llvm.lshr"(%arg0, %1) : (i16, i16) -> i16 - %3 = "llvm.trunc"(%2) : (i16) -> i8 - %4 = "llvm.trunc"(%arg0) : (i16) -> i8 - %5 = "llvm.ashr"(%4, %0) : (i8, i8) -> i8 - %6 = "llvm.icmp"(%3, %5) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "testi16i8_ne_com", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %2 = "llvm.lshr"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.trunc"(%2) : (i64) -> i32 - %4 = "llvm.trunc"(%arg0) : (i64) -> i32 - %5 = "llvm.ashr"(%4, %0) : (i32, i32) -> i32 - %6 = "llvm.icmp"(%5, %3) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "testi64i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %2 = "llvm.lshr"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.trunc"(%2) : (i64) -> i32 - %4 = "llvm.trunc"(%arg0) : (i64) -> i32 - %5 = "llvm.ashr"(%4, %0) : (i32, i32) -> i32 - %6 = "llvm.icmp"(%5, %3) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "testi64i32_ne", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.trunc"(%2) : (i32) -> i8 - %4 = "llvm.trunc"(%arg0) : (i32) -> i8 - %5 = "llvm.ashr"(%4, %0) : (i8, i8) -> i8 - %6 = "llvm.icmp"(%5, %3) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "testi32i8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 7 : i16} : () -> i16 - %2 = "llvm.lshr"(%arg0, %1) : (i16, i16) -> i16 - %3 = "llvm.trunc"(%2) : (i16) -> i8 - %4 = "llvm.trunc"(%arg0) : (i16) -> i8 - %5 = "llvm.ashr"(%4, %0) : (i8, i8) -> i8 - %6 = "llvm.icmp"(%5, %3) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "wrongimm1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 8 : i16} : () -> i16 - %2 = "llvm.lshr"(%arg0, %1) : (i16, i16) -> i16 - %3 = "llvm.trunc"(%2) : (i16) -> i8 - %4 = "llvm.trunc"(%arg0) : (i16) -> i8 - %5 = "llvm.ashr"(%4, %0) : (i8, i8) -> i8 - %6 = "llvm.icmp"(%5, %3) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "wrongimm2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %2 = "llvm.lshr"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.trunc"(%2) : (i64) -> i32 - %4 = "llvm.trunc"(%arg0) : (i64) -> i32 - %5 = "llvm.ashr"(%4, %0) : (i32, i32) -> i32 - %6 = "llvm.icmp"(%5, %3) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "slt", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 8 : i16} : () -> i16 - %2 = "llvm.lshr"(%arg0, %1) : (i16, i16) -> i16 - %3 = "llvm.trunc"(%2) : (i16) -> i8 - %4 = "llvm.trunc"(%arg0) : (i16) -> i8 - %5 = "llvm.ashr"(%4, %0) : (i8, i8) -> i8 - %6 = "llvm.icmp"(%5, %3) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.call"(%5) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "extrause_a", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 8 : i16} : () -> i16 - %2 = "llvm.lshr"(%arg0, %1) : (i16, i16) -> i16 - %3 = "llvm.trunc"(%2) : (i16) -> i8 - %4 = "llvm.trunc"(%arg0) : (i16) -> i8 - %5 = "llvm.ashr"(%4, %0) : (i8, i8) -> i8 - %6 = "llvm.icmp"(%5, %3) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.call"(%3) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "extrause_l", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 8 : i16} : () -> i16 - %2 = "llvm.lshr"(%arg0, %1) : (i16, i16) -> i16 - %3 = "llvm.trunc"(%2) : (i16) -> i8 - %4 = "llvm.trunc"(%arg0) : (i16) -> i8 - %5 = "llvm.ashr"(%4, %0) : (i8, i8) -> i8 - %6 = "llvm.icmp"(%5, %3) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.call"(%5) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - "llvm.call"(%3) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "extrause_la", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @use16(i16) + llvm.func @testi16i8(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i16 + %3 = llvm.trunc %2 : i16 to i8 + %4 = llvm.trunc %arg0 : i16 to i8 + %5 = llvm.ashr %4, %1 : i8 + %6 = llvm.icmp "eq" %5, %3 : i8 + llvm.return %6 : i1 + } + llvm.func @testi16i8_com(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i16 + %3 = llvm.trunc %2 : i16 to i8 + %4 = llvm.trunc %arg0 : i16 to i8 + %5 = llvm.ashr %4, %1 : i8 + %6 = llvm.icmp "eq" %3, %5 : i8 + llvm.return %6 : i1 + } + llvm.func @testi16i8_ne(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i16 + %3 = llvm.trunc %2 : i16 to i8 + %4 = llvm.trunc %arg0 : i16 to i8 + %5 = llvm.ashr %4, %1 : i8 + %6 = llvm.icmp "ne" %5, %3 : i8 + llvm.return %6 : i1 + } + llvm.func @testi16i8_ne_com(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i16 + %3 = llvm.trunc %2 : i16 to i8 + %4 = llvm.trunc %arg0 : i16 to i8 + %5 = llvm.ashr %4, %1 : i8 + %6 = llvm.icmp "ne" %3, %5 : i8 + llvm.return %6 : i1 + } + llvm.func @testi64i32(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.trunc %arg0 : i64 to i32 + %5 = llvm.ashr %4, %1 : i32 + %6 = llvm.icmp "eq" %5, %3 : i32 + llvm.return %6 : i1 + } + llvm.func @testi64i32_ne(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.trunc %arg0 : i64 to i32 + %5 = llvm.ashr %4, %1 : i32 + %6 = llvm.icmp "ne" %5, %3 : i32 + llvm.return %6 : i1 + } + llvm.func @testi32i8(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.trunc %arg0 : i32 to i8 + %5 = llvm.ashr %4, %1 : i8 + %6 = llvm.icmp "eq" %5, %3 : i8 + llvm.return %6 : i1 + } + llvm.func @wrongimm1(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(7 : i16) : i16 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i16 + %3 = llvm.trunc %2 : i16 to i8 + %4 = llvm.trunc %arg0 : i16 to i8 + %5 = llvm.ashr %4, %1 : i8 + %6 = llvm.icmp "eq" %5, %3 : i8 + llvm.return %6 : i1 + } + llvm.func @wrongimm2(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i16 + %3 = llvm.trunc %2 : i16 to i8 + %4 = llvm.trunc %arg0 : i16 to i8 + %5 = llvm.ashr %4, %1 : i8 + %6 = llvm.icmp "eq" %5, %3 : i8 + llvm.return %6 : i1 + } + llvm.func @slt(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.trunc %arg0 : i64 to i32 + %5 = llvm.ashr %4, %1 : i32 + %6 = llvm.icmp "slt" %5, %3 : i32 + llvm.return %6 : i1 + } + llvm.func @extrause_a(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i16 + %3 = llvm.trunc %2 : i16 to i8 + %4 = llvm.trunc %arg0 : i16 to i8 + %5 = llvm.ashr %4, %1 : i8 + %6 = llvm.icmp "eq" %5, %3 : i8 + llvm.call @use(%5) : (i8) -> () + llvm.return %6 : i1 + } + llvm.func @extrause_l(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i16 + %3 = llvm.trunc %2 : i16 to i8 + %4 = llvm.trunc %arg0 : i16 to i8 + %5 = llvm.ashr %4, %1 : i8 + %6 = llvm.icmp "eq" %5, %3 : i8 + llvm.call @use(%3) : (i8) -> () + llvm.return %6 : i1 + } + llvm.func @extrause_la(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i16 + %3 = llvm.trunc %2 : i16 to i8 + %4 = llvm.trunc %arg0 : i16 to i8 + %5 = llvm.ashr %4, %1 : i8 + %6 = llvm.icmp "eq" %5, %3 : i8 + llvm.call @use(%5) : (i8) -> () + llvm.call @use(%3) : (i8) -> () + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-trunc.ll.mlir b/test/LLVMDialect/InstCombine/icmp-trunc.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/icmp-uadd-sat.ll.mlir b/test/LLVMDialect/InstCombine/icmp-uadd-sat.ll.mlir new file mode 100644 index 000000000..dfd622f1c --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-uadd-sat.ll.mlir @@ -0,0 +1,146 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @icmp_eq_basic(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.intr.uadd.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_ne_basic(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(9 : i16) : i16 + %2 = llvm.intr.uadd.sat(%arg0, %0) : (i16, i16) -> i16 + %3 = llvm.icmp "ne" %2, %1 : i16 + llvm.return %3 : i1 + } + llvm.func @icmp_ule_basic(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.intr.uadd.sat(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.icmp "ule" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_ult_basic(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(5 : i64) : i64 + %1 = llvm.mlir.constant(20 : i64) : i64 + %2 = llvm.intr.uadd.sat(%arg0, %0) : (i64, i64) -> i64 + %3 = llvm.icmp "ult" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @icmp_uge_basic(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(8 : i8) : i8 + %2 = llvm.intr.uadd.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.icmp "uge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_ugt_basic(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.constant(3 : i16) : i16 + %2 = llvm.intr.uadd.sat(%arg0, %0) : (i16, i16) -> i16 + %3 = llvm.icmp "ugt" %2, %1 : i16 + llvm.return %3 : i1 + } + llvm.func @icmp_sle_basic(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.intr.uadd.sat(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.icmp "sle" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_slt_basic(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(24 : i64) : i64 + %1 = llvm.mlir.constant(5 : i64) : i64 + %2 = llvm.intr.uadd.sat(%arg0, %0) : (i64, i64) -> i64 + %3 = llvm.icmp "slt" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @icmp_sge_basic(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.intr.uadd.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.icmp "sge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt_basic(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(2 : i16) : i16 + %1 = llvm.mlir.constant(5 : i16) : i16 + %2 = llvm.intr.uadd.sat(%arg0, %0) : (i16, i16) -> i16 + %3 = llvm.icmp "sgt" %2, %1 : i16 + llvm.return %3 : i1 + } + llvm.func @icmp_eq_multiuse(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.intr.uadd.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.call @use.i8(%2) : (i8) -> () + llvm.return %3 : i1 + } + llvm.func @icmp_eq_vector_equal(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.uadd.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_eq_vector_unequal(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[5, 6]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.uadd.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_ne_vector_equal(%arg0: vector<2xi16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<5> : vector<2xi16>) : vector<2xi16> + %2 = llvm.intr.uadd.sat(%arg0, %0) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_ne_vector_unequal(%arg0: vector<2xi16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 33]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<[7, 6]> : vector<2xi16>) : vector<2xi16> + %2 = llvm.intr.uadd.sat(%arg0, %0) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_ule_vector_equal(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.uadd.sat(%arg0, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + %3 = llvm.icmp "ult" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_ule_vector_unequal(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 35]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[5, 7]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.uadd.sat(%arg0, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + %3 = llvm.icmp "ult" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_sgt_vector_equal(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<409623> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<1234> : vector<2xi64>) : vector<2xi64> + %2 = llvm.intr.uadd.sat(%arg0, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> + %3 = llvm.icmp "sgt" %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_sgt_vector_unequal(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[320498, 409623]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<[1234, 3456]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.intr.uadd.sat(%arg0, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> + %3 = llvm.icmp "sgt" %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_eq_vector_multiuse_equal(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.uadd.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi8> + llvm.call @use.v2i8(%2) : (vector<2xi8>) -> () + llvm.return %3 : vector<2xi1> + } + llvm.func @use.i8(i8) + llvm.func @use.v2i8(vector<2xi8>) +} diff --git a/test/LLVMDialect/InstCombine/icmp-uge-of-add-of-shl-one-by-bits-to-allones-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir b/test/LLVMDialect/InstCombine/icmp-uge-of-add-of-shl-one-by-bits-to-allones-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir new file mode 100644 index 000000000..10a9e877a --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-uge-of-add-of-shl-one-by-bits-to-allones-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir @@ -0,0 +1,184 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use2i8(vector<2xi8>) + llvm.func @use3i8(vector<3xi8>) + llvm.func @p0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.icmp "uge" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @p1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg1 : vector<2xi8> + llvm.call @use2i8(%2) : (vector<2xi8>) -> () + %3 = llvm.add %2, %1 : vector<2xi8> + %4 = llvm.icmp "uge" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @p2_vec_undef0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %10 = llvm.shl %8, %arg1 : vector<3xi8> + llvm.call @use3i8(%10) : (vector<3xi8>) -> () + %11 = llvm.add %10, %9 : vector<3xi8> + %12 = llvm.icmp "uge" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @p2_vec_poison0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %10 = llvm.shl %8, %arg1 : vector<3xi8> + llvm.call @use3i8(%10) : (vector<3xi8>) -> () + %11 = llvm.add %10, %9 : vector<3xi8> + %12 = llvm.icmp "uge" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @p2_vec_poison1(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.shl %0, %arg1 : vector<3xi8> + llvm.call @use3i8(%10) : (vector<3xi8>) -> () + %11 = llvm.add %10, %9 : vector<3xi8> + %12 = llvm.icmp "uge" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @p2_vec_poison2(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(-1 : i8) : i8 + %10 = llvm.mlir.undef : vector<3xi8> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi8> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi8> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi8> + %17 = llvm.shl %8, %arg1 : vector<3xi8> + llvm.call @use3i8(%17) : (vector<3xi8>) -> () + %18 = llvm.add %17, %16 : vector<3xi8> + %19 = llvm.icmp "uge" %18, %arg0 : vector<3xi8> + llvm.return %19 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.call @gen8() : () -> i8 + %5 = llvm.icmp "ule" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @both(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.add %4, %1 : i8 + %6 = llvm.icmp "uge" %3, %5 : i8 + llvm.return %6 : i1 + } + llvm.func @oneuse(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "uge" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.add %1, %0 : i8 + %3 = llvm.icmp "uge" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.add %1, %0 : i8 + %3 = llvm.icmp "uge" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n2_vec_nonsplat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, -1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg1 : vector<2xi8> + llvm.call @use2i8(%2) : (vector<2xi8>) -> () + %3 = llvm.add %2, %1 : vector<2xi8> + %4 = llvm.icmp "uge" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @n3_vec_nonsplat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-1, 1]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg1 : vector<2xi8> + llvm.call @use2i8(%2) : (vector<2xi8>) -> () + %3 = llvm.add %2, %1 : vector<2xi8> + %4 = llvm.icmp "uge" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @n3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.icmp "ugt" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.call @gen8() : () -> i8 + %5 = llvm.icmp "ult" %4, %3 : i8 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-uge-of-not-of-shl-allones-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir b/test/LLVMDialect/InstCombine/icmp-uge-of-not-of-shl-allones-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir new file mode 100644 index 000000000..88e6e8fa0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-uge-of-not-of-shl-allones-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir @@ -0,0 +1,154 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.icmp "uge" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @p1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %0, %arg1 : vector<2xi8> + %2 = llvm.xor %1, %0 : vector<2xi8> + %3 = llvm.icmp "uge" %2, %arg0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_poison0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %10 = llvm.shl %8, %arg1 : vector<3xi8> + %11 = llvm.xor %10, %9 : vector<3xi8> + %12 = llvm.icmp "uge" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @p2_vec_poison1(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.shl %0, %arg1 : vector<3xi8> + %11 = llvm.xor %10, %9 : vector<3xi8> + %12 = llvm.icmp "uge" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @p2_vec_poison2(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.shl %8, %arg1 : vector<3xi8> + %10 = llvm.xor %9, %8 : vector<3xi8> + %11 = llvm.icmp "uge" %10, %arg0 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.icmp "ule" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @both(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.shl %0, %arg1 : i8 + %4 = llvm.xor %3, %0 : i8 + %5 = llvm.icmp "uge" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @use8(i8) + llvm.func @oneuse0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.icmp "uge" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @oneuse1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "uge" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @oneuse2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "uge" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.icmp "uge" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.icmp "uge" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n2_vec_nonsplat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-1, 1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg1 : vector<2xi8> + %3 = llvm.xor %2, %1 : vector<2xi8> + %4 = llvm.icmp "uge" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @n3_vec_nonsplat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-1, 1]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg1 : vector<2xi8> + %3 = llvm.xor %2, %1 : vector<2xi8> + %4 = llvm.icmp "uge" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @n3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.icmp "ugt" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.icmp "ult" %3, %2 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-ugt-of-shl-1-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir b/test/LLVMDialect/InstCombine/icmp-ugt-of-shl-1-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir new file mode 100644 index 000000000..5f6ad2691 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-ugt-of-shl-1-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll.mlir @@ -0,0 +1,76 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.icmp "ugt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @p1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %0, %arg1 : vector<2xi8> + %2 = llvm.icmp "ugt" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_poison(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.shl %8, %arg1 : vector<3xi8> + %10 = llvm.icmp "ugt" %9, %arg0 : vector<3xi8> + llvm.return %10 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @both(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.icmp "ugt" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @use8(i8) + llvm.func @oneuse0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ugt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.icmp "ugt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n1_vec_nonsplat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %0, %arg1 : vector<2xi8> + %2 = llvm.icmp "ugt" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @n2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.icmp "uge" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.icmp "ule" %2, %1 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-ule-of-shl-1-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir b/test/LLVMDialect/InstCombine/icmp-ule-of-shl-1-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir new file mode 100644 index 000000000..ccd9789a1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-ule-of-shl-1-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir @@ -0,0 +1,76 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.icmp "ule" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @p1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %0, %arg1 : vector<2xi8> + %2 = llvm.icmp "ule" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @p2_vec_poison(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.shl %8, %arg1 : vector<3xi8> + %10 = llvm.icmp "ule" %9, %arg0 : vector<3xi8> + llvm.return %10 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.icmp "uge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @both(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.icmp "ule" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @use8(i8) + llvm.func @oneuse0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ule" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.icmp "ule" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n1_vec_nonsplat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %0, %arg1 : vector<2xi8> + %2 = llvm.icmp "ule" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @n2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.icmp "ult" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-ult-of-add-of-shl-one-by-bits-to-allones-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir b/test/LLVMDialect/InstCombine/icmp-ult-of-add-of-shl-one-by-bits-to-allones-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir new file mode 100644 index 000000000..9ddda59c6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-ult-of-add-of-shl-one-by-bits-to-allones-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir @@ -0,0 +1,184 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use2i8(vector<2xi8>) + llvm.func @use3i8(vector<3xi8>) + llvm.func @p0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.icmp "ult" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @p1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg1 : vector<2xi8> + llvm.call @use2i8(%2) : (vector<2xi8>) -> () + %3 = llvm.add %2, %1 : vector<2xi8> + %4 = llvm.icmp "ult" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @p2_vec_undef0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %10 = llvm.shl %8, %arg1 : vector<3xi8> + llvm.call @use3i8(%10) : (vector<3xi8>) -> () + %11 = llvm.add %10, %9 : vector<3xi8> + %12 = llvm.icmp "ult" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @p2_vec_poison0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %10 = llvm.shl %8, %arg1 : vector<3xi8> + llvm.call @use3i8(%10) : (vector<3xi8>) -> () + %11 = llvm.add %10, %9 : vector<3xi8> + %12 = llvm.icmp "ult" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @p2_vec_poison1(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.shl %0, %arg1 : vector<3xi8> + llvm.call @use3i8(%10) : (vector<3xi8>) -> () + %11 = llvm.add %10, %9 : vector<3xi8> + %12 = llvm.icmp "ult" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @p2_vec_poison2(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(-1 : i8) : i8 + %10 = llvm.mlir.undef : vector<3xi8> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi8> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi8> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi8> + %17 = llvm.shl %8, %arg1 : vector<3xi8> + llvm.call @use3i8(%17) : (vector<3xi8>) -> () + %18 = llvm.add %17, %16 : vector<3xi8> + %19 = llvm.icmp "ult" %18, %arg0 : vector<3xi8> + llvm.return %19 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.call @gen8() : () -> i8 + %5 = llvm.icmp "ugt" %4, %3 : i8 + llvm.return %5 : i1 + } + llvm.func @both(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.add %4, %1 : i8 + %6 = llvm.icmp "ult" %3, %5 : i8 + llvm.return %6 : i1 + } + llvm.func @oneuse(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ult" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.add %1, %0 : i8 + %3 = llvm.icmp "ult" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.add %1, %0 : i8 + %3 = llvm.icmp "ult" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n2_vec_nonsplat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, -1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg1 : vector<2xi8> + llvm.call @use2i8(%2) : (vector<2xi8>) -> () + %3 = llvm.add %2, %1 : vector<2xi8> + %4 = llvm.icmp "ult" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @n3_vec_nonsplat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-1, 1]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg1 : vector<2xi8> + llvm.call @use2i8(%2) : (vector<2xi8>) -> () + %3 = llvm.add %2, %1 : vector<2xi8> + %4 = llvm.icmp "ult" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @n3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.icmp "ule" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %2, %1 : i8 + %4 = llvm.call @gen8() : () -> i8 + %5 = llvm.icmp "uge" %4, %3 : i8 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-ult-of-not-of-shl-allones-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir b/test/LLVMDialect/InstCombine/icmp-ult-of-not-of-shl-allones-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir new file mode 100644 index 000000000..52cb20bd3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-ult-of-not-of-shl-allones-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll.mlir @@ -0,0 +1,154 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.icmp "ult" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @p1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %0, %arg1 : vector<2xi8> + %2 = llvm.xor %1, %0 : vector<2xi8> + %3 = llvm.icmp "ult" %2, %arg0 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @p2_vec_poison0(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %10 = llvm.shl %8, %arg1 : vector<3xi8> + %11 = llvm.xor %10, %9 : vector<3xi8> + %12 = llvm.icmp "ult" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @p2_vec_poison1(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.shl %0, %arg1 : vector<3xi8> + %11 = llvm.xor %10, %9 : vector<3xi8> + %12 = llvm.icmp "ult" %11, %arg0 : vector<3xi8> + llvm.return %12 : vector<3xi1> + } + llvm.func @p2_vec_poison2(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.shl %8, %arg1 : vector<3xi8> + %10 = llvm.xor %9, %8 : vector<3xi8> + %11 = llvm.icmp "ult" %10, %arg0 : vector<3xi8> + llvm.return %11 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @c0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.icmp "ugt" %3, %2 : i8 + llvm.return %4 : i1 + } + llvm.func @both(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.shl %0, %arg1 : i8 + %4 = llvm.xor %3, %0 : i8 + %5 = llvm.icmp "ult" %2, %4 : i8 + llvm.return %5 : i1 + } + llvm.func @use8(i8) + llvm.func @oneuse0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.icmp "ult" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @oneuse1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ult" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @oneuse2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ult" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.icmp "ult" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.icmp "ult" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @n2_vec_nonsplat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-1, 1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg1 : vector<2xi8> + %3 = llvm.xor %2, %1 : vector<2xi8> + %4 = llvm.icmp "ult" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @n3_vec_nonsplat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-1, 1]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg1 : vector<2xi8> + %3 = llvm.xor %2, %1 : vector<2xi8> + %4 = llvm.icmp "ult" %3, %arg0 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @n3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.icmp "ule" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @n4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.call @gen8() : () -> i8 + %4 = llvm.icmp "uge" %3, %2 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-usub-sat.ll.mlir b/test/LLVMDialect/InstCombine/icmp-usub-sat.ll.mlir new file mode 100644 index 000000000..19437fc84 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-usub-sat.ll.mlir @@ -0,0 +1,245 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @icmp_eq_basic_positive(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_ne_basic_positive(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(9 : i16) : i16 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i16, i16) -> i16 + %3 = llvm.icmp "ne" %2, %1 : i16 + llvm.return %3 : i1 + } + llvm.func @icmp_ule_basic_positive(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.icmp "ule" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_ult_basic_positive(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(5 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i64, i64) -> i64 + %3 = llvm.icmp "ult" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @icmp_uge_basic_positive(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.intr.usub.sat(%arg0, %0) : (i8, i8) -> i8 + %2 = llvm.icmp "uge" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @icmp_ugt_basic_positive(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.constant(3 : i16) : i16 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i16, i16) -> i16 + %3 = llvm.icmp "ugt" %2, %1 : i16 + llvm.return %3 : i1 + } + llvm.func @icmp_sle_basic_positive(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.icmp "sle" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_slt_basic_positive(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(24 : i64) : i64 + %1 = llvm.mlir.constant(5 : i64) : i64 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i64, i64) -> i64 + %3 = llvm.icmp "slt" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @icmp_sge_basic_positive(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.icmp "sge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt_basic_positive(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(2 : i16) : i16 + %1 = llvm.mlir.constant(5 : i16) : i16 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i16, i16) -> i16 + %3 = llvm.icmp "sgt" %2, %1 : i16 + llvm.return %3 : i1 + } + llvm.func @icmp_eq_basic_negative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-20 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_ne_basic_negative(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(-80 : i16) : i16 + %1 = llvm.mlir.constant(9 : i16) : i16 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i16, i16) -> i16 + %3 = llvm.icmp "ne" %2, %1 : i16 + llvm.return %3 : i1 + } + llvm.func @icmp_ule_basic_negative(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-6 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.icmp "ule" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_ult_basic_negative(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(-10 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i64, i64) -> i64 + %3 = llvm.icmp "ult" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @icmp_uge_basic_negative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-4 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.icmp "uge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_ugt_basic_negative(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(-10 : i16) : i16 + %1 = llvm.mlir.constant(3 : i16) : i16 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i16, i16) -> i16 + %3 = llvm.icmp "ugt" %2, %1 : i16 + llvm.return %3 : i1 + } + llvm.func @icmp_sle_basic_negative(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-10 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.icmp "sle" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @icmp_slt_basic_negative(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(-24 : i64) : i64 + %1 = llvm.mlir.constant(5 : i64) : i64 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i64, i64) -> i64 + %3 = llvm.icmp "slt" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @icmp_sge_basic_negative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-10 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.icmp "sge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @icmp_sgt_basic_negative(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(-20 : i16) : i16 + %1 = llvm.mlir.constant(5 : i16) : i16 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i16, i16) -> i16 + %3 = llvm.icmp "sgt" %2, %1 : i16 + llvm.return %3 : i1 + } + llvm.func @icmp_eq_multiuse_positive(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.call @use.i8(%2) : (i8) -> () + llvm.return %3 : i1 + } + llvm.func @icmp_eq_multiuse_negative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.call @use.i8(%2) : (i8) -> () + llvm.return %3 : i1 + } + llvm.func @icmp_eq_vector_positive_equal(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_eq_vector_positive_unequal(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[5, 6]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_ne_vector_positive_equal(%arg0: vector<2xi16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<5> : vector<2xi16>) : vector<2xi16> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_ne_vector_positive_unequal(%arg0: vector<2xi16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 33]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<[7, 6]> : vector<2xi16>) : vector<2xi16> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> + %3 = llvm.icmp "ne" %2, %1 : vector<2xi16> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_ule_vector_positive_equal(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + %3 = llvm.icmp "ult" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_ule_vector_positive_unequal(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[3, 35]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[5, 7]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + %3 = llvm.icmp "ult" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_sgt_vector_positive_equal(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<409623> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<1234> : vector<2xi64>) : vector<2xi64> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> + %3 = llvm.icmp "sgt" %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_sgt_vector_positive_unequal(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[320498, 409623]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<[1234, 3456]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> + %3 = llvm.icmp "sgt" %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_eq_vector_negative_equal(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_eq_vector_negative_unequal(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-10, -20]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[5, 6]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_eq_vector_multiuse_positive_equal(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi8> + llvm.call @use.v2i8(%2) : (vector<2xi8>) -> () + llvm.return %3 : vector<2xi1> + } + llvm.func @icmp_eq_vector_multiuse_negative_equal(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-20> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi8> + llvm.call @use.v2i8(%2) : (vector<2xi8>) -> () + llvm.return %3 : vector<2xi1> + } + llvm.func @use.i8(i8) + llvm.func @use.v2i8(vector<2xi8>) +} diff --git a/test/LLVMDialect/InstCombine/icmp-vec-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/icmp-vec-inseltpoison.ll.mlir new file mode 100644 index 000000000..2d7b419ac --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-vec-inseltpoison.ll.mlir @@ -0,0 +1,283 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @someglobal(0 : i32) {addr_space = 0 : i32} : i32 + llvm.func @sge(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-127, 127]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.icmp "sge" %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi1> + } + llvm.func @uge(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-1, 1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.icmp "uge" %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi1> + } + llvm.func @sle(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[126, -128]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.icmp "sle" %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi1> + } + llvm.func @ule(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-2, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.icmp "ule" %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi1> + } + llvm.func @ult_min_signed_value(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.icmp "ult" %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi1> + } + llvm.func @sge_zero(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.icmp "sge" %arg0, %1 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @uge_zero(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.icmp "uge" %arg0, %1 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @sle_zero(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.icmp "sle" %arg0, %1 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @ule_zero(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.icmp "ule" %arg0, %1 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @sge_weird(%arg0: vector<3xi3>) -> vector<3xi1> { + %0 = llvm.mlir.constant(0 : i3) : i3 + %1 = llvm.mlir.constant(3 : i3) : i3 + %2 = llvm.mlir.constant(-3 : i3) : i3 + %3 = llvm.mlir.constant(dense<[-3, 3, 0]> : vector<3xi3>) : vector<3xi3> + %4 = llvm.icmp "sge" %arg0, %3 : vector<3xi3> + llvm.return %4 : vector<3xi1> + } + llvm.func @uge_weird(%arg0: vector<3xi3>) -> vector<3xi1> { + %0 = llvm.mlir.constant(2 : i3) : i3 + %1 = llvm.mlir.constant(1 : i3) : i3 + %2 = llvm.mlir.constant(-1 : i3) : i3 + %3 = llvm.mlir.constant(dense<[-1, 1, 2]> : vector<3xi3>) : vector<3xi3> + %4 = llvm.icmp "uge" %arg0, %3 : vector<3xi3> + llvm.return %4 : vector<3xi1> + } + llvm.func @sle_weird(%arg0: vector<3xi3>) -> vector<3xi1> { + %0 = llvm.mlir.constant(0 : i3) : i3 + %1 = llvm.mlir.constant(-4 : i3) : i3 + %2 = llvm.mlir.constant(2 : i3) : i3 + %3 = llvm.mlir.constant(dense<[2, -4, 0]> : vector<3xi3>) : vector<3xi3> + %4 = llvm.icmp "sle" %arg0, %3 : vector<3xi3> + llvm.return %4 : vector<3xi1> + } + llvm.func @ule_weird(%arg0: vector<3xi3>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i3) : i3 + %1 = llvm.mlir.constant(0 : i3) : i3 + %2 = llvm.mlir.constant(-2 : i3) : i3 + %3 = llvm.mlir.constant(dense<[-2, 0, 1]> : vector<3xi3>) : vector<3xi3> + %4 = llvm.icmp "ule" %arg0, %3 : vector<3xi3> + llvm.return %4 : vector<3xi1> + } + llvm.func @sge_min(%arg0: vector<2xi3>) -> vector<2xi1> { + %0 = llvm.mlir.constant(1 : i3) : i3 + %1 = llvm.mlir.constant(-4 : i3) : i3 + %2 = llvm.mlir.constant(dense<[-4, 1]> : vector<2xi3>) : vector<2xi3> + %3 = llvm.icmp "sge" %arg0, %2 : vector<2xi3> + llvm.return %3 : vector<2xi1> + } + llvm.func @uge_min(%arg0: vector<2xi3>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i3) : i3 + %1 = llvm.mlir.constant(1 : i3) : i3 + %2 = llvm.mlir.constant(dense<[1, 0]> : vector<2xi3>) : vector<2xi3> + %3 = llvm.icmp "uge" %arg0, %2 : vector<2xi3> + llvm.return %3 : vector<2xi1> + } + llvm.func @sle_max(%arg0: vector<2xi3>) -> vector<2xi1> { + %0 = llvm.mlir.constant(3 : i3) : i3 + %1 = llvm.mlir.constant(1 : i3) : i3 + %2 = llvm.mlir.constant(dense<[1, 3]> : vector<2xi3>) : vector<2xi3> + %3 = llvm.icmp "sle" %arg0, %2 : vector<2xi3> + llvm.return %3 : vector<2xi1> + } + llvm.func @ule_max(%arg0: vector<2xi3>) -> vector<2xi1> { + %0 = llvm.mlir.constant(1 : i3) : i3 + %1 = llvm.mlir.constant(-1 : i3) : i3 + %2 = llvm.mlir.constant(dense<[-1, 1]> : vector<2xi3>) : vector<2xi3> + %3 = llvm.icmp "ule" %arg0, %2 : vector<2xi3> + llvm.return %3 : vector<2xi1> + } + llvm.func @PR27756_1(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.mlir.constant(1 : i4) : i4 + %3 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi4>) : vector<2xi4> + %4 = llvm.bitcast %3 : vector<2xi4> to i8 + %5 = llvm.mlir.undef : vector<2xi8> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %4, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<2xi8> + %10 = llvm.icmp "sle" %arg0, %9 : vector<2xi8> + llvm.return %10 : vector<2xi1> + } + llvm.func @PR27756_2(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(42 : i8) : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi8> + %10 = llvm.icmp "sle" %arg0, %9 : vector<3xi8> + llvm.return %10 : vector<3xi1> + } + llvm.func @PR27756_3(%arg0: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi8> + %10 = llvm.icmp "sge" %arg0, %9 : vector<3xi8> + llvm.return %10 : vector<3xi1> + } + llvm.func @PR27786(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @someglobal : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i16 + %3 = llvm.bitcast %2 : i16 to vector<2xi8> + %4 = llvm.icmp "sle" %arg0, %3 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @same_shuffle_inputs_icmp(%arg0: vector<4xi8>, %arg1: vector<4xi8>) -> vector<4xi1> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.shufflevector %arg0, %0 [3, 3, 2, 0] : vector<4xi8> + %2 = llvm.shufflevector %arg1, %0 [3, 3, 2, 0] : vector<4xi8> + %3 = llvm.icmp "sgt" %1, %2 : vector<4xi8> + llvm.return %3 : vector<4xi1> + } + llvm.func @same_shuffle_inputs_fcmp(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<5xi1> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.shufflevector %arg0, %0 [0, 1, 3, 2, 0] : vector<4xf32> + %2 = llvm.shufflevector %arg1, %0 [0, 1, 3, 2, 0] : vector<4xf32> + %3 = llvm.fcmp "oeq" %1, %2 : vector<5xf32> + llvm.return %3 : vector<5xi1> + } + llvm.func @use_v4i8(vector<4xi8>) + llvm.func @same_shuffle_inputs_icmp_extra_use1(%arg0: vector<4xi8>, %arg1: vector<4xi8>) -> vector<4xi1> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.shufflevector %arg0, %0 [3, 3, 3, 3] : vector<4xi8> + %2 = llvm.shufflevector %arg1, %0 [3, 3, 3, 3] : vector<4xi8> + %3 = llvm.icmp "ugt" %1, %2 : vector<4xi8> + llvm.call @use_v4i8(%1) : (vector<4xi8>) -> () + llvm.return %3 : vector<4xi1> + } + llvm.func @use_v2i8(vector<2xi8>) + llvm.func @same_shuffle_inputs_icmp_extra_use2(%arg0: vector<4xi8>, %arg1: vector<4xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.shufflevector %arg0, %0 [3, 2] : vector<4xi8> + %2 = llvm.shufflevector %arg1, %0 [3, 2] : vector<4xi8> + %3 = llvm.icmp "eq" %1, %2 : vector<2xi8> + llvm.call @use_v2i8(%2) : (vector<2xi8>) -> () + llvm.return %3 : vector<2xi1> + } + llvm.func @same_shuffle_inputs_icmp_extra_use3(%arg0: vector<4xi8>, %arg1: vector<4xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.shufflevector %arg0, %0 [0, 0] : vector<4xi8> + %2 = llvm.shufflevector %arg1, %0 [0, 0] : vector<4xi8> + %3 = llvm.icmp "eq" %1, %2 : vector<2xi8> + llvm.call @use_v2i8(%1) : (vector<2xi8>) -> () + llvm.call @use_v2i8(%2) : (vector<2xi8>) -> () + llvm.return %3 : vector<2xi1> + } + llvm.func @splat_icmp(%arg0: vector<4xi8>) -> vector<4xi1> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(dense<42> : vector<4xi8>) : vector<4xi8> + %2 = llvm.shufflevector %arg0, %0 [3, 3, 3, 3] : vector<4xi8> + %3 = llvm.icmp "sgt" %2, %1 : vector<4xi8> + llvm.return %3 : vector<4xi1> + } + llvm.func @splat_icmp_poison(%arg0: vector<4xi8>) -> vector<4xi1> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(42 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<4xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %2, %7[%8 : i32] : vector<4xi8> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<4xi8> + %12 = llvm.shufflevector %arg0, %0 [2, -1, -1, 2] : vector<4xi8> + %13 = llvm.icmp "ult" %12, %11 : vector<4xi8> + llvm.return %13 : vector<4xi1> + } + llvm.func @splat_icmp_larger_size(%arg0: vector<2xi8>) -> vector<4xi1> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(42 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<4xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<4xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %2, %7[%8 : i32] : vector<4xi8> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<4xi8> + %12 = llvm.shufflevector %arg0, %0 [1, -1, 1, -1] : vector<2xi8> + %13 = llvm.icmp "eq" %12, %11 : vector<4xi8> + llvm.return %13 : vector<4xi1> + } + llvm.func @splat_fcmp_smaller_size(%arg0: vector<5xf32>) -> vector<4xi1> { + %0 = llvm.mlir.poison : vector<5xf32> + %1 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %2 = llvm.mlir.poison : f32 + %3 = llvm.mlir.undef : vector<4xf32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<4xf32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xf32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %2, %7[%8 : i32] : vector<4xf32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<4xf32> + %12 = llvm.shufflevector %arg0, %0 [1, -1, 1, -1] : vector<5xf32> + %13 = llvm.fcmp "oeq" %12, %11 : vector<4xf32> + llvm.return %13 : vector<4xi1> + } + llvm.func @splat_icmp_extra_use(%arg0: vector<4xi8>) -> vector<4xi1> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(dense<42> : vector<4xi8>) : vector<4xi8> + %2 = llvm.shufflevector %arg0, %0 [3, 3, 3, 3] : vector<4xi8> + llvm.call @use_v4i8(%2) : (vector<4xi8>) -> () + %3 = llvm.icmp "sgt" %2, %1 : vector<4xi8> + llvm.return %3 : vector<4xi1> + } + llvm.func @not_splat_icmp(%arg0: vector<4xi8>) -> vector<4xi1> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(dense<42> : vector<4xi8>) : vector<4xi8> + %2 = llvm.shufflevector %arg0, %0 [3, 2, 3, 3] : vector<4xi8> + %3 = llvm.icmp "sgt" %2, %1 : vector<4xi8> + llvm.return %3 : vector<4xi1> + } + llvm.func @not_splat_icmp2(%arg0: vector<4xi8>) -> vector<4xi1> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(dense<[43, 42, 42, 42]> : vector<4xi8>) : vector<4xi8> + %2 = llvm.shufflevector %arg0, %0 [2, 2, 2, 2] : vector<4xi8> + %3 = llvm.icmp "sgt" %2, %1 : vector<4xi8> + llvm.return %3 : vector<4xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-vec.ll.mlir b/test/LLVMDialect/InstCombine/icmp-vec.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/icmp-vscale.ll.mlir b/test/LLVMDialect/InstCombine/icmp-vscale.ll.mlir new file mode 100644 index 000000000..42ee66129 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-vscale.ll.mlir @@ -0,0 +1,118 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @ugt_vscale64_x_32() -> i1 vscale_range(1, 16) { + %0 = llvm.mlir.constant(5 : i64) : i64 + %1 = llvm.mlir.constant(1024 : i64) : i64 + %2 = "llvm.intr.vscale"() : () -> i64 + %3 = llvm.shl %2, %0 : i64 + %4 = llvm.icmp "ugt" %3, %1 : i64 + llvm.return %4 : i1 + } + llvm.func @ugt_vscale64_x_31() -> i1 vscale_range(1, 16) { + %0 = llvm.mlir.constant(31 : i64) : i64 + %1 = llvm.mlir.constant(1024 : i64) : i64 + %2 = "llvm.intr.vscale"() : () -> i64 + %3 = llvm.mul %2, %0 : i64 + %4 = llvm.icmp "ugt" %3, %1 : i64 + llvm.return %4 : i1 + } + llvm.func @ugt_vscale16_x_32() -> i1 vscale_range(1, 16) { + %0 = llvm.mlir.constant(5 : i16) : i16 + %1 = llvm.mlir.constant(1024 : i16) : i16 + %2 = "llvm.intr.vscale"() : () -> i16 + %3 = llvm.shl %2, %0 : i16 + %4 = llvm.icmp "ugt" %3, %1 : i16 + llvm.return %4 : i1 + } + llvm.func @ult_vscale16() -> i1 vscale_range(1, 16) { + %0 = llvm.mlir.constant(1024 : i16) : i16 + %1 = "llvm.intr.vscale"() : () -> i16 + %2 = llvm.icmp "ult" %0, %1 : i16 + llvm.return %2 : i1 + } + llvm.func @ule_vscale64() -> i1 vscale_range(1, 16) { + %0 = llvm.mlir.constant(1024 : i64) : i64 + %1 = "llvm.intr.vscale"() : () -> i64 + %2 = llvm.icmp "ule" %0, %1 : i64 + llvm.return %2 : i1 + } + llvm.func @ueq_vscale64_range4_4() -> i1 vscale_range(4, 4) { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = "llvm.intr.vscale"() : () -> i64 + %2 = llvm.icmp "eq" %1, %0 : i64 + llvm.return %2 : i1 + } + llvm.func @ne_vscale64_x_32() -> i1 vscale_range(1, 16) { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(39488 : i64) : i64 + %2 = "llvm.intr.vscale"() : () -> i64 + %3 = llvm.mul %2, %0 : i64 + %4 = llvm.icmp "ne" %3, %1 : i64 + llvm.return %4 : i1 + } + llvm.func @vscale_ule_max() -> i1 vscale_range(4, 8) { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = "llvm.intr.vscale"() : () -> i16 + %2 = llvm.icmp "ule" %1, %0 : i16 + llvm.return %2 : i1 + } + llvm.func @vscale_ult_max() -> i1 vscale_range(4, 8) { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = "llvm.intr.vscale"() : () -> i16 + %2 = llvm.icmp "ult" %1, %0 : i16 + llvm.return %2 : i1 + } + llvm.func @vscale_uge_min() -> i1 vscale_range(4, 8) { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = "llvm.intr.vscale"() : () -> i16 + %2 = llvm.icmp "uge" %1, %0 : i16 + llvm.return %2 : i1 + } + llvm.func @vscale_ugt_min() -> i1 vscale_range(4, 8) { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = "llvm.intr.vscale"() : () -> i16 + %2 = llvm.icmp "ugt" %1, %0 : i16 + llvm.return %2 : i1 + } + llvm.func @vscale_uge_no_max() -> i1 vscale_range(4, 4) { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = "llvm.intr.vscale"() : () -> i8 + %2 = llvm.icmp "uge" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @vscale_ugt_no_max() -> i1 vscale_range(4, 4) { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = "llvm.intr.vscale"() : () -> i8 + %2 = llvm.icmp "ugt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @vscale_uge_max_overflow() -> i1 vscale_range(4, 256) { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = "llvm.intr.vscale"() : () -> i8 + %2 = llvm.icmp "uge" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @vscale_ugt_max_overflow() -> i1 vscale_range(4, 256) { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = "llvm.intr.vscale"() : () -> i8 + %2 = llvm.icmp "ugt" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @vscale_eq_min_overflow() -> i1 vscale_range(256, 512) { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = "llvm.intr.vscale"() : () -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @vscale_ult_min_overflow() -> i1 vscale_range(256, 512) { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = "llvm.intr.vscale"() : () -> i8 + %2 = llvm.icmp "ult" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @vscale_ugt_min_overflow() -> i1 vscale_range(256, 512) { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = "llvm.intr.vscale"() : () -> i8 + %2 = llvm.icmp "ugt" %1, %0 : i8 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-with-selects.ll.mlir b/test/LLVMDialect/InstCombine/icmp-with-selects.ll.mlir new file mode 100644 index 000000000..fdb077a9c --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-with-selects.ll.mlir @@ -0,0 +1,77 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32, ...) + llvm.func @both_sides_fold_slt(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.select %arg1, %0, %arg0 : i1, i32 + %3 = llvm.select %arg1, %1, %arg0 : i1, i32 + %4 = llvm.icmp "slt" %3, %2 : i32 + llvm.return %4 : i1 + } + llvm.func @both_sides_fold_eq(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.select %arg1, %0, %arg0 : i1, i32 + %3 = llvm.select %arg1, %1, %arg0 : i1, i32 + %4 = llvm.icmp "eq" %3, %2 : i32 + llvm.return %4 : i1 + } + llvm.func @one_side_fold_slt(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i1) -> i1 { + %0 = llvm.select %arg3, %arg0, %arg2 : i1, i32 + %1 = llvm.select %arg3, %arg1, %arg2 : i1, i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @one_side_fold_sgt(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i1) -> i1 { + %0 = llvm.select %arg3, %arg2, %arg0 : i1, i32 + %1 = llvm.select %arg3, %arg2, %arg1 : i1, i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @one_side_fold_eq(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i1) -> i1 { + %0 = llvm.select %arg3, %arg0, %arg2 : i1, i32 + %1 = llvm.select %arg3, %arg1, %arg2 : i1, i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @no_side_fold_cond(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.select %arg3, %arg0, %arg2 : i1, i32 + %1 = llvm.select %arg4, %arg1, %arg2 : i1, i32 + %2 = llvm.icmp "sle" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @no_side_fold_op(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i1) -> i1 { + %0 = llvm.select %arg3, %arg0, %arg1 : i1, i32 + %1 = llvm.select %arg3, %arg1, %arg2 : i1, i32 + %2 = llvm.icmp "sge" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @one_select_mult_use(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i1) -> i1 { + %0 = llvm.mlir.addressof @use : !llvm.ptr + %1 = llvm.select %arg3, %arg0, %arg2 : i1, i32 + %2 = llvm.select %arg3, %arg1, %arg2 : i1, i32 + llvm.call %0(%1) : !llvm.ptr, (i32) -> () + %3 = llvm.icmp "slt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @both_select_mult_use(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i1) -> i1 { + %0 = llvm.mlir.addressof @use : !llvm.ptr + %1 = llvm.select %arg3, %arg0, %arg2 : i1, i32 + %2 = llvm.select %arg3, %arg1, %arg2 : i1, i32 + llvm.call %0(%1, %2) : !llvm.ptr, (i32, i32) -> () + %3 = llvm.icmp "slt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @fold_vector_ops(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi32>, %arg3: i1) -> vector<4xi1> { + %0 = llvm.select %arg3, %arg0, %arg2 : i1, vector<4xi32> + %1 = llvm.select %arg3, %arg1, %arg2 : i1, vector<4xi32> + %2 = llvm.icmp "eq" %1, %0 : vector<4xi32> + llvm.return %2 : vector<4xi1> + } + llvm.func @fold_vector_cond_ops(%arg0: vector<8xi32>, %arg1: vector<8xi32>, %arg2: vector<8xi32>, %arg3: vector<8xi1>) -> vector<8xi1> { + %0 = llvm.select %arg3, %arg0, %arg2 : vector<8xi1>, vector<8xi32> + %1 = llvm.select %arg3, %arg1, %arg2 : vector<8xi1>, vector<8xi32> + %2 = llvm.icmp "sgt" %1, %0 : vector<8xi32> + llvm.return %2 : vector<8xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/icmp-xor-signbit.ll.mlir b/test/LLVMDialect/InstCombine/icmp-xor-signbit.ll.mlir new file mode 100644 index 000000000..d7cfb4350 --- /dev/null +++ b/test/LLVMDialect/InstCombine/icmp-xor-signbit.ll.mlir @@ -0,0 +1,200 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @slt_to_ult(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.icmp "slt" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @slt_to_ult_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg0, %0 : vector<2xi8> + %2 = llvm.xor %arg1, %0 : vector<2xi8> + %3 = llvm.icmp "slt" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @ult_to_slt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.icmp "ult" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_to_slt_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg0, %0 : vector<2xi8> + %2 = llvm.xor %arg1, %0 : vector<2xi8> + %3 = llvm.icmp "ult" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @slt_to_ugt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.icmp "slt" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @slt_to_ugt_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg0, %0 : vector<2xi8> + %2 = llvm.xor %arg1, %0 : vector<2xi8> + %3 = llvm.icmp "slt" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @ult_to_sgt(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.icmp "ult" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @ult_to_sgt_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg0, %0 : vector<2xi8> + %2 = llvm.xor %arg1, %0 : vector<2xi8> + %3 = llvm.icmp "ult" %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @sge_to_ugt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.icmp "sge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @sge_to_ugt_splat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %2 = llvm.xor %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "sge" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @uge_to_sgt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.icmp "uge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @uge_to_sgt_splat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %2 = llvm.xor %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "uge" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @sge_to_ult(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.icmp "sge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @sge_to_ult_splat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %2 = llvm.xor %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "sge" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @uge_to_slt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.icmp "uge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @uge_to_slt_splat(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %2 = llvm.xor %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "uge" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @sgt_to_ugt_bitcasted_splat(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<8xi1> { + %0 = llvm.mlir.constant(dense<-2139062144> : vector<2xi32>) : vector<2xi32> + %1 = llvm.xor %arg0, %0 : vector<2xi32> + %2 = llvm.xor %arg1, %0 : vector<2xi32> + %3 = llvm.bitcast %1 : vector<2xi32> to vector<8xi8> + %4 = llvm.bitcast %2 : vector<2xi32> to vector<8xi8> + %5 = llvm.icmp "sgt" %3, %4 : vector<8xi8> + llvm.return %5 : vector<8xi1> + } + llvm.func @negative_simplify_splat(%arg0: vector<4xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[0, -128, 0, -128]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.mlir.constant(dense<0> : vector<2xi16>) : vector<2xi16> + %3 = llvm.or %arg0, %0 : vector<4xi8> + %4 = llvm.bitcast %3 : vector<4xi8> to vector<2xi16> + %5 = llvm.icmp "sgt" %4, %2 : vector<2xi16> + llvm.return %5 : vector<2xi1> + } + llvm.func @slt_zero_eq_i1(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.zext %arg1 : i1 to i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.icmp "eq" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @slt_zero_eq_i1_fail(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.zext %arg1 : i1 to i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.icmp "eq" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @slt_zero_eq_ne_0(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.icmp "eq" %3, %4 : i32 + llvm.return %5 : i1 + } + llvm.func @slt_zero_ne_ne_0(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.icmp "ne" %3, %4 : i32 + llvm.return %5 : i1 + } + llvm.func @slt_zero_eq_ne_0_vec(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %3 = llvm.icmp "ne" %arg0, %1 : vector<4xi32> + %4 = llvm.zext %3 : vector<4xi1> to vector<4xi32> + %5 = llvm.lshr %arg0, %2 : vector<4xi32> + %6 = llvm.icmp "eq" %4, %5 : vector<4xi32> + llvm.return %6 : vector<4xi1> + } + llvm.func @slt_zero_ne_ne_b(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %arg1 : i32 + %2 = llvm.zext %1 : i1 to i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.icmp "ne" %2, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @slt_zero_eq_ne_0_fail1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.ashr %arg0, %1 : i32 + %5 = llvm.icmp "eq" %3, %4 : i32 + llvm.return %5 : i1 + } + llvm.func @slt_zero_eq_ne_0_fail2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.icmp "eq" %3, %4 : i32 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/icmp.ll.mlir b/test/LLVMDialect/InstCombine/icmp.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/icmp_sdiv_with_and_without_range.ll.mlir b/test/LLVMDialect/InstCombine/icmp_sdiv_with_and_without_range.ll.mlir index 3158b2d37..366e1bd62 100644 --- a/test/LLVMDialect/InstCombine/icmp_sdiv_with_and_without_range.ll.mlir +++ b/test/LLVMDialect/InstCombine/icmp_sdiv_with_and_without_range.ll.mlir @@ -1,21 +1,18 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %3 = "llvm.sdiv"(%2, %1) : (i32, i32) -> i32 - %4 = "llvm.icmp"(%0, %3) {predicate = 5 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "without_range", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %3 = "llvm.sdiv"(%2, %1) : (i32, i32) -> i32 - %4 = "llvm.icmp"(%0, %3) {predicate = 5 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "with_range", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @without_range(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i32 + %3 = llvm.sdiv %2, %0 : i32 + %4 = llvm.icmp "sge" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @with_range(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i32 + %3 = llvm.sdiv %2, %0 : i32 + %4 = llvm.icmp "sge" %1, %3 : i32 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/idioms.ll.mlir b/test/LLVMDialect/InstCombine/idioms.ll.mlir index 9f8f728fe..de90c806b 100644 --- a/test/LLVMDialect/InstCombine/idioms.ll.mlir +++ b/test/LLVMDialect/InstCombine/idioms.ll.mlir @@ -1,22 +1,20 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.icmp"(%arg0, %1) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_asr(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + llvm.cond_br %2, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %3 = "llvm.sub"(%1, %arg0) : (i32, i32) -> i32 - %4 = "llvm.sub"(%3, %0) : (i32, i32) -> i32 - %5 = "llvm.ashr"(%4, %arg1) : (i32, i32) -> i32 - %6 = "llvm.sub"(%1, %5) : (i32, i32) -> i32 - %7 = "llvm.sub"(%6, %0) : (i32, i32) -> i32 - "llvm.br"(%7)[^bb3] : (i32) -> () + %3 = llvm.sub %0, %arg0 : i32 + %4 = llvm.sub %3, %1 : i32 + %5 = llvm.ashr %4, %arg1 : i32 + %6 = llvm.sub %0, %5 : i32 + %7 = llvm.sub %6, %1 : i32 + llvm.br ^bb3(%7 : i32) ^bb2: // pred: ^bb0 - %8 = "llvm.ashr"(%arg0, %arg1) : (i32, i32) -> i32 - "llvm.br"(%8)[^bb3] : (i32) -> () + %8 = llvm.ashr %arg0, %arg1 : i32 + llvm.br ^bb3(%8 : i32) ^bb3(%9: i32): // 2 preds: ^bb1, ^bb2 - "llvm.return"(%9) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_asr", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %9 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/implies.ll.mlir b/test/LLVMDialect/InstCombine/implies.ll.mlir new file mode 100644 index 000000000..a62c92c3a --- /dev/null +++ b/test/LLVMDialect/InstCombine/implies.ll.mlir @@ -0,0 +1,229 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @or_implies_sle(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(23 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.icmp "sle" %1, %arg1 : i8 + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.icmp "sle" %arg0, %arg1 : i8 + llvm.return %3 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg2 : i1 + } + llvm.func @or_implies_sle_fail(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-34 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.icmp "sle" %1, %arg1 : i8 + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.icmp "sle" %arg0, %arg1 : i8 + llvm.return %3 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg2 : i1 + } + llvm.func @or_distjoint_implies_ule(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(23 : i8) : i8 + %1 = llvm.mlir.constant(24 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.or %arg0, %1 : i8 + %4 = llvm.icmp "ule" %3, %arg1 : i8 + llvm.cond_br %4, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %5 = llvm.icmp "ule" %2, %arg1 : i8 + llvm.return %5 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg2 : i1 + } + llvm.func @or_distjoint_implies_ule_fail(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(28 : i8) : i8 + %1 = llvm.mlir.constant(24 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.or %arg0, %1 : i8 + %4 = llvm.icmp "ule" %3, %arg1 : i8 + llvm.cond_br %4, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %5 = llvm.icmp "ule" %2, %arg1 : i8 + llvm.return %5 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg2 : i1 + } + llvm.func @or_prove_distjoin_implies_ule(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(-16 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(10 : i8) : i8 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.or %3, %1 : i8 + %5 = llvm.or %3, %2 : i8 + %6 = llvm.icmp "ule" %5, %arg1 : i8 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %7 = llvm.icmp "ule" %4, %arg1 : i8 + llvm.return %7 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg2 : i1 + } + llvm.func @src_or_distjoint_implies_sle(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(23 : i8) : i8 + %1 = llvm.mlir.constant(24 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.or %arg0, %1 : i8 + %4 = llvm.icmp "sle" %3, %arg1 : i8 + llvm.cond_br %4, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %5 = llvm.icmp "sle" %2, %arg1 : i8 + llvm.return %5 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg2 : i1 + } + llvm.func @src_or_distjoint_implies_sle_fail(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(23 : i8) : i8 + %1 = llvm.mlir.constant(24 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.or %arg0, %1 : i8 + %4 = llvm.icmp "sle" %arg1, %3 : i8 + llvm.cond_br %4, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %5 = llvm.icmp "sle" %2, %arg1 : i8 + llvm.return %5 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg2 : i1 + } + llvm.func @src_addnsw_implies_sle(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(23 : i8) : i8 + %1 = llvm.mlir.constant(24 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.add %arg0, %1 overflow : i8 + %4 = llvm.icmp "sle" %3, %arg1 : i8 + llvm.cond_br %4, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %5 = llvm.icmp "sle" %2, %arg1 : i8 + llvm.return %5 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg2 : i1 + } + llvm.func @src_addnsw_implies_sle_fail(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(24 : i8) : i8 + %1 = llvm.mlir.constant(23 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.add %arg0, %1 overflow : i8 + %4 = llvm.icmp "sle" %3, %arg1 : i8 + llvm.cond_br %4, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %5 = llvm.icmp "sle" %2, %arg1 : i8 + llvm.return %5 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg2 : i1 + } + llvm.func @src_and_implies_ult(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i1) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg2 : i8 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.and %arg2, %arg0 : i8 + %2 = llvm.icmp "ult" %1, %arg2 : i8 + llvm.return %2 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg3 : i1 + } + llvm.func @src_and_implies_ult_fail(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i1) -> i1 { + %0 = llvm.icmp "ule" %arg0, %arg2 : i8 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.and %arg0, %arg2 : i8 + %2 = llvm.icmp "ult" %1, %arg2 : i8 + llvm.return %2 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg3 : i1 + } + llvm.func @src_and_implies_slt_fail(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i1) -> i1 { + %0 = llvm.icmp "slt" %arg0, %arg2 : i8 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.and %arg0, %arg1 : i8 + %2 = llvm.icmp "slt" %1, %arg2 : i8 + llvm.return %2 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg3 : i1 + } + llvm.func @src_or_implies_ule(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i1) -> i1 { + %0 = llvm.or %arg1, %arg0 : i8 + %1 = llvm.icmp "uge" %arg2, %0 : i8 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.icmp "ule" %arg0, %arg2 : i8 + llvm.return %2 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg3 : i1 + } + llvm.func @src_or_implies_false_ugt_todo(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i1) -> i1 { + %0 = llvm.or %arg0, %arg1 : i8 + %1 = llvm.icmp "ugt" %0, %arg2 : i8 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %arg3 : i1 + ^bb2: // pred: ^bb0 + %2 = llvm.icmp "ugt" %arg0, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @src_udiv_implies_ult(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.icmp "ugt" %arg1, %arg0 : i8 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.udiv %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %arg1 : i8 + llvm.return %3 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg2 : i1 + } + llvm.func @src_udiv_implies_ult2(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.icmp "ule" %arg1, %arg0 : i8 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %arg2 : i1 + ^bb2: // pred: ^bb0 + %2 = llvm.udiv %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %arg1 : i8 + llvm.return %3 : i1 + } + llvm.func @src_smin_implies_sle(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i1) -> i1 { + %0 = llvm.icmp "sle" %arg0, %arg2 : i8 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smin(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "sle" %1, %arg2 : i8 + llvm.return %2 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg3 : i1 + } + llvm.func @src_umin_implies_ule(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i1) -> i1 { + %0 = llvm.icmp "ule" %arg0, %arg2 : i8 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umin(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "ule" %1, %arg2 : i8 + llvm.return %2 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg3 : i1 + } + llvm.func @src_umax_implies_ule(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i1) -> i1 { + %0 = llvm.intr.umax(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.icmp "ule" %0, %arg2 : i8 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.icmp "ule" %arg0, %arg2 : i8 + llvm.return %2 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg3 : i1 + } + llvm.func @src_smax_implies_sle(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i1) -> i1 { + %0 = llvm.intr.smax(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.icmp "sle" %0, %arg2 : i8 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.icmp "sle" %arg0, %arg2 : i8 + llvm.return %2 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/inbounds-gep.ll.mlir b/test/LLVMDialect/InstCombine/inbounds-gep.ll.mlir new file mode 100644 index 000000000..6cf838de9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/inbounds-gep.ll.mlir @@ -0,0 +1,58 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @g() -> !llvm.ptr + llvm.func @use(!llvm.ptr) -> !llvm.ptr + llvm.func @call1() { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.addressof @use : !llvm.ptr + %2 = llvm.call @g() : () -> !llvm.ptr + %3 = llvm.getelementptr %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call %1(%3) : !llvm.ptr, (!llvm.ptr) -> () + llvm.return + } + llvm.func @call2() { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.addressof @use : !llvm.ptr + %2 = llvm.call @g() : () -> !llvm.ptr + %3 = llvm.getelementptr %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call %1(%3) : !llvm.ptr, (!llvm.ptr) -> () + llvm.return + } + llvm.func @call3() { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.addressof @use : !llvm.ptr + %2 = llvm.call @g() : () -> !llvm.ptr + %3 = llvm.getelementptr %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call %1(%3) : !llvm.ptr, (!llvm.ptr) -> () + llvm.return + } + llvm.func @alloca() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(4 : i64) : i64 + %2 = llvm.mlir.addressof @use : !llvm.ptr + %3 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.getelementptr %3[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call %2(%4) : !llvm.ptr, (!llvm.ptr) -> () + llvm.return + } + llvm.func @arg1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.addressof @use : !llvm.ptr + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call %1(%2) : !llvm.ptr, (!llvm.ptr) -> () + llvm.return + } + llvm.func @arg2(%arg0: !llvm.ptr {llvm.dereferenceable = 8 : i64}) { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.addressof @use : !llvm.ptr + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call %1(%2) : !llvm.ptr, (!llvm.ptr) -> () + llvm.return + } + llvm.func @arg3(%arg0: !llvm.ptr {llvm.dereferenceable_or_null = 8 : i64}) { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.addressof @use : !llvm.ptr + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call %1(%2) : !llvm.ptr, (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/indexed-gep-compares.ll.mlir b/test/LLVMDialect/InstCombine/indexed-gep-compares.ll.mlir new file mode 100644 index 000000000..34033b716 --- /dev/null +++ b/test/LLVMDialect/InstCombine/indexed-gep-compares.ll.mlir @@ -0,0 +1,165 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @pr30402(3 : i64) {addr_space = 0 : i32} : i64 + llvm.func @test1(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.br ^bb1(%2 : !llvm.ptr) + ^bb1(%3: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %4 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %5 = llvm.getelementptr inbounds %3[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %6 = llvm.icmp "ult" %4, %3 : !llvm.ptr + llvm.cond_br %6, ^bb2, ^bb1(%5 : !llvm.ptr) + ^bb2: // pred: ^bb1 + llvm.return %3 : !llvm.ptr + } + llvm.func @test2(%arg0: i32, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.inttoptr %arg0 : i32 to !llvm.ptr + %3 = llvm.getelementptr inbounds %2[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.br ^bb1(%3 : !llvm.ptr) + ^bb1(%4: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %5 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %6 = llvm.getelementptr inbounds %4[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %7 = llvm.ptrtoint %5 : !llvm.ptr to i32 + %8 = llvm.ptrtoint %4 : !llvm.ptr to i32 + %9 = llvm.icmp "ult" %7, %8 : i32 + llvm.cond_br %9, ^bb2, ^bb1(%6 : !llvm.ptr) + ^bb2: // pred: ^bb1 + llvm.return %4 : !llvm.ptr + } + llvm.func @test3_no_inbounds1(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.br ^bb1(%2 : !llvm.ptr) + ^bb1(%3: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %4 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %5 = llvm.getelementptr inbounds %3[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %6 = llvm.icmp "ult" %4, %3 : !llvm.ptr + llvm.cond_br %6, ^bb2, ^bb1(%5 : !llvm.ptr) + ^bb2: // pred: ^bb1 + llvm.return %3 : !llvm.ptr + } + llvm.func @test3_no_inbounds2(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.br ^bb1(%2 : !llvm.ptr) + ^bb1(%3: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %4 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %5 = llvm.getelementptr %3[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %6 = llvm.icmp "ult" %4, %3 : !llvm.ptr + llvm.cond_br %6, ^bb2, ^bb1(%5 : !llvm.ptr) + ^bb2: // pred: ^bb1 + llvm.return %3 : !llvm.ptr + } + llvm.func @test3_no_inbounds3(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.br ^bb1(%2 : !llvm.ptr) + ^bb1(%3: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %4 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %5 = llvm.getelementptr inbounds %3[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %6 = llvm.icmp "ult" %4, %3 : !llvm.ptr + llvm.cond_br %6, ^bb2, ^bb1(%5 : !llvm.ptr) + ^bb2: // pred: ^bb1 + llvm.return %3 : !llvm.ptr + } + llvm.func @test4(%arg0: i16, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.inttoptr %arg0 : i16 to !llvm.ptr + %3 = llvm.getelementptr inbounds %2[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.br ^bb1(%3 : !llvm.ptr) + ^bb1(%4: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %5 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %6 = llvm.getelementptr inbounds %4[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %7 = llvm.ptrtoint %5 : !llvm.ptr to i32 + %8 = llvm.ptrtoint %4 : !llvm.ptr to i32 + %9 = llvm.icmp "ult" %7, %8 : i32 + llvm.cond_br %9, ^bb2, ^bb1(%6 : !llvm.ptr) + ^bb2: // pred: ^bb1 + llvm.return %4 : !llvm.ptr + } + llvm.func @fun_ptr() -> !llvm.ptr + llvm.func @test5(%arg0: i32) -> !llvm.ptr attributes {personality = @__gxx_personality_v0} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(100 : i32) : i32 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.invoke @fun_ptr() to ^bb1 unwind ^bb4 : () -> !llvm.ptr + ^bb1: // pred: ^bb0 + %4 = llvm.getelementptr inbounds %3[%arg0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.br ^bb2(%4 : !llvm.ptr) + ^bb2(%5: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + %6 = llvm.getelementptr inbounds %3[%1] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %7 = llvm.getelementptr inbounds %5[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %8 = llvm.icmp "ult" %6, %5 : !llvm.ptr + llvm.cond_br %8, ^bb3, ^bb2(%7 : !llvm.ptr) + ^bb3: // pred: ^bb2 + llvm.return %5 : !llvm.ptr + ^bb4: // pred: ^bb0 + %9 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)> + llvm.return %0 : !llvm.ptr + } + llvm.func @fun_i32() -> i32 + llvm.func @test6(%arg0: i32) -> !llvm.ptr attributes {personality = @__gxx_personality_v0} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(100 : i32) : i32 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.invoke @fun_i32() to ^bb1 unwind ^bb4 : () -> i32 + ^bb1: // pred: ^bb0 + %4 = llvm.inttoptr %3 : i32 to !llvm.ptr + %5 = llvm.getelementptr inbounds %4[%arg0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.br ^bb2(%5 : !llvm.ptr) + ^bb2(%6: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + %7 = llvm.getelementptr inbounds %4[%1] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %8 = llvm.getelementptr inbounds %6[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %9 = llvm.icmp "ult" %7, %6 : !llvm.ptr + llvm.cond_br %9, ^bb3, ^bb2(%8 : !llvm.ptr) + ^bb3: // pred: ^bb2 + llvm.return %6 : !llvm.ptr + ^bb4: // pred: ^bb0 + %10 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)> + llvm.return %0 : !llvm.ptr + } + llvm.func @test7() -> i1 { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.mlir.addressof @pr30402 : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.getelementptr inbounds %1[%2] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.br ^bb1(%1 : !llvm.ptr) + ^bb1(%4: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %5 = llvm.icmp "eq" %4, %3 : !llvm.ptr + llvm.cond_br %5, ^bb2, ^bb1(%3 : !llvm.ptr) + ^bb2: // pred: ^bb1 + llvm.return %5 : i1 + } + llvm.func @__gxx_personality_v0(...) -> i32 + llvm.func @test8(%arg0: !llvm.ptr, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + %2 = llvm.inttoptr %1 : i64 to !llvm.ptr + %3 = llvm.getelementptr inbounds %2[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.inttoptr %1 : i64 to !llvm.ptr + %5 = llvm.getelementptr inbounds %4[%0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr + %6 = llvm.icmp "eq" %5, %3 : !llvm.ptr + llvm.return %6 : i1 + } + llvm.func @test_zero_offset_cycle(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.getelementptr inbounds %arg0[%0, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<(i64, i64)> + %3 = llvm.ptrtoint %2 : !llvm.ptr to i32 + llvm.br ^bb1(%3 : i32) + ^bb1(%4: i32): // 3 preds: ^bb0, ^bb1, ^bb2 + %5 = llvm.inttoptr %4 : i32 to !llvm.ptr + %6 = llvm.icmp "eq" %2, %5 : !llvm.ptr + llvm.cond_br %6, ^bb1(%4 : i32), ^bb2 + ^bb2: // pred: ^bb1 + %7 = llvm.ptrtoint %2 : !llvm.ptr to i32 + llvm.br ^bb1(%7 : i32) + } +} diff --git a/test/LLVMDialect/InstCombine/infinite-loop-postdom.ll.mlir b/test/LLVMDialect/InstCombine/infinite-loop-postdom.ll.mlir new file mode 100644 index 000000000..60d1e3f13 --- /dev/null +++ b/test/LLVMDialect/InstCombine/infinite-loop-postdom.ll.mlir @@ -0,0 +1,98 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i24, %arg1: i24) { + llvm.br ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb3 + %0 = llvm.icmp "uge" %arg0, %arg1 : i24 + llvm.cond_br %0, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %1 = llvm.add %arg0, %arg1 : i24 + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + llvm.br ^bb1 + } + llvm.func @"test1-canonicalized"(%arg0: i24, %arg1: i24) { + llvm.br ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb3 + %0 = llvm.icmp "ult" %arg0, %arg1 : i24 + llvm.cond_br %0, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + %1 = llvm.add %arg0, %arg1 : i24 + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + llvm.br ^bb1 + } + llvm.func @test2(%arg0: i24, %arg1: i24) { + llvm.br ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb2 + %0 = llvm.icmp "uge" %arg0, %arg1 : i24 + llvm.cond_br %0, ^bb3, ^bb2 + ^bb2: // 2 preds: ^bb1, ^bb3 + llvm.br ^bb1 + ^bb3: // pred: ^bb1 + %1 = llvm.add %arg0, %arg1 : i24 + llvm.br ^bb2 + } + llvm.func @"test2-canonicalized"(%arg0: i24, %arg1: i24) { + llvm.br ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb2 + %0 = llvm.icmp "ult" %arg0, %arg1 : i24 + llvm.cond_br %0, ^bb2, ^bb3 + ^bb2: // 2 preds: ^bb1, ^bb3 + llvm.br ^bb1 + ^bb3: // pred: ^bb1 + %1 = llvm.add %arg0, %arg1 : i24 + llvm.br ^bb2 + } + llvm.func @test3(%arg0: i24, %arg1: i24, %arg2: i32) { + llvm.switch %arg2 : i32, ^bb8 [ + 1: ^bb1, + 2: ^bb5, + 3: ^bb6 + ] + ^bb1: // pred: ^bb0 + %0 = llvm.icmp "uge" %arg0, %arg1 : i24 + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb1, ^bb4 + llvm.cond_br %0, ^bb3, ^bb4 + ^bb3: // pred: ^bb2 + %1 = llvm.add %arg0, %arg1 : i24 + llvm.br ^bb4 + ^bb4: // 2 preds: ^bb2, ^bb3 + llvm.br ^bb2 + ^bb5: // pred: ^bb0 + %2 = llvm.icmp "uge" %arg0, %arg1 : i24 + llvm.cond_br %2, ^bb6, ^bb7 + ^bb6: // 3 preds: ^bb0, ^bb5, ^bb7 + llvm.br ^bb7 + ^bb7: // 2 preds: ^bb5, ^bb6 + llvm.br ^bb6 + ^bb8: // pred: ^bb0 + llvm.return + } + llvm.func @"test3-canonicalized"(%arg0: i24, %arg1: i24, %arg2: i32) { + llvm.switch %arg2 : i32, ^bb8 [ + 1: ^bb1, + 2: ^bb5, + 3: ^bb6 + ] + ^bb1: // pred: ^bb0 + %0 = llvm.icmp "ult" %arg0, %arg1 : i24 + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb1, ^bb4 + llvm.cond_br %0, ^bb4, ^bb3 + ^bb3: // pred: ^bb2 + %1 = llvm.add %arg0, %arg1 : i24 + llvm.br ^bb4 + ^bb4: // 2 preds: ^bb2, ^bb3 + llvm.br ^bb2 + ^bb5: // pred: ^bb0 + %2 = llvm.icmp "ult" %arg0, %arg1 : i24 + llvm.cond_br %2, ^bb7, ^bb6 + ^bb6: // 3 preds: ^bb0, ^bb5, ^bb7 + llvm.br ^bb7 + ^bb7: // 2 preds: ^bb5, ^bb6 + llvm.br ^bb6 + ^bb8: // pred: ^bb0 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/inline-intrinsic-assert.ll.mlir b/test/LLVMDialect/InstCombine/inline-intrinsic-assert.ll.mlir index 4aee99864..c9788b267 100644 --- a/test/LLVMDialect/InstCombine/inline-intrinsic-assert.ll.mlir +++ b/test/LLVMDialect/InstCombine/inline-intrinsic-assert.ll.mlir @@ -1,21 +1,16 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @bar, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%0) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @sqr, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %1 = "llvm.call"(%0) {callee = @sqrtf, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fmul"(%arg0, %arg0) : (f32, f32) -> f32 - "llvm.return"(%0) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "sqr", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sqrtf", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: f32) -> f32 { + %0 = llvm.call @bar(%arg0) : (f32) -> f32 + llvm.return %0 : f32 + } + llvm.func @bar(%arg0: f32) -> f32 { + %0 = llvm.call @sqr(%arg0) : (f32) -> f32 + %1 = llvm.call @sqrtf(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @sqr(%arg0: f32) -> f32 { + %0 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %0 : f32 + } + llvm.func @sqrtf(f32) -> f32 +} diff --git a/test/LLVMDialect/InstCombine/inselt-binop-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/inselt-binop-inseltpoison.ll.mlir new file mode 100644 index 000000000..5cef4defa --- /dev/null +++ b/test/LLVMDialect/InstCombine/inselt-binop-inseltpoison.ll.mlir @@ -0,0 +1,651 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @add_constant(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(42 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.add %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @add_constant_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.add %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @sub_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-42 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.sub %8, %9 overflow : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @sub_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.sub %2, %3 overflow : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @sub_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(42 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.sub %9, %8 overflow : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @sub_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.sub %3, %2 overflow : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @mul_constant(%arg0: i8) -> vector<3xi8> { + %0 = llvm.mlir.poison : vector<3xi8> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(-42 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<3xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %3, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %2, %8[%9 : i32] : vector<3xi8> + %11 = llvm.insertelement %arg0, %0[%1 : i32] : vector<3xi8> + %12 = llvm.mul %11, %10 : vector<3xi8> + llvm.return %12 : vector<3xi8> + } + llvm.func @mul_constant_not_undef_lane(%arg0: i8) -> vector<3xi8> { + %0 = llvm.mlir.poison : vector<3xi8> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(-42 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.constant(42 : i8) : i8 + %5 = llvm.mlir.undef : vector<3xi8> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %4, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %3, %7[%8 : i32] : vector<3xi8> + %10 = llvm.mlir.constant(2 : i32) : i32 + %11 = llvm.insertelement %2, %9[%10 : i32] : vector<3xi8> + %12 = llvm.insertelement %arg0, %0[%1 : i32] : vector<3xi8> + %13 = llvm.mul %12, %11 : vector<3xi8> + llvm.return %13 : vector<3xi8> + } + llvm.func @shl_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.shl %8, %9 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @shl_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.shl %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @shl_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(5 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.shl %9, %8 overflow : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @shl_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.shl %3, %2 overflow : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @ashr_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.ashr %8, %9 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @ashr_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.ashr %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @ashr_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(5 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.ashr %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @ashr_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.ashr %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @lshr_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(5 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.lshr %8, %9 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @lshr_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.lshr %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @lshr_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.lshr %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @lshr_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.lshr %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @urem_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(5 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.urem %8, %9 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @urem_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.urem %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @urem_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.urem %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @urem_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.urem %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @srem_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(5 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.srem %8, %9 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @srem_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.srem %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @srem_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.srem %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @srem_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.srem %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @udiv_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(5 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.udiv %8, %9 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @udiv_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.udiv %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @udiv_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.udiv %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @udiv_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.udiv %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @sdiv_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(5 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.sdiv %8, %9 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @sdiv_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.sdiv %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @sdiv_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.sdiv %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @sdiv_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.sdiv %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @and_constant(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(42 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.and %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @and_constant_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.and %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @or_constant(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-42 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.or %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @or_constant_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.or %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @xor_constant(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(42 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.xor %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @xor_constant_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.xor %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @fadd_constant(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.fadd %9, %8 : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @fadd_constant_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.fadd %3, %2 : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fsub_constant_op0(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.fsub %8, %9 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @fsub_constant_op0_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.fsub %2, %3 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fsub_constant_op1(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %3 = llvm.mlir.undef : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.fsub %9, %8 : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @fsub_constant_op1_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.fsub %3, %2 : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fmul_constant(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.fmul %9, %8 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @fmul_constant_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.fmul %3, %2 : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fdiv_constant_op0(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %3 = llvm.mlir.undef : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.fdiv %8, %9 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @fdiv_constant_op0_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.fdiv %2, %3 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fdiv_constant_op1(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.fdiv %9, %8 : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @fdiv_constant_op1_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.fdiv %3, %2 : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @frem_constant_op0(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.frem %8, %9 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @frem_constant_op0_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.frem %2, %3 : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @frem_constant_op1(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %3 = llvm.mlir.undef : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.frem %9, %8 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @frem_constant_op1_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.frem %3, %2 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %4 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/inselt-binop.ll.mlir b/test/LLVMDialect/InstCombine/inselt-binop.ll.mlir new file mode 100644 index 000000000..415e09d3d --- /dev/null +++ b/test/LLVMDialect/InstCombine/inselt-binop.ll.mlir @@ -0,0 +1,651 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @add_constant(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(42 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.add %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @add_constant_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.add %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @sub_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-42 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.sub %8, %9 overflow : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @sub_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.sub %2, %3 overflow : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @sub_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(42 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.sub %9, %8 overflow : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @sub_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.sub %3, %2 overflow : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @mul_constant(%arg0: i8) -> vector<3xi8> { + %0 = llvm.mlir.undef : vector<3xi8> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(-42 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<3xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %3, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %2, %8[%9 : i32] : vector<3xi8> + %11 = llvm.insertelement %arg0, %0[%1 : i32] : vector<3xi8> + %12 = llvm.mul %11, %10 : vector<3xi8> + llvm.return %12 : vector<3xi8> + } + llvm.func @mul_constant_not_undef_lane(%arg0: i8) -> vector<3xi8> { + %0 = llvm.mlir.undef : vector<3xi8> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(-42 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.constant(42 : i8) : i8 + %5 = llvm.mlir.undef : vector<3xi8> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %4, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %3, %7[%8 : i32] : vector<3xi8> + %10 = llvm.mlir.constant(2 : i32) : i32 + %11 = llvm.insertelement %2, %9[%10 : i32] : vector<3xi8> + %12 = llvm.insertelement %arg0, %0[%1 : i32] : vector<3xi8> + %13 = llvm.mul %12, %11 : vector<3xi8> + llvm.return %13 : vector<3xi8> + } + llvm.func @shl_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.shl %8, %9 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @shl_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.shl %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @shl_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(5 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.shl %9, %8 overflow : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @shl_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.shl %3, %2 overflow : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @ashr_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.ashr %8, %9 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @ashr_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.ashr %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @ashr_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(5 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.ashr %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @ashr_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.ashr %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @lshr_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(5 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.lshr %8, %9 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @lshr_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.lshr %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @lshr_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.lshr %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @lshr_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.lshr %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @urem_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(5 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.urem %8, %9 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @urem_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.urem %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @urem_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.urem %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @urem_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.urem %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @srem_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(5 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.srem %8, %9 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @srem_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.srem %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @srem_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.srem %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @srem_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.srem %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @udiv_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(5 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.udiv %8, %9 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @udiv_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.udiv %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @udiv_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.udiv %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @udiv_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.udiv %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @sdiv_constant_op0(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(5 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.sdiv %8, %9 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @sdiv_constant_op0_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.sdiv %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @sdiv_constant_op1(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.sdiv %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @sdiv_constant_op1_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[5, 2]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.sdiv %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @and_constant(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(42 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.and %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @and_constant_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.and %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @or_constant(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-42 : i8) : i8 + %3 = llvm.mlir.undef : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.or %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @or_constant_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.or %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @xor_constant(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.constant(42 : i8) : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %10 = llvm.xor %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @xor_constant_not_undef_lane(%arg0: i8) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi8> + %4 = llvm.xor %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @fadd_constant(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.fadd %9, %8 : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @fadd_constant_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.fadd %3, %2 : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fsub_constant_op0(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.fsub %8, %9 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @fsub_constant_op0_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.fsub %2, %3 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fsub_constant_op1(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %3 = llvm.mlir.undef : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.fsub %9, %8 : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @fsub_constant_op1_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.fsub %3, %2 : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fmul_constant(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.fmul %9, %8 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @fmul_constant_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.fmul %3, %2 : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fdiv_constant_op0(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %3 = llvm.mlir.undef : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.fdiv %8, %9 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @fdiv_constant_op0_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.fdiv %2, %3 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fdiv_constant_op1(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.fdiv %9, %8 : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @fdiv_constant_op1_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.fdiv %3, %2 : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @frem_constant_op0(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.frem %8, %9 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @frem_constant_op0_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.frem %2, %3 : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @frem_constant_op1(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %3 = llvm.mlir.undef : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %10 = llvm.frem %9, %8 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @frem_constant_op1_not_undef_lane(%arg0: f32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %4 = llvm.frem %3, %2 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %4 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/insert-const-shuf-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/insert-const-shuf-inseltpoison.ll.mlir new file mode 100644 index 000000000..7e20773bf --- /dev/null +++ b/test/LLVMDialect/InstCombine/insert-const-shuf-inseltpoison.ll.mlir @@ -0,0 +1,154 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @PR29126(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.poison : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.mlir.undef : vector<4xf32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : vector<4xf32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<4xf32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<4xf32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xf32> + %12 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %13 = llvm.mlir.constant(3 : i32) : i32 + %14 = llvm.shufflevector %arg0, %11 [0, 5, 6, 3] : vector<4xf32> + %15 = llvm.insertelement %12, %14[%13 : i32] : vector<4xf32> + llvm.return %15 : vector<4xf32> + } + llvm.func @twoInserts(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(1.100000e+01 : f32) : f32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.shufflevector %arg0, %1 [0, 5, 6, 3] : vector<4xf32> + %7 = llvm.insertelement %2, %6[%3 : i32] : vector<4xf32> + %8 = llvm.insertelement %4, %7[%5 : i32] : vector<4xf32> + llvm.return %8 : vector<4xf32> + } + llvm.func @shuffleRetain(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[4, 3, 2, 1]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [1, 2, -1, 7] : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @disguisedSelect(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.mlir.poison : f32 + %4 = llvm.mlir.undef : vector<4xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xf32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xf32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xf32> + %13 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %14 = llvm.mlir.constant(0 : i32) : i32 + %15 = llvm.shufflevector %arg0, %12 [7, 6, 5, 3] : vector<4xf32> + %16 = llvm.insertelement %13, %15[%14 : i32] : vector<4xf32> + llvm.return %16 : vector<4xf32> + } + llvm.func @notSelectButNoMaskDifference(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.mlir.poison : f32 + %4 = llvm.mlir.undef : vector<4xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xf32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xf32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xf32> + %13 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %14 = llvm.mlir.constant(3 : i32) : i32 + %15 = llvm.shufflevector %arg0, %12 [1, 5, 6, 3] : vector<4xf32> + %16 = llvm.insertelement %13, %15[%14 : i32] : vector<4xf32> + llvm.return %16 : vector<4xf32> + } + llvm.func @tooRisky(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.poison : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.mlir.undef : vector<4xf32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<4xf32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xf32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xf32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xf32> + %11 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %12 = llvm.mlir.constant(3 : i32) : i32 + %13 = llvm.shufflevector %arg0, %10 [1, 4, 4, 4] : vector<4xf32> + %14 = llvm.insertelement %11, %13[%12 : i32] : vector<4xf32> + llvm.return %14 : vector<4xf32> + } + llvm.func @twoShufUses(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.mlir.poison : f32 + %3 = llvm.mlir.undef : vector<3xf32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xf32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xf32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xf32> + %10 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %11 = llvm.mlir.constant(1 : i2) : i2 + %12 = llvm.shufflevector %arg0, %9 [0, 4, 5] : vector<3xf32> + %13 = llvm.insertelement %10, %12[%11 : i2] : vector<3xf32> + %14 = llvm.fadd %12, %13 : vector<3xf32> + llvm.return %14 : vector<3xf32> + } + llvm.func @longerMask(%arg0: vector<3xi8>) -> vector<5xi8> { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi8> + %10 = llvm.mlir.constant(42 : i8) : i8 + %11 = llvm.mlir.constant(4 : i17) : i17 + %12 = llvm.shufflevector %arg0, %9 [2, 1, 4, 3, 0] : vector<3xi8> + %13 = llvm.insertelement %10, %12[%11 : i17] : vector<5xi8> + llvm.return %13 : vector<5xi8> + } + llvm.func @shorterMask(%arg0: vector<5xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.constant(1 : i8) : i8 + %4 = llvm.mlir.poison : i8 + %5 = llvm.mlir.undef : vector<5xi8> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %4, %5[%6 : i32] : vector<5xi8> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %3, %7[%8 : i32] : vector<5xi8> + %10 = llvm.mlir.constant(2 : i32) : i32 + %11 = llvm.insertelement %2, %9[%10 : i32] : vector<5xi8> + %12 = llvm.mlir.constant(3 : i32) : i32 + %13 = llvm.insertelement %1, %11[%12 : i32] : vector<5xi8> + %14 = llvm.mlir.constant(4 : i32) : i32 + %15 = llvm.insertelement %0, %13[%14 : i32] : vector<5xi8> + %16 = llvm.mlir.constant(42 : i8) : i8 + %17 = llvm.mlir.constant(0 : i21) : i21 + %18 = llvm.shufflevector %arg0, %15 [2, 1, 4] : vector<5xi8> + %19 = llvm.insertelement %16, %18[%17 : i21] : vector<3xi8> + llvm.return %19 : vector<3xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/insert-const-shuf.ll.mlir b/test/LLVMDialect/InstCombine/insert-const-shuf.ll.mlir new file mode 100644 index 000000000..52d3f5f75 --- /dev/null +++ b/test/LLVMDialect/InstCombine/insert-const-shuf.ll.mlir @@ -0,0 +1,154 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @PR29126(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.undef : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.mlir.undef : vector<4xf32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : vector<4xf32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<4xf32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<4xf32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xf32> + %12 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %13 = llvm.mlir.constant(3 : i32) : i32 + %14 = llvm.shufflevector %arg0, %11 [0, 5, 6, 3] : vector<4xf32> + %15 = llvm.insertelement %12, %14[%13 : i32] : vector<4xf32> + llvm.return %15 : vector<4xf32> + } + llvm.func @twoInserts(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(1.100000e+01 : f32) : f32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.shufflevector %arg0, %1 [0, 5, 6, 3] : vector<4xf32> + %7 = llvm.insertelement %2, %6[%3 : i32] : vector<4xf32> + %8 = llvm.insertelement %4, %7[%5 : i32] : vector<4xf32> + llvm.return %8 : vector<4xf32> + } + llvm.func @shuffleRetain(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[4, 3, 2, 1]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [1, 2, -1, 7] : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @disguisedSelect(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.mlir.undef : f32 + %4 = llvm.mlir.undef : vector<4xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xf32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xf32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xf32> + %13 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %14 = llvm.mlir.constant(0 : i32) : i32 + %15 = llvm.shufflevector %arg0, %12 [7, 6, 5, 3] : vector<4xf32> + %16 = llvm.insertelement %13, %15[%14 : i32] : vector<4xf32> + llvm.return %16 : vector<4xf32> + } + llvm.func @notSelectButNoMaskDifference(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.mlir.undef : f32 + %4 = llvm.mlir.undef : vector<4xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xf32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xf32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xf32> + %13 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %14 = llvm.mlir.constant(3 : i32) : i32 + %15 = llvm.shufflevector %arg0, %12 [1, 5, 6, 3] : vector<4xf32> + %16 = llvm.insertelement %13, %15[%14 : i32] : vector<4xf32> + llvm.return %16 : vector<4xf32> + } + llvm.func @tooRisky(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.undef : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.mlir.undef : vector<4xf32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<4xf32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xf32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xf32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xf32> + %11 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %12 = llvm.mlir.constant(3 : i32) : i32 + %13 = llvm.shufflevector %arg0, %10 [1, 4, 4, 4] : vector<4xf32> + %14 = llvm.insertelement %11, %13[%12 : i32] : vector<4xf32> + llvm.return %14 : vector<4xf32> + } + llvm.func @twoShufUses(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.undef : vector<3xf32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xf32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xf32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xf32> + %10 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %11 = llvm.mlir.constant(1 : i2) : i2 + %12 = llvm.shufflevector %arg0, %9 [0, 4, 5] : vector<3xf32> + %13 = llvm.insertelement %10, %12[%11 : i2] : vector<3xf32> + %14 = llvm.fadd %12, %13 : vector<3xf32> + llvm.return %14 : vector<3xf32> + } + llvm.func @longerMask(%arg0: vector<3xi8>) -> vector<5xi8> { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi8> + %10 = llvm.mlir.constant(42 : i8) : i8 + %11 = llvm.mlir.constant(4 : i17) : i17 + %12 = llvm.shufflevector %arg0, %9 [2, 1, 4, 3, 0] : vector<3xi8> + %13 = llvm.insertelement %10, %12[%11 : i17] : vector<5xi8> + llvm.return %13 : vector<5xi8> + } + llvm.func @shorterMask(%arg0: vector<5xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.mlir.constant(1 : i8) : i8 + %4 = llvm.mlir.undef : i8 + %5 = llvm.mlir.undef : vector<5xi8> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %4, %5[%6 : i32] : vector<5xi8> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %3, %7[%8 : i32] : vector<5xi8> + %10 = llvm.mlir.constant(2 : i32) : i32 + %11 = llvm.insertelement %2, %9[%10 : i32] : vector<5xi8> + %12 = llvm.mlir.constant(3 : i32) : i32 + %13 = llvm.insertelement %1, %11[%12 : i32] : vector<5xi8> + %14 = llvm.mlir.constant(4 : i32) : i32 + %15 = llvm.insertelement %0, %13[%14 : i32] : vector<5xi8> + %16 = llvm.mlir.constant(42 : i8) : i8 + %17 = llvm.mlir.constant(0 : i21) : i21 + %18 = llvm.shufflevector %arg0, %15 [2, 1, 4] : vector<5xi8> + %19 = llvm.insertelement %16, %18[%17 : i21] : vector<3xi8> + llvm.return %19 : vector<3xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/insert-ext.ll.mlir b/test/LLVMDialect/InstCombine/insert-ext.ll.mlir new file mode 100644 index 000000000..28338e4fd --- /dev/null +++ b/test/LLVMDialect/InstCombine/insert-ext.ll.mlir @@ -0,0 +1,62 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @usevec(vector<2xi32>) + llvm.func @fpext_fpext(%arg0: vector<2xf16>, %arg1: f16, %arg2: i32) -> vector<2xf64> { + %0 = llvm.fpext %arg0 : vector<2xf16> to vector<2xf64> + %1 = llvm.fpext %arg1 : f16 to f64 + %2 = llvm.insertelement %1, %0[%arg2 : i32] : vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @sext_sext(%arg0: vector<2xi8>, %arg1: i8, %arg2: i32) -> vector<2xi32> { + %0 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.insertelement %1, %0[%arg2 : i32] : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @zext_zext(%arg0: vector<2xi8>, %arg1: i8, %arg2: i32) -> vector<2xi12> { + %0 = llvm.zext %arg0 : vector<2xi8> to vector<2xi12> + %1 = llvm.zext %arg1 : i8 to i12 + %2 = llvm.insertelement %1, %0[%arg2 : i32] : vector<2xi12> + llvm.return %2 : vector<2xi12> + } + llvm.func @fpext_fpext_types(%arg0: vector<2xf16>, %arg1: f32, %arg2: i32) -> vector<2xf64> { + %0 = llvm.fpext %arg0 : vector<2xf16> to vector<2xf64> + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.insertelement %1, %0[%arg2 : i32] : vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @sext_sext_types(%arg0: vector<2xi16>, %arg1: i8, %arg2: i32) -> vector<2xi32> { + %0 = llvm.sext %arg0 : vector<2xi16> to vector<2xi32> + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.insertelement %1, %0[%arg2 : i32] : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @sext_zext(%arg0: vector<2xi8>, %arg1: i8, %arg2: i32) -> vector<2xi12> { + %0 = llvm.sext %arg0 : vector<2xi8> to vector<2xi12> + %1 = llvm.zext %arg1 : i8 to i12 + %2 = llvm.insertelement %1, %0[%arg2 : i32] : vector<2xi12> + llvm.return %2 : vector<2xi12> + } + llvm.func @sext_sext_use1(%arg0: vector<2xi8>, %arg1: i8, %arg2: i32) -> vector<2xi32> { + %0 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + llvm.call @usevec(%0) : (vector<2xi32>) -> () + %1 = llvm.sext %arg1 : i8 to i32 + %2 = llvm.insertelement %1, %0[%arg2 : i32] : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @zext_zext_use2(%arg0: vector<2xi8>, %arg1: i8, %arg2: i32) -> vector<2xi32> { + %0 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + %1 = llvm.zext %arg1 : i8 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.insertelement %1, %0[%arg2 : i32] : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @zext_zext_use3(%arg0: vector<2xi8>, %arg1: i8, %arg2: i32) -> vector<2xi32> { + %0 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + llvm.call @usevec(%0) : (vector<2xi32>) -> () + %1 = llvm.zext %arg1 : i8 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.insertelement %1, %0[%arg2 : i32] : vector<2xi32> + llvm.return %2 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/insert-extract-shuffle-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/insert-extract-shuffle-inseltpoison.ll.mlir new file mode 100644 index 000000000..23b5f2873 --- /dev/null +++ b/test/LLVMDialect/InstCombine/insert-extract-shuffle-inseltpoison.ll.mlir @@ -0,0 +1,455 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: vector<8xi8>) -> vector<1xi8> { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.poison : vector<1xi8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.extractelement %arg0[%0 : i32] : vector<8xi8> + %4 = llvm.insertelement %3, %1[%2 : i32] : vector<1xi8> + llvm.return %4 : vector<1xi8> + } + llvm.func @test2(%arg0: vector<8xi16>, %arg1: vector<8xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.poison : vector<4xi16> + %5 = llvm.extractelement %arg0[%0 : i32] : vector<8xi16> + %6 = llvm.extractelement %arg0[%1 : i32] : vector<8xi16> + %7 = llvm.extractelement %arg1[%2 : i32] : vector<8xi16> + %8 = llvm.extractelement %arg0[%3 : i32] : vector<8xi16> + %9 = llvm.insertelement %5, %4[%2 : i32] : vector<4xi16> + %10 = llvm.insertelement %6, %9[%1 : i32] : vector<4xi16> + %11 = llvm.insertelement %7, %10[%3 : i32] : vector<4xi16> + %12 = llvm.insertelement %8, %11[%0 : i32] : vector<4xi16> + llvm.return %12 : vector<4xi16> + } + llvm.func @test_vcopyq_lane_p64(%arg0: vector<2xi64>, %arg1: vector<1xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.extractelement %arg1[%0 : i32] : vector<1xi64> + %3 = llvm.insertelement %2, %arg0[%1 : i32] : vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @widen_extract2(%arg0: vector<4xf32>, %arg1: vector<2xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.extractelement %arg1[%0 : i32] : vector<2xf32> + %4 = llvm.extractelement %arg1[%1 : i32] : vector<2xf32> + %5 = llvm.insertelement %3, %arg0[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %4, %5[%2 : i32] : vector<4xf32> + llvm.return %6 : vector<4xf32> + } + llvm.func @widen_extract3(%arg0: vector<4xf32>, %arg1: vector<3xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.extractelement %arg1[%0 : i32] : vector<3xf32> + %4 = llvm.extractelement %arg1[%1 : i32] : vector<3xf32> + %5 = llvm.extractelement %arg1[%2 : i32] : vector<3xf32> + %6 = llvm.insertelement %3, %arg0[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %4, %6[%1 : i32] : vector<4xf32> + %8 = llvm.insertelement %5, %7[%0 : i32] : vector<4xf32> + llvm.return %8 : vector<4xf32> + } + llvm.func @widen_extract4(%arg0: vector<8xf32>, %arg1: vector<2xf32>) -> vector<8xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.extractelement %arg1[%0 : i32] : vector<2xf32> + %3 = llvm.insertelement %2, %arg0[%1 : i32] : vector<8xf32> + llvm.return %3 : vector<8xf32> + } + llvm.func @pr26015(%arg0: vector<4xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.mlir.constant(dense<0> : vector<8xi16>) : vector<8xi16> + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.constant(6 : i32) : i32 + %5 = llvm.mlir.constant(7 : i32) : i32 + %6 = llvm.extractelement %arg0[%0 : i32] : vector<4xi16> + %7 = llvm.insertelement %6, %2[%3 : i32] : vector<8xi16> + %8 = llvm.insertelement %1, %7[%4 : i32] : vector<8xi16> + %9 = llvm.extractelement %arg0[%3 : i32] : vector<4xi16> + %10 = llvm.insertelement %9, %8[%5 : i32] : vector<8xi16> + llvm.return %10 : vector<8xi16> + } + llvm.func @pr25999(%arg0: vector<4xi16>, %arg1: i1) -> vector<8xi16> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(4 : i16) : i16 + %2 = llvm.mlir.constant(0 : i16) : i16 + %3 = llvm.mlir.constant(dense<0> : vector<8xi16>) : vector<8xi16> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.mlir.constant(6 : i32) : i32 + %7 = llvm.mlir.constant(7 : i32) : i32 + %8 = llvm.extractelement %arg0[%0 : i32] : vector<4xi16> + llvm.cond_br %arg1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %9 = llvm.insertelement %8, %3[%5 : i32] : vector<8xi16> + %10 = llvm.insertelement %2, %9[%6 : i32] : vector<8xi16> + %11 = llvm.extractelement %arg0[%5 : i32] : vector<4xi16> + %12 = llvm.insertelement %11, %10[%7 : i32] : vector<8xi16> + llvm.return %12 : vector<8xi16> + ^bb2: // pred: ^bb0 + %13 = llvm.add %8, %1 : i16 + %14 = llvm.insertelement %13, %3[%4 : i32] : vector<8xi16> + llvm.return %14 : vector<8xi16> + } + llvm.func @pr25999_phis1(%arg0: i1, %arg1: vector<2xf64>, %arg2: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf64>) : vector<4xf64> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : vector<2xf64>, vector<4xf64>) + ^bb1: // pred: ^bb0 + %4 = llvm.call @dummy(%arg1) : (vector<2xf64>) -> vector<2xf64> + llvm.br ^bb2(%4, %1 : vector<2xf64>, vector<4xf64>) + ^bb2(%5: vector<2xf64>, %6: vector<4xf64>): // 2 preds: ^bb0, ^bb1 + %7 = llvm.extractelement %5[%2 : i32] : vector<2xf64> + %8 = llvm.insertelement %7, %6[%3 : i32] : vector<4xf64> + llvm.return %8 : vector<4xf64> + } + llvm.func @dummy(vector<2xf64>) -> vector<2xf64> + llvm.func @pr25999_phis2(%arg0: i1, %arg1: vector<2xf64>, %arg2: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf64>) : vector<4xf64> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : vector<2xf64>, vector<4xf64>) + ^bb1: // pred: ^bb0 + %4 = llvm.call @dummy(%arg1) : (vector<2xf64>) -> vector<2xf64> + llvm.br ^bb2(%4, %1 : vector<2xf64>, vector<4xf64>) + ^bb2(%5: vector<2xf64>, %6: vector<4xf64>): // 2 preds: ^bb0, ^bb1 + %7 = llvm.fadd %5, %5 : vector<2xf64> + %8 = llvm.extractelement %7[%2 : i32] : vector<2xf64> + %9 = llvm.insertelement %8, %6[%3 : i32] : vector<4xf64> + llvm.return %9 : vector<4xf64> + } + llvm.func @pr26354(%arg0: !llvm.ptr, %arg1: i1) -> f64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.undef : vector<4xf64> + %3 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %4 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf64>) : vector<4xf64> + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> vector<2xf64> + %7 = llvm.extractelement %6[%0 : i32] : vector<2xf64> + %8 = llvm.extractelement %6[%1 : i32] : vector<2xf64> + llvm.cond_br %arg1, ^bb1, ^bb2(%2 : vector<4xf64>) + ^bb1: // pred: ^bb0 + %9 = llvm.insertelement %8, %4[%5 : i32] : vector<4xf64> + llvm.br ^bb2(%9 : vector<4xf64>) + ^bb2(%10: vector<4xf64>): // 2 preds: ^bb0, ^bb1 + %11 = llvm.extractelement %10[%1 : i32] : vector<4xf64> + %12 = llvm.fmul %7, %11 : f64 + llvm.return %12 : f64 + } + llvm.func @PR30923(%arg0: vector<2xf32>, %arg1: !llvm.ptr) -> vector<4xf32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.poison : vector<2xf32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.undef : f32 + %4 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %5 = llvm.mlir.undef : vector<4xf32> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %4, %5[%6 : i32] : vector<4xf32> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %4, %7[%8 : i32] : vector<4xf32> + %10 = llvm.mlir.constant(2 : i32) : i32 + %11 = llvm.insertelement %3, %9[%10 : i32] : vector<4xf32> + %12 = llvm.mlir.constant(3 : i32) : i32 + %13 = llvm.insertelement %3, %11[%12 : i32] : vector<4xf32> + %14 = llvm.mlir.constant(2 : i32) : i32 + %15 = llvm.mlir.constant(3 : i32) : i32 + %16 = llvm.extractelement %arg0[%0 : i32] : vector<2xf32> + llvm.store %16, %arg1 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + %17 = llvm.shufflevector %arg0, %1 [0, 1, -1, -1] : vector<2xf32> + %18 = llvm.extractelement %17[%2 : i32] : vector<4xf32> + %19 = llvm.insertelement %18, %13[%14 : i32] : vector<4xf32> + %20 = llvm.insertelement %16, %19[%15 : i32] : vector<4xf32> + llvm.return %20 : vector<4xf32> + } + llvm.func @extractelt_insertion(%arg0: vector<2xi32>, %arg1: i32) -> vector<4xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %3 = llvm.mlir.constant(3 : i64) : i64 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.extractelement %arg0[%0 : i32] : vector<2xi32> + %6 = llvm.insertelement %5, %2[%3 : i64] : vector<4xi32> + %7 = llvm.add %arg1, %4 : i32 + %8 = llvm.extractelement %arg0[%7 : i32] : vector<2xi32> + %9 = llvm.icmp "eq" %8, %1 : i32 + %10 = llvm.select %9, %6, %2 : i1, vector<4xi32> + llvm.return %10 : vector<4xi32> + } + llvm.func @collectShuffleElts(%arg0: vector<2xf32>, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.poison : vector<4xf32> + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.extractelement %arg0[%0 : i32] : vector<2xf32> + %6 = llvm.extractelement %arg0[%1 : i32] : vector<2xf32> + %7 = llvm.insertelement %5, %2[%1 : i32] : vector<4xf32> + %8 = llvm.insertelement %6, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg1, %8[%4 : i32] : vector<4xf32> + llvm.return %9 : vector<4xf32> + } + llvm.func @insert_shuffle(%arg0: f32, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %3 = llvm.shufflevector %2, %arg1 [0, 5, 6, 7] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_shuffle_translate(%arg0: f32, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %3 = llvm.shufflevector %2, %arg1 [4, 0, 6, 7] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_not_undef_shuffle_translate(%arg0: f32, %arg1: vector<4xf32>, %arg2: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.insertelement %arg0, %arg2[%0 : i32] : vector<4xf32> + %2 = llvm.shufflevector %1, %arg1 [4, 5, 3, 7] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @insert_not_undef_shuffle_translate_commute(%arg0: f32, %arg1: vector<4xf32>, %arg2: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.insertelement %arg0, %arg2[%0 : i32] : vector<4xf32> + %2 = llvm.shufflevector %arg1, %1 [0, 6, 2, -1] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @insert_insert_shuffle_translate(%arg0: f32, %arg1: f32, %arg2: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg0, %arg2[%0 : i32] : vector<4xf32> + %3 = llvm.insertelement %arg1, %arg2[%1 : i32] : vector<4xf32> + %4 = llvm.shufflevector %2, %3 [4, 0, 6, 7] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @insert_insert_shuffle_translate_commute(%arg0: f32, %arg1: f32, %arg2: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg0, %arg2[%0 : i32] : vector<4xf32> + %3 = llvm.insertelement %arg1, %arg2[%1 : i32] : vector<4xf32> + %4 = llvm.shufflevector %2, %3 [0, 6, 2, 3] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @insert_insert_shuffle_translate_wrong_mask(%arg0: f32, %arg1: f32, %arg2: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg0, %arg2[%0 : i32] : vector<4xf32> + %3 = llvm.insertelement %arg1, %arg2[%1 : i32] : vector<4xf32> + %4 = llvm.shufflevector %2, %3 [0, 6, 2, 7] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @use(vector<4xf32>) + llvm.func @insert_not_undef_shuffle_translate_commute_uses(%arg0: f32, %arg1: vector<4xf32>, %arg2: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.insertelement %arg0, %arg2[%0 : i32] : vector<4xf32> + llvm.call @use(%1) : (vector<4xf32>) -> () + %2 = llvm.shufflevector %arg1, %1 [6, -1, 2, 3] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @insert_not_undef_shuffle_translate_commute_lengthen(%arg0: f32, %arg1: vector<4xf32>, %arg2: vector<4xf32>) -> vector<5xf32> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.insertelement %arg0, %arg2[%0 : i32] : vector<4xf32> + %2 = llvm.shufflevector %arg1, %1 [0, 6, 2, -1, -1] : vector<4xf32> + llvm.return %2 : vector<5xf32> + } + llvm.func @insert_nonzero_index_splat(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %3 = llvm.shufflevector %2, %0 [-1, 2, 2, -1] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_nonzero_index_splat_narrow(%arg0: f64) -> vector<3xf64> { + %0 = llvm.mlir.poison : vector<4xf64> + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf64> + %3 = llvm.shufflevector %2, %0 [3, -1, 3] : vector<4xf64> + llvm.return %3 : vector<3xf64> + } + llvm.func @insert_nonzero_index_splat_widen(%arg0: i7) -> vector<5xi7> { + %0 = llvm.mlir.poison : vector<4xi7> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi7> + %3 = llvm.shufflevector %2, %0 [-1, 1, 1, -1, 1] : vector<4xi7> + llvm.return %3 : vector<5xi7> + } + llvm.func @insert_nonzero_index_splat_extra_use(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + llvm.call @use(%2) : (vector<4xf32>) -> () + %3 = llvm.shufflevector %2, %0 [-1, 2, 2, -1] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_nonzero_index_splat_wrong_base(%arg0: f32, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.poison : vector<4xf32> + %2 = llvm.insertelement %arg0, %arg1[%0 : i32] : vector<4xf32> + %3 = llvm.shufflevector %2, %1 [-1, 2, 3, -1] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_nonzero_index_splat_wrong_index(%arg0: f32, %arg1: i32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.insertelement %arg0, %0[%arg1 : i32] : vector<4xf32> + %2 = llvm.shufflevector %1, %0 [-1, 1, 1, -1] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @insert_in_splat(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %4 = llvm.shufflevector %3, %0 [-1, 0, 0, -1] : vector<4xf32> + %5 = llvm.insertelement %arg0, %4[%2 : i32] : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @insert_in_splat_extra_uses(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + llvm.call @use(%3) : (vector<4xf32>) -> () + %4 = llvm.shufflevector %3, %0 [-1, 0, 0, -1] : vector<4xf32> + llvm.call @use(%4) : (vector<4xf32>) -> () + %5 = llvm.insertelement %arg0, %4[%2 : i32] : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @insert_in_splat_variable_index(%arg0: f32, %arg1: i32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %3 = llvm.shufflevector %2, %0 [-1, 0, 0, -1] : vector<4xf32> + %4 = llvm.insertelement %arg0, %3[%arg1 : i32] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @insert_in_nonsplat(%arg0: f32, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %4 = llvm.shufflevector %3, %arg1 [-1, 0, 4, -1] : vector<4xf32> + %5 = llvm.insertelement %arg0, %4[%2 : i32] : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @insert_in_nonsplat2(%arg0: f32, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : vector<4xf32> + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.insertelement %arg0, %arg1[%0 : i32] : vector<4xf32> + %4 = llvm.shufflevector %3, %1 [-1, 0, 1, -1] : vector<4xf32> + %5 = llvm.insertelement %arg0, %4[%2 : i32] : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @shuf_identity_padding(%arg0: vector<2xi8>, %arg1: i8) -> vector<4xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi8> + %4 = llvm.extractelement %arg0[%1 : i32] : vector<2xi8> + %5 = llvm.insertelement %4, %3[%1 : i32] : vector<4xi8> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<4xi8> + llvm.return %6 : vector<4xi8> + } + llvm.func @shuf_identity_extract(%arg0: vector<4xi8>, %arg1: i8) -> vector<3xi8> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.shufflevector %arg0, %0 [0, -1, -1] : vector<4xi8> + %4 = llvm.extractelement %arg0[%1 : i32] : vector<4xi8> + %5 = llvm.insertelement %4, %3[%1 : i32] : vector<3xi8> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<3xi8> + llvm.return %6 : vector<3xi8> + } + llvm.func @shuf_identity_extract_extra_use(%arg0: vector<6xf32>, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<6xf32> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.shufflevector %arg0, %0 [0, -1, -1, 3] : vector<6xf32> + llvm.call @use(%3) : (vector<4xf32>) -> () + %4 = llvm.extractelement %arg0[%1 : i32] : vector<6xf32> + %5 = llvm.insertelement %4, %3[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<4xf32> + llvm.return %6 : vector<4xf32> + } + llvm.func @shuf_identity_padding_variable_index(%arg0: vector<2xi8>, %arg1: i8, %arg2: i32) -> vector<4xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi8> + %3 = llvm.extractelement %arg0[%arg2 : i32] : vector<2xi8> + %4 = llvm.insertelement %3, %2[%arg2 : i32] : vector<4xi8> + %5 = llvm.insertelement %arg1, %4[%1 : i32] : vector<4xi8> + llvm.return %5 : vector<4xi8> + } + llvm.func @shuf_identity_padding_wrong_source_vec(%arg0: vector<2xi8>, %arg1: i8, %arg2: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi8> + %4 = llvm.extractelement %arg2[%1 : i32] : vector<2xi8> + %5 = llvm.insertelement %4, %3[%1 : i32] : vector<4xi8> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<4xi8> + llvm.return %6 : vector<4xi8> + } + llvm.func @shuf_identity_padding_wrong_index(%arg0: vector<2xi8>, %arg1: i8) -> vector<4xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi8> + %5 = llvm.extractelement %arg0[%1 : i32] : vector<2xi8> + %6 = llvm.insertelement %5, %4[%2 : i32] : vector<4xi8> + %7 = llvm.insertelement %arg1, %6[%3 : i32] : vector<4xi8> + llvm.return %7 : vector<4xi8> + } + llvm.func @insert_undemanded_element_op0(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + llvm.call @use(%2) : (vector<4xf32>) -> () + %3 = llvm.shufflevector %2, %arg1 [0, 7, 1, 4] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_undemanded_element_op1(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + llvm.call @use(%2) : (vector<4xf32>) -> () + %3 = llvm.shufflevector %arg1, %2 [3, 2, 1, 4] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_demanded_element_op0(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + llvm.call @use(%2) : (vector<4xf32>) -> () + %3 = llvm.shufflevector %2, %arg1 [3, 2, 1, 4] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_demanded_element_op1(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(4.300000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + llvm.call @use(%2) : (vector<4xf32>) -> () + %3 = llvm.shufflevector %arg1, %2 [0, 7, 1, 4] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @splat_constant(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.poison : vector<4xf32> + %3 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + %4 = llvm.shufflevector %3, %2 [3, 3, 3, 3] : vector<4xf32> + %5 = llvm.fadd %3, %4 : vector<4xf32> + llvm.return %5 : vector<4xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/insert-extract-shuffle.ll.mlir b/test/LLVMDialect/InstCombine/insert-extract-shuffle.ll.mlir new file mode 100644 index 000000000..741cf8caa --- /dev/null +++ b/test/LLVMDialect/InstCombine/insert-extract-shuffle.ll.mlir @@ -0,0 +1,498 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: vector<8xi8>) -> vector<1xi8> { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.undef : vector<1xi8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.extractelement %arg0[%0 : i32] : vector<8xi8> + %4 = llvm.insertelement %3, %1[%2 : i32] : vector<1xi8> + llvm.return %4 : vector<1xi8> + } + llvm.func @test2(%arg0: vector<8xi16>, %arg1: vector<8xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.undef : vector<4xi16> + %5 = llvm.extractelement %arg0[%0 : i32] : vector<8xi16> + %6 = llvm.extractelement %arg0[%1 : i32] : vector<8xi16> + %7 = llvm.extractelement %arg1[%2 : i32] : vector<8xi16> + %8 = llvm.extractelement %arg0[%3 : i32] : vector<8xi16> + %9 = llvm.insertelement %5, %4[%2 : i32] : vector<4xi16> + %10 = llvm.insertelement %6, %9[%1 : i32] : vector<4xi16> + %11 = llvm.insertelement %7, %10[%3 : i32] : vector<4xi16> + %12 = llvm.insertelement %8, %11[%0 : i32] : vector<4xi16> + llvm.return %12 : vector<4xi16> + } + llvm.func @test_vcopyq_lane_p64(%arg0: vector<2xi64>, %arg1: vector<1xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.extractelement %arg1[%0 : i32] : vector<1xi64> + %3 = llvm.insertelement %2, %arg0[%1 : i32] : vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @widen_extract2(%arg0: vector<4xf32>, %arg1: vector<2xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.extractelement %arg1[%0 : i32] : vector<2xf32> + %4 = llvm.extractelement %arg1[%1 : i32] : vector<2xf32> + %5 = llvm.insertelement %3, %arg0[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %4, %5[%2 : i32] : vector<4xf32> + llvm.return %6 : vector<4xf32> + } + llvm.func @widen_extract3(%arg0: vector<4xf32>, %arg1: vector<3xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.extractelement %arg1[%0 : i32] : vector<3xf32> + %4 = llvm.extractelement %arg1[%1 : i32] : vector<3xf32> + %5 = llvm.extractelement %arg1[%2 : i32] : vector<3xf32> + %6 = llvm.insertelement %3, %arg0[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %4, %6[%1 : i32] : vector<4xf32> + %8 = llvm.insertelement %5, %7[%0 : i32] : vector<4xf32> + llvm.return %8 : vector<4xf32> + } + llvm.func @widen_extract4(%arg0: vector<8xf32>, %arg1: vector<2xf32>) -> vector<8xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.extractelement %arg1[%0 : i32] : vector<2xf32> + %3 = llvm.insertelement %2, %arg0[%1 : i32] : vector<8xf32> + llvm.return %3 : vector<8xf32> + } + llvm.func @pr26015(%arg0: vector<4xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.mlir.constant(dense<0> : vector<8xi16>) : vector<8xi16> + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.constant(6 : i32) : i32 + %5 = llvm.mlir.constant(7 : i32) : i32 + %6 = llvm.extractelement %arg0[%0 : i32] : vector<4xi16> + %7 = llvm.insertelement %6, %2[%3 : i32] : vector<8xi16> + %8 = llvm.insertelement %1, %7[%4 : i32] : vector<8xi16> + %9 = llvm.extractelement %arg0[%3 : i32] : vector<4xi16> + %10 = llvm.insertelement %9, %8[%5 : i32] : vector<8xi16> + llvm.return %10 : vector<8xi16> + } + llvm.func @pr25999(%arg0: vector<4xi16>, %arg1: i1) -> vector<8xi16> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(4 : i16) : i16 + %2 = llvm.mlir.constant(0 : i16) : i16 + %3 = llvm.mlir.constant(dense<0> : vector<8xi16>) : vector<8xi16> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.mlir.constant(6 : i32) : i32 + %7 = llvm.mlir.constant(7 : i32) : i32 + %8 = llvm.extractelement %arg0[%0 : i32] : vector<4xi16> + llvm.cond_br %arg1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %9 = llvm.insertelement %8, %3[%5 : i32] : vector<8xi16> + %10 = llvm.insertelement %2, %9[%6 : i32] : vector<8xi16> + %11 = llvm.extractelement %arg0[%5 : i32] : vector<4xi16> + %12 = llvm.insertelement %11, %10[%7 : i32] : vector<8xi16> + llvm.return %12 : vector<8xi16> + ^bb2: // pred: ^bb0 + %13 = llvm.add %8, %1 : i16 + %14 = llvm.insertelement %13, %3[%4 : i32] : vector<8xi16> + llvm.return %14 : vector<8xi16> + } + llvm.func @pr25999_phis1(%arg0: i1, %arg1: vector<2xf64>, %arg2: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf64>) : vector<4xf64> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : vector<2xf64>, vector<4xf64>) + ^bb1: // pred: ^bb0 + %4 = llvm.call @dummy(%arg1) : (vector<2xf64>) -> vector<2xf64> + llvm.br ^bb2(%4, %1 : vector<2xf64>, vector<4xf64>) + ^bb2(%5: vector<2xf64>, %6: vector<4xf64>): // 2 preds: ^bb0, ^bb1 + %7 = llvm.extractelement %5[%2 : i32] : vector<2xf64> + %8 = llvm.insertelement %7, %6[%3 : i32] : vector<4xf64> + llvm.return %8 : vector<4xf64> + } + llvm.func @dummy(vector<2xf64>) -> vector<2xf64> + llvm.func @pr25999_phis2(%arg0: i1, %arg1: vector<2xf64>, %arg2: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf64>) : vector<4xf64> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1, %arg2 : vector<2xf64>, vector<4xf64>) + ^bb1: // pred: ^bb0 + %4 = llvm.call @dummy(%arg1) : (vector<2xf64>) -> vector<2xf64> + llvm.br ^bb2(%4, %1 : vector<2xf64>, vector<4xf64>) + ^bb2(%5: vector<2xf64>, %6: vector<4xf64>): // 2 preds: ^bb0, ^bb1 + %7 = llvm.fadd %5, %5 : vector<2xf64> + %8 = llvm.extractelement %7[%2 : i32] : vector<2xf64> + %9 = llvm.insertelement %8, %6[%3 : i32] : vector<4xf64> + llvm.return %9 : vector<4xf64> + } + llvm.func @pr26354(%arg0: !llvm.ptr, %arg1: i1) -> f64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.undef : vector<4xf64> + %3 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %4 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf64>) : vector<4xf64> + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> vector<2xf64> + %7 = llvm.extractelement %6[%0 : i32] : vector<2xf64> + %8 = llvm.extractelement %6[%1 : i32] : vector<2xf64> + llvm.cond_br %arg1, ^bb1, ^bb2(%2 : vector<4xf64>) + ^bb1: // pred: ^bb0 + %9 = llvm.insertelement %8, %4[%5 : i32] : vector<4xf64> + llvm.br ^bb2(%9 : vector<4xf64>) + ^bb2(%10: vector<4xf64>): // 2 preds: ^bb0, ^bb1 + %11 = llvm.extractelement %10[%1 : i32] : vector<4xf64> + %12 = llvm.fmul %7, %11 : f64 + llvm.return %12 : f64 + } + llvm.func @PR30923(%arg0: vector<2xf32>, %arg1: !llvm.ptr) -> vector<4xf32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.undef : vector<2xf32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.undef : f32 + %4 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %5 = llvm.mlir.undef : vector<4xf32> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %4, %5[%6 : i32] : vector<4xf32> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %4, %7[%8 : i32] : vector<4xf32> + %10 = llvm.mlir.constant(2 : i32) : i32 + %11 = llvm.insertelement %3, %9[%10 : i32] : vector<4xf32> + %12 = llvm.mlir.constant(3 : i32) : i32 + %13 = llvm.insertelement %3, %11[%12 : i32] : vector<4xf32> + %14 = llvm.mlir.constant(2 : i32) : i32 + %15 = llvm.mlir.constant(3 : i32) : i32 + %16 = llvm.extractelement %arg0[%0 : i32] : vector<2xf32> + llvm.store %16, %arg1 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + %17 = llvm.shufflevector %arg0, %1 [0, 1, -1, -1] : vector<2xf32> + %18 = llvm.extractelement %17[%2 : i32] : vector<4xf32> + %19 = llvm.insertelement %18, %13[%14 : i32] : vector<4xf32> + %20 = llvm.insertelement %16, %19[%15 : i32] : vector<4xf32> + llvm.return %20 : vector<4xf32> + } + llvm.func @extractelt_insertion(%arg0: vector<2xi32>, %arg1: i32) -> vector<4xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %3 = llvm.mlir.constant(3 : i64) : i64 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.extractelement %arg0[%0 : i32] : vector<2xi32> + %6 = llvm.insertelement %5, %2[%3 : i64] : vector<4xi32> + %7 = llvm.add %arg1, %4 : i32 + %8 = llvm.extractelement %arg0[%7 : i32] : vector<2xi32> + %9 = llvm.icmp "eq" %8, %1 : i32 + %10 = llvm.select %9, %6, %2 : i1, vector<4xi32> + llvm.return %10 : vector<4xi32> + } + llvm.func @collectShuffleElts(%arg0: vector<2xf32>, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.undef : vector<4xf32> + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.extractelement %arg0[%0 : i32] : vector<2xf32> + %6 = llvm.extractelement %arg0[%1 : i32] : vector<2xf32> + %7 = llvm.insertelement %5, %2[%1 : i32] : vector<4xf32> + %8 = llvm.insertelement %6, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg1, %8[%4 : i32] : vector<4xf32> + llvm.return %9 : vector<4xf32> + } + llvm.func @insert_shuffle(%arg0: f32, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %3 = llvm.shufflevector %2, %arg1 [0, 5, 6, 7] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_shuffle_translate(%arg0: f32, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %3 = llvm.shufflevector %2, %arg1 [4, 0, 6, 7] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_not_undef_shuffle_translate(%arg0: f32, %arg1: vector<4xf32>, %arg2: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.insertelement %arg0, %arg2[%0 : i32] : vector<4xf32> + %2 = llvm.shufflevector %1, %arg1 [4, 5, 3, 7] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @insert_not_undef_shuffle_translate_commute(%arg0: f32, %arg1: vector<4xf32>, %arg2: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.insertelement %arg0, %arg2[%0 : i32] : vector<4xf32> + %2 = llvm.shufflevector %arg1, %1 [0, 6, 2, -1] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @insert_insert_shuffle_translate(%arg0: f32, %arg1: f32, %arg2: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg0, %arg2[%0 : i32] : vector<4xf32> + %3 = llvm.insertelement %arg1, %arg2[%1 : i32] : vector<4xf32> + %4 = llvm.shufflevector %2, %3 [4, 0, 6, 7] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @insert_insert_shuffle_translate_commute(%arg0: f32, %arg1: f32, %arg2: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg0, %arg2[%0 : i32] : vector<4xf32> + %3 = llvm.insertelement %arg1, %arg2[%1 : i32] : vector<4xf32> + %4 = llvm.shufflevector %2, %3 [0, 6, 2, 3] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @insert_insert_shuffle_translate_wrong_mask(%arg0: f32, %arg1: f32, %arg2: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg0, %arg2[%0 : i32] : vector<4xf32> + %3 = llvm.insertelement %arg1, %arg2[%1 : i32] : vector<4xf32> + %4 = llvm.shufflevector %2, %3 [0, 6, 2, 7] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @use(vector<4xf32>) + llvm.func @insert_not_undef_shuffle_translate_commute_uses(%arg0: f32, %arg1: vector<4xf32>, %arg2: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.insertelement %arg0, %arg2[%0 : i32] : vector<4xf32> + llvm.call @use(%1) : (vector<4xf32>) -> () + %2 = llvm.shufflevector %arg1, %1 [6, -1, 2, 3] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @insert_not_undef_shuffle_translate_commute_lengthen(%arg0: f32, %arg1: vector<4xf32>, %arg2: vector<4xf32>) -> vector<5xf32> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.insertelement %arg0, %arg2[%0 : i32] : vector<4xf32> + %2 = llvm.shufflevector %arg1, %1 [0, 6, 2, -1, -1] : vector<4xf32> + llvm.return %2 : vector<5xf32> + } + llvm.func @insert_nonzero_index_splat(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %3 = llvm.shufflevector %2, %0 [-1, 2, 2, -1] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_nonzero_index_splat_narrow(%arg0: f64) -> vector<3xf64> { + %0 = llvm.mlir.undef : vector<4xf64> + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf64> + %3 = llvm.shufflevector %2, %0 [3, -1, 3] : vector<4xf64> + llvm.return %3 : vector<3xf64> + } + llvm.func @insert_nonzero_index_splat_widen(%arg0: i7) -> vector<5xi7> { + %0 = llvm.mlir.undef : vector<4xi7> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi7> + %3 = llvm.shufflevector %2, %0 [-1, 1, 1, -1, 1] : vector<4xi7> + llvm.return %3 : vector<5xi7> + } + llvm.func @insert_nonzero_index_splat_extra_use(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + llvm.call @use(%2) : (vector<4xf32>) -> () + %3 = llvm.shufflevector %2, %0 [-1, 2, 2, -1] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_nonzero_index_splat_wrong_base(%arg0: f32, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xf32> + %2 = llvm.insertelement %arg0, %arg1[%0 : i32] : vector<4xf32> + %3 = llvm.shufflevector %2, %1 [-1, 2, 3, -1] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_nonzero_index_splat_wrong_index(%arg0: f32, %arg1: i32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.insertelement %arg0, %0[%arg1 : i32] : vector<4xf32> + %2 = llvm.shufflevector %1, %0 [-1, 1, 1, -1] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @insert_in_splat(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %4 = llvm.shufflevector %3, %0 [-1, 0, 0, -1] : vector<4xf32> + %5 = llvm.insertelement %arg0, %4[%2 : i32] : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @insert_in_splat_extra_uses(%arg0: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + llvm.call @use(%3) : (vector<4xf32>) -> () + %4 = llvm.shufflevector %3, %0 [-1, 0, 0, -1] : vector<4xf32> + llvm.call @use(%4) : (vector<4xf32>) -> () + %5 = llvm.insertelement %arg0, %4[%2 : i32] : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @insert_in_splat_variable_index(%arg0: f32, %arg1: i32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %3 = llvm.shufflevector %2, %0 [-1, 0, 0, -1] : vector<4xf32> + %4 = llvm.insertelement %arg0, %3[%arg1 : i32] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @insert_in_nonsplat(%arg0: f32, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %4 = llvm.shufflevector %3, %arg1 [-1, 0, 4, -1] : vector<4xf32> + %5 = llvm.insertelement %arg0, %4[%2 : i32] : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @insert_in_nonsplat2(%arg0: f32, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xf32> + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.insertelement %arg0, %arg1[%0 : i32] : vector<4xf32> + %4 = llvm.shufflevector %3, %1 [-1, 0, 1, -1] : vector<4xf32> + %5 = llvm.insertelement %arg0, %4[%2 : i32] : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @shuf_identity_padding(%arg0: vector<2xi8>, %arg1: i8) -> vector<4xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi8> + %4 = llvm.extractelement %arg0[%1 : i32] : vector<2xi8> + %5 = llvm.insertelement %4, %3[%1 : i32] : vector<4xi8> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<4xi8> + llvm.return %6 : vector<4xi8> + } + llvm.func @shuf_identity_extract(%arg0: vector<4xi8>, %arg1: i8) -> vector<3xi8> { + %0 = llvm.mlir.undef : vector<4xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.shufflevector %arg0, %0 [0, -1, -1] : vector<4xi8> + %4 = llvm.extractelement %arg0[%1 : i32] : vector<4xi8> + %5 = llvm.insertelement %4, %3[%1 : i32] : vector<3xi8> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<3xi8> + llvm.return %6 : vector<3xi8> + } + llvm.func @shuf_identity_extract_extra_use(%arg0: vector<6xf32>, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<6xf32> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.shufflevector %arg0, %0 [0, -1, -1, 3] : vector<6xf32> + llvm.call @use(%3) : (vector<4xf32>) -> () + %4 = llvm.extractelement %arg0[%1 : i32] : vector<6xf32> + %5 = llvm.insertelement %4, %3[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<4xf32> + llvm.return %6 : vector<4xf32> + } + llvm.func @shuf_identity_padding_variable_index(%arg0: vector<2xi8>, %arg1: i8, %arg2: i32) -> vector<4xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi8> + %3 = llvm.extractelement %arg0[%arg2 : i32] : vector<2xi8> + %4 = llvm.insertelement %3, %2[%arg2 : i32] : vector<4xi8> + %5 = llvm.insertelement %arg1, %4[%1 : i32] : vector<4xi8> + llvm.return %5 : vector<4xi8> + } + llvm.func @shuf_identity_padding_wrong_source_vec(%arg0: vector<2xi8>, %arg1: i8, %arg2: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi8> + %4 = llvm.extractelement %arg2[%1 : i32] : vector<2xi8> + %5 = llvm.insertelement %4, %3[%1 : i32] : vector<4xi8> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<4xi8> + llvm.return %6 : vector<4xi8> + } + llvm.func @shuf_identity_padding_wrong_index(%arg0: vector<2xi8>, %arg1: i8) -> vector<4xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi8> + %5 = llvm.extractelement %arg0[%1 : i32] : vector<2xi8> + %6 = llvm.insertelement %5, %4[%2 : i32] : vector<4xi8> + %7 = llvm.insertelement %arg1, %6[%3 : i32] : vector<4xi8> + llvm.return %7 : vector<4xi8> + } + llvm.func @insert_undemanded_element_op0(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + llvm.call @use(%2) : (vector<4xf32>) -> () + %3 = llvm.shufflevector %2, %arg1 [0, 7, 1, 4] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_undemanded_element_op1(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + llvm.call @use(%2) : (vector<4xf32>) -> () + %3 = llvm.shufflevector %arg1, %2 [3, 2, 1, 4] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_undemanded_element_unequal_length_op0(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<5xf32> { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + llvm.call @use(%2) : (vector<4xf32>) -> () + %3 = llvm.shufflevector %2, %arg1 [-1, 0, 7, 1, 4] : vector<4xf32> + llvm.return %3 : vector<5xf32> + } + llvm.func @insert_undemanded_element_unequal_length_op1(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<5xf32> { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + llvm.call @use(%2) : (vector<4xf32>) -> () + %3 = llvm.shufflevector %arg1, %2 [-1, 3, 2, 1, 4] : vector<4xf32> + llvm.return %3 : vector<5xf32> + } + llvm.func @insert_demanded_element_op0(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + llvm.call @use(%2) : (vector<4xf32>) -> () + %3 = llvm.shufflevector %2, %arg1 [3, 2, 1, 4] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_demanded_element_op1(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(4.300000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + llvm.call @use(%2) : (vector<4xf32>) -> () + %3 = llvm.shufflevector %arg1, %2 [0, 7, 1, 4] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @insert_demanded_element_unequal_length_op0(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<5xf32> { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + llvm.call @use(%2) : (vector<4xf32>) -> () + %3 = llvm.shufflevector %2, %arg1 [-1, 3, 2, 1, 4] : vector<4xf32> + llvm.return %3 : vector<5xf32> + } + llvm.func @insert_demanded_element_unequal_length_op1(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<5xf32> { + %0 = llvm.mlir.constant(4.300000e+01 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + llvm.call @use(%2) : (vector<4xf32>) -> () + %3 = llvm.shufflevector %arg1, %2 [-1, 0, 7, 1, 4] : vector<4xf32> + llvm.return %3 : vector<5xf32> + } + llvm.func @splat_constant(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.undef : vector<4xf32> + %3 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + %4 = llvm.shufflevector %3, %2 [3, 3, 3, 3] : vector<4xf32> + %5 = llvm.fadd %3, %4 : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @infloop_D151807(%arg0: vector<4xf32>) -> vector<4xi32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %4 = llvm.shufflevector %arg0, %0 [2, -1] : vector<4xf32> + %5 = llvm.bitcast %4 : vector<2xf32> to vector<2xi32> + %6 = llvm.extractelement %5[%1 : i64] : vector<2xi32> + %7 = llvm.insertelement %6, %3[%1 : i64] : vector<4xi32> + llvm.return %7 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/insert-trunc.ll.mlir b/test/LLVMDialect/InstCombine/insert-trunc.ll.mlir new file mode 100644 index 000000000..33e18a99d --- /dev/null +++ b/test/LLVMDialect/InstCombine/insert-trunc.ll.mlir @@ -0,0 +1,312 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @use64(i64) + llvm.func @low_index_same_length_poison_basevec(%arg0: i64) -> vector<4xi16> { + %0 = llvm.mlir.poison : vector<4xi16> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.trunc %arg0 : i64 to i16 + %3 = llvm.insertelement %2, %0[%1 : i64] : vector<4xi16> + llvm.return %3 : vector<4xi16> + } + llvm.func @high_index_same_length_poison_basevec(%arg0: i64) -> vector<4xi16> { + %0 = llvm.mlir.poison : vector<4xi16> + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.trunc %arg0 : i64 to i16 + %3 = llvm.insertelement %2, %0[%1 : i64] : vector<4xi16> + llvm.return %3 : vector<4xi16> + } + llvm.func @wrong_index_same_length_poison_basevec(%arg0: i64) -> vector<4xi16> { + %0 = llvm.mlir.poison : vector<4xi16> + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.trunc %arg0 : i64 to i16 + %3 = llvm.insertelement %2, %0[%1 : i64] : vector<4xi16> + llvm.return %3 : vector<4xi16> + } + llvm.func @low_index_longer_length_poison_basevec(%arg0: i64) -> vector<8xi16> { + %0 = llvm.mlir.poison : vector<8xi16> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.trunc %arg0 : i64 to i16 + %3 = llvm.insertelement %2, %0[%1 : i64] : vector<8xi16> + llvm.return %3 : vector<8xi16> + } + llvm.func @high_index_longer_length_poison_basevec(%arg0: i64) -> vector<8xi16> { + %0 = llvm.mlir.poison : vector<8xi16> + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.trunc %arg0 : i64 to i16 + %3 = llvm.insertelement %2, %0[%1 : i64] : vector<8xi16> + llvm.return %3 : vector<8xi16> + } + llvm.func @wrong_index_longer_length_poison_basevec(%arg0: i64) -> vector<8xi16> { + %0 = llvm.mlir.poison : vector<8xi16> + %1 = llvm.mlir.constant(7 : i64) : i64 + %2 = llvm.trunc %arg0 : i64 to i16 + %3 = llvm.insertelement %2, %0[%1 : i64] : vector<8xi16> + llvm.return %3 : vector<8xi16> + } + llvm.func @low_index_shorter_length_poison_basevec(%arg0: i64) -> vector<2xi16> { + %0 = llvm.mlir.poison : vector<2xi16> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.trunc %arg0 : i64 to i16 + %3 = llvm.insertelement %2, %0[%1 : i64] : vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @wrong_index_shorter_length_poison_basevec(%arg0: i64) -> vector<4xi8> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.trunc %arg0 : i64 to i8 + %3 = llvm.insertelement %2, %0[%1 : i64] : vector<4xi8> + llvm.return %3 : vector<4xi8> + } + llvm.func @wrong_width_low_index_shorter_length_poison_basevec(%arg0: i65) -> vector<4xi8> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.trunc %arg0 : i65 to i8 + %3 = llvm.insertelement %2, %0[%1 : i64] : vector<4xi8> + llvm.return %3 : vector<4xi8> + } + llvm.func @low_index_shorter_length_poison_basevec_extra_use(%arg0: i64) -> vector<4xi8> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.trunc %arg0 : i64 to i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.insertelement %2, %0[%1 : i64] : vector<4xi8> + llvm.return %3 : vector<4xi8> + } + llvm.func @lshr_same_length_poison_basevec_le(%arg0: i64) -> vector<4xi16> { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i16 + %5 = llvm.insertelement %4, %1[%2 : i64] : vector<4xi16> + llvm.return %5 : vector<4xi16> + } + llvm.func @lshr_same_length_poison_basevec_be(%arg0: i64) -> vector<4xi16> { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i16 + %5 = llvm.insertelement %4, %1[%2 : i64] : vector<4xi16> + llvm.return %5 : vector<4xi16> + } + llvm.func @lshr_same_length_poison_basevec_both_endian(%arg0: i64) -> vector<4xi16> { + %0 = llvm.mlir.constant(48 : i64) : i64 + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i16 + %5 = llvm.insertelement %4, %1[%2 : i64] : vector<4xi16> + llvm.return %5 : vector<4xi16> + } + llvm.func @lshr_wrong_index_same_length_poison_basevec(%arg0: i64) -> vector<4xi16> { + %0 = llvm.mlir.constant(48 : i64) : i64 + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i16 + %5 = llvm.insertelement %4, %1[%2 : i64] : vector<4xi16> + llvm.return %5 : vector<4xi16> + } + llvm.func @lshr_longer_length_poison_basevec_le(%arg0: i64) -> vector<8xi16> { + %0 = llvm.mlir.constant(48 : i64) : i64 + %1 = llvm.mlir.poison : vector<8xi16> + %2 = llvm.mlir.constant(3 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i16 + %5 = llvm.insertelement %4, %1[%2 : i64] : vector<8xi16> + llvm.return %5 : vector<8xi16> + } + llvm.func @lshr_longer_length_poison_basevec_be(%arg0: i64) -> vector<8xi16> { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.poison : vector<8xi16> + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i16 + %5 = llvm.insertelement %4, %1[%2 : i64] : vector<8xi16> + llvm.return %5 : vector<8xi16> + } + llvm.func @lshr_wrong_index_longer_length_poison_basevec(%arg0: i64) -> vector<8xi16> { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.poison : vector<8xi16> + %2 = llvm.mlir.constant(6 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i16 + %5 = llvm.insertelement %4, %1[%2 : i64] : vector<8xi16> + llvm.return %5 : vector<8xi16> + } + llvm.func @lshr_shorter_length_poison_basevec_le(%arg0: i64) -> vector<2xi16> { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.poison : vector<2xi16> + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i16 + %5 = llvm.insertelement %4, %1[%2 : i64] : vector<2xi16> + llvm.return %5 : vector<2xi16> + } + llvm.func @lshr_shorter_length_poison_basevec_be(%arg0: i64) -> vector<4xi8> { + %0 = llvm.mlir.constant(40 : i64) : i64 + %1 = llvm.mlir.poison : vector<4xi8> + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i8 + %5 = llvm.insertelement %4, %1[%2 : i64] : vector<4xi8> + llvm.return %5 : vector<4xi8> + } + llvm.func @lshr_wrong_index_shorter_length_poison_basevec(%arg0: i64) -> vector<4xi8> { + %0 = llvm.mlir.constant(40 : i64) : i64 + %1 = llvm.mlir.poison : vector<4xi8> + %2 = llvm.mlir.constant(3 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i8 + %5 = llvm.insertelement %4, %1[%2 : i64] : vector<4xi8> + llvm.return %5 : vector<4xi8> + } + llvm.func @lshr_wrong_shift_shorter_length_poison_basevec(%arg0: i64) -> vector<4xi8> { + %0 = llvm.mlir.constant(57 : i64) : i64 + %1 = llvm.mlir.poison : vector<4xi8> + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i8 + %5 = llvm.insertelement %4, %1[%2 : i64] : vector<4xi8> + llvm.return %5 : vector<4xi8> + } + llvm.func @lshr_shorter_length_poison_basevec_be_extra_use(%arg0: i64) -> vector<4xi8> { + %0 = llvm.mlir.constant(40 : i64) : i64 + %1 = llvm.mlir.poison : vector<4xi8> + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.trunc %3 : i64 to i8 + %5 = llvm.insertelement %4, %1[%2 : i64] : vector<4xi8> + llvm.return %5 : vector<4xi8> + } + llvm.func @low_index_same_length_basevec(%arg0: i64, %arg1: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.trunc %arg0 : i64 to i16 + %2 = llvm.insertelement %1, %arg1[%0 : i64] : vector<4xi16> + llvm.return %2 : vector<4xi16> + } + llvm.func @high_index_same_length_basevec(%arg0: i64, %arg1: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.trunc %arg0 : i64 to i16 + %2 = llvm.insertelement %1, %arg1[%0 : i64] : vector<4xi16> + llvm.return %2 : vector<4xi16> + } + llvm.func @wrong_index_same_length_basevec(%arg0: i64, %arg1: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.trunc %arg0 : i64 to i16 + %2 = llvm.insertelement %1, %arg1[%0 : i64] : vector<4xi16> + llvm.return %2 : vector<4xi16> + } + llvm.func @low_index_longer_length_basevec(%arg0: i64, %arg1: vector<8xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.trunc %arg0 : i64 to i16 + %2 = llvm.insertelement %1, %arg1[%0 : i64] : vector<8xi16> + llvm.return %2 : vector<8xi16> + } + llvm.func @high_index_longer_length_basevec(%arg0: i64, %arg1: vector<8xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.trunc %arg0 : i64 to i16 + %2 = llvm.insertelement %1, %arg1[%0 : i64] : vector<8xi16> + llvm.return %2 : vector<8xi16> + } + llvm.func @wrong_index_longer_length_basevec(%arg0: i64, %arg1: vector<8xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.trunc %arg0 : i64 to i16 + %2 = llvm.insertelement %1, %arg1[%0 : i64] : vector<8xi16> + llvm.return %2 : vector<8xi16> + } + llvm.func @low_index_shorter_length_basevec(%arg0: i64, %arg1: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.trunc %arg0 : i64 to i16 + %2 = llvm.insertelement %1, %arg1[%0 : i64] : vector<2xi16> + llvm.return %2 : vector<2xi16> + } + llvm.func @wrong_index_shorter_length_basevec(%arg0: i64, %arg1: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.trunc %arg0 : i64 to i8 + %2 = llvm.insertelement %1, %arg1[%0 : i64] : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @lshr_same_length_basevec_le(%arg0: i64, %arg1: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i16 + %4 = llvm.insertelement %3, %arg1[%1 : i64] : vector<4xi16> + llvm.return %4 : vector<4xi16> + } + llvm.func @lshr_same_length_basevec_be(%arg0: i64, %arg1: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i16 + %4 = llvm.insertelement %3, %arg1[%1 : i64] : vector<4xi16> + llvm.return %4 : vector<4xi16> + } + llvm.func @lshr_same_length_basevec_both_endian(%arg0: i64, %arg1: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(48 : i64) : i64 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i16 + %4 = llvm.insertelement %3, %arg1[%1 : i64] : vector<4xi16> + llvm.return %4 : vector<4xi16> + } + llvm.func @lshr_wrong_index_same_length_basevec(%arg0: i64, %arg1: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(48 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i16 + %4 = llvm.insertelement %3, %arg1[%1 : i64] : vector<4xi16> + llvm.return %4 : vector<4xi16> + } + llvm.func @lshr_longer_length_basevec_le(%arg0: i64, %arg1: vector<8xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(48 : i64) : i64 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i16 + %4 = llvm.insertelement %3, %arg1[%1 : i64] : vector<8xi16> + llvm.return %4 : vector<8xi16> + } + llvm.func @lshr_longer_length_basevec_be(%arg0: i64, %arg1: vector<8xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i16 + %4 = llvm.insertelement %3, %arg1[%1 : i64] : vector<8xi16> + llvm.return %4 : vector<8xi16> + } + llvm.func @lshr_wrong_index_longer_length_basevec(%arg0: i64, %arg1: vector<8xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(6 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i16 + %4 = llvm.insertelement %3, %arg1[%1 : i64] : vector<8xi16> + llvm.return %4 : vector<8xi16> + } + llvm.func @lshr_shorter_length_basevec_le(%arg0: i64, %arg1: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i16 + %4 = llvm.insertelement %3, %arg1[%1 : i64] : vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @lshr_shorter_length_basevec_be(%arg0: i64, %arg1: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(48 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i8 + %4 = llvm.insertelement %3, %arg1[%1 : i64] : vector<4xi8> + llvm.return %4 : vector<4xi8> + } + llvm.func @lshr_wrong_index_shorter_length_basevec(%arg0: i64, %arg1: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(40 : i64) : i64 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i8 + %4 = llvm.insertelement %3, %arg1[%1 : i64] : vector<4xi8> + llvm.return %4 : vector<4xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/insert-val-extract-elem.ll.mlir b/test/LLVMDialect/InstCombine/insert-val-extract-elem.ll.mlir new file mode 100644 index 000000000..352c972e1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/insert-val-extract-elem.ll.mlir @@ -0,0 +1,64 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @julia_2xdouble(%arg0: !llvm.ptr {llvm.sret = !llvm.array<2 x f64>}, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.array<2 x f64> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.load %arg1 {alignment = 16 : i64} : !llvm.ptr -> vector<2xf64> + %4 = llvm.extractelement %3[%0 : i32] : vector<2xf64> + %5 = llvm.insertvalue %4, %1[0] : !llvm.array<2 x f64> + %6 = llvm.extractelement %3[%2 : i32] : vector<2xf64> + %7 = llvm.insertvalue %6, %5[1] : !llvm.array<2 x f64> + llvm.store %7, %arg0 {alignment = 4 : i64} : !llvm.array<2 x f64>, !llvm.ptr + llvm.return + } + llvm.func @julia_2xi64(%arg0: !llvm.ptr {llvm.sret = !llvm.array<2 x i64>}, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.array<2 x i64> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.load %arg1 {alignment = 16 : i64} : !llvm.ptr -> vector<2xi64> + %4 = llvm.extractelement %3[%0 : i32] : vector<2xi64> + %5 = llvm.insertvalue %4, %1[0] : !llvm.array<2 x i64> + %6 = llvm.extractelement %3[%0 : i32] : vector<2xi64> + %7 = llvm.insertvalue %6, %5[1] : !llvm.array<2 x i64> + %8 = llvm.extractelement %3[%2 : i32] : vector<2xi64> + %9 = llvm.insertvalue %8, %7[0] : !llvm.array<2 x i64> + llvm.store %9, %arg0 {alignment = 4 : i64} : !llvm.array<2 x i64>, !llvm.ptr + llvm.return + } + llvm.func @julia_4xfloat(%arg0: !llvm.ptr {llvm.sret = !llvm.array<4 x f32>}, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.array<4 x f32> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.load %arg1 {alignment = 16 : i64} : !llvm.ptr -> vector<4xf32> + %6 = llvm.extractelement %5[%0 : i32] : vector<4xf32> + %7 = llvm.insertvalue %6, %1[0] : !llvm.array<4 x f32> + %8 = llvm.extractelement %5[%2 : i32] : vector<4xf32> + %9 = llvm.insertvalue %8, %7[1] : !llvm.array<4 x f32> + %10 = llvm.extractelement %5[%3 : i32] : vector<4xf32> + %11 = llvm.insertvalue %10, %9[2] : !llvm.array<4 x f32> + %12 = llvm.extractelement %5[%4 : i32] : vector<4xf32> + %13 = llvm.insertvalue %12, %11[3] : !llvm.array<4 x f32> + llvm.store %13, %arg0 {alignment = 4 : i64} : !llvm.array<4 x f32>, !llvm.ptr + llvm.return + } + llvm.func @julia_pseudovec(%arg0: !llvm.ptr {llvm.sret = !llvm.struct<"pseudovec", (f32, f32, f32, f32)>}, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.struct<"pseudovec", (f32, f32, f32, f32)> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.load %arg1 {alignment = 16 : i64} : !llvm.ptr -> vector<4xf32> + %6 = llvm.extractelement %5[%0 : i32] : vector<4xf32> + %7 = llvm.insertvalue %6, %1[0] : !llvm.struct<"pseudovec", (f32, f32, f32, f32)> + %8 = llvm.extractelement %5[%2 : i32] : vector<4xf32> + %9 = llvm.insertvalue %8, %7[1] : !llvm.struct<"pseudovec", (f32, f32, f32, f32)> + %10 = llvm.extractelement %5[%3 : i32] : vector<4xf32> + %11 = llvm.insertvalue %10, %9[2] : !llvm.struct<"pseudovec", (f32, f32, f32, f32)> + %12 = llvm.extractelement %5[%4 : i32] : vector<4xf32> + %13 = llvm.insertvalue %12, %11[3] : !llvm.struct<"pseudovec", (f32, f32, f32, f32)> + llvm.store %13, %arg0 {alignment = 4 : i64} : !llvm.struct<"pseudovec", (f32, f32, f32, f32)>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/insertelement-bitcast.ll.mlir b/test/LLVMDialect/InstCombine/insertelement-bitcast.ll.mlir new file mode 100644 index 000000000..94668e1d8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/insertelement-bitcast.ll.mlir @@ -0,0 +1,49 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use_f32(f32) + llvm.func @use_v4f32(vector<4xf32>) + llvm.func @bitcast_inselt(%arg0: i32, %arg1: vector<4xi32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : i32 to f32 + %2 = llvm.bitcast %arg1 : vector<4xi32> to vector<4xf32> + %3 = llvm.insertelement %1, %2[%0 : i32] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @bitcast_inselt_use1(%arg0: i32, %arg1: vector<4xi32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.bitcast %arg0 : i32 to f32 + llvm.call @use_f32(%1) : (f32) -> () + %2 = llvm.bitcast %arg1 : vector<4xi32> to vector<4xf32> + %3 = llvm.insertelement %1, %2[%0 : i32] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @bitcast_inselt_use2(%arg0: i32, %arg1: vector<4xi32>, %arg2: i32) -> vector<4xf32> { + %0 = llvm.bitcast %arg0 : i32 to f32 + %1 = llvm.bitcast %arg1 : vector<4xi32> to vector<4xf32> + llvm.call @use_v4f32(%1) : (vector<4xf32>) -> () + %2 = llvm.insertelement %0, %1[%arg2 : i32] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @bitcast_inselt_use3(%arg0: i32, %arg1: vector<4xi32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : i32 to f32 + llvm.call @use_f32(%1) : (f32) -> () + %2 = llvm.bitcast %arg1 : vector<4xi32> to vector<4xf32> + llvm.call @use_v4f32(%2) : (vector<4xf32>) -> () + %3 = llvm.insertelement %1, %2[%0 : i32] : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @bitcast_inselt_wrong_bitcast1(%arg0: i32, %arg1: i64) -> vector<2xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : i32 to f32 + %2 = llvm.bitcast %arg1 : i64 to vector<2xf32> + %3 = llvm.insertelement %1, %2[%0 : i32] : vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @bitcast_inselt_wrong_bitcast2(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg0 : vector<2xi16> to f32 + %2 = llvm.bitcast %arg1 : vector<2xi32> to vector<2xf32> + %3 = llvm.insertelement %1, %2[%0 : i32] : vector<2xf32> + llvm.return %3 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/insertelement.ll.mlir b/test/LLVMDialect/InstCombine/insertelement.ll.mlir new file mode 100644 index 000000000..fd5d97a61 --- /dev/null +++ b/test/LLVMDialect/InstCombine/insertelement.ll.mlir @@ -0,0 +1,48 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @insert_known_idx(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<7> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : vector<4xi32> + %4 = llvm.insertelement %1, %3[%2 : i32] : vector<4xi32> + %5 = llvm.and %4, %0 : vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @insert_unknown_idx(%arg0: vector<4xi32>, %arg1: i32) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<7> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.and %arg0, %0 : vector<4xi32> + %3 = llvm.insertelement %1, %2[%arg1 : i32] : vector<4xi32> + %4 = llvm.and %3, %0 : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @insert_known_any_idx(%arg0: vector<2xi8>, %arg1: i8, %arg2: i32) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(16 : i8) : i8 + %2 = llvm.or %arg0, %0 : vector<2xi8> + %3 = llvm.or %arg1, %1 : i8 + %4 = llvm.insertelement %3, %2[%arg2 : i32] : vector<2xi8> + %5 = llvm.and %4, %0 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @insert_known_any_idx_fail1(%arg0: vector<2xi8>, %arg1: i8, %arg2: i32) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[17, 33]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(16 : i8) : i8 + %2 = llvm.mlir.constant(dense<16> : vector<2xi8>) : vector<2xi8> + %3 = llvm.or %arg0, %0 : vector<2xi8> + %4 = llvm.or %arg1, %1 : i8 + %5 = llvm.insertelement %4, %3[%arg2 : i32] : vector<2xi8> + %6 = llvm.and %5, %2 : vector<2xi8> + llvm.return %6 : vector<2xi8> + } + llvm.func @insert_known_any_idx_fail2(%arg0: vector<2xi8>, %arg1: i8, %arg2: i32) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[17, 31]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.mlir.constant(dense<16> : vector<2xi8>) : vector<2xi8> + %3 = llvm.or %arg0, %0 : vector<2xi8> + %4 = llvm.or %arg1, %1 : i8 + %5 = llvm.insertelement %4, %3[%arg2 : i32] : vector<2xi8> + %6 = llvm.and %5, %2 : vector<2xi8> + llvm.return %6 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/insertelt-trunc.ll.mlir b/test/LLVMDialect/InstCombine/insertelt-trunc.ll.mlir new file mode 100644 index 000000000..b1a1bffa8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/insertelt-trunc.ll.mlir @@ -0,0 +1,214 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i16) + llvm.func @use_vec(vector<8xi16>) + llvm.func @insert_01_poison_v4i16(%arg0: i32) -> vector<4xi16> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.lshr %arg0, %0 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.trunc %arg0 : i32 to i16 + %7 = llvm.insertelement %6, %1[%2 : i64] : vector<4xi16> + %8 = llvm.insertelement %5, %7[%3 : i64] : vector<4xi16> + llvm.return %8 : vector<4xi16> + } + llvm.func @insert_10_poison_v8i16(%arg0: i32) -> vector<8xi16> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.poison : vector<8xi16> + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.lshr %arg0, %0 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.trunc %arg0 : i32 to i16 + %7 = llvm.insertelement %6, %1[%2 : i64] : vector<8xi16> + %8 = llvm.insertelement %5, %7[%3 : i64] : vector<8xi16> + llvm.return %8 : vector<8xi16> + } + llvm.func @insert_12_poison_v4i32(%arg0: i64) -> vector<4xi32> { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.poison : vector<4xi32> + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(2 : i64) : i64 + %4 = llvm.lshr %arg0, %0 : i64 + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.trunc %arg0 : i64 to i32 + %7 = llvm.insertelement %6, %1[%2 : i64] : vector<4xi32> + %8 = llvm.insertelement %5, %7[%3 : i64] : vector<4xi32> + llvm.return %8 : vector<4xi32> + } + llvm.func @insert_21_poison_v4i16(%arg0: i32) -> vector<4xi16> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.lshr %arg0, %0 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.trunc %arg0 : i32 to i16 + %7 = llvm.insertelement %6, %1[%2 : i64] : vector<4xi16> + %8 = llvm.insertelement %5, %7[%3 : i64] : vector<4xi16> + llvm.return %8 : vector<4xi16> + } + llvm.func @insert_23_poison_v4i32(%arg0: i64) -> vector<4xi32> { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.poison : vector<4xi32> + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.mlir.constant(3 : i64) : i64 + %4 = llvm.lshr %arg0, %0 : i64 + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.trunc %arg0 : i64 to i32 + %7 = llvm.insertelement %6, %1[%2 : i64] : vector<4xi32> + %8 = llvm.insertelement %5, %7[%3 : i64] : vector<4xi32> + llvm.return %8 : vector<4xi32> + } + llvm.func @insert_32_poison_v4i16(%arg0: i32) -> vector<4xi16> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.mlir.constant(3 : i64) : i64 + %3 = llvm.mlir.constant(2 : i64) : i64 + %4 = llvm.lshr %arg0, %0 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.trunc %arg0 : i32 to i16 + %7 = llvm.insertelement %6, %1[%2 : i64] : vector<4xi16> + %8 = llvm.insertelement %5, %7[%3 : i64] : vector<4xi16> + llvm.return %8 : vector<4xi16> + } + llvm.func @insert_01_v2i16(%arg0: i32, %arg1: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i16 + %5 = llvm.trunc %arg0 : i32 to i16 + %6 = llvm.insertelement %5, %arg1[%1 : i64] : vector<2xi16> + %7 = llvm.insertelement %4, %6[%2 : i64] : vector<2xi16> + llvm.return %7 : vector<2xi16> + } + llvm.func @insert_10_v8i16(%arg0: i32, %arg1: vector<8xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i16 + %5 = llvm.trunc %arg0 : i32 to i16 + %6 = llvm.insertelement %5, %arg1[%1 : i64] : vector<8xi16> + %7 = llvm.insertelement %4, %6[%2 : i64] : vector<8xi16> + llvm.return %7 : vector<8xi16> + } + llvm.func @insert_12_v4i32(%arg0: i64, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i32 + %5 = llvm.trunc %arg0 : i64 to i32 + %6 = llvm.insertelement %5, %arg1[%1 : i64] : vector<4xi32> + %7 = llvm.insertelement %4, %6[%2 : i64] : vector<4xi32> + llvm.return %7 : vector<4xi32> + } + llvm.func @insert_21_v4i16(%arg0: i32, %arg1: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i16 + %5 = llvm.trunc %arg0 : i32 to i16 + %6 = llvm.insertelement %5, %arg1[%1 : i64] : vector<4xi16> + %7 = llvm.insertelement %4, %6[%2 : i64] : vector<4xi16> + llvm.return %7 : vector<4xi16> + } + llvm.func @insert_23_v4i32(%arg0: i64, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.mlir.constant(3 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i32 + %5 = llvm.trunc %arg0 : i64 to i32 + %6 = llvm.insertelement %5, %arg1[%1 : i64] : vector<4xi32> + %7 = llvm.insertelement %4, %6[%2 : i64] : vector<4xi32> + llvm.return %7 : vector<4xi32> + } + llvm.func @insert_32_v4i16(%arg0: i32, %arg1: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i16 + %5 = llvm.trunc %arg0 : i32 to i16 + %6 = llvm.insertelement %5, %arg1[%1 : i64] : vector<4xi16> + %7 = llvm.insertelement %4, %6[%2 : i64] : vector<4xi16> + llvm.return %7 : vector<4xi16> + } + llvm.func @insert_01_v4i16_wrong_shift1(%arg0: i32) -> vector<4xi16> { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.lshr %arg0, %0 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.trunc %arg0 : i32 to i16 + %7 = llvm.insertelement %6, %1[%2 : i64] : vector<4xi16> + %8 = llvm.insertelement %5, %7[%3 : i64] : vector<4xi16> + llvm.return %8 : vector<4xi16> + } + llvm.func @insert_01_v4i16_wrong_op(%arg0: i32, %arg1: i32) -> vector<4xi16> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.lshr %arg0, %0 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.trunc %arg1 : i32 to i16 + %7 = llvm.insertelement %6, %1[%2 : i64] : vector<4xi16> + %8 = llvm.insertelement %5, %7[%3 : i64] : vector<4xi16> + llvm.return %8 : vector<4xi16> + } + llvm.func @insert_67_v4i16_uses1(%arg0: i32, %arg1: vector<8xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(6 : i64) : i64 + %2 = llvm.mlir.constant(7 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i16 + llvm.call @use(%4) : (i16) -> () + %5 = llvm.trunc %arg0 : i32 to i16 + %6 = llvm.insertelement %5, %arg1[%1 : i64] : vector<8xi16> + %7 = llvm.insertelement %4, %6[%2 : i64] : vector<8xi16> + llvm.return %7 : vector<8xi16> + } + llvm.func @insert_76_v4i16_uses2(%arg0: i32, %arg1: vector<8xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(7 : i64) : i64 + %2 = llvm.mlir.constant(6 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i16 + %5 = llvm.trunc %arg0 : i32 to i16 + llvm.call @use(%5) : (i16) -> () + %6 = llvm.insertelement %5, %arg1[%1 : i64] : vector<8xi16> + %7 = llvm.insertelement %4, %6[%2 : i64] : vector<8xi16> + llvm.return %7 : vector<8xi16> + } + llvm.func @insert_67_v4i16_uses3(%arg0: i32, %arg1: vector<8xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(6 : i64) : i64 + %2 = llvm.mlir.constant(7 : i64) : i64 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.trunc %3 : i32 to i16 + %5 = llvm.trunc %arg0 : i32 to i16 + %6 = llvm.insertelement %5, %arg1[%1 : i64] : vector<8xi16> + llvm.call @use_vec(%6) : (vector<8xi16>) -> () + %7 = llvm.insertelement %4, %6[%2 : i64] : vector<8xi16> + llvm.return %7 : vector<8xi16> + } + llvm.func @insert_01_poison_v4i16_high_first(%arg0: i32) -> vector<4xi16> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.lshr %arg0, %0 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.trunc %arg0 : i32 to i16 + %7 = llvm.insertelement %5, %1[%2 : i64] : vector<4xi16> + %8 = llvm.insertelement %6, %7[%3 : i64] : vector<4xi16> + llvm.return %8 : vector<4xi16> + } +} diff --git a/test/LLVMDialect/InstCombine/int_sideeffect.ll.mlir b/test/LLVMDialect/InstCombine/int_sideeffect.ll.mlir index 202652536..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/int_sideeffect.ll.mlir +++ b/test/LLVMDialect/InstCombine/int_sideeffect.ll.mlir @@ -1,13 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.sideeffect", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.000000e+00 : f32} : () -> f32 - "llvm.store"(%0, %arg0) : (f32, !llvm.ptr) -> () - "llvm.call"() {callee = @llvm.sideeffect, fastmathFlags = #llvm.fastmath<>} : () -> () - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "s2l", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/integer-round-up-pow2-alignment.ll.mlir b/test/LLVMDialect/InstCombine/integer-round-up-pow2-alignment.ll.mlir new file mode 100644 index 000000000..1dc71a6b0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/integer-round-up-pow2-alignment.ll.mlir @@ -0,0 +1,457 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use.i8(i8) + llvm.func @use.v2i4(vector<2xi4>) + llvm.func @use.i1(i1) + llvm.func @t0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(16 : i8) : i8 + %3 = llvm.mlir.constant(-16 : i8) : i8 + %4 = llvm.and %arg0, %0 : i8 + %5 = llvm.icmp "eq" %4, %1 : i8 + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.select %5, %arg0, %7 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @t1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(31 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(32 : i8) : i8 + %3 = llvm.mlir.constant(-32 : i8) : i8 + %4 = llvm.and %arg0, %0 : i8 + %5 = llvm.icmp "eq" %4, %1 : i8 + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.select %5, %arg0, %7 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @t2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(-16 : i8) : i8 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + %5 = llvm.add %arg0, %0 : i8 + %6 = llvm.and %5, %2 : i8 + %7 = llvm.select %4, %arg0, %6 : i1, i8 + llvm.return %7 : i8 + } + llvm.func @t3_commutative(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(16 : i8) : i8 + %3 = llvm.mlir.constant(-16 : i8) : i8 + %4 = llvm.and %arg0, %0 : i8 + %5 = llvm.icmp "ne" %4, %1 : i8 + llvm.call @use.i1(%5) : (i1) -> () + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.select %5, %7, %arg0 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @t4_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<16> : vector<2xi8>) : vector<2xi8> + %4 = llvm.mlir.constant(dense<-16> : vector<2xi8>) : vector<2xi8> + %5 = llvm.and %arg0, %0 : vector<2xi8> + %6 = llvm.icmp "eq" %5, %2 : vector<2xi8> + %7 = llvm.add %arg0, %3 : vector<2xi8> + %8 = llvm.and %7, %4 : vector<2xi8> + %9 = llvm.select %6, %arg0, %8 : vector<2xi1>, vector<2xi8> + llvm.return %9 : vector<2xi8> + } + llvm.func @t5_splat_poison_0b0001(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<16> : vector<2xi8>) : vector<2xi8> + %4 = llvm.mlir.poison : i8 + %5 = llvm.mlir.constant(-16 : i8) : i8 + %6 = llvm.mlir.undef : vector<2xi8> + %7 = llvm.mlir.constant(0 : i32) : i32 + %8 = llvm.insertelement %5, %6[%7 : i32] : vector<2xi8> + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.insertelement %4, %8[%9 : i32] : vector<2xi8> + %11 = llvm.and %arg0, %0 : vector<2xi8> + %12 = llvm.icmp "eq" %11, %2 : vector<2xi8> + %13 = llvm.add %arg0, %3 : vector<2xi8> + %14 = llvm.and %13, %10 : vector<2xi8> + %15 = llvm.select %12, %arg0, %14 : vector<2xi1>, vector<2xi8> + llvm.return %15 : vector<2xi8> + } + llvm.func @t5_splat_poison_0b0010(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.poison : i8 + %4 = llvm.mlir.constant(16 : i8) : i8 + %5 = llvm.mlir.undef : vector<2xi8> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %4, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %3, %7[%8 : i32] : vector<2xi8> + %10 = llvm.mlir.constant(dense<-16> : vector<2xi8>) : vector<2xi8> + %11 = llvm.and %arg0, %0 : vector<2xi8> + %12 = llvm.icmp "eq" %11, %2 : vector<2xi8> + %13 = llvm.add %arg0, %9 : vector<2xi8> + %14 = llvm.and %13, %10 : vector<2xi8> + %15 = llvm.select %12, %arg0, %14 : vector<2xi1>, vector<2xi8> + llvm.return %15 : vector<2xi8> + } + llvm.func @t5_splat_poison_0b0100(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mlir.constant(dense<16> : vector<2xi8>) : vector<2xi8> + %9 = llvm.mlir.constant(dense<-16> : vector<2xi8>) : vector<2xi8> + %10 = llvm.and %arg0, %0 : vector<2xi8> + %11 = llvm.icmp "eq" %10, %7 : vector<2xi8> + %12 = llvm.add %arg0, %8 : vector<2xi8> + %13 = llvm.and %12, %9 : vector<2xi8> + %14 = llvm.select %11, %arg0, %13 : vector<2xi1>, vector<2xi8> + llvm.return %14 : vector<2xi8> + } + llvm.func @t5_splat_poison_0b1000(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(0 : i8) : i8 + %8 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %9 = llvm.mlir.constant(dense<16> : vector<2xi8>) : vector<2xi8> + %10 = llvm.mlir.constant(dense<-16> : vector<2xi8>) : vector<2xi8> + %11 = llvm.and %arg0, %6 : vector<2xi8> + %12 = llvm.icmp "eq" %11, %8 : vector<2xi8> + %13 = llvm.add %arg0, %9 : vector<2xi8> + %14 = llvm.and %13, %10 : vector<2xi8> + %15 = llvm.select %12, %arg0, %14 : vector<2xi1>, vector<2xi8> + llvm.return %15 : vector<2xi8> + } + llvm.func @t6_nonsplat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[15, 31]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<[16, 32]> : vector<2xi8>) : vector<2xi8> + %4 = llvm.mlir.constant(dense<[-16, -32]> : vector<2xi8>) : vector<2xi8> + %5 = llvm.and %arg0, %0 : vector<2xi8> + %6 = llvm.icmp "eq" %5, %2 : vector<2xi8> + %7 = llvm.add %arg0, %3 : vector<2xi8> + %8 = llvm.and %7, %4 : vector<2xi8> + %9 = llvm.select %6, %arg0, %8 : vector<2xi1>, vector<2xi8> + llvm.return %9 : vector<2xi8> + } + llvm.func @t7_nonsplat_bias(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<[15, 16]> : vector<2xi8>) : vector<2xi8> + %4 = llvm.mlir.constant(dense<-16> : vector<2xi8>) : vector<2xi8> + %5 = llvm.and %arg0, %0 : vector<2xi8> + %6 = llvm.icmp "eq" %5, %2 : vector<2xi8> + %7 = llvm.add %arg0, %3 : vector<2xi8> + %8 = llvm.and %7, %4 : vector<2xi8> + %9 = llvm.select %6, %arg0, %8 : vector<2xi1>, vector<2xi8> + llvm.return %9 : vector<2xi8> + } + llvm.func @t8_nonsplat_masked_by_poison_0b0001(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[15, 31]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<[16, 32]> : vector<2xi8>) : vector<2xi8> + %4 = llvm.mlir.poison : i8 + %5 = llvm.mlir.constant(-16 : i8) : i8 + %6 = llvm.mlir.undef : vector<2xi8> + %7 = llvm.mlir.constant(0 : i32) : i32 + %8 = llvm.insertelement %5, %6[%7 : i32] : vector<2xi8> + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.insertelement %4, %8[%9 : i32] : vector<2xi8> + %11 = llvm.and %arg0, %0 : vector<2xi8> + %12 = llvm.icmp "eq" %11, %2 : vector<2xi8> + %13 = llvm.add %arg0, %3 : vector<2xi8> + %14 = llvm.and %13, %10 : vector<2xi8> + %15 = llvm.select %12, %arg0, %14 : vector<2xi1>, vector<2xi8> + llvm.return %15 : vector<2xi8> + } + llvm.func @t8_nonsplat_masked_by_poison_0b0010(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[15, 31]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.poison : i8 + %4 = llvm.mlir.constant(16 : i8) : i8 + %5 = llvm.mlir.undef : vector<2xi8> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %4, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %3, %7[%8 : i32] : vector<2xi8> + %10 = llvm.mlir.constant(dense<[-16, -32]> : vector<2xi8>) : vector<2xi8> + %11 = llvm.and %arg0, %0 : vector<2xi8> + %12 = llvm.icmp "eq" %11, %2 : vector<2xi8> + %13 = llvm.add %arg0, %9 : vector<2xi8> + %14 = llvm.and %13, %10 : vector<2xi8> + %15 = llvm.select %12, %arg0, %14 : vector<2xi1>, vector<2xi8> + llvm.return %15 : vector<2xi8> + } + llvm.func @t8_nonsplat_masked_by_poison_0b0100(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[15, 31]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mlir.constant(dense<[16, 32]> : vector<2xi8>) : vector<2xi8> + %9 = llvm.mlir.constant(dense<[-16, -32]> : vector<2xi8>) : vector<2xi8> + %10 = llvm.and %arg0, %0 : vector<2xi8> + %11 = llvm.icmp "eq" %10, %7 : vector<2xi8> + %12 = llvm.add %arg0, %8 : vector<2xi8> + %13 = llvm.and %12, %9 : vector<2xi8> + %14 = llvm.select %11, %arg0, %13 : vector<2xi1>, vector<2xi8> + llvm.return %14 : vector<2xi8> + } + llvm.func @t8_nonsplat_masked_by_poison_0b1000(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(0 : i8) : i8 + %8 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %9 = llvm.mlir.constant(dense<[16, 32]> : vector<2xi8>) : vector<2xi8> + %10 = llvm.mlir.constant(dense<[-16, -32]> : vector<2xi8>) : vector<2xi8> + %11 = llvm.and %arg0, %6 : vector<2xi8> + %12 = llvm.icmp "eq" %11, %8 : vector<2xi8> + %13 = llvm.add %arg0, %9 : vector<2xi8> + %14 = llvm.and %13, %10 : vector<2xi8> + %15 = llvm.select %12, %arg0, %14 : vector<2xi1>, vector<2xi8> + llvm.return %15 : vector<2xi8> + } + llvm.func @n9_wrong_x0(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(16 : i8) : i8 + %3 = llvm.mlir.constant(-16 : i8) : i8 + %4 = llvm.and %arg0, %0 : i8 + %5 = llvm.icmp "eq" %4, %1 : i8 + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.select %5, %arg1, %7 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @n9_wrong_x1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(16 : i8) : i8 + %3 = llvm.mlir.constant(-16 : i8) : i8 + %4 = llvm.and %arg0, %0 : i8 + %5 = llvm.icmp "eq" %4, %1 : i8 + %6 = llvm.add %arg1, %2 : i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.select %5, %arg0, %7 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @n9_wrong_x2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(16 : i8) : i8 + %3 = llvm.mlir.constant(-16 : i8) : i8 + %4 = llvm.and %arg1, %0 : i8 + %5 = llvm.icmp "eq" %4, %1 : i8 + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.select %5, %arg0, %7 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @n10_wrong_low_bit_mask(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(31 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(16 : i8) : i8 + %3 = llvm.mlir.constant(-16 : i8) : i8 + %4 = llvm.and %arg0, %0 : i8 + %5 = llvm.icmp "eq" %4, %1 : i8 + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.select %5, %arg0, %7 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @n11_wrong_high_bit_mask(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(16 : i8) : i8 + %3 = llvm.mlir.constant(-32 : i8) : i8 + %4 = llvm.and %arg0, %0 : i8 + %5 = llvm.icmp "eq" %4, %1 : i8 + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.select %5, %arg0, %7 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @n12_wrong_bias(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(32 : i8) : i8 + %3 = llvm.mlir.constant(-16 : i8) : i8 + %4 = llvm.and %arg0, %0 : i8 + %5 = llvm.icmp "eq" %4, %1 : i8 + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.select %5, %arg0, %7 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @n13_wrong_constants_alignment_is_not_power_of_two(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.mlir.constant(-3 : i8) : i8 + %4 = llvm.and %arg0, %0 : i8 + %5 = llvm.icmp "eq" %4, %1 : i8 + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.select %5, %arg0, %7 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @n14_wrong_comparison_constant(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(16 : i8) : i8 + %3 = llvm.mlir.constant(-16 : i8) : i8 + %4 = llvm.and %arg0, %0 : i8 + %5 = llvm.icmp "eq" %4, %1 : i8 + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.select %5, %arg0, %7 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @n15_wrong_comparison_predicate_and_constant(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(16 : i8) : i8 + %3 = llvm.mlir.constant(-16 : i8) : i8 + %4 = llvm.and %arg0, %0 : i8 + %5 = llvm.icmp "ult" %4, %1 : i8 + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.and %6, %3 : i8 + %8 = llvm.select %5, %arg0, %7 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @n16_oneuse(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(16 : i8) : i8 + %3 = llvm.mlir.constant(-16 : i8) : i8 + %4 = llvm.and %arg0, %0 : i8 + %5 = llvm.icmp "eq" %4, %1 : i8 + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.and %6, %3 : i8 + llvm.call @use.i8(%7) : (i8) -> () + %8 = llvm.select %5, %arg0, %7 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @t17_oneuse(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(-16 : i8) : i8 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + %5 = llvm.add %arg0, %0 : i8 + %6 = llvm.and %5, %2 : i8 + llvm.call @use.i8(%6) : (i8) -> () + %7 = llvm.select %4, %arg0, %6 : i1, i8 + llvm.return %7 : i8 + } + llvm.func @t18_replacement_0b0001(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(dense<3> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(0 : i4) : i4 + %3 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %4 = llvm.mlir.poison : i4 + %5 = llvm.mlir.constant(-4 : i4) : i4 + %6 = llvm.mlir.undef : vector<2xi4> + %7 = llvm.mlir.constant(0 : i32) : i32 + %8 = llvm.insertelement %5, %6[%7 : i32] : vector<2xi4> + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.insertelement %4, %8[%9 : i32] : vector<2xi4> + %11 = llvm.and %arg0, %1 : vector<2xi4> + %12 = llvm.icmp "eq" %11, %3 : vector<2xi4> + %13 = llvm.add %arg0, %1 : vector<2xi4> + %14 = llvm.and %13, %10 : vector<2xi4> + llvm.call @use.v2i4(%14) : (vector<2xi4>) -> () + %15 = llvm.select %12, %arg0, %14 : vector<2xi1>, vector<2xi4> + llvm.return %15 : vector<2xi4> + } + llvm.func @t18_replacement_0b0010(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(dense<3> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(0 : i4) : i4 + %3 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %4 = llvm.mlir.poison : i4 + %5 = llvm.mlir.undef : vector<2xi4> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %0, %5[%6 : i32] : vector<2xi4> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %4, %7[%8 : i32] : vector<2xi4> + %10 = llvm.mlir.constant(-4 : i4) : i4 + %11 = llvm.mlir.constant(dense<-4> : vector<2xi4>) : vector<2xi4> + %12 = llvm.and %arg0, %1 : vector<2xi4> + %13 = llvm.icmp "eq" %12, %3 : vector<2xi4> + %14 = llvm.add %arg0, %9 : vector<2xi4> + %15 = llvm.and %14, %11 : vector<2xi4> + llvm.call @use.v2i4(%15) : (vector<2xi4>) -> () + %16 = llvm.select %13, %arg0, %15 : vector<2xi1>, vector<2xi4> + llvm.return %16 : vector<2xi4> + } + llvm.func @t18_replacement_0b0100(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(3 : i4) : i4 + %1 = llvm.mlir.constant(dense<3> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.poison : i4 + %3 = llvm.mlir.constant(0 : i4) : i4 + %4 = llvm.mlir.undef : vector<2xi4> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi4> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi4> + %9 = llvm.mlir.constant(-4 : i4) : i4 + %10 = llvm.mlir.constant(dense<-4> : vector<2xi4>) : vector<2xi4> + %11 = llvm.and %arg0, %1 : vector<2xi4> + %12 = llvm.icmp "eq" %11, %8 : vector<2xi4> + %13 = llvm.add %arg0, %1 : vector<2xi4> + %14 = llvm.and %13, %10 : vector<2xi4> + llvm.call @use.v2i4(%14) : (vector<2xi4>) -> () + %15 = llvm.select %12, %arg0, %14 : vector<2xi1>, vector<2xi4> + llvm.return %15 : vector<2xi4> + } + llvm.func @t18_replacement_0b1000(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.poison : i4 + %1 = llvm.mlir.constant(3 : i4) : i4 + %2 = llvm.mlir.undef : vector<2xi4> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi4> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi4> + %7 = llvm.mlir.constant(0 : i4) : i4 + %8 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %9 = llvm.mlir.constant(dense<3> : vector<2xi4>) : vector<2xi4> + %10 = llvm.mlir.constant(-4 : i4) : i4 + %11 = llvm.mlir.constant(dense<-4> : vector<2xi4>) : vector<2xi4> + %12 = llvm.and %arg0, %6 : vector<2xi4> + %13 = llvm.icmp "eq" %12, %8 : vector<2xi4> + %14 = llvm.add %arg0, %9 : vector<2xi4> + %15 = llvm.and %14, %11 : vector<2xi4> + llvm.call @use.v2i4(%15) : (vector<2xi4>) -> () + %16 = llvm.select %13, %arg0, %15 : vector<2xi1>, vector<2xi4> + llvm.return %16 : vector<2xi4> + } +} diff --git a/test/LLVMDialect/InstCombine/intersect-accessgroup.ll.mlir b/test/LLVMDialect/InstCombine/intersect-accessgroup.ll.mlir index 8c27bf8b5..f54357227 100644 --- a/test/LLVMDialect/InstCombine/intersect-accessgroup.ll.mlir +++ b/test/LLVMDialect/InstCombine/intersect-accessgroup.ll.mlir @@ -1,50 +1,54 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "arg", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.br"(%1)[^bb1] : (i32) -> () +#access_group = #llvm.access_group> +#access_group1 = #llvm.access_group> +#access_group2 = #llvm.access_group> +#loop_annotation = #llvm.loop_annotation +#loop_annotation1 = #llvm.loop_annotation +#loop_annotation2 = #llvm.loop_annotation +#loop_annotation3 = #llvm.loop_annotation +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @arg(f64) + llvm.func @func(%arg0: i64, %arg1: !llvm.ptr {llvm.noalias, llvm.nonnull}) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + llvm.br ^bb1(%0 : i32) ^bb1(%2: i32): // 2 preds: ^bb0, ^bb8 - %3 = "llvm.sext"(%2) : (i32) -> i64 - %4 = "llvm.icmp"(%3, %arg0) {predicate = 2 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%4, %1)[^bb2, ^bb9] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i32) -> () + %3 = llvm.sext %2 : i32 to i64 + %4 = llvm.icmp "slt" %3, %arg0 : i64 + llvm.cond_br %4, ^bb2(%0 : i32), ^bb9 ^bb2(%5: i32): // 2 preds: ^bb1, ^bb7 - %6 = "llvm.sext"(%5) : (i32) -> i64 - %7 = "llvm.icmp"(%6, %arg0) {predicate = 2 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%7, %1)[^bb3, ^bb8] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i32) -> () + %6 = llvm.sext %5 : i32 to i64 + %7 = llvm.icmp "slt" %6, %arg0 : i64 + llvm.cond_br %7, ^bb3(%0 : i32), ^bb8 ^bb3(%8: i32): // 2 preds: ^bb2, ^bb6 - %9 = "llvm.sext"(%8) : (i32) -> i64 - %10 = "llvm.icmp"(%9, %arg0) {predicate = 2 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%10, %1)[^bb4, ^bb7] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i32) -> () + %9 = llvm.sext %8 : i32 to i64 + %10 = llvm.icmp "slt" %9, %arg0 : i64 + llvm.cond_br %10, ^bb4(%0 : i32), ^bb7 ^bb4(%11: i32): // 2 preds: ^bb3, ^bb5 - %12 = "llvm.sext"(%11) : (i32) -> i64 - %13 = "llvm.icmp"(%12, %arg0) {predicate = 2 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%13)[^bb5, ^bb6] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %12 = llvm.sext %11 : i32 to i64 + %13 = llvm.icmp "slt" %12, %arg0 : i64 + llvm.cond_br %13, ^bb5, ^bb6 ^bb5: // pred: ^bb4 - %14 = "llvm.add"(%2, %5) : (i32, i32) -> i32 - %15 = "llvm.add"(%14, %8) : (i32, i32) -> i32 - %16 = "llvm.add"(%15, %11) : (i32, i32) -> i32 - %17 = "llvm.sext"(%16) : (i32) -> i64 - %18 = "llvm.getelementptr"(%arg1, %17) : (!llvm.ptr, i64) -> !llvm.ptr - %19 = "llvm.load"(%18) : (!llvm.ptr) -> f64 - %20 = "llvm.load"(%18) : (!llvm.ptr) -> f64 - %21 = "llvm.fadd"(%19, %20) : (f64, f64) -> f64 - "llvm.call"(%21) {callee = @arg, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - %22 = "llvm.add"(%11, %0) : (i32, i32) -> i32 - "llvm.br"(%22)[^bb4] : (i32) -> () + %14 = llvm.add %2, %5 overflow : i32 + %15 = llvm.add %14, %8 overflow : i32 + %16 = llvm.add %15, %11 overflow : i32 + %17 = llvm.sext %16 : i32 to i64 + %18 = llvm.getelementptr inbounds %arg1[%17] : (!llvm.ptr, i64) -> !llvm.ptr, f64 + %19 = llvm.load %18 {access_groups = [#access_group, #access_group1], alignment = 8 : i64} : !llvm.ptr -> f64 + %20 = llvm.load %18 {access_groups = [#access_group, #access_group2], alignment = 8 : i64} : !llvm.ptr -> f64 + %21 = llvm.fadd %19, %20 : f64 + llvm.call @arg(%21) {access_groups = [#access_group, #access_group2, #access_group1]} : (f64) -> () + %22 = llvm.add %11, %1 overflow : i32 + llvm.br ^bb4(%22 : i32) {loop_annotation = #loop_annotation} ^bb6: // pred: ^bb4 - %23 = "llvm.add"(%8, %0) : (i32, i32) -> i32 - "llvm.br"(%23)[^bb3] : (i32) -> () + %23 = llvm.add %8, %1 overflow : i32 + llvm.br ^bb3(%23 : i32) {loop_annotation = #loop_annotation1} ^bb7: // pred: ^bb3 - %24 = "llvm.add"(%5, %0) : (i32, i32) -> i32 - "llvm.br"(%24)[^bb2] : (i32) -> () + %24 = llvm.add %5, %1 overflow : i32 + llvm.br ^bb2(%24 : i32) {loop_annotation = #loop_annotation2} ^bb8: // pred: ^bb2 - %25 = "llvm.add"(%2, %0) : (i32, i32) -> i32 - "llvm.br"(%25)[^bb1] : (i32) -> () + %25 = llvm.add %2, %1 overflow : i32 + llvm.br ^bb1(%25 : i32) {loop_annotation = #loop_annotation3} ^bb9: // pred: ^bb1 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "func", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/intptr1.ll.mlir b/test/LLVMDialect/InstCombine/intptr1.ll.mlir new file mode 100644 index 000000000..77f341de6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/intptr1.ll.mlir @@ -0,0 +1,111 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.readnone}, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.icmp "ult" %arg0, %arg1 : !llvm.ptr + llvm.cond_br %2, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %3 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> i64 + llvm.br ^bb2(%arg0, %3 : !llvm.ptr, i64) + ^bb2(%4: !llvm.ptr, %5: i64): // 2 preds: ^bb1, ^bb2 + %6 = llvm.inttoptr %5 : i64 to !llvm.ptr + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %8 = llvm.fmul %7, %0 : f32 + llvm.store %8, %4 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.getelementptr inbounds %6[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %10 = llvm.ptrtoint %9 : !llvm.ptr to i64 + %11 = llvm.getelementptr inbounds %4[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %12 = llvm.icmp "ult" %11, %arg1 : !llvm.ptr + llvm.cond_br %12, ^bb2(%11, %10 : !llvm.ptr, i64), ^bb3 + ^bb3: // 2 preds: ^bb0, ^bb2 + llvm.return + } + llvm.func @test1_neg(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.readnone}, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.icmp "ult" %arg0, %arg1 : !llvm.ptr + llvm.cond_br %2, ^bb1, ^bb4 + ^bb1: // pred: ^bb0 + %3 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> i64 + llvm.br ^bb2(%arg0, %3 : !llvm.ptr, i64) + ^bb2(%4: !llvm.ptr, %5: i64): // 2 preds: ^bb1, ^bb3 + %6 = llvm.inttoptr %5 : i64 to !llvm.ptr + %7 = llvm.icmp "ult" %6, %arg1 : !llvm.ptr + llvm.cond_br %7, ^bb4, ^bb3 + ^bb3: // pred: ^bb2 + %8 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> f32 + %9 = llvm.fmul %8, %0 : f32 + llvm.store %9, %4 {alignment = 4 : i64} : f32, !llvm.ptr + %10 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %11 = llvm.ptrtoint %10 : !llvm.ptr to i64 + %12 = llvm.getelementptr inbounds %4[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %13 = llvm.icmp "ult" %12, %arg1 : !llvm.ptr + llvm.cond_br %13, ^bb2(%12, %11 : !llvm.ptr, i64), ^bb4 + ^bb4: // 3 preds: ^bb0, ^bb2, ^bb3 + llvm.return + } + llvm.func @test2(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.readnone}, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.icmp "ult" %arg0, %arg1 : !llvm.ptr + llvm.cond_br %2, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %3 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> i64 + llvm.br ^bb2(%arg0, %3 : !llvm.ptr, i64) + ^bb2(%4: !llvm.ptr, %5: i64): // 2 preds: ^bb1, ^bb2 + %6 = llvm.inttoptr %5 : i64 to !llvm.ptr + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %8 = llvm.fmul %7, %0 : f32 + llvm.store %8, %4 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.getelementptr inbounds %6[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %10 = llvm.ptrtoint %9 : !llvm.ptr to i64 + %11 = llvm.getelementptr inbounds %4[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %12 = llvm.icmp "ult" %11, %arg1 : !llvm.ptr + llvm.cond_br %12, ^bb2(%11, %10 : !llvm.ptr, i64), ^bb3 + ^bb3: // 2 preds: ^bb0, ^bb2 + llvm.return + } + llvm.func @test3(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.readnone}, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.icmp "ult" %arg0, %arg1 : !llvm.ptr + llvm.cond_br %2, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %3 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> i64 + llvm.br ^bb2(%arg0, %3 : !llvm.ptr, i64) + ^bb2(%4: !llvm.ptr, %5: i64): // 2 preds: ^bb1, ^bb2 + %6 = llvm.inttoptr %5 : i64 to !llvm.ptr + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %8 = llvm.fmul %7, %0 : f32 + llvm.store %8, %4 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.getelementptr inbounds %6[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %10 = llvm.ptrtoint %9 : !llvm.ptr to i64 + %11 = llvm.getelementptr inbounds %4[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %12 = llvm.icmp "ult" %11, %arg1 : !llvm.ptr + llvm.cond_br %12, ^bb2(%11, %10 : !llvm.ptr, i64), ^bb3 + ^bb3: // 2 preds: ^bb0, ^bb2 + llvm.return + } + llvm.func @test4(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.readnone}, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.icmp "ult" %arg0, %arg1 : !llvm.ptr + llvm.cond_br %2, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %3 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %4 = llvm.ptrtoint %3 : !llvm.ptr to i64 + llvm.br ^bb2(%arg0, %4 : !llvm.ptr, i64) + ^bb2(%5: !llvm.ptr, %6: i64): // 2 preds: ^bb1, ^bb2 + %7 = llvm.inttoptr %6 : i64 to !llvm.ptr + %8 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %9 = llvm.fmul %8, %0 : f32 + llvm.store %9, %5 {alignment = 4 : i64} : f32, !llvm.ptr + %10 = llvm.getelementptr inbounds %7[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %11 = llvm.ptrtoint %10 : !llvm.ptr to i64 + %12 = llvm.getelementptr inbounds %5[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %13 = llvm.icmp "ult" %12, %arg1 : !llvm.ptr + llvm.cond_br %13, ^bb2(%12, %11 : !llvm.ptr, i64), ^bb3 + ^bb3: // 2 preds: ^bb0, ^bb2 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/intptr2.ll.mlir b/test/LLVMDialect/InstCombine/intptr2.ll.mlir new file mode 100644 index 000000000..a43290949 --- /dev/null +++ b/test/LLVMDialect/InstCombine/intptr2.ll.mlir @@ -0,0 +1,23 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.readnone}, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.icmp "ult" %arg0, %arg1 : !llvm.ptr + llvm.cond_br %2, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %3 = llvm.ptrtoint %arg2 : !llvm.ptr to i64 + llvm.br ^bb2(%arg0, %3 : !llvm.ptr, i64) + ^bb2(%4: !llvm.ptr, %5: i64): // 2 preds: ^bb1, ^bb2 + %6 = llvm.inttoptr %5 : i64 to !llvm.ptr + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %8 = llvm.fmul %7, %0 : f32 + llvm.store %8, %4 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.getelementptr inbounds %6[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %10 = llvm.ptrtoint %9 : !llvm.ptr to i64 + %11 = llvm.getelementptr inbounds %4[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %12 = llvm.icmp "ult" %11, %arg1 : !llvm.ptr + llvm.cond_br %12, ^bb2(%11, %10 : !llvm.ptr, i64), ^bb3 + ^bb3: // 2 preds: ^bb0, ^bb2 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/intptr3.ll.mlir b/test/LLVMDialect/InstCombine/intptr3.ll.mlir new file mode 100644 index 000000000..d66c65c3d --- /dev/null +++ b/test/LLVMDialect/InstCombine/intptr3.ll.mlir @@ -0,0 +1,23 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func unnamed_addr @test(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.readnone}, %arg2: i64) { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.icmp "ult" %arg0, %arg1 : !llvm.ptr + llvm.cond_br %2, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %3 = llvm.inttoptr %arg2 : i64 to !llvm.ptr + llvm.br ^bb2(%arg0, %3, %arg2 : !llvm.ptr, !llvm.ptr, i64) + ^bb2(%4: !llvm.ptr, %5: !llvm.ptr, %6: i64): // 2 preds: ^bb1, ^bb2 + %7 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> f32 + %8 = llvm.fmul %7, %0 : f32 + llvm.store %8, %4 {alignment = 4 : i64} : f32, !llvm.ptr + %9 = llvm.inttoptr %6 : i64 to !llvm.ptr + %10 = llvm.getelementptr inbounds %9[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %11 = llvm.ptrtoint %10 : !llvm.ptr to i64 + %12 = llvm.getelementptr inbounds %4[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %13 = llvm.icmp "ult" %12, %arg1 : !llvm.ptr + llvm.cond_br %13, ^bb2(%12, %10, %11 : !llvm.ptr, !llvm.ptr, i64), ^bb3 + ^bb3: // 2 preds: ^bb0, ^bb2 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/intptr4.ll.mlir b/test/LLVMDialect/InstCombine/intptr4.ll.mlir new file mode 100644 index 000000000..70c3404bb --- /dev/null +++ b/test/LLVMDialect/InstCombine/intptr4.ll.mlir @@ -0,0 +1,28 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func unnamed_addr @test(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.readnone}, %arg2: i64, %arg3: !llvm.ptr) { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.icmp "ult" %arg0, %arg1 : !llvm.ptr + %3 = llvm.inttoptr %arg2 : i64 to !llvm.ptr + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%arg2 : i64) + ^bb2: // pred: ^bb0 + %4 = llvm.ptrtoint %arg3 : !llvm.ptr to i64 + llvm.br ^bb3(%4 : i64) + ^bb3(%5: i64): // 2 preds: ^bb1, ^bb2 + llvm.br ^bb4(%arg0, %3, %5 : !llvm.ptr, !llvm.ptr, i64) + ^bb4(%6: !llvm.ptr, %7: !llvm.ptr, %8: i64): // 2 preds: ^bb3, ^bb4 + %9 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %10 = llvm.fmul %9, %0 : f32 + llvm.store %10, %6 {alignment = 4 : i64} : f32, !llvm.ptr + %11 = llvm.inttoptr %8 : i64 to !llvm.ptr + %12 = llvm.getelementptr inbounds %11[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %13 = llvm.ptrtoint %12 : !llvm.ptr to i64 + %14 = llvm.getelementptr inbounds %6[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %15 = llvm.icmp "ult" %14, %arg1 : !llvm.ptr + llvm.cond_br %15, ^bb4(%14, %12, %13 : !llvm.ptr, !llvm.ptr, i64), ^bb5 + ^bb5: // pred: ^bb4 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/intptr5.ll.mlir b/test/LLVMDialect/InstCombine/intptr5.ll.mlir new file mode 100644 index 000000000..b856c4841 --- /dev/null +++ b/test/LLVMDialect/InstCombine/intptr5.ll.mlir @@ -0,0 +1,30 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func unnamed_addr @test(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.readnone}, %arg2: i64, %arg3: !llvm.ptr) { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.icmp "ult" %arg0, %arg1 : !llvm.ptr + %3 = llvm.inttoptr %arg2 : i64 to !llvm.ptr + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%arg2 : i64) + ^bb2: // pred: ^bb0 + %4 = llvm.ptrtoint %arg3 : !llvm.ptr to i64 + llvm.br ^bb3(%4 : i64) + ^bb3(%5: i64): // 2 preds: ^bb1, ^bb2 + llvm.switch %arg2 : i64, ^bb4(%arg0, %3, %5 : !llvm.ptr, !llvm.ptr, i64) [ + 1: ^bb4(%arg0, %3, %5 : !llvm.ptr, !llvm.ptr, i64) + ] + ^bb4(%6: !llvm.ptr, %7: !llvm.ptr, %8: i64): // 3 preds: ^bb3, ^bb3, ^bb4 + %9 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + %10 = llvm.fmul %9, %0 : f32 + llvm.store %10, %6 {alignment = 4 : i64} : f32, !llvm.ptr + %11 = llvm.inttoptr %8 : i64 to !llvm.ptr + %12 = llvm.getelementptr inbounds %11[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %13 = llvm.ptrtoint %12 : !llvm.ptr to i64 + %14 = llvm.getelementptr inbounds %6[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %15 = llvm.icmp "ult" %14, %arg1 : !llvm.ptr + llvm.cond_br %15, ^bb4(%14, %12, %13 : !llvm.ptr, !llvm.ptr, i64), ^bb5 + ^bb5: // pred: ^bb4 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/intptr6.ll.mlir b/test/LLVMDialect/InstCombine/intptr6.ll.mlir new file mode 100644 index 000000000..7408f0fb4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/intptr6.ll.mlir @@ -0,0 +1,54 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.comdat @__llvm_global_comdat { + llvm.comdat_selector @foo any + } + llvm.mlir.global external thread_local @bar() {addr_space = 0 : i32, alignment = 8 : i64} : !llvm.struct<"A", (struct<"B", (ptr)>)> + llvm.func @__gxx_personality_v0(...) -> i32 + llvm.func local_unnamed_addr @foo(%arg0: i1) comdat(@__llvm_global_comdat::@foo) attributes {alignment = 2 : i64, passthrough = ["inlinehint", "sanitize_memory", ["uwtable", "2"]], personality = @__gxx_personality_v0} { + %0 = llvm.mlir.addressof @bar : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<(ptr, i32)> + %5 = llvm.load %0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %6 = llvm.ptrtoint %5 : !llvm.ptr to i64 + %7 = llvm.getelementptr inbounds %5[%1, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"C", packed (ptr, i32, array<4 x i8>)> + llvm.store %3, %7 {alignment = 8 : i64} : i32, !llvm.ptr + %8 = llvm.invoke @_Znwm() to ^bb1 unwind ^bb6 : () -> !llvm.ptr + ^bb1: // pred: ^bb0 + %9 = llvm.invoke @_Znwm() to ^bb2 unwind ^bb7 : () -> !llvm.ptr + ^bb2: // pred: ^bb1 + llvm.invoke @lazy() to ^bb4 unwind ^bb3 : () -> () + ^bb3: // pred: ^bb2 + %10 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)> + llvm.br ^bb8 + ^bb4: // pred: ^bb2 + %11 = llvm.ptrtoint %9 : !llvm.ptr to i64 + llvm.invoke @scale() to ^bb5 unwind ^bb9 : () -> () + ^bb5: // pred: ^bb4 + llvm.return + ^bb6: // pred: ^bb0 + %12 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb7: // pred: ^bb1 + %13 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)> + llvm.unreachable + ^bb8: // pred: ^bb3 + llvm.br ^bb10(%6 : i64) + ^bb9: // pred: ^bb4 + %14 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)> + llvm.br ^bb10(%11 : i64) + ^bb10(%15: i64): // 2 preds: ^bb8, ^bb9 + %16 = llvm.inttoptr %15 : i64 to !llvm.ptr + llvm.cond_br %arg0, ^bb12, ^bb11 + ^bb11: // pred: ^bb10 + %17 = llvm.getelementptr inbounds %16[%1, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"C", packed (ptr, i32, array<4 x i8>)> + %18 = llvm.load %17 {alignment = 8 : i64} : !llvm.ptr -> i32 + llvm.unreachable + ^bb12: // pred: ^bb10 + llvm.resume %4 : !llvm.struct<(ptr, i32)> + } + llvm.func local_unnamed_addr @_Znwm() -> (!llvm.ptr {llvm.noalias, llvm.nonnull}) attributes {passthrough = ["nobuiltin"]} + llvm.func local_unnamed_addr @scale() attributes {alignment = 2 : i64, passthrough = ["sanitize_memory", ["uwtable", "2"]]} + llvm.func unnamed_addr @lazy() attributes {alignment = 2 : i64, passthrough = ["sanitize_memory", ["uwtable", "2"]]} +} diff --git a/test/LLVMDialect/InstCombine/intptr7.ll.mlir b/test/LLVMDialect/InstCombine/intptr7.ll.mlir index 21fc45651..adec29189 100644 --- a/test/LLVMDialect/InstCombine/intptr7.ll.mlir +++ b/test/LLVMDialect/InstCombine/intptr7.ll.mlir @@ -1,53 +1,50 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: !llvm.ptr, %arg2: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4.200000e+01 : f32} : () -> f32 - %1 = "llvm.mlir.constant"() {value = 1.000000e+01 : f32} : () -> f32 - %2 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = false} : () -> i1 - %5 = "llvm.icmp"(%arg2, %4) {predicate = 0 : i64} : (i1, i1) -> i1 - %6 = "llvm.add"(%arg0, %3) : (i64, i64) -> i64 - %7 = "llvm.inttoptr"(%6) : (i64) -> !llvm.ptr - %8 = "llvm.getelementptr"(%arg1, %2) : (!llvm.ptr, i64) -> !llvm.ptr - %9 = "llvm.ptrtoint"(%8) : (!llvm.ptr) -> i64 - "llvm.cond_br"(%5)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @matching_phi(%arg0: i64, %arg1: !llvm.ptr, %arg2: i1) { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.mlir.constant(1.000000e+01 : f32) : f32 + %4 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %5 = llvm.icmp "eq" %arg2, %0 : i1 + %6 = llvm.add %arg0, %1 : i64 + %7 = llvm.inttoptr %6 : i64 to !llvm.ptr + %8 = llvm.getelementptr inbounds %arg1[%2] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %9 = llvm.ptrtoint %8 : !llvm.ptr to i64 + llvm.cond_br %5, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.br"(%8, %9)[^bb3] : (!llvm.ptr, i64) -> () + llvm.br ^bb3(%8, %9 : !llvm.ptr, i64) ^bb2: // pred: ^bb0 - "llvm.store"(%1, %7) : (f32, !llvm.ptr) -> () - "llvm.br"(%7, %6)[^bb3] : (!llvm.ptr, i64) -> () - ^bb3(%10: !llvm.ptr, %11: i64): // 2 preds: ^bb1, ^bb2 - %12 = "llvm.inttoptr"(%11) : (i64) -> !llvm.ptr - %13 = "llvm.load"(%12) : (!llvm.ptr) -> f32 - %14 = "llvm.fmul"(%13, %0) : (f32, f32) -> f32 - "llvm.store"(%14, %10) : (f32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "matching_phi", type = !llvm.func, i1)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: !llvm.ptr, %arg2: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4.200000e+01 : f32} : () -> f32 - %1 = "llvm.mlir.constant"() {value = 1.000000e+01 : f32} : () -> f32 - %2 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = false} : () -> i1 - %5 = "llvm.icmp"(%arg2, %4) {predicate = 0 : i64} : (i1, i1) -> i1 - %6 = "llvm.add"(%arg0, %3) : (i64, i64) -> i64 - %7 = "llvm.inttoptr"(%6) : (i64) -> !llvm.ptr - %8 = "llvm.getelementptr"(%arg1, %2) : (!llvm.ptr, i64) -> !llvm.ptr - %9 = "llvm.ptrtoint"(%8) : (!llvm.ptr) -> i64 - "llvm.cond_br"(%5)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.store %3, %7 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.br ^bb3(%7, %6 : !llvm.ptr, i64) + ^bb3(%10: !llvm.ptr, %11: i64): // 2 preds: ^bb1, ^bb2 + %12 = llvm.inttoptr %11 : i64 to !llvm.ptr + %13 = llvm.load %12 {alignment = 4 : i64} : !llvm.ptr -> f32 + %14 = llvm.fmul %13, %4 : f32 + llvm.store %14, %10 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.return + } + llvm.func @no_matching_phi(%arg0: i64, %arg1: !llvm.ptr, %arg2: i1) { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.mlir.constant(1.000000e+01 : f32) : f32 + %4 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %5 = llvm.icmp "eq" %arg2, %0 : i1 + %6 = llvm.add %arg0, %1 : i64 + %7 = llvm.inttoptr %6 : i64 to !llvm.ptr + %8 = llvm.getelementptr inbounds %arg1[%2] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %9 = llvm.ptrtoint %8 : !llvm.ptr to i64 + llvm.cond_br %5, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.br"(%8, %6)[^bb3] : (!llvm.ptr, i64) -> () + llvm.br ^bb3(%8, %6 : !llvm.ptr, i64) ^bb2: // pred: ^bb0 - "llvm.store"(%1, %7) : (f32, !llvm.ptr) -> () - "llvm.br"(%7, %9)[^bb3] : (!llvm.ptr, i64) -> () - ^bb3(%10: !llvm.ptr, %11: i64): // 2 preds: ^bb1, ^bb2 - %12 = "llvm.inttoptr"(%11) : (i64) -> !llvm.ptr - %13 = "llvm.load"(%12) : (!llvm.ptr) -> f32 - %14 = "llvm.fmul"(%13, %0) : (f32, f32) -> f32 - "llvm.store"(%14, %10) : (f32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "no_matching_phi", type = !llvm.func, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.store %3, %7 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.br ^bb3(%7, %9 : !llvm.ptr, i64) + ^bb3(%10: !llvm.ptr, %11: i64): // 2 preds: ^bb1, ^bb2 + %12 = llvm.inttoptr %11 : i64 to !llvm.ptr + %13 = llvm.load %12 {alignment = 4 : i64} : !llvm.ptr -> f32 + %14 = llvm.fmul %13, %4 : f32 + llvm.store %14, %10 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/intptr8.ll.mlir b/test/LLVMDialect/InstCombine/intptr8.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/intrinsic-select.ll.mlir b/test/LLVMDialect/InstCombine/intrinsic-select.ll.mlir new file mode 100644 index 000000000..7e25792f9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/intrinsic-select.ll.mlir @@ -0,0 +1,224 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @g1(dense<0> : vector<2xi32>) {addr_space = 0 : i32} : vector<2xi32> + llvm.mlir.global external @g2() {addr_space = 0 : i32} : i8 + llvm.func @use(i32) + llvm.func @ctlz_sel_const_true_false(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(-7 : i32) : i32 + %2 = llvm.select %arg0, %0, %1 : i1, i32 + %3 = "llvm.intr.ctlz"(%2) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @ctlz_sel_const_true(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.select %arg0, %0, %arg1 : i1, i32 + %2 = "llvm.intr.ctlz"(%1) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @ctlz_sel_const_false(%arg0: vector<3xi1>, %arg1: vector<3xi17>) -> vector<3xi17> { + %0 = llvm.mlir.constant(0 : i17) : i17 + %1 = llvm.mlir.constant(-1 : i17) : i17 + %2 = llvm.mlir.constant(7 : i17) : i17 + %3 = llvm.mlir.constant(dense<[7, -1, 0]> : vector<3xi17>) : vector<3xi17> + %4 = llvm.select %arg0, %arg1, %3 : vector<3xi1>, vector<3xi17> + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = true}> : (vector<3xi17>) -> vector<3xi17> + llvm.return %5 : vector<3xi17> + } + llvm.func @ctlz_sel_const_true_false_extra_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.select %arg0, %0, %1 : i1, i32 + llvm.call @use(%2) : (i32) -> () + %3 = "llvm.intr.ctlz"(%2) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @cttz_sel_const_true_false(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(-7 : i32) : i32 + %2 = llvm.select %arg0, %0, %1 : i1, i32 + %3 = "llvm.intr.cttz"(%2) <{is_zero_poison = false}> : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @cttz_sel_const_true(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.select %arg0, %0, %arg1 : i1, i32 + %2 = "llvm.intr.cttz"(%1) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @cttz_sel_const_false(%arg0: vector<3xi1>, %arg1: vector<3xi5>) -> vector<3xi5> { + %0 = llvm.mlir.constant(0 : i5) : i5 + %1 = llvm.mlir.constant(-1 : i5) : i5 + %2 = llvm.mlir.constant(7 : i5) : i5 + %3 = llvm.mlir.constant(dense<[7, -1, 0]> : vector<3xi5>) : vector<3xi5> + %4 = llvm.select %arg0, %arg1, %3 : vector<3xi1>, vector<3xi5> + %5 = "llvm.intr.cttz"(%4) <{is_zero_poison = false}> : (vector<3xi5>) -> vector<3xi5> + llvm.return %5 : vector<3xi5> + } + llvm.func @cttz_sel_const_true_false_extra_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(-8 : i32) : i32 + %2 = llvm.select %arg0, %0, %1 : i1, i32 + llvm.call @use(%2) : (i32) -> () + %3 = "llvm.intr.cttz"(%2) <{is_zero_poison = true}> : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @ctpop_sel_const_true_false(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(-7 : i32) : i32 + %2 = llvm.select %arg0, %0, %1 : i1, i32 + %3 = llvm.intr.ctpop(%2) : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @ctpop_sel_const_true(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.select %arg0, %0, %arg1 : i1, i32 + %2 = llvm.intr.ctpop(%1) : (i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @ctpop_sel_const_false(%arg0: vector<3xi1>, %arg1: vector<3xi7>) -> vector<3xi7> { + %0 = llvm.mlir.constant(0 : i7) : i7 + %1 = llvm.mlir.constant(-1 : i7) : i7 + %2 = llvm.mlir.constant(7 : i7) : i7 + %3 = llvm.mlir.constant(dense<[7, -1, 0]> : vector<3xi7>) : vector<3xi7> + %4 = llvm.select %arg0, %arg1, %3 : vector<3xi1>, vector<3xi7> + %5 = llvm.intr.ctpop(%4) : (vector<3xi7>) -> vector<3xi7> + llvm.return %5 : vector<3xi7> + } + llvm.func @ctpop_sel_const_true_false_extra_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.select %arg0, %0, %1 : i1, i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.intr.ctpop(%2) : (i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @usub_sat_rhs_const_select_all_const(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.intr.usub.sat(%3, %2) : (i32, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @usub_sat_rhs_var_select_all_const(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.select %arg0, %0, %1 : i1, i32 + %3 = llvm.intr.usub.sat(%2, %arg1) : (i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @usub_sat_rhs_const_select_one_const(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.select %arg0, %0, %arg1 : i1, i32 + %3 = llvm.intr.usub.sat(%2, %1) : (i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @usub_sat_rhs_const_select_no_const(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.select %arg0, %arg2, %arg1 : i1, i32 + %2 = llvm.intr.usub.sat(%1, %0) : (i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @usub_sat_lhs_const_select_all_const(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.intr.usub.sat(%2, %3) : (i32, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @non_speculatable(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.addressof @g1 : !llvm.ptr + %3 = llvm.mlir.addressof @g2 : !llvm.ptr + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(true) : i1 + %6 = llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : vector<2xi1> + %7 = llvm.mlir.poison : vector<2xi32> + %8 = llvm.mlir.constant(64 : i32) : i32 + %9 = llvm.select %arg0, %2, %3 : i1, !llvm.ptr + %10 = llvm.intr.masked.load %9, %6, %7 {alignment = 64 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xi32>) -> vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @vec_to_scalar_select_scalar(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[3, 4]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.select %arg0, %0, %1 : i1, vector<2xi32> + %3 = "llvm.intr.vector.reduce.add"(%2) : (vector<2xi32>) -> i32 + llvm.return %3 : i32 + } + llvm.func @vec_to_scalar_select_vector(%arg0: vector<2xi1>) -> i32 { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[3, 4]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.select %arg0, %0, %1 : vector<2xi1>, vector<2xi32> + %3 = "llvm.intr.vector.reduce.add"(%2) : (vector<2xi32>) -> i32 + llvm.return %3 : i32 + } + llvm.func @test_drop_noundef(%arg0: i1, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.select %arg0, %0, %arg1 : i1, i8 + %3 = llvm.intr.smin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @pr85536(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(30 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(48 : i64) : i64 + %3 = llvm.mlir.constant(-1 : i64) : i64 + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.mlir.constant(65535 : i64) : i64 + %6 = llvm.icmp "ugt" %arg0, %0 : i32 + %7 = llvm.shl %1, %arg0 overflow : i32 + %8 = llvm.zext %7 : i32 to i64 + %9 = llvm.shl %8, %2 : i64 + %10 = llvm.ashr %9, %2 : i64 + %11 = llvm.select %6, %3, %10 : i1, i64 + %12 = llvm.intr.smin(%11, %4) : (i64, i64) -> i64 + %13 = llvm.and %12, %5 : i64 + %14 = llvm.icmp "eq" %13, %4 : i64 + llvm.return %14 : i1 + } + llvm.func @test_fabs_select1(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %2 = llvm.fcmp "uno" %arg0, %0 : f64 + %3 = llvm.select %2, %1, %arg0 : i1, f64 + %4 = llvm.intr.fabs(%3) : (f64) -> f64 + %5 = llvm.select %2, %4, %arg0 : i1, f64 + llvm.return %5 : f64 + } + llvm.func @test_fabs_select1_vec(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.mlir.constant(dense<0x7FF8000000000000> : vector<2xf64>) : vector<2xf64> + %3 = llvm.fcmp "uno" %arg0, %1 : vector<2xf64> + %4 = llvm.select %3, %2, %arg0 : vector<2xi1>, vector<2xf64> + %5 = llvm.intr.fabs(%4) : (vector<2xf64>) -> vector<2xf64> + %6 = llvm.select %3, %5, %arg0 : vector<2xi1>, vector<2xf64> + llvm.return %6 : vector<2xf64> + } + llvm.func @test_fabs_select2(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0x7FF0000000000000 : f64) : f64 + %1 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %2 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %3 = llvm.fcmp "oeq" %2, %0 : f64 + %4 = llvm.select %3, %1, %2 : i1, f64 + %5 = llvm.intr.fabs(%4) : (f64) -> f64 + llvm.return %5 : f64 + } + llvm.func @test_fabs_select_fmf1(%arg0: i1, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f64 + %2 = llvm.intr.fabs(%1) : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @test_fabs_select_fmf2(%arg0: i1, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.select %arg0, %0, %arg1 : i1, f64 + %2 = llvm.intr.fabs(%1) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %2 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/intrinsics.ll.mlir b/test/LLVMDialect/InstCombine/intrinsics.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/invariant.group.ll.mlir b/test/LLVMDialect/InstCombine/invariant.group.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/invariant.ll.mlir b/test/LLVMDialect/InstCombine/invariant.ll.mlir index e62a585ee..3ec8bdc0d 100644 --- a/test/LLVMDialect/InstCombine/invariant.ll.mlir +++ b/test/LLVMDialect/InstCombine/invariant.ll.mlir @@ -1,32 +1,22 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "g", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "g_addr1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.invariant.start.p0i8", type = !llvm.func> (i64, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.invariant.start.p1i8", type = !llvm.func> (i64, ptr)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - "llvm.store"(%1, %3) : (i8, !llvm.ptr) -> () - %4 = "llvm.call"(%0, %3) {callee = @llvm.invariant.start.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> !llvm.ptr> - "llvm.call"(%3) {callee = @g, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - %5 = "llvm.load"(%3) : (!llvm.ptr) -> i8 - "llvm.return"(%5) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - "llvm.store"(%1, %arg0) : (i8, !llvm.ptr) -> () - %2 = "llvm.call"(%0, %arg0) {callee = @llvm.invariant.start.p1i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> !llvm.ptr> - "llvm.call"(%arg0) {callee = @g_addr1, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - %3 = "llvm.load"(%arg0) : (!llvm.ptr) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "f_addrspace1", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @g(!llvm.ptr) + llvm.func @g_addr1(!llvm.ptr<1>) + llvm.func @f() -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %2 {alignment = 1 : i64} : i8, !llvm.ptr + %3 = llvm.intr.invariant.start 1, %2 : !llvm.ptr + llvm.call @g(%2) : (!llvm.ptr) -> () + %4 = llvm.load %2 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %4 : i8 + } + llvm.func @f_addrspace1(%arg0: !llvm.ptr<1>) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.store %0, %arg0 {alignment = 1 : i64} : i8, !llvm.ptr<1> + %1 = llvm.intr.invariant.start 1, %arg0 : !llvm.ptr<1> + llvm.call @g_addr1(%arg0) : (!llvm.ptr<1>) -> () + %2 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr<1> -> i8 + llvm.return %2 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/invert-variable-mask-in-masked-merge-scalar.ll.mlir b/test/LLVMDialect/InstCombine/invert-variable-mask-in-masked-merge-scalar.ll.mlir index c08e6be2e..c2b74a8b7 100644 --- a/test/LLVMDialect/InstCombine/invert-variable-mask-in-masked-merge-scalar.ll.mlir +++ b/test/LLVMDialect/InstCombine/invert-variable-mask-in-masked-merge-scalar.ll.mlir @@ -1,192 +1,170 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4, %arg2: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg2, %0) : (i4, i4) -> i4 - %2 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %1) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %arg1) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "scalar", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg1, %0) : (i4, i4) -> i4 - %2 = "llvm.xor"(%arg0, %0) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %1) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %0) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "in_constant_varx_mone_invmask", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %2 = "llvm.xor"(%arg1, %1) : (i4, i4) -> i4 - %3 = "llvm.xor"(%arg0, %0) : (i4, i4) -> i4 - %4 = "llvm.and"(%3, %2) : (i4, i4) -> i4 - %5 = "llvm.xor"(%4, %0) : (i4, i4) -> i4 - "llvm.return"(%5) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "in_constant_varx_6_invmask", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg1, %0) : (i4, i4) -> i4 - %2 = "llvm.xor"(%0, %arg0) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %1) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %arg0) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "in_constant_mone_vary_invmask", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %2 = "llvm.xor"(%arg1, %1) : (i4, i4) -> i4 - %3 = "llvm.xor"(%arg0, %0) : (i4, i4) -> i4 - %4 = "llvm.and"(%3, %2) : (i4, i4) -> i4 - %5 = "llvm.xor"(%4, %arg0) : (i4, i4) -> i4 - "llvm.return"(%5) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "in_constant_6_vary_invmask", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4, %arg2: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg2, %0) : (i4, i4) -> i4 - %2 = "llvm.xor"(%arg1, %arg0) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %1) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %arg1) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "c_1_0_0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4, %arg2: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg2, %0) : (i4, i4) -> i4 - %2 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %1) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %arg0) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "c_0_1_0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.call"() {callee = @gen4, fastmathFlags = #llvm.fastmath<>} : () -> i4 - %3 = "llvm.call"() {callee = @gen4, fastmathFlags = #llvm.fastmath<>} : () -> i4 - %4 = "llvm.xor"(%2, %3) : (i4, i4) -> i4 - %5 = "llvm.and"(%4, %1) : (i4, i4) -> i4 - %6 = "llvm.xor"(%3, %5) : (i4, i4) -> i4 - "llvm.return"(%6) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "c_0_0_1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4, %arg2: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg2, %0) : (i4, i4) -> i4 - %2 = "llvm.xor"(%arg1, %arg0) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %1) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %arg0) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "c_1_1_0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg1, %0) : (i4, i4) -> i4 - %2 = "llvm.call"() {callee = @gen4, fastmathFlags = #llvm.fastmath<>} : () -> i4 - %3 = "llvm.xor"(%2, %arg0) : (i4, i4) -> i4 - %4 = "llvm.and"(%3, %1) : (i4, i4) -> i4 - %5 = "llvm.xor"(%2, %4) : (i4, i4) -> i4 - "llvm.return"(%5) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "c_1_0_1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg1, %0) : (i4, i4) -> i4 - %2 = "llvm.call"() {callee = @gen4, fastmathFlags = #llvm.fastmath<>} : () -> i4 - %3 = "llvm.xor"(%2, %arg0) : (i4, i4) -> i4 - %4 = "llvm.and"(%3, %1) : (i4, i4) -> i4 - %5 = "llvm.xor"(%2, %4) : (i4, i4) -> i4 - "llvm.return"(%5) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "c_0_1_1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg0, %0) : (i4, i4) -> i4 - %2 = "llvm.call"() {callee = @gen4, fastmathFlags = #llvm.fastmath<>} : () -> i4 - %3 = "llvm.call"() {callee = @gen4, fastmathFlags = #llvm.fastmath<>} : () -> i4 - %4 = "llvm.xor"(%3, %2) : (i4, i4) -> i4 - %5 = "llvm.and"(%4, %1) : (i4, i4) -> i4 - %6 = "llvm.xor"(%2, %5) : (i4, i4) -> i4 - "llvm.return"(%6) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "c_1_1_1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %2 = "llvm.xor"(%arg1, %1) : (i4, i4) -> i4 - %3 = "llvm.xor"(%arg0, %0) : (i4, i4) -> i4 - %4 = "llvm.and"(%2, %3) : (i4, i4) -> i4 - %5 = "llvm.xor"(%4, %0) : (i4, i4) -> i4 - "llvm.return"(%5) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "commutativity_constant_varx_6_invmask", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %2 = "llvm.xor"(%arg1, %1) : (i4, i4) -> i4 - %3 = "llvm.xor"(%arg0, %0) : (i4, i4) -> i4 - %4 = "llvm.and"(%2, %3) : (i4, i4) -> i4 - %5 = "llvm.xor"(%4, %arg0) : (i4, i4) -> i4 - "llvm.return"(%5) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "commutativity_constant_6_vary_invmask", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4, %arg2: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg2, %0) : (i4, i4) -> i4 - %2 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %1) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %arg1) : (i4, i4) -> i4 - "llvm.call"(%2) {callee = @use4, fastmathFlags = #llvm.fastmath<>} : (i4) -> () - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "n_oneuse_D_is_ok", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4, %arg2: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg2, %0) : (i4, i4) -> i4 - %2 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %1) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %arg1) : (i4, i4) -> i4 - "llvm.call"(%3) {callee = @use4, fastmathFlags = #llvm.fastmath<>} : (i4) -> () - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "n_oneuse_A", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4, %arg2: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg2, %0) : (i4, i4) -> i4 - %2 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %1) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %arg1) : (i4, i4) -> i4 - "llvm.call"(%2) {callee = @use4, fastmathFlags = #llvm.fastmath<>} : (i4) -> () - "llvm.call"(%3) {callee = @use4, fastmathFlags = #llvm.fastmath<>} : (i4) -> () - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "n_oneuse_AD", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4, %arg2: i4, %arg3: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg3, %0) : (i4, i4) -> i4 - %2 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %1) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %arg2) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "n_third_var", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4, %arg2: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg2, %0) : (i4, i4) -> i4 - %2 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %1) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %arg1) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "n_badxor", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @scalar(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg2, %0 : i4 + %2 = llvm.xor %arg0, %arg1 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %arg1 : i4 + llvm.return %4 : i4 + } + llvm.func @in_constant_varx_mone_invmask(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg1, %0 : i4 + %2 = llvm.xor %arg0, %0 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %0 : i4 + llvm.return %4 : i4 + } + llvm.func @in_constant_varx_6_invmask(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.xor %arg1, %0 : i4 + %3 = llvm.xor %arg0, %1 : i4 + %4 = llvm.and %3, %2 : i4 + %5 = llvm.xor %4, %1 : i4 + llvm.return %5 : i4 + } + llvm.func @in_constant_mone_vary_invmask(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg1, %0 : i4 + %2 = llvm.xor %0, %arg0 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %arg0 : i4 + llvm.return %4 : i4 + } + llvm.func @in_constant_6_vary_invmask(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.xor %arg1, %0 : i4 + %3 = llvm.xor %arg0, %1 : i4 + %4 = llvm.and %3, %2 : i4 + %5 = llvm.xor %4, %arg0 : i4 + llvm.return %5 : i4 + } + llvm.func @gen4() -> i4 + llvm.func @c_1_0_0(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg2, %0 : i4 + %2 = llvm.xor %arg1, %arg0 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %arg1 : i4 + llvm.return %4 : i4 + } + llvm.func @c_0_1_0(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg2, %0 : i4 + %2 = llvm.xor %arg0, %arg1 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %arg0 : i4 + llvm.return %4 : i4 + } + llvm.func @c_0_0_1(%arg0: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg0, %0 : i4 + %2 = llvm.call @gen4() : () -> i4 + %3 = llvm.call @gen4() : () -> i4 + %4 = llvm.xor %2, %3 : i4 + %5 = llvm.and %4, %1 : i4 + %6 = llvm.xor %3, %5 : i4 + llvm.return %6 : i4 + } + llvm.func @c_1_1_0(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg2, %0 : i4 + %2 = llvm.xor %arg1, %arg0 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %arg0 : i4 + llvm.return %4 : i4 + } + llvm.func @c_1_0_1(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg1, %0 : i4 + %2 = llvm.call @gen4() : () -> i4 + %3 = llvm.xor %2, %arg0 : i4 + %4 = llvm.and %3, %1 : i4 + %5 = llvm.xor %2, %4 : i4 + llvm.return %5 : i4 + } + llvm.func @c_0_1_1(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg1, %0 : i4 + %2 = llvm.call @gen4() : () -> i4 + %3 = llvm.xor %2, %arg0 : i4 + %4 = llvm.and %3, %1 : i4 + %5 = llvm.xor %2, %4 : i4 + llvm.return %5 : i4 + } + llvm.func @c_1_1_1(%arg0: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg0, %0 : i4 + %2 = llvm.call @gen4() : () -> i4 + %3 = llvm.call @gen4() : () -> i4 + %4 = llvm.xor %3, %2 : i4 + %5 = llvm.and %4, %1 : i4 + %6 = llvm.xor %2, %5 : i4 + llvm.return %6 : i4 + } + llvm.func @commutativity_constant_varx_6_invmask(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.xor %arg1, %0 : i4 + %3 = llvm.xor %arg0, %1 : i4 + %4 = llvm.and %2, %3 : i4 + %5 = llvm.xor %4, %1 : i4 + llvm.return %5 : i4 + } + llvm.func @commutativity_constant_6_vary_invmask(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(6 : i4) : i4 + %2 = llvm.xor %arg1, %0 : i4 + %3 = llvm.xor %arg0, %1 : i4 + %4 = llvm.and %2, %3 : i4 + %5 = llvm.xor %4, %arg0 : i4 + llvm.return %5 : i4 + } + llvm.func @use4(i4) + llvm.func @n_oneuse_D_is_ok(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg2, %0 : i4 + %2 = llvm.xor %arg0, %arg1 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %arg1 : i4 + llvm.call @use4(%2) : (i4) -> () + llvm.return %4 : i4 + } + llvm.func @n_oneuse_A(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg2, %0 : i4 + %2 = llvm.xor %arg0, %arg1 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %arg1 : i4 + llvm.call @use4(%3) : (i4) -> () + llvm.return %4 : i4 + } + llvm.func @n_oneuse_AD(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg2, %0 : i4 + %2 = llvm.xor %arg0, %arg1 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %arg1 : i4 + llvm.call @use4(%2) : (i4) -> () + llvm.call @use4(%3) : (i4) -> () + llvm.return %4 : i4 + } + llvm.func @n_third_var(%arg0: i4, %arg1: i4, %arg2: i4, %arg3: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg3, %0 : i4 + %2 = llvm.xor %arg0, %arg1 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %arg2 : i4 + llvm.return %4 : i4 + } + llvm.func @n_badxor(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.xor %arg2, %0 : i4 + %2 = llvm.xor %arg0, %arg1 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %arg1 : i4 + llvm.return %4 : i4 + } +} diff --git a/test/LLVMDialect/InstCombine/invert-variable-mask-in-masked-merge-vector.ll.mlir b/test/LLVMDialect/InstCombine/invert-variable-mask-in-masked-merge-vector.ll.mlir new file mode 100644 index 000000000..bc4582753 --- /dev/null +++ b/test/LLVMDialect/InstCombine/invert-variable-mask-in-masked-merge-vector.ll.mlir @@ -0,0 +1,305 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @vector(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg2, %1 : vector<2xi4> + %3 = llvm.xor %arg0, %arg1 : vector<2xi4> + %4 = llvm.and %3, %2 : vector<2xi4> + %5 = llvm.xor %4, %arg1 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @vector_poison(%arg0: vector<3xi4>, %arg1: vector<3xi4>, %arg2: vector<3xi4>) -> vector<3xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.poison : i4 + %2 = llvm.mlir.undef : vector<3xi4> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi4> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi4> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi4> + %9 = llvm.xor %arg2, %8 : vector<3xi4> + %10 = llvm.xor %arg0, %arg1 : vector<3xi4> + %11 = llvm.and %10, %9 : vector<3xi4> + %12 = llvm.xor %11, %arg1 : vector<3xi4> + llvm.return %12 : vector<3xi4> + } + llvm.func @in_constant_varx_mone_invmask(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg1, %1 : vector<2xi4> + %3 = llvm.xor %arg0, %1 : vector<2xi4> + %4 = llvm.and %3, %2 : vector<2xi4> + %5 = llvm.xor %4, %1 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @in_constant_varx_6_invmask(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(6 : i4) : i4 + %3 = llvm.mlir.constant(dense<6> : vector<2xi4>) : vector<2xi4> + %4 = llvm.xor %arg1, %1 : vector<2xi4> + %5 = llvm.xor %arg0, %3 : vector<2xi4> + %6 = llvm.and %5, %4 : vector<2xi4> + %7 = llvm.xor %6, %3 : vector<2xi4> + llvm.return %7 : vector<2xi4> + } + llvm.func @in_constant_varx_6_invmask_nonsplat(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(7 : i4) : i4 + %3 = llvm.mlir.constant(6 : i4) : i4 + %4 = llvm.mlir.constant(dense<[6, 7]> : vector<2xi4>) : vector<2xi4> + %5 = llvm.xor %arg1, %1 : vector<2xi4> + %6 = llvm.xor %arg0, %4 : vector<2xi4> + %7 = llvm.and %6, %5 : vector<2xi4> + %8 = llvm.xor %7, %4 : vector<2xi4> + llvm.return %8 : vector<2xi4> + } + llvm.func @in_constant_varx_6_invmask_poison(%arg0: vector<3xi4>, %arg1: vector<3xi4>) -> vector<3xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.poison : i4 + %2 = llvm.mlir.undef : vector<3xi4> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi4> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi4> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi4> + %9 = llvm.mlir.constant(7 : i4) : i4 + %10 = llvm.mlir.constant(6 : i4) : i4 + %11 = llvm.mlir.undef : vector<3xi4> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.insertelement %10, %11[%12 : i32] : vector<3xi4> + %14 = llvm.mlir.constant(1 : i32) : i32 + %15 = llvm.insertelement %1, %13[%14 : i32] : vector<3xi4> + %16 = llvm.mlir.constant(2 : i32) : i32 + %17 = llvm.insertelement %9, %15[%16 : i32] : vector<3xi4> + %18 = llvm.xor %arg1, %8 : vector<3xi4> + %19 = llvm.xor %arg0, %17 : vector<3xi4> + %20 = llvm.and %19, %18 : vector<3xi4> + %21 = llvm.xor %20, %17 : vector<3xi4> + llvm.return %21 : vector<3xi4> + } + llvm.func @in_constant_mone_vary_invmask(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg1, %1 : vector<2xi4> + %3 = llvm.xor %1, %arg0 : vector<2xi4> + %4 = llvm.and %3, %2 : vector<2xi4> + %5 = llvm.xor %4, %arg0 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @in_constant_6_vary_invmask(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(6 : i4) : i4 + %3 = llvm.mlir.constant(dense<6> : vector<2xi4>) : vector<2xi4> + %4 = llvm.xor %arg1, %1 : vector<2xi4> + %5 = llvm.xor %arg0, %3 : vector<2xi4> + %6 = llvm.and %5, %4 : vector<2xi4> + %7 = llvm.xor %6, %arg0 : vector<2xi4> + llvm.return %7 : vector<2xi4> + } + llvm.func @in_constant_6_vary_invmask_nonsplat(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(7 : i4) : i4 + %3 = llvm.mlir.constant(6 : i4) : i4 + %4 = llvm.mlir.constant(dense<[6, 7]> : vector<2xi4>) : vector<2xi4> + %5 = llvm.xor %arg1, %1 : vector<2xi4> + %6 = llvm.xor %arg0, %4 : vector<2xi4> + %7 = llvm.and %6, %5 : vector<2xi4> + %8 = llvm.xor %7, %arg0 : vector<2xi4> + llvm.return %8 : vector<2xi4> + } + llvm.func @in_constant_6_vary_invmask_poison(%arg0: vector<3xi4>, %arg1: vector<3xi4>) -> vector<3xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.poison : i4 + %2 = llvm.mlir.undef : vector<3xi4> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi4> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi4> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi4> + %9 = llvm.mlir.constant(6 : i4) : i4 + %10 = llvm.mlir.undef : vector<3xi4> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi4> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi4> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi4> + %17 = llvm.xor %arg1, %8 : vector<3xi4> + %18 = llvm.xor %arg0, %16 : vector<3xi4> + %19 = llvm.and %18, %17 : vector<3xi4> + %20 = llvm.xor %19, %arg0 : vector<3xi4> + llvm.return %20 : vector<3xi4> + } + llvm.func @gen4() -> vector<2xi4> + llvm.func @c_1_0_0(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg2, %1 : vector<2xi4> + %3 = llvm.xor %arg1, %arg0 : vector<2xi4> + %4 = llvm.and %3, %2 : vector<2xi4> + %5 = llvm.xor %4, %arg1 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @c_0_1_0(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg2, %1 : vector<2xi4> + %3 = llvm.xor %arg0, %arg1 : vector<2xi4> + %4 = llvm.and %3, %2 : vector<2xi4> + %5 = llvm.xor %4, %arg0 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @c_0_0_1(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg0, %1 : vector<2xi4> + %3 = llvm.call @gen4() : () -> vector<2xi4> + %4 = llvm.call @gen4() : () -> vector<2xi4> + %5 = llvm.xor %3, %4 : vector<2xi4> + %6 = llvm.and %5, %2 : vector<2xi4> + %7 = llvm.xor %4, %6 : vector<2xi4> + llvm.return %7 : vector<2xi4> + } + llvm.func @c_1_1_0(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg2, %1 : vector<2xi4> + %3 = llvm.xor %arg1, %arg0 : vector<2xi4> + %4 = llvm.and %3, %2 : vector<2xi4> + %5 = llvm.xor %4, %arg0 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @c_1_0_1(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg1, %1 : vector<2xi4> + %3 = llvm.call @gen4() : () -> vector<2xi4> + %4 = llvm.xor %3, %arg0 : vector<2xi4> + %5 = llvm.and %4, %2 : vector<2xi4> + %6 = llvm.xor %3, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @c_0_1_1(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg1, %1 : vector<2xi4> + %3 = llvm.call @gen4() : () -> vector<2xi4> + %4 = llvm.xor %3, %arg0 : vector<2xi4> + %5 = llvm.and %4, %2 : vector<2xi4> + %6 = llvm.xor %3, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @c_1_1_1(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg0, %1 : vector<2xi4> + %3 = llvm.call @gen4() : () -> vector<2xi4> + %4 = llvm.call @gen4() : () -> vector<2xi4> + %5 = llvm.xor %4, %3 : vector<2xi4> + %6 = llvm.and %5, %2 : vector<2xi4> + %7 = llvm.xor %3, %6 : vector<2xi4> + llvm.return %7 : vector<2xi4> + } + llvm.func @commutativity_constant_varx_6_invmask(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(6 : i4) : i4 + %3 = llvm.mlir.constant(dense<6> : vector<2xi4>) : vector<2xi4> + %4 = llvm.xor %arg1, %1 : vector<2xi4> + %5 = llvm.xor %arg0, %3 : vector<2xi4> + %6 = llvm.and %4, %5 : vector<2xi4> + %7 = llvm.xor %6, %3 : vector<2xi4> + llvm.return %7 : vector<2xi4> + } + llvm.func @commutativity_constant_6_vary_invmask(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(6 : i4) : i4 + %3 = llvm.mlir.constant(dense<6> : vector<2xi4>) : vector<2xi4> + %4 = llvm.xor %arg1, %1 : vector<2xi4> + %5 = llvm.xor %arg0, %3 : vector<2xi4> + %6 = llvm.and %4, %5 : vector<2xi4> + %7 = llvm.xor %6, %arg0 : vector<2xi4> + llvm.return %7 : vector<2xi4> + } + llvm.func @use4(vector<2xi4>) + llvm.func @n_oneuse_D_is_ok(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg2, %1 : vector<2xi4> + %3 = llvm.xor %arg0, %arg1 : vector<2xi4> + %4 = llvm.and %3, %2 : vector<2xi4> + %5 = llvm.xor %4, %arg1 : vector<2xi4> + llvm.call @use4(%3) : (vector<2xi4>) -> () + llvm.return %5 : vector<2xi4> + } + llvm.func @n_oneuse_A(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg2, %1 : vector<2xi4> + %3 = llvm.xor %arg0, %arg1 : vector<2xi4> + %4 = llvm.and %3, %2 : vector<2xi4> + %5 = llvm.xor %4, %arg1 : vector<2xi4> + llvm.call @use4(%4) : (vector<2xi4>) -> () + llvm.return %5 : vector<2xi4> + } + llvm.func @n_oneuse_AD(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg2, %1 : vector<2xi4> + %3 = llvm.xor %arg0, %arg1 : vector<2xi4> + %4 = llvm.and %3, %2 : vector<2xi4> + %5 = llvm.xor %4, %arg1 : vector<2xi4> + llvm.call @use4(%3) : (vector<2xi4>) -> () + llvm.call @use4(%4) : (vector<2xi4>) -> () + llvm.return %5 : vector<2xi4> + } + llvm.func @n_third_var(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>, %arg3: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg3, %1 : vector<2xi4> + %3 = llvm.xor %arg0, %arg1 : vector<2xi4> + %4 = llvm.and %3, %2 : vector<2xi4> + %5 = llvm.xor %4, %arg2 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @n_third_var_const(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(7 : i4) : i4 + %3 = llvm.mlir.constant(6 : i4) : i4 + %4 = llvm.mlir.constant(dense<[6, 7]> : vector<2xi4>) : vector<2xi4> + %5 = llvm.mlir.constant(dense<[7, 6]> : vector<2xi4>) : vector<2xi4> + %6 = llvm.xor %arg2, %1 : vector<2xi4> + %7 = llvm.xor %arg0, %4 : vector<2xi4> + %8 = llvm.and %7, %6 : vector<2xi4> + %9 = llvm.xor %8, %5 : vector<2xi4> + llvm.return %9 : vector<2xi4> + } + llvm.func @n_badxor_splat(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(dense<1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg2, %1 : vector<2xi4> + %3 = llvm.xor %arg0, %arg1 : vector<2xi4> + %4 = llvm.and %3, %2 : vector<2xi4> + %5 = llvm.xor %4, %arg1 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @n_badxor(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.mlir.constant(dense<[-1, 1]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.xor %arg2, %2 : vector<2xi4> + %4 = llvm.xor %arg0, %arg1 : vector<2xi4> + %5 = llvm.and %4, %3 : vector<2xi4> + %6 = llvm.xor %5, %arg1 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } +} diff --git a/test/LLVMDialect/InstCombine/invoke.ll.mlir b/test/LLVMDialect/InstCombine/invoke.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/is_fpclass.ll.mlir b/test/LLVMDialect/InstCombine/is_fpclass.ll.mlir new file mode 100644 index 000000000..9432b1a6e --- /dev/null +++ b/test/LLVMDialect/InstCombine/is_fpclass.ll.mlir @@ -0,0 +1,1912 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_class_no_mask_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 0 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_full_mask_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1023 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_undef_no_mask_f32() -> i1 { + %0 = llvm.mlir.undef : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 0 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_undef_full_mask_f32() -> i1 { + %0 = llvm.mlir.undef : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 1023 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_poison_no_mask_f32() -> i1 { + %0 = llvm.mlir.poison : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 0 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_poison_full_mask_f32() -> i1 { + %0 = llvm.mlir.poison : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 1023 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_undef_val_f32() -> i1 { + %0 = llvm.mlir.undef : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 4 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_poison_val_f32() -> i1 { + %0 = llvm.mlir.poison : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 4 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_isnan_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 3 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_isnan_v2f32(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 3 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_isnan_f32_strict(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 3 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 96 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_v2f32(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 96 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_p0_n0_v2f32_daz(%arg0: vector<2xf32>) -> vector<2xi1> attributes {passthrough = [["denormal-fp-math-f32", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 96 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_p0_n0_v2f32_dynamic(%arg0: vector<2xf32>) -> vector<2xi1> attributes {passthrough = [["denormal-fp-math-f32", "ieee,dynamic"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 96 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_p0_n0_or_nan_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 99 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_or_nan_v2f32(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 99 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_p0_n0_or_nan_f32_daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math-f32", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 99 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_or_nan_v2f32_daz(%arg0: vector<2xf32>) -> vector<2xi1> attributes {passthrough = [["denormal-fp-math-f32", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 99 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_p0_n0_or_sub_or_nan_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 243 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_or_sub_or_nan_v2f32(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 243 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_p0_n0_or_sub_or_nan_f32_daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math-f32", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 243 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_or_sub_or_nan_v2f32_daz(%arg0: vector<2xf32>) -> vector<2xi1> attributes {passthrough = [["denormal-fp-math-f32", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 243 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_p0_n0_or_sub_or_snan_f32_daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math-f32", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 241 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_or_sub_or_qnan_f32_daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math-f32", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 242 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_or_nan_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 924 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_or_qnan_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 926 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_or_snan_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 925 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_or_nan_f32_daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math-f32", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 924 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_or_sub_or_nan_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 783 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_or_sub_or_nan_f32_daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math-f32", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 783 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_or_sub_and_not_nan_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 780 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_or_sub_and_not_nan_f32_daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math-f32", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 780 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 927 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_v2f32(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 927 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_not_p0_n0_f32_strict(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 927 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_f32_daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 927 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_f32_dynamic(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,dynamic"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 927 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_psub_nsub_f32_daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 783 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_psub_nsub_f32_dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 783 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_p0_n0_psub_nsub_f32_dynamic(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,dynamiz"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 783 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_f32_strict(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 96 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_f32_daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 96 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_f32_dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 96 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_psub_nsub_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 240 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_psub_nsub_f32_daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 240 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_psub_nsub_f32_dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 240 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_psub_nsub_f32_dynamic(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "ieee,dynamic"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 240 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_p0_n0_psub_nsub_v2f32(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 240 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_p0_n0_psub_nsub_v2f32_daz(%arg0: vector<2xf32>) -> vector<2xi1> attributes {passthrough = [["denormal-fp-math", "ieee,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 240 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_p0_n0_psub_nsub_v2f32_dapz(%arg0: vector<2xf32>) -> vector<2xi1> attributes {passthrough = [["denormal-fp-math", "ieee,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 240 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_p0_n0_psub_nsub_v2f32_dynamic(%arg0: vector<2xf32>) -> vector<2xi1> attributes {passthrough = [["denormal-fp-math", "ieee,dynamic"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 240 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_pinf_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 512 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pinf_or_nan_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 515 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pinf_v2f32(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 512 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_ninf_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_ninf_or_nan_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 7 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_ninf_v2f32(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_inf_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 516 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_inf_v2f32(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 516 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test_class_is_inf_or_nan_f32(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 519 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pinf_f32_strict(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 512 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_ninf_f32_strict(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_inf_f32_strict(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 516 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pinf_or_nan_f32_strict(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 515 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_ninf_or_nan_f32_strict(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 7 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_inf_or_nan_f32_strict(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 519 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_constant_class_snan_test_snan_f64() -> i1 { + %0 = llvm.mlir.constant(0x7FF0000000000001 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 1 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_qnan_test_qnan_f64() -> i1 { + %0 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 2 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_qnan_test_snan_f64() -> i1 { + %0 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 1 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_ninf_test_ninf_f64() -> i1 { + %0 = llvm.mlir.constant(0xFFF0000000000000 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 4 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_pinf_test_ninf_f64() -> i1 { + %0 = llvm.mlir.constant(0x7FF0000000000000 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 4 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_qnan_test_ninf_f64() -> i1 { + %0 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 4 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_snan_test_ninf_f64() -> i1 { + %0 = llvm.mlir.constant(0x7FF0000000000001 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 4 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_nnormal_test_nnormal_f64() -> i1 { + %0 = llvm.mlir.constant(-1.000000e+00 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 8 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_pnormal_test_nnormal_f64() -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 8 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_nsubnormal_test_nsubnormal_f64() -> i1 { + %0 = llvm.mlir.constant(-2.2250738585072009E-308 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 16 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_psubnormal_test_nsubnormal_f64() -> i1 { + %0 = llvm.mlir.constant(2.2250738585072009E-308 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 16 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_nzero_test_nzero_f64() -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 32 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_pzero_test_nzero_f64() -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 32 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_pzero_test_pzero_f64() -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 64 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_nzero_test_pzero_f64() -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 64 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_psubnormal_test_psubnormal_f64() -> i1 { + %0 = llvm.mlir.constant(2.2250738585072009E-308 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 128 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_nsubnormal_test_psubnormal_f64() -> i1 { + %0 = llvm.mlir.constant(-2.2250738585072009E-308 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 128 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_pnormal_test_pnormal_f64() -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 256 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_nnormal_test_pnormal_f64() -> i1 { + %0 = llvm.mlir.constant(-1.000000e+00 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 256 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_pinf_test_pinf_f64() -> i1 { + %0 = llvm.mlir.constant(0x7FF0000000000000 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 512 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_ninf_test_pinf_f64() -> i1 { + %0 = llvm.mlir.constant(0xFFF0000000000000 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 512 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_qnan_test_pinf_f64() -> i1 { + %0 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 512 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_constant_class_snan_test_pinf_f64() -> i1 { + %0 = llvm.mlir.constant(0x7FF0000000000001 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 512 : i32}> : (f64) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_is_snan_nnan_src(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 1 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_is_qnan_nnan_src(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 2 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_is_nan_nnan_src(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 3 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_is_nan_other_nnan_src(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 267 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_is_not_nan_nnan_src(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 1020 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_is_not_nan_nnan_src_strict(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 1020 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_is_ninf_pinf_ninf_src(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 516 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_is_ninf_ninf_src(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 4 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_is_pinf_ninf_src(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 512 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_is_ninf_pinf_pnormal_ninf_src(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 772 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_is_not_inf_ninf_src(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 507 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_is_not_inf_ninf_src_strict(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 507 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_not_is_nan(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 3 : i32}> : (f32) -> i1 + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @test_class_not_is_nan_multi_use(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 3 : i32}> : (f32) -> i1 + llvm.store %1, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @test_class_not_is_inf_nan(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 519 : i32}> : (f32) -> i1 + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @test_class_not_is_normal(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f32) -> i1 + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @test_class_xor_false(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 33 : i32}> : (f32) -> i1 + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @test_class_not_vector(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 33 : i32}> : (vector<2xf32>) -> vector<2xi1> + %3 = llvm.xor %2, %1 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @test_class_xor_vector(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : vector<2xi1> + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 33 : i32}> : (vector<2xf32>) -> vector<2xi1> + %4 = llvm.xor %3, %2 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @test_fold_or_class_f32_0(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1 : i32}> : (f32) -> i1 + %2 = llvm.fcmp "uno" %arg0, %0 : f32 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @test_fold_or3_class_f32_0(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 2 : i32}> : (f32) -> i1 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + %3 = llvm.or %0, %1 : i1 + %4 = llvm.or %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @test_fold_or_all_tests_class_f32_0(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 2 : i32}> : (f32) -> i1 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 8 : i32}> : (f32) -> i1 + %4 = "llvm.intr.is.fpclass"(%arg0) <{bit = 16 : i32}> : (f32) -> i1 + %5 = "llvm.intr.is.fpclass"(%arg0) <{bit = 32 : i32}> : (f32) -> i1 + %6 = "llvm.intr.is.fpclass"(%arg0) <{bit = 64 : i32}> : (f32) -> i1 + %7 = "llvm.intr.is.fpclass"(%arg0) <{bit = 128 : i32}> : (f32) -> i1 + %8 = "llvm.intr.is.fpclass"(%arg0) <{bit = 256 : i32}> : (f32) -> i1 + %9 = "llvm.intr.is.fpclass"(%arg0) <{bit = 512 : i32}> : (f32) -> i1 + %10 = llvm.or %0, %1 : i1 + %11 = llvm.or %10, %2 : i1 + %12 = llvm.or %11, %3 : i1 + %13 = llvm.or %12, %4 : i1 + %14 = llvm.or %13, %5 : i1 + %15 = llvm.or %14, %6 : i1 + %16 = llvm.or %15, %7 : i1 + %17 = llvm.or %16, %8 : i1 + %18 = llvm.or %17, %9 : i1 + llvm.return %18 : i1 + } + llvm.func @test_fold_or_class_f32_1(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 8 : i32}> : (f32) -> i1 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_no_fold_or_class_f32_multi_use0(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + llvm.store %0, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 8 : i32}> : (f32) -> i1 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_no_fold_or_class_f32_multi_use1(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 8 : i32}> : (f32) -> i1 + llvm.store %1, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_fold_or_class_f32_2(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 7 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 7 : i32}> : (f32) -> i1 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_no_fold_or_class_f32_0(%arg0: f32, %arg1: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg1) <{bit = 8 : i32}> : (f32) -> i1 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_fold_or_class_v2f32(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (vector<2xf32>) -> vector<2xi1> + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 8 : i32}> : (vector<2xf32>) -> vector<2xi1> + %2 = llvm.or %0, %1 : vector<2xi1> + llvm.return %2 : vector<2xi1> + } + llvm.func @test_fold_and_class_f32_0(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1 : i32}> : (f32) -> i1 + %2 = llvm.fcmp "uno" %arg0, %0 : f32 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @test_fold_and3_class_f32_0(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 3 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 2 : i32}> : (f32) -> i1 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 7 : i32}> : (f32) -> i1 + %3 = llvm.and %0, %1 : i1 + %4 = llvm.and %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @test_fold_and_all_tests_class_f32_0(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 2 : i32}> : (f32) -> i1 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 8 : i32}> : (f32) -> i1 + %4 = "llvm.intr.is.fpclass"(%arg0) <{bit = 16 : i32}> : (f32) -> i1 + %5 = "llvm.intr.is.fpclass"(%arg0) <{bit = 32 : i32}> : (f32) -> i1 + %6 = "llvm.intr.is.fpclass"(%arg0) <{bit = 64 : i32}> : (f32) -> i1 + %7 = "llvm.intr.is.fpclass"(%arg0) <{bit = 128 : i32}> : (f32) -> i1 + %8 = "llvm.intr.is.fpclass"(%arg0) <{bit = 256 : i32}> : (f32) -> i1 + %9 = "llvm.intr.is.fpclass"(%arg0) <{bit = 512 : i32}> : (f32) -> i1 + %10 = llvm.and %0, %1 : i1 + %11 = llvm.and %10, %2 : i1 + %12 = llvm.and %11, %3 : i1 + %13 = llvm.and %12, %4 : i1 + %14 = llvm.and %13, %5 : i1 + %15 = llvm.and %14, %6 : i1 + %16 = llvm.and %15, %7 : i1 + %17 = llvm.and %16, %8 : i1 + %18 = llvm.and %17, %9 : i1 + llvm.return %18 : i1 + } + llvm.func @test_fold_and_not_all_tests_class_f32_0(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1022 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1021 : i32}> : (f32) -> i1 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1019 : i32}> : (f32) -> i1 + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1015 : i32}> : (f32) -> i1 + %4 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1007 : i32}> : (f32) -> i1 + %5 = "llvm.intr.is.fpclass"(%arg0) <{bit = 991 : i32}> : (f32) -> i1 + %6 = "llvm.intr.is.fpclass"(%arg0) <{bit = 959 : i32}> : (f32) -> i1 + %7 = "llvm.intr.is.fpclass"(%arg0) <{bit = 895 : i32}> : (f32) -> i1 + %8 = "llvm.intr.is.fpclass"(%arg0) <{bit = 767 : i32}> : (f32) -> i1 + %9 = "llvm.intr.is.fpclass"(%arg0) <{bit = 511 : i32}> : (f32) -> i1 + %10 = llvm.and %0, %1 : i1 + %11 = llvm.and %10, %2 : i1 + %12 = llvm.and %11, %3 : i1 + %13 = llvm.and %12, %4 : i1 + %14 = llvm.and %13, %5 : i1 + %15 = llvm.and %14, %6 : i1 + %16 = llvm.and %15, %7 : i1 + %17 = llvm.and %16, %8 : i1 + %18 = llvm.and %17, %9 : i1 + llvm.return %18 : i1 + } + llvm.func @test_fold_and_class_f32_1(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 48 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 11 : i32}> : (f32) -> i1 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_no_fold_and_class_f32_multi_use0(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 15 : i32}> : (f32) -> i1 + llvm.store %0, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 8 : i32}> : (f32) -> i1 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_no_fold_and_class_f32_multi_use1(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 15 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 8 : i32}> : (f32) -> i1 + llvm.store %1, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_fold_and_class_f32_2(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 7 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 7 : i32}> : (f32) -> i1 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_fold_and_class_f32_3(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 37 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 393 : i32}> : (f32) -> i1 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_fold_and_class_f32_4(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 393 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 37 : i32}> : (f32) -> i1 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_no_fold_and_class_f32_0(%arg0: f32, %arg1: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 7 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg1) <{bit = 15 : i32}> : (f32) -> i1 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_fold_and_class_v2f32(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 7 : i32}> : (vector<2xf32>) -> vector<2xi1> + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 15 : i32}> : (vector<2xf32>) -> vector<2xi1> + %2 = llvm.and %0, %1 : vector<2xi1> + llvm.return %2 : vector<2xi1> + } + llvm.func @test_fold_xor_class_f32_0(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1 : i32}> : (f32) -> i1 + %2 = llvm.fcmp "uno" %arg0, %0 : f32 + %3 = llvm.xor %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @test_fold_xor3_class_f32_0(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 2 : i32}> : (f32) -> i1 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + %3 = llvm.xor %0, %1 : i1 + %4 = llvm.xor %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @test_fold_xor_all_tests_class_f32_0(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 2 : i32}> : (f32) -> i1 + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + %3 = "llvm.intr.is.fpclass"(%arg0) <{bit = 8 : i32}> : (f32) -> i1 + %4 = "llvm.intr.is.fpclass"(%arg0) <{bit = 16 : i32}> : (f32) -> i1 + %5 = "llvm.intr.is.fpclass"(%arg0) <{bit = 32 : i32}> : (f32) -> i1 + %6 = "llvm.intr.is.fpclass"(%arg0) <{bit = 64 : i32}> : (f32) -> i1 + %7 = "llvm.intr.is.fpclass"(%arg0) <{bit = 128 : i32}> : (f32) -> i1 + %8 = "llvm.intr.is.fpclass"(%arg0) <{bit = 256 : i32}> : (f32) -> i1 + %9 = "llvm.intr.is.fpclass"(%arg0) <{bit = 512 : i32}> : (f32) -> i1 + %10 = llvm.xor %0, %1 : i1 + %11 = llvm.xor %10, %2 : i1 + %12 = llvm.xor %11, %3 : i1 + %13 = llvm.xor %12, %4 : i1 + %14 = llvm.xor %13, %5 : i1 + %15 = llvm.xor %14, %6 : i1 + %16 = llvm.xor %15, %7 : i1 + %17 = llvm.xor %16, %8 : i1 + %18 = llvm.xor %17, %9 : i1 + llvm.return %18 : i1 + } + llvm.func @test_fold_xor_class_f32_1(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 8 : i32}> : (f32) -> i1 + %2 = llvm.xor %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_no_fold_xor_class_f32_multi_use0(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + llvm.store %0, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 8 : i32}> : (f32) -> i1 + %2 = llvm.xor %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_no_fold_xor_class_f32_multi_use1(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 8 : i32}> : (f32) -> i1 + llvm.store %1, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + %2 = llvm.xor %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_fold_xor_class_f32_2(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 7 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 7 : i32}> : (f32) -> i1 + %2 = llvm.xor %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_no_fold_xor_class_f32_0(%arg0: f32, %arg1: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + %1 = "llvm.intr.is.fpclass"(%arg1) <{bit = 8 : i32}> : (f32) -> i1 + %2 = llvm.xor %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test_fold_xor_class_v2f32(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (vector<2xf32>) -> vector<2xi1> + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 13 : i32}> : (vector<2xf32>) -> vector<2xi1> + %2 = llvm.xor %0, %1 : vector<2xi1> + llvm.return %2 : vector<2xi1> + } + llvm.func @test_class_fneg_none(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 0 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_all(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 1023 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_snan(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 1 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_qnan(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 2 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_neginf(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 4 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_negnormal(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 8 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_negsubnormal(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 16 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_negzero(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 32 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_poszero(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 64 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_possubnormal(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 128 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_posnormal(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 256 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_posinf(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 512 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_isnan(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 3 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_nnan(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 1020 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_normal(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 264 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_zero(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 96 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_subnormal(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 144 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_normal_neginf(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 268 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_normal_pinf(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 776 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_neginf_posnormal_negsubnormal_poszero(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 340 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_neginf_posnormal_negsubnormal_poszero_snan(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 341 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_neginf_posnormal_negsubnormal_poszero_qnan(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 342 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_neginf_posnormal_negsubnormal_poszero_nan(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 343 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_posinf_negnormal_possubnormal_negzero(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 680 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_posinf_negnormal_possubnormal_negzero_snan(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 681 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_posinf_negnormal_possubnormal_negzero_qnan(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 682 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_posinf_negnormal_possubnormal_negzero_nan(%arg0: f32) -> i1 { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 683 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_posinf_negnormal_possubnormal_negzero_snan_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.fneg %arg0 : f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 681 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_multiple_use_fneg(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.fneg %arg0 : f32 + llvm.store %0, %arg1 {alignment = 4 : i64} : f32, !llvm.ptr + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 682 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fneg_posinf_negnormal_possubnormal_negzero_nan_vector(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.fneg %arg0 : vector<2xf32> + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 683 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %1 : vector<2xi1> + } + llvm.func @test_class_fabs_none(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 0 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_all(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 1023 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_snan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 1 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_qnan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 2 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_neginf(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 4 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_negnormal(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 8 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_negsubnormal(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 16 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_negzero(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 32 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_poszero(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 64 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_possubnormal(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 128 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_posnormal(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 256 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_posinf(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 512 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_isnan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 3 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_nnan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 1020 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_normal(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 264 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_zero(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 96 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_subnormal(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 144 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_normal_neginf(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 268 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_normal_pinf(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 776 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_neginf_posnormal_negsubnormal_poszero(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 340 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_neginf_posnormal_negsubnormal_poszero_snan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 341 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_neginf_posnormal_negsubnormal_poszero_qnan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 342 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_neginf_posnormal_negsubnormal_poszero_nan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 343 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_posinf_negnormal_possubnormal_negzero(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 680 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_posinf_negnormal_possubnormal_negzero_snan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 681 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_posinf_negnormal_possubnormal_negzero_qnan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 682 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_posinf_negnormal_possubnormal_negzero_nan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 683 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_posinf_negnormal_possubnormal_negzero_snan_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 681 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_multiple_use_fabs(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + llvm.store %0, %arg1 {alignment = 4 : i64} : f32, !llvm.ptr + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 682 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_fabs_posinf_negnormal_possubnormal_negzero_nan_vector(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.intr.fabs(%arg0) : (vector<2xf32>) -> vector<2xf32> + %1 = "llvm.intr.is.fpclass"(%0) <{bit = 683 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %1 : vector<2xi1> + } + llvm.func @test_class_fneg_fabs_none(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 0 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_all(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 1023 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_snan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 1 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_qnan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 2 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_neginf(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 4 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_negnormal(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 8 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_negsubnormal(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 16 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_negzero(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 32 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_poszero(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 64 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_possubnormal(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 128 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_posnormal(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 256 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_posinf(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 512 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_isnan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 3 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_nnan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 1020 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_normal(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 264 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_zero(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 96 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_subnormal(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 144 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_normal_neginf(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 268 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_normal_pinf(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 776 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_neginf_posnormal_negsubnormal_poszero(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 340 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_neginf_posnormal_negsubnormal_poszero_snan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 341 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_neginf_posnormal_negsubnormal_poszero_qnan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 342 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_neginf_posnormal_negsubnormal_poszero_nan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 343 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_posinf_negnormal_possubnormal_negzero(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 680 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_posinf_negnormal_possubnormal_negzero_snan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 681 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_posinf_negnormal_possubnormal_negzero_qnan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 682 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_posinf_negnormal_possubnormal_negzero_nan(%arg0: f32) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 683 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_posinf_negnormal_possubnormal_negzero_snan_strictfp(%arg0: f32) -> i1 attributes {passthrough = ["strictfp"]} { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 681 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_multiple_use_fabs(%arg0: f32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.fneg %0 : f32 + llvm.store %1, %arg1 {alignment = 4 : i64} : f32, !llvm.ptr + %2 = "llvm.intr.is.fpclass"(%1) <{bit = 682 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_fneg_fabs_posinf_negnormal_possubnormal_negzero_nan_vector(%arg0: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.intr.fabs(%arg0) : (vector<2xf32>) -> vector<2xf32> + %1 = llvm.fneg %0 : vector<2xf32> + %2 = "llvm.intr.is.fpclass"(%0) <{bit = 683 : i32}> : (vector<2xf32>) -> vector<2xi1> + llvm.return %2 : vector<2xi1> + } + llvm.func @test_class_is_zero_nozero_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 96 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_zero_noposzero_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 96 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_zero_nonegzero_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 96 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_nozero_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 64 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_nopzero_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 64 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_nonzero_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 64 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_nozero_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 32 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_nopzero_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 32 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_nonzero_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 32 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_normal_or_zero_nozero_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 360 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_inf_or_nan_nozero_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 519 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_inf_or_nan_noinf_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 519 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_inf_or_nan_nonan_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 519 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_normal_or_subnormal_noinf_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 408 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_neginf_or_nopinf_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_neginf_noninf_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_neginf_noinf_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 4 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_posinf_noninf_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 512 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_posinf_nopinf_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 512 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_posinf_noinf_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 512 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_subnormal_nosub_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 144 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_subnormal_nonsub_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 144 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_subnormal_nosub_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 879 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_negsubnormal_nosub_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1007 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_negsubnormal_nonegsub_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1007 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nnormal_nonorm_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nnormal_nonorm_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 759 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nnormal_onlynorm_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 759 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nnormal_onlynorm_src(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_normal_assume_normal(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f32) -> i1 + "llvm.intr.assume"(%0) : (i1) -> () + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_is_normal_assume_not_normal(%arg0: f32) -> i1 { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 264 : i32}> : (f32) -> i1 + "llvm.intr.assume"(%0) : (i1) -> () + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 759 : i32}> : (f32) -> i1 + llvm.return %1 : i1 + } + llvm.func @test_class_is_nan_assume_ord(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ord" %arg0, %0 : f32 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 3 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_is_nan_assume_uno(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "uno" %arg0, %0 : f32 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 3 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_is_nan_assume_not_eq_pinf(%arg0: f32) -> i1 { + %0 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = "llvm.intr.is.fpclass"(%arg0) <{bit = 3 : i32}> : (f32) -> i1 + llvm.return %2 : i1 + } + llvm.func @test_class_is_pzero_psub_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 960 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_psub_pnorm_pinf_snan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 961 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_psub_pnorm_pinf_qnan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 962 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_psub_pnorm_pinf_nan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 963 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_psub_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 896 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_psub_pnorm_pinf_snan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 897 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_psub_pnorm_pinf_qnan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 898 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_psub_pnorm_pinf_nan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 899 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 768 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 704 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_pnorm_pinf_nan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 707 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_pzero_psub_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 992 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_pzero_psub_pnorm_pinf_snan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 993 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_pzero_psub_pnorm_pinf_qnan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 994 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_pzero_psub_pnorm_pinf_nan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 995 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nsub_nzero_pzero_psub_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1017 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nsub_nzero_pzero_psub_pnorm_pinf_snan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1009 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nsub_nzero_pzero_psub_pnorm_pinf_qnan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1010 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nsub_nzero_pzero_psub_pnorm_pinf_nan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1011 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_psub_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 928 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_nsub_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 816 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_psub_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 63 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_psub_pnorm_pinf_snan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 62 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_psub_pnorm_pinf_qnan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 61 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_psub_pnorm_pinf_nan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 960 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_psub_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 127 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_psub_pnorm_pinf_snan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 126 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_psub_pnorm_pinf_qnan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 125 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_psub_pnorm_pinf_nan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 124 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 255 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 319 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_pnorm_pinf_nan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 316 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_pzero_psub_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 22 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_pzero_psub_pnorm_pinf_snan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 30 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_pzero_psub_pnorm_pinf_qnan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 29 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_pzero_psub_pnorm_pinf_nan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 28 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nsub_nzero_pzero_psub_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 6 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nsub_nzero_pzero_psub_pnorm_pinf_snan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 14 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nsub_nzero_pzero_psub_pnorm_pinf_qnan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 13 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nsub_nzero_pzero_psub_pnorm_pinf_nan__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 12 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_psub_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 95 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_nsub_pnorm_pinf__ieee(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,ieee"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 207 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_psub_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 960 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_psub_pnorm_pinf_snan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 961 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_psub_pnorm_pinf_qnan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 962 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_psub_pnorm_pinf_nan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 963 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_psub_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 896 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_psub_pnorm_pinf_snan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 897 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_psub_pnorm_pinf_qnan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 898 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_psub_pnorm_pinf_nan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 899 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 768 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 704 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_pnorm_pinf_nan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 707 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_pzero_psub_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 992 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_pzero_psub_pnorm_pinf_snan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 993 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_pzero_psub_pnorm_pinf_qnan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 994 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_pzero_psub_pnorm_pinf_nan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 995 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nsub_nzero_pzero_psub_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1017 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nsub_nzero_pzero_psub_pnorm_pinf_snan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1009 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nsub_nzero_pzero_psub_pnorm_pinf_qnan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1010 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nsub_nzero_pzero_psub_pnorm_pinf_nan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1011 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_psub_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 928 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_nsub_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 816 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_psub_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 63 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_psub_pnorm_pinf_snan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 62 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_psub_pnorm_pinf_qnan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 61 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_psub_pnorm_pinf_nan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 960 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_psub_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 127 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_psub_pnorm_pinf_snan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 126 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_psub_pnorm_pinf_qnan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 125 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_psub_pnorm_pinf_nan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 124 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 255 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 319 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_pnorm_pinf_nan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 316 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_pzero_psub_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 22 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_pzero_psub_pnorm_pinf_snan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 30 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_pzero_psub_pnorm_pinf_qnan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 29 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_pzero_psub_pnorm_pinf_nan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 28 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nsub_nzero_pzero_psub_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 6 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nsub_nzero_pzero_psub_pnorm_pinf_snan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 14 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nsub_nzero_pzero_psub_pnorm_pinf_qnan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 13 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nsub_nzero_pzero_psub_pnorm_pinf_nan__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 12 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_psub_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 95 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_nsub_pnorm_pinf__daz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,preserve-sign"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 207 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_psub_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 960 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_psub_pnorm_pinf_snan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 961 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_psub_pnorm_pinf_qnan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 962 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_psub_pnorm_pinf_nan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 963 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_psub_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 896 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_psub_pnorm_pinf_snan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 897 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_psub_pnorm_pinf_qnan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 898 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_psub_pnorm_pinf_nan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 899 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 768 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 704 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_pzero_pnorm_pinf_nan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 707 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_pzero_psub_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 992 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_pzero_psub_pnorm_pinf_snan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 993 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_pzero_psub_pnorm_pinf_qnan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 994 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_pzero_psub_pnorm_pinf_nan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 995 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nsub_nzero_pzero_psub_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1017 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nsub_nzero_pzero_psub_pnorm_pinf_snan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1009 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nsub_nzero_pzero_psub_pnorm_pinf_qnan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1010 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nsub_nzero_pzero_psub_pnorm_pinf_nan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 1011 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_psub_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 928 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_nzero_nsub_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 816 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_psub_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 63 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_psub_pnorm_pinf_snan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 62 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_psub_pnorm_pinf_qnan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 61 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_psub_pnorm_pinf_nan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 960 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_psub_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 127 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_psub_pnorm_pinf_snan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 126 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_psub_pnorm_pinf_qnan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 125 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_psub_pnorm_pinf_nan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 124 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 255 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 319 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_pzero_pnorm_pinf_nan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 316 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_pzero_psub_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 22 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_pzero_psub_pnorm_pinf_snan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 30 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_pzero_psub_pnorm_pinf_qnan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 29 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_pzero_psub_pnorm_pinf_nan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 28 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nsub_nzero_pzero_psub_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 6 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nsub_nzero_pzero_psub_pnorm_pinf_snan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 14 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nsub_nzero_pzero_psub_pnorm_pinf_qnan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 13 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nsub_nzero_pzero_psub_pnorm_pinf_nan__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 12 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_psub_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 95 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_nzero_nsub_pnorm_pinf__dapz(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,positive-zero"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 207 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_psub_pnorm_pinf__dynamic(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,dynamic"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 896 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } + llvm.func @test_class_is_not_psub_pnorm_pinf__dynamic(%arg0: f32) -> i1 attributes {passthrough = [["denormal-fp-math", "dynamic,dynamic"]]} { + %0 = "llvm.intr.is.fpclass"(%arg0) <{bit = 127 : i32}> : (f32) -> i1 + llvm.return %0 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/isascii-1.ll.mlir b/test/LLVMDialect/InstCombine/isascii-1.ll.mlir index 181c201d2..b5886d789 100644 --- a/test/LLVMDialect/InstCombine/isascii-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/isascii-1.ll.mlir @@ -1,20 +1,17 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "isascii", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 127 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @isascii, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify1", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 128 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @isascii, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @isascii, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify3", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @isascii(i32) -> i32 + llvm.func @test_simplify1() -> i32 { + %0 = llvm.mlir.constant(127 : i32) : i32 + %1 = llvm.call @isascii(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify2() -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.call @isascii(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify3(%arg0: i32) -> i32 { + %0 = llvm.call @isascii(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/isascii-i16.ll.mlir b/test/LLVMDialect/InstCombine/isascii-i16.ll.mlir index b21b747a3..f0d259ce8 100644 --- a/test/LLVMDialect/InstCombine/isascii-i16.ll.mlir +++ b/test/LLVMDialect/InstCombine/isascii-i16.ll.mlir @@ -1,37 +1,33 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "isascii", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sink", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i16} : () -> i16 - %1 = "llvm.mlir.constant"() {value = 32767 : i16} : () -> i16 - %2 = "llvm.mlir.constant"() {value = 256 : i16} : () -> i16 - %3 = "llvm.mlir.constant"() {value = 255 : i16} : () -> i16 - %4 = "llvm.mlir.constant"() {value = 128 : i16} : () -> i16 - %5 = "llvm.mlir.constant"() {value = 127 : i16} : () -> i16 - %6 = "llvm.mlir.constant"() {value = 1 : i16} : () -> i16 - %7 = "llvm.mlir.constant"() {value = 0 : i16} : () -> i16 - %8 = "llvm.call"(%7) {callee = @isascii, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%8) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %9 = "llvm.call"(%6) {callee = @isascii, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%9) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %10 = "llvm.call"(%5) {callee = @isascii, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%10) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %11 = "llvm.call"(%4) {callee = @isascii, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%11) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %12 = "llvm.call"(%3) {callee = @isascii, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%12) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %13 = "llvm.call"(%2) {callee = @isascii, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%13) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %14 = "llvm.call"(%1) {callee = @isascii, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%14) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %15 = "llvm.call"(%0) {callee = @isascii, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%15) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %16 = "llvm.call"(%arg0) {callee = @isascii, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%16) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_isascii", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @isascii(i16) -> i16 + llvm.func @sink(i16) + llvm.func @fold_isascii(%arg0: i16) { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(1 : i16) : i16 + %2 = llvm.mlir.constant(127 : i16) : i16 + %3 = llvm.mlir.constant(128 : i16) : i16 + %4 = llvm.mlir.constant(255 : i16) : i16 + %5 = llvm.mlir.constant(256 : i16) : i16 + %6 = llvm.mlir.constant(32767 : i16) : i16 + %7 = llvm.mlir.constant(-1 : i16) : i16 + %8 = llvm.call @isascii(%0) : (i16) -> i16 + llvm.call @sink(%8) : (i16) -> () + %9 = llvm.call @isascii(%1) : (i16) -> i16 + llvm.call @sink(%9) : (i16) -> () + %10 = llvm.call @isascii(%2) : (i16) -> i16 + llvm.call @sink(%10) : (i16) -> () + %11 = llvm.call @isascii(%3) : (i16) -> i16 + llvm.call @sink(%11) : (i16) -> () + %12 = llvm.call @isascii(%4) : (i16) -> i16 + llvm.call @sink(%12) : (i16) -> () + %13 = llvm.call @isascii(%5) : (i16) -> i16 + llvm.call @sink(%13) : (i16) -> () + %14 = llvm.call @isascii(%6) : (i16) -> i16 + llvm.call @sink(%14) : (i16) -> () + %15 = llvm.call @isascii(%7) : (i16) -> i16 + llvm.call @sink(%15) : (i16) -> () + %16 = llvm.call @isascii(%arg0) : (i16) -> i16 + llvm.call @sink(%16) : (i16) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/isdigit-1.ll.mlir b/test/LLVMDialect/InstCombine/isdigit-1.ll.mlir index 3cb7362fb..154e06613 100644 --- a/test/LLVMDialect/InstCombine/isdigit-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/isdigit-1.ll.mlir @@ -1,30 +1,27 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "isdigit", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 47 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify1", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 48 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify2", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 57 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify3", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 58 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify5", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @isdigit(i32) -> i32 + llvm.func @test_simplify1() -> i32 { + %0 = llvm.mlir.constant(47 : i32) : i32 + %1 = llvm.call @isdigit(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify2() -> i32 { + %0 = llvm.mlir.constant(48 : i32) : i32 + %1 = llvm.call @isdigit(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify3() -> i32 { + %0 = llvm.mlir.constant(57 : i32) : i32 + %1 = llvm.call @isdigit(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify4() -> i32 { + %0 = llvm.mlir.constant(58 : i32) : i32 + %1 = llvm.call @isdigit(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify5(%arg0: i32) -> i32 { + %0 = llvm.call @isdigit(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/isdigit-i16.ll.mlir b/test/LLVMDialect/InstCombine/isdigit-i16.ll.mlir index bfda45c39..d1ce7c598 100644 --- a/test/LLVMDialect/InstCombine/isdigit-i16.ll.mlir +++ b/test/LLVMDialect/InstCombine/isdigit-i16.ll.mlir @@ -1,49 +1,45 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "isdigit", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sink", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32767 : i16} : () -> i16 - %1 = "llvm.mlir.constant"() {value = 256 : i16} : () -> i16 - %2 = "llvm.mlir.constant"() {value = 255 : i16} : () -> i16 - %3 = "llvm.mlir.constant"() {value = 128 : i16} : () -> i16 - %4 = "llvm.mlir.constant"() {value = 127 : i16} : () -> i16 - %5 = "llvm.mlir.constant"() {value = 58 : i16} : () -> i16 - %6 = "llvm.mlir.constant"() {value = 57 : i16} : () -> i16 - %7 = "llvm.mlir.constant"() {value = 49 : i16} : () -> i16 - %8 = "llvm.mlir.constant"() {value = 48 : i16} : () -> i16 - %9 = "llvm.mlir.constant"() {value = 47 : i16} : () -> i16 - %10 = "llvm.mlir.constant"() {value = 1 : i16} : () -> i16 - %11 = "llvm.mlir.constant"() {value = 0 : i16} : () -> i16 - %12 = "llvm.call"(%11) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%12) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %13 = "llvm.call"(%10) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%13) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %14 = "llvm.call"(%9) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%14) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %15 = "llvm.call"(%8) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%15) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %16 = "llvm.call"(%7) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%16) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %17 = "llvm.call"(%6) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%17) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %18 = "llvm.call"(%5) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%18) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %19 = "llvm.call"(%4) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%19) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %20 = "llvm.call"(%3) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%20) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %21 = "llvm.call"(%2) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%21) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %22 = "llvm.call"(%1) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%22) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %23 = "llvm.call"(%0) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%23) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - %24 = "llvm.call"(%arg0) {callee = @isdigit, fastmathFlags = #llvm.fastmath<>} : (i16) -> i16 - "llvm.call"(%24) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i16) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_isdigit", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @isdigit(i16) -> i16 + llvm.func @sink(i16) + llvm.func @fold_isdigit(%arg0: i16) { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(1 : i16) : i16 + %2 = llvm.mlir.constant(47 : i16) : i16 + %3 = llvm.mlir.constant(48 : i16) : i16 + %4 = llvm.mlir.constant(49 : i16) : i16 + %5 = llvm.mlir.constant(57 : i16) : i16 + %6 = llvm.mlir.constant(58 : i16) : i16 + %7 = llvm.mlir.constant(127 : i16) : i16 + %8 = llvm.mlir.constant(128 : i16) : i16 + %9 = llvm.mlir.constant(255 : i16) : i16 + %10 = llvm.mlir.constant(256 : i16) : i16 + %11 = llvm.mlir.constant(32767 : i16) : i16 + %12 = llvm.call @isdigit(%0) : (i16) -> i16 + llvm.call @sink(%12) : (i16) -> () + %13 = llvm.call @isdigit(%1) : (i16) -> i16 + llvm.call @sink(%13) : (i16) -> () + %14 = llvm.call @isdigit(%2) : (i16) -> i16 + llvm.call @sink(%14) : (i16) -> () + %15 = llvm.call @isdigit(%3) : (i16) -> i16 + llvm.call @sink(%15) : (i16) -> () + %16 = llvm.call @isdigit(%4) : (i16) -> i16 + llvm.call @sink(%16) : (i16) -> () + %17 = llvm.call @isdigit(%5) : (i16) -> i16 + llvm.call @sink(%17) : (i16) -> () + %18 = llvm.call @isdigit(%6) : (i16) -> i16 + llvm.call @sink(%18) : (i16) -> () + %19 = llvm.call @isdigit(%7) : (i16) -> i16 + llvm.call @sink(%19) : (i16) -> () + %20 = llvm.call @isdigit(%8) : (i16) -> i16 + llvm.call @sink(%20) : (i16) -> () + %21 = llvm.call @isdigit(%9) : (i16) -> i16 + llvm.call @sink(%21) : (i16) -> () + %22 = llvm.call @isdigit(%10) : (i16) -> i16 + llvm.call @sink(%22) : (i16) -> () + %23 = llvm.call @isdigit(%11) : (i16) -> i16 + llvm.call @sink(%23) : (i16) -> () + %24 = llvm.call @isdigit(%arg0) : (i16) -> i16 + llvm.call @sink(%24) : (i16) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/ispow2.ll.mlir b/test/LLVMDialect/InstCombine/ispow2.ll.mlir new file mode 100644 index 000000000..56fb6ac78 --- /dev/null +++ b/test/LLVMDialect/InstCombine/ispow2.ll.mlir @@ -0,0 +1,951 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @is_pow2or0_negate_op(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.icmp "eq" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @is_pow2or0_negate_op_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %1, %arg0 : vector<2xi32> + %3 = llvm.and %2, %arg0 : vector<2xi32> + %4 = llvm.icmp "eq" %3, %arg0 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @is_pow2or0_decrement_op(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @is_pow2or0_decrement_op_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.add %arg0, %0 : vector<2xi8> + %4 = llvm.and %3, %arg0 : vector<2xi8> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi8> + llvm.return %5 : vector<2xi1> + } + llvm.func @isnot_pow2or0_negate_op(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.icmp "ne" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @isnot_pow2or0_negate_op_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %1, %arg0 : vector<2xi32> + %3 = llvm.and %2, %arg0 : vector<2xi32> + %4 = llvm.icmp "ne" %3, %arg0 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @isnot_pow2or0_decrement_op(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "ne" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @isnot_pow2or0_decrement_op_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.add %arg0, %0 : vector<2xi8> + %4 = llvm.and %3, %arg0 : vector<2xi8> + %5 = llvm.icmp "ne" %4, %2 : vector<2xi8> + llvm.return %5 : vector<2xi1> + } + llvm.func @is_pow2or0_negate_op_commute1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %0, %arg0 : i32 + %3 = llvm.sub %1, %2 : i32 + %4 = llvm.and %2, %3 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @isnot_pow2or0_negate_op_commute2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.urem %0, %arg0 : i32 + %3 = llvm.sub %1, %2 : i32 + %4 = llvm.and %3, %2 : i32 + %5 = llvm.icmp "ne" %2, %4 : i32 + llvm.return %5 : i1 + } + llvm.func @isnot_pow2or0_negate_op_commute3(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.urem %0, %arg0 : i32 + %3 = llvm.sub %1, %2 : i32 + %4 = llvm.and %2, %3 : i32 + %5 = llvm.icmp "ne" %2, %4 : i32 + llvm.return %5 : i1 + } + llvm.func @use(i32) + llvm.func @is_pow2or0_negate_op_extra_use1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.icmp "eq" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @is_pow2or0_negate_op_extra_use2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.and %1, %arg0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "eq" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @is_pow2_ctpop(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ult" %2, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @is_pow2_non_zero_ult_2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ult" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @is_pow2_non_zero_eq_1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @is_pow2_non_zero_ugt_1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ugt" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @is_pow2_non_zero_ne_1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @is_pow2_ctpop_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + %5 = llvm.icmp "ne" %arg0, %1 : i32 + %6 = llvm.select %5, %4, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @use_i1(i1) + llvm.func @is_pow2_ctpop_extra_uses(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ult" %2, %0 : i32 + llvm.call @use_i1(%3) : (i1) -> () + %4 = llvm.icmp "ne" %arg0, %1 : i32 + llvm.call @use_i1(%4) : (i1) -> () + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @is_pow2_ctpop_extra_uses_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.call @use_i1(%4) : (i1) -> () + %5 = llvm.icmp "ne" %arg0, %1 : i32 + llvm.call @use_i1(%5) : (i1) -> () + %6 = llvm.select %5, %4, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @is_pow2_ctpop_commute_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.intr.ctpop(%arg0) : (vector<2xi8>) -> vector<2xi8> + %4 = llvm.icmp "ult" %3, %0 : vector<2xi8> + %5 = llvm.icmp "ne" %arg0, %2 : vector<2xi8> + %6 = llvm.and %4, %5 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @is_pow2_ctpop_wrong_cmp_op1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ult" %2, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @is_pow2_ctpop_wrong_cmp_op1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + %5 = llvm.icmp "ne" %arg0, %1 : i32 + %6 = llvm.select %5, %4, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @is_pow2_ctpop_wrong_cmp_op2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ult" %2, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @is_pow2_ctpop_wrong_cmp_op2_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + %5 = llvm.icmp "ne" %arg0, %1 : i32 + %6 = llvm.select %5, %4, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @is_pow2_ctpop_wrong_pred1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ugt" %2, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @is_pow2_ctpop_wrong_pred1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + %5 = llvm.icmp "ne" %arg0, %1 : i32 + %6 = llvm.select %5, %4, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @is_pow2_ctpop_wrong_pred2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ult" %2, %0 : i32 + %4 = llvm.icmp "sgt" %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @is_pow2_ctpop_wrong_pred2_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + %5 = llvm.icmp "sgt" %arg0, %1 : i32 + %6 = llvm.select %5, %4, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @isnot_pow2_ctpop(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ugt" %2, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.or %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @isnot_pow2_ctpop_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + %5 = llvm.icmp "eq" %arg0, %1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @isnot_pow2_ctpop_extra_uses(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ugt" %2, %0 : i32 + llvm.call @use_i1(%3) : (i1) -> () + %4 = llvm.icmp "eq" %arg0, %1 : i32 + llvm.call @use_i1(%4) : (i1) -> () + %5 = llvm.or %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @isnot_pow2_ctpop_extra_uses_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + llvm.call @use_i1(%4) : (i1) -> () + %5 = llvm.icmp "eq" %arg0, %1 : i32 + llvm.call @use_i1(%5) : (i1) -> () + %6 = llvm.select %5, %2, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @isnot_pow2_ctpop_commute_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.intr.ctpop(%arg0) : (vector<2xi8>) -> vector<2xi8> + %4 = llvm.icmp "ugt" %3, %0 : vector<2xi8> + %5 = llvm.icmp "eq" %arg0, %2 : vector<2xi8> + %6 = llvm.or %4, %5 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @isnot_pow2_ctpop_wrong_cmp_op1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ugt" %2, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.or %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @isnot_pow2_ctpop_wrong_cmp_op1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + %5 = llvm.icmp "eq" %arg0, %1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @isnot_pow2_ctpop_wrong_cmp_op2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.or %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @isnot_pow2_ctpop_wrong_cmp_op2_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ugt" %2, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %0 : i32 + %5 = llvm.select %4, %1, %3 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @isnot_pow2_ctpop_wrong_pred2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ugt" %2, %0 : i32 + %4 = llvm.icmp "slt" %arg0, %1 : i32 + %5 = llvm.or %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @isnot_pow2_ctpop_wrong_pred2_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ugt" %3, %0 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @is_pow2_negate_op(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.icmp "eq" %2, %arg0 : i32 + %4 = llvm.icmp "ne" %arg0, %0 : i32 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @is_pow2_negate_op_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "eq" %3, %arg0 : i32 + %5 = llvm.icmp "ne" %arg0, %0 : i32 + %6 = llvm.select %5, %4, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @is_pow2_negate_op_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %1, %arg0 : vector<2xi32> + %3 = llvm.and %2, %arg0 : vector<2xi32> + %4 = llvm.icmp "eq" %3, %arg0 : vector<2xi32> + %5 = llvm.icmp "ne" %arg0, %1 : vector<2xi32> + %6 = llvm.and %4, %5 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @is_pow2_decrement_op(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + %5 = llvm.icmp "ne" %arg0, %1 : i8 + %6 = llvm.and %4, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @is_pow2_decrement_op_logical(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.add %arg0, %0 : i8 + %4 = llvm.and %3, %arg0 : i8 + %5 = llvm.icmp "eq" %4, %1 : i8 + %6 = llvm.icmp "ne" %arg0, %1 : i8 + %7 = llvm.select %5, %6, %2 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @is_pow2_decrement_op_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.add %arg0, %0 : vector<2xi8> + %4 = llvm.and %3, %arg0 : vector<2xi8> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi8> + %6 = llvm.icmp "ne" %arg0, %2 : vector<2xi8> + %7 = llvm.and %6, %5 : vector<2xi1> + llvm.return %7 : vector<2xi1> + } + llvm.func @isnot_pow2_negate_op(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.icmp "ne" %2, %arg0 : i32 + %4 = llvm.icmp "eq" %arg0, %0 : i32 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @isnot_pow2_negate_op_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "ne" %3, %arg0 : i32 + %5 = llvm.icmp "eq" %arg0, %0 : i32 + %6 = llvm.select %4, %1, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @isnot_pow2_negate_op_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %1, %arg0 : vector<2xi32> + %3 = llvm.and %2, %arg0 : vector<2xi32> + %4 = llvm.icmp "ne" %3, %arg0 : vector<2xi32> + %5 = llvm.icmp "eq" %arg0, %1 : vector<2xi32> + %6 = llvm.or %5, %4 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @isnot_pow2_decrement_op(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "ne" %3, %1 : i8 + %5 = llvm.icmp "eq" %arg0, %1 : i8 + %6 = llvm.or %5, %4 : i1 + llvm.return %6 : i1 + } + llvm.func @isnot_pow2_decrement_op_logical(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.add %arg0, %0 : i8 + %4 = llvm.and %3, %arg0 : i8 + %5 = llvm.icmp "ne" %4, %1 : i8 + %6 = llvm.icmp "eq" %arg0, %1 : i8 + %7 = llvm.select %6, %2, %5 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @isnot_pow2_decrement_op_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.add %arg0, %0 : vector<2xi8> + %4 = llvm.and %3, %arg0 : vector<2xi8> + %5 = llvm.icmp "ne" %4, %2 : vector<2xi8> + %6 = llvm.icmp "eq" %arg0, %2 : vector<2xi8> + %7 = llvm.or %5, %6 : vector<2xi1> + llvm.return %7 : vector<2xi1> + } + llvm.func @is_pow2or0_ctpop(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.or %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @is_pow2or0_ctpop_swap_cmp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @is_pow2or0_ctpop_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + %5 = llvm.icmp "eq" %arg0, %1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @is_pow2or0_ctpop_commute_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.intr.ctpop(%arg0) : (vector<2xi8>) -> vector<2xi8> + %4 = llvm.icmp "eq" %3, %0 : vector<2xi8> + %5 = llvm.icmp "eq" %arg0, %2 : vector<2xi8> + %6 = llvm.or %5, %4 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @is_pow2or0_ctpop_extra_uses(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.call @use_i1(%3) : (i1) -> () + %4 = llvm.icmp "eq" %arg0, %1 : i32 + llvm.call @use_i1(%4) : (i1) -> () + %5 = llvm.or %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @is_pow2or0_ctpop_logical_extra_uses(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.call @use_i1(%4) : (i1) -> () + %5 = llvm.icmp "eq" %arg0, %1 : i32 + llvm.call @use_i1(%5) : (i1) -> () + %6 = llvm.select %5, %2, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @is_pow2or0_ctpop_wrong_cmp_op1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.or %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @is_pow2or0_ctpop_wrong_cmp_op1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + %5 = llvm.icmp "eq" %arg0, %1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @is_pow2or0_ctpop_commute_vec_wrong_cmp_op1(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-1, 1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.intr.ctpop(%arg0) : (vector<2xi8>) -> vector<2xi8> + %4 = llvm.icmp "eq" %3, %0 : vector<2xi8> + %5 = llvm.icmp "eq" %arg0, %2 : vector<2xi8> + %6 = llvm.or %4, %5 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @is_pow2or0_ctpop_wrong_pred1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.or %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @is_pow2or0_ctpop_wrong_pred2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.or %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @is_pow2or0_ctpop_wrong_pred2_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + %5 = llvm.icmp "ne" %arg0, %1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @is_pow2or0_ctpop_commute_vec_wrong_pred3(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.intr.ctpop(%arg0) : (vector<2xi8>) -> vector<2xi8> + %4 = llvm.icmp "eq" %3, %0 : vector<2xi8> + %5 = llvm.icmp "eq" %arg0, %2 : vector<2xi8> + %6 = llvm.and %4, %5 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @isnot_pow2nor0_ctpop(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @isnot_pow2nor0_ctpop_swap_cmp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @isnot_pow2nor0_ctpop_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + %5 = llvm.icmp "ne" %arg0, %1 : i32 + %6 = llvm.select %5, %4, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @isnot_pow2nor0_ctpop_commute_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.intr.ctpop(%arg0) : (vector<2xi8>) -> vector<2xi8> + %4 = llvm.icmp "ne" %3, %0 : vector<2xi8> + %5 = llvm.icmp "ne" %arg0, %2 : vector<2xi8> + %6 = llvm.and %5, %4 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @isnot_pow2nor0_ctpop_extra_uses(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.icmp "ne" %2, %0 : i32 + llvm.call @use_i1(%3) : (i1) -> () + %4 = llvm.icmp "ne" %arg0, %1 : i32 + llvm.call @use_i1(%4) : (i1) -> () + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @isnot_pow2nor0_ctpop_logical_extra_uses(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.call @use_i1(%4) : (i1) -> () + %5 = llvm.icmp "ne" %arg0, %1 : i32 + llvm.call @use_i1(%5) : (i1) -> () + %6 = llvm.select %5, %4, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @isnot_pow2nor0_ctpop_wrong_cmp_op1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @isnot_pow2nor0_ctpop_wrong_cmp_op1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + %5 = llvm.icmp "ne" %arg0, %1 : i32 + %6 = llvm.select %5, %4, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @isnot_pow2nor0_ctpop_commute_vec_wrong_cmp_op1(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[0, -1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.intr.ctpop(%arg0) : (vector<2xi8>) -> vector<2xi8> + %4 = llvm.icmp "ne" %3, %0 : vector<2xi8> + %5 = llvm.icmp "ne" %arg0, %2 : vector<2xi8> + %6 = llvm.and %4, %5 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @isnot_pow2nor0_ctpop_wrong_pred1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @isnot_pow2nor0_ctpop_wrong_pred2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @isnot_pow2nor0_ctpop_wrong_pred2_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + %5 = llvm.icmp "eq" %arg0, %1 : i32 + %6 = llvm.select %5, %4, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @isnot_pow2nor0_wrong_pred3_ctpop_commute_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.intr.ctpop(%arg0) : (vector<2xi8>) -> vector<2xi8> + %4 = llvm.icmp "ne" %3, %0 : vector<2xi8> + %5 = llvm.icmp "ne" %arg0, %2 : vector<2xi8> + %6 = llvm.or %4, %5 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @is_pow2_fail_pr63327(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.and %arg0, %1 : i32 + %3 = llvm.icmp "sge" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @blsmsk_is_p2_or_z(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.add %1, %0 : i32 + %3 = llvm.xor %1, %2 : i32 + %4 = llvm.icmp "uge" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @blsmsk_isnt_p2_or_z(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.xor %arg0, %1 : i32 + %3 = llvm.icmp "ult" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @blsmsk_is_p2_or_z_fail(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.add %1, %0 : i32 + %3 = llvm.xor %1, %2 : i32 + %4 = llvm.icmp "ugt" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @blsmsk_isnt_p2_or_z_fail(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.xor %arg0, %1 : i32 + %3 = llvm.icmp "ule" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @use.i32(i32) + llvm.func @blsmsk_isnt_p2_or_z_fail_multiuse(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.xor %arg0, %1 : i32 + llvm.call @use.i32(%2) : (i32) -> () + %3 = llvm.icmp "ult" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @blsmsk_isnt_p2_or_z_fail_wrong_add(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg1, %0 : i32 + %2 = llvm.xor %arg0, %1 : i32 + %3 = llvm.icmp "ult" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @blsmsk_isnt_p2_or_z_fail_bad_xor(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.xor %arg1, %1 : i32 + %3 = llvm.icmp "ult" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @blsmsk_is_p2_or_z_fail_bad_cmp(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.xor %arg0, %1 : i32 + %3 = llvm.icmp "uge" %2, %arg1 : i32 + llvm.return %3 : i1 + } + llvm.func @blsmsk_is_p2_or_z_ule_xy(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.or %arg0, %arg1 : i8 + %2 = llvm.add %1, %0 : i8 + %3 = llvm.xor %1, %2 : i8 + %4 = llvm.icmp "ule" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @blsmsk_is_p2_or_z_ule_yx_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.or %arg0, %arg1 : i8 + %2 = llvm.add %1, %0 : i8 + %3 = llvm.xor %1, %2 : i8 + %4 = llvm.icmp "ule" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @blsmsk_is_p2_or_z_uge_yx(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.or %arg0, %arg1 : i8 + %2 = llvm.add %1, %0 : i8 + %3 = llvm.xor %1, %2 : i8 + %4 = llvm.icmp "uge" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @blsmsk_is_p2_or_z_uge_xy_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.or %arg0, %arg1 : i8 + %2 = llvm.add %1, %0 : i8 + %3 = llvm.xor %1, %2 : i8 + %4 = llvm.icmp "uge" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @blsmsk_isnt_p2_or_z_ugt_xy(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.or %arg0, %arg1 : i8 + %2 = llvm.add %1, %0 : i8 + %3 = llvm.xor %1, %2 : i8 + %4 = llvm.icmp "ugt" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @blsmsk_isnt_p2_or_z_ugt_yx_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.or %arg0, %arg1 : i8 + %2 = llvm.add %1, %0 : i8 + %3 = llvm.xor %1, %2 : i8 + %4 = llvm.icmp "ugt" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @blsmsk_isnt_p2_or_z_ult_yx(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.or %arg0, %arg1 : i8 + %2 = llvm.add %1, %0 : i8 + %3 = llvm.xor %1, %2 : i8 + %4 = llvm.icmp "ult" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @blsmsk_isnt_p2_or_z_ult_xy_fail(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.or %arg0, %arg1 : i8 + %2 = llvm.add %1, %0 : i8 + %3 = llvm.xor %1, %2 : i8 + %4 = llvm.icmp "ult" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @is_pow2_nz_known_bits(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.intr.ctpop(%2) : (i32) -> i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @is_pow2_nz_known_bits_fail_multiuse(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.intr.ctpop(%2) : (i32) -> i32 + llvm.call @use.i32(%3) : (i32) -> () + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @not_pow2_nz_known_bits(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.or %arg0, %0 : i32 + %2 = llvm.intr.ctpop(%1) : (i32) -> i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @not_pow2_nz_known_bits_fail_not_p2_test(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.intr.ctpop(%2) : (i32) -> i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @is_pow2_or_z_known_bits(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.intr.ctpop(%2) : (i32) -> i32 + %4 = llvm.icmp "ult" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @not_pow2_or_z_known_bits(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<64> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.or %arg0, %0 : vector<2xi32> + %3 = llvm.intr.ctpop(%2) : (vector<2xi32>) -> vector<2xi32> + %4 = llvm.icmp "ugt" %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @not_pow2_or_z_known_bits_fail_wrong_cmp(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<64> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %2 = llvm.or %arg0, %0 : vector<2xi32> + %3 = llvm.intr.ctpop(%2) : (vector<2xi32>) -> vector<2xi32> + %4 = llvm.icmp "ugt" %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/kcfi-operand-bundles.ll.mlir b/test/LLVMDialect/InstCombine/kcfi-operand-bundles.ll.mlir new file mode 100644 index 000000000..ef253b078 --- /dev/null +++ b/test/LLVMDialect/InstCombine/kcfi-operand-bundles.ll.mlir @@ -0,0 +1,12 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f1() attributes {passthrough = ["kcfi-target"]} { + llvm.return + } + llvm.func @f2() attributes {passthrough = ["kcfi-target"]} + llvm.func @g(%arg0: !llvm.ptr {llvm.noundef}) attributes {passthrough = ["kcfi-target"]} { + llvm.call %arg0() : !llvm.ptr, () -> () + llvm.call @f1() : () -> () + llvm.call @f2() : () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/known-bits.ll.mlir b/test/LLVMDialect/InstCombine/known-bits.ll.mlir index 7ab917854..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/known-bits.ll.mlir +++ b/test/LLVMDialect/InstCombine/known-bits.ll.mlir @@ -1,44 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 64 : i8} : () -> i8 - %2 = "llvm.zext"(%arg0) : (i1) -> i8 - %3 = "llvm.shl"(%1, %2) : (i8, i8) -> i8 - %4 = "llvm.and"(%3, %0) : (i8, i8) -> i8 - "llvm.call"(%4) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_shl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 64 : i8} : () -> i8 - %2 = "llvm.zext"(%arg0) : (i1) -> i8 - %3 = "llvm.lshr"(%1, %2) : (i8, i8) -> i8 - %4 = "llvm.and"(%3, %0) : (i8, i8) -> i8 - "llvm.call"(%4) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_lshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = -16 : i8} : () -> i8 - %2 = "llvm.zext"(%arg0) : (i1) -> i8 - %3 = "llvm.ashr"(%1, %2) : (i8, i8) -> i8 - %4 = "llvm.and"(%3, %0) : (i8, i8) -> i8 - "llvm.call"(%4) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_ashr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 64 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 10 : i8} : () -> i8 - %2 = "llvm.udiv"(%1, %arg0) : (i8, i8) -> i8 - %3 = "llvm.and"(%2, %0) : (i8, i8) -> i8 - "llvm.call"(%3) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_udiv", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sink", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/known-fpclass-reduce-signbit.ll.mlir b/test/LLVMDialect/InstCombine/known-fpclass-reduce-signbit.ll.mlir new file mode 100644 index 000000000..05e93d82b --- /dev/null +++ b/test/LLVMDialect/InstCombine/known-fpclass-reduce-signbit.ll.mlir @@ -0,0 +1,65 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @vector_reduce_maximum_signbit(%arg0: vector<4xf64>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (vector<4xf64>) -> vector<4xf64> + %2 = llvm.intr.vector.reduce.fmaximum(%1) : (vector<4xf64>) -> f64 + %3 = llvm.fcmp "oge" %2, %0 : f64 + llvm.return %3 : i1 + } + llvm.func @vector_reduce_maximum_signbit_fail_maybe_nan(%arg0: vector<4xf64>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (vector<4xf64>) -> vector<4xf64> + %2 = llvm.intr.vector.reduce.fmaximum(%1) : (vector<4xf64>) -> f64 + %3 = llvm.fcmp "oge" %2, %0 : f64 + llvm.return %3 : i1 + } + llvm.func @vector_reduce_minimum_signbit(%arg0: vector<4xf64>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (vector<4xf64>) -> vector<4xf64> + %2 = llvm.intr.vector.reduce.fminimum(%1) : (vector<4xf64>) -> f64 + %3 = llvm.fcmp "oge" %2, %0 : f64 + llvm.return %3 : i1 + } + llvm.func @vector_reduce_minimum_signbit_fail_maybe_nan(%arg0: vector<4xf64>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (vector<4xf64>) -> vector<4xf64> + %2 = llvm.intr.vector.reduce.fminimum(%1) : (vector<4xf64>) -> f64 + %3 = llvm.fcmp "oge" %2, %0 : f64 + llvm.return %3 : i1 + } + llvm.func @vector_reduce_max_signbit(%arg0: vector<4xf64>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (vector<4xf64>) -> vector<4xf64> + %2 = llvm.intr.vector.reduce.fmax(%1) : (vector<4xf64>) -> f64 + %3 = llvm.fcmp "oge" %2, %0 : f64 + llvm.return %3 : i1 + } + llvm.func @vector_reduce_max_signbit_fail_maybe_nan(%arg0: vector<4xf64>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (vector<4xf64>) -> vector<4xf64> + %2 = llvm.intr.vector.reduce.fmax(%1) : (vector<4xf64>) -> f64 + %3 = llvm.fcmp "oge" %2, %0 : f64 + llvm.return %3 : i1 + } + llvm.func @vector_reduce_min_signbit(%arg0: vector<4xf64>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (vector<4xf64>) -> vector<4xf64> + %2 = llvm.intr.vector.reduce.fmin(%1) : (vector<4xf64>) -> f64 + %3 = llvm.fcmp "oge" %2, %0 : f64 + llvm.return %3 : i1 + } + llvm.func @vector_reduce_min_signbit_fail_maybe_nan(%arg0: vector<4xf64>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (vector<4xf64>) -> vector<4xf64> + %2 = llvm.intr.vector.reduce.fmin(%1) : (vector<4xf64>) -> f64 + %3 = llvm.fcmp "oge" %2, %0 : f64 + llvm.return %3 : i1 + } + llvm.func @vector_reduce_min_signbit_nnan_from_fmf(%arg0: vector<4xf64>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.fabs(%arg0) : (vector<4xf64>) -> vector<4xf64> + %2 = llvm.intr.vector.reduce.fmin(%1) {fastmathFlags = #llvm.fastmath} : (vector<4xf64>) -> f64 + %3 = llvm.fcmp "oge" %2, %0 : f64 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/known-never-nan.ll.mlir b/test/LLVMDialect/InstCombine/known-never-nan.ll.mlir new file mode 100644 index 000000000..2d952e1f1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/known-never-nan.ll.mlir @@ -0,0 +1,106 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fabs_sqrt_src_maybe_nan(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %1 = llvm.intr.sqrt(%0) : (f64) -> f64 + %2 = llvm.fcmp "ord" %1, %1 : f64 + llvm.return %2 : i1 + } + llvm.func @select_maybe_nan_lhs(%arg0: i1, %arg1: f64, %arg2: f64) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.fadd %arg2, %0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.select %arg0, %arg1, %1 : i1, f64 + %3 = llvm.fcmp "ord" %2, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @select_maybe_nan_rhs(%arg0: i1, %arg1: f64, %arg2: f64) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.fadd %arg1, %0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.select %arg0, %1, %arg2 : i1, f64 + %3 = llvm.fcmp "ord" %2, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @nnan_fadd(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fadd %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + %4 = llvm.fadd %2, %3 : f64 + %5 = llvm.fcmp "ord" %4, %4 : f64 + llvm.return %5 : i1 + } + llvm.func @nnan_fadd_maybe_nan_lhs(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.fadd %arg1, %0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fadd %arg0, %1 : f64 + %3 = llvm.fcmp "ord" %2, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @nnan_fadd_maybe_nan_rhs(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fadd %1, %arg1 : f64 + %3 = llvm.fcmp "ord" %2, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @nnan_fmul(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fadd %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + %4 = llvm.fmul %2, %3 : f64 + %5 = llvm.fcmp "ord" %4, %4 : f64 + llvm.return %5 : i1 + } + llvm.func @nnan_fsub(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fadd %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + %4 = llvm.fsub %2, %3 : f64 + %5 = llvm.fcmp "ord" %4, %4 : f64 + llvm.return %5 : i1 + } + llvm.func @func() -> f64 + llvm.func @nnan_fneg() -> i1 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.call @func() {fastmathFlags = #llvm.fastmath} : () -> f64 + %2 = llvm.fsub %0, %1 : f64 + %3 = llvm.fcmp "ord" %2, %2 : f64 + llvm.return %3 : i1 + } + llvm.func @nnan_unary_fneg() -> i1 { + %0 = llvm.call @func() {fastmathFlags = #llvm.fastmath} : () -> f64 + %1 = llvm.fneg %0 : f64 + %2 = llvm.fcmp "ord" %1, %1 : f64 + llvm.return %2 : i1 + } + llvm.func @fpext_maybe_nan(%arg0: f32) -> i1 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fcmp "ord" %0, %0 : f64 + llvm.return %1 : i1 + } + llvm.func @fptrunc_maybe_nan(%arg0: f64) -> i1 { + %0 = llvm.fptrunc %arg0 : f64 to f32 + %1 = llvm.fcmp "ord" %0, %0 : f32 + llvm.return %1 : i1 + } + llvm.func @nnan_fdiv(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fadd %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + %4 = llvm.fdiv %2, %3 : f64 + %5 = llvm.fcmp "ord" %4, %4 : f64 + llvm.return %5 : i1 + } + llvm.func @nnan_frem(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.fadd %arg0, %0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fadd %arg0, %1 {fastmathFlags = #llvm.fastmath} : f64 + %4 = llvm.frem %2, %3 : f64 + %5 = llvm.fcmp "ord" %4, %4 : f64 + llvm.return %5 : i1 + } + llvm.func @llvm.canonicalize.f64(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nocallback", "nofree", "nosync", "nounwind", "speculatable", "willreturn"]} +} diff --git a/test/LLVMDialect/InstCombine/known-non-zero.ll.mlir b/test/LLVMDialect/InstCombine/known-non-zero.ll.mlir new file mode 100644 index 000000000..897259d5c --- /dev/null +++ b/test/LLVMDialect/InstCombine/known-non-zero.ll.mlir @@ -0,0 +1,145 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test0(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i64 + llvm.cond_br %2, ^bb2(%1 : i32), ^bb1 + ^bb1: // pred: ^bb0 + %3 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i64) -> i64 + %4 = llvm.trunc %3 : i64 to i32 + llvm.br ^bb2(%4 : i32) + ^bb2(%5: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %5 : i32 + } + llvm.func @test1(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i64 + llvm.cond_br %2, ^bb2(%1 : i32), ^bb1 + ^bb1: // pred: ^bb0 + %3 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i64) -> i64 + %4 = llvm.trunc %3 : i64 to i32 + llvm.br ^bb2(%4 : i32) + ^bb2(%5: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %5 : i32 + } + llvm.func @test2(%arg0: vector<8xi64>) -> vector<8xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<8xi64>) : vector<8xi64> + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "eq" %arg0, %1 : vector<8xi64> + %4 = llvm.bitcast %3 : vector<8xi1> to i8 + %5 = llvm.icmp "eq" %4, %2 : i8 + llvm.cond_br %5, ^bb2(%1 : vector<8xi64>), ^bb1 + ^bb1: // pred: ^bb0 + %6 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (vector<8xi64>) -> vector<8xi64> + llvm.br ^bb2(%6 : vector<8xi64>) + ^bb2(%7: vector<8xi64>): // 2 preds: ^bb0, ^bb1 + llvm.return %7 : vector<8xi64> + } + llvm.func @D60846_miscompile(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(1 : i16) : i16 + %2 = llvm.mlir.constant(2 : i16) : i16 + llvm.br ^bb1(%0 : i16) + ^bb1(%3: i16): // 2 preds: ^bb0, ^bb3 + %4 = llvm.icmp "eq" %3, %0 : i16 + llvm.cond_br %4, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + %5 = llvm.icmp "eq" %3, %1 : i16 + llvm.store %5, %arg0 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + %6 = llvm.add %3, %1 : i16 + %7 = llvm.icmp "ult" %6, %2 : i16 + llvm.cond_br %7, ^bb1(%6 : i16), ^bb4 + ^bb4: // pred: ^bb3 + llvm.return + } + llvm.func @test_sgt_zero(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i64) -> i64 + llvm.return %3 : i64 + ^bb2: // pred: ^bb0 + llvm.return %1 : i64 + } + llvm.func @test_slt_neg_ten(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(-10 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.icmp "slt" %arg0, %0 : i64 + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i64) -> i64 + llvm.return %3 : i64 + ^bb2: // pred: ^bb0 + llvm.return %1 : i64 + } + llvm.func @test_slt_ten(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.icmp "slt" %arg0, %0 : i64 + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i64) -> i64 + llvm.return %3 : i64 + ^bb2: // pred: ^bb0 + llvm.return %1 : i64 + } + llvm.func @test_ugt_unknown(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i64 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i64) -> i64 + llvm.return %2 : i64 + ^bb2: // pred: ^bb0 + llvm.return %0 : i64 + } + llvm.func @test_sle_zero(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.icmp "sle" %arg0, %0 : i64 + llvm.cond_br %2, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + %3 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i64) -> i64 + llvm.return %3 : i64 + ^bb2: // pred: ^bb0 + llvm.return %1 : i64 + } + llvm.func @test_sge_neg_ten(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(-10 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.icmp "sge" %arg0, %0 : i64 + llvm.cond_br %2, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + %3 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i64) -> i64 + llvm.return %3 : i64 + ^bb2: // pred: ^bb0 + llvm.return %1 : i64 + } + llvm.func @test_sge_ten(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.icmp "sge" %arg0, %0 : i64 + llvm.cond_br %2, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + %3 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i64) -> i64 + llvm.return %3 : i64 + ^bb2: // pred: ^bb0 + llvm.return %1 : i64 + } + llvm.func @test_ule_unknown(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.icmp "ule" %arg0, %arg1 : i64 + llvm.cond_br %1, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i64) -> i64 + llvm.return %2 : i64 + ^bb2: // pred: ^bb0 + llvm.return %0 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/known-phi-br.ll.mlir b/test/LLVMDialect/InstCombine/known-phi-br.ll.mlir index e59be47d1..bb6a9a3a8 100644 --- a/test/LLVMDialect/InstCombine/known-phi-br.ll.mlir +++ b/test/LLVMDialect/InstCombine/known-phi-br.ll.mlir @@ -1,103 +1,93 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%1, %arg0)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i64) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @limit_i64_eq_7(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.icmp "eq" %arg0, %0 : i64 + llvm.cond_br %1, ^bb2(%arg0 : i64), ^bb1 ^bb1: // pred: ^bb0 - "llvm.br"(%0)[^bb2] : (i64) -> () + llvm.br ^bb2(%0 : i64) ^bb2(%2: i64): // 2 preds: ^bb0, ^bb1 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "limit_i64_eq_7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 255 : i64} : () -> i64 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 1 : i64} : (i64, i64) -> i1 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.cond_br"(%1, %arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i64) -> () + llvm.return %2 : i64 + } + llvm.func @limit_i64_ne_255(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(255 : i64) : i64 + %1 = llvm.icmp "ne" %arg0, %0 : i64 + llvm.call @use(%1) : (i1) -> () + llvm.cond_br %1, ^bb1, ^bb2(%arg0 : i64) ^bb1: // pred: ^bb0 - "llvm.br"(%0)[^bb2] : (i64) -> () + llvm.br ^bb2(%0 : i64) ^bb2(%2: i64): // 2 preds: ^bb0, ^bb1 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "limit_i64_ne_255", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 15 : i64} : () -> i64 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 7 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%1, %arg0)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i64) -> () + llvm.return %2 : i64 + } + llvm.func @use(i1) + llvm.func @limit_i64_ule_15(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(15 : i64) : i64 + %1 = llvm.icmp "ule" %arg0, %0 : i64 + llvm.cond_br %1, ^bb2(%arg0 : i64), ^bb1 ^bb1: // pred: ^bb0 - %2 = "llvm.and"(%arg0, %0) : (i64, i64) -> i64 - "llvm.br"(%2)[^bb2] : (i64) -> () + %2 = llvm.and %arg0, %0 : i64 + llvm.br ^bb2(%2 : i64) ^bb2(%3: i64): // 2 preds: ^bb0, ^bb1 - %4 = "llvm.and"(%3, %0) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "limit_i64_ule_15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %2 = "llvm.icmp"(%arg0, %1) {predicate = 9 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%2, %arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i64) -> () + %4 = llvm.and %3, %0 : i64 + llvm.return %4 : i64 + } + llvm.func @limit_i64_uge_8(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(7 : i64) : i64 + %2 = llvm.icmp "uge" %arg0, %0 : i64 + llvm.cond_br %2, ^bb1, ^bb2(%arg0 : i64) ^bb1: // pred: ^bb0 - %3 = "llvm.and"(%arg0, %0) : (i64, i64) -> i64 - "llvm.br"(%3)[^bb2] : (i64) -> () + %3 = llvm.and %arg0, %1 : i64 + llvm.br ^bb2(%3 : i64) ^bb2(%4: i64): // 2 preds: ^bb0, ^bb1 - %5 = "llvm.and"(%4, %0) : (i64, i64) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "limit_i64_uge_8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %2 = "llvm.icmp"(%arg0, %1) {predicate = 6 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%2, %arg0)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i64) -> () + %5 = llvm.and %4, %1 : i64 + llvm.return %5 : i64 + } + llvm.func @limit_i64_ult_8(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(7 : i64) : i64 + %2 = llvm.icmp "ult" %arg0, %0 : i64 + llvm.cond_br %2, ^bb2(%arg0 : i64), ^bb1 ^bb1: // pred: ^bb0 - %3 = "llvm.and"(%arg0, %0) : (i64, i64) -> i64 - "llvm.br"(%3)[^bb2] : (i64) -> () + %3 = llvm.and %arg0, %1 : i64 + llvm.br ^bb2(%3 : i64) ^bb2(%4: i64): // 2 preds: ^bb0, ^bb1 - %5 = "llvm.and"(%4, %0) : (i64, i64) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "limit_i64_ult_8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 8 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%1, %arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i64) -> () + %5 = llvm.and %4, %1 : i64 + llvm.return %5 : i64 + } + llvm.func @limit_i64_ugt_7(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.icmp "ugt" %arg0, %0 : i64 + llvm.cond_br %1, ^bb1, ^bb2(%arg0 : i64) ^bb1: // pred: ^bb0 - %2 = "llvm.and"(%arg0, %0) : (i64, i64) -> i64 - "llvm.br"(%2)[^bb2] : (i64) -> () + %2 = llvm.and %arg0, %0 : i64 + llvm.br ^bb2(%2 : i64) ^bb2(%3: i64): // 2 preds: ^bb0, ^bb1 - %4 = "llvm.and"(%3, %0) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "limit_i64_ugt_7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 15 : i64} : () -> i64 - %2 = "llvm.icmp"(%arg0, %1) {predicate = 7 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%2, %arg0)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i64) -> () + %4 = llvm.and %3, %0 : i64 + llvm.return %4 : i64 + } + llvm.func @limit_i64_ule_15_mask3(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(15 : i64) : i64 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.icmp "ule" %arg0, %0 : i64 + llvm.cond_br %2, ^bb2(%arg0 : i64), ^bb1 ^bb1: // pred: ^bb0 - %3 = "llvm.and"(%arg0, %1) : (i64, i64) -> i64 - "llvm.br"(%3)[^bb2] : (i64) -> () + %3 = llvm.and %arg0, %0 : i64 + llvm.br ^bb2(%3 : i64) ^bb2(%4: i64): // 2 preds: ^bb0, ^bb1 - %5 = "llvm.and"(%4, %0) : (i64, i64) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "limit_i64_ule_15_mask3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %3 = "llvm.icmp"(%arg0, %2) {predicate = 6 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%3, %arg0)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i64) -> () + %5 = llvm.and %4, %1 : i64 + llvm.return %5 : i64 + } + llvm.func @limit_i64_ult_8_mask1(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(7 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.icmp "ult" %arg0, %0 : i64 + llvm.cond_br %3, ^bb2(%arg0 : i64), ^bb1 ^bb1: // pred: ^bb0 - %4 = "llvm.and"(%arg0, %1) : (i64, i64) -> i64 - "llvm.br"(%4)[^bb2] : (i64) -> () + %4 = llvm.and %arg0, %1 : i64 + llvm.br ^bb2(%4 : i64) ^bb2(%5: i64): // 2 preds: ^bb0, ^bb1 - %6 = "llvm.and"(%5, %0) : (i64, i64) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "limit_i64_ult_8_mask1", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %6 = llvm.and %5, %2 : i64 + llvm.return %6 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/known-phi-recurse.ll.mlir b/test/LLVMDialect/InstCombine/known-phi-recurse.ll.mlir new file mode 100644 index 000000000..92c0e5e4a --- /dev/null +++ b/test/LLVMDialect/InstCombine/known-phi-recurse.ll.mlir @@ -0,0 +1,67 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @single_entry_phi(%arg0: i64, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(127 : i32) : i32 + %1 = llvm.intr.ctpop(%arg0) : (i64) -> i64 + %2 = llvm.trunc %1 : i64 to i32 + llvm.br ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb1 + llvm.cond_br %arg1, ^bb2(%2 : i32), ^bb1 + ^bb2(%3: i32): // pred: ^bb1 + %4 = llvm.and %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @two_entry_phi_with_constant(%arg0: i64, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.intr.ctpop(%arg0) : (i64) -> i64 + %2 = llvm.trunc %1 : i64 to i32 + llvm.cond_br %arg1, ^bb2(%2 : i32), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%0 : i32) + ^bb2(%3: i32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.and %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @two_entry_phi_non_constant(%arg0: i64, %arg1: i64, %arg2: i1) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.intr.ctpop(%arg0) : (i64) -> i64 + %2 = llvm.trunc %1 : i64 to i32 + llvm.cond_br %arg2, ^bb2(%2 : i32), ^bb1 + ^bb1: // pred: ^bb0 + %3 = llvm.intr.ctpop(%arg1) : (i64) -> i64 + %4 = llvm.trunc %3 : i64 to i32 + llvm.br ^bb2(%4 : i32) + ^bb2(%5: i32): // 2 preds: ^bb0, ^bb1 + %6 = llvm.and %5, %0 : i32 + llvm.return %6 : i32 + } + llvm.func @neg_many_branches(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(255 : i32) : i32 + %5 = llvm.intr.ctpop(%arg0) : (i64) -> i64 + %6 = llvm.trunc %5 : i64 to i32 + llvm.switch %6 : i32, ^bb5(%6 : i32) [ + 1: ^bb1, + 2: ^bb2, + 3: ^bb3, + 4: ^bb4 + ] + ^bb1: // pred: ^bb0 + %7 = llvm.add %6, %3 : i32 + llvm.br ^bb5(%7 : i32) + ^bb2: // pred: ^bb0 + %8 = llvm.add %6, %2 : i32 + llvm.br ^bb5(%8 : i32) + ^bb3: // pred: ^bb0 + %9 = llvm.add %6, %1 : i32 + llvm.br ^bb5(%9 : i32) + ^bb4: // pred: ^bb0 + %10 = llvm.add %6, %0 : i32 + llvm.br ^bb5(%10 : i32) + ^bb5(%11: i32): // 5 preds: ^bb0, ^bb1, ^bb2, ^bb3, ^bb4 + %12 = llvm.and %11, %4 : i32 + llvm.return %12 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/known-signbit-shift.ll.mlir b/test/LLVMDialect/InstCombine/known-signbit-shift.ll.mlir new file mode 100644 index 000000000..1fdd4cfb9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/known-signbit-shift.ll.mlir @@ -0,0 +1,37 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_shift_nonnegative(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.shl %3, %1 overflow : i32 + %5 = llvm.icmp "sge" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @test_shift_negative(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.or %arg0, %0 : i32 + %4 = llvm.and %arg1, %1 : i32 + %5 = llvm.shl %3, %4 overflow : i32 + %6 = llvm.icmp "slt" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @test_no_sign_bit_conflict1(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(8193 : i32) : i32 + %1 = llvm.mlir.constant(8192 : i32) : i32 + %2 = llvm.mlir.constant(18 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.shl %3, %2 overflow : i32 + llvm.return %4 : i32 + } + llvm.func @test_no_sign_bit_conflict2(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(-8193 : i32) : i32 + %1 = llvm.mlir.constant(-8194 : i32) : i32 + %2 = llvm.mlir.constant(18 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.shl %3, %2 overflow : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/known_align.ll.mlir b/test/LLVMDialect/InstCombine/known_align.ll.mlir new file mode 100644 index 000000000..58b915b95 --- /dev/null +++ b/test/LLVMDialect/InstCombine/known_align.ll.mlir @@ -0,0 +1,51 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @t() {addr_space = 0 : i32} : !llvm.struct<"struct.p", packed (i8, i32)> { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.undef : !llvm.struct<"struct.p", packed (i8, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.p", packed (i8, i32)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.p", packed (i8, i32)> + llvm.return %4 : !llvm.struct<"struct.p", packed (i8, i32)> + } + llvm.mlir.global weak @u() {addr_space = 0 : i32} : !llvm.struct<"struct.p", packed (i8, i32)> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.undef : !llvm.struct<"struct.p", packed (i8, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.p", packed (i8, i32)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.p", packed (i8, i32)> + llvm.return %4 : !llvm.struct<"struct.p", packed (i8, i32)> + } + llvm.func @main() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(10 : i32) : i32 + %3 = llvm.mlir.constant(1 : i8) : i8 + %4 = llvm.mlir.undef : !llvm.struct<"struct.p", packed (i8, i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.p", packed (i8, i32)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"struct.p", packed (i8, i32)> + %7 = llvm.mlir.addressof @t : !llvm.ptr + %8 = llvm.getelementptr inbounds %7[%1, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.p", packed (i8, i32)> + %9 = llvm.mlir.constant(0 : i8) : i8 + %10 = llvm.mlir.undef : !llvm.struct<"struct.p", packed (i8, i32)> + %11 = llvm.insertvalue %9, %10[0] : !llvm.struct<"struct.p", packed (i8, i32)> + %12 = llvm.insertvalue %1, %11[1] : !llvm.struct<"struct.p", packed (i8, i32)> + %13 = llvm.mlir.addressof @u : !llvm.ptr + %14 = llvm.getelementptr inbounds %13[%1, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.p", packed (i8, i32)> + %15 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %16 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %17 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %18 = llvm.bitcast %1 : i32 to i32 + %19 = llvm.load %8 {alignment = 1 : i64} : !llvm.ptr -> i32 + llvm.store %19, %17 {alignment = 4 : i64} : i32, !llvm.ptr + %20 = llvm.load %17 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %20, %14 {alignment = 1 : i64} : i32, !llvm.ptr + %21 = llvm.load %17 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %21, %16 {alignment = 4 : i64} : i32, !llvm.ptr + %22 = llvm.load %16 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %22, %15 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + %23 = llvm.load %15 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %23 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/ldexp-ext.ll.mlir b/test/LLVMDialect/InstCombine/ldexp-ext.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/ldexp.ll.mlir b/test/LLVMDialect/InstCombine/ldexp.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/lifetime-no-null-opt.ll.mlir b/test/LLVMDialect/InstCombine/lifetime-no-null-opt.ll.mlir new file mode 100644 index 000000000..baf32e1ad --- /dev/null +++ b/test/LLVMDialect/InstCombine/lifetime-no-null-opt.ll.mlir @@ -0,0 +1,47 @@ +#di_basic_type = #llvm.di_basic_type +#di_basic_type1 = #llvm.di_basic_type +#di_file = #llvm.di_file<"test.cpp" in "/home/user"> +#di_null_type = #llvm.di_null_type +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C_plus_plus, file = #di_file, producer = "clang version 3.8.0 (trunk 248826) (llvm/trunk 248827)", isOptimized = true, emissionKind = Full> +#di_composite_type = #llvm.di_composite_type> +#di_subroutine_type = #llvm.di_subroutine_type +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "bar", linkageName = "bar", file = #di_file, line = 2, scopeLine = 2, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#di_lexical_block = #llvm.di_lexical_block +#di_lexical_block1 = #llvm.di_lexical_block +#di_lexical_block2 = #llvm.di_lexical_block +#di_local_variable = #llvm.di_local_variable +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(!llvm.ptr {llvm.nocapture}, !llvm.ptr {llvm.nocapture}) + llvm.func @bar(%arg0: i1) attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.array<1 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.intr.dbg.declare #di_local_variable = %1 : !llvm.ptr + %2 = llvm.alloca %0 x !llvm.array<1 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb4 + ^bb1: // pred: ^bb0 + llvm.intr.lifetime.start 1, %1 : !llvm.ptr + llvm.intr.lifetime.start 1, %2 : !llvm.ptr + llvm.intr.lifetime.end 1, %2 : !llvm.ptr + llvm.intr.lifetime.end 1, %1 : !llvm.ptr + llvm.br ^bb2 + ^bb2: // pred: ^bb1 + llvm.intr.lifetime.start 1, %1 : !llvm.ptr + llvm.intr.lifetime.start 1, %2 : !llvm.ptr + llvm.intr.lifetime.end 1, %1 : !llvm.ptr + llvm.intr.lifetime.end 1, %2 : !llvm.ptr + llvm.br ^bb3 + ^bb3: // pred: ^bb2 + llvm.intr.lifetime.start 1, %1 : !llvm.ptr + llvm.intr.lifetime.end 1, %1 : !llvm.ptr + llvm.br ^bb5 + ^bb4: // pred: ^bb0 + llvm.intr.lifetime.start 1, %1 : !llvm.ptr + llvm.intr.lifetime.start 1, %2 : !llvm.ptr + llvm.call @foo(%2, %1) : (!llvm.ptr, !llvm.ptr) -> () + llvm.intr.lifetime.end 1, %2 : !llvm.ptr + llvm.intr.lifetime.end 1, %1 : !llvm.ptr + llvm.br ^bb5 + ^bb5: // 2 preds: ^bb3, ^bb4 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/lifetime-sanitizer.ll.mlir b/test/LLVMDialect/InstCombine/lifetime-sanitizer.ll.mlir index 1d0bd3055..cab9c7b10 100644 --- a/test/LLVMDialect/InstCombine/lifetime-sanitizer.ll.mlir +++ b/test/LLVMDialect/InstCombine/lifetime-sanitizer.ll.mlir @@ -1,45 +1,35 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.lifetime.start.p0i8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.lifetime.end.p0i8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - "llvm.call"(%0, %2) {callee = @llvm.lifetime.start.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.call"(%0, %2) {callee = @llvm.lifetime.end.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.call"(%2) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "asan", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - "llvm.call"(%0, %2) {callee = @llvm.lifetime.start.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.call"(%0, %2) {callee = @llvm.lifetime.end.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.call"(%2) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "hwasan", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - "llvm.call"(%0, %2) {callee = @llvm.lifetime.start.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.call"(%0, %2) {callee = @llvm.lifetime.end.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.call"(%2) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "msan", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - "llvm.call"(%0, %2) {callee = @llvm.lifetime.start.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.call"(%0, %2) {callee = @llvm.lifetime.end.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.call"(%2) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "no_asan", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(!llvm.ptr {llvm.nocapture}) + llvm.func @asan() attributes {passthrough = ["sanitize_address"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 1, %1 : !llvm.ptr + llvm.intr.lifetime.end 1, %1 : !llvm.ptr + llvm.call @foo(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @hwasan() attributes {passthrough = ["sanitize_hwaddress"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 1, %1 : !llvm.ptr + llvm.intr.lifetime.end 1, %1 : !llvm.ptr + llvm.call @foo(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @msan() attributes {passthrough = ["sanitize_memory"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 1, %1 : !llvm.ptr + llvm.intr.lifetime.end 1, %1 : !llvm.ptr + llvm.call @foo(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @no_asan() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 1, %1 : !llvm.ptr + llvm.intr.lifetime.end 1, %1 : !llvm.ptr + llvm.call @foo(%1) : (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/lifetime.ll.mlir b/test/LLVMDialect/InstCombine/lifetime.ll.mlir new file mode 100644 index 000000000..a286fe96b --- /dev/null +++ b/test/LLVMDialect/InstCombine/lifetime.ll.mlir @@ -0,0 +1,47 @@ +#di_basic_type = #llvm.di_basic_type +#di_basic_type1 = #llvm.di_basic_type +#di_file = #llvm.di_file<"test.cpp" in "/home/user"> +#di_null_type = #llvm.di_null_type +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C_plus_plus, file = #di_file, producer = "clang version 3.8.0 (trunk 248826) (llvm/trunk 248827)", isOptimized = true, emissionKind = Full> +#di_composite_type = #llvm.di_composite_type> +#di_subroutine_type = #llvm.di_subroutine_type +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "bar", linkageName = "bar", file = #di_file, line = 2, scopeLine = 2, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#di_lexical_block = #llvm.di_lexical_block +#di_lexical_block1 = #llvm.di_lexical_block +#di_lexical_block2 = #llvm.di_lexical_block +#di_local_variable = #llvm.di_local_variable +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(!llvm.ptr {llvm.nocapture}, !llvm.ptr {llvm.nocapture}) + llvm.func @bar(%arg0: i1) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.array<1 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.intr.dbg.declare #di_local_variable = %1 : !llvm.ptr + %2 = llvm.alloca %0 x !llvm.array<1 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb4 + ^bb1: // pred: ^bb0 + llvm.intr.lifetime.start 1, %1 : !llvm.ptr + llvm.intr.lifetime.start 1, %2 : !llvm.ptr + llvm.intr.lifetime.end 1, %2 : !llvm.ptr + llvm.intr.lifetime.end 1, %1 : !llvm.ptr + llvm.br ^bb2 + ^bb2: // pred: ^bb1 + llvm.intr.lifetime.start 1, %1 : !llvm.ptr + llvm.intr.lifetime.start 1, %2 : !llvm.ptr + llvm.intr.lifetime.end 1, %1 : !llvm.ptr + llvm.intr.lifetime.end 1, %2 : !llvm.ptr + llvm.br ^bb3 + ^bb3: // pred: ^bb2 + llvm.intr.lifetime.start 1, %1 : !llvm.ptr + llvm.intr.lifetime.end 1, %1 : !llvm.ptr + llvm.br ^bb5 + ^bb4: // pred: ^bb0 + llvm.intr.lifetime.start 1, %1 : !llvm.ptr + llvm.intr.lifetime.start 1, %2 : !llvm.ptr + llvm.call @foo(%2, %1) : (!llvm.ptr, !llvm.ptr) -> () + llvm.intr.lifetime.end 1, %2 : !llvm.ptr + llvm.intr.lifetime.end 1, %1 : !llvm.ptr + llvm.br ^bb5 + ^bb5: // 2 preds: ^bb3, ^bb4 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/load-bitcast-select.ll.mlir b/test/LLVMDialect/InstCombine/load-bitcast-select.ll.mlir new file mode 100644 index 000000000..30db30b7f --- /dev/null +++ b/test/LLVMDialect/InstCombine/load-bitcast-select.ll.mlir @@ -0,0 +1,52 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @a(dense<0.000000e+00> : tensor<1000xf32>) {addr_space = 0 : i32, alignment = 16 : i64} : !llvm.array<1000 x f32> + llvm.mlir.global external @b(dense<0.000000e+00> : tensor<1000xf32>) {addr_space = 0 : i32, alignment = 16 : i64} : !llvm.array<1000 x f32> + llvm.func @_Z3foov() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1000 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(dense<0.000000e+00> : tensor<1000xf32>) : !llvm.array<1000 x f32> + %4 = llvm.mlir.addressof @a : !llvm.ptr + %5 = llvm.mlir.constant(0 : i64) : i64 + %6 = llvm.mlir.addressof @b : !llvm.ptr + %7 = llvm.mlir.constant(1 : i32) : i32 + llvm.br ^bb1(%0 : i32) + ^bb1(%8: i32): // 2 preds: ^bb0, ^bb3 + %9 = llvm.icmp "ult" %8, %1 : i32 + llvm.cond_br %9, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return + ^bb3: // pred: ^bb1 + %10 = llvm.zext %8 : i32 to i64 + %11 = llvm.getelementptr inbounds %4[%5, %10] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<1000 x f32> + %12 = llvm.getelementptr inbounds %6[%5, %10] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<1000 x f32> + %13 = llvm.load %11 {alignment = 4 : i64} : !llvm.ptr -> f32 + %14 = llvm.load %12 {alignment = 4 : i64} : !llvm.ptr -> f32 + %15 = llvm.fcmp "olt" %13, %14 {fastmathFlags = #llvm.fastmath} : f32 + %16 = llvm.select %15, %12, %11 : i1, !llvm.ptr + %17 = llvm.load %16 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %17, %11 {alignment = 4 : i64} : i32, !llvm.ptr + %18 = llvm.add %8, %7 overflow : i32 + llvm.br ^bb1(%18 : i32) + } + llvm.func @store_bitcasted_load(%arg0: i1, %arg1: !llvm.ptr {llvm.dereferenceable = 4 : i64}, %arg2: !llvm.ptr {llvm.dereferenceable = 4 : i64}) -> i32 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, !llvm.ptr + %1 = llvm.load %0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %1 : i32 + } + llvm.func @bitcasted_store(%arg0: i1, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr) { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, !llvm.ptr + %1 = llvm.load %0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %1, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @bitcasted_minmax_with_select_of_pointers(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> f32 + %1 = llvm.load %arg1 {alignment = 4 : i64} : !llvm.ptr -> f32 + %2 = llvm.fcmp "ogt" %0, %1 : f32 + %3 = llvm.select %2, %arg0, %arg1 : i1, !llvm.ptr + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %4, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/load-bitcast-vec.ll.mlir b/test/LLVMDialect/InstCombine/load-bitcast-vec.ll.mlir index da46a935e..b5f8cc656 100644 --- a/test/LLVMDialect/InstCombine/load-bitcast-vec.ll.mlir +++ b/test/LLVMDialect/InstCombine/load-bitcast-vec.ll.mlir @@ -1,75 +1,50 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "matching_scalar", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "nonmatching_scalar", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> i64 - "llvm.return"(%1) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "larger_scalar", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> i8 - "llvm.return"(%1) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "smaller_scalar", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> i8 - "llvm.return"(%1) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "smaller_scalar_less_aligned", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "matching_scalar_small_deref", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "matching_scalar_smallest_deref", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "matching_scalar_smallest_deref_or_null", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, 4>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr, 4>) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "matching_scalar_smallest_deref_addrspace", type = !llvm.func, 4>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, 4>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr, 4>) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "matching_scalar_smallest_deref_or_null_addrspace", type = !llvm.func, 4>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "matching_scalar_volatile", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "nonvector", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @matching_scalar(%arg0: !llvm.ptr {llvm.dereferenceable = 16 : i64}) -> f32 { + %0 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> f32 + llvm.return %0 : f32 + } + llvm.func @nonmatching_scalar(%arg0: !llvm.ptr {llvm.dereferenceable = 16 : i64}) -> i32 { + %0 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> i32 + llvm.return %0 : i32 + } + llvm.func @larger_scalar(%arg0: !llvm.ptr {llvm.dereferenceable = 16 : i64}) -> i64 { + %0 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> i64 + llvm.return %0 : i64 + } + llvm.func @smaller_scalar(%arg0: !llvm.ptr {llvm.dereferenceable = 16 : i64}) -> i8 { + %0 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> i8 + llvm.return %0 : i8 + } + llvm.func @smaller_scalar_less_aligned(%arg0: !llvm.ptr {llvm.dereferenceable = 16 : i64}) -> i8 { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i8 + llvm.return %0 : i8 + } + llvm.func @matching_scalar_small_deref(%arg0: !llvm.ptr {llvm.dereferenceable = 15 : i64}) -> f32 { + %0 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> f32 + llvm.return %0 : f32 + } + llvm.func @matching_scalar_smallest_deref(%arg0: !llvm.ptr {llvm.dereferenceable = 1 : i64}) -> f32 { + %0 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> f32 + llvm.return %0 : f32 + } + llvm.func @matching_scalar_smallest_deref_or_null(%arg0: !llvm.ptr {llvm.dereferenceable_or_null = 1 : i64}) -> f32 { + %0 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> f32 + llvm.return %0 : f32 + } + llvm.func @matching_scalar_smallest_deref_addrspace(%arg0: !llvm.ptr<4> {llvm.dereferenceable = 1 : i64}) -> f32 { + %0 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr<4> -> f32 + llvm.return %0 : f32 + } + llvm.func @matching_scalar_smallest_deref_or_null_addrspace(%arg0: !llvm.ptr<4> {llvm.dereferenceable_or_null = 1 : i64}) -> f32 { + %0 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr<4> -> f32 + llvm.return %0 : f32 + } + llvm.func @matching_scalar_volatile(%arg0: !llvm.ptr {llvm.dereferenceable = 16 : i64}) -> f32 { + %0 = llvm.load volatile %arg0 {alignment = 16 : i64} : !llvm.ptr -> f32 + llvm.return %0 : f32 + } + llvm.func @nonvector(%arg0: !llvm.ptr {llvm.dereferenceable = 16 : i64}) -> f32 { + %0 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> f32 + llvm.return %0 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/load-bitcast32.ll.mlir b/test/LLVMDialect/InstCombine/load-bitcast32.ll.mlir index 9e833e4a3..66b9fbc36 100644 --- a/test/LLVMDialect/InstCombine/load-bitcast32.ll.mlir +++ b/test/LLVMDialect/InstCombine/load-bitcast32.ll.mlir @@ -1,45 +1,32 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> i64 - %2 = "llvm.inttoptr"(%1) : (i64) -> !llvm.ptr - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> i32 - %2 = "llvm.inttoptr"(%1) : (i32) -> !llvm.ptr - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> i32 - %2 = "llvm.inttoptr"(%1) : (i32) -> !llvm.ptr - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr> - %1 = "llvm.load"(%0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr> - %1 = "llvm.load"(%0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr> - %1 = "llvm.load"(%0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i64 + %1 = llvm.inttoptr %0 : i64 to !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test2(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.inttoptr %0 : i32 to !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test3(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.inttoptr %0 : i32 to !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test4(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i64 + llvm.return %1 : i64 + } + llvm.func @test5(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i32 + llvm.return %1 : i32 + } + llvm.func @test6(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i64 + llvm.return %1 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/load-bitcast64.ll.mlir b/test/LLVMDialect/InstCombine/load-bitcast64.ll.mlir index 9e833e4a3..f41bd95b9 100644 --- a/test/LLVMDialect/InstCombine/load-bitcast64.ll.mlir +++ b/test/LLVMDialect/InstCombine/load-bitcast64.ll.mlir @@ -1,45 +1,32 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> i64 - %2 = "llvm.inttoptr"(%1) : (i64) -> !llvm.ptr - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> i32 - %2 = "llvm.inttoptr"(%1) : (i32) -> !llvm.ptr - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> i32 - %2 = "llvm.inttoptr"(%1) : (i32) -> !llvm.ptr - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr> - %1 = "llvm.load"(%0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr> - %1 = "llvm.load"(%0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr> - %1 = "llvm.load"(%0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i64 + %1 = llvm.inttoptr %0 : i64 to !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test2(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.inttoptr %0 : i32 to !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test3(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.inttoptr %0 : i32 to !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test4(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i64 + llvm.return %1 : i64 + } + llvm.func @test5(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i32 + llvm.return %1 : i32 + } + llvm.func @test6(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i64 + llvm.return %1 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/load-cmp.ll.mlir b/test/LLVMDialect/InstCombine/load-cmp.ll.mlir new file mode 100644 index 000000000..345e0b3b4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/load-cmp.ll.mlir @@ -0,0 +1,621 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal constant @G16(dense<[35, 82, 69, 81, 85, 73, 82, 69, 68, 0]> : tensor<10xi16>) {addr_space = 0 : i32, dso_local} : !llvm.array<10 x i16> + llvm.mlir.global internal constant @G16_as1(dense<[35, 82, 69, 81, 85, 73, 82, 69, 68, 0]> : tensor<10xi16>) {addr_space = 1 : i32, dso_local} : !llvm.array<10 x i16> + llvm.mlir.global internal constant @G16_as2(dense<[35, 82, 69, 81, 85, 73, 82, 69, 68, 0]> : tensor<10xi16>) {addr_space = 2 : i32, dso_local} : !llvm.array<10 x i16> + llvm.mlir.global internal constant @GD(dense<[-1.000000e+01, 1.000000e+00, 4.000000e+00, 2.000000e+00, -2.000000e+01, -4.000000e+01]> : tensor<6xf64>) {addr_space = 0 : i32, dso_local} : !llvm.array<6 x f64> + llvm.mlir.global internal constant @GS() {addr_space = 0 : i32, dso_local} : !llvm.struct<"Foo", (i32, i32, i32, i32)> { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %8 = llvm.insertvalue %0, %7[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + llvm.return %8 : !llvm.struct<"Foo", (i32, i32, i32, i32)> + } + llvm.mlir.global internal constant @GStructArr() {addr_space = 0 : i32, dso_local} : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(12 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %8 = llvm.insertvalue %0, %7[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %9 = llvm.mlir.constant(20 : i32) : i32 + %10 = llvm.mlir.constant(5 : i32) : i32 + %11 = llvm.mlir.constant(6 : i32) : i32 + %12 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %13 = llvm.insertvalue %11, %12[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %14 = llvm.insertvalue %10, %13[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %15 = llvm.insertvalue %1, %14[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %16 = llvm.insertvalue %9, %15[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %17 = llvm.mlir.constant(11 : i32) : i32 + %18 = llvm.mlir.constant(4 : i32) : i32 + %19 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %20 = llvm.insertvalue %10, %19[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %21 = llvm.insertvalue %18, %20[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %22 = llvm.insertvalue %11, %21[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %23 = llvm.insertvalue %17, %22[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %24 = llvm.mlir.constant(14 : i32) : i32 + %25 = llvm.mlir.constant(1 : i32) : i32 + %26 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %27 = llvm.insertvalue %25, %26[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %28 = llvm.insertvalue %18, %27[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %29 = llvm.insertvalue %1, %28[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %30 = llvm.insertvalue %24, %29[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %31 = llvm.mlir.undef : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %32 = llvm.insertvalue %30, %31[0] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %33 = llvm.insertvalue %23, %32[1] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %34 = llvm.insertvalue %16, %33[2] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %35 = llvm.insertvalue %8, %34[3] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + llvm.return %35 : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + } + llvm.mlir.global internal constant @GA() {addr_space = 0 : i32, dso_local} : !llvm.array<4 x struct<(i32, i32)>> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<(i32, i32)> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.mlir.constant(3 : i32) : i32 + %7 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %8 = llvm.insertvalue %6, %7[0] : !llvm.struct<(i32, i32)> + %9 = llvm.insertvalue %5, %8[1] : !llvm.struct<(i32, i32)> + %10 = llvm.mlir.constant(2 : i32) : i32 + %11 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %12 = llvm.insertvalue %10, %11[0] : !llvm.struct<(i32, i32)> + %13 = llvm.insertvalue %5, %12[1] : !llvm.struct<(i32, i32)> + %14 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %15 = llvm.insertvalue %5, %14[0] : !llvm.struct<(i32, i32)> + %16 = llvm.insertvalue %0, %15[1] : !llvm.struct<(i32, i32)> + %17 = llvm.mlir.undef : !llvm.array<4 x struct<(i32, i32)>> + %18 = llvm.insertvalue %16, %17[0] : !llvm.array<4 x struct<(i32, i32)>> + %19 = llvm.insertvalue %13, %18[1] : !llvm.array<4 x struct<(i32, i32)>> + %20 = llvm.insertvalue %9, %19[2] : !llvm.array<4 x struct<(i32, i32)>> + %21 = llvm.insertvalue %4, %20[3] : !llvm.array<4 x struct<(i32, i32)>> + llvm.return %21 : !llvm.array<4 x struct<(i32, i32)>> + } + llvm.mlir.global internal constant @table() {addr_space = 0 : i32, alignment = 16 : i64, dso_local} : !llvm.array<2 x ptr> { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.addressof @g : !llvm.ptr + %2 = llvm.getelementptr %1[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.mlir.undef : !llvm.array<2 x ptr> + %4 = llvm.insertvalue %1, %3[0] : !llvm.array<2 x ptr> + %5 = llvm.insertvalue %2, %4[1] : !llvm.array<2 x ptr> + llvm.return %5 : !llvm.array<2 x ptr> + } + llvm.mlir.global external @g() {addr_space = 0 : i32} : !llvm.array<2 x i32> + llvm.func @test1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(dense<[35, 82, 69, 81, 85, 73, 82, 69, 68, 0]> : tensor<10xi16>) : !llvm.array<10 x i16> + %1 = llvm.mlir.addressof @G16 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<10 x i16> + %5 = llvm.load %4 {alignment = 2 : i64} : !llvm.ptr -> i16 + %6 = llvm.icmp "eq" %5, %3 : i16 + llvm.return %6 : i1 + } + llvm.func @test1_noinbounds(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(dense<[35, 82, 69, 81, 85, 73, 82, 69, 68, 0]> : tensor<10xi16>) : !llvm.array<10 x i16> + %1 = llvm.mlir.addressof @G16 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.getelementptr %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<10 x i16> + %5 = llvm.load %4 {alignment = 2 : i64} : !llvm.ptr -> i16 + %6 = llvm.icmp "eq" %5, %3 : i16 + llvm.return %6 : i1 + } + llvm.func @test1_noinbounds_i64(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(dense<[35, 82, 69, 81, 85, 73, 82, 69, 68, 0]> : tensor<10xi16>) : !llvm.array<10 x i16> + %1 = llvm.mlir.addressof @G16 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.getelementptr %1[%2, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<10 x i16> + %5 = llvm.load %4 {alignment = 2 : i64} : !llvm.ptr -> i16 + %6 = llvm.icmp "eq" %5, %3 : i16 + llvm.return %6 : i1 + } + llvm.func @test1_noinbounds_as1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(dense<[35, 82, 69, 81, 85, 73, 82, 69, 68, 0]> : tensor<10xi16>) : !llvm.array<10 x i16> + %1 = llvm.mlir.addressof @G16_as1 : !llvm.ptr<1> + %2 = llvm.mlir.constant(0 : i16) : i16 + %3 = llvm.getelementptr %1[%2, %arg0] : (!llvm.ptr<1>, i16, i32) -> !llvm.ptr<1>, !llvm.array<10 x i16> + %4 = llvm.load %3 {alignment = 2 : i64} : !llvm.ptr<1> -> i16 + %5 = llvm.icmp "eq" %4, %2 : i16 + llvm.return %5 : i1 + } + llvm.func @test1_noinbounds_as2(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(dense<[35, 82, 69, 81, 85, 73, 82, 69, 68, 0]> : tensor<10xi16>) : !llvm.array<10 x i16> + %1 = llvm.mlir.addressof @G16_as2 : !llvm.ptr<2> + %2 = llvm.mlir.constant(0 : i16) : i16 + %3 = llvm.getelementptr %1[%2, %arg0] : (!llvm.ptr<2>, i16, i64) -> !llvm.ptr<2>, !llvm.array<10 x i16> + %4 = llvm.load %3 {alignment = 2 : i64} : !llvm.ptr<2> -> i16 + %5 = llvm.icmp "eq" %4, %2 : i16 + llvm.return %5 : i1 + } + llvm.func @test2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(dense<[35, 82, 69, 81, 85, 73, 82, 69, 68, 0]> : tensor<10xi16>) : !llvm.array<10 x i16> + %1 = llvm.mlir.addressof @G16 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(85 : i16) : i16 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<10 x i16> + %5 = llvm.load %4 {alignment = 2 : i64} : !llvm.ptr -> i16 + %6 = llvm.icmp "slt" %5, %3 : i16 + llvm.return %6 : i1 + } + llvm.func @test3(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(dense<[-1.000000e+01, 1.000000e+00, 4.000000e+00, 2.000000e+00, -2.000000e+01, -4.000000e+01]> : tensor<6xf64>) : !llvm.array<6 x f64> + %1 = llvm.mlir.addressof @GD : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<6 x f64> + %5 = llvm.load %4 {alignment = 8 : i64} : !llvm.ptr -> f64 + %6 = llvm.fcmp "oeq" %5, %3 : f64 + llvm.return %6 : i1 + } + llvm.func @test4(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(dense<[35, 82, 69, 81, 85, 73, 82, 69, 68, 0]> : tensor<10xi16>) : !llvm.array<10 x i16> + %1 = llvm.mlir.addressof @G16 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(73 : i16) : i16 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<10 x i16> + %5 = llvm.load %4 {alignment = 2 : i64} : !llvm.ptr -> i16 + %6 = llvm.icmp "sle" %5, %3 : i16 + llvm.return %6 : i1 + } + llvm.func @test4_i16(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(dense<[35, 82, 69, 81, 85, 73, 82, 69, 68, 0]> : tensor<10xi16>) : !llvm.array<10 x i16> + %1 = llvm.mlir.addressof @G16 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(73 : i16) : i16 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i16) -> !llvm.ptr, !llvm.array<10 x i16> + %5 = llvm.load %4 {alignment = 2 : i64} : !llvm.ptr -> i16 + %6 = llvm.icmp "sle" %5, %3 : i16 + llvm.return %6 : i1 + } + llvm.func @test5(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(dense<[35, 82, 69, 81, 85, 73, 82, 69, 68, 0]> : tensor<10xi16>) : !llvm.array<10 x i16> + %1 = llvm.mlir.addressof @G16 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(69 : i16) : i16 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<10 x i16> + %5 = llvm.load %4 {alignment = 2 : i64} : !llvm.ptr -> i16 + %6 = llvm.icmp "eq" %5, %3 : i16 + llvm.return %6 : i1 + } + llvm.func @test6(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(dense<[-1.000000e+01, 1.000000e+00, 4.000000e+00, 2.000000e+00, -2.000000e+01, -4.000000e+01]> : tensor<6xf64>) : !llvm.array<6 x f64> + %1 = llvm.mlir.addressof @GD : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<6 x f64> + %5 = llvm.load %4 {alignment = 8 : i64} : !llvm.ptr -> f64 + %6 = llvm.fcmp "ogt" %5, %3 : f64 + llvm.return %6 : i1 + } + llvm.func @test7(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(dense<[-1.000000e+01, 1.000000e+00, 4.000000e+00, 2.000000e+00, -2.000000e+01, -4.000000e+01]> : tensor<6xf64>) : !llvm.array<6 x f64> + %1 = llvm.mlir.addressof @GD : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<6 x f64> + %5 = llvm.load %4 {alignment = 8 : i64} : !llvm.ptr -> f64 + %6 = llvm.fcmp "olt" %5, %3 : f64 + llvm.return %6 : i1 + } + llvm.func @test8(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(dense<[35, 82, 69, 81, 85, 73, 82, 69, 68, 0]> : tensor<10xi16>) : !llvm.array<10 x i16> + %1 = llvm.mlir.addressof @G16 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(3 : i16) : i16 + %4 = llvm.mlir.constant(0 : i16) : i16 + %5 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<10 x i16> + %6 = llvm.load %5 {alignment = 2 : i64} : !llvm.ptr -> i16 + %7 = llvm.and %6, %3 : i16 + %8 = llvm.icmp "eq" %7, %4 : i16 + llvm.return %8 : i1 + } + llvm.func @test9(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<(i32, i32)> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.mlir.constant(3 : i32) : i32 + %7 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %8 = llvm.insertvalue %6, %7[0] : !llvm.struct<(i32, i32)> + %9 = llvm.insertvalue %5, %8[1] : !llvm.struct<(i32, i32)> + %10 = llvm.mlir.constant(2 : i32) : i32 + %11 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %12 = llvm.insertvalue %10, %11[0] : !llvm.struct<(i32, i32)> + %13 = llvm.insertvalue %5, %12[1] : !llvm.struct<(i32, i32)> + %14 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %15 = llvm.insertvalue %5, %14[0] : !llvm.struct<(i32, i32)> + %16 = llvm.insertvalue %0, %15[1] : !llvm.struct<(i32, i32)> + %17 = llvm.mlir.undef : !llvm.array<4 x struct<(i32, i32)>> + %18 = llvm.insertvalue %16, %17[0] : !llvm.array<4 x struct<(i32, i32)>> + %19 = llvm.insertvalue %13, %18[1] : !llvm.array<4 x struct<(i32, i32)>> + %20 = llvm.insertvalue %9, %19[2] : !llvm.array<4 x struct<(i32, i32)>> + %21 = llvm.insertvalue %4, %20[3] : !llvm.array<4 x struct<(i32, i32)>> + %22 = llvm.mlir.addressof @GA : !llvm.ptr + %23 = llvm.getelementptr inbounds %22[%0, %arg0, 1] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<4 x struct<(i32, i32)>> + %24 = llvm.load %23 {alignment = 4 : i64} : !llvm.ptr -> i32 + %25 = llvm.icmp "eq" %24, %5 : i32 + llvm.return %25 : i1 + } + llvm.func @test10_struct(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %8 = llvm.insertvalue %0, %7[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %9 = llvm.mlir.addressof @GS : !llvm.ptr + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.getelementptr inbounds %9[%arg0, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"Foo", (i32, i32, i32, i32)> + %12 = llvm.load %11 {alignment = 4 : i64} : !llvm.ptr -> i32 + %13 = llvm.icmp "eq" %12, %1 : i32 + llvm.return %13 : i1 + } + llvm.func @test10_struct_noinbounds(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %8 = llvm.insertvalue %0, %7[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %9 = llvm.mlir.addressof @GS : !llvm.ptr + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.getelementptr %9[%arg0, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"Foo", (i32, i32, i32, i32)> + %12 = llvm.load %11 {alignment = 4 : i64} : !llvm.ptr -> i32 + %13 = llvm.icmp "eq" %12, %1 : i32 + llvm.return %13 : i1 + } + llvm.func @test10_struct_i16(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %8 = llvm.insertvalue %0, %7[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %9 = llvm.mlir.addressof @GS : !llvm.ptr + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.getelementptr inbounds %9[%arg0, 0] : (!llvm.ptr, i16) -> !llvm.ptr, !llvm.struct<"Foo", (i32, i32, i32, i32)> + %12 = llvm.load %11 {alignment = 4 : i64} : !llvm.ptr -> i32 + %13 = llvm.icmp "eq" %12, %10 : i32 + llvm.return %13 : i1 + } + llvm.func @test10_struct_i64(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %8 = llvm.insertvalue %0, %7[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %9 = llvm.mlir.addressof @GS : !llvm.ptr + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.getelementptr inbounds %9[%arg0, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"Foo", (i32, i32, i32, i32)> + %12 = llvm.load %11 {alignment = 4 : i64} : !llvm.ptr -> i32 + %13 = llvm.icmp "eq" %12, %10 : i32 + llvm.return %13 : i1 + } + llvm.func @test10_struct_noinbounds_i16(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %8 = llvm.insertvalue %0, %7[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %9 = llvm.mlir.addressof @GS : !llvm.ptr + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.getelementptr %9[%arg0, 0] : (!llvm.ptr, i16) -> !llvm.ptr, !llvm.struct<"Foo", (i32, i32, i32, i32)> + %12 = llvm.load %11 {alignment = 4 : i64} : !llvm.ptr -> i32 + %13 = llvm.icmp "eq" %12, %10 : i32 + llvm.return %13 : i1 + } + llvm.func @test10_struct_arr(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(12 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %8 = llvm.insertvalue %0, %7[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %9 = llvm.mlir.constant(20 : i32) : i32 + %10 = llvm.mlir.constant(5 : i32) : i32 + %11 = llvm.mlir.constant(6 : i32) : i32 + %12 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %13 = llvm.insertvalue %11, %12[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %14 = llvm.insertvalue %10, %13[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %15 = llvm.insertvalue %1, %14[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %16 = llvm.insertvalue %9, %15[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %17 = llvm.mlir.constant(11 : i32) : i32 + %18 = llvm.mlir.constant(4 : i32) : i32 + %19 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %20 = llvm.insertvalue %10, %19[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %21 = llvm.insertvalue %18, %20[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %22 = llvm.insertvalue %11, %21[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %23 = llvm.insertvalue %17, %22[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %24 = llvm.mlir.constant(14 : i32) : i32 + %25 = llvm.mlir.constant(1 : i32) : i32 + %26 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %27 = llvm.insertvalue %25, %26[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %28 = llvm.insertvalue %18, %27[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %29 = llvm.insertvalue %1, %28[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %30 = llvm.insertvalue %24, %29[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %31 = llvm.mlir.undef : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %32 = llvm.insertvalue %30, %31[0] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %33 = llvm.insertvalue %23, %32[1] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %34 = llvm.insertvalue %16, %33[2] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %35 = llvm.insertvalue %8, %34[3] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %36 = llvm.mlir.addressof @GStructArr : !llvm.ptr + %37 = llvm.mlir.constant(0 : i32) : i32 + %38 = llvm.mlir.constant(2 : i32) : i32 + %39 = llvm.getelementptr inbounds %36[%37, %arg0, 2] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %40 = llvm.load %39 {alignment = 4 : i64} : !llvm.ptr -> i32 + %41 = llvm.icmp "eq" %40, %1 : i32 + llvm.return %41 : i1 + } + llvm.func @test10_struct_arr_noinbounds(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(12 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %8 = llvm.insertvalue %0, %7[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %9 = llvm.mlir.constant(20 : i32) : i32 + %10 = llvm.mlir.constant(5 : i32) : i32 + %11 = llvm.mlir.constant(6 : i32) : i32 + %12 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %13 = llvm.insertvalue %11, %12[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %14 = llvm.insertvalue %10, %13[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %15 = llvm.insertvalue %1, %14[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %16 = llvm.insertvalue %9, %15[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %17 = llvm.mlir.constant(11 : i32) : i32 + %18 = llvm.mlir.constant(4 : i32) : i32 + %19 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %20 = llvm.insertvalue %10, %19[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %21 = llvm.insertvalue %18, %20[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %22 = llvm.insertvalue %11, %21[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %23 = llvm.insertvalue %17, %22[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %24 = llvm.mlir.constant(14 : i32) : i32 + %25 = llvm.mlir.constant(1 : i32) : i32 + %26 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %27 = llvm.insertvalue %25, %26[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %28 = llvm.insertvalue %18, %27[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %29 = llvm.insertvalue %1, %28[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %30 = llvm.insertvalue %24, %29[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %31 = llvm.mlir.undef : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %32 = llvm.insertvalue %30, %31[0] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %33 = llvm.insertvalue %23, %32[1] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %34 = llvm.insertvalue %16, %33[2] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %35 = llvm.insertvalue %8, %34[3] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %36 = llvm.mlir.addressof @GStructArr : !llvm.ptr + %37 = llvm.mlir.constant(0 : i32) : i32 + %38 = llvm.mlir.constant(2 : i32) : i32 + %39 = llvm.getelementptr %36[%37, %arg0, 2] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %40 = llvm.load %39 {alignment = 4 : i64} : !llvm.ptr -> i32 + %41 = llvm.icmp "eq" %40, %1 : i32 + llvm.return %41 : i1 + } + llvm.func @test10_struct_arr_i16(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(12 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %8 = llvm.insertvalue %0, %7[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %9 = llvm.mlir.constant(20 : i32) : i32 + %10 = llvm.mlir.constant(5 : i32) : i32 + %11 = llvm.mlir.constant(6 : i32) : i32 + %12 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %13 = llvm.insertvalue %11, %12[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %14 = llvm.insertvalue %10, %13[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %15 = llvm.insertvalue %1, %14[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %16 = llvm.insertvalue %9, %15[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %17 = llvm.mlir.constant(11 : i32) : i32 + %18 = llvm.mlir.constant(4 : i32) : i32 + %19 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %20 = llvm.insertvalue %10, %19[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %21 = llvm.insertvalue %18, %20[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %22 = llvm.insertvalue %11, %21[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %23 = llvm.insertvalue %17, %22[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %24 = llvm.mlir.constant(14 : i32) : i32 + %25 = llvm.mlir.constant(1 : i32) : i32 + %26 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %27 = llvm.insertvalue %25, %26[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %28 = llvm.insertvalue %18, %27[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %29 = llvm.insertvalue %1, %28[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %30 = llvm.insertvalue %24, %29[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %31 = llvm.mlir.undef : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %32 = llvm.insertvalue %30, %31[0] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %33 = llvm.insertvalue %23, %32[1] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %34 = llvm.insertvalue %16, %33[2] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %35 = llvm.insertvalue %8, %34[3] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %36 = llvm.mlir.addressof @GStructArr : !llvm.ptr + %37 = llvm.mlir.constant(0 : i16) : i16 + %38 = llvm.mlir.constant(2 : i32) : i32 + %39 = llvm.getelementptr inbounds %36[%37, %arg0, 2] : (!llvm.ptr, i16, i16) -> !llvm.ptr, !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %40 = llvm.load %39 {alignment = 4 : i64} : !llvm.ptr -> i32 + %41 = llvm.icmp "eq" %40, %1 : i32 + llvm.return %41 : i1 + } + llvm.func @test10_struct_arr_i64(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(12 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %8 = llvm.insertvalue %0, %7[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %9 = llvm.mlir.constant(20 : i32) : i32 + %10 = llvm.mlir.constant(5 : i32) : i32 + %11 = llvm.mlir.constant(6 : i32) : i32 + %12 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %13 = llvm.insertvalue %11, %12[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %14 = llvm.insertvalue %10, %13[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %15 = llvm.insertvalue %1, %14[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %16 = llvm.insertvalue %9, %15[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %17 = llvm.mlir.constant(11 : i32) : i32 + %18 = llvm.mlir.constant(4 : i32) : i32 + %19 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %20 = llvm.insertvalue %10, %19[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %21 = llvm.insertvalue %18, %20[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %22 = llvm.insertvalue %11, %21[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %23 = llvm.insertvalue %17, %22[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %24 = llvm.mlir.constant(14 : i32) : i32 + %25 = llvm.mlir.constant(1 : i32) : i32 + %26 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %27 = llvm.insertvalue %25, %26[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %28 = llvm.insertvalue %18, %27[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %29 = llvm.insertvalue %1, %28[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %30 = llvm.insertvalue %24, %29[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %31 = llvm.mlir.undef : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %32 = llvm.insertvalue %30, %31[0] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %33 = llvm.insertvalue %23, %32[1] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %34 = llvm.insertvalue %16, %33[2] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %35 = llvm.insertvalue %8, %34[3] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %36 = llvm.mlir.addressof @GStructArr : !llvm.ptr + %37 = llvm.mlir.constant(0 : i64) : i64 + %38 = llvm.mlir.constant(2 : i32) : i32 + %39 = llvm.getelementptr inbounds %36[%37, %arg0, 2] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %40 = llvm.load %39 {alignment = 4 : i64} : !llvm.ptr -> i32 + %41 = llvm.icmp "eq" %40, %1 : i32 + llvm.return %41 : i1 + } + llvm.func @test10_struct_arr_noinbounds_i16(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(12 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %8 = llvm.insertvalue %0, %7[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %9 = llvm.mlir.constant(20 : i32) : i32 + %10 = llvm.mlir.constant(5 : i32) : i32 + %11 = llvm.mlir.constant(6 : i32) : i32 + %12 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %13 = llvm.insertvalue %11, %12[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %14 = llvm.insertvalue %10, %13[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %15 = llvm.insertvalue %1, %14[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %16 = llvm.insertvalue %9, %15[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %17 = llvm.mlir.constant(11 : i32) : i32 + %18 = llvm.mlir.constant(4 : i32) : i32 + %19 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %20 = llvm.insertvalue %10, %19[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %21 = llvm.insertvalue %18, %20[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %22 = llvm.insertvalue %11, %21[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %23 = llvm.insertvalue %17, %22[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %24 = llvm.mlir.constant(14 : i32) : i32 + %25 = llvm.mlir.constant(1 : i32) : i32 + %26 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %27 = llvm.insertvalue %25, %26[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %28 = llvm.insertvalue %18, %27[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %29 = llvm.insertvalue %1, %28[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %30 = llvm.insertvalue %24, %29[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %31 = llvm.mlir.undef : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %32 = llvm.insertvalue %30, %31[0] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %33 = llvm.insertvalue %23, %32[1] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %34 = llvm.insertvalue %16, %33[2] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %35 = llvm.insertvalue %8, %34[3] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %36 = llvm.mlir.addressof @GStructArr : !llvm.ptr + %37 = llvm.mlir.constant(0 : i32) : i32 + %38 = llvm.mlir.constant(2 : i32) : i32 + %39 = llvm.getelementptr %36[%37, %arg0, 2] : (!llvm.ptr, i32, i16) -> !llvm.ptr, !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %40 = llvm.load %39 {alignment = 4 : i64} : !llvm.ptr -> i32 + %41 = llvm.icmp "eq" %40, %1 : i32 + llvm.return %41 : i1 + } + llvm.func @test10_struct_arr_noinbounds_i64(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(12 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %8 = llvm.insertvalue %0, %7[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %9 = llvm.mlir.constant(20 : i32) : i32 + %10 = llvm.mlir.constant(5 : i32) : i32 + %11 = llvm.mlir.constant(6 : i32) : i32 + %12 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %13 = llvm.insertvalue %11, %12[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %14 = llvm.insertvalue %10, %13[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %15 = llvm.insertvalue %1, %14[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %16 = llvm.insertvalue %9, %15[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %17 = llvm.mlir.constant(11 : i32) : i32 + %18 = llvm.mlir.constant(4 : i32) : i32 + %19 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %20 = llvm.insertvalue %10, %19[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %21 = llvm.insertvalue %18, %20[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %22 = llvm.insertvalue %11, %21[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %23 = llvm.insertvalue %17, %22[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %24 = llvm.mlir.constant(14 : i32) : i32 + %25 = llvm.mlir.constant(1 : i32) : i32 + %26 = llvm.mlir.undef : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %27 = llvm.insertvalue %25, %26[0] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %28 = llvm.insertvalue %18, %27[1] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %29 = llvm.insertvalue %1, %28[2] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %30 = llvm.insertvalue %24, %29[3] : !llvm.struct<"Foo", (i32, i32, i32, i32)> + %31 = llvm.mlir.undef : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %32 = llvm.insertvalue %30, %31[0] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %33 = llvm.insertvalue %23, %32[1] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %34 = llvm.insertvalue %16, %33[2] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %35 = llvm.insertvalue %8, %34[3] : !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %36 = llvm.mlir.addressof @GStructArr : !llvm.ptr + %37 = llvm.mlir.constant(0 : i32) : i32 + %38 = llvm.mlir.constant(2 : i32) : i32 + %39 = llvm.getelementptr %36[%37, %arg0, 2] : (!llvm.ptr, i32, i64) -> !llvm.ptr, !llvm.array<4 x struct<"Foo", (i32, i32, i32, i32)>> + %40 = llvm.load %39 {alignment = 4 : i64} : !llvm.ptr -> i32 + %41 = llvm.icmp "eq" %40, %1 : i32 + llvm.return %41 : i1 + } + llvm.func @pr93017(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.addressof @g : !llvm.ptr + %2 = llvm.getelementptr %1[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.mlir.undef : !llvm.array<2 x ptr> + %4 = llvm.insertvalue %1, %3[0] : !llvm.array<2 x ptr> + %5 = llvm.insertvalue %2, %4[1] : !llvm.array<2 x ptr> + %6 = llvm.mlir.addressof @table : !llvm.ptr + %7 = llvm.mlir.constant(0 : i64) : i64 + %8 = llvm.mlir.zero : !llvm.ptr + %9 = llvm.getelementptr inbounds %6[%7, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<2 x ptr> + %10 = llvm.load %9 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %11 = llvm.icmp "ne" %10, %8 : !llvm.ptr + llvm.return %11 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/load-combine-metadata-2.ll.mlir b/test/LLVMDialect/InstCombine/load-combine-metadata-2.ll.mlir index 333ec94b2..029eb3022 100644 --- a/test/LLVMDialect/InstCombine/load-combine-metadata-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/load-combine-metadata-2.ll.mlir @@ -1,12 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>, %arg2: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - "llvm.store"(%0, %1) : (i32, !llvm.ptr) -> () - "llvm.store"(%0, %2) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_load_load_combine_metadata", type = !llvm.func>, ptr>, ptr>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @test_load_load_combine_metadata(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %2 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/load-combine-metadata-3.ll.mlir b/test/LLVMDialect/InstCombine/load-combine-metadata-3.ll.mlir index 333ec94b2..a8faf0c5d 100644 --- a/test/LLVMDialect/InstCombine/load-combine-metadata-3.ll.mlir +++ b/test/LLVMDialect/InstCombine/load-combine-metadata-3.ll.mlir @@ -1,12 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>, %arg2: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - "llvm.store"(%0, %1) : (i32, !llvm.ptr) -> () - "llvm.store"(%0, %2) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_load_load_combine_metadata", type = !llvm.func>, ptr>, ptr>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_load_load_combine_metadata(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %2 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/load-combine-metadata-4.ll.mlir b/test/LLVMDialect/InstCombine/load-combine-metadata-4.ll.mlir index 333ec94b2..c8c93e19c 100644 --- a/test/LLVMDialect/InstCombine/load-combine-metadata-4.ll.mlir +++ b/test/LLVMDialect/InstCombine/load-combine-metadata-4.ll.mlir @@ -1,12 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>, %arg2: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - "llvm.store"(%0, %1) : (i32, !llvm.ptr) -> () - "llvm.store"(%0, %2) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_load_load_combine_metadata", type = !llvm.func>, ptr>, ptr>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_load_load_combine_metadata(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %2 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/load-combine-metadata-dominance.ll.mlir b/test/LLVMDialect/InstCombine/load-combine-metadata-dominance.ll.mlir index 494bb0b42..0b4397661 100644 --- a/test/LLVMDialect/InstCombine/load-combine-metadata-dominance.ll.mlir +++ b/test/LLVMDialect/InstCombine/load-combine-metadata-dominance.ll.mlir @@ -1,29 +1,65 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"()[^bb1] : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @combine_metadata_dominance1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb1 ^bb1: // pred: ^bb0 - %2 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - "llvm.store"(%0, %1) : (i32, !llvm.ptr) -> () - "llvm.store"(%0, %2) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "combine_metadata_dominance1", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - "llvm.cond_br"(%arg1)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %2 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @use(!llvm.ptr, i32) -> i32 attributes {memory = #llvm.memory_effects} + llvm.func @combine_metadata_dominance2(%arg0: !llvm.ptr, %arg1: i1) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.cond_br %arg1, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %2 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - "llvm.store"(%0, %1) : (i32, !llvm.ptr) -> () - "llvm.store"(%0, %2) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () + %2 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return ^bb2: // pred: ^bb0 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "combine_metadata_dominance2", type = !llvm.func>, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } + llvm.func @combine_metadata_dominance3(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + %2 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @combine_metadata_dominance4(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + %2 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @combine_metadata_dominance5(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + %2 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @combine_metadata_dominance6(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + %2 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/load-combine-metadata.ll.mlir b/test/LLVMDialect/InstCombine/load-combine-metadata.ll.mlir index 5a0e88883..87222d477 100644 --- a/test/LLVMDialect/InstCombine/load-combine-metadata.ll.mlir +++ b/test/LLVMDialect/InstCombine/load-combine-metadata.ll.mlir @@ -1,11 +1,15 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - "llvm.store"(%0, %arg1) : (i32, !llvm.ptr) -> () - "llvm.store"(%1, %arg2) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_load_load_combine_metadata", type = !llvm.func, ptr, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +#alias_scope_domain = #llvm.alias_scope_domain> +#tbaa_root = #llvm.tbaa_root +#alias_scope = #llvm.alias_scope, domain = #alias_scope_domain> +#alias_scope1 = #llvm.alias_scope, domain = #alias_scope_domain> +#tbaa_type_desc = #llvm.tbaa_type_desc}> +#tbaa_tag = #llvm.tbaa_tag +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @test_load_load_combine_metadata(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.load %arg0 {alias_scopes = [#alias_scope], alignment = 4 : i64, noalias_scopes = [#alias_scope1], tbaa = [#tbaa_tag]} : !llvm.ptr -> i32 + %1 = llvm.load %arg0 {alignment = 4 : i64, tbaa = [#tbaa_tag]} : !llvm.ptr -> i32 + llvm.store %0, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %1, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/load-gep-overalign.ll.mlir b/test/LLVMDialect/InstCombine/load-gep-overalign.ll.mlir new file mode 100644 index 000000000..9206744cc --- /dev/null +++ b/test/LLVMDialect/InstCombine/load-gep-overalign.ll.mlir @@ -0,0 +1,41 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @foo(dense<[8961, 26437, -21623, -4147]> : vector<4xi16>) {addr_space = 0 : i32, alignment = 8 : i64} : vector<4xi16> + llvm.func @report(i64, i8) + llvm.func @test_vector_load_i8() { + %0 = llvm.mlir.constant(dense<[8961, 26437, -21623, -4147]> : vector<4xi16>) : vector<4xi16> + %1 = llvm.mlir.addressof @foo : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(2 : i64) : i64 + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.constant(4 : i64) : i64 + %7 = llvm.mlir.constant(5 : i64) : i64 + %8 = llvm.mlir.constant(6 : i64) : i64 + %9 = llvm.mlir.constant(7 : i64) : i64 + %10 = llvm.getelementptr %1[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %11 = llvm.load %10 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.call @report(%2, %11) : (i64, i8) -> () + %12 = llvm.getelementptr %1[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %13 = llvm.load %12 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.call @report(%3, %13) : (i64, i8) -> () + %14 = llvm.getelementptr %1[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %15 = llvm.load %14 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.call @report(%4, %15) : (i64, i8) -> () + %16 = llvm.getelementptr %1[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %17 = llvm.load %16 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.call @report(%5, %17) : (i64, i8) -> () + %18 = llvm.getelementptr %1[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %19 = llvm.load %18 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.call @report(%6, %19) : (i64, i8) -> () + %20 = llvm.getelementptr %1[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %21 = llvm.load %20 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.call @report(%7, %21) : (i64, i8) -> () + %22 = llvm.getelementptr %1[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %23 = llvm.load %22 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.call @report(%8, %23) : (i64, i8) -> () + %24 = llvm.getelementptr %1[%9] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %25 = llvm.load %24 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.call @report(%9, %25) : (i64, i8) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/load-no-aliasing.ll.mlir b/test/LLVMDialect/InstCombine/load-no-aliasing.ll.mlir index c4ee57da6..b382fa69f 100644 --- a/test/LLVMDialect/InstCombine/load-no-aliasing.ll.mlir +++ b/test/LLVMDialect/InstCombine/load-no-aliasing.ll.mlir @@ -1,11 +1,15 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %1 = "llvm.sitofp"(%0) : (i32) -> f32 - "llvm.store"(%1, %arg1) : (f32, !llvm.ptr) -> () - %2 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_load_store_load_combine", type = !llvm.func, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +#tbaa_root = #llvm.tbaa_root +#tbaa_type_desc = #llvm.tbaa_type_desc}> +#tbaa_type_desc1 = #llvm.tbaa_type_desc}> +#tbaa_type_desc2 = #llvm.tbaa_type_desc}> +#tbaa_tag = #llvm.tbaa_tag +#tbaa_tag1 = #llvm.tbaa_tag +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_load_store_load_combine(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 {alignment = 4 : i64, tbaa = [#tbaa_tag]} : !llvm.ptr -> i32 + %1 = llvm.sitofp %0 : i32 to f32 + llvm.store %1, %arg1 {alignment = 4 : i64, tbaa = [#tbaa_tag1]} : f32, !llvm.ptr + %2 = llvm.load %arg0 {alignment = 4 : i64, tbaa = [#tbaa_tag]} : !llvm.ptr -> i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/load-select.ll.mlir b/test/LLVMDialect/InstCombine/load-select.ll.mlir new file mode 100644 index 000000000..982d796ac --- /dev/null +++ b/test/LLVMDialect/InstCombine/load-select.ll.mlir @@ -0,0 +1,14 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a(dense<[3, 6]> : tensor<2xi32>) {addr_space = 0 : i32} : !llvm.array<2 x i32> + llvm.func @b(%arg0: i32) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(dense<[3, 6]> : tensor<2xi32>) : !llvm.array<2 x i32> + %3 = llvm.mlir.addressof @a : !llvm.ptr + %4 = llvm.getelementptr inbounds %3[%0, %1] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<2 x i32> + %5 = llvm.icmp "eq" %arg0, %0 : i32 + %6 = llvm.select %5, %4, %3 : i1, !llvm.ptr + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/load-store-forward.ll.mlir b/test/LLVMDialect/InstCombine/load-store-forward.ll.mlir new file mode 100644 index 000000000..c9c689277 --- /dev/null +++ b/test/LLVMDialect/InstCombine/load-store-forward.ll.mlir @@ -0,0 +1,316 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @load_smaller_int(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(258 : i16) : i16 + llvm.store %0, %arg0 {alignment = 2 : i64} : i16, !llvm.ptr + %1 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %1 : i8 + } + llvm.func @load_larger_int(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(258 : i16) : i16 + llvm.store %0, %arg0 {alignment = 2 : i64} : i16, !llvm.ptr + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %1 : i32 + } + llvm.func @vec_store_load_first(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi32>) : vector<2xi32> + llvm.store %0, %arg0 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %1 : i32 + } + llvm.func @vec_store_load_first_odd_size(%arg0: !llvm.ptr) -> i17 { + %0 = llvm.mlir.constant(2 : i17) : i17 + %1 = llvm.mlir.constant(1 : i17) : i17 + %2 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi17>) : vector<2xi17> + llvm.store %2, %arg0 {alignment = 8 : i64} : vector<2xi17>, !llvm.ptr + %3 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i17 + llvm.return %3 : i17 + } + llvm.func @vec_store_load_first_constexpr(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.addressof @vec_store_load_first : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %2 = llvm.bitcast %1 : i64 to vector<2xi32> + llvm.store %2, %arg0 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + %3 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %3 : i32 + } + llvm.func @vec_store_load_second(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(1 : i64) : i64 + llvm.store %0, %arg0 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + %2 = llvm.getelementptr %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %3 : i32 + } + llvm.func @vec_store_load_whole(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi32>) : vector<2xi32> + llvm.store %0, %arg0 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i64 + llvm.return %1 : i64 + } + llvm.func @vec_store_load_overlap(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(2 : i64) : i64 + llvm.store %0, %arg0 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + %2 = llvm.getelementptr %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.load %2 {alignment = 2 : i64} : !llvm.ptr -> i32 + llvm.return %3 : i32 + } + llvm.func @load_i32_store_nxv4i32(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %2, %0[%1 : i64] : !llvm.vec + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : !llvm.vec + llvm.store %4, %arg0 {alignment = 16 : i64} : vector<[4]xi32>, !llvm.ptr + %5 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %5 : i32 + } + llvm.func @load_i64_store_nxv8i8(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.insertelement %2, %0[%1 : i64] : !llvm.vec + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0, 0, 0, 0, 0] : !llvm.vec + llvm.store %4, %arg0 {alignment = 16 : i64} : vector<[8]xi8>, !llvm.ptr + %5 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + llvm.return %5 : i64 + } + llvm.func @load_i64_store_nxv4i32(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %2, %0[%1 : i64] : !llvm.vec + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : !llvm.vec + llvm.store %4, %arg0 {alignment = 16 : i64} : vector<[4]xi32>, !llvm.ptr + %5 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + llvm.return %5 : i64 + } + llvm.func @load_i8_store_nxv4i32(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %2, %0[%1 : i64] : !llvm.vec + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : !llvm.vec + llvm.store %4, %arg0 {alignment = 16 : i64} : vector<[4]xi32>, !llvm.ptr + %5 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %5 : i8 + } + llvm.func @load_f32_store_nxv4f32(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.insertelement %2, %0[%1 : i64] : !llvm.vec + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : !llvm.vec + llvm.store %4, %arg0 {alignment = 16 : i64} : vector<[4]xf32>, !llvm.ptr + %5 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.return %5 : f32 + } + llvm.func @load_i32_store_nxv4f32(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.insertelement %2, %0[%1 : i64] : !llvm.vec + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : !llvm.vec + llvm.store %4, %arg0 {alignment = 16 : i64} : vector<[4]xf32>, !llvm.ptr + %5 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %5 : i32 + } + llvm.func @load_v4i32_store_nxv4i32(%arg0: !llvm.ptr) -> vector<4xi32> { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %2, %0[%1 : i64] : !llvm.vec + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : !llvm.vec + llvm.store %4, %arg0 {alignment = 16 : i64} : vector<[4]xi32>, !llvm.ptr + %5 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @load_v4i16_store_nxv4i32(%arg0: !llvm.ptr) -> vector<4xi16> { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %2, %0[%1 : i64] : !llvm.vec + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : !llvm.vec + llvm.store %4, %arg0 {alignment = 16 : i64} : vector<[4]xi32>, !llvm.ptr + %5 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> vector<4xi16> + llvm.return %5 : vector<4xi16> + } + llvm.func @load_i64_store_nxv4i8(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.insertelement %2, %0[%1 : i64] : !llvm.vec + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : !llvm.vec + llvm.store %4, %arg0 {alignment = 16 : i64} : vector<[4]xi8>, !llvm.ptr + %5 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + llvm.return %5 : i64 + } + llvm.func @load_nxv4i8_store_nxv4i32(%arg0: !llvm.ptr) -> !llvm.vec { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %2, %0[%1 : i64] : !llvm.vec + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : !llvm.vec + llvm.store %4, %arg0 {alignment = 16 : i64} : vector<[4]xi32>, !llvm.ptr + %5 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> !llvm.vec + llvm.return %5 : !llvm.vec + } + llvm.func @load_i8_store_i1(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + llvm.store %0, %arg0 {alignment = 1 : i64} : i1, !llvm.ptr + %1 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %1 : i8 + } + llvm.func @load_i1_store_i8(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + llvm.store %0, %arg0 {alignment = 1 : i64} : i8, !llvm.ptr + %1 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i1 + llvm.return %1 : i1 + } + llvm.func @load_after_memset_0(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %2 : i32 + } + llvm.func @load_after_memset_0_float(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.return %2 : f32 + } + llvm.func @load_after_memset_0_non_byte_sized(%arg0: !llvm.ptr) -> i27 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i27 + llvm.return %2 : i27 + } + llvm.func @load_after_memset_0_i1(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %2 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i1 + llvm.return %2 : i1 + } + llvm.func @load_after_memset_0_vec(%arg0: !llvm.ptr) -> vector<4xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @load_after_memset_1(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %2 : i32 + } + llvm.func @load_after_memset_1_float(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.return %2 : f32 + } + llvm.func @load_after_memset_1_non_byte_sized(%arg0: !llvm.ptr) -> i27 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i27 + llvm.return %2 : i27 + } + llvm.func @load_after_memset_1_i1(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %2 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i1 + llvm.return %2 : i1 + } + llvm.func @load_after_memset_1_vec(%arg0: !llvm.ptr) -> vector<4xi8> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @load_after_memset_unknown(%arg0: !llvm.ptr, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %1 : i32 + } + llvm.func @load_after_memset_0_offset(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + %2 = llvm.mlir.constant(4 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %3 = llvm.getelementptr %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %4 : i32 + } + llvm.func @load_after_memset_0_offset_too_large(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + %2 = llvm.mlir.constant(13 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %3 = llvm.getelementptr %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %4 : i32 + } + llvm.func @load_after_memset_0_offset_negative(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + %2 = llvm.mlir.constant(-1 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %3 = llvm.getelementptr %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %4 : i32 + } + llvm.func @load_after_memset_0_clobber(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + %2 = llvm.mlir.constant(1 : i8) : i8 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + llvm.store %2, %arg0 {alignment = 1 : i64} : i8, !llvm.ptr + %3 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %3 : i32 + } + llvm.func @load_after_memset_0_too_small(%arg0: !llvm.ptr) -> i256 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i256 + llvm.return %2 : i256 + } + llvm.func @load_after_memset_0_too_small_by_one_bit(%arg0: !llvm.ptr) -> i129 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i129 + llvm.return %2 : i129 + } + llvm.func @load_after_memset_0_unknown_length(%arg0: !llvm.ptr, %arg1: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + "llvm.intr.memset"(%arg0, %0, %arg1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %1 : i32 + } + llvm.func @load_after_memset_0_atomic(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %2 = llvm.load %arg0 atomic seq_cst {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %2 : i32 + } + llvm.func @load_after_memset_0_scalable(%arg0: !llvm.ptr) -> !llvm.vec { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> !llvm.vec + llvm.return %2 : !llvm.vec + } +} diff --git a/test/LLVMDialect/InstCombine/load-store-masked-constant-array.ll.mlir b/test/LLVMDialect/InstCombine/load-store-masked-constant-array.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/load.ll.mlir b/test/LLVMDialect/InstCombine/load.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/load3.ll.mlir b/test/LLVMDialect/InstCombine/load3.ll.mlir new file mode 100644 index 000000000..6ecfacfbf --- /dev/null +++ b/test/LLVMDialect/InstCombine/load3.ll.mlir @@ -0,0 +1,34 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.mlir.global private constant @".str"("XYZ\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global external @rslts32(dense<0> : tensor<36xi32>) {addr_space = 0 : i32, alignment = 4 : i64} : !llvm.array<36 x i32> + llvm.mlir.global internal constant @expect32(dense<[1, 2, 0, 100, 3, 4, 0, -7, 4, 4, 8, 8, 1, 3, 8, 3, 4, -2, 2, 8, 83, 77, 8, 17, 77, 88, 22, 33, 44, 88, 77, 4, 4, 7, -7, -8]> : tensor<36xi32>) {addr_space = 0 : i32, alignment = 4 : i64, dso_local} : !llvm.array<36 x i32> + llvm.func @test1(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + %3 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + %5 = llvm.sub %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test2() -> f32 { + %0 = llvm.mlir.constant("XYZ\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.load %1 {alignment = 1 : i64} : !llvm.ptr -> f32 + llvm.return %2 : f32 + } + llvm.func @test3() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(28 : i32) : i32 + %1 = llvm.mlir.constant(29826161 : i32) : i32 + %2 = llvm.mlir.constant(dense<[1, 2, 0, 100, 3, 4, 0, -7, 4, 4, 8, 8, 1, 3, 8, 3, 4, -2, 2, 8, 83, 77, 8, 17, 77, 88, 22, 33, 44, 88, 77, 4, 4, 7, -7, -8]> : tensor<36xi32>) : !llvm.array<36 x i32> + %3 = llvm.mlir.addressof @expect32 : !llvm.ptr + %4 = llvm.getelementptr %3[%1, %0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<36 x i32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(dense<0> : tensor<36xi32>) : !llvm.array<36 x i32> + %7 = llvm.mlir.addressof @rslts32 : !llvm.ptr + %8 = llvm.getelementptr %7[%1, %0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<36 x i32> + %9 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %9, %8 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/load_combine_aa.ll.mlir b/test/LLVMDialect/InstCombine/load_combine_aa.ll.mlir index 937b6f18d..48c568895 100644 --- a/test/LLVMDialect/InstCombine/load_combine_aa.ll.mlir +++ b/test/LLVMDialect/InstCombine/load_combine_aa.ll.mlir @@ -1,13 +1,11 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - "llvm.store"(%0, %arg3) : (i32, !llvm.ptr) -> () - %2 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - "llvm.store"(%1, %arg1) : (i32, !llvm.ptr) -> () - "llvm.store"(%2, %arg2) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_load_combine_aa", type = !llvm.func, ptr, ptr, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_load_combine_aa(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr {llvm.noalias}) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %0, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %1, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %2, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/loadstore-alignment.ll.mlir b/test/LLVMDialect/InstCombine/loadstore-alignment.ll.mlir index b3beadcfd..61c5f788b 100644 --- a/test/LLVMDialect/InstCombine/loadstore-alignment.ll.mlir +++ b/test/LLVMDialect/InstCombine/loadstore-alignment.ll.mlir @@ -1,80 +1,68 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "x", type = vector<2xi64>} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "xx", type = !llvm.array<13 x vector<2xi64>>} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "x.as2", type = vector<2xi64>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @x} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0) : (!llvm.ptr>, i32) -> !llvm.ptr> - %3 = "llvm.load"(%2) : (!llvm.ptr>) -> vector<2xi64> - "llvm.return"(%3) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "static_hem", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @x} : () -> !llvm.ptr> - %1 = "llvm.getelementptr"(%0, %arg0) : (!llvm.ptr>, i32) -> !llvm.ptr> - %2 = "llvm.load"(%1) : (!llvm.ptr>) -> vector<2xi64> - "llvm.return"(%2) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "hem", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @xx} : () -> !llvm.ptr>> - %1 = "llvm.getelementptr"(%0, %arg0, %arg1) : (!llvm.ptr>>, i32, i32) -> !llvm.ptr> - %2 = "llvm.load"(%1) : (!llvm.ptr>) -> vector<2xi64> - "llvm.return"(%2) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "hem_2d", type = !llvm.func (i32, i32)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @x} : () -> !llvm.ptr> - %1 = "llvm.load"(%0) : (!llvm.ptr>) -> vector<2xi64> - "llvm.return"(%1) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr> - "llvm.call"(%1) {callee = @kip, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>) -> () - %2 = "llvm.load"(%1) : (!llvm.ptr>) -> vector<2xi64> - "llvm.return"(%2) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @x} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0) : (!llvm.ptr>, i32) -> !llvm.ptr> - "llvm.store"(%arg0, %2) : (vector<2xi64>, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "static_hem_store", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @x} : () -> !llvm.ptr> - %1 = "llvm.getelementptr"(%0, %arg0) : (!llvm.ptr>, i32) -> !llvm.ptr> - "llvm.store"(%arg1, %1) : (vector<2xi64>, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "hem_store", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @xx} : () -> !llvm.ptr>> - %1 = "llvm.getelementptr"(%0, %arg0, %arg1) : (!llvm.ptr>>, i32, i32) -> !llvm.ptr> - "llvm.store"(%arg2, %1) : (vector<2xi64>, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "hem_2d_store", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @x} : () -> !llvm.ptr> - "llvm.store"(%arg0, %0) : (vector<2xi64>, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "foo_store", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr> - "llvm.call"(%1) {callee = @kip, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>) -> () - "llvm.store"(%arg0, %1) : (vector<2xi64>, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "bar_store", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "kip", type = !llvm.func>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry, dense<64> : vector<4xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "big">>} { + llvm.mlir.global external @x() {addr_space = 0 : i32, alignment = 16 : i64} : vector<2xi64> + llvm.mlir.global external @xx() {addr_space = 0 : i32, alignment = 16 : i64} : !llvm.array<13 x vector<2xi64>> + llvm.mlir.global external @x.as2() {addr_space = 2 : i32, alignment = 16 : i64} : vector<2xi64> + llvm.func @static_hem() -> vector<2xi64> { + %0 = llvm.mlir.addressof @x : !llvm.ptr + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.getelementptr %0[%1] : (!llvm.ptr, i32) -> !llvm.ptr, vector<2xi64> + %3 = llvm.load %2 {alignment = 1 : i64} : !llvm.ptr -> vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @hem(%arg0: i32) -> vector<2xi64> { + %0 = llvm.mlir.addressof @x : !llvm.ptr + %1 = llvm.getelementptr %0[%arg0] : (!llvm.ptr, i32) -> !llvm.ptr, vector<2xi64> + %2 = llvm.load %1 {alignment = 1 : i64} : !llvm.ptr -> vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @hem_2d(%arg0: i32, %arg1: i32) -> vector<2xi64> { + %0 = llvm.mlir.addressof @xx : !llvm.ptr + %1 = llvm.getelementptr %0[%arg0, %arg1] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<13 x vector<2xi64>> + %2 = llvm.load %1 {alignment = 1 : i64} : !llvm.ptr -> vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @foo() -> vector<2xi64> { + %0 = llvm.mlir.addressof @x : !llvm.ptr + %1 = llvm.load %0 {alignment = 1 : i64} : !llvm.ptr -> vector<2xi64> + llvm.return %1 : vector<2xi64> + } + llvm.func @bar() -> vector<2xi64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x vector<2xi64> {alignment = 16 : i64} : (i32) -> !llvm.ptr + llvm.call @kip(%1) : (!llvm.ptr) -> () + %2 = llvm.load %1 {alignment = 1 : i64} : !llvm.ptr -> vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @static_hem_store(%arg0: vector<2xi64>) { + %0 = llvm.mlir.addressof @x : !llvm.ptr + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.getelementptr %0[%1] : (!llvm.ptr, i32) -> !llvm.ptr, vector<2xi64> + llvm.store %arg0, %2 {alignment = 1 : i64} : vector<2xi64>, !llvm.ptr + llvm.return + } + llvm.func @hem_store(%arg0: i32, %arg1: vector<2xi64>) { + %0 = llvm.mlir.addressof @x : !llvm.ptr + %1 = llvm.getelementptr %0[%arg0] : (!llvm.ptr, i32) -> !llvm.ptr, vector<2xi64> + llvm.store %arg1, %1 {alignment = 1 : i64} : vector<2xi64>, !llvm.ptr + llvm.return + } + llvm.func @hem_2d_store(%arg0: i32, %arg1: i32, %arg2: vector<2xi64>) { + %0 = llvm.mlir.addressof @xx : !llvm.ptr + %1 = llvm.getelementptr %0[%arg0, %arg1] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<13 x vector<2xi64>> + llvm.store %arg2, %1 {alignment = 1 : i64} : vector<2xi64>, !llvm.ptr + llvm.return + } + llvm.func @foo_store(%arg0: vector<2xi64>) { + %0 = llvm.mlir.addressof @x : !llvm.ptr + llvm.store %arg0, %0 {alignment = 1 : i64} : vector<2xi64>, !llvm.ptr + llvm.return + } + llvm.func @bar_store(%arg0: vector<2xi64>) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x vector<2xi64> {alignment = 16 : i64} : (i32) -> !llvm.ptr + llvm.call @kip(%1) : (!llvm.ptr) -> () + llvm.store %arg0, %1 {alignment = 1 : i64} : vector<2xi64>, !llvm.ptr + llvm.return + } + llvm.func @kip(!llvm.ptr) +} diff --git a/test/LLVMDialect/InstCombine/loadstore-metadata.ll.mlir b/test/LLVMDialect/InstCombine/loadstore-metadata.ll.mlir index 0104c483a..501f74bda 100644 --- a/test/LLVMDialect/InstCombine/loadstore-metadata.ll.mlir +++ b/test/LLVMDialect/InstCombine/loadstore-metadata.ll.mlir @@ -1,76 +1,73 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> f32 - %1 = "llvm.bitcast"(%0) : (f32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_load_cast_combine_tbaa", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> f32 - %1 = "llvm.bitcast"(%0) : (f32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_load_cast_combine_noalias", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %1 = "llvm.bitcast"(%0) : (i32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_load_cast_combine_range", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> f32 - %1 = "llvm.bitcast"(%0) : (f32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_load_cast_combine_invariant", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> f32 - %1 = "llvm.bitcast"(%0) : (f32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_load_cast_combine_nontemporal", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %1 = "llvm.bitcast"(%0) : (!llvm.ptr) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_load_cast_combine_align", type = !llvm.func (ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %1 = "llvm.bitcast"(%0) : (!llvm.ptr) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_load_cast_combine_deref", type = !llvm.func (ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %1 = "llvm.bitcast"(%0) : (!llvm.ptr) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_load_cast_combine_deref_or_null", type = !llvm.func (ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.br"(%1)[^bb1] : (i32) -> () +#access_group = #llvm.access_group> +#alias_scope_domain = #llvm.alias_scope_domain> +#tbaa_root = #llvm.tbaa_root +#alias_scope = #llvm.alias_scope, domain = #alias_scope_domain> +#tbaa_type_desc = #llvm.tbaa_type_desc}> +#tbaa_tag = #llvm.tbaa_tag +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @test_load_cast_combine_tbaa(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 {alignment = 4 : i64, tbaa = [#tbaa_tag]} : !llvm.ptr -> f32 + %1 = llvm.bitcast %0 : f32 to i32 + llvm.return %1 : i32 + } + llvm.func @test_load_cast_combine_noalias(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 {alias_scopes = [#alias_scope], alignment = 4 : i64, noalias_scopes = [#alias_scope]} : !llvm.ptr -> f32 + %1 = llvm.bitcast %0 : f32 to i32 + llvm.return %1 : i32 + } + llvm.func @test_load_cast_combine_range(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.bitcast %0 : i32 to f32 + llvm.return %1 : f32 + } + llvm.func @test_load_cast_combine_invariant(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 invariant {alignment = 4 : i64} : !llvm.ptr -> f32 + %1 = llvm.bitcast %0 : f32 to i32 + llvm.return %1 : i32 + } + llvm.func @test_load_cast_combine_nontemporal(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 {alignment = 4 : i64, nontemporal} : !llvm.ptr -> f32 + %1 = llvm.bitcast %0 : f32 to i32 + llvm.return %1 : i32 + } + llvm.func @test_load_cast_combine_align(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test_load_cast_combine_deref(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test_load_cast_combine_deref_or_null(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test_load_cast_combine_loop(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + llvm.br ^bb1(%0 : i32) ^bb1(%2: i32): // 2 preds: ^bb0, ^bb1 - %3 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i32) -> !llvm.ptr - %4 = "llvm.getelementptr"(%arg1, %2) : (!llvm.ptr, i32) -> !llvm.ptr - %5 = "llvm.load"(%3) : (!llvm.ptr) -> f32 - %6 = "llvm.bitcast"(%5) : (f32) -> i32 - "llvm.store"(%6, %4) : (i32, !llvm.ptr) -> () - %7 = "llvm.add"(%2, %0) : (i32, i32) -> i32 - %8 = "llvm.icmp"(%7, %arg2) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%8, %7)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i32) -> () + %3 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i32) -> !llvm.ptr, f32 + %4 = llvm.getelementptr inbounds %arg1[%2] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %5 = llvm.load %3 {access_groups = [#access_group], alignment = 4 : i64} : !llvm.ptr -> f32 + %6 = llvm.bitcast %5 : f32 to i32 + llvm.store %6, %4 {alignment = 4 : i64} : i32, !llvm.ptr + %7 = llvm.add %2, %1 : i32 + %8 = llvm.icmp "slt" %7, %arg2 : i32 + llvm.cond_br %8, ^bb1(%7 : i32), ^bb2 ^bb2: // pred: ^bb1 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_load_cast_combine_loop", type = !llvm.func, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr>, i32) -> !llvm.ptr> - "llvm.store"(%1, %2) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_load_cast_combine_nonnull", type = !llvm.func>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } + llvm.func @test_load_cast_combine_nonnull(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + llvm.store %1, %2 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test_load_cast_combine_noundef(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> f32 + %1 = llvm.bitcast %0 : f32 to i32 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/log-pow-nofastmath.ll.mlir b/test/LLVMDialect/InstCombine/log-pow-nofastmath.ll.mlir index 2f81d5253..9203fe724 100644 --- a/test/LLVMDialect/InstCombine/log-pow-nofastmath.ll.mlir +++ b/test/LLVMDialect/InstCombine/log-pow-nofastmath.ll.mlir @@ -1,21 +1,14 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %1 = "llvm.call"(%0) {callee = @log, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "mylog", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp2, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%0) {callee = @log, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "log", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp2", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f64", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @mylog(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.intr.pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.call @log(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test3(%arg0: f64) -> f64 { + %0 = llvm.call @exp2(%arg0) : (f64) -> f64 + %1 = llvm.call @log(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @log(f64) -> f64 + llvm.func @exp2(f64) -> f64 +} diff --git a/test/LLVMDialect/InstCombine/log-pow.ll.mlir b/test/LLVMDialect/InstCombine/log-pow.ll.mlir index 7307dd518..dd038c759 100644 --- a/test/LLVMDialect/InstCombine/log-pow.ll.mlir +++ b/test/LLVMDialect/InstCombine/log-pow.ll.mlir @@ -1,96 +1,96 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %1 = "llvm.call"(%0) {callee = @log, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "log_pow", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %1 = "llvm.call"(%0) {callee = @llvm.log10.f32, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "log10f_powf", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf64>, %arg1: vector<2xf64>): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.pow.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> - %1 = "llvm.call"(%0) {callee = @llvm.log2.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>) -> vector<2xf64> - "llvm.return"(%1) : (vector<2xf64>) -> () - }) {linkage = 10 : i64, sym_name = "log2v_powv", type = !llvm.func (vector<2xf64>, vector<2xf64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %1 = "llvm.call"(%0) {callee = @log, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "log_pow_not_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: f32): // no predecessors - %0 = "llvm.call"(%arg0) : (!llvm.ptr>) -> f32 - %1 = "llvm.call"(%0) {callee = @logf, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "function_pointer", type = !llvm.func>, f32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%0) {callee = @log10, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "log10_exp", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.exp2.v2f32, fastmathFlags = #llvm.fastmath<>} : (vector<2xf32>) -> vector<2xf32> - %1 = "llvm.call"(%0) {callee = @llvm.log.v2f32, fastmathFlags = #llvm.fastmath<>} : (vector<2xf32>) -> vector<2xf32> - "llvm.return"(%1) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "logv_exp2v", type = !llvm.func (vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp10f, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %1 = "llvm.call"(%0) {callee = @log2f, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "log2f_exp10f", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp2, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%0) {callee = @log, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "log_exp2_not_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: i32, %arg2: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = -0.000000e+00 : f64} : () -> f64 - %1 = "llvm.fsub"(%0, %arg0) : (f64, f64) -> f64 - %2 = "llvm.call"(%arg2, %arg1) : (!llvm.ptr>, i32) -> f64 - %3 = "llvm.call"(%2) {callee = @llvm.log.f64, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %4 = "llvm.fmul"(%3, %1) : (f64, f64) -> f64 - "llvm.return"(%4) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pr43617", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "log", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "logf", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.log.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.log.v2f32", type = !llvm.func (vector<2xf32>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "log2f", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.log2.v2f64", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "log10", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.log10.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp2", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp10f", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.exp2.v2f32", type = !llvm.func (vector<2xf32>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "pow", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "powf", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.v2f64", type = !llvm.func (vector<2xf64>, vector<2xf64>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @log_pow(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.call @pow(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %1 = llvm.call @log(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @log_powi_const(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.call @log(%1) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @log_powi_nonconst(%arg0: f64, %arg1: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %1 = llvm.call @log(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @logf64_powi_nonconst(%arg0: f64, %arg1: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %1 = llvm.intr.log(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @logf_powfi_const(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, i32) -> f32 + %2 = llvm.call @logf(%1) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @logf_powfi_nonconst(%arg0: f32, %arg1: i32) -> f32 { + %0 = llvm.intr.powi(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, i32) -> f32 + %1 = llvm.call @logf(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @log_powi_not_fast(%arg0: f64, %arg1: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) : (f64, i32) -> f64 + %1 = llvm.call @log(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @log10f_powf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.call @powf(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %1 = llvm.intr.log10(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @log2v_powv(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.intr.pow(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + %1 = llvm.intr.log2(%0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @log_pow_not_fast(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.call @pow(%arg0, %arg1) : (f64, f64) -> f64 + %1 = llvm.call @log(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @function_pointer(%arg0: !llvm.ptr, %arg1: f32) -> f32 { + %0 = llvm.call %arg0() : !llvm.ptr, () -> f32 + %1 = llvm.call @logf(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @log10_exp(%arg0: f64) -> f64 { + %0 = llvm.call @exp(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.call @log10(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @logv_exp2v(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.intr.exp2(%arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> vector<2xf32> + %1 = llvm.intr.log(%0) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @log2f_exp10f(%arg0: f32) -> f32 { + %0 = llvm.call @exp10f(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %1 = llvm.call @log2f(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @log_exp2_not_fast(%arg0: f64) -> f64 { + %0 = llvm.call @exp2(%arg0) : (f64) -> f64 + %1 = llvm.call @log(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pr43617(%arg0: f64, %arg1: i32, %arg2: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.call %arg2(%arg1) {fastmathFlags = #llvm.fastmath} : !llvm.ptr, (i32) -> f64 + %3 = llvm.intr.log(%2) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %4 = llvm.fmul %3, %1 : f64 + llvm.return %4 : f64 + } + llvm.func @log(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @logf(f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @log2f(f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @log10(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @exp(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @exp2(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @exp10f(f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @pow(f64, f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @powf(f32, f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} +} diff --git a/test/LLVMDialect/InstCombine/logical-select-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/logical-select-inseltpoison.ll.mlir new file mode 100644 index 000000000..173500fa6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/logical-select-inseltpoison.ll.mlir @@ -0,0 +1,422 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %arg1 : i32 + %2 = llvm.sext %1 : i1 to i32 + %3 = llvm.and %arg2, %2 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.and %arg3, %4 : i32 + %6 = llvm.or %3, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @bar(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %arg1 : i32 + %2 = llvm.sext %1 : i1 to i32 + %3 = llvm.and %arg2, %2 : i32 + %4 = llvm.xor %2, %0 : i32 + %5 = llvm.and %arg3, %4 : i32 + %6 = llvm.or %5, %3 : i32 + llvm.return %6 : i32 + } + llvm.func @goo(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %arg1 : i32 + %3 = llvm.select %2, %0, %1 : i1, i32 + %4 = llvm.and %3, %arg2 : i32 + %5 = llvm.xor %3, %0 : i32 + %6 = llvm.and %5, %arg3 : i32 + %7 = llvm.or %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @poo(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %arg1 : i32 + %3 = llvm.select %2, %0, %1 : i1, i32 + %4 = llvm.and %3, %arg2 : i32 + %5 = llvm.select %2, %1, %0 : i1, i32 + %6 = llvm.and %5, %arg3 : i32 + %7 = llvm.or %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @fold_inverted_icmp_preds(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %arg1 : i32 + %2 = llvm.select %1, %arg2, %0 : i1, i32 + %3 = llvm.icmp "sge" %arg0, %arg1 : i32 + %4 = llvm.select %3, %arg3, %0 : i1, i32 + %5 = llvm.or %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @fold_inverted_icmp_preds_reverse(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %arg1 : i32 + %2 = llvm.select %1, %0, %arg2 : i1, i32 + %3 = llvm.icmp "sge" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %arg3 : i1, i32 + %5 = llvm.or %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @fold_inverted_fcmp_preds(%arg0: f32, %arg1: f32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f32 + %2 = llvm.select %1, %arg2, %0 : i1, i32 + %3 = llvm.fcmp "uge" %arg0, %arg1 : f32 + %4 = llvm.select %3, %arg3, %0 : i1, i32 + %5 = llvm.or %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @fold_inverted_icmp_vector_preds(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>, %arg3: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "ne" %arg0, %arg1 : vector<2xi32> + %3 = llvm.select %2, %arg2, %1 : vector<2xi1>, vector<2xi32> + %4 = llvm.icmp "eq" %arg0, %arg1 : vector<2xi32> + %5 = llvm.select %4, %arg3, %1 : vector<2xi1>, vector<2xi32> + %6 = llvm.or %3, %5 : vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @par(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %arg1 : i32 + %3 = llvm.select %2, %0, %1 : i1, i32 + %4 = llvm.and %3, %arg2 : i32 + %5 = llvm.xor %3, %0 : i32 + %6 = llvm.and %5, %arg3 : i32 + %7 = llvm.or %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @bitcast_select_swap0(%arg0: vector<4xi1>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.fptosi %arg1 : vector<2xf64> to vector<2xi64> + %2 = llvm.fptosi %arg2 : vector<2xf64> to vector<2xi64> + %3 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %4 = llvm.bitcast %3 : vector<4xi32> to vector<2xi64> + %5 = llvm.and %4, %1 : vector<2xi64> + %6 = llvm.xor %3, %0 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + %8 = llvm.and %7, %2 : vector<2xi64> + %9 = llvm.or %5, %8 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @bitcast_select_swap1(%arg0: vector<4xi1>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.fptosi %arg1 : vector<2xf64> to vector<2xi64> + %2 = llvm.fptosi %arg2 : vector<2xf64> to vector<2xi64> + %3 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %4 = llvm.bitcast %3 : vector<4xi32> to vector<2xi64> + %5 = llvm.and %4, %1 : vector<2xi64> + %6 = llvm.xor %3, %0 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + %8 = llvm.and %7, %2 : vector<2xi64> + %9 = llvm.or %8, %5 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @bitcast_select_swap2(%arg0: vector<4xi1>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.fptosi %arg1 : vector<2xf64> to vector<2xi64> + %2 = llvm.fptosi %arg2 : vector<2xf64> to vector<2xi64> + %3 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %4 = llvm.bitcast %3 : vector<4xi32> to vector<2xi64> + %5 = llvm.and %4, %1 : vector<2xi64> + %6 = llvm.xor %3, %0 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + %8 = llvm.and %2, %7 : vector<2xi64> + %9 = llvm.or %5, %8 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @bitcast_select_swap3(%arg0: vector<4xi1>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.fptosi %arg1 : vector<2xf64> to vector<2xi64> + %2 = llvm.fptosi %arg2 : vector<2xf64> to vector<2xi64> + %3 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %4 = llvm.bitcast %3 : vector<4xi32> to vector<2xi64> + %5 = llvm.and %4, %1 : vector<2xi64> + %6 = llvm.xor %3, %0 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + %8 = llvm.and %2, %7 : vector<2xi64> + %9 = llvm.or %8, %5 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @bitcast_select_swap4(%arg0: vector<4xi1>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.fptosi %arg1 : vector<2xf64> to vector<2xi64> + %2 = llvm.fptosi %arg2 : vector<2xf64> to vector<2xi64> + %3 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %4 = llvm.bitcast %3 : vector<4xi32> to vector<2xi64> + %5 = llvm.and %1, %4 : vector<2xi64> + %6 = llvm.xor %3, %0 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + %8 = llvm.and %7, %2 : vector<2xi64> + %9 = llvm.or %5, %8 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @bitcast_select_swap5(%arg0: vector<4xi1>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.fptosi %arg1 : vector<2xf64> to vector<2xi64> + %2 = llvm.fptosi %arg2 : vector<2xf64> to vector<2xi64> + %3 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %4 = llvm.bitcast %3 : vector<4xi32> to vector<2xi64> + %5 = llvm.and %1, %4 : vector<2xi64> + %6 = llvm.xor %3, %0 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + %8 = llvm.and %7, %2 : vector<2xi64> + %9 = llvm.or %8, %5 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @bitcast_select_swap6(%arg0: vector<4xi1>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.fptosi %arg1 : vector<2xf64> to vector<2xi64> + %2 = llvm.fptosi %arg2 : vector<2xf64> to vector<2xi64> + %3 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %4 = llvm.bitcast %3 : vector<4xi32> to vector<2xi64> + %5 = llvm.and %1, %4 : vector<2xi64> + %6 = llvm.xor %3, %0 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + %8 = llvm.and %2, %7 : vector<2xi64> + %9 = llvm.or %5, %8 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @bitcast_select_swap7(%arg0: vector<4xi1>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.fptosi %arg1 : vector<2xf64> to vector<2xi64> + %2 = llvm.fptosi %arg2 : vector<2xf64> to vector<2xi64> + %3 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %4 = llvm.bitcast %3 : vector<4xi32> to vector<2xi64> + %5 = llvm.and %1, %4 : vector<2xi64> + %6 = llvm.xor %3, %0 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + %8 = llvm.and %2, %7 : vector<2xi64> + %9 = llvm.or %8, %5 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @bitcast_select_multi_uses(%arg0: vector<4xi1>, %arg1: vector<2xi64>, %arg2: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %2 = llvm.bitcast %1 : vector<4xi32> to vector<2xi64> + %3 = llvm.and %arg1, %2 : vector<2xi64> + %4 = llvm.xor %1, %0 : vector<4xi32> + %5 = llvm.bitcast %4 : vector<4xi32> to vector<2xi64> + %6 = llvm.and %arg2, %5 : vector<2xi64> + %7 = llvm.or %6, %3 : vector<2xi64> + %8 = llvm.add %6, %5 : vector<2xi64> + %9 = llvm.sub %7, %8 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @bools(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg2, %0 : i1 + %2 = llvm.and %1, %arg0 : i1 + %3 = llvm.and %arg2, %arg1 : i1 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @bools_logical(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %2, %arg0, %1 : i1, i1 + %4 = llvm.select %arg2, %arg1, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools_multi_uses1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg2, %0 : i1 + %2 = llvm.and %1, %arg0 : i1 + %3 = llvm.and %arg2, %arg1 : i1 + %4 = llvm.or %2, %3 : i1 + %5 = llvm.xor %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @bools_multi_uses1_logical(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %2, %arg0, %1 : i1, i1 + %4 = llvm.select %arg2, %arg1, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + %6 = llvm.xor %5, %3 : i1 + llvm.return %6 : i1 + } + llvm.func @bools_multi_uses2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg2, %0 : i1 + %2 = llvm.and %1, %arg0 : i1 + %3 = llvm.and %arg2, %arg1 : i1 + %4 = llvm.or %2, %3 : i1 + %5 = llvm.add %2, %3 : i1 + %6 = llvm.and %4, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @bools_multi_uses2_logical(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %2, %arg0, %1 : i1, i1 + %4 = llvm.select %arg2, %arg1, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + %6 = llvm.add %3, %4 : i1 + %7 = llvm.select %5, %6, %1 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @vec_of_bools(%arg0: vector<4xi1>, %arg1: vector<4xi1>, %arg2: vector<4xi1>) -> vector<4xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %2 = llvm.xor %arg2, %1 : vector<4xi1> + %3 = llvm.and %2, %arg0 : vector<4xi1> + %4 = llvm.and %arg1, %arg2 : vector<4xi1> + %5 = llvm.or %4, %3 : vector<4xi1> + llvm.return %5 : vector<4xi1> + } + llvm.func @vec_of_casted_bools(%arg0: i4, %arg1: i4, %arg2: vector<4xi1>) -> i4 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %2 = llvm.xor %arg2, %1 : vector<4xi1> + %3 = llvm.bitcast %2 : vector<4xi1> to i4 + %4 = llvm.bitcast %arg2 : vector<4xi1> to i4 + %5 = llvm.and %arg0, %3 : i4 + %6 = llvm.and %4, %arg1 : i4 + %7 = llvm.or %5, %6 : i4 + llvm.return %7 : i4 + } + llvm.func @vec_sel_consts(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[-1, 0, 0, -1]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[0, -1, -1, 0]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.and %arg0, %0 : vector<4xi32> + %3 = llvm.and %arg1, %1 : vector<4xi32> + %4 = llvm.or %2, %3 : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @vec_sel_consts_weird(%arg0: vector<3xi129>, %arg1: vector<3xi129>) -> vector<3xi129> { + %0 = llvm.mlir.constant(-1 : i129) : i129 + %1 = llvm.mlir.constant(0 : i129) : i129 + %2 = llvm.mlir.constant(dense<[-1, 0, -1]> : vector<3xi129>) : vector<3xi129> + %3 = llvm.mlir.constant(dense<[0, -1, 0]> : vector<3xi129>) : vector<3xi129> + %4 = llvm.and %arg0, %2 : vector<3xi129> + %5 = llvm.and %arg1, %3 : vector<3xi129> + %6 = llvm.or %5, %4 : vector<3xi129> + llvm.return %6 : vector<3xi129> + } + llvm.func @vec_not_sel_consts(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[-1, 0, 0, 0]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[0, -1, 0, -1]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.and %arg0, %0 : vector<4xi32> + %3 = llvm.and %arg1, %1 : vector<4xi32> + %4 = llvm.or %2, %3 : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @vec_not_sel_consts_undef_elts(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.undef : vector<4xi32> + %13 = llvm.mlir.constant(0 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<4xi32> + %15 = llvm.mlir.constant(1 : i32) : i32 + %16 = llvm.insertelement %2, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(2 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(3 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.and %arg0, %11 : vector<4xi32> + %22 = llvm.and %arg1, %20 : vector<4xi32> + %23 = llvm.or %21, %22 : vector<4xi32> + llvm.return %23 : vector<4xi32> + } + llvm.func @vec_sel_xor(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi1>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[-1, 0, 0, 0]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[0, -1, -1, -1]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sext %arg2 : vector<4xi1> to vector<4xi32> + %3 = llvm.xor %2, %0 : vector<4xi32> + %4 = llvm.xor %2, %1 : vector<4xi32> + %5 = llvm.and %4, %arg0 : vector<4xi32> + %6 = llvm.and %3, %arg1 : vector<4xi32> + %7 = llvm.or %5, %6 : vector<4xi32> + llvm.return %7 : vector<4xi32> + } + llvm.func @vec_sel_xor_multi_use(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi1>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[-1, 0, 0, 0]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[0, -1, -1, -1]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sext %arg2 : vector<4xi1> to vector<4xi32> + %3 = llvm.xor %2, %0 : vector<4xi32> + %4 = llvm.xor %2, %1 : vector<4xi32> + %5 = llvm.and %4, %arg0 : vector<4xi32> + %6 = llvm.and %3, %arg1 : vector<4xi32> + %7 = llvm.or %5, %6 : vector<4xi32> + %8 = llvm.add %7, %3 : vector<4xi32> + llvm.return %8 : vector<4xi32> + } + llvm.func @allSignBits(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.xor %2, %1 : i32 + %4 = llvm.and %arg1, %2 : i32 + %5 = llvm.and %3, %arg2 : i32 + %6 = llvm.or %4, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @allSignBits_vec(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<7> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<4xi8>) : vector<4xi8> + %2 = llvm.ashr %arg0, %0 : vector<4xi8> + %3 = llvm.xor %2, %1 : vector<4xi8> + %4 = llvm.and %arg1, %2 : vector<4xi8> + %5 = llvm.and %arg2, %3 : vector<4xi8> + %6 = llvm.or %5, %4 : vector<4xi8> + llvm.return %6 : vector<4xi8> + } + llvm.func @fp_bitcast(%arg0: vector<4xi1>, %arg1: vector<2xf64>, %arg2: vector<2xf64>) -> vector<2xi64> { + %0 = llvm.fptosi %arg1 : vector<2xf64> to vector<2xi64> + %1 = llvm.fptosi %arg2 : vector<2xf64> to vector<2xi64> + %2 = llvm.bitcast %arg1 : vector<2xf64> to vector<2xi64> + %3 = llvm.and %0, %2 : vector<2xi64> + %4 = llvm.bitcast %arg2 : vector<2xf64> to vector<2xi64> + %5 = llvm.and %1, %4 : vector<2xi64> + %6 = llvm.or %5, %3 : vector<2xi64> + llvm.return %6 : vector<2xi64> + } + llvm.func @computesignbits_through_shuffles(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: vector<4xf32>) -> vector<4xi32> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %2 = llvm.fcmp "ole" %arg0, %arg1 : vector<4xf32> + %3 = llvm.sext %2 : vector<4xi1> to vector<4xi32> + %4 = llvm.shufflevector %3, %0 [0, 0, 1, 1] : vector<4xi32> + %5 = llvm.shufflevector %3, %0 [2, 2, 3, 3] : vector<4xi32> + %6 = llvm.or %4, %5 : vector<4xi32> + %7 = llvm.shufflevector %6, %0 [0, 0, 1, 1] : vector<4xi32> + %8 = llvm.shufflevector %6, %0 [2, 2, 3, 3] : vector<4xi32> + %9 = llvm.or %7, %8 : vector<4xi32> + %10 = llvm.xor %9, %1 : vector<4xi32> + %11 = llvm.bitcast %arg0 : vector<4xf32> to vector<4xi32> + %12 = llvm.bitcast %arg2 : vector<4xf32> to vector<4xi32> + %13 = llvm.and %10, %11 : vector<4xi32> + %14 = llvm.and %9, %12 : vector<4xi32> + %15 = llvm.or %13, %14 : vector<4xi32> + llvm.return %15 : vector<4xi32> + } + llvm.func @computesignbits_through_two_input_shuffle(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi1>, %arg3: vector<4xi1>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sext %arg2 : vector<4xi1> to vector<4xi32> + %2 = llvm.sext %arg3 : vector<4xi1> to vector<4xi32> + %3 = llvm.shufflevector %1, %2 [0, 2, 4, 6] : vector<4xi32> + %4 = llvm.xor %3, %0 : vector<4xi32> + %5 = llvm.and %4, %arg0 : vector<4xi32> + %6 = llvm.and %3, %arg1 : vector<4xi32> + %7 = llvm.or %5, %6 : vector<4xi32> + llvm.return %7 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/logical-select.ll.mlir b/test/LLVMDialect/InstCombine/logical-select.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/low-bit-splat.ll.mlir b/test/LLVMDialect/InstCombine/low-bit-splat.ll.mlir new file mode 100644 index 000000000..a2fc48b6a --- /dev/null +++ b/test/LLVMDialect/InstCombine/low-bit-splat.ll.mlir @@ -0,0 +1,121 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @t0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + %2 = llvm.ashr %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @t1_otherbitwidth(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(15 : i16) : i16 + %1 = llvm.shl %arg0, %0 : i16 + %2 = llvm.ashr %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @t2_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %1 = llvm.shl %arg0, %0 : vector<2xi8> + %2 = llvm.ashr %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @t3_vec_poison0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<7> : vector<3xi8>) : vector<3xi8> + %10 = llvm.shl %arg0, %8 : vector<3xi8> + %11 = llvm.ashr %10, %9 : vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @t4_vec_poison1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<7> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.shl %arg0, %0 : vector<3xi8> + %11 = llvm.ashr %10, %9 : vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @t5_vec_poison2(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.shl %arg0, %8 : vector<3xi8> + %10 = llvm.ashr %9, %8 : vector<3xi8> + llvm.return %10 : vector<3xi8> + } + llvm.func @n6_extrause(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.ashr %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @t7_already_masked(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.shl %2, %1 : i8 + %4 = llvm.ashr %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @t8_already_masked_extrause(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.shl %2, %1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.ashr %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @n9_wrongly_masked_extrause(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.shl %2, %1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.ashr %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @n10(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.ashr %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @n11(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.ashr %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @n12(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + %2 = llvm.ashr %1, %0 : i8 + llvm.return %2 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/lower-dbg-declare.ll.mlir b/test/LLVMDialect/InstCombine/lower-dbg-declare.ll.mlir new file mode 100644 index 000000000..50175e19e --- /dev/null +++ b/test/LLVMDialect/InstCombine/lower-dbg-declare.ll.mlir @@ -0,0 +1,48 @@ +#di_basic_type = #llvm.di_basic_type +#di_file = #llvm.di_file<"lower-dbg-declare.cpp" in ""> +#loc = loc("lower-dbg-declare.cpp":7:0) +#loc1 = loc("lower-dbg-declare.cpp":8:0) +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C_plus_plus, file = #di_file, producer = "clang", isOptimized = true, emissionKind = Full> +#di_derived_type = #llvm.di_derived_type +#di_subroutine_type = #llvm.di_subroutine_type +#di_global_variable = #llvm.di_global_variable +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "main", file = #di_file, line = 5, scopeLine = 5, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#di_global_variable_expression = #llvm.di_global_variable_expression> +#di_local_variable = #llvm.di_local_variable +#loc2 = loc(fused<#di_subprogram>[#loc]) +#loc3 = loc(fused<#di_subprogram>[#loc1]) +#loop_annotation = #llvm.loop_annotation +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.mlir.global internal @_ZL4sink(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64, dbg_expr = #di_global_variable_expression, dso_local} : i32 + llvm.func @main() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %5 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.dbg.declare #di_local_variable = %5 : !llvm.ptr + llvm.store %1, %4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.intr.lifetime.start 4, %5 : !llvm.ptr + llvm.store %2, %5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb2 + %6 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + %7 = llvm.call @_ZL5emptyi(%6) : (i32) -> i1 + %8 = llvm.xor %7, %3 : i1 + llvm.cond_br %8, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.call @_ZL6escapeRi(%5) : (!llvm.ptr) -> () + llvm.br ^bb1 {loop_annotation = #loop_annotation} + ^bb3: // pred: ^bb1 + llvm.intr.lifetime.end 4, %5 : !llvm.ptr + llvm.return %1 : i32 + } + llvm.func internal @_ZL5emptyi(%arg0: i32) -> (i1 {llvm.zeroext}) attributes {dso_local} { + %0 = llvm.mlir.constant(false) : i1 + llvm.return %0 : i1 + } + llvm.func internal @_ZL6escapeRi(%arg0: !llvm.ptr {llvm.dereferenceable = 4 : i64}) attributes {dso_local} { + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/lshr-and-negC-icmpeq-zero.ll.mlir b/test/LLVMDialect/InstCombine/lshr-and-negC-icmpeq-zero.ll.mlir new file mode 100644 index 000000000..8a70a5516 --- /dev/null +++ b/test/LLVMDialect/InstCombine/lshr-and-negC-icmpeq-zero.ll.mlir @@ -0,0 +1,206 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @scalar_i8_lshr_and_negC_eq(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-4 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %arg0, %arg1 : i8 + %3 = llvm.and %2, %0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @scalar_i16_lshr_and_negC_eq(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(-128 : i16) : i16 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.lshr %arg0, %arg1 : i16 + %3 = llvm.and %2, %0 : i16 + %4 = llvm.icmp "eq" %3, %1 : i16 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_lshr_and_negC_eq(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-262144 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @scalar_i64_lshr_and_negC_eq(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(-8589934592 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.lshr %arg0, %arg1 : i64 + %3 = llvm.and %2, %0 : i64 + %4 = llvm.icmp "eq" %3, %1 : i64 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_lshr_and_negC_ne(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-262144 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @vec_4xi32_lshr_and_negC_eq(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<-8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %3 = llvm.lshr %arg0, %arg1 : vector<4xi32> + %4 = llvm.and %3, %0 : vector<4xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<4xi32> + llvm.return %5 : vector<4xi1> + } + llvm.func @vec_lshr_and_negC_eq_poison1(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %13 = llvm.lshr %arg0, %arg1 : vector<4xi32> + %14 = llvm.and %13, %10 : vector<4xi32> + %15 = llvm.icmp "eq" %14, %12 : vector<4xi32> + llvm.return %15 : vector<4xi1> + } + llvm.func @vec_lshr_and_negC_eq_poison2(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<-8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %2, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<4xi32> + %12 = llvm.lshr %arg0, %arg1 : vector<4xi32> + %13 = llvm.and %12, %0 : vector<4xi32> + %14 = llvm.icmp "eq" %13, %11 : vector<4xi32> + llvm.return %14 : vector<4xi1> + } + llvm.func @vec_lshr_and_negC_eq_poison3(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.mlir.undef : vector<4xi32> + %13 = llvm.mlir.constant(0 : i32) : i32 + %14 = llvm.insertelement %11, %12[%13 : i32] : vector<4xi32> + %15 = llvm.mlir.constant(1 : i32) : i32 + %16 = llvm.insertelement %11, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(2 : i32) : i32 + %18 = llvm.insertelement %11, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(3 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.lshr %arg0, %arg1 : vector<4xi32> + %22 = llvm.and %21, %10 : vector<4xi32> + %23 = llvm.icmp "eq" %22, %20 : vector<4xi32> + llvm.return %23 : vector<4xi1> + } + llvm.func @scalar_lshr_and_negC_eq_extra_use_lshr(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.xor %2, %arg2 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.and %2, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_lshr_and_negC_eq_extra_use_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.mul %3, %arg2 : i32 + llvm.store %4, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_lshr_and_negC_eq_extra_use_lshr_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr, %arg4: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.add %2, %arg2 : i32 + llvm.store %4, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_lshr_and_negC_eq_X_is_constant1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12345 : i32) : i32 + %1 = llvm.mlir.constant(-8 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_lshr_and_negC_eq_X_is_constant2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(268435456 : i32) : i32 + %1 = llvm.mlir.constant(-8 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_udiv_and_negC_eq_X_is_constant3(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12345 : i32) : i32 + %1 = llvm.mlir.constant(16376 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.udiv %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "ne" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_lshr_and_negC_eq_X_is_constant_negative(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(16384 : i32) : i32 + %1 = llvm.mlir.constant(16376 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_lshr_and_negC_slt(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_lshr_and_negC_eq_nonzero(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @scalar_i8_lshr_and_negC_eq_not_negatedPowerOf2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-3 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %arg0, %arg1 : i8 + %3 = llvm.and %2, %0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/lshr-and-signbit-icmpeq-zero.ll.mlir b/test/LLVMDialect/InstCombine/lshr-and-signbit-icmpeq-zero.ll.mlir new file mode 100644 index 000000000..61427be12 --- /dev/null +++ b/test/LLVMDialect/InstCombine/lshr-and-signbit-icmpeq-zero.ll.mlir @@ -0,0 +1,179 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @scalar_i8_lshr_and_signbit_eq(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %arg0, %arg1 : i8 + %3 = llvm.and %2, %0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @scalar_i16_lshr_and_signbit_eq(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(-32768 : i16) : i16 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.lshr %arg0, %arg1 : i16 + %3 = llvm.and %2, %0 : i16 + %4 = llvm.icmp "eq" %3, %1 : i16 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_lshr_and_signbit_eq(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @scalar_i64_lshr_and_signbit_eq(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.lshr %arg0, %arg1 : i64 + %3 = llvm.and %2, %0 : i64 + %4 = llvm.icmp "eq" %3, %1 : i64 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_lshr_and_signbit_ne(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @vec_4xi32_lshr_and_signbit_eq(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %3 = llvm.lshr %arg0, %arg1 : vector<4xi32> + %4 = llvm.and %3, %0 : vector<4xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<4xi32> + llvm.return %5 : vector<4xi1> + } + llvm.func @vec_4xi32_lshr_and_signbit_eq_poison1(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %13 = llvm.lshr %arg0, %arg1 : vector<4xi32> + %14 = llvm.and %13, %10 : vector<4xi32> + %15 = llvm.icmp "eq" %14, %12 : vector<4xi32> + llvm.return %15 : vector<4xi1> + } + llvm.func @vec_4xi32_lshr_and_signbit_eq_poison2(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<4xi32> + %12 = llvm.lshr %arg0, %arg1 : vector<4xi32> + %13 = llvm.and %12, %0 : vector<4xi32> + %14 = llvm.icmp "eq" %13, %11 : vector<4xi32> + llvm.return %14 : vector<4xi1> + } + llvm.func @vec_4xi32_lshr_and_signbit_eq_poison3(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.mlir.undef : vector<4xi32> + %13 = llvm.mlir.constant(0 : i32) : i32 + %14 = llvm.insertelement %11, %12[%13 : i32] : vector<4xi32> + %15 = llvm.mlir.constant(1 : i32) : i32 + %16 = llvm.insertelement %11, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(2 : i32) : i32 + %18 = llvm.insertelement %11, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(3 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.lshr %arg0, %arg1 : vector<4xi32> + %22 = llvm.and %21, %10 : vector<4xi32> + %23 = llvm.icmp "eq" %22, %20 : vector<4xi32> + llvm.return %23 : vector<4xi1> + } + llvm.func @scalar_lshr_and_signbit_eq_extra_use_lshr(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.xor %2, %arg2 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.and %2, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_lshr_and_signbit_eq_extra_use_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.mul %3, %arg2 : i32 + llvm.store %4, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_lshr_and_signbit_eq_extra_use_lshr_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr, %arg4: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.add %2, %arg2 : i32 + llvm.store %4, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_lshr_and_signbit_eq_X_is_constant1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12345 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_lshr_and_negC_eq_X_is_constant2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %0, %arg0 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_lshr_and_negC_slt(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_lshr_and_negC_eq_nonzero(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/lshr-phi.ll.mlir b/test/LLVMDialect/InstCombine/lshr-phi.ll.mlir index 9ba051d97..b88db7764 100644 --- a/test/LLVMDialect/InstCombine/lshr-phi.ll.mlir +++ b/test/LLVMDialect/InstCombine/lshr-phi.ll.mlir @@ -1,32 +1,30 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 16383 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 14 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %7 = "llvm.load"(%arg0) : (!llvm.ptr) -> i8 - %8 = "llvm.icmp"(%7, %6) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.cond_br"(%8, %5, %4, %5)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 1, 2]> : vector<3xi32>} : (i1, i32, i64, i32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @hash_string(%arg0: !llvm.ptr {llvm.nocapture}) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(14 : i32) : i32 + %5 = llvm.mlir.constant(16383 : i32) : i32 + %6 = llvm.mlir.constant(1 : i64) : i64 + %7 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %8 = llvm.icmp "eq" %7, %0 : i8 + llvm.cond_br %8, ^bb2(%1 : i32), ^bb1(%2, %1 : i64, i32) ^bb1(%9: i64, %10: i32): // 2 preds: ^bb0, ^bb1 - %11 = "llvm.getelementptr"(%arg0, %9) : (!llvm.ptr, i64) -> !llvm.ptr - %12 = "llvm.shl"(%10, %3) : (i32, i32) -> i32 - %13 = "llvm.lshr"(%10, %2) : (i32, i32) -> i32 - %14 = "llvm.add"(%12, %13) : (i32, i32) -> i32 - %15 = "llvm.load"(%11) : (!llvm.ptr) -> i8 - %16 = "llvm.sext"(%15) : (i8) -> i32 - %17 = "llvm.xor"(%16, %14) : (i32, i32) -> i32 - %18 = "llvm.and"(%17, %1) : (i32, i32) -> i32 - %19 = "llvm.add"(%9, %0) : (i64, i64) -> i64 - %20 = "llvm.getelementptr"(%arg0, %19) : (!llvm.ptr, i64) -> !llvm.ptr - %21 = "llvm.load"(%20) : (!llvm.ptr) -> i8 - %22 = "llvm.icmp"(%21, %6) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.cond_br"(%22, %18, %19, %18)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 1, 2]> : vector<3xi32>} : (i1, i32, i64, i32) -> () + %11 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %12 = llvm.shl %10, %3 : i32 + %13 = llvm.lshr %10, %4 : i32 + %14 = llvm.add %12, %13 : i32 + %15 = llvm.load %11 {alignment = 1 : i64} : !llvm.ptr -> i8 + %16 = llvm.sext %15 : i8 to i32 + %17 = llvm.xor %16, %14 : i32 + %18 = llvm.and %17, %5 : i32 + %19 = llvm.add %9, %6 : i64 + %20 = llvm.getelementptr %arg0[%19] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %21 = llvm.load %20 {alignment = 1 : i64} : !llvm.ptr -> i8 + %22 = llvm.icmp "eq" %21, %0 : i8 + llvm.cond_br %22, ^bb2(%18 : i32), ^bb1(%19, %18 : i64, i32) ^bb2(%23: i32): // 2 preds: ^bb0, ^bb1 - "llvm.return"(%23) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "hash_string", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %23 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/lshr-trunc-sext-to-ashr-sext.ll.mlir b/test/LLVMDialect/InstCombine/lshr-trunc-sext-to-ashr-sext.ll.mlir new file mode 100644 index 000000000..b6e2a8bc0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/lshr-trunc-sext-to-ashr-sext.ll.mlir @@ -0,0 +1,169 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @use8(i8) + llvm.func @use4(i4) + llvm.func @usevec8(vector<2xi8>) + llvm.func @usevec4(vector<2xi4>) + llvm.func @t0(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.trunc %1 : i8 to i4 + %3 = llvm.sext %2 : i4 to i16 + llvm.return %3 : i16 + } + llvm.func @t1(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.trunc %1 : i8 to i3 + %3 = llvm.sext %2 : i3 to i16 + llvm.return %3 : i16 + } + llvm.func @t2(%arg0: i7) -> i16 { + %0 = llvm.mlir.constant(3 : i7) : i7 + %1 = llvm.lshr %arg0, %0 : i7 + %2 = llvm.trunc %1 : i7 to i4 + %3 = llvm.sext %2 : i4 to i16 + llvm.return %3 : i16 + } + llvm.func @n3(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.trunc %1 : i8 to i4 + %3 = llvm.sext %2 : i4 to i16 + llvm.return %3 : i16 + } + llvm.func @t4_vec_splat(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi8>) : vector<2xi8> + %1 = llvm.lshr %arg0, %0 : vector<2xi8> + %2 = llvm.trunc %1 : vector<2xi8> to vector<2xi4> + %3 = llvm.sext %2 : vector<2xi4> to vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @t5_vec_poison(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.lshr %arg0, %6 : vector<2xi8> + %8 = llvm.trunc %7 : vector<2xi8> to vector<2xi4> + %9 = llvm.sext %8 : vector<2xi4> to vector<2xi16> + llvm.return %9 : vector<2xi16> + } + llvm.func @t6_extrause0(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.trunc %1 : i8 to i4 + llvm.call @use4(%2) : (i4) -> () + %3 = llvm.sext %2 : i4 to i16 + llvm.return %3 : i16 + } + llvm.func @t7_extrause0_vec_poison(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.lshr %arg0, %6 : vector<2xi8> + %8 = llvm.trunc %7 : vector<2xi8> to vector<2xi4> + llvm.call @usevec4(%8) : (vector<2xi4>) -> () + %9 = llvm.sext %8 : vector<2xi4> to vector<2xi16> + llvm.return %9 : vector<2xi16> + } + llvm.func @t8_extrause1(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.trunc %1 : i8 to i4 + %3 = llvm.sext %2 : i4 to i16 + llvm.return %3 : i16 + } + llvm.func @t9_extrause1_vec_poison(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.lshr %arg0, %6 : vector<2xi8> + llvm.call @usevec8(%7) : (vector<2xi8>) -> () + %8 = llvm.trunc %7 : vector<2xi8> to vector<2xi4> + %9 = llvm.sext %8 : vector<2xi4> to vector<2xi16> + llvm.return %9 : vector<2xi16> + } + llvm.func @t10_extrause2(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.trunc %1 : i8 to i4 + llvm.call @use4(%2) : (i4) -> () + %3 = llvm.sext %2 : i4 to i16 + llvm.return %3 : i16 + } + llvm.func @t11_extrause2_vec_poison(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.lshr %arg0, %6 : vector<2xi8> + llvm.call @usevec8(%7) : (vector<2xi8>) -> () + %8 = llvm.trunc %7 : vector<2xi8> to vector<2xi4> + llvm.call @usevec4(%8) : (vector<2xi4>) -> () + %9 = llvm.sext %8 : vector<2xi4> to vector<2xi16> + llvm.return %9 : vector<2xi16> + } + llvm.func @wide_source_shifted_signbit(%arg0: vector<2xi32>) -> vector<2xi10> { + %0 = llvm.mlir.constant(dense<24> : vector<2xi32>) : vector<2xi32> + %1 = llvm.lshr %arg0, %0 : vector<2xi32> + %2 = llvm.trunc %1 : vector<2xi32> to vector<2xi8> + %3 = llvm.sext %2 : vector<2xi8> to vector<2xi10> + llvm.return %3 : vector<2xi10> + } + llvm.func @wide_source_shifted_signbit_use1(%arg0: i32) -> i10 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.trunc %1 : i32 to i8 + %3 = llvm.sext %2 : i8 to i10 + llvm.return %3 : i10 + } + llvm.func @wide_source_shifted_signbit_use2(%arg0: i32) -> i10 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.trunc %1 : i32 to i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sext %2 : i8 to i10 + llvm.return %3 : i10 + } + llvm.func @same_source_shifted_signbit(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.trunc %1 : i32 to i8 + %3 = llvm.sext %2 : i8 to i32 + llvm.return %3 : i32 + } + llvm.func @same_source_shifted_signbit_use1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.trunc %1 : i32 to i8 + %3 = llvm.sext %2 : i8 to i32 + llvm.return %3 : i32 + } + llvm.func @same_source_shifted_signbit_use2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.trunc %1 : i32 to i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sext %2 : i8 to i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/lshr.ll.mlir b/test/LLVMDialect/InstCombine/lshr.ll.mlir new file mode 100644 index 000000000..a17ac1b29 --- /dev/null +++ b/test/LLVMDialect/InstCombine/lshr.ll.mlir @@ -0,0 +1,858 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @usevec(vector<3xi14>) + llvm.func @lshr_ctlz_zero_is_not_undef(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @lshr_cttz_zero_is_not_undef(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @lshr_ctpop(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @lshr_ctlz_zero_is_not_undef_splat_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = false}> : (vector<2xi8>) -> vector<2xi8> + %2 = llvm.lshr %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @lshr_cttz_zero_is_not_undef_splat_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (vector<2xi8>) -> vector<2xi8> + %2 = llvm.lshr %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @lshr_ctpop_splat_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.intr.ctpop(%arg0) : (vector<2xi8>) -> vector<2xi8> + %2 = llvm.lshr %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @lshr_ctlz_zero_is_undef(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @lshr_cttz_zero_is_undef(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @lshr_ctlz_zero_is_undef_splat_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (vector<2xi8>) -> vector<2xi8> + %2 = llvm.lshr %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @lshr_ctlz_zero_is_undef_vec(%arg0: vector<2xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<[3, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (vector<2xi8>) -> vector<2xi8> + %3 = llvm.lshr %2, %0 : vector<2xi8> + %4 = llvm.extractelement %3[%1 : i32] : vector<2xi8> + llvm.return %4 : i8 + } + llvm.func @lshr_cttz_zero_is_undef_splat_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = true}> : (vector<2xi8>) -> vector<2xi8> + %2 = llvm.lshr %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @lshr_cttz_zero_is_undef_vec(%arg0: vector<2xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<[3, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = true}> : (vector<2xi8>) -> vector<2xi8> + %3 = llvm.lshr %2, %0 : vector<2xi8> + %4 = llvm.extractelement %3[%1 : i32] : vector<2xi8> + llvm.return %4 : i8 + } + llvm.func @lshr_exact(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.add %2, %1 : i8 + %4 = llvm.lshr %3, %0 : i8 + llvm.return %4 : i8 + } + llvm.func @lshr_exact_splat_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<4> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.add %2, %1 : vector<2xi8> + %4 = llvm.lshr %3, %0 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @lshr_exact_splat_vec_nuw(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<4> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 overflow : vector<2xi8> + %3 = llvm.add %2, %1 overflow : vector<2xi8> + %4 = llvm.lshr %3, %0 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @shl_add(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.shl %arg0, %0 : i8 + %2 = llvm.add %1, %arg1 : i8 + %3 = llvm.lshr %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @shl_add_commute_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mul %arg1, %arg1 : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.add %1, %2 : vector<2xi8> + %4 = llvm.lshr %3, %0 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @shl_add_use1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.shl %arg0, %0 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.add %1, %arg1 : i32 + %3 = llvm.lshr %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_add_use2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.shl %arg0, %0 : i32 + %2 = llvm.add %1, %arg1 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.lshr %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @bool_zext(%arg0: i1) -> i16 { + %0 = llvm.mlir.constant(15 : i16) : i16 + %1 = llvm.sext %arg0 : i1 to i16 + %2 = llvm.lshr %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @bool_zext_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @bool_zext_splat(%arg0: vector<2xi1>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sext %arg0 : vector<2xi1> to vector<2xi8> + %2 = llvm.lshr %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @smear_sign_and_widen(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @smear_sign_and_widen_should_not_change_type(%arg0: i4) -> i16 { + %0 = llvm.mlir.constant(12 : i16) : i16 + %1 = llvm.sext %arg0 : i4 to i16 + %2 = llvm.lshr %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @smear_sign_and_widen_splat(%arg0: vector<2xi6>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sext %arg0 : vector<2xi6> to vector<2xi8> + %2 = llvm.lshr %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @fake_sext(%arg0: i3) -> i18 { + %0 = llvm.mlir.constant(17 : i18) : i18 + %1 = llvm.sext %arg0 : i3 to i18 + %2 = llvm.lshr %1, %0 : i18 + llvm.return %2 : i18 + } + llvm.func @fake_sext_but_should_not_change_type(%arg0: i3) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sext %arg0 : i3 to i32 + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @fake_sext_splat(%arg0: vector<2xi3>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sext %arg0 : vector<2xi3> to vector<2xi8> + %2 = llvm.lshr %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @narrow_lshr_constant(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @mul_splat_fold(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(65537 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @mul_splat_fold_vec(%arg0: vector<3xi14>) -> vector<3xi14> { + %0 = llvm.mlir.constant(129 : i14) : i14 + %1 = llvm.mlir.constant(dense<129> : vector<3xi14>) : vector<3xi14> + %2 = llvm.mlir.constant(7 : i14) : i14 + %3 = llvm.mlir.constant(dense<7> : vector<3xi14>) : vector<3xi14> + %4 = llvm.mul %arg0, %1 overflow : vector<3xi14> + llvm.call @usevec(%4) : (vector<3xi14>) -> () + %5 = llvm.lshr %4, %3 : vector<3xi14> + llvm.return %5 : vector<3xi14> + } + llvm.func @shl_add_lshr_flag_preservation(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.add %0, %arg2 overflow : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_add_lshr(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.add %0, %arg2 overflow : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_add_lshr_comm(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.mul %arg2, %arg2 : i32 + %2 = llvm.add %1, %0 overflow : i32 + %3 = llvm.lshr %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_add_lshr_no_nuw(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.add %0, %arg2 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_sub_lshr_not_exact(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.sub %0, %arg2 overflow : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_sub_lshr_no_nuw(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.sub %0, %arg2 overflow : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_sub_lshr(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.sub %0, %arg2 overflow : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_sub_lshr_reverse(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.sub %arg2, %0 overflow : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_sub_lshr_reverse_no_nsw(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.sub %arg2, %0 overflow : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_sub_lshr_reverse_nsw_on_op1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.sub %arg2, %0 overflow : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_sub_lshr_reverse_no_exact(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.sub %arg2, %0 overflow : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_sub_lshr_reverse_multiuse(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.sub %arg2, %0 overflow : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_sub_lshr_reverse_multiuse2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.sub %arg2, %0 overflow : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_sub_lshr_reverse_no_nuw(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.sub %arg2, %0 overflow : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_sub_lshr_reverse_no_nsw_2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.sub %arg2, %0 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_or_lshr(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.or %0, %arg2 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_or_disjoint_lshr(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.or %0, %arg2 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_or_lshr_comm(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.or %arg2, %0 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_or_disjoint_lshr_comm(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.or %arg2, %0 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_xor_lshr(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.xor %0, %arg2 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_xor_lshr_comm(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.xor %arg2, %0 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_and_lshr(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.and %0, %arg2 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_and_lshr_comm(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.and %arg2, %0 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_lshr_and_exact(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.and %0, %arg2 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @shl_add_lshr_neg(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.add %0, %arg2 overflow : i32 + %2 = llvm.lshr %1, %arg2 : i32 + llvm.return %2 : i32 + } + llvm.func @mul_splat_fold_wrong_mul_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(65538 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_add_lshr_multiuse(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 overflow : i32 + %1 = llvm.add %0, %arg2 overflow : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.lshr %1, %arg2 : i32 + llvm.return %2 : i32 + } + llvm.func @mul_splat_fold_wrong_lshr_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(65537 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @mul_splat_fold_no_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(65537 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @mul_splat_fold_no_flags(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(65537 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @mul_splat_fold_too_narrow(%arg0: i2) -> i2 { + %0 = llvm.mlir.constant(-2 : i2) : i2 + %1 = llvm.mlir.constant(1 : i2) : i2 + %2 = llvm.mul %arg0, %0 overflow : i2 + %3 = llvm.lshr %2, %1 : i2 + llvm.return %3 : i2 + } + llvm.func @negative_and_odd(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @negative_and_odd_vec(%arg0: vector<2xi7>) -> vector<2xi7> { + %0 = llvm.mlir.constant(2 : i7) : i7 + %1 = llvm.mlir.constant(dense<2> : vector<2xi7>) : vector<2xi7> + %2 = llvm.mlir.constant(6 : i7) : i7 + %3 = llvm.mlir.constant(dense<6> : vector<2xi7>) : vector<2xi7> + %4 = llvm.srem %arg0, %1 : vector<2xi7> + %5 = llvm.lshr %4, %3 : vector<2xi7> + llvm.return %5 : vector<2xi7> + } + llvm.func @negative_and_odd_uses(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + llvm.store %2, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @srem3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @srem2_lshr30(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @trunc_sandwich(%arg0: i32) -> i12 { + %0 = llvm.mlir.constant(28 : i32) : i32 + %1 = llvm.mlir.constant(2 : i12) : i12 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i12 + %4 = llvm.lshr %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @trunc_sandwich_splat_vec(%arg0: vector<2xi32>) -> vector<2xi12> { + %0 = llvm.mlir.constant(dense<22> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(8 : i12) : i12 + %2 = llvm.mlir.constant(dense<8> : vector<2xi12>) : vector<2xi12> + %3 = llvm.lshr %arg0, %0 : vector<2xi32> + %4 = llvm.trunc %3 : vector<2xi32> to vector<2xi12> + %5 = llvm.lshr %4, %2 : vector<2xi12> + llvm.return %5 : vector<2xi12> + } + llvm.func @trunc_sandwich_min_shift1(%arg0: i32) -> i12 { + %0 = llvm.mlir.constant(20 : i32) : i32 + %1 = llvm.mlir.constant(1 : i12) : i12 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i12 + %4 = llvm.lshr %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @trunc_sandwich_small_shift1(%arg0: i32) -> i12 { + %0 = llvm.mlir.constant(19 : i32) : i32 + %1 = llvm.mlir.constant(1 : i12) : i12 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i12 + %4 = llvm.lshr %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @trunc_sandwich_max_sum_shift(%arg0: i32) -> i12 { + %0 = llvm.mlir.constant(20 : i32) : i32 + %1 = llvm.mlir.constant(11 : i12) : i12 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i12 + %4 = llvm.lshr %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @trunc_sandwich_max_sum_shift2(%arg0: i32) -> i12 { + %0 = llvm.mlir.constant(30 : i32) : i32 + %1 = llvm.mlir.constant(1 : i12) : i12 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i12 + %4 = llvm.lshr %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @trunc_sandwich_big_sum_shift1(%arg0: i32) -> i12 { + %0 = llvm.mlir.constant(21 : i32) : i32 + %1 = llvm.mlir.constant(11 : i12) : i12 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i12 + %4 = llvm.lshr %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @trunc_sandwich_big_sum_shift2(%arg0: i32) -> i12 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i12) : i12 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i12 + %4 = llvm.lshr %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @trunc_sandwich_use1(%arg0: i32) -> i12 { + %0 = llvm.mlir.constant(28 : i32) : i32 + %1 = llvm.mlir.constant(2 : i12) : i12 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i12 + %4 = llvm.lshr %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @trunc_sandwich_splat_vec_use1(%arg0: vector<3xi14>) -> vector<3xi9> { + %0 = llvm.mlir.constant(6 : i14) : i14 + %1 = llvm.mlir.constant(dense<6> : vector<3xi14>) : vector<3xi14> + %2 = llvm.mlir.constant(5 : i9) : i9 + %3 = llvm.mlir.constant(dense<5> : vector<3xi9>) : vector<3xi9> + %4 = llvm.lshr %arg0, %1 : vector<3xi14> + llvm.call @usevec(%4) : (vector<3xi14>) -> () + %5 = llvm.trunc %4 : vector<3xi14> to vector<3xi9> + %6 = llvm.lshr %5, %3 : vector<3xi9> + llvm.return %6 : vector<3xi9> + } + llvm.func @trunc_sandwich_min_shift1_use1(%arg0: i32) -> i12 { + %0 = llvm.mlir.constant(20 : i32) : i32 + %1 = llvm.mlir.constant(1 : i12) : i12 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i12 + %4 = llvm.lshr %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @trunc_sandwich_small_shift1_use1(%arg0: i32) -> i12 { + %0 = llvm.mlir.constant(19 : i32) : i32 + %1 = llvm.mlir.constant(1 : i12) : i12 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i12 + %4 = llvm.lshr %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @trunc_sandwich_max_sum_shift_use1(%arg0: i32) -> i12 { + %0 = llvm.mlir.constant(20 : i32) : i32 + %1 = llvm.mlir.constant(11 : i12) : i12 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i12 + %4 = llvm.lshr %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @trunc_sandwich_max_sum_shift2_use1(%arg0: i32) -> i12 { + %0 = llvm.mlir.constant(30 : i32) : i32 + %1 = llvm.mlir.constant(1 : i12) : i12 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i12 + %4 = llvm.lshr %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @trunc_sandwich_big_sum_shift1_use1(%arg0: i32) -> i12 { + %0 = llvm.mlir.constant(21 : i32) : i32 + %1 = llvm.mlir.constant(11 : i12) : i12 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i12 + %4 = llvm.lshr %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @trunc_sandwich_big_sum_shift2_use1(%arg0: i32) -> i12 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i12) : i12 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i12 + %4 = llvm.lshr %3, %1 : i12 + llvm.return %4 : i12 + } + llvm.func @lshr_sext_i1_to_i16(%arg0: i1) -> i16 { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = llvm.sext %arg0 : i1 to i16 + %2 = llvm.lshr %1, %0 : i16 + llvm.return %2 : i16 + } + llvm.func @lshr_sext_i1_to_i128(%arg0: i1) -> i128 { + %0 = llvm.mlir.constant(42 : i128) : i128 + %1 = llvm.sext %arg0 : i1 to i128 + %2 = llvm.lshr %1, %0 : i128 + llvm.return %2 : i128 + } + llvm.func @lshr_sext_i1_to_i32_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.lshr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @lshr_sext_i1_to_i14_splat_vec_use1(%arg0: vector<3xi1>) -> vector<3xi14> { + %0 = llvm.mlir.constant(4 : i14) : i14 + %1 = llvm.mlir.constant(dense<4> : vector<3xi14>) : vector<3xi14> + %2 = llvm.sext %arg0 : vector<3xi1> to vector<3xi14> + llvm.call @usevec(%2) : (vector<3xi14>) -> () + %3 = llvm.lshr %2, %1 : vector<3xi14> + llvm.return %3 : vector<3xi14> + } + llvm.func @icmp_ule(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.lshr %arg0, %arg1 : i32 + %1 = llvm.icmp "ule" %0, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @icmp_ult(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.lshr %arg0, %arg1 : i32 + %1 = llvm.icmp "ult" %0, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @icmp_eq(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.lshr %arg0, %arg1 : i32 + %1 = llvm.icmp "eq" %0, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @icmp_ne(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.lshr %arg0, %arg1 : i32 + %1 = llvm.icmp "ne" %0, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @icmp_ugt(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.lshr %arg0, %arg1 : i32 + %1 = llvm.icmp "ugt" %0, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @icmp_uge(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.lshr %arg0, %arg1 : i32 + %1 = llvm.icmp "uge" %0, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @icmp_sle(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.lshr %arg0, %arg1 : i32 + %1 = llvm.icmp "sle" %0, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @icmp_slt(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.lshr %arg0, %arg1 : i32 + %1 = llvm.icmp "slt" %0, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @icmp_sgt(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.lshr %arg0, %arg1 : i32 + %1 = llvm.icmp "sgt" %0, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @icmp_sge(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.lshr %arg0, %arg1 : i32 + %1 = llvm.icmp "sge" %0, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @narrow_bswap(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.intr.bswap(%1) : (i32) -> i32 + %3 = llvm.lshr %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @narrow_bswap_extra_wide(%arg0: i16) -> i128 { + %0 = llvm.mlir.constant(112 : i128) : i128 + %1 = llvm.zext %arg0 : i16 to i128 + %2 = llvm.intr.bswap(%1) : (i128) -> i128 + %3 = llvm.lshr %2, %0 : i128 + llvm.return %3 : i128 + } + llvm.func @narrow_bswap_undershift(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.intr.bswap(%1) : (i32) -> i32 + %3 = llvm.lshr %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @narrow_bswap_splat(%arg0: vector<2xi16>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<48> : vector<2xi64>) : vector<2xi64> + %1 = llvm.zext %arg0 : vector<2xi16> to vector<2xi64> + %2 = llvm.intr.bswap(%1) : (vector<2xi64>) -> vector<2xi64> + %3 = llvm.lshr %2, %0 : vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @narrow_bswap_splat_poison_elt(%arg0: vector<2xi16>) -> vector<2xi64> { + %0 = llvm.mlir.poison : i64 + %1 = llvm.mlir.constant(48 : i64) : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.zext %arg0 : vector<2xi16> to vector<2xi64> + %8 = llvm.intr.bswap(%7) : (vector<2xi64>) -> vector<2xi64> + %9 = llvm.lshr %8, %6 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @narrow_bswap_overshift(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<48> : vector<2xi64>) : vector<2xi64> + %1 = llvm.zext %arg0 : vector<2xi32> to vector<2xi64> + %2 = llvm.intr.bswap(%1) : (vector<2xi64>) -> vector<2xi64> + %3 = llvm.lshr %2, %0 : vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @narrow_bswap_overshift2(%arg0: i96) -> i128 { + %0 = llvm.mlir.constant(61 : i128) : i128 + %1 = llvm.zext %arg0 : i96 to i128 + %2 = llvm.intr.bswap(%1) : (i128) -> i128 + %3 = llvm.lshr %2, %0 : i128 + llvm.return %3 : i128 + } + llvm.func @not_narrow_bswap(%arg0: i24) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.zext %arg0 : i24 to i32 + %2 = llvm.intr.bswap(%1) : (i32) -> i32 + %3 = llvm.lshr %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @not_signbit(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.lshr %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_signbit_vec(%arg0: vector<2xi6>) -> vector<2xi6> { + %0 = llvm.mlir.poison : i6 + %1 = llvm.mlir.constant(-1 : i6) : i6 + %2 = llvm.mlir.undef : vector<2xi6> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi6> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi6> + %7 = llvm.mlir.constant(5 : i6) : i6 + %8 = llvm.mlir.undef : vector<2xi6> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi6> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi6> + %13 = llvm.xor %arg0, %6 : vector<2xi6> + %14 = llvm.lshr %13, %12 : vector<2xi6> + llvm.return %14 : vector<2xi6> + } + llvm.func @not_signbit_alt_xor(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.lshr %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_not_signbit(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.lshr %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_signbit_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @not_signbit_zext(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(-1 : i16) : i16 + %1 = llvm.mlir.constant(15 : i16) : i16 + %2 = llvm.xor %arg0, %0 : i16 + %3 = llvm.lshr %2, %1 : i16 + %4 = llvm.zext %3 : i16 to i32 + llvm.return %4 : i32 + } + llvm.func @not_signbit_trunc(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(-1 : i16) : i16 + %1 = llvm.mlir.constant(15 : i16) : i16 + %2 = llvm.xor %arg0, %0 : i16 + %3 = llvm.lshr %2, %1 : i16 + %4 = llvm.trunc %3 : i16 to i8 + llvm.return %4 : i8 + } + llvm.func @bool_add_lshr(%arg0: i1, %arg1: i1) -> i2 { + %0 = llvm.mlir.constant(1 : i2) : i2 + %1 = llvm.zext %arg0 : i1 to i2 + %2 = llvm.zext %arg1 : i1 to i2 + %3 = llvm.add %1, %2 : i2 + %4 = llvm.lshr %3, %0 : i2 + llvm.return %4 : i2 + } + llvm.func @not_bool_add_lshr(%arg0: i2, %arg1: i2) -> i4 { + %0 = llvm.mlir.constant(2 : i4) : i4 + %1 = llvm.zext %arg0 : i2 to i4 + %2 = llvm.zext %arg1 : i2 to i4 + %3 = llvm.add %1, %2 : i4 + %4 = llvm.lshr %3, %0 : i4 + llvm.return %4 : i4 + } + llvm.func @bool_add_ashr(%arg0: i1, %arg1: i1) -> i2 { + %0 = llvm.mlir.constant(1 : i2) : i2 + %1 = llvm.zext %arg0 : i1 to i2 + %2 = llvm.zext %arg1 : i1 to i2 + %3 = llvm.add %1, %2 : i2 + %4 = llvm.ashr %3, %0 : i2 + llvm.return %4 : i2 + } + llvm.func @bool_add_lshr_vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi8> + %2 = llvm.zext %arg1 : vector<2xi1> to vector<2xi8> + %3 = llvm.add %1, %2 : vector<2xi8> + %4 = llvm.lshr %3, %0 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @bool_add_lshr_uses(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.zext %arg1 : i1 to i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.add %1, %2 : i32 + %4 = llvm.lshr %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @bool_add_lshr_uses2(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.zext %arg1 : i1 to i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.add %1, %2 : i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.lshr %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @bool_add_lshr_uses3(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.zext %arg1 : i1 to i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.add %1, %2 : i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.lshr %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @bool_add_lshr_vec_wrong_shift_amt(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi8> + %2 = llvm.zext %arg1 : vector<2xi1> to vector<2xi8> + %3 = llvm.add %1, %2 : vector<2xi8> + %4 = llvm.lshr %3, %0 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/malloc-free-addrspace.ll.mlir b/test/LLVMDialect/InstCombine/malloc-free-addrspace.ll.mlir new file mode 100644 index 000000000..94b4e7e7e --- /dev/null +++ b/test/LLVMDialect/InstCombine/malloc-free-addrspace.ll.mlir @@ -0,0 +1,53 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<[128, 128, 128, 64]> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.alloca_memory_space", 200 : ui64>, #dlti.dl_entry<"dlti.program_memory_space", 200 : ui64>, #dlti.dl_entry<"dlti.global_memory_space", 200 : ui64>>} { + llvm.func @remove_malloc() -> i64 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr<200> + llvm.call @free(%2) : (!llvm.ptr<200>) -> () + llvm.return %1 : i64 + } + llvm.func @remove_calloc() -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(4 : i64) : i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.call @calloc(%0, %1) : (i64, i64) -> !llvm.ptr<200> + llvm.call @free(%3) : (!llvm.ptr<200>) -> () + llvm.return %2 : i64 + } + llvm.func @remove_aligned_alloc() -> i64 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.call @aligned_alloc(%0, %0) : (i64, i64) -> !llvm.ptr<200> + llvm.call @free(%2) : (!llvm.ptr<200>) -> () + llvm.return %1 : i64 + } + llvm.func @remove_strdup(%arg0: !llvm.ptr<200>) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @strdup(%arg0) : (!llvm.ptr<200>) -> !llvm.ptr<200> + llvm.call @free(%1) : (!llvm.ptr<200>) -> () + llvm.return %0 : i64 + } + llvm.func @remove_new(%arg0: !llvm.ptr<200>) -> i64 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.call @_Znwm(%0) : (i64) -> !llvm.ptr<200> + llvm.call @_ZdlPv(%2) : (!llvm.ptr<200>) -> () + llvm.return %1 : i64 + } + llvm.func @remove_new_array(%arg0: !llvm.ptr<200>) -> i64 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.call @_Znam(%0) : (i64) -> !llvm.ptr<200> + llvm.call @_ZdaPv(%2) : (!llvm.ptr<200>) -> () + llvm.return %1 : i64 + } + llvm.func @calloc(i64, i64) -> (!llvm.ptr<200> {llvm.noalias}) attributes {passthrough = ["nounwind", ["allockind", "17"], ["allocsize", "1"], ["alloc-family", "malloc"]]} + llvm.func @malloc(i64) -> (!llvm.ptr<200> {llvm.noalias}) attributes {passthrough = [["allockind", "9"], ["allocsize", "4294967295"], ["alloc-family", "malloc"]]} + llvm.func @aligned_alloc(i64, i64) -> (!llvm.ptr<200> {llvm.noalias}) attributes {passthrough = [["allockind", "41"], ["allocsize", "8589934591"], ["alloc-family", "malloc"]]} + llvm.func @strdup(!llvm.ptr<200>) -> (!llvm.ptr<200> {llvm.noalias}) + llvm.func @free(!llvm.ptr<200>) attributes {passthrough = [["allockind", "4"], ["alloc-family", "malloc"]]} + llvm.func @_Znwm(i64) -> (!llvm.ptr<200> {llvm.noalias}) + llvm.func @_ZdlPv(!llvm.ptr<200>) + llvm.func @_Znam(i64) -> (!llvm.ptr<200> {llvm.noalias}) + llvm.func @_ZdaPv(!llvm.ptr<200>) +} diff --git a/test/LLVMDialect/InstCombine/malloc-free-delete-dbginvar.ll.mlir b/test/LLVMDialect/InstCombine/malloc-free-delete-dbginvar.ll.mlir new file mode 100644 index 000000000..7292a73ff --- /dev/null +++ b/test/LLVMDialect/InstCombine/malloc-free-delete-dbginvar.ll.mlir @@ -0,0 +1,13 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @free(!llvm.ptr) + llvm.func @test12(%arg0: !llvm.ptr) attributes {passthrough = ["minsize"]} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + llvm.cond_br %1, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.call @free(%arg0) : (!llvm.ptr) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/malloc-free-mismatched.ll.mlir b/test/LLVMDialect/InstCombine/malloc-free-mismatched.ll.mlir new file mode 100644 index 000000000..4dba3ffe3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/malloc-free-mismatched.ll.mlir @@ -0,0 +1,17 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @_Z6answeri(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(80 : i64) : i64 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.call @_Znam(%0) : (i64) -> !llvm.ptr + llvm.call @free(%2) : (!llvm.ptr) -> () + llvm.return %1 : i32 + } + llvm.func @test_alloca() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.call @free(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @_Znam(i64) -> (!llvm.ptr {llvm.nonnull}) attributes {passthrough = ["nobuiltin", ["allockind", "9"], ["allocsize", "4294967295"], ["alloc-family", "_Znam"]]} + llvm.func @free(!llvm.ptr) attributes {passthrough = [["allockind", "4"], ["alloc-family", "malloc"]]} +} diff --git a/test/LLVMDialect/InstCombine/malloc-free.ll.mlir b/test/LLVMDialect/InstCombine/malloc-free.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/malloc_free_delete_nvptx.ll.mlir b/test/LLVMDialect/InstCombine/malloc_free_delete_nvptx.ll.mlir new file mode 100644 index 000000000..4f90e2f3d --- /dev/null +++ b/test/LLVMDialect/InstCombine/malloc_free_delete_nvptx.ll.mlir @@ -0,0 +1,20 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @user(!llvm.ptr) + llvm.func @malloc(i64) -> !llvm.ptr attributes {passthrough = [["allockind", "9"], ["allocsize", "4294967295"], ["alloc-family", "malloc"]]} + llvm.func @free(!llvm.ptr) attributes {passthrough = [["allockind", "4"], ["alloc-family", "malloc"]]} + llvm.func @malloc_then_free_not_needed() { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + llvm.store %1, %2 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.call @free(%2) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @malloc_then_free_needed() { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr + llvm.call @user(%1) : (!llvm.ptr) -> () + llvm.call @free(%1) : (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/masked-merge-add.ll.mlir b/test/LLVMDialect/InstCombine/masked-merge-add.ll.mlir new file mode 100644 index 000000000..8e279eb53 --- /dev/null +++ b/test/LLVMDialect/InstCombine/masked-merge-add.ll.mlir @@ -0,0 +1,266 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg2 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.add %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_splatvec(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32> {llvm.noundef}) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg0, %arg2 : vector<2xi32> + %2 = llvm.xor %arg2, %0 : vector<2xi32> + %3 = llvm.and %2, %arg1 : vector<2xi32> + %4 = llvm.add %1, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_vec_undef(%arg0: vector<3xi32>, %arg1: vector<3xi32>, %arg2: vector<3xi32> {llvm.noundef}) -> vector<3xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.and %arg0, %arg2 : vector<3xi32> + %10 = llvm.xor %arg2, %8 : vector<3xi32> + %11 = llvm.and %10, %arg1 : vector<3xi32> + %12 = llvm.add %9, %11 : vector<3xi32> + llvm.return %12 : vector<3xi32> + } + llvm.func @p_vec_poison(%arg0: vector<3xi32>, %arg1: vector<3xi32>, %arg2: vector<3xi32> {llvm.noundef}) -> vector<3xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.and %arg0, %arg2 : vector<3xi32> + %10 = llvm.xor %arg2, %8 : vector<3xi32> + %11 = llvm.and %10, %arg1 : vector<3xi32> + %12 = llvm.add %9, %11 : vector<3xi32> + llvm.return %12 : vector<3xi32> + } + llvm.func @p_constmask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.constant(-65281 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_constmask_splatvec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<65280> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-65281> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg1, %1 : vector<2xi32> + %4 = llvm.add %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_constmask_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[65280, 16776960]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-65281, -16776961]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg1, %1 : vector<2xi32> + %4 = llvm.add %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_constmask_vec_undef(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(-65281 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.and %arg0, %8 : vector<3xi32> + %18 = llvm.and %arg1, %16 : vector<3xi32> + %19 = llvm.add %17, %18 : vector<3xi32> + llvm.return %19 : vector<3xi32> + } + llvm.func @p_constmask2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(61440 : i32) : i32 + %1 = llvm.mlir.constant(-65281 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_constmask2_splatvec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<61440> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-65281> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg1, %1 : vector<2xi32> + %4 = llvm.add %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_constmask2_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[61440, 16711680]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-65281, -16776961]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg1, %1 : vector<2xi32> + %4 = llvm.add %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_constmask2_vec_undef(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(61440 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(-65281 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.and %arg0, %8 : vector<3xi32> + %18 = llvm.and %arg1, %16 : vector<3xi32> + %19 = llvm.add %17, %18 : vector<3xi32> + llvm.return %19 : vector<3xi32> + } + llvm.func @gen32() -> i32 + llvm.func @p_commutative0(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg2, %arg0 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.add %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_commutative1(%arg0: i32, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.xor %arg1, %0 : i32 + %4 = llvm.and %1, %3 : i32 + %5 = llvm.add %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @p_commutative2(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg2 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @p_commutative3(%arg0: i32, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.and %arg1, %arg0 : i32 + %3 = llvm.xor %arg1, %0 : i32 + %4 = llvm.and %1, %3 : i32 + %5 = llvm.add %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @p_commutative4(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg2, %arg0 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @p_commutative5(%arg0: i32, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.xor %arg1, %0 : i32 + %4 = llvm.and %1, %3 : i32 + %5 = llvm.add %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @p_commutative6(%arg0: i32, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.and %arg1, %arg0 : i32 + %3 = llvm.xor %arg1, %0 : i32 + %4 = llvm.and %1, %3 : i32 + %5 = llvm.add %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @p_constmask_commutative(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.constant(-65281 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.add %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @use32(i32) + llvm.func @n0_oneuse(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg2 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.add %1, %3 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n0_constmask_oneuse(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.constant(-65281 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.add %2, %3 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n1_badxor(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.and %arg0, %arg2 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.add %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n2_badmask(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg2, %arg0 : i32 + %2 = llvm.xor %arg3, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.add %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n3_constmask_badmask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.constant(-65280 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n3_constmask_samemask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.add %1, %2 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/masked-merge-and-of-ors.ll.mlir b/test/LLVMDialect/InstCombine/masked-merge-and-of-ors.ll.mlir new file mode 100644 index 000000000..070a099a9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/masked-merge-and-of-ors.ll.mlir @@ -0,0 +1,286 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg2, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.or %arg1, %arg2 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_splatvec(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.xor %arg2, %0 : vector<2xi32> + %2 = llvm.or %1, %arg0 : vector<2xi32> + %3 = llvm.or %arg1, %arg2 : vector<2xi32> + %4 = llvm.and %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_vec_undef(%arg0: vector<3xi32>, %arg1: vector<3xi32>, %arg2: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.xor %arg2, %8 : vector<3xi32> + %10 = llvm.or %9, %arg0 : vector<3xi32> + %11 = llvm.or %arg1, %arg2 : vector<3xi32> + %12 = llvm.and %10, %11 : vector<3xi32> + llvm.return %12 : vector<3xi32> + } + llvm.func @p_constmask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-65281 : i32) : i32 + %1 = llvm.mlir.constant(65280 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.or %arg1, %1 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_constmask_splatvec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-65281> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<65280> : vector<2xi32>) : vector<2xi32> + %2 = llvm.or %arg0, %0 : vector<2xi32> + %3 = llvm.or %arg1, %1 : vector<2xi32> + %4 = llvm.and %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_constmask_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[-65281, -16776961]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[65280, 16776960]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.or %arg0, %0 : vector<2xi32> + %3 = llvm.or %arg1, %1 : vector<2xi32> + %4 = llvm.and %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_constmask_vec_undef(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(-65281 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(65280 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.or %arg0, %8 : vector<3xi32> + %18 = llvm.or %arg1, %16 : vector<3xi32> + %19 = llvm.and %17, %18 : vector<3xi32> + llvm.return %19 : vector<3xi32> + } + llvm.func @gen32() -> i32 + llvm.func @p_commutative0(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg2, %0 : i32 + %2 = llvm.or %arg0, %1 : i32 + %3 = llvm.or %arg1, %arg2 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_commutative1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.or %arg1, %1 : i32 + %5 = llvm.and %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @p_commutative2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg2, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.or %arg1, %arg2 : i32 + %4 = llvm.and %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @p_commutative3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.or %arg0, %2 : i32 + %4 = llvm.or %arg1, %1 : i32 + %5 = llvm.and %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @p_commutative4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg2, %0 : i32 + %2 = llvm.or %arg0, %1 : i32 + %3 = llvm.or %arg1, %arg2 : i32 + %4 = llvm.and %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @p_commutative5(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.or %arg1, %1 : i32 + %5 = llvm.and %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @p_commutative6(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.or %arg0, %2 : i32 + %4 = llvm.or %arg1, %1 : i32 + %5 = llvm.and %4, %3 : i32 + llvm.return %5 : i32 + } + llvm.func @p_constmask_commutative(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-65281 : i32) : i32 + %1 = llvm.mlir.constant(65280 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.or %arg1, %1 : i32 + %4 = llvm.and %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @use32(i32) + llvm.func @n0_oneuse_of_neg_is_ok_0(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg2, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.or %arg1, %arg2 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n0_oneuse_1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg2, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.or %arg1, %arg2 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n0_oneuse_2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg2, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.or %arg1, %arg2 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n0_oneuse_3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg2, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.or %arg1, %arg2 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n0_oneuse_4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg2, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.or %arg1, %arg2 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n0_oneuse_5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg2, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.or %arg1, %arg2 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n0_oneuse_6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg2, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.or %arg1, %arg2 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n0_constmask_oneuse_0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-65281 : i32) : i32 + %1 = llvm.mlir.constant(65280 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.or %arg1, %1 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n0_constmask_oneuse_1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-65281 : i32) : i32 + %1 = llvm.mlir.constant(65280 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.or %arg1, %1 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n0_constmask_oneuse_2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-65281 : i32) : i32 + %1 = llvm.mlir.constant(65280 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.or %arg1, %1 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n1_badxor(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.xor %arg2, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.or %arg1, %arg2 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n2_badmask(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg3, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + %3 = llvm.or %arg2, %arg1 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n3_constmask_badmask_set(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-65281 : i32) : i32 + %1 = llvm.mlir.constant(65281 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.or %arg1, %1 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n3_constmask_badmask_unset(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-65281 : i32) : i32 + %1 = llvm.mlir.constant(65024 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.or %arg1, %1 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n3_constmask_samemask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-65281 : i32) : i32 + %1 = llvm.or %arg0, %0 : i32 + %2 = llvm.or %arg1, %0 : i32 + %3 = llvm.and %1, %2 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/masked-merge-or.ll.mlir b/test/LLVMDialect/InstCombine/masked-merge-or.ll.mlir new file mode 100644 index 000000000..8803e6c36 --- /dev/null +++ b/test/LLVMDialect/InstCombine/masked-merge-or.ll.mlir @@ -0,0 +1,266 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg2 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.or %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_splatvec(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32> {llvm.noundef}) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg0, %arg2 : vector<2xi32> + %2 = llvm.xor %arg2, %0 : vector<2xi32> + %3 = llvm.and %2, %arg1 : vector<2xi32> + %4 = llvm.or %1, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_vec_undef(%arg0: vector<3xi32>, %arg1: vector<3xi32>, %arg2: vector<3xi32> {llvm.noundef}) -> vector<3xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.and %arg0, %arg2 : vector<3xi32> + %10 = llvm.xor %arg2, %8 : vector<3xi32> + %11 = llvm.and %10, %arg1 : vector<3xi32> + %12 = llvm.or %9, %11 : vector<3xi32> + llvm.return %12 : vector<3xi32> + } + llvm.func @p_vec_poison(%arg0: vector<3xi32>, %arg1: vector<3xi32>, %arg2: vector<3xi32> {llvm.noundef}) -> vector<3xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.and %arg0, %arg2 : vector<3xi32> + %10 = llvm.xor %arg2, %8 : vector<3xi32> + %11 = llvm.and %10, %arg1 : vector<3xi32> + %12 = llvm.or %9, %11 : vector<3xi32> + llvm.return %12 : vector<3xi32> + } + llvm.func @p_constmask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.constant(-65281 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.or %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_constmask_splatvec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<65280> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-65281> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg1, %1 : vector<2xi32> + %4 = llvm.or %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_constmask_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[65280, 16776960]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-65281, -16776961]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg1, %1 : vector<2xi32> + %4 = llvm.or %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_constmask_vec_undef(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(-65281 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.and %arg0, %8 : vector<3xi32> + %18 = llvm.and %arg1, %16 : vector<3xi32> + %19 = llvm.or %17, %18 : vector<3xi32> + llvm.return %19 : vector<3xi32> + } + llvm.func @p_constmask2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(61440 : i32) : i32 + %1 = llvm.mlir.constant(-65281 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.or %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_constmask2_splatvec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<61440> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-65281> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg1, %1 : vector<2xi32> + %4 = llvm.or %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_constmask2_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[61440, 16711680]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-65281, -16776961]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg1, %1 : vector<2xi32> + %4 = llvm.or %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_constmask2_vec_undef(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(61440 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(-65281 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.and %arg0, %8 : vector<3xi32> + %18 = llvm.and %arg1, %16 : vector<3xi32> + %19 = llvm.or %17, %18 : vector<3xi32> + llvm.return %19 : vector<3xi32> + } + llvm.func @gen32() -> i32 + llvm.func @p_commutative0(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg2, %arg0 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.or %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_commutative1(%arg0: i32, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.xor %arg1, %0 : i32 + %4 = llvm.and %1, %3 : i32 + %5 = llvm.or %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @p_commutative2(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg2 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.or %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @p_commutative3(%arg0: i32, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.and %arg1, %arg0 : i32 + %3 = llvm.xor %arg1, %0 : i32 + %4 = llvm.and %1, %3 : i32 + %5 = llvm.or %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @p_commutative4(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg2, %arg0 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.or %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @p_commutative5(%arg0: i32, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.xor %arg1, %0 : i32 + %4 = llvm.and %1, %3 : i32 + %5 = llvm.or %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @p_commutative6(%arg0: i32, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.and %arg1, %arg0 : i32 + %3 = llvm.xor %arg1, %0 : i32 + %4 = llvm.and %1, %3 : i32 + %5 = llvm.or %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @p_constmask_commutative(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.constant(-65281 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @use32(i32) + llvm.func @n0_oneuse(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg2 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.or %1, %3 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n0_constmask_oneuse(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.constant(-65281 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.or %2, %3 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n1_badxor(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.and %arg0, %arg2 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.or %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n2_badmask(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg2, %arg0 : i32 + %2 = llvm.xor %arg3, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.or %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n3_constmask_badmask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.constant(-65280 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.or %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n3_constmask_samemask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.or %1, %2 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/masked-merge-xor.ll.mlir b/test/LLVMDialect/InstCombine/masked-merge-xor.ll.mlir new file mode 100644 index 000000000..a3f336a93 --- /dev/null +++ b/test/LLVMDialect/InstCombine/masked-merge-xor.ll.mlir @@ -0,0 +1,266 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg2 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.xor %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_splatvec(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32> {llvm.noundef}) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg0, %arg2 : vector<2xi32> + %2 = llvm.xor %arg2, %0 : vector<2xi32> + %3 = llvm.and %2, %arg1 : vector<2xi32> + %4 = llvm.xor %1, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_vec_undef(%arg0: vector<3xi32>, %arg1: vector<3xi32>, %arg2: vector<3xi32> {llvm.noundef}) -> vector<3xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.and %arg0, %arg2 : vector<3xi32> + %10 = llvm.xor %arg2, %8 : vector<3xi32> + %11 = llvm.and %10, %arg1 : vector<3xi32> + %12 = llvm.xor %9, %11 : vector<3xi32> + llvm.return %12 : vector<3xi32> + } + llvm.func @p_vec_poison(%arg0: vector<3xi32>, %arg1: vector<3xi32>, %arg2: vector<3xi32> {llvm.noundef}) -> vector<3xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.and %arg0, %arg2 : vector<3xi32> + %10 = llvm.xor %arg2, %8 : vector<3xi32> + %11 = llvm.and %10, %arg1 : vector<3xi32> + %12 = llvm.xor %9, %11 : vector<3xi32> + llvm.return %12 : vector<3xi32> + } + llvm.func @p_constmask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.constant(-65281 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_constmask_splatvec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<65280> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-65281> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg1, %1 : vector<2xi32> + %4 = llvm.xor %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_constmask_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[65280, 16776960]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-65281, -16776961]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg1, %1 : vector<2xi32> + %4 = llvm.xor %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_constmask_vec_undef(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(-65281 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.and %arg0, %8 : vector<3xi32> + %18 = llvm.and %arg1, %16 : vector<3xi32> + %19 = llvm.xor %17, %18 : vector<3xi32> + llvm.return %19 : vector<3xi32> + } + llvm.func @p_constmask2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(61440 : i32) : i32 + %1 = llvm.mlir.constant(-65281 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_constmask2_splatvec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<61440> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-65281> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg1, %1 : vector<2xi32> + %4 = llvm.xor %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_constmask2_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[61440, 16711680]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-65281, -16776961]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.and %arg1, %1 : vector<2xi32> + %4 = llvm.xor %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @p_constmask2_vec_undef(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(61440 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(-65281 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.and %arg0, %8 : vector<3xi32> + %18 = llvm.and %arg1, %16 : vector<3xi32> + %19 = llvm.xor %17, %18 : vector<3xi32> + llvm.return %19 : vector<3xi32> + } + llvm.func @gen32() -> i32 + llvm.func @p_commutative0(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg2, %arg0 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.xor %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @p_commutative1(%arg0: i32, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.xor %arg1, %0 : i32 + %4 = llvm.and %1, %3 : i32 + %5 = llvm.xor %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @p_commutative2(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg2 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.xor %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @p_commutative3(%arg0: i32, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.and %arg1, %arg0 : i32 + %3 = llvm.xor %arg1, %0 : i32 + %4 = llvm.and %1, %3 : i32 + %5 = llvm.xor %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @p_commutative4(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg2, %arg0 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.xor %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @p_commutative5(%arg0: i32, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.xor %arg1, %0 : i32 + %4 = llvm.and %1, %3 : i32 + %5 = llvm.xor %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @p_commutative6(%arg0: i32, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.and %arg1, %arg0 : i32 + %3 = llvm.xor %arg1, %0 : i32 + %4 = llvm.and %1, %3 : i32 + %5 = llvm.xor %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @p_constmask_commutative(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.constant(-65281 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.xor %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @use32(i32) + llvm.func @n0_oneuse(%arg0: i32, %arg1: i32, %arg2: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg2 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.xor %1, %3 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n0_constmask_oneuse(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.constant(-65281 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.return %4 : i32 + } + llvm.func @n1_badxor(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.and %arg0, %arg2 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.xor %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n2_badmask(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg2, %arg0 : i32 + %2 = llvm.xor %arg3, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.xor %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n3_constmask_badmask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.mlir.constant(-65280 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @n3_constmask_samemask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65280 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.xor %1, %2 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/masked_intrinsics-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/masked_intrinsics-inseltpoison.ll.mlir new file mode 100644 index 000000000..6093c67c4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/masked_intrinsics-inseltpoison.ll.mlir @@ -0,0 +1,230 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @G() {addr_space = 0 : i32} : i8 + llvm.func @load_zeromask(%arg0: !llvm.ptr, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.intr.masked.load %arg0, %1, %arg1 {alignment = 1 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @load_onemask(%arg0: !llvm.ptr, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.intr.masked.load %arg0, %1, %arg1 {alignment = 2 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @load_undefmask(%arg0: !llvm.ptr, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.undef : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.undef : vector<2xi1> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi1> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi1> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.intr.masked.load %arg0, %6, %arg1 {alignment = 2 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %8 : vector<2xf64> + } + llvm.func @load_cemask(%arg0: !llvm.ptr, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.addressof @G : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i1 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.undef : vector<2xi1> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi1> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi1> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.intr.masked.load %arg0, %7, %arg1 {alignment = 2 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %9 : vector<2xf64> + } + llvm.func @load_lane0(%arg0: !llvm.ptr, %arg1: f64) -> vector<2xf64> { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : vector<2xi1> + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.insertelement %arg1, %0[%1 : i64] : vector<2xf64> + %8 = llvm.insertelement %arg1, %7[%2 : i64] : vector<2xf64> + %9 = llvm.intr.masked.load %arg0, %5, %8 {alignment = 2 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %9 : vector<2xf64> + } + llvm.func @load_all(%arg0: !llvm.ptr, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(dense<[0, 1, 2, 3]> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense<[true, false, true, true]> : vector<4xi1>) : vector<4xi1> + %4 = llvm.mlir.undef : vector<4xf64> + %5 = llvm.mlir.constant(4 : i32) : i32 + %6 = llvm.mlir.constant(2 : i64) : i64 + %7 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, vector<4xi64>) -> !llvm.vec<4 x ptr>, f64 + %8 = llvm.intr.masked.gather %7, %3, %4 {alignment = 4 : i32} : (!llvm.vec<4 x ptr>, vector<4xi1>, vector<4xf64>) -> vector<4xf64> + %9 = llvm.extractelement %8[%6 : i64] : vector<4xf64> + llvm.return %9 : f64 + } + llvm.func @load_generic(%arg0: !llvm.ptr, %arg1: f64, %arg2: vector<2xi1>) -> vector<2xf64> { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.insertelement %arg1, %0[%1 : i64] : vector<2xf64> + %5 = llvm.insertelement %arg1, %4[%2 : i64] : vector<2xf64> + %6 = llvm.intr.masked.load %arg0, %arg2, %5 {alignment = 4 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %6 : vector<2xf64> + } + llvm.func @load_speculative(%arg0: !llvm.ptr {llvm.align = 4 : i64, llvm.dereferenceable = 16 : i64}, %arg1: f64, %arg2: vector<2xi1>) -> vector<2xf64> attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.insertelement %arg1, %0[%1 : i64] : vector<2xf64> + %5 = llvm.insertelement %arg1, %4[%2 : i64] : vector<2xf64> + %6 = llvm.intr.masked.load %arg0, %arg2, %5 {alignment = 4 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %6 : vector<2xf64> + } + llvm.func @load_speculative_less_aligned(%arg0: !llvm.ptr {llvm.dereferenceable = 16 : i64}, %arg1: f64, %arg2: vector<2xi1>) -> vector<2xf64> attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.insertelement %arg1, %0[%1 : i64] : vector<2xf64> + %5 = llvm.insertelement %arg1, %4[%2 : i64] : vector<2xf64> + %6 = llvm.intr.masked.load %arg0, %arg2, %5 {alignment = 4 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %6 : vector<2xf64> + } + llvm.func @load_spec_neg_size(%arg0: !llvm.ptr {llvm.dereferenceable = 8 : i64}, %arg1: f64, %arg2: vector<2xi1>) -> vector<2xf64> attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.insertelement %arg1, %0[%1 : i64] : vector<2xf64> + %5 = llvm.insertelement %arg1, %4[%2 : i64] : vector<2xf64> + %6 = llvm.intr.masked.load %arg0, %arg2, %5 {alignment = 4 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %6 : vector<2xf64> + } + llvm.func @load_spec_lan0(%arg0: !llvm.ptr {llvm.dereferenceable = 8 : i64}, %arg1: f64, %arg2: vector<2xi1>) -> vector<2xf64> attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(4 : i32) : i32 + %5 = llvm.insertelement %arg1, %0[%1 : i64] : vector<2xf64> + %6 = llvm.insertelement %arg1, %5[%2 : i64] : vector<2xf64> + %7 = llvm.insertelement %3, %arg2[%2 : i64] : vector<2xi1> + %8 = llvm.intr.masked.load %arg0, %7, %6 {alignment = 4 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %8 : vector<2xf64> + } + llvm.func @store_zeromask(%arg0: !llvm.ptr, %arg1: vector<2xf64>) { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(4 : i32) : i32 + llvm.intr.masked.store %arg1, %arg0, %1 {alignment = 4 : i32} : vector<2xf64>, vector<2xi1> into !llvm.ptr + llvm.return + } + llvm.func @store_onemask(%arg0: !llvm.ptr, %arg1: vector<2xf64>) { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(4 : i32) : i32 + llvm.intr.masked.store %arg1, %arg0, %1 {alignment = 4 : i32} : vector<2xf64>, vector<2xi1> into !llvm.ptr + llvm.return + } + llvm.func @store_demandedelts(%arg0: !llvm.ptr, %arg1: f64) { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : vector<2xi1> + %6 = llvm.mlir.constant(4 : i32) : i32 + %7 = llvm.insertelement %arg1, %0[%1 : i32] : vector<2xf64> + %8 = llvm.insertelement %arg1, %7[%2 : i32] : vector<2xf64> + llvm.intr.masked.store %8, %arg0, %5 {alignment = 4 : i32} : vector<2xf64>, vector<2xi1> into !llvm.ptr + llvm.return + } + llvm.func @gather_generic(%arg0: !llvm.vec<2 x ptr>, %arg1: vector<2xi1>, %arg2: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.intr.masked.gather %arg0, %arg1, %arg2 {alignment = 4 : i32} : (!llvm.vec<2 x ptr>, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @gather_zeromask(%arg0: !llvm.vec<2 x ptr>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.intr.masked.gather %arg0, %1, %arg1 {alignment = 4 : i32} : (!llvm.vec<2 x ptr>, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @gather_onemask(%arg0: !llvm.vec<2 x ptr>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.intr.masked.gather %arg0, %1, %arg1 {alignment = 4 : i32} : (!llvm.vec<2 x ptr>, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @gather_lane2(%arg0: !llvm.ptr, %arg1: f64) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[0, 1, 2, 3]> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mlir.poison : vector<4xf64> + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.mlir.constant(dense<[false, false, true, false]> : vector<4xi1>) : vector<4xi1> + %6 = llvm.mlir.constant(4 : i32) : i32 + %7 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, vector<4xi64>) -> !llvm.vec<4 x ptr>, f64 + %8 = llvm.insertelement %arg1, %1[%2 : i64] : vector<4xf64> + %9 = llvm.shufflevector %8, %1 [0, 0, 0, 0] : vector<4xf64> + %10 = llvm.intr.masked.gather %7, %5, %9 {alignment = 4 : i32} : (!llvm.vec<4 x ptr>, vector<4xi1>, vector<4xf64>) -> vector<4xf64> + llvm.return %10 : vector<4xf64> + } + llvm.func @gather_lane0_maybe(%arg0: !llvm.ptr, %arg1: f64, %arg2: vector<2xi1>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.poison : vector<2xf64> + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(4 : i32) : i32 + %6 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, f64 + %7 = llvm.insertelement %arg1, %1[%2 : i64] : vector<2xf64> + %8 = llvm.insertelement %arg1, %7[%3 : i64] : vector<2xf64> + %9 = llvm.insertelement %4, %arg2[%3 : i64] : vector<2xi1> + %10 = llvm.intr.masked.gather %6, %9, %8 {alignment = 4 : i32} : (!llvm.vec<2 x ptr>, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %10 : vector<2xf64> + } + llvm.func @gather_lane0_maybe_spec(%arg0: !llvm.ptr, %arg1: f64, %arg2: vector<2xi1>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.poison : vector<2xf64> + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(4 : i32) : i32 + %6 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, f64 + %7 = llvm.insertelement %arg1, %1[%2 : i64] : vector<2xf64> + %8 = llvm.insertelement %arg1, %7[%3 : i64] : vector<2xf64> + %9 = llvm.insertelement %4, %arg2[%3 : i64] : vector<2xi1> + %10 = llvm.intr.masked.gather %6, %9, %8 {alignment = 4 : i32} : (!llvm.vec<2 x ptr>, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %10 : vector<2xf64> + } + llvm.func @scatter_zeromask(%arg0: !llvm.vec<2 x ptr>, %arg1: vector<2xf64>) { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(8 : i32) : i32 + llvm.intr.masked.scatter %arg1, %arg0, %1 {alignment = 8 : i32} : vector<2xf64>, vector<2xi1> into !llvm.vec<2 x ptr> + llvm.return + } + llvm.func @scatter_demandedelts(%arg0: !llvm.ptr, %arg1: f64) { + %0 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.poison : vector<2xf64> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(true) : i1 + %6 = llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : vector<2xi1> + %7 = llvm.mlir.constant(8 : i32) : i32 + %8 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, f64 + %9 = llvm.insertelement %arg1, %1[%2 : i32] : vector<2xf64> + %10 = llvm.insertelement %arg1, %9[%3 : i32] : vector<2xf64> + llvm.intr.masked.scatter %10, %8, %6 {alignment = 8 : i32} : vector<2xf64>, vector<2xi1> into !llvm.vec<2 x ptr> + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/masked_intrinsics.ll.mlir b/test/LLVMDialect/InstCombine/masked_intrinsics.ll.mlir new file mode 100644 index 000000000..80ef1bf1f --- /dev/null +++ b/test/LLVMDialect/InstCombine/masked_intrinsics.ll.mlir @@ -0,0 +1,359 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @G() {addr_space = 0 : i32} : i8 + llvm.func @load_zeromask(%arg0: !llvm.ptr, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.intr.masked.load %arg0, %1, %arg1 {alignment = 1 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @load_onemask(%arg0: !llvm.ptr, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.intr.masked.load %arg0, %1, %arg1 {alignment = 2 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @load_undefmask(%arg0: !llvm.ptr, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.undef : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.undef : vector<2xi1> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi1> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi1> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.intr.masked.load %arg0, %6, %arg1 {alignment = 2 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %8 : vector<2xf64> + } + llvm.func @load_cemask(%arg0: !llvm.ptr, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.addressof @G : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i1 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.undef : vector<2xi1> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi1> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi1> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.intr.masked.load %arg0, %7, %arg1 {alignment = 2 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %9 : vector<2xf64> + } + llvm.func @load_lane0(%arg0: !llvm.ptr, %arg1: f64) -> vector<2xf64> { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : vector<2xi1> + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.insertelement %arg1, %0[%1 : i64] : vector<2xf64> + %8 = llvm.insertelement %arg1, %7[%2 : i64] : vector<2xf64> + %9 = llvm.intr.masked.load %arg0, %5, %8 {alignment = 2 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %9 : vector<2xf64> + } + llvm.func @load_all(%arg0: !llvm.ptr, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(dense<[0, 1, 2, 3]> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense<[true, false, true, true]> : vector<4xi1>) : vector<4xi1> + %4 = llvm.mlir.undef : vector<4xf64> + %5 = llvm.mlir.constant(4 : i32) : i32 + %6 = llvm.mlir.constant(2 : i64) : i64 + %7 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, vector<4xi64>) -> !llvm.vec<4 x ptr>, f64 + %8 = llvm.intr.masked.gather %7, %3, %4 {alignment = 4 : i32} : (!llvm.vec<4 x ptr>, vector<4xi1>, vector<4xf64>) -> vector<4xf64> + %9 = llvm.extractelement %8[%6 : i64] : vector<4xf64> + llvm.return %9 : f64 + } + llvm.func @load_generic(%arg0: !llvm.ptr, %arg1: f64, %arg2: vector<2xi1>) -> vector<2xf64> { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.insertelement %arg1, %0[%1 : i64] : vector<2xf64> + %5 = llvm.insertelement %arg1, %4[%2 : i64] : vector<2xf64> + %6 = llvm.intr.masked.load %arg0, %arg2, %5 {alignment = 4 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %6 : vector<2xf64> + } + llvm.func @load_speculative(%arg0: !llvm.ptr {llvm.align = 4 : i64, llvm.dereferenceable = 16 : i64}, %arg1: f64, %arg2: vector<2xi1>) -> vector<2xf64> attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.insertelement %arg1, %0[%1 : i64] : vector<2xf64> + %5 = llvm.insertelement %arg1, %4[%2 : i64] : vector<2xf64> + %6 = llvm.intr.masked.load %arg0, %arg2, %5 {alignment = 4 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %6 : vector<2xf64> + } + llvm.func @load_speculative_less_aligned(%arg0: !llvm.ptr {llvm.dereferenceable = 16 : i64}, %arg1: f64, %arg2: vector<2xi1>) -> vector<2xf64> attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.insertelement %arg1, %0[%1 : i64] : vector<2xf64> + %5 = llvm.insertelement %arg1, %4[%2 : i64] : vector<2xf64> + %6 = llvm.intr.masked.load %arg0, %arg2, %5 {alignment = 4 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %6 : vector<2xf64> + } + llvm.func @load_spec_neg_size(%arg0: !llvm.ptr {llvm.dereferenceable = 8 : i64}, %arg1: f64, %arg2: vector<2xi1>) -> vector<2xf64> attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.insertelement %arg1, %0[%1 : i64] : vector<2xf64> + %5 = llvm.insertelement %arg1, %4[%2 : i64] : vector<2xf64> + %6 = llvm.intr.masked.load %arg0, %arg2, %5 {alignment = 4 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %6 : vector<2xf64> + } + llvm.func @load_spec_lan0(%arg0: !llvm.ptr {llvm.dereferenceable = 8 : i64}, %arg1: f64, %arg2: vector<2xi1>) -> vector<2xf64> attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(4 : i32) : i32 + %5 = llvm.insertelement %arg1, %0[%1 : i64] : vector<2xf64> + %6 = llvm.insertelement %arg1, %5[%2 : i64] : vector<2xf64> + %7 = llvm.insertelement %3, %arg2[%2 : i64] : vector<2xi1> + %8 = llvm.intr.masked.load %arg0, %7, %6 {alignment = 4 : i32} : (!llvm.ptr, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %8 : vector<2xf64> + } + llvm.func @store_zeromask(%arg0: !llvm.ptr, %arg1: vector<2xf64>) { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(4 : i32) : i32 + llvm.intr.masked.store %arg1, %arg0, %1 {alignment = 4 : i32} : vector<2xf64>, vector<2xi1> into !llvm.ptr + llvm.return + } + llvm.func @store_onemask(%arg0: !llvm.ptr, %arg1: vector<2xf64>) { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(4 : i32) : i32 + llvm.intr.masked.store %arg1, %arg0, %1 {alignment = 4 : i32} : vector<2xf64>, vector<2xi1> into !llvm.ptr + llvm.return + } + llvm.func @store_demandedelts(%arg0: !llvm.ptr, %arg1: f64) { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : vector<2xi1> + %6 = llvm.mlir.constant(4 : i32) : i32 + %7 = llvm.insertelement %arg1, %0[%1 : i32] : vector<2xf64> + %8 = llvm.insertelement %arg1, %7[%2 : i32] : vector<2xf64> + llvm.intr.masked.store %8, %arg0, %5 {alignment = 4 : i32} : vector<2xf64>, vector<2xi1> into !llvm.ptr + llvm.return + } + llvm.func @gather_generic(%arg0: !llvm.vec<2 x ptr>, %arg1: vector<2xi1>, %arg2: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.intr.masked.gather %arg0, %arg1, %arg2 {alignment = 4 : i32} : (!llvm.vec<2 x ptr>, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @gather_zeromask(%arg0: !llvm.vec<2 x ptr>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.intr.masked.gather %arg0, %1, %arg1 {alignment = 4 : i32} : (!llvm.vec<2 x ptr>, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @gather_onemask(%arg0: !llvm.vec<2 x ptr>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.intr.masked.gather %arg0, %1, %arg1 {alignment = 4 : i32} : (!llvm.vec<2 x ptr>, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @gather_lane2(%arg0: !llvm.ptr, %arg1: f64) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[0, 1, 2, 3]> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mlir.undef : vector<4xf64> + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.mlir.constant(dense<[false, false, true, false]> : vector<4xi1>) : vector<4xi1> + %6 = llvm.mlir.constant(4 : i32) : i32 + %7 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, vector<4xi64>) -> !llvm.vec<4 x ptr>, f64 + %8 = llvm.insertelement %arg1, %1[%2 : i64] : vector<4xf64> + %9 = llvm.shufflevector %8, %1 [0, 0, 0, 0] : vector<4xf64> + %10 = llvm.intr.masked.gather %7, %5, %9 {alignment = 4 : i32} : (!llvm.vec<4 x ptr>, vector<4xi1>, vector<4xf64>) -> vector<4xf64> + llvm.return %10 : vector<4xf64> + } + llvm.func @gather_lane0_maybe(%arg0: !llvm.ptr, %arg1: f64, %arg2: vector<2xi1>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.undef : vector<2xf64> + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(4 : i32) : i32 + %6 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, f64 + %7 = llvm.insertelement %arg1, %1[%2 : i64] : vector<2xf64> + %8 = llvm.insertelement %arg1, %7[%3 : i64] : vector<2xf64> + %9 = llvm.insertelement %4, %arg2[%3 : i64] : vector<2xi1> + %10 = llvm.intr.masked.gather %6, %9, %8 {alignment = 4 : i32} : (!llvm.vec<2 x ptr>, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %10 : vector<2xf64> + } + llvm.func @gather_lane0_maybe_spec(%arg0: !llvm.ptr, %arg1: f64, %arg2: vector<2xi1>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.undef : vector<2xf64> + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(4 : i32) : i32 + %6 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, f64 + %7 = llvm.insertelement %arg1, %1[%2 : i64] : vector<2xf64> + %8 = llvm.insertelement %arg1, %7[%3 : i64] : vector<2xf64> + %9 = llvm.insertelement %4, %arg2[%3 : i64] : vector<2xi1> + %10 = llvm.intr.masked.gather %6, %9, %8 {alignment = 4 : i32} : (!llvm.vec<2 x ptr>, vector<2xi1>, vector<2xf64>) -> vector<2xf64> + llvm.return %10 : vector<2xf64> + } + llvm.func @scatter_zeromask(%arg0: !llvm.vec<2 x ptr>, %arg1: vector<2xf64>) { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(8 : i32) : i32 + llvm.intr.masked.scatter %arg1, %arg0, %1 {alignment = 8 : i32} : vector<2xf64>, vector<2xi1> into !llvm.vec<2 x ptr> + llvm.return + } + llvm.func @scatter_demandedelts(%arg0: !llvm.ptr, %arg1: f64) { + %0 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.undef : vector<2xf64> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(true) : i1 + %6 = llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : vector<2xi1> + %7 = llvm.mlir.constant(8 : i32) : i32 + %8 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, f64 + %9 = llvm.insertelement %arg1, %1[%2 : i32] : vector<2xf64> + %10 = llvm.insertelement %arg1, %9[%3 : i32] : vector<2xf64> + llvm.intr.masked.scatter %10, %8, %6 {alignment = 8 : i32} : vector<2xf64>, vector<2xi1> into !llvm.vec<2 x ptr> + llvm.return + } + llvm.func @scatter_v4i16_uniform_vals_uniform_ptrs_no_all_active_mask(%arg0: !llvm.ptr, %arg1: i16) { + %0 = llvm.mlir.poison : !llvm.vec<4 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.poison : vector<4xi16> + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(dense<[false, false, true, true]> : vector<4xi1>) : vector<4xi1> + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<4 x ptr> + %8 = llvm.shufflevector %7, %0 [0, 0, 0, 0] : !llvm.vec<4 x ptr> + %9 = llvm.insertelement %arg1, %2[%1 : i32] : vector<4xi16> + %10 = llvm.shufflevector %9, %2 [0, 0, 0, 0] : vector<4xi16> + llvm.intr.masked.scatter %10, %8, %5 {alignment = 2 : i32} : vector<4xi16>, vector<4xi1> into !llvm.vec<4 x ptr> + llvm.return + } + llvm.func @scatter_nxv4i16_uniform_vals_uniform_ptrs_all_active_mask(%arg0: !llvm.ptr, %arg1: i16) { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.poison : !llvm.vec + %3 = llvm.mlir.poison : !llvm.vec + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.mlir.constant(true) : i1 + %6 = llvm.insertelement %5, %3[%4 : i64] : !llvm.vec + %7 = llvm.shufflevector %6, %3 [0, 0, 0, 0] : !llvm.vec + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec + %10 = llvm.shufflevector %9, %0 [0, 0, 0, 0] : !llvm.vec + %11 = llvm.insertelement %arg1, %2[%1 : i32] : !llvm.vec + %12 = llvm.shufflevector %11, %2 [0, 0, 0, 0] : !llvm.vec + llvm.intr.masked.scatter %12, %10, %7 {alignment = 2 : i32} : vector<[4]xi16>, vector<[4]xi1> into !llvm.vec + llvm.return + } + llvm.func @scatter_v4i16_no_uniform_vals_uniform_ptrs_all_active_mask(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.poison : !llvm.vec<4 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<4 x ptr> + %6 = llvm.shufflevector %5, %0 [0, 0, 0, 0] : !llvm.vec<4 x ptr> + %7 = llvm.load %arg1 {alignment = 2 : i64} : !llvm.ptr -> vector<4xi16> + llvm.intr.masked.scatter %7, %6, %3 {alignment = 2 : i32} : vector<4xi16>, vector<4xi1> into !llvm.vec<4 x ptr> + llvm.return + } + llvm.func @scatter_nxv4i16_no_uniform_vals_uniform_ptrs_all_active_mask(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.poison : !llvm.vec + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.insertelement %4, %2[%3 : i64] : !llvm.vec + %6 = llvm.shufflevector %5, %2 [0, 0, 0, 0] : !llvm.vec + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec + %9 = llvm.shufflevector %8, %0 [0, 0, 0, 0] : !llvm.vec + %10 = llvm.load %arg1 {alignment = 2 : i64} : !llvm.ptr -> !llvm.vec + llvm.intr.masked.scatter %10, %9, %6 {alignment = 2 : i32} : !llvm.vec, vector<[4]xi1> into !llvm.vec + llvm.return + } + llvm.func @negative_scatter_v4i16_no_uniform_vals_uniform_ptrs_all_inactive_mask(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.poison : !llvm.vec<4 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(dense<[false, false, true, true]> : vector<4xi1>) : vector<4xi1> + %5 = llvm.mlir.constant(2 : i32) : i32 + %6 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<4 x ptr> + %7 = llvm.shufflevector %6, %0 [0, 0, 0, 0] : !llvm.vec<4 x ptr> + %8 = llvm.load %arg1 {alignment = 2 : i64} : !llvm.ptr -> vector<4xi16> + llvm.intr.masked.scatter %8, %7, %4 {alignment = 2 : i32} : vector<4xi16>, vector<4xi1> into !llvm.vec<4 x ptr> + llvm.return + } + llvm.func @negative_scatter_v4i16_no_uniform_vals_no_uniform_ptrs_all_active_mask(%arg0: !llvm.vec<4 x ptr>, %arg1: !llvm.ptr) { + %0 = llvm.mlir.poison : !llvm.vec<4 x ptr> + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.shufflevector %arg0, %0 [0, 0, 0, 0] : !llvm.vec<4 x ptr> + %5 = llvm.load %arg1 {alignment = 2 : i64} : !llvm.ptr -> vector<4xi16> + llvm.intr.masked.scatter %5, %4, %2 {alignment = 2 : i32} : vector<4xi16>, vector<4xi1> into !llvm.vec<4 x ptr> + llvm.return + } + llvm.func @gather_nxv2i64_uniform_ptrs_all_active_mask(%arg0: !llvm.ptr) -> !llvm.vec { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.poison : !llvm.vec + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.insertelement %4, %2[%3 : i64] : !llvm.vec + %6 = llvm.shufflevector %5, %2 [0, 0] : !llvm.vec + %7 = llvm.mlir.undef : !llvm.vec + %8 = llvm.mlir.constant(8 : i32) : i32 + %9 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec + %10 = llvm.shufflevector %9, %0 [0, 0] : !llvm.vec + %11 = llvm.intr.masked.gather %10, %6, %7 {alignment = 8 : i32} : (!llvm.vec, vector<[2]xi1>, !llvm.vec) -> !llvm.vec + llvm.return %11 : !llvm.vec + } + llvm.func @gather_v2i64_uniform_ptrs_all_active_mask(%arg0: !llvm.ptr) -> vector<2xi64> { + %0 = llvm.mlir.poison : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.mlir.undef : vector<2xi64> + %5 = llvm.mlir.constant(8 : i32) : i32 + %6 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %7 = llvm.shufflevector %6, %0 [0, 0] : !llvm.vec<2 x ptr> + %8 = llvm.intr.masked.gather %7, %3, %4 {alignment = 8 : i32} : (!llvm.vec<2 x ptr>, vector<2xi1>, vector<2xi64>) -> vector<2xi64> + llvm.return %8 : vector<2xi64> + } + llvm.func @negative_gather_v2i64_non_uniform_ptrs_all_active_mask(%arg0: !llvm.vec<2 x ptr>, %arg1: !llvm.ptr) -> vector<2xi64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %3 = llvm.mlir.undef : vector<2xi64> + %4 = llvm.mlir.constant(8 : i32) : i32 + %5 = llvm.insertelement %arg1, %arg0[%0 : i32] : !llvm.vec<2 x ptr> + %6 = llvm.intr.masked.gather %5, %2, %3 {alignment = 8 : i32} : (!llvm.vec<2 x ptr>, vector<2xi1>, vector<2xi64>) -> vector<2xi64> + llvm.return %6 : vector<2xi64> + } + llvm.func @negative_gather_v2i64_uniform_ptrs_no_all_active_mask(%arg0: !llvm.ptr, %arg1: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.poison : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.shufflevector %4, %0 [0, 0] : !llvm.vec<2 x ptr> + %6 = llvm.intr.masked.gather %5, %arg1, %2 {alignment = 8 : i32} : (!llvm.vec<2 x ptr>, vector<2xi1>, vector<2xi64>) -> vector<2xi64> + llvm.return %6 : vector<2xi64> + } +} diff --git a/test/LLVMDialect/InstCombine/masked_intrinsics_keep_metadata.ll.mlir b/test/LLVMDialect/InstCombine/masked_intrinsics_keep_metadata.ll.mlir new file mode 100644 index 000000000..de941bace --- /dev/null +++ b/test/LLVMDialect/InstCombine/masked_intrinsics_keep_metadata.ll.mlir @@ -0,0 +1,29 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g0(dense<0> : vector<4xi32>) {addr_space = 0 : i32, alignment = 16 : i64} : vector<4xi32> + llvm.func @mload1(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> (vector<4xi32> {llvm.inreg}) attributes {passthrough = ["norecurse", "nounwind"]} { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(16 : i32) : i32 + %4 = llvm.intr.masked.load %arg0, %1, %2 {alignment = 16 : i32} : (!llvm.ptr, vector<4xi1>, vector<4xi32>) -> vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mload2() -> (vector<4xi32> {llvm.inreg}) attributes {passthrough = ["norecurse", "nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.addressof @g0 : !llvm.ptr + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(dense<[false, true, true, true]> : vector<4xi1>) : vector<4xi1> + %6 = llvm.mlir.constant(16 : i32) : i32 + %7 = llvm.intr.masked.load %2, %5, %1 {alignment = 16 : i32} : (!llvm.ptr, vector<4xi1>, vector<4xi32>) -> vector<4xi32> + llvm.return %7 : vector<4xi32> + } + llvm.func @mstore(%arg0: vector<4xi32>, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) attributes {passthrough = ["norecurse", "nounwind"]} { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %2 = llvm.mlir.constant(16 : i32) : i32 + llvm.intr.masked.store %arg0, %arg1, %1 {alignment = 16 : i32} : vector<4xi32>, vector<4xi1> into !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/math-odd-even-parity.ll.mlir b/test/LLVMDialect/InstCombine/math-odd-even-parity.ll.mlir new file mode 100644 index 000000000..e43554775 --- /dev/null +++ b/test/LLVMDialect/InstCombine/math-odd-even-parity.ll.mlir @@ -0,0 +1,24 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @erf(f64) -> f64 + llvm.func @cos(f64) -> f64 + llvm.func @fabs(f64) -> f64 + llvm.func @use(f64) attributes {passthrough = ["nounwind"]} + llvm.func @test_erf(%arg0: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.call @erf(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %2 = llvm.fneg %1 : f64 + llvm.return %2 : f64 + } + llvm.func @test_cos_fabs(%arg0: f64) -> f64 { + %0 = llvm.call @fabs(%arg0) : (f64) -> f64 + %1 = llvm.call @cos(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_erf_multi_use(%arg0: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + llvm.call @use(%0) : (f64) -> () + %1 = llvm.call @erf(%0) : (f64) -> f64 + %2 = llvm.fneg %1 : f64 + llvm.return %2 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/matrix-multiplication-negation.ll.mlir b/test/LLVMDialect/InstCombine/matrix-multiplication-negation.ll.mlir new file mode 100644 index 000000000..bed5628e1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/matrix-multiplication-negation.ll.mlir @@ -0,0 +1,216 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_negation_move_to_result(%arg0: vector<6xf64>, %arg1: vector<3xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.fneg %arg0 : vector<6xf64> + %4 = llvm.intr.matrix.multiply %3, %arg1 {lhs_columns = 3 : i32, lhs_rows = 2 : i32, rhs_columns = 1 : i32} : (vector<6xf64>, vector<3xf64>) -> vector<2xf64> + llvm.return %4 : vector<2xf64> + } + llvm.func @test_negation_move_to_result_with_fastflags(%arg0: vector<6xf64>, %arg1: vector<3xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.fneg %arg0 : vector<6xf64> + %4 = llvm.intr.matrix.multiply %3, %arg1 {lhs_columns = 3 : i32, lhs_rows = 2 : i32, rhs_columns = 1 : i32} : (vector<6xf64>, vector<3xf64>) -> vector<2xf64> + llvm.return %4 : vector<2xf64> + } + llvm.func @test_negation_move_to_result_with_nnan_flag(%arg0: vector<6xf64>, %arg1: vector<3xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.fneg %arg0 : vector<6xf64> + %4 = llvm.intr.matrix.multiply %3, %arg1 {lhs_columns = 3 : i32, lhs_rows = 2 : i32, rhs_columns = 1 : i32} : (vector<6xf64>, vector<3xf64>) -> vector<2xf64> + llvm.return %4 : vector<2xf64> + } + llvm.func @test_negation_move_to_result_with_nsz_flag(%arg0: vector<6xf64>, %arg1: vector<3xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.fneg %arg0 : vector<6xf64> + %4 = llvm.intr.matrix.multiply %3, %arg1 {lhs_columns = 3 : i32, lhs_rows = 2 : i32, rhs_columns = 1 : i32} : (vector<6xf64>, vector<3xf64>) -> vector<2xf64> + llvm.return %4 : vector<2xf64> + } + llvm.func @test_negation_move_to_result_with_fastflag_on_negation(%arg0: vector<6xf64>, %arg1: vector<3xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : vector<6xf64> + %4 = llvm.intr.matrix.multiply %3, %arg1 {lhs_columns = 3 : i32, lhs_rows = 2 : i32, rhs_columns = 1 : i32} : (vector<6xf64>, vector<3xf64>) -> vector<2xf64> + llvm.return %4 : vector<2xf64> + } + llvm.func @test_move_negation_to_second_operand(%arg0: vector<27xf64>, %arg1: vector<3xf64>) -> vector<9xf64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.fneg %arg0 : vector<27xf64> + %4 = llvm.intr.matrix.multiply %3, %arg1 {lhs_columns = 3 : i32, lhs_rows = 9 : i32, rhs_columns = 1 : i32} : (vector<27xf64>, vector<3xf64>) -> vector<9xf64> + llvm.return %4 : vector<9xf64> + } + llvm.func @test_move_negation_to_second_operand_with_fast_flags(%arg0: vector<27xf64>, %arg1: vector<3xf64>) -> vector<9xf64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.fneg %arg0 : vector<27xf64> + %4 = llvm.intr.matrix.multiply %3, %arg1 {lhs_columns = 3 : i32, lhs_rows = 9 : i32, rhs_columns = 1 : i32} : (vector<27xf64>, vector<3xf64>) -> vector<9xf64> + llvm.return %4 : vector<9xf64> + } + llvm.func @test_negation_move_to_result_from_second_operand(%arg0: vector<3xf64>, %arg1: vector<6xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.fneg %arg1 : vector<6xf64> + %4 = llvm.intr.matrix.multiply %arg0, %3 {lhs_columns = 3 : i32, lhs_rows = 1 : i32, rhs_columns = 2 : i32} : (vector<3xf64>, vector<6xf64>) -> vector<2xf64> + llvm.return %4 : vector<2xf64> + } + llvm.func @test_move_negation_to_first_operand(%arg0: vector<3xf64>, %arg1: vector<27xf64>) -> vector<9xf64> { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.fneg %arg1 : vector<27xf64> + %4 = llvm.intr.matrix.multiply %arg0, %3 {lhs_columns = 3 : i32, lhs_rows = 1 : i32, rhs_columns = 9 : i32} : (vector<3xf64>, vector<27xf64>) -> vector<9xf64> + llvm.return %4 : vector<9xf64> + } + llvm.func @test_negation_not_moved(%arg0: vector<3xf64>, %arg1: vector<5xf64>) -> vector<15xf64> { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.fneg %arg0 : vector<3xf64> + %4 = llvm.intr.matrix.multiply %3, %arg1 {lhs_columns = 1 : i32, lhs_rows = 3 : i32, rhs_columns = 5 : i32} : (vector<3xf64>, vector<5xf64>) -> vector<15xf64> + llvm.return %4 : vector<15xf64> + } + llvm.func @test_negation_not_moved_second_operand(%arg0: vector<5xf64>, %arg1: vector<3xf64>) -> vector<15xf64> { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(5 : i32) : i32 + %3 = llvm.fneg %arg1 : vector<3xf64> + %4 = llvm.intr.matrix.multiply %arg0, %3 {lhs_columns = 1 : i32, lhs_rows = 5 : i32, rhs_columns = 3 : i32} : (vector<5xf64>, vector<3xf64>) -> vector<15xf64> + llvm.return %4 : vector<15xf64> + } + llvm.func @test_negation_on_result(%arg0: vector<3xf64>, %arg1: vector<5xf64>) -> vector<15xf64> { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.intr.matrix.multiply %arg0, %arg1 {lhs_columns = 1 : i32, lhs_rows = 3 : i32, rhs_columns = 5 : i32} : (vector<3xf64>, vector<5xf64>) -> vector<15xf64> + %4 = llvm.fneg %3 : vector<15xf64> + llvm.return %4 : vector<15xf64> + } + llvm.func @test_with_two_operands_negated1(%arg0: vector<6xf64>, %arg1: vector<3xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.fneg %arg0 : vector<6xf64> + %4 = llvm.fneg %arg1 : vector<3xf64> + %5 = llvm.intr.matrix.multiply %3, %4 {lhs_columns = 3 : i32, lhs_rows = 2 : i32, rhs_columns = 1 : i32} : (vector<6xf64>, vector<3xf64>) -> vector<2xf64> + llvm.return %5 : vector<2xf64> + } + llvm.func @test_with_two_operands_negated2(%arg0: vector<27xf64>, %arg1: vector<3xf64>) -> vector<9xf64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.fneg %arg0 : vector<27xf64> + %4 = llvm.fneg %arg1 : vector<3xf64> + %5 = llvm.intr.matrix.multiply %3, %4 {lhs_columns = 3 : i32, lhs_rows = 9 : i32, rhs_columns = 1 : i32} : (vector<27xf64>, vector<3xf64>) -> vector<9xf64> + llvm.return %5 : vector<9xf64> + } + llvm.func @test_with_two_operands_negated_with_fastflags(%arg0: vector<27xf64>, %arg1: vector<3xf64>) -> vector<9xf64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.fneg %arg0 : vector<27xf64> + %4 = llvm.fneg %arg1 : vector<3xf64> + %5 = llvm.intr.matrix.multiply %3, %4 {lhs_columns = 3 : i32, lhs_rows = 9 : i32, rhs_columns = 1 : i32} : (vector<27xf64>, vector<3xf64>) -> vector<9xf64> + llvm.return %5 : vector<9xf64> + } + llvm.func @test_with_two_operands_negated2_commute(%arg0: vector<3xf64>, %arg1: vector<27xf64>) -> vector<9xf64> { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.fneg %arg0 : vector<3xf64> + %4 = llvm.fneg %arg1 : vector<27xf64> + %5 = llvm.intr.matrix.multiply %3, %4 {lhs_columns = 3 : i32, lhs_rows = 1 : i32, rhs_columns = 9 : i32} : (vector<3xf64>, vector<27xf64>) -> vector<9xf64> + llvm.return %5 : vector<9xf64> + } + llvm.func @matrix_multiply_two_operands_negated_with_same_size(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.fneg %arg0 : vector<2xf64> + %3 = llvm.fneg %arg1 : vector<2xf64> + %4 = llvm.intr.matrix.multiply %2, %3 {lhs_columns = 1 : i32, lhs_rows = 2 : i32, rhs_columns = 2 : i32} : (vector<2xf64>, vector<2xf64>) -> vector<4xf64> + llvm.return %4 : vector<4xf64> + } + llvm.func @matrix_multiply_two_operands_with_multiple_uses(%arg0: vector<6xf64>, %arg1: vector<3xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.undef : vector<6xf64> + %4 = llvm.fneg %arg0 : vector<6xf64> + %5 = llvm.fneg %arg1 : vector<3xf64> + %6 = llvm.intr.matrix.multiply %4, %5 {lhs_columns = 3 : i32, lhs_rows = 2 : i32, rhs_columns = 1 : i32} : (vector<6xf64>, vector<3xf64>) -> vector<2xf64> + %7 = llvm.shufflevector %4, %3 [0, 1] : vector<6xf64> + %8 = llvm.fadd %7, %6 : vector<2xf64> + llvm.return %8 : vector<2xf64> + } + llvm.func @matrix_multiply_two_operands_with_multiple_uses2(%arg0: vector<27xf64>, %arg1: vector<3xf64>, %arg2: !llvm.ptr, %arg3: !llvm.ptr) -> vector<9xf64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.fneg %arg0 : vector<27xf64> + %4 = llvm.fneg %arg1 : vector<3xf64> + %5 = llvm.intr.matrix.multiply %3, %4 {lhs_columns = 3 : i32, lhs_rows = 9 : i32, rhs_columns = 1 : i32} : (vector<27xf64>, vector<3xf64>) -> vector<9xf64> + llvm.store %3, %arg2 {alignment = 256 : i64} : vector<27xf64>, !llvm.ptr + llvm.store %4, %arg3 {alignment = 32 : i64} : vector<3xf64>, !llvm.ptr + llvm.return %5 : vector<9xf64> + } + llvm.func @fneg_with_multiple_uses(%arg0: vector<15xf64>, %arg1: vector<20xf64>) -> vector<12xf64> { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.undef : vector<15xf64> + %4 = llvm.fneg %arg0 : vector<15xf64> + %5 = llvm.intr.matrix.multiply %4, %arg1 {lhs_columns = 5 : i32, lhs_rows = 3 : i32, rhs_columns = 4 : i32} : (vector<15xf64>, vector<20xf64>) -> vector<12xf64> + %6 = llvm.shufflevector %4, %3 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] : vector<15xf64> + %7 = llvm.fadd %6, %5 : vector<12xf64> + llvm.return %7 : vector<12xf64> + } + llvm.func @fneg_with_multiple_uses_2(%arg0: vector<15xf64>, %arg1: vector<20xf64>, %arg2: !llvm.ptr) -> vector<12xf64> { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.fneg %arg0 : vector<15xf64> + %4 = llvm.intr.matrix.multiply %3, %arg1 {lhs_columns = 5 : i32, lhs_rows = 3 : i32, rhs_columns = 4 : i32} : (vector<15xf64>, vector<20xf64>) -> vector<12xf64> + llvm.store %3, %arg2 {alignment = 128 : i64} : vector<15xf64>, !llvm.ptr + llvm.return %4 : vector<12xf64> + } + llvm.func @chain_of_matrix_mutliplies(%arg0: vector<27xf64>, %arg1: vector<3xf64>, %arg2: vector<8xf64>) -> vector<72xf64> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.mlir.constant(8 : i32) : i32 + %4 = llvm.fneg %arg0 : vector<27xf64> + %5 = llvm.intr.matrix.multiply %4, %arg1 {lhs_columns = 3 : i32, lhs_rows = 9 : i32, rhs_columns = 1 : i32} : (vector<27xf64>, vector<3xf64>) -> vector<9xf64> + %6 = llvm.intr.matrix.multiply %5, %arg2 {lhs_columns = 1 : i32, lhs_rows = 9 : i32, rhs_columns = 8 : i32} : (vector<9xf64>, vector<8xf64>) -> vector<72xf64> + llvm.return %6 : vector<72xf64> + } + llvm.func @chain_of_matrix_mutliplies_with_two_negations(%arg0: vector<3xf64>, %arg1: vector<5xf64>, %arg2: vector<10xf64>) -> vector<6xf64> { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.fneg %arg1 : vector<5xf64> + %5 = llvm.intr.matrix.multiply %arg0, %4 {lhs_columns = 1 : i32, lhs_rows = 3 : i32, rhs_columns = 5 : i32} : (vector<3xf64>, vector<5xf64>) -> vector<15xf64> + %6 = llvm.fneg %5 : vector<15xf64> + %7 = llvm.intr.matrix.multiply %6, %arg2 {lhs_columns = 5 : i32, lhs_rows = 3 : i32, rhs_columns = 2 : i32} : (vector<15xf64>, vector<10xf64>) -> vector<6xf64> + llvm.return %7 : vector<6xf64> + } + llvm.func @chain_of_matrix_mutliplies_propagation(%arg0: vector<15xf64>, %arg1: vector<20xf64>, %arg2: vector<8xf64>) -> vector<6xf64> { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.fneg %arg0 : vector<15xf64> + %5 = llvm.intr.matrix.multiply %4, %arg1 {lhs_columns = 5 : i32, lhs_rows = 3 : i32, rhs_columns = 4 : i32} : (vector<15xf64>, vector<20xf64>) -> vector<12xf64> + %6 = llvm.intr.matrix.multiply %5, %arg2 {lhs_columns = 4 : i32, lhs_rows = 3 : i32, rhs_columns = 2 : i32} : (vector<12xf64>, vector<8xf64>) -> vector<6xf64> + llvm.return %6 : vector<6xf64> + } +} diff --git a/test/LLVMDialect/InstCombine/max-of-nots.ll.mlir b/test/LLVMDialect/InstCombine/max-of-nots.ll.mlir new file mode 100644 index 000000000..ae17b9359 --- /dev/null +++ b/test/LLVMDialect/InstCombine/max-of-nots.ll.mlir @@ -0,0 +1,326 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @umin_of_nots(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.xor %arg0, %0 : vector<2xi32> + %2 = llvm.xor %arg1, %0 : vector<2xi32> + %3 = llvm.icmp "ult" %1, %2 : vector<2xi32> + %4 = llvm.select %3, %1, %2 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @smin_of_nots(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.xor %arg0, %0 : vector<2xi32> + %2 = llvm.xor %arg1, %0 : vector<2xi32> + %3 = llvm.icmp "sle" %1, %2 : vector<2xi32> + %4 = llvm.select %3, %1, %2 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @compute_min_2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.icmp "sgt" %1, %2 : i32 + %4 = llvm.select %3, %1, %2 : i1, i32 + %5 = llvm.sub %0, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @extra_use(i8) + llvm.func @umin_not_1_extra_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.icmp "ult" %1, %2 : i8 + %4 = llvm.select %3, %1, %2 : i1, i8 + llvm.call @extra_use(%1) : (i8) -> () + llvm.return %4 : i8 + } + llvm.func @umin_not_2_extra_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.icmp "ult" %1, %2 : i8 + %4 = llvm.select %3, %1, %2 : i1, i8 + llvm.call @extra_use(%1) : (i8) -> () + llvm.call @extra_use(%2) : (i8) -> () + llvm.return %4 : i8 + } + llvm.func @umin3_not(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.icmp "ult" %arg1, %arg0 : i8 + %5 = llvm.icmp "ult" %1, %3 : i8 + %6 = llvm.select %5, %1, %3 : i1, i8 + %7 = llvm.icmp "ult" %2, %3 : i8 + %8 = llvm.select %7, %2, %3 : i1, i8 + %9 = llvm.select %4, %6, %8 : i1, i8 + llvm.return %9 : i8 + } + llvm.func @umin3_not_more_uses(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.icmp "ult" %1, %3 : i8 + %5 = llvm.select %4, %1, %3 : i1, i8 + %6 = llvm.icmp "ult" %2, %3 : i8 + %7 = llvm.select %6, %2, %3 : i1, i8 + %8 = llvm.icmp "ult" %arg1, %arg0 : i8 + %9 = llvm.select %8, %5, %7 : i1, i8 + llvm.call @extra_use(%1) : (i8) -> () + llvm.call @extra_use(%2) : (i8) -> () + llvm.return %9 : i8 + } + llvm.func @use8(i8) + llvm.func @umin3_not_all_ops_extra_uses(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.icmp "ult" %1, %3 : i8 + %5 = llvm.select %4, %1, %3 : i1, i8 + %6 = llvm.icmp "ult" %5, %2 : i8 + %7 = llvm.select %6, %5, %2 : i1, i8 + llvm.call @use8(%1) : (i8) -> () + llvm.call @use8(%2) : (i8) -> () + llvm.call @use8(%3) : (i8) -> () + llvm.return %7 : i8 + } + llvm.func @compute_min_3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.sub %0, %arg2 : i32 + %4 = llvm.icmp "sgt" %1, %2 : i32 + %5 = llvm.select %4, %1, %2 : i1, i32 + %6 = llvm.icmp "sgt" %5, %3 : i32 + %7 = llvm.select %6, %5, %3 : i1, i32 + %8 = llvm.sub %0, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @compute_min_arithmetic(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.sub %1, %arg1 : i32 + %4 = llvm.icmp "sgt" %2, %3 : i32 + %5 = llvm.select %4, %2, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @fake_use(i32) + llvm.func @compute_min_pessimization(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + llvm.call @fake_use(%2) : (i32) -> () + %3 = llvm.sub %1, %arg1 : i32 + %4 = llvm.icmp "sgt" %2, %3 : i32 + %5 = llvm.select %4, %2, %3 : i1, i32 + %6 = llvm.sub %1, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @max_of_nots(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "sgt" %arg1, %0 : i32 + %3 = llvm.xor %arg1, %1 : i32 + %4 = llvm.select %2, %3, %1 : i1, i32 + %5 = llvm.xor %arg0, %1 : i32 + %6 = llvm.icmp "slt" %4, %5 : i32 + %7 = llvm.select %6, %5, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_of_min_of_not(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.icmp "sge" %4, %3 : i32 + %6 = llvm.select %5, %3, %4 : i1, i32 + %7 = llvm.icmp "sgt" %6, %0 : i32 + %8 = llvm.sub %2, %6 : i32 + %9 = llvm.select %7, %6, %8 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @max_of_nots_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.icmp "sgt" %arg1, %1 : vector<2xi32> + %4 = llvm.xor %arg1, %2 : vector<2xi32> + %5 = llvm.select %3, %4, %2 : vector<2xi1>, vector<2xi32> + %6 = llvm.xor %arg0, %2 : vector<2xi32> + %7 = llvm.icmp "slt" %5, %6 : vector<2xi32> + %8 = llvm.select %7, %6, %5 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @max_of_nots_weird_type_vec(%arg0: vector<2xi37>, %arg1: vector<2xi37>) -> vector<2xi37> { + %0 = llvm.mlir.constant(0 : i37) : i37 + %1 = llvm.mlir.constant(dense<0> : vector<2xi37>) : vector<2xi37> + %2 = llvm.mlir.constant(-1 : i37) : i37 + %3 = llvm.mlir.constant(dense<-1> : vector<2xi37>) : vector<2xi37> + %4 = llvm.icmp "sgt" %arg1, %1 : vector<2xi37> + %5 = llvm.xor %arg1, %3 : vector<2xi37> + %6 = llvm.select %4, %5, %3 : vector<2xi1>, vector<2xi37> + %7 = llvm.xor %arg0, %3 : vector<2xi37> + %8 = llvm.icmp "slt" %6, %7 : vector<2xi37> + %9 = llvm.select %8, %7, %6 : vector<2xi1>, vector<2xi37> + llvm.return %9 : vector<2xi37> + } + llvm.func @max_of_min(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.select %3, %2, %0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %0 : i32 + %6 = llvm.select %5, %4, %0 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @max_of_min_swap(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i32 + %5 = llvm.icmp "sgt" %4, %0 : i32 + %6 = llvm.select %5, %4, %0 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @min_of_max(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.select %3, %2, %0 : i1, i32 + %5 = llvm.icmp "slt" %4, %0 : i32 + %6 = llvm.select %5, %4, %0 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @min_of_max_swap(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i32 + %5 = llvm.icmp "slt" %4, %0 : i32 + %6 = llvm.select %5, %4, %0 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @max_of_min_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.xor %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "sgt" %arg0, %2 : vector<2xi32> + %5 = llvm.select %4, %3, %0 : vector<2xi1>, vector<2xi32> + %6 = llvm.icmp "sgt" %5, %0 : vector<2xi32> + %7 = llvm.select %6, %5, %0 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @use(i8, i8, i8, i8) + llvm.func @cmyk(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.icmp "slt" %arg1, %arg0 : i8 + %5 = llvm.icmp "slt" %1, %3 : i8 + %6 = llvm.select %5, %1, %3 : i1, i8 + %7 = llvm.icmp "slt" %2, %3 : i8 + %8 = llvm.select %7, %2, %3 : i1, i8 + %9 = llvm.select %4, %6, %8 : i1, i8 + %10 = llvm.sub %1, %9 : i8 + %11 = llvm.sub %2, %9 : i8 + %12 = llvm.sub %3, %9 : i8 + llvm.call @use(%10, %11, %12, %9) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk2(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.icmp "slt" %arg1, %arg0 : i8 + %5 = llvm.icmp "slt" %arg2, %arg0 : i8 + %6 = llvm.select %5, %1, %3 : i1, i8 + %7 = llvm.icmp "slt" %arg2, %arg1 : i8 + %8 = llvm.select %7, %2, %3 : i1, i8 + %9 = llvm.select %4, %6, %8 : i1, i8 + %10 = llvm.sub %1, %9 : i8 + %11 = llvm.sub %2, %9 : i8 + %12 = llvm.sub %3, %9 : i8 + llvm.call @use(%10, %11, %12, %9) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk3(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.icmp "slt" %arg1, %arg0 : i8 + %5 = llvm.icmp "sgt" %arg0, %arg2 : i8 + %6 = llvm.select %5, %1, %3 : i1, i8 + %7 = llvm.icmp "slt" %arg2, %arg1 : i8 + %8 = llvm.select %7, %2, %3 : i1, i8 + %9 = llvm.select %4, %6, %8 : i1, i8 + %10 = llvm.sub %1, %9 : i8 + %11 = llvm.sub %2, %9 : i8 + %12 = llvm.sub %3, %9 : i8 + llvm.call @use(%10, %11, %12, %9) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk4(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.icmp "slt" %arg1, %arg0 : i8 + %5 = llvm.icmp "sgt" %arg0, %arg2 : i8 + %6 = llvm.select %5, %1, %3 : i1, i8 + %7 = llvm.icmp "sgt" %arg1, %arg2 : i8 + %8 = llvm.select %7, %2, %3 : i1, i8 + %9 = llvm.select %4, %6, %8 : i1, i8 + %10 = llvm.sub %1, %9 : i8 + %11 = llvm.sub %2, %9 : i8 + %12 = llvm.sub %3, %9 : i8 + llvm.call @use(%10, %11, %12, %9) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk5(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %5 = llvm.icmp "sgt" %arg0, %arg2 : i8 + %6 = llvm.select %5, %1, %3 : i1, i8 + %7 = llvm.icmp "sgt" %arg1, %arg2 : i8 + %8 = llvm.select %7, %2, %3 : i1, i8 + %9 = llvm.select %4, %6, %8 : i1, i8 + %10 = llvm.sub %1, %9 : i8 + %11 = llvm.sub %2, %9 : i8 + %12 = llvm.sub %3, %9 : i8 + llvm.call @use(%10, %11, %12, %9) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk6(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.icmp "ult" %arg1, %arg0 : i8 + %5 = llvm.icmp "ult" %arg2, %arg0 : i8 + %6 = llvm.select %5, %1, %3 : i1, i8 + %7 = llvm.icmp "ult" %arg2, %arg1 : i8 + %8 = llvm.select %7, %2, %3 : i1, i8 + %9 = llvm.select %4, %6, %8 : i1, i8 + %10 = llvm.sub %1, %9 : i8 + %11 = llvm.sub %2, %9 : i8 + %12 = llvm.sub %3, %9 : i8 + llvm.call @use(%10, %11, %12, %9) : (i8, i8, i8, i8) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/max_known_bits.ll.mlir b/test/LLVMDialect/InstCombine/max_known_bits.ll.mlir new file mode 100644 index 000000000..97304e800 --- /dev/null +++ b/test/LLVMDialect/InstCombine/max_known_bits.ll.mlir @@ -0,0 +1,105 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(255 : i16) : i16 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.and %arg0, %0 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.icmp "ult" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + %6 = llvm.trunc %5 : i32 to i16 + %7 = llvm.and %6, %0 : i16 + llvm.return %7 : i16 + } + llvm.func @min_max_clamp(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(-2048 : i16) : i16 + %1 = llvm.mlir.constant(2047 : i16) : i16 + %2 = llvm.mlir.constant(1 : i16) : i16 + %3 = llvm.icmp "sgt" %arg0, %0 : i16 + %4 = llvm.select %3, %arg0, %0 : i1, i16 + %5 = llvm.icmp "slt" %4, %1 : i16 + %6 = llvm.select %5, %4, %1 : i1, i16 + %7 = llvm.add %6, %2 : i16 + llvm.return %7 : i16 + } + llvm.func @min_max_clamp_2(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(2047 : i16) : i16 + %1 = llvm.mlir.constant(-2048 : i16) : i16 + %2 = llvm.mlir.constant(1 : i16) : i16 + %3 = llvm.icmp "slt" %arg0, %0 : i16 + %4 = llvm.select %3, %arg0, %0 : i1, i16 + %5 = llvm.icmp "sgt" %4, %1 : i16 + %6 = llvm.select %5, %4, %1 : i1, i16 + %7 = llvm.add %6, %2 : i16 + llvm.return %7 : i16 + } + llvm.func @min_max_clamp_3(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(-2048 : i16) : i16 + %1 = llvm.mlir.constant(2047 : i16) : i16 + %2 = llvm.mlir.constant(1 : i16) : i16 + %3 = llvm.mlir.constant(-1 : i32) : i32 + %4 = llvm.icmp "sgt" %arg0, %0 : i16 + %5 = llvm.select %4, %arg0, %0 : i1, i16 + %6 = llvm.icmp "slt" %5, %1 : i16 + %7 = llvm.select %6, %5, %1 : i1, i16 + %8 = llvm.add %7, %2 : i16 + %9 = llvm.sext %8 : i16 to i32 + %10 = llvm.add %9, %3 : i32 + llvm.return %10 : i32 + } + llvm.func @min_max_clamp_4(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(2047 : i16) : i16 + %1 = llvm.mlir.constant(-2048 : i16) : i16 + %2 = llvm.mlir.constant(1 : i16) : i16 + %3 = llvm.mlir.constant(-1 : i32) : i32 + %4 = llvm.icmp "slt" %arg0, %0 : i16 + %5 = llvm.select %4, %arg0, %0 : i1, i16 + %6 = llvm.icmp "sgt" %5, %1 : i16 + %7 = llvm.select %6, %5, %1 : i1, i16 + %8 = llvm.add %7, %2 : i16 + %9 = llvm.sext %8 : i16 to i32 + %10 = llvm.add %9, %3 : i32 + llvm.return %10 : i32 + } + llvm.func @min_max_clamp_intrinsic(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(-2048 : i16) : i16 + %1 = llvm.mlir.constant(2047 : i16) : i16 + %2 = llvm.mlir.constant(1 : i16) : i16 + %3 = llvm.intr.smax(%arg0, %0) : (i16, i16) -> i16 + %4 = llvm.intr.smin(%3, %1) : (i16, i16) -> i16 + %5 = llvm.add %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @min_max_clamp_intrinsic_2(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(2047 : i16) : i16 + %1 = llvm.mlir.constant(-2048 : i16) : i16 + %2 = llvm.mlir.constant(1 : i16) : i16 + %3 = llvm.intr.smin(%arg0, %0) : (i16, i16) -> i16 + %4 = llvm.intr.smax(%3, %1) : (i16, i16) -> i16 + %5 = llvm.add %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @min_max_clamp_intrinsic_3(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(-2048 : i16) : i16 + %1 = llvm.mlir.constant(2047 : i16) : i16 + %2 = llvm.mlir.constant(1 : i16) : i16 + %3 = llvm.mlir.constant(-1 : i32) : i32 + %4 = llvm.intr.smax(%arg0, %0) : (i16, i16) -> i16 + %5 = llvm.intr.smin(%4, %1) : (i16, i16) -> i16 + %6 = llvm.add %5, %2 : i16 + %7 = llvm.sext %6 : i16 to i32 + %8 = llvm.add %7, %3 : i32 + llvm.return %8 : i32 + } + llvm.func @min_max_clamp_intrinsic_4(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(2047 : i16) : i16 + %1 = llvm.mlir.constant(-2048 : i16) : i16 + %2 = llvm.mlir.constant(1 : i16) : i16 + %3 = llvm.mlir.constant(-1 : i32) : i32 + %4 = llvm.intr.smin(%arg0, %0) : (i16, i16) -> i16 + %5 = llvm.intr.smax(%4, %1) : (i16, i16) -> i16 + %6 = llvm.add %5, %2 : i16 + %7 = llvm.sext %6 : i16 to i32 + %8 = llvm.add %7, %3 : i32 + llvm.return %8 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/maximum.ll.mlir b/test/LLVMDialect/InstCombine/maximum.ll.mlir new file mode 100644 index 000000000..fefca435c --- /dev/null +++ b/test/LLVMDialect/InstCombine/maximum.ll.mlir @@ -0,0 +1,270 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @constant_fold_maximum_f32() -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.intr.maximum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_maximum_f32_inv() -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.maximum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_maximum_f32_nan0() -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.intr.maximum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_maximum_f32_nan1() -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %2 = llvm.intr.maximum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_maximum_f32_nan_nan() -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.intr.maximum(%0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_maximum_f32_p0_p0() -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.intr.maximum(%0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_maximum_f32_p0_n0() -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.intr.maximum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_maximum_f32_n0_p0() -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.intr.maximum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_maximum_f32_n0_n0() -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.intr.maximum(%0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_maximum_v4f32() -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 8.000000e+00, 3.000000e+00, 9.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[2.000000e+00, 2.000000e+00, 1.000000e+01, 5.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.intr.maximum(%0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @constant_fold_maximum_f64() -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.intr.maximum(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @constant_fold_maximum_f64_nan0() -> f64 { + %0 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.intr.maximum(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @constant_fold_maximum_f64_nan1() -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %2 = llvm.intr.maximum(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @constant_fold_maximum_f64_nan_nan() -> f64 { + %0 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %1 = llvm.intr.maximum(%0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @canonicalize_constant_maximum_f32(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.maximum(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @maximum_f32_nan_val(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.intr.maximum(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @maximum_f32_val_nan(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.intr.maximum(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @maximum_f32_1_maximum_val_p0(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.maximum(%arg0, %0) : (f32, f32) -> f32 + %3 = llvm.intr.maximum(%2, %1) : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @maximum_f32_1_maximum_p0_val_fast(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.maximum(%0, %arg0) : (f32, f32) -> f32 + %3 = llvm.intr.maximum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @maximum_f32_1_maximum_p0_val_fmf1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.maximum(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.intr.maximum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @maximum_f32_1_maximum_p0_val_fmf2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.maximum(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.intr.maximum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @maximum_f32_1_maximum_p0_val_fmf3(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.maximum(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.intr.maximum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @maximum_f32_p0_maximum_val_n0(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.intr.maximum(%arg0, %0) : (f32, f32) -> f32 + %3 = llvm.intr.maximum(%2, %1) : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @maximum_f32_1_maximum_p0_val(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.maximum(%0, %arg0) : (f32, f32) -> f32 + %3 = llvm.intr.maximum(%2, %1) : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @maximum_f32_1_maximum_val_p0_val_v2f32(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.constant(dense<1.000000e+00> : vector<2xf32>) : vector<2xf32> + %3 = llvm.intr.maximum(%arg0, %1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + %4 = llvm.intr.maximum(%3, %2) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @maximum4(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: f32) -> f32 { + %0 = llvm.intr.maximum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maximum(%arg2, %arg3) : (f32, f32) -> f32 + %2 = llvm.intr.maximum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @neg_neg(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 : vector<2xf32> + %2 = llvm.fsub %0, %arg1 : vector<2xf32> + %3 = llvm.intr.maximum(%1, %2) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @unary_neg_neg(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fneg %arg0 : vector<2xf32> + %1 = llvm.fneg %arg1 : vector<2xf32> + %2 = llvm.intr.maximum(%0, %1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @neg_neg_vec_fmf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.intr.maximum(%1, %2) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @unary_neg_neg_vec_fmf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fneg %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.intr.maximum(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @use(f32) + llvm.func @neg_neg_extra_use_x(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fsub %0, %arg1 : f32 + %3 = llvm.intr.maximum(%1, %2) : (f32, f32) -> f32 + llvm.call @use(%1) : (f32) -> () + llvm.return %3 : f32 + } + llvm.func @unary_neg_neg_extra_use_x(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fneg %arg1 : f32 + %2 = llvm.intr.maximum(%0, %1) : (f32, f32) -> f32 + llvm.call @use(%0) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @neg_neg_extra_use_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fsub %0, %arg1 : f32 + %3 = llvm.intr.maximum(%1, %2) : (f32, f32) -> f32 + llvm.call @use(%2) : (f32) -> () + llvm.return %3 : f32 + } + llvm.func @unary_neg_neg_extra_use_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fneg %arg1 : f32 + %2 = llvm.intr.maximum(%0, %1) : (f32, f32) -> f32 + llvm.call @use(%1) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @neg_neg_extra_use_x_and_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fsub %0, %arg1 : f32 + %3 = llvm.intr.maximum(%1, %2) : (f32, f32) -> f32 + llvm.call @use(%1) : (f32) -> () + llvm.call @use(%2) : (f32) -> () + llvm.return %3 : f32 + } + llvm.func @unary_neg_neg_extra_use_x_and_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fneg %arg1 : f32 + %2 = llvm.intr.maximum(%0, %1) : (f32, f32) -> f32 + llvm.call @use(%0) : (f32) -> () + llvm.call @use(%1) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @reduce_precision(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.maximum(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @reduce_precision_fmf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.maximum(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @negated_op(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.intr.maximum(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @negated_op_fmf_commute_vec(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.fneg %arg0 : vector<2xf64> + %1 = llvm.intr.maximum(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @negated_op_extra_use(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + llvm.call @use(%0) : (f32) -> () + %1 = llvm.intr.maximum(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @negated_op_extra_use_comm(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + llvm.call @use(%0) : (f32) -> () + %1 = llvm.intr.maximum(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/maxnum.ll.mlir b/test/LLVMDialect/InstCombine/maxnum.ll.mlir new file mode 100644 index 000000000..d24457eed --- /dev/null +++ b/test/LLVMDialect/InstCombine/maxnum.ll.mlir @@ -0,0 +1,280 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @constant_fold_maxnum_f32() -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.intr.maxnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_maxnum_f32_inv() -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.maxnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_maxnum_f32_nan0() -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.intr.maxnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_maxnum_f32_nan1() -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %2 = llvm.intr.maxnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_maxnum_f32_nan_nan() -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.intr.maxnum(%0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_maxnum_f32_p0_p0() -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.intr.maxnum(%0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_maxnum_f32_p0_n0() -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.intr.maxnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_maxnum_f32_n0_p0() -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.intr.maxnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_maxnum_f32_n0_n0() -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.intr.maxnum(%0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_maxnum_v4f32() -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 8.000000e+00, 3.000000e+00, 9.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[2.000000e+00, 2.000000e+00, 1.000000e+01, 5.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.intr.maxnum(%0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @constant_fold_maxnum_f64() -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.intr.maxnum(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @constant_fold_maxnum_f64_nan0() -> f64 { + %0 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.intr.maxnum(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @constant_fold_maxnum_f64_nan1() -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %2 = llvm.intr.maxnum(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @constant_fold_maxnum_f64_nan_nan() -> f64 { + %0 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %1 = llvm.intr.maxnum(%0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @canonicalize_constant_maxnum_f32(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.maxnum(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @maxnum_f32_nan_val(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.intr.maxnum(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @maxnum_f32_val_nan(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.intr.maxnum(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @maxnum_f32_1_maxnum_val_p0(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.maxnum(%arg0, %0) : (f32, f32) -> f32 + %3 = llvm.intr.maxnum(%2, %1) : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @maxnum_f32_1_maxnum_p0_val_fast(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.maxnum(%0, %arg0) : (f32, f32) -> f32 + %3 = llvm.intr.maxnum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minnum_f32_1_maxnum_p0_val_fmf1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.maxnum(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.intr.maxnum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minnum_f32_1_maxnum_p0_val_fmf2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.maxnum(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.intr.maxnum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minnum_f32_1_maxnum_p0_val_fmf3(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.maxnum(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.intr.maxnum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @maxnum_f32_p0_maxnum_val_n0(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.intr.maxnum(%arg0, %0) : (f32, f32) -> f32 + %3 = llvm.intr.maxnum(%2, %1) : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @maxnum_f32_1_maxnum_p0_val(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.maxnum(%0, %arg0) : (f32, f32) -> f32 + %3 = llvm.intr.maxnum(%2, %1) : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @maxnum_f32_1_maxnum_val_p0_val_v2f32(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.constant(dense<1.000000e+00> : vector<2xf32>) : vector<2xf32> + %3 = llvm.intr.maxnum(%arg0, %1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + %4 = llvm.intr.maxnum(%3, %2) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @maxnum4(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: f32) -> f32 { + %0 = llvm.intr.maxnum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maxnum(%arg2, %arg3) : (f32, f32) -> f32 + %2 = llvm.intr.maxnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @neg_neg(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 : vector<2xf32> + %2 = llvm.fsub %0, %arg1 : vector<2xf32> + %3 = llvm.intr.maxnum(%1, %2) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @neg_neg_vec_fmf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.fsub %0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.intr.maxnum(%1, %2) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @unary_neg_neg_vec_fmf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fneg %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.intr.maxnum(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @use(f32) + llvm.func @neg_neg_extra_use_x(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fsub %0, %arg1 : f32 + %3 = llvm.intr.maxnum(%1, %2) : (f32, f32) -> f32 + llvm.call @use(%1) : (f32) -> () + llvm.return %3 : f32 + } + llvm.func @unary_neg_neg_extra_use_x(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fneg %arg1 : f32 + %2 = llvm.intr.maxnum(%0, %1) : (f32, f32) -> f32 + llvm.call @use(%0) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @neg_neg_extra_use_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fsub %0, %arg1 : f32 + %3 = llvm.intr.maxnum(%1, %2) : (f32, f32) -> f32 + llvm.call @use(%2) : (f32) -> () + llvm.return %3 : f32 + } + llvm.func @unary_neg_neg_extra_use_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fneg %arg1 : f32 + %2 = llvm.intr.maxnum(%0, %1) : (f32, f32) -> f32 + llvm.call @use(%1) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @neg_neg_extra_use_x_and_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fsub %0, %arg0 : f32 + %2 = llvm.fsub %0, %arg1 : f32 + %3 = llvm.intr.maxnum(%1, %2) : (f32, f32) -> f32 + llvm.call @use(%1) : (f32) -> () + llvm.call @use(%2) : (f32) -> () + llvm.return %3 : f32 + } + llvm.func @unary_neg_neg_extra_use_x_and_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fneg %arg1 : f32 + %2 = llvm.intr.maxnum(%0, %1) : (f32, f32) -> f32 + llvm.call @use(%0) : (f32) -> () + llvm.call @use(%1) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @reduce_precision(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.maxnum(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @reduce_precision_fmf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.maxnum(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @reduce_precision_multi_use_0(%arg0: f32, %arg1: f32, %arg2: !llvm.ptr) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + llvm.store %0, %arg2 {alignment = 8 : i64} : f64, !llvm.ptr + %2 = llvm.intr.maxnum(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @reduce_precision_multi_use_1(%arg0: f32, %arg1: f32, %arg2: !llvm.ptr) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + llvm.store %1, %arg2 {alignment = 8 : i64} : f64, !llvm.ptr + %2 = llvm.intr.maxnum(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @negated_op(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.intr.maxnum(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @negated_op_fmf_commute_vec(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.fneg %arg0 : vector<2xf64> + %1 = llvm.intr.maxnum(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @negated_op_extra_use(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + llvm.call @use(%0) : (f32) -> () + %1 = llvm.intr.maxnum(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @negated_op_extra_use_comm(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + llvm.call @use(%0) : (f32) -> () + %1 = llvm.intr.maxnum(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/mem-deref-bytes-addrspaces.ll.mlir b/test/LLVMDialect/InstCombine/mem-deref-bytes-addrspaces.ll.mlir index 39df3e013..932d265d4 100644 --- a/test/LLVMDialect/InstCombine/mem-deref-bytes-addrspaces.ll.mlir +++ b/test/LLVMDialect/InstCombine/mem-deref-bytes-addrspaces.ll.mlir @@ -1,16 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memcmp", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_const_size_update_deref", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_nonconst_size_nonnnull", type = !llvm.func, ptr, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @memcmp(!llvm.ptr<1> {llvm.nocapture}, !llvm.ptr<1> {llvm.nocapture}, i64) -> i32 + llvm.func @memcmp_const_size_update_deref(%arg0: !llvm.ptr<1> {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr<1> {llvm.nocapture, llvm.readonly}) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.call @memcmp(%arg0, %arg1, %0) : (!llvm.ptr<1>, !llvm.ptr<1>, i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @memcmp_nonconst_size_nonnnull(%arg0: !llvm.ptr<1> {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr<1> {llvm.nocapture, llvm.readonly}, %arg2: i64) -> i32 { + %0 = llvm.call @memcmp(%arg0, %arg1, %arg2) : (!llvm.ptr<1>, !llvm.ptr<1>, i64) -> i32 + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/mem-deref-bytes.ll.mlir b/test/LLVMDialect/InstCombine/mem-deref-bytes.ll.mlir index c68a60654..5e955b0b2 100644 --- a/test/LLVMDialect/InstCombine/mem-deref-bytes.ll.mlir +++ b/test/LLVMDialect/InstCombine/mem-deref-bytes.ll.mlir @@ -1,123 +1,91 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memcmp", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memcpy", type = !llvm.func (ptr, ptr, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memmove", type = !llvm.func (ptr, ptr, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memset", type = !llvm.func (ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memchr", type = !llvm.func (ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memcpy.p0i8.p0i8.i64", type = !llvm.func, ptr, i64, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memmove.p0i8.p0i8.i64", type = !llvm.func, ptr, i64, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memset.p0i8.i64", type = !llvm.func, i8, i64, i1)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_const_size_set_deref", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_const_size_update_deref", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_const_size_update_deref2", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_const_size_update_deref3", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_const_size_update_deref4", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_const_size_update_deref5", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_const_size_update_deref6", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_const_size_update_deref7", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_const_size_no_update_deref", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_nonconst_size", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 64 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memcpy_const_size_set_deref", type = !llvm.func (ptr, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 64 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memmove, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memmove_const_size_set_deref", type = !llvm.func (ptr, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 64 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memset, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memset_const_size_set_deref", type = !llvm.func (ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 64 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memchr_const_size_set_deref", type = !llvm.func (ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - "llvm.call"(%arg0, %arg1, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - "llvm.return"(%arg0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "llvm_memcpy_const_size_set_deref", type = !llvm.func (ptr, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - "llvm.call"(%arg0, %arg1, %1, %0) {callee = @llvm.memmove.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - "llvm.return"(%arg0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "llvm_memmove_const_size_set_deref", type = !llvm.func (ptr, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - "llvm.call"(%arg0, %arg1, %1, %0) {callee = @llvm.memset.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i64, i1) -> () - "llvm.return"(%arg0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "llvm_memset_const_size_set_deref", type = !llvm.func (ptr, i8)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @memcmp(!llvm.ptr {llvm.nocapture}, !llvm.ptr {llvm.nocapture}, i64) -> i32 + llvm.func @memcpy(!llvm.ptr {llvm.nocapture}, !llvm.ptr {llvm.nocapture}, i64) -> !llvm.ptr + llvm.func @memmove(!llvm.ptr {llvm.nocapture}, !llvm.ptr {llvm.nocapture}, i64) -> !llvm.ptr + llvm.func @memset(!llvm.ptr {llvm.nocapture}, i32, i64) -> !llvm.ptr + llvm.func @memchr(!llvm.ptr {llvm.nocapture}, i32, i64) -> !llvm.ptr + llvm.func @memcmp_const_size_set_deref(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.call @memcmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @memcmp_const_size_update_deref(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.call @memcmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @memcmp_const_size_update_deref2(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.call @memcmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @memcmp_const_size_update_deref3(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.call @memcmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @memcmp_const_size_update_deref4(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.call @memcmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @memcmp_const_size_update_deref5(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.call @memcmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @memcmp_const_size_update_deref6(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> i32 attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.call @memcmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @memcmp_const_size_update_deref7(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> i32 attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.call @memcmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @memcmp_const_size_no_update_deref(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.call @memcmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %1 : i32 + } + llvm.func @memcmp_nonconst_size(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg2: i64) -> i32 { + %0 = llvm.call @memcmp(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %0 : i32 + } + llvm.func @memcpy_const_size_set_deref(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> !llvm.ptr { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.call @memcpy(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @memmove_const_size_set_deref(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> !llvm.ptr { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.call @memmove(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @memset_const_size_set_deref(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.call @memset(%arg0, %arg1, %0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @memchr_const_size_set_deref(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.call @memchr(%arg0, %arg1, %0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @llvm_memcpy_const_size_set_deref(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> !llvm.ptr { + %0 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return %arg0 : !llvm.ptr + } + llvm.func @llvm_memmove_const_size_set_deref(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> !llvm.ptr { + %0 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memmove"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return %arg0 : !llvm.ptr + } + llvm.func @llvm_memset_const_size_set_deref(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: i8) -> !llvm.ptr { + %0 = llvm.mlir.constant(16 : i64) : i64 + "llvm.intr.memset"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, i8, i64) -> () + llvm.return %arg0 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/mem-gep-zidx.ll.mlir b/test/LLVMDialect/InstCombine/mem-gep-zidx.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/mem-par-metadata-memcpy.ll.mlir b/test/LLVMDialect/InstCombine/mem-par-metadata-memcpy.ll.mlir index 41b291af8..db0a208cd 100644 --- a/test/LLVMDialect/InstCombine/mem-par-metadata-memcpy.ll.mlir +++ b/test/LLVMDialect/InstCombine/mem-par-metadata-memcpy.ll.mlir @@ -1,26 +1,24 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - "llvm.br"(%2)[^bb1] : (i64) -> () - ^bb1(%3: i64): // 2 preds: ^bb0, ^bb3 - %4 = "llvm.icmp"(%3, %arg1) {predicate = 2 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%4)[^bb2, ^bb4] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +#access_group = #llvm.access_group> +#loop_vectorize = #llvm.loop_vectorize +#loop_annotation = #llvm.loop_annotation +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @_Z4testPcl(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + llvm.br ^bb1(%0 : i64) + ^bb1(%2: i64): // 2 preds: ^bb0, ^bb3 + %3 = llvm.icmp "slt" %2, %arg1 : i64 + llvm.cond_br %3, ^bb2, ^bb4 ^bb2: // pred: ^bb1 - %5 = "llvm.getelementptr"(%arg0, %3) : (!llvm.ptr, i64) -> !llvm.ptr - %6 = "llvm.add"(%3, %arg1) : (i64, i64) -> i64 - %7 = "llvm.getelementptr"(%arg0, %6) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%5, %7, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - "llvm.br"()[^bb3] : () -> () + %4 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %5 = llvm.add %2, %arg1 overflow : i64 + %6 = llvm.getelementptr inbounds %arg0[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + "llvm.intr.memcpy"(%4, %6, %1) <{access_groups = [#access_group], isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.br ^bb3 ^bb3: // pred: ^bb2 - %8 = "llvm.add"(%3, %1) : (i64, i64) -> i64 - "llvm.br"(%8)[^bb1] : (i64) -> () + %7 = llvm.add %2, %1 overflow : i64 + llvm.br ^bb1(%7 : i64) {loop_annotation = #loop_annotation} ^bb4: // pred: ^bb1 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "_Z4testPcl", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memcpy.p0i8.p0i8.i64", type = !llvm.func, ptr, i64, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/memccpy.ll.mlir b/test/LLVMDialect/InstCombine/memccpy.ll.mlir index 07dd4617d..42801c53a 100644 --- a/test/LLVMDialect/InstCombine/memccpy.ll.mlir +++ b/test/LLVMDialect/InstCombine/memccpy.ll.mlir @@ -1,271 +1,213 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = "hello", type = !llvm.array<11 x i8>, value = "helloworld\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = "NoNulTerminator", type = !llvm.array<10 x i8>, value = "helloworld"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = "StopCharAfterNulTerminator", type = !llvm.array<12 x i8>, value = "helloworld\00x"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "StringWithEOF", type = !llvm.array<14 x i8>, value = "helloworld\FFab\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memccpy", type = !llvm.func (ptr, ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 12 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 114 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 114 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy2", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 111 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy3", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 111 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy3_tail", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32, %arg3: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 111 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy3_musttail", type = !llvm.func (ptr, ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 12 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy4", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 114 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy5", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 114 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy5_tail", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32, %arg3: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 114 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy5_musttail", type = !llvm.func (ptr, ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 114 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy6", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 115 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy7", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 11 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 115 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy8", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 15 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 120 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @StopCharAfterNulTerminator} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy9", type = !llvm.func (ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 15 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 255 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @StringWithEOF} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy10", type = !llvm.func (ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 15 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @StringWithEOF} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy11", type = !llvm.func (ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 15 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1023 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @StringWithEOF} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy12", type = !llvm.func (ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %arg2, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_null", type = !llvm.func (ptr, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32, %arg2: i64): // no predecessors - %0 = "llvm.call"(%arg0, %arg0, %arg1, %arg2) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "memccpy_dst_src_same_retval_unused", type = !llvm.func, i32, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 12 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 114 : i32} : () -> i32 - %2 = "llvm.call"(%arg0, %arg1, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "unknown_src", type = !llvm.func (ptr, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 12 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %arg1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "unknown_stop_char", type = !llvm.func (ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 114 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %0, %arg1) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "unknown_size_n", type = !llvm.func (ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 120 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @StopCharAfterNulTerminator} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %0, %arg1) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "no_nul_terminator", type = !llvm.func (ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 115 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @NoNulTerminator} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %0, %arg1) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "possibly_valid_data_after_array", type = !llvm.func (ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 115 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %0, %arg1) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "possibly_valid_data_after_array2", type = !llvm.func (ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 12 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 115 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "possibly_valid_data_after_array3", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32, %arg2: i64): // no predecessors - %0 = "llvm.call"(%arg0, %arg0, %arg1, %arg2) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_dst_src_same_retval_used", type = !llvm.func (ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32, %arg3: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 12 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 114 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy_musttail", type = !llvm.func (ptr, ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32, %arg3: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 114 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1, %0) {callee = @memccpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memccpy_to_memcpy2_musttail", type = !llvm.func (ptr, ptr, i32, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private constant @hello("helloworld\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private constant @NoNulTerminator("helloworld") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private constant @StopCharAfterNulTerminator("helloworld\00x") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global external constant @StringWithEOF("helloworld\FFab\00") {addr_space = 0 : i32, alignment = 1 : i64} + llvm.func @memccpy(!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @memccpy_to_memcpy(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(114 : i32) : i32 + %3 = llvm.mlir.constant(12 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_to_memcpy2(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(114 : i32) : i32 + %3 = llvm.mlir.constant(8 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_to_memcpy3(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(111 : i32) : i32 + %3 = llvm.mlir.constant(10 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return + } + llvm.func @memccpy_to_memcpy3_tail(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(111 : i32) : i32 + %3 = llvm.mlir.constant(10 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return + } + llvm.func @memccpy_to_memcpy3_musttail(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32, %arg3: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(111 : i32) : i32 + %3 = llvm.mlir.constant(10 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_to_memcpy4(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(12 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return + } + llvm.func @memccpy_to_memcpy5(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(114 : i32) : i32 + %3 = llvm.mlir.constant(7 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_to_memcpy5_tail(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(114 : i32) : i32 + %3 = llvm.mlir.constant(7 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_to_memcpy5_musttail(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32, %arg3: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(114 : i32) : i32 + %3 = llvm.mlir.constant(7 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_to_memcpy6(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(114 : i32) : i32 + %3 = llvm.mlir.constant(6 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_to_memcpy7(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(115 : i32) : i32 + %3 = llvm.mlir.constant(5 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_to_memcpy8(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(115 : i32) : i32 + %3 = llvm.mlir.constant(11 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_to_memcpy9(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00x") : !llvm.array<12 x i8> + %1 = llvm.mlir.addressof @StopCharAfterNulTerminator : !llvm.ptr + %2 = llvm.mlir.constant(120 : i32) : i32 + %3 = llvm.mlir.constant(15 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_to_memcpy10(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\FFab\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @StringWithEOF : !llvm.ptr + %2 = llvm.mlir.constant(255 : i32) : i32 + %3 = llvm.mlir.constant(15 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_to_memcpy11(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\FFab\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @StringWithEOF : !llvm.ptr + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(15 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_to_memcpy12(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\FFab\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @StringWithEOF : !llvm.ptr + %2 = llvm.mlir.constant(1023 : i32) : i32 + %3 = llvm.mlir.constant(15 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_to_null(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @memccpy(%arg0, %arg1, %arg2, %0) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @memccpy_dst_src_same_retval_unused(%arg0: !llvm.ptr, %arg1: i32, %arg2: i64) { + %0 = llvm.call @memccpy(%arg0, %arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return + } + llvm.func @unknown_src(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(114 : i32) : i32 + %1 = llvm.mlir.constant(12 : i64) : i64 + %2 = llvm.call @memccpy(%arg0, %arg1, %0, %1) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @unknown_stop_char(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(12 : i64) : i64 + %3 = llvm.call @memccpy(%arg0, %1, %arg1, %2) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @unknown_size_n(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(114 : i32) : i32 + %3 = llvm.call @memccpy(%arg0, %1, %2, %arg1) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @no_nul_terminator(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00x") : !llvm.array<12 x i8> + %1 = llvm.mlir.addressof @StopCharAfterNulTerminator : !llvm.ptr + %2 = llvm.mlir.constant(120 : i32) : i32 + %3 = llvm.call @memccpy(%arg0, %1, %2, %arg1) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @possibly_valid_data_after_array(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld") : !llvm.array<10 x i8> + %1 = llvm.mlir.addressof @NoNulTerminator : !llvm.ptr + %2 = llvm.mlir.constant(115 : i32) : i32 + %3 = llvm.call @memccpy(%arg0, %1, %2, %arg1) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @possibly_valid_data_after_array2(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(115 : i32) : i32 + %3 = llvm.call @memccpy(%arg0, %1, %2, %arg1) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @possibly_valid_data_after_array3(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(115 : i32) : i32 + %3 = llvm.mlir.constant(12 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_dst_src_same_retval_used(%arg0: !llvm.ptr, %arg1: i32, %arg2: i64) -> !llvm.ptr { + %0 = llvm.call @memccpy(%arg0, %arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @memccpy_to_memcpy_musttail(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32, %arg3: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(114 : i32) : i32 + %3 = llvm.mlir.constant(12 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memccpy_to_memcpy2_musttail(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32, %arg3: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("helloworld\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(114 : i32) : i32 + %3 = llvm.mlir.constant(8 : i64) : i64 + %4 = llvm.call @memccpy(%arg0, %1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memchr-10.ll.mlir b/test/LLVMDialect/InstCombine/memchr-10.ll.mlir new file mode 100644 index 000000000..e53f220e4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/memchr-10.ll.mlir @@ -0,0 +1,62 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a5("12345") {addr_space = 0 : i32} + llvm.func @memchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @call_memchr_ap5_c_1_eq_a(%arg0: i32, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.mlir.constant(1 : i64) : i64 + %6 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %7 = llvm.getelementptr %1[%4, %2] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %8 = llvm.call @memchr(%6, %arg0, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %9 = llvm.icmp "eq" %8, %7 : !llvm.ptr + llvm.return %9 : i1 + } + llvm.func @call_memchr_ap5_c_5_eq_a(%arg0: i32, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.mlir.constant(5 : i64) : i64 + %6 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %7 = llvm.getelementptr %1[%4, %2] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %8 = llvm.call @memchr(%6, %arg0, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %9 = llvm.icmp "eq" %8, %7 : !llvm.ptr + llvm.return %9 : i1 + } + llvm.func @fold_memchr_ap5_c_n_eq_a(%arg0: i32, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.call @memchr(%4, %arg0, %arg1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %6 = llvm.icmp "eq" %5, %1 : !llvm.ptr + llvm.return %6 : i1 + } + llvm.func @fold_memchr_ap5_c_n_eqz(%arg0: i32, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.zero : !llvm.ptr + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @memchr(%5, %arg0, %arg1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %7 = llvm.icmp "eq" %6, %4 : !llvm.ptr + llvm.return %7 : i1 + } + llvm.func @fold_memchr_a_nul_n_eqz(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.zero : !llvm.ptr + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @memchr(%5, %2, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %7 = llvm.icmp "eq" %6, %4 : !llvm.ptr + llvm.return %7 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/memchr-11.ll.mlir b/test/LLVMDialect/InstCombine/memchr-11.ll.mlir new file mode 100644 index 000000000..860ad5998 --- /dev/null +++ b/test/LLVMDialect/InstCombine/memchr-11.ll.mlir @@ -0,0 +1,52 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a5("12345") {addr_space = 0 : i32} + llvm.func @memchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @fold_memchr_a_c_5_eq_a(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %4 = llvm.icmp "eq" %3, %1 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @fold_memchr_a_c_n_eq_a(%arg0: i32, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.call @memchr(%1, %arg0, %arg1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %3 = llvm.icmp "eq" %2, %1 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @call_memchr_api_c_n_eq_a(%arg0: i64, %arg1: i32, %arg2: i64) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.getelementptr %1[%2, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<5 x i8> + %4 = llvm.call @memchr(%3, %arg1, %arg2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %5 = llvm.icmp "eq" %4, %3 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @fold_memchr_s_c_15_eq_s(%arg0: !llvm.ptr, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(15 : i64) : i64 + %1 = llvm.call @memchr(%arg0, %arg1, %0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %2 = llvm.icmp "eq" %1, %arg0 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @fold_memchr_s_c_17_neq_s(%arg0: !llvm.ptr, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(17 : i64) : i64 + %1 = llvm.call @memchr(%arg0, %arg1, %0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %2 = llvm.icmp "ne" %1, %arg0 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @fold_memchr_s_c_nz_eq_s(%arg0: !llvm.ptr, %arg1: i32, %arg2: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.or %arg2, %0 : i64 + %2 = llvm.call @memchr(%arg0, %arg1, %1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %3 = llvm.icmp "eq" %2, %arg0 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @call_memchr_s_c_n_eq_s(%arg0: !llvm.ptr, %arg1: i32, %arg2: i64) -> i1 { + %0 = llvm.call @memchr(%arg0, %arg1, %arg2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %1 = llvm.icmp "eq" %0, %arg0 : !llvm.ptr + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/memchr-2.ll.mlir b/test/LLVMDialect/InstCombine/memchr-2.ll.mlir index 8e38bb124..41940c4ad 100644 --- a/test/LLVMDialect/InstCombine/memchr-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/memchr-2.ll.mlir @@ -1,92 +1,73 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "ax", type = !llvm.array<0 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a12345", type = !llvm.array<5 x i8>, value = "\01\02\03\04\05"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a123f45", type = !llvm.array<5 x i8>, value = "\01\02\03\F4\05"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memchr", type = !llvm.func (ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0, %arg0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memchr_a12345_6_n", type = !llvm.func (i64)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memchr_a12345_4_2", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memchr_a12345_4_3", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memchr_a12345_3_3", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 9 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memchr_a12345_3_9", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 9 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 500 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a123f45} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memchr_a123f45_500_9", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0, %arg0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_a12345_3_n", type = !llvm.func (i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 259 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0, %arg0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_a12345_259_n", type = !llvm.func (i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0, %arg0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_ax_1_n", type = !llvm.func (i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @ax() {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.mlir.global external constant @a12345("\01\02\03\04\05") {addr_space = 0 : i32} + llvm.mlir.global external constant @a123f45("\01\02\03\F4\05") {addr_space = 0 : i32} + llvm.func @memchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @fold_memchr_a12345_6_n(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(6 : i32) : i32 + %3 = llvm.call @memchr(%1, %2, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @fold_memchr_a12345_4_2() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.constant(2 : i64) : i64 + %4 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memchr_a12345_4_3() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.constant(3 : i64) : i64 + %4 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memchr_a12345_3_3() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(3 : i64) : i64 + %4 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memchr_a12345_3_9() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(9 : i64) : i64 + %4 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memchr_a123f45_500_9() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\F4\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a123f45 : !llvm.ptr + %2 = llvm.mlir.constant(500 : i32) : i32 + %3 = llvm.mlir.constant(9 : i64) : i64 + %4 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_a12345_3_n(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.call @memchr(%1, %2, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @fold_a12345_259_n(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(259 : i32) : i32 + %3 = llvm.call @memchr(%1, %2, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @call_ax_1_n(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.call @memchr(%0, %1, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memchr-3.ll.mlir b/test/LLVMDialect/InstCombine/memchr-3.ll.mlir index 2b38fcce7..4681f044c 100644 --- a/test/LLVMDialect/InstCombine/memchr-3.ll.mlir +++ b/test/LLVMDialect/InstCombine/memchr-3.ll.mlir @@ -1,46 +1,34 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "ax", type = !llvm.array<0 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a12345", type = !llvm.array<5 x i8>, value = "\01\02\03\04\05"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memchr", type = !llvm.func (ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memchr_a12345_1_1", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memchr_a12345_2_1", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 257 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memchr_ax_257_1", type = !llvm.func (i32, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memchr_ax_c_1", type = !llvm.func (i32, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @ax() {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.mlir.global external constant @a12345("\01\02\03\04\05") {addr_space = 0 : i32} + llvm.func @memchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @fold_memchr_a12345_1_1() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memchr_a12345_2_1() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memchr_ax_257_1(%arg0: i32, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(257 : i32) : i32 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.call @memchr(%0, %1, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @fold_memchr_ax_c_1(%arg0: i32, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.call @memchr(%0, %arg0, %1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memchr-4.ll.mlir b/test/LLVMDialect/InstCombine/memchr-4.ll.mlir index 3ca2bec5b..37e442c3b 100644 --- a/test/LLVMDialect/InstCombine/memchr-4.ll.mlir +++ b/test/LLVMDialect/InstCombine/memchr-4.ll.mlir @@ -1,45 +1,34 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "ax", type = !llvm.array<0 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a12345", type = !llvm.array<5 x i8>, value = "\01\02\03\04\05"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memchr", type = !llvm.func (ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4294967296 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_memchr_ax_2_uimax_p1", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4294967296 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_memchr_ax_2_uimax_p2", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4294967297 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memchr_a12345_3_uimax_p2", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4294967297 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memchr_a12345_c_uimax_p2", type = !llvm.func (i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @ax() {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.mlir.global external constant @a12345("\01\02\03\04\05") {addr_space = 0 : i32} + llvm.func @memchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @call_memchr_ax_2_uimax_p1() -> !llvm.ptr { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(4294967296 : i64) : i64 + %3 = llvm.call @memchr(%0, %1, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @call_memchr_ax_2_uimax_p2() -> !llvm.ptr { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(4294967296 : i64) : i64 + %3 = llvm.call @memchr(%0, %1, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @fold_memchr_a12345_3_uimax_p2() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(4294967297 : i64) : i64 + %4 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memchr_a12345_c_uimax_p2(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(4294967297 : i64) : i64 + %3 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memchr-5.ll.mlir b/test/LLVMDialect/InstCombine/memchr-5.ll.mlir index df5507fba..728cf723b 100644 --- a/test/LLVMDialect/InstCombine/memchr-5.ll.mlir +++ b/test/LLVMDialect/InstCombine/memchr-5.ll.mlir @@ -1,121 +1,111 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a", type = !llvm.array<4 x i32>, value = dense<[1633837924, 1701209960, 1768581996, 1835954032]> : tensor<4xi32>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memchr", type = !llvm.func (ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 113 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 112 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 111 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %7 = "llvm.mlir.constant"() {value = 110 : i32} : () -> i32 - %8 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %9 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %10 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %11 = "llvm.mlir.constant"() {value = 99 : i32} : () -> i32 - %12 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %13 = "llvm.mlir.constant"() {value = 98 : i32} : () -> i32 - %14 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %15 = "llvm.mlir.constant"() {value = 97 : i32} : () -> i32 - %16 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %17 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %18 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %19 = "llvm.getelementptr"(%18, %17, %17) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %20 = "llvm.bitcast"(%19) : (!llvm.ptr) -> !llvm.ptr - %21 = "llvm.ptrtoint"(%16) : (!llvm.ptr>) -> i64 - %22 = "llvm.call"(%20, %15, %14) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %23 = "llvm.ptrtoint"(%22) : (!llvm.ptr) -> i64 - %24 = "llvm.sub"(%23, %21) : (i64, i64) -> i64 - %25 = "llvm.getelementptr"(%arg0, %17) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%24, %25) : (i64, !llvm.ptr) -> () - %26 = "llvm.call"(%20, %13, %14) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %27 = "llvm.ptrtoint"(%26) : (!llvm.ptr) -> i64 - %28 = "llvm.sub"(%27, %21) : (i64, i64) -> i64 - %29 = "llvm.getelementptr"(%arg0, %12) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%28, %29) : (i64, !llvm.ptr) -> () - %30 = "llvm.call"(%20, %11, %14) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %31 = "llvm.ptrtoint"(%30) : (!llvm.ptr) -> i64 - %32 = "llvm.sub"(%31, %21) : (i64, i64) -> i64 - %33 = "llvm.getelementptr"(%arg0, %10) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%32, %33) : (i64, !llvm.ptr) -> () - %34 = "llvm.call"(%20, %9, %14) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %35 = "llvm.ptrtoint"(%34) : (!llvm.ptr) -> i64 - %36 = "llvm.sub"(%35, %21) : (i64, i64) -> i64 - %37 = "llvm.getelementptr"(%arg0, %8) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%36, %37) : (i64, !llvm.ptr) -> () - %38 = "llvm.call"(%20, %7, %14) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %39 = "llvm.ptrtoint"(%38) : (!llvm.ptr) -> i64 - %40 = "llvm.sub"(%39, %21) : (i64, i64) -> i64 - %41 = "llvm.getelementptr"(%arg0, %6) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%40, %41) : (i64, !llvm.ptr) -> () - %42 = "llvm.call"(%20, %5, %14) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %43 = "llvm.ptrtoint"(%42) : (!llvm.ptr) -> i64 - %44 = "llvm.sub"(%43, %21) : (i64, i64) -> i64 - %45 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%44, %45) : (i64, !llvm.ptr) -> () - %46 = "llvm.call"(%20, %3, %14) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %47 = "llvm.ptrtoint"(%46) : (!llvm.ptr) -> i64 - %48 = "llvm.sub"(%47, %21) : (i64, i64) -> i64 - %49 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%48, %49) : (i64, !llvm.ptr) -> () - %50 = "llvm.call"(%20, %1, %14) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %51 = "llvm.ptrtoint"(%50) : (!llvm.ptr) -> i64 - %52 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%51, %52) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memchr_a", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 97 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 104 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %7 = "llvm.mlir.constant"() {value = 103 : i32} : () -> i32 - %8 = "llvm.mlir.constant"() {value = 102 : i32} : () -> i32 - %9 = "llvm.mlir.constant"() {value = 12 : i64} : () -> i64 - %10 = "llvm.mlir.constant"() {value = 101 : i32} : () -> i32 - %11 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %12 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %13 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %14 = "llvm.getelementptr"(%13, %12, %11) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %15 = "llvm.bitcast"(%14) : (!llvm.ptr) -> !llvm.ptr - %16 = "llvm.ptrtoint"(%15) : (!llvm.ptr) -> i64 - %17 = "llvm.call"(%15, %10, %9) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %18 = "llvm.ptrtoint"(%17) : (!llvm.ptr) -> i64 - %19 = "llvm.sub"(%18, %16) : (i64, i64) -> i64 - %20 = "llvm.getelementptr"(%arg0, %12) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%19, %20) : (i64, !llvm.ptr) -> () - %21 = "llvm.call"(%15, %8, %9) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %22 = "llvm.ptrtoint"(%21) : (!llvm.ptr) -> i64 - %23 = "llvm.sub"(%22, %16) : (i64, i64) -> i64 - %24 = "llvm.getelementptr"(%arg0, %11) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%23, %24) : (i64, !llvm.ptr) -> () - %25 = "llvm.call"(%15, %7, %9) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %26 = "llvm.ptrtoint"(%25) : (!llvm.ptr) -> i64 - %27 = "llvm.sub"(%26, %16) : (i64, i64) -> i64 - %28 = "llvm.getelementptr"(%arg0, %6) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%27, %28) : (i64, !llvm.ptr) -> () - %29 = "llvm.call"(%15, %5, %9) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %30 = "llvm.ptrtoint"(%29) : (!llvm.ptr) -> i64 - %31 = "llvm.sub"(%30, %16) : (i64, i64) -> i64 - %32 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%31, %32) : (i64, !llvm.ptr) -> () - %33 = "llvm.call"(%15, %3, %9) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %34 = "llvm.ptrtoint"(%33) : (!llvm.ptr) -> i64 - %35 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%34, %35) : (i64, !llvm.ptr) -> () - %36 = "llvm.call"(%15, %1, %9) {callee = @memchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %37 = "llvm.ptrtoint"(%36) : (!llvm.ptr) -> i64 - %38 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%37, %38) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memchr_a_p1", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a(dense<[1633837924, 1701209960, 1768581996, 1835954032]> : tensor<4xi32>) {addr_space = 0 : i32} : !llvm.array<4 x i32> + llvm.func @memchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @fold_memchr_a(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<[1633837924, 1701209960, 1768581996, 1835954032]> : tensor<4xi32>) : !llvm.array<4 x i32> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(97 : i32) : i32 + %3 = llvm.mlir.constant(16 : i64) : i64 + %4 = llvm.mlir.constant(98 : i32) : i32 + %5 = llvm.mlir.constant(1 : i64) : i64 + %6 = llvm.mlir.constant(99 : i32) : i32 + %7 = llvm.mlir.constant(2 : i64) : i64 + %8 = llvm.mlir.constant(100 : i32) : i32 + %9 = llvm.mlir.constant(3 : i64) : i64 + %10 = llvm.mlir.constant(110 : i32) : i32 + %11 = llvm.mlir.constant(4 : i64) : i64 + %12 = llvm.mlir.constant(111 : i32) : i32 + %13 = llvm.mlir.constant(6 : i64) : i64 + %14 = llvm.mlir.constant(112 : i32) : i32 + %15 = llvm.mlir.constant(7 : i64) : i64 + %16 = llvm.mlir.constant(113 : i32) : i32 + %17 = llvm.mlir.constant(8 : i64) : i64 + %18 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %19 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %20 = llvm.ptrtoint %19 : !llvm.ptr to i64 + %21 = llvm.sub %20, %18 : i64 + llvm.store %21, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %22 = llvm.call @memchr(%1, %4, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %23 = llvm.ptrtoint %22 : !llvm.ptr to i64 + %24 = llvm.sub %23, %18 : i64 + %25 = llvm.getelementptr %arg0[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %24, %25 {alignment = 4 : i64} : i64, !llvm.ptr + %26 = llvm.call @memchr(%1, %6, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %27 = llvm.ptrtoint %26 : !llvm.ptr to i64 + %28 = llvm.sub %27, %18 : i64 + %29 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %28, %29 {alignment = 4 : i64} : i64, !llvm.ptr + %30 = llvm.call @memchr(%1, %8, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %31 = llvm.ptrtoint %30 : !llvm.ptr to i64 + %32 = llvm.sub %31, %18 : i64 + %33 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %32, %33 {alignment = 4 : i64} : i64, !llvm.ptr + %34 = llvm.call @memchr(%1, %10, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %35 = llvm.ptrtoint %34 : !llvm.ptr to i64 + %36 = llvm.sub %35, %18 : i64 + %37 = llvm.getelementptr %arg0[%11] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %36, %37 {alignment = 4 : i64} : i64, !llvm.ptr + %38 = llvm.call @memchr(%1, %12, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %39 = llvm.ptrtoint %38 : !llvm.ptr to i64 + %40 = llvm.sub %39, %18 : i64 + %41 = llvm.getelementptr %arg0[%13] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %40, %41 {alignment = 4 : i64} : i64, !llvm.ptr + %42 = llvm.call @memchr(%1, %14, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %43 = llvm.ptrtoint %42 : !llvm.ptr to i64 + %44 = llvm.sub %43, %18 : i64 + %45 = llvm.getelementptr %arg0[%15] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %44, %45 {alignment = 4 : i64} : i64, !llvm.ptr + %46 = llvm.call @memchr(%1, %16, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %47 = llvm.ptrtoint %46 : !llvm.ptr to i64 + %48 = llvm.getelementptr %arg0[%17] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %47, %48 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_memchr_a_p1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<[1633837924, 1701209960, 1768581996, 1835954032]> : tensor<4xi32>) : !llvm.array<4 x i32> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(101 : i32) : i32 + %5 = llvm.mlir.constant(12 : i64) : i64 + %6 = llvm.mlir.constant(102 : i32) : i32 + %7 = llvm.mlir.constant(103 : i32) : i32 + %8 = llvm.mlir.constant(2 : i64) : i64 + %9 = llvm.mlir.constant(104 : i32) : i32 + %10 = llvm.mlir.constant(3 : i64) : i64 + %11 = llvm.mlir.constant(97 : i32) : i32 + %12 = llvm.mlir.constant(4 : i64) : i64 + %13 = llvm.mlir.constant(100 : i32) : i32 + %14 = llvm.mlir.constant(5 : i64) : i64 + %15 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i32> + %16 = llvm.ptrtoint %15 : !llvm.ptr to i64 + %17 = llvm.call @memchr(%15, %4, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %18 = llvm.ptrtoint %17 : !llvm.ptr to i64 + %19 = llvm.sub %18, %16 : i64 + llvm.store %19, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %20 = llvm.call @memchr(%15, %6, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %21 = llvm.ptrtoint %20 : !llvm.ptr to i64 + %22 = llvm.sub %21, %16 : i64 + %23 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %22, %23 {alignment = 4 : i64} : i64, !llvm.ptr + %24 = llvm.call @memchr(%15, %7, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %25 = llvm.ptrtoint %24 : !llvm.ptr to i64 + %26 = llvm.sub %25, %16 : i64 + %27 = llvm.getelementptr %arg0[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %26, %27 {alignment = 4 : i64} : i64, !llvm.ptr + %28 = llvm.call @memchr(%15, %9, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %29 = llvm.ptrtoint %28 : !llvm.ptr to i64 + %30 = llvm.sub %29, %16 : i64 + %31 = llvm.getelementptr %arg0[%10] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %30, %31 {alignment = 4 : i64} : i64, !llvm.ptr + %32 = llvm.call @memchr(%15, %11, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %33 = llvm.ptrtoint %32 : !llvm.ptr to i64 + %34 = llvm.getelementptr %arg0[%12] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %33, %34 {alignment = 4 : i64} : i64, !llvm.ptr + %35 = llvm.call @memchr(%15, %13, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %36 = llvm.ptrtoint %35 : !llvm.ptr to i64 + %37 = llvm.getelementptr %arg0[%14] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %36, %37 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/memchr-6.ll.mlir b/test/LLVMDialect/InstCombine/memchr-6.ll.mlir new file mode 100644 index 000000000..14e481908 --- /dev/null +++ b/test/LLVMDialect/InstCombine/memchr-6.ll.mlir @@ -0,0 +1,61 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a00000(dense<0> : tensor<5xi8>) {addr_space = 0 : i32} : !llvm.array<5 x i8> + llvm.mlir.global external constant @a11111("\01\01\01\01\01") {addr_space = 0 : i32} + llvm.mlir.global external constant @a111122("\01\01\01\01\02\02") {addr_space = 0 : i32} + llvm.mlir.global external constant @a1110111("\01\01\01\00\01\01\01") {addr_space = 0 : i32} + llvm.func @memchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @fold_memchr_a00000_c_5(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<5xi8>) : !llvm.array<5 x i8> + %2 = llvm.mlir.addressof @a00000 : !llvm.ptr + %3 = llvm.mlir.constant(5 : i64) : i64 + %4 = llvm.call @memchr(%2, %arg0, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memchr_a11111_c_5(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\01\01") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a11111 : !llvm.ptr + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @fold_memchr_a11111_c_n(%arg0: i32, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\01\01") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a11111 : !llvm.ptr + %2 = llvm.call @memchr(%1, %arg0, %arg1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @fold_memchr_a111122_c_n(%arg0: i32, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\01\02\02") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @a111122 : !llvm.ptr + %2 = llvm.call @memchr(%1, %arg0, %arg1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @fold_memchr_a1110111_c_3(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\00\01\01\01") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @a1110111 : !llvm.ptr + %2 = llvm.mlir.constant(3 : i64) : i64 + %3 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @call_memchr_a1110111_c_4(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\00\01\01\01") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @a1110111 : !llvm.ptr + %2 = llvm.mlir.constant(4 : i64) : i64 + %3 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @call_memchr_a1110111_c_7(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\00\01\01\01") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @a1110111 : !llvm.ptr + %2 = llvm.mlir.constant(7 : i64) : i64 + %3 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @call_memchr_a1110111_c_n(%arg0: i32, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\00\01\01\01") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @a1110111 : !llvm.ptr + %2 = llvm.call @memchr(%1, %arg0, %arg1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memchr-7.ll.mlir b/test/LLVMDialect/InstCombine/memchr-7.ll.mlir new file mode 100644 index 000000000..4d32efa44 --- /dev/null +++ b/test/LLVMDialect/InstCombine/memchr-7.ll.mlir @@ -0,0 +1,100 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private unnamed_addr constant @".str"("abcdefghijklmnopqrstuvwxyz\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.1"("\0D\0A") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.2"("abcdefmno\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.3"("abcijkmno\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.4"("mnabcc\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.func @strchr(!llvm.ptr, i32) -> !llvm.ptr + llvm.func @memchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @strchr_to_memchr_n_equals_len(%arg0: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant("abcdefghijklmnopqrstuvwxyz\00") : !llvm.array<27 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.call @strchr(%1, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + %4 = llvm.icmp "ne" %3, %2 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @memchr_n_equals_len(%arg0: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant("\0D\0A") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @".str.1" : !llvm.ptr + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %5 = llvm.icmp "eq" %4, %3 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @memchr_n_less_than_len(%arg0: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant("abcdefghijklmnopqrstuvwxyz\00") : !llvm.array<27 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.constant(15 : i64) : i64 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %5 = llvm.icmp "ne" %4, %3 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @memchr_n_more_than_len(%arg0: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant("abcdefghijklmnopqrstuvwxyz\00") : !llvm.array<27 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.constant(30 : i64) : i64 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %5 = llvm.icmp "ne" %4, %3 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @memchr_no_zero_cmp(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("abcdefghijklmnopqrstuvwxyz\00") : !llvm.array<27 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.call @strchr(%1, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @memchr_no_zero_cmp2(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\0D\0A") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @".str.1" : !llvm.ptr + %2 = llvm.call @strchr(%1, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @memchr_n_equals_len_minsize(%arg0: i32) -> (i1 {llvm.zeroext}) attributes {passthrough = ["minsize"]} { + %0 = llvm.mlir.constant("abcdefghijklmnopqrstuvwxyz\00") : !llvm.array<27 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.call @strchr(%1, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + %4 = llvm.icmp "ne" %3, %2 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @memchr_n_equals_len2_minsize(%arg0: i32) -> (i1 {llvm.zeroext}) attributes {passthrough = ["minsize"]} { + %0 = llvm.mlir.constant("\0D\0A") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @".str.1" : !llvm.ptr + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %5 = llvm.icmp "eq" %4, %3 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @strchr_to_memchr_2_non_cont_ranges(%arg0: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant("abcdefmno\00") : !llvm.array<10 x i8> + %1 = llvm.mlir.addressof @".str.2" : !llvm.ptr + %2 = llvm.mlir.constant(9 : i64) : i64 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %5 = llvm.icmp "ne" %4, %3 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @strchr_to_memchr_2_non_cont_ranges_char_dup(%arg0: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant("mnabcc\00") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @".str.4" : !llvm.ptr + %2 = llvm.mlir.constant(6 : i64) : i64 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %5 = llvm.icmp "ne" %4, %3 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @strchr_to_memchr_3_non_cont_ranges(%arg0: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant("abcijkmno\00") : !llvm.array<10 x i8> + %1 = llvm.mlir.addressof @".str.3" : !llvm.ptr + %2 = llvm.mlir.constant(9 : i64) : i64 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %5 = llvm.icmp "ne" %4, %3 : !llvm.ptr + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/memchr-8.ll.mlir b/test/LLVMDialect/InstCombine/memchr-8.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/memchr-9.ll.mlir b/test/LLVMDialect/InstCombine/memchr-9.ll.mlir new file mode 100644 index 000000000..14e52863b --- /dev/null +++ b/test/LLVMDialect/InstCombine/memchr-9.ll.mlir @@ -0,0 +1,199 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a() {addr_space = 0 : i32} : !llvm.array<1 x struct<"struct.A", (array<2 x i16>, array<2 x i16>)>> { + %0 = llvm.mlir.constant(dense<[514, 771]> : tensor<2xi16>) : !llvm.array<2 x i16> + %1 = llvm.mlir.constant(dense<[0, 257]> : tensor<2xi16>) : !llvm.array<2 x i16> + %2 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<2 x i16>, array<2 x i16>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.A", (array<2 x i16>, array<2 x i16>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.A", (array<2 x i16>, array<2 x i16>)> + %5 = llvm.mlir.undef : !llvm.array<1 x struct<"struct.A", (array<2 x i16>, array<2 x i16>)>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<1 x struct<"struct.A", (array<2 x i16>, array<2 x i16>)>> + llvm.return %6 : !llvm.array<1 x struct<"struct.A", (array<2 x i16>, array<2 x i16>)>> + } + llvm.mlir.global external constant @ai64(dense<[0, -1]> : tensor<2xi64>) {addr_space = 0 : i32} : !llvm.array<2 x i64> + llvm.mlir.global external constant @u() {addr_space = 0 : i32} : !llvm.struct<"union.U", (array<2 x i32>)> { + %0 = llvm.mlir.constant(dense<[286331153, 35791394]> : tensor<2xi32>) : !llvm.array<2 x i32> + %1 = llvm.mlir.undef : !llvm.struct<"union.U", (array<2 x i32>)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<"union.U", (array<2 x i32>)> + llvm.return %2 : !llvm.struct<"union.U", (array<2 x i32>)> + } + llvm.func @memchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @fold_memchr_A_pIb_cst_cst(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<[514, 771]> : tensor<2xi16>) : !llvm.array<2 x i16> + %1 = llvm.mlir.constant(dense<[0, 257]> : tensor<2xi16>) : !llvm.array<2 x i16> + %2 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<2 x i16>, array<2 x i16>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.A", (array<2 x i16>, array<2 x i16>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.A", (array<2 x i16>, array<2 x i16>)> + %5 = llvm.mlir.undef : !llvm.array<1 x struct<"struct.A", (array<2 x i16>, array<2 x i16>)>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<1 x struct<"struct.A", (array<2 x i16>, array<2 x i16>)>> + %7 = llvm.mlir.addressof @a : !llvm.ptr + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.mlir.constant(1 : i64) : i64 + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.mlir.constant(2 : i32) : i32 + %12 = llvm.mlir.constant(4 : i32) : i32 + %13 = llvm.mlir.constant(4 : i64) : i64 + %14 = llvm.mlir.constant(3 : i32) : i32 + %15 = llvm.mlir.constant(3 : i64) : i64 + %16 = llvm.mlir.constant(5 : i32) : i32 + %17 = llvm.mlir.constant(6 : i32) : i32 + %18 = llvm.mlir.constant(2 : i64) : i64 + %19 = llvm.mlir.constant(7 : i32) : i32 + %20 = llvm.mlir.constant(8 : i32) : i32 + %21 = llvm.mlir.constant(9 : i32) : i32 + %22 = llvm.mlir.constant(5 : i64) : i64 + %23 = llvm.mlir.constant(10 : i32) : i32 + %24 = llvm.mlir.constant(6 : i64) : i64 + %25 = llvm.call @memchr(%7, %8, %9) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %25, %arg0 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %26 = llvm.getelementptr %arg0[%10] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %27 = llvm.call @memchr(%7, %10, %9) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %27, %26 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %28 = llvm.getelementptr %arg0[%11] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %29 = llvm.call @memchr(%7, %12, %13) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %29, %28 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %30 = llvm.getelementptr %7[%10] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %31 = llvm.getelementptr %arg0[%14] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %32 = llvm.call @memchr(%30, %8, %9) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %32, %31 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %33 = llvm.getelementptr %arg0[%12] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %34 = llvm.call @memchr(%30, %8, %15) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %34, %33 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %35 = llvm.getelementptr %arg0[%16] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %36 = llvm.call @memchr(%30, %10, %9) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %36, %35 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %37 = llvm.getelementptr %arg0[%17] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %38 = llvm.call @memchr(%30, %10, %18) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %38, %37 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %39 = llvm.getelementptr %arg0[%19] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %40 = llvm.call @memchr(%30, %14, %15) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %40, %39 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %41 = llvm.getelementptr %arg0[%20] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %42 = llvm.call @memchr(%30, %14, %13) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %42, %41 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %43 = llvm.getelementptr %arg0[%21] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %44 = llvm.call @memchr(%30, %14, %22) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %42, %41 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %45 = llvm.getelementptr %arg0[%23] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %46 = llvm.call @memchr(%30, %14, %24) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %46, %45 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @fold_memchr_A_pIb_cst_N(%arg0: i64, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<[514, 771]> : tensor<2xi16>) : !llvm.array<2 x i16> + %1 = llvm.mlir.constant(dense<[0, 257]> : tensor<2xi16>) : !llvm.array<2 x i16> + %2 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<2 x i16>, array<2 x i16>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.A", (array<2 x i16>, array<2 x i16>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.A", (array<2 x i16>, array<2 x i16>)> + %5 = llvm.mlir.undef : !llvm.array<1 x struct<"struct.A", (array<2 x i16>, array<2 x i16>)>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<1 x struct<"struct.A", (array<2 x i16>, array<2 x i16>)>> + %7 = llvm.mlir.addressof @a : !llvm.ptr + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.mlir.constant(2 : i32) : i32 + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.mlir.constant(3 : i32) : i32 + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.mlir.constant(6 : i32) : i32 + %15 = llvm.mlir.constant(7 : i32) : i32 + %16 = llvm.mlir.constant(8 : i32) : i32 + %17 = llvm.mlir.constant(9 : i32) : i32 + %18 = llvm.mlir.constant(10 : i32) : i32 + %19 = llvm.mlir.constant(11 : i32) : i32 + %20 = llvm.mlir.constant(12 : i32) : i32 + %21 = llvm.call @memchr(%7, %8, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %21, %arg1 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %22 = llvm.getelementptr %arg1[%9] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %23 = llvm.call @memchr(%7, %9, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %23, %22 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %24 = llvm.getelementptr %arg1[%10] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %25 = llvm.call @memchr(%7, %11, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %25, %24 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %26 = llvm.getelementptr %7[%9] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %27 = llvm.getelementptr %arg1[%12] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %28 = llvm.call @memchr(%26, %8, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %28, %27 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %29 = llvm.getelementptr %arg1[%11] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %30 = llvm.call @memchr(%26, %9, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %30, %29 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %31 = llvm.getelementptr %arg1[%13] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %32 = llvm.call @memchr(%26, %10, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %32, %31 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %33 = llvm.getelementptr %arg1[%14] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %34 = llvm.call @memchr(%26, %12, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %34, %33 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %35 = llvm.getelementptr %arg1[%15] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %36 = llvm.call @memchr(%26, %11, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %36, %35 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %37 = llvm.getelementptr %7[%10] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %38 = llvm.getelementptr %arg1[%16] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %39 = llvm.call @memchr(%37, %8, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %39, %38 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %40 = llvm.getelementptr %arg1[%17] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %41 = llvm.call @memchr(%37, %9, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %41, %40 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %42 = llvm.getelementptr %arg1[%18] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %43 = llvm.call @memchr(%37, %10, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %43, %42 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %44 = llvm.getelementptr %arg1[%19] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %45 = llvm.call @memchr(%37, %12, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %45, %44 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %46 = llvm.getelementptr %arg1[%20] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %47 = llvm.call @memchr(%37, %11, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %47, %46 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @call_memchr_A_pIb_xs_cst(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<[514, 771]> : tensor<2xi16>) : !llvm.array<2 x i16> + %1 = llvm.mlir.constant(dense<[0, 257]> : tensor<2xi16>) : !llvm.array<2 x i16> + %2 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<2 x i16>, array<2 x i16>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.A", (array<2 x i16>, array<2 x i16>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.A", (array<2 x i16>, array<2 x i16>)> + %5 = llvm.mlir.undef : !llvm.array<1 x struct<"struct.A", (array<2 x i16>, array<2 x i16>)>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<1 x struct<"struct.A", (array<2 x i16>, array<2 x i16>)>> + %7 = llvm.mlir.addressof @a : !llvm.ptr + %8 = llvm.mlir.constant(1 : i64) : i64 + %9 = llvm.mlir.constant(0 : i64) : i64 + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.mlir.constant(2 : i64) : i64 + %12 = llvm.mlir.constant(1 : i32) : i32 + %13 = llvm.mlir.constant(8 : i32) : i32 + %14 = llvm.mlir.constant(2 : i32) : i32 + %15 = llvm.getelementptr %7[%8, %9] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<1 x struct<"struct.A", (array<2 x i16>, array<2 x i16>)>> + %16 = llvm.call @memchr(%15, %10, %11) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %16, %arg0 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %17 = llvm.getelementptr %15[%12] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %18 = llvm.getelementptr %arg0[%12] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %19 = llvm.call @memchr(%15, %10, %11) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %19, %18 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %20 = llvm.getelementptr %7[%13] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %21 = llvm.getelementptr %arg0[%14] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %22 = llvm.call @memchr(%20, %10, %11) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.store %22, %21 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @fold_memchr_gep_gep_gep() -> !llvm.ptr { + %0 = llvm.mlir.constant(dense<[0, -1]> : tensor<2xi64>) : !llvm.array<2 x i64> + %1 = llvm.mlir.addressof @ai64 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(-1 : i32) : i32 + %5 = llvm.mlir.constant(2 : i64) : i64 + %6 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<2 x i64> + %7 = llvm.getelementptr %6[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %8 = llvm.getelementptr %7[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i16 + %9 = llvm.call @memchr(%8, %4, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %9 : !llvm.ptr + } + llvm.func @fold_memchr_union_member() -> !llvm.ptr { + %0 = llvm.mlir.constant(dense<[286331153, 35791394]> : tensor<2xi32>) : !llvm.array<2 x i32> + %1 = llvm.mlir.undef : !llvm.struct<"union.U", (array<2 x i32>)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<"union.U", (array<2 x i32>)> + %3 = llvm.mlir.addressof @u : !llvm.ptr + %4 = llvm.mlir.constant(1 : i64) : i64 + %5 = llvm.mlir.constant(34 : i32) : i32 + %6 = llvm.mlir.constant(8 : i64) : i64 + %7 = llvm.getelementptr %3[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %8 = llvm.call @memchr(%7, %5, %6) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %8 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memchr.ll.mlir b/test/LLVMDialect/InstCombine/memchr.ll.mlir new file mode 100644 index 000000000..b8fa66812 --- /dev/null +++ b/test/LLVMDialect/InstCombine/memchr.ll.mlir @@ -0,0 +1,199 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello world\\n\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hellonull("hello\00world\\n\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external constant @newlines("\0D\0A\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @single("\1F\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @spaces(" \0D\0A\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @negative("\FF\FE\00") {addr_space = 0 : i32} + llvm.mlir.global external @chp() {addr_space = 0 : i32} : !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.mlir.global internal constant @s(dense<0> : tensor<1xi8>) {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : !llvm.array<1 x i8> + llvm.func @memchr(!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.func @test1() { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(119 : i32) : i32 + %3 = llvm.mlir.constant(14 : i32) : i32 + %4 = llvm.mlir.zero : !llvm.ptr + %5 = llvm.mlir.addressof @chp : !llvm.ptr + %6 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.store %6, %5 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test2() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.mlir.constant(119 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.mlir.zero : !llvm.ptr + %6 = llvm.mlir.addressof @chp : !llvm.ptr + %7 = llvm.call @memchr(%2, %3, %4) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.store %7, %6 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test3() { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(14 : i32) : i32 + %4 = llvm.mlir.zero : !llvm.ptr + %5 = llvm.mlir.addressof @chp : !llvm.ptr + %6 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.store %6, %5 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test4(%arg0: i32) { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(14 : i32) : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.mlir.addressof @chp : !llvm.ptr + %5 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.store %5, %4 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test5() { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(65280 : i32) : i32 + %3 = llvm.mlir.constant(14 : i32) : i32 + %4 = llvm.mlir.zero : !llvm.ptr + %5 = llvm.mlir.addressof @chp : !llvm.ptr + %6 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.store %6, %5 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test6() { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(119 : i32) : i32 + %3 = llvm.mlir.constant(100 : i32) : i32 + %4 = llvm.mlir.zero : !llvm.ptr + %5 = llvm.mlir.addressof @chp : !llvm.ptr + %6 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.store %6, %5 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test7() { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(120 : i32) : i32 + %3 = llvm.mlir.constant(100 : i32) : i32 + %4 = llvm.mlir.zero : !llvm.ptr + %5 = llvm.mlir.addressof @chp : !llvm.ptr + %6 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.store %6, %5 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test8() { + %0 = llvm.mlir.constant("hello\00world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hellonull : !llvm.ptr + %2 = llvm.mlir.constant(119 : i32) : i32 + %3 = llvm.mlir.constant(14 : i32) : i32 + %4 = llvm.mlir.zero : !llvm.ptr + %5 = llvm.mlir.addressof @chp : !llvm.ptr + %6 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.store %6, %5 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test9() { + %0 = llvm.mlir.constant("hello\00world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hellonull : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(119 : i32) : i32 + %5 = llvm.mlir.constant(12 : i32) : i32 + %6 = llvm.mlir.zero : !llvm.ptr + %7 = llvm.mlir.addressof @chp : !llvm.ptr + %8 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<14 x i8> + %9 = llvm.call @memchr(%8, %4, %5) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.store %9, %7 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test10() { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(119 : i32) : i32 + %3 = llvm.mlir.constant(6 : i32) : i32 + %4 = llvm.mlir.zero : !llvm.ptr + %5 = llvm.mlir.addressof @chp : !llvm.ptr + %6 = llvm.call @memchr(%1, %2, %3) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.store %6, %5 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test11(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant("\0D\0A\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @newlines : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + %5 = llvm.icmp "ne" %4, %3 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @test12(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(" \0D\0A\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @spaces : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + %5 = llvm.icmp "ne" %4, %3 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @test13(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant("\1F\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @single : !llvm.ptr + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + %5 = llvm.icmp "ne" %4, %3 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @test14(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant("\1F\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @single : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.call @memchr(%1, %arg0, %2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + %5 = llvm.icmp "ne" %4, %3 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @test15(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant("\FF\FE\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @negative : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.call @memchr(%1, %arg0, %arg1) : (!llvm.ptr, i32, i32) -> !llvm.ptr + %4 = llvm.icmp "ne" %3, %2 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @pr32124() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @s : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.call @memchr(%2, %3, %4) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @test16(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memchr(%arg0, %arg1, %arg2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test17(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memchr(%arg0, %arg1, %arg2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test18(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.call @memchr(%arg0, %arg1, %0) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test19(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.call @memchr(%arg0, %arg1, %0) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memcmp-1.ll.mlir b/test/LLVMDialect/InstCombine/memcmp-1.ll.mlir index 3887e07be..a9c98dab7 100644 --- a/test/LLVMDialect/InstCombine/memcmp-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/memcmp-1.ll.mlir @@ -1,110 +1,89 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "foo", type = !llvm.array<4 x i8>, value = "foo\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hel", type = !llvm.array<4 x i8>, value = "hel\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello_u", type = !llvm.array<8 x i8>, value = "hello_u\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memcmp", type = !llvm.func, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg0, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify1", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify2", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify3", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @hello_u} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @hel} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%4, %5, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify4", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @foo} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @hel} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%4, %5, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify5", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @hel} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @foo} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%4, %5, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %4 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - "llvm.store"(%arg0, %3) : (i64, !llvm.ptr) -> () - "llvm.store"(%arg1, %4) : (i64, !llvm.ptr) -> () - %5 = "llvm.bitcast"(%3) : (!llvm.ptr) -> !llvm.ptr - %6 = "llvm.bitcast"(%4) : (!llvm.ptr) -> !llvm.ptr - %7 = "llvm.call"(%5, %6, %1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - %8 = "llvm.icmp"(%7, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%8) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %4 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - "llvm.store"(%arg0, %3) : (i32, !llvm.ptr) -> () - "llvm.store"(%arg1, %4) : (i32, !llvm.ptr) -> () - %5 = "llvm.bitcast"(%3) : (!llvm.ptr) -> !llvm.ptr - %6 = "llvm.bitcast"(%4) : (!llvm.ptr) -> !llvm.ptr - %7 = "llvm.call"(%5, %6, %1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - %8 = "llvm.icmp"(%7, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%8) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %4 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - "llvm.store"(%arg0, %3) : (i16, !llvm.ptr) -> () - "llvm.store"(%arg1, %4) : (i16, !llvm.ptr) -> () - %5 = "llvm.bitcast"(%3) : (!llvm.ptr) -> !llvm.ptr - %6 = "llvm.bitcast"(%4) : (!llvm.ptr) -> !llvm.ptr - %7 = "llvm.call"(%5, %6, %1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - %8 = "llvm.icmp"(%7, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%8) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify9", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify10", type = !llvm.func, ptr, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @foo("foo\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hel("hel\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hello_u("hello_u\00") {addr_space = 0 : i32} + llvm.func @memcmp(!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.func @test_simplify1(%arg0: !llvm.ptr, %arg1: i32) -> i32 { + %0 = llvm.call @memcmp(%arg0, %arg0, %arg1) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %0 : i32 + } + llvm.func @test_simplify2(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @memcmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify3(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.call @memcmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify4() -> i32 { + %0 = llvm.mlir.constant("hel\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @hel : !llvm.ptr + %2 = llvm.mlir.constant("hello_u\00") : !llvm.array<8 x i8> + %3 = llvm.mlir.addressof @hello_u : !llvm.ptr + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.call @memcmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @test_simplify5() -> i32 { + %0 = llvm.mlir.constant("hel\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @hel : !llvm.ptr + %2 = llvm.mlir.constant("foo\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.addressof @foo : !llvm.ptr + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.call @memcmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @test_simplify6() -> i32 { + %0 = llvm.mlir.constant("foo\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @foo : !llvm.ptr + %2 = llvm.mlir.constant("hel\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.addressof @hel : !llvm.ptr + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.call @memcmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @test_simplify7(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %3 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.store %arg1, %4 {alignment = 8 : i64} : i64, !llvm.ptr + %5 = llvm.call @memcmp(%3, %4, %1) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @test_simplify8(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %arg1, %4 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.call @memcmp(%3, %4, %1) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @test_simplify9(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.alloca %0 x i16 {alignment = 2 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x i16 {alignment = 2 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %3 {alignment = 2 : i64} : i16, !llvm.ptr + llvm.store %arg1, %4 {alignment = 2 : i64} : i16, !llvm.ptr + %5 = llvm.call @memcmp(%3, %4, %1) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @test_simplify10(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @memcmp(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/memcmp-2.ll.mlir b/test/LLVMDialect/InstCombine/memcmp-2.ll.mlir index 26480c44f..4f56cc000 100644 --- a/test/LLVMDialect/InstCombine/memcmp-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/memcmp-2.ll.mlir @@ -1,10 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memcmp", type = !llvm.func (ptr, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg0, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func (ptr, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @memcmp(!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.func @test_no_simplify1(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.call @memcmp(%arg0, %arg0, %arg1) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memcmp-3.ll.mlir b/test/LLVMDialect/InstCombine/memcmp-3.ll.mlir index 0d4dcaffe..455756495 100644 --- a/test/LLVMDialect/InstCombine/memcmp-3.ll.mlir +++ b/test/LLVMDialect/InstCombine/memcmp-3.ll.mlir @@ -1,91 +1,83 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "ia16a", type = !llvm.array<4 x i16>, value = dense<[24930, 25444, 25958, 26472]> : tensor<4xi16>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "i8a", type = !llvm.array<8 x i8>, value = "abcdefgg"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memcmp", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %6 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %7 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %8 = "llvm.mlir.addressof"() {global_name = @i8a} : () -> !llvm.ptr> - %9 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %10 = "llvm.mlir.addressof"() {global_name = @ia16a} : () -> !llvm.ptr> - %11 = "llvm.getelementptr"(%10, %9, %9) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %12 = "llvm.bitcast"(%11) : (!llvm.ptr) -> !llvm.ptr - %13 = "llvm.getelementptr"(%8, %9, %9) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %14 = "llvm.call"(%12, %13, %9) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %15 = "llvm.getelementptr"(%arg0, %9) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%14, %15) : (i32, !llvm.ptr) -> () - %16 = "llvm.call"(%12, %13, %7) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %17 = "llvm.getelementptr"(%arg0, %7) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%16, %17) : (i32, !llvm.ptr) -> () - %18 = "llvm.call"(%12, %13, %6) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %19 = "llvm.getelementptr"(%arg0, %6) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%18, %19) : (i32, !llvm.ptr) -> () - %20 = "llvm.call"(%12, %13, %5) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %21 = "llvm.getelementptr"(%arg0, %5) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%20, %21) : (i32, !llvm.ptr) -> () - %22 = "llvm.call"(%12, %13, %4) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %23 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%22, %23) : (i32, !llvm.ptr) -> () - %24 = "llvm.call"(%12, %13, %3) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %25 = "llvm.getelementptr"(%arg0, %3) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%24, %25) : (i32, !llvm.ptr) -> () - %26 = "llvm.call"(%12, %13, %2) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %27 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%26, %27) : (i32, !llvm.ptr) -> () - %28 = "llvm.call"(%12, %13, %1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %29 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%28, %29) : (i32, !llvm.ptr) -> () - %30 = "llvm.call"(%12, %13, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %31 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%30, %31) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memcmp_ia16a_i8a", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %5 = "llvm.mlir.addressof"() {global_name = @i8a} : () -> !llvm.ptr> - %6 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %7 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %8 = "llvm.mlir.addressof"() {global_name = @ia16a} : () -> !llvm.ptr> - %9 = "llvm.getelementptr"(%8, %7, %6) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %10 = "llvm.bitcast"(%9) : (!llvm.ptr) -> !llvm.ptr - %11 = "llvm.getelementptr"(%5, %7, %6) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %12 = "llvm.call"(%10, %11, %7) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %13 = "llvm.getelementptr"(%arg0, %7) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%12, %13) : (i32, !llvm.ptr) -> () - %14 = "llvm.call"(%10, %11, %6) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %15 = "llvm.getelementptr"(%arg0, %6) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%14, %15) : (i32, !llvm.ptr) -> () - %16 = "llvm.call"(%10, %11, %4) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %17 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%16, %17) : (i32, !llvm.ptr) -> () - %18 = "llvm.call"(%10, %11, %3) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %19 = "llvm.getelementptr"(%arg0, %3) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%18, %19) : (i32, !llvm.ptr) -> () - %20 = "llvm.call"(%10, %11, %2) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %21 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%20, %21) : (i32, !llvm.ptr) -> () - %22 = "llvm.call"(%10, %11, %1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %23 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%22, %23) : (i32, !llvm.ptr) -> () - %24 = "llvm.call"(%10, %11, %0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %25 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%24, %25) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memcmp_ia16a_p1_i8a_p1", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @ia16a(dense<[24930, 25444, 25958, 26472]> : tensor<4xi16>) {addr_space = 0 : i32} : !llvm.array<4 x i16> + llvm.mlir.global external constant @i8a("abcdefgg") {addr_space = 0 : i32} + llvm.func @memcmp(!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.func @fold_memcmp_ia16a_i8a(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<[24930, 25444, 25958, 26472]> : tensor<4xi16>) : !llvm.array<4 x i16> + %1 = llvm.mlir.addressof @ia16a : !llvm.ptr + %2 = llvm.mlir.constant("abcdefgg") : !llvm.array<8 x i8> + %3 = llvm.mlir.addressof @i8a : !llvm.ptr + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.mlir.constant(1 : i64) : i64 + %6 = llvm.mlir.constant(2 : i64) : i64 + %7 = llvm.mlir.constant(3 : i64) : i64 + %8 = llvm.mlir.constant(4 : i64) : i64 + %9 = llvm.mlir.constant(5 : i64) : i64 + %10 = llvm.mlir.constant(6 : i64) : i64 + %11 = llvm.mlir.constant(7 : i64) : i64 + %12 = llvm.mlir.constant(8 : i64) : i64 + %13 = llvm.call @memcmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %13, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %14 = llvm.call @memcmp(%1, %3, %5) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %15 = llvm.getelementptr %arg0[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %14, %15 {alignment = 4 : i64} : i32, !llvm.ptr + %16 = llvm.call @memcmp(%1, %3, %6) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %17 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %16, %17 {alignment = 4 : i64} : i32, !llvm.ptr + %18 = llvm.call @memcmp(%1, %3, %7) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %19 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %18, %19 {alignment = 4 : i64} : i32, !llvm.ptr + %20 = llvm.call @memcmp(%1, %3, %8) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %21 = llvm.getelementptr %arg0[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %20, %21 {alignment = 4 : i64} : i32, !llvm.ptr + %22 = llvm.call @memcmp(%1, %3, %9) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %23 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %22, %23 {alignment = 4 : i64} : i32, !llvm.ptr + %24 = llvm.call @memcmp(%1, %3, %10) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %25 = llvm.getelementptr %arg0[%10] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %24, %25 {alignment = 4 : i64} : i32, !llvm.ptr + %26 = llvm.call @memcmp(%1, %3, %11) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %27 = llvm.getelementptr %arg0[%11] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %26, %27 {alignment = 4 : i64} : i32, !llvm.ptr + %28 = llvm.call @memcmp(%1, %3, %12) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %29 = llvm.getelementptr %arg0[%12] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %28, %29 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_memcmp_ia16a_p1_i8a_p1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<[24930, 25444, 25958, 26472]> : tensor<4xi16>) : !llvm.array<4 x i16> + %1 = llvm.mlir.addressof @ia16a : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant("abcdefgg") : !llvm.array<8 x i8> + %5 = llvm.mlir.addressof @i8a : !llvm.ptr + %6 = llvm.mlir.constant(2 : i64) : i64 + %7 = llvm.mlir.constant(3 : i64) : i64 + %8 = llvm.mlir.constant(4 : i64) : i64 + %9 = llvm.mlir.constant(5 : i64) : i64 + %10 = llvm.mlir.constant(6 : i64) : i64 + %11 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i16> + %12 = llvm.getelementptr %5[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %13 = llvm.call @memcmp(%11, %12, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %13, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %14 = llvm.call @memcmp(%11, %12, %3) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %15 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %14, %15 {alignment = 4 : i64} : i32, !llvm.ptr + %16 = llvm.call @memcmp(%11, %12, %6) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %17 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %16, %17 {alignment = 4 : i64} : i32, !llvm.ptr + %18 = llvm.call @memcmp(%11, %12, %7) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %19 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %18, %19 {alignment = 4 : i64} : i32, !llvm.ptr + %20 = llvm.call @memcmp(%11, %12, %8) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %21 = llvm.getelementptr %arg0[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %20, %21 {alignment = 4 : i64} : i32, !llvm.ptr + %22 = llvm.call @memcmp(%11, %12, %9) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %23 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %22, %23 {alignment = 4 : i64} : i32, !llvm.ptr + %24 = llvm.call @memcmp(%11, %12, %10) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %25 = llvm.getelementptr %arg0[%10] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %24, %25 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/memcmp-4.ll.mlir b/test/LLVMDialect/InstCombine/memcmp-4.ll.mlir index 6d71926f2..a862f533a 100644 --- a/test/LLVMDialect/InstCombine/memcmp-4.ll.mlir +++ b/test/LLVMDialect/InstCombine/memcmp-4.ll.mlir @@ -1,50 +1,35 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "ia16a", type = !llvm.array<4 x i16>, value = dense<[24930, 25444, 25958, 26472]> : tensor<4xi16>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "ia16b", type = !llvm.array<5 x i16>, value = dense<[24930, 25444, 25958, 26472, 26992]> : tensor<5xi16>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "ia16c", type = !llvm.array<6 x i16>, value = dense<[24930, 25444, 25958, 26472, 26993, 29042]> : tensor<6xi16>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memcmp", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 12 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @ia16c} : () -> !llvm.ptr> - %3 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %4 = "llvm.mlir.addressof"() {global_name = @ia16b} : () -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %3, %3) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %6 = "llvm.bitcast"(%5) : (!llvm.ptr) -> !llvm.ptr - %7 = "llvm.getelementptr"(%2, %3, %3) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %8 = "llvm.bitcast"(%7) : (!llvm.ptr) -> !llvm.ptr - %9 = "llvm.call"(%6, %8, %1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %10 = "llvm.getelementptr"(%arg0, %3) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%9, %10) : (i32, !llvm.ptr) -> () - %11 = "llvm.call"(%8, %6, %1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %12 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%11, %12) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memcmp_mismatch_too_big", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = -1 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 9 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @ia16b} : () -> !llvm.ptr> - %4 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %5 = "llvm.mlir.addressof"() {global_name = @ia16a} : () -> !llvm.ptr> - %6 = "llvm.getelementptr"(%5, %4, %4) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %7 = "llvm.bitcast"(%6) : (!llvm.ptr) -> !llvm.ptr - %8 = "llvm.getelementptr"(%3, %4, %4) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %9 = "llvm.bitcast"(%8) : (!llvm.ptr) -> !llvm.ptr - %10 = "llvm.call"(%7, %9, %2) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %11 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%10, %11) : (i32, !llvm.ptr) -> () - %12 = "llvm.call"(%7, %9, %1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %13 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%12, %13) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memcmp_match_too_big", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @ia16a(dense<[24930, 25444, 25958, 26472]> : tensor<4xi16>) {addr_space = 0 : i32} : !llvm.array<4 x i16> + llvm.mlir.global external constant @ia16b(dense<[24930, 25444, 25958, 26472, 26992]> : tensor<5xi16>) {addr_space = 0 : i32} : !llvm.array<5 x i16> + llvm.mlir.global external constant @ia16c(dense<[24930, 25444, 25958, 26472, 26993, 29042]> : tensor<6xi16>) {addr_space = 0 : i32} : !llvm.array<6 x i16> + llvm.func @memcmp(!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.func @fold_memcmp_mismatch_too_big(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<[24930, 25444, 25958, 26472, 26992]> : tensor<5xi16>) : !llvm.array<5 x i16> + %1 = llvm.mlir.addressof @ia16b : !llvm.ptr + %2 = llvm.mlir.constant(dense<[24930, 25444, 25958, 26472, 26993, 29042]> : tensor<6xi16>) : !llvm.array<6 x i16> + %3 = llvm.mlir.addressof @ia16c : !llvm.ptr + %4 = llvm.mlir.constant(12 : i64) : i64 + %5 = llvm.mlir.constant(1 : i64) : i64 + %6 = llvm.call @memcmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %6, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %7 = llvm.call @memcmp(%3, %1, %4) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %8 = llvm.getelementptr %arg0[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %7, %8 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_memcmp_match_too_big(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<[24930, 25444, 25958, 26472]> : tensor<4xi16>) : !llvm.array<4 x i16> + %1 = llvm.mlir.addressof @ia16a : !llvm.ptr + %2 = llvm.mlir.constant(dense<[24930, 25444, 25958, 26472, 26992]> : tensor<5xi16>) : !llvm.array<5 x i16> + %3 = llvm.mlir.addressof @ia16b : !llvm.ptr + %4 = llvm.mlir.constant(9 : i64) : i64 + %5 = llvm.mlir.constant(-1 : i64) : i64 + %6 = llvm.mlir.constant(1 : i64) : i64 + %7 = llvm.call @memcmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %7, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %8 = llvm.call @memcmp(%1, %3, %5) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %9 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %8, %9 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/memcmp-5.ll.mlir b/test/LLVMDialect/InstCombine/memcmp-5.ll.mlir index 998a1b3e0..e80f8fe86 100644 --- a/test/LLVMDialect/InstCombine/memcmp-5.ll.mlir +++ b/test/LLVMDialect/InstCombine/memcmp-5.ll.mlir @@ -1,158 +1,123 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "ax", type = !llvm.array<8 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a01230123", type = !llvm.array<8 x i8>, value = "01230123"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "b01230123", type = !llvm.array<8 x i8>, value = "01230123"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "c01230129", type = !llvm.array<8 x i8>, value = "01230129"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "d9123012", type = !llvm.array<7 x i8>, value = "9123012"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memcmp", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @b01230123} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @b01230123} : () -> !llvm.ptr> - %4 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %5 = "llvm.mlir.addressof"() {global_name = @b01230123} : () -> !llvm.ptr> - %6 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %7 = "llvm.mlir.addressof"() {global_name = @b01230123} : () -> !llvm.ptr> - %8 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %9 = "llvm.mlir.addressof"() {global_name = @b01230123} : () -> !llvm.ptr> - %10 = "llvm.mlir.addressof"() {global_name = @b01230123} : () -> !llvm.ptr> - %11 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %12 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %13 = "llvm.getelementptr"(%12, %11, %11) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %14 = "llvm.getelementptr"(%10, %11, %11) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %15 = "llvm.getelementptr"(%9, %11, %8) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %16 = "llvm.getelementptr"(%7, %11, %6) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %17 = "llvm.getelementptr"(%5, %11, %4) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %18 = "llvm.getelementptr"(%3, %11, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %19 = "llvm.getelementptr"(%1, %11, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %20 = "llvm.call"(%13, %14, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %21 = "llvm.getelementptr"(%arg0, %11) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%20, %21) : (i32, !llvm.ptr) -> () - %22 = "llvm.call"(%13, %15, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %23 = "llvm.getelementptr"(%arg0, %8) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%22, %23) : (i32, !llvm.ptr) -> () - %24 = "llvm.call"(%13, %16, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %25 = "llvm.getelementptr"(%arg0, %6) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%24, %25) : (i32, !llvm.ptr) -> () - %26 = "llvm.call"(%13, %17, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %27 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%26, %27) : (i32, !llvm.ptr) -> () - %28 = "llvm.call"(%13, %18, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %29 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%28, %29) : (i32, !llvm.ptr) -> () - %30 = "llvm.call"(%13, %19, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %31 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%30, %31) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memcmp_a_b_n", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.getelementptr"(%0, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%3, %4, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %6 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%5, %6) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "call_memcmp_a_ax_n", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @c01230129} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @c01230129} : () -> !llvm.ptr> - %4 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %5 = "llvm.mlir.addressof"() {global_name = @c01230129} : () -> !llvm.ptr> - %6 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %7 = "llvm.mlir.addressof"() {global_name = @c01230129} : () -> !llvm.ptr> - %8 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %9 = "llvm.mlir.addressof"() {global_name = @c01230129} : () -> !llvm.ptr> - %10 = "llvm.mlir.addressof"() {global_name = @c01230129} : () -> !llvm.ptr> - %11 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %12 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %13 = "llvm.getelementptr"(%12, %11, %11) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %14 = "llvm.getelementptr"(%10, %11, %11) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %15 = "llvm.getelementptr"(%9, %11, %8) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %16 = "llvm.getelementptr"(%7, %11, %6) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %17 = "llvm.getelementptr"(%5, %11, %4) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %18 = "llvm.getelementptr"(%3, %11, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %19 = "llvm.getelementptr"(%1, %11, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %20 = "llvm.call"(%13, %14, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %21 = "llvm.getelementptr"(%arg0, %11) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%20, %21) : (i32, !llvm.ptr) -> () - %22 = "llvm.call"(%13, %15, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %23 = "llvm.getelementptr"(%arg0, %8) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%22, %23) : (i32, !llvm.ptr) -> () - %24 = "llvm.call"(%13, %16, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %25 = "llvm.getelementptr"(%arg0, %6) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%24, %25) : (i32, !llvm.ptr) -> () - %26 = "llvm.call"(%13, %17, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %27 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%26, %27) : (i32, !llvm.ptr) -> () - %28 = "llvm.call"(%13, %18, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %29 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%28, %29) : (i32, !llvm.ptr) -> () - %30 = "llvm.call"(%13, %18, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %31 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%30, %31) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memcmp_a_c_n", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @d9123012} : () -> !llvm.ptr> - %3 = "llvm.mlir.addressof"() {global_name = @d9123012} : () -> !llvm.ptr> - %4 = "llvm.mlir.addressof"() {global_name = @d9123012} : () -> !llvm.ptr> - %5 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %6 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %7 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %8 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %9 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %10 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %11 = "llvm.getelementptr"(%10, %9, %9) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %12 = "llvm.getelementptr"(%8, %9, %7) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %13 = "llvm.getelementptr"(%6, %9, %5) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %14 = "llvm.getelementptr"(%4, %9, %9) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %15 = "llvm.getelementptr"(%3, %9, %7) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %16 = "llvm.getelementptr"(%2, %9, %5) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %17 = "llvm.call"(%11, %14, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %18 = "llvm.getelementptr"(%arg0, %9) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%17, %18) : (i32, !llvm.ptr) -> () - %19 = "llvm.call"(%11, %15, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %20 = "llvm.getelementptr"(%arg0, %7) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%19, %20) : (i32, !llvm.ptr) -> () - %21 = "llvm.call"(%12, %15, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %22 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%21, %22) : (i32, !llvm.ptr) -> () - %23 = "llvm.call"(%13, %16, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %24 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%23, %24) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memcmp_a_d_n", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @d9123012} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %6 = "llvm.or"(%arg1, %0) : (i64, i64) -> i64 - %7 = "llvm.call"(%4, %5, %6) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %8 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%7, %8) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memcmp_a_d_nz", type = !llvm.func, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @ax() {addr_space = 0 : i32} : !llvm.array<8 x i8> + llvm.mlir.global external constant @a01230123("01230123") {addr_space = 0 : i32} + llvm.mlir.global external constant @b01230123("01230123") {addr_space = 0 : i32} + llvm.mlir.global external constant @c01230129("01230129") {addr_space = 0 : i32} + llvm.mlir.global external constant @d9123012("9123012") {addr_space = 0 : i32} + llvm.func @memcmp(!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.func @fold_memcmp_a_b_n(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("01230123") : !llvm.array<8 x i8> + %1 = llvm.mlir.addressof @b01230123 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(2 : i64) : i64 + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.constant(4 : i64) : i64 + %7 = llvm.mlir.constant(5 : i64) : i64 + %8 = llvm.mlir.addressof @a01230123 : !llvm.ptr + %9 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %10 = llvm.getelementptr %1[%2, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %11 = llvm.getelementptr %1[%2, %5] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %12 = llvm.getelementptr %1[%2, %6] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %13 = llvm.getelementptr %1[%2, %7] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %14 = llvm.call @memcmp(%8, %1, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %14, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %15 = llvm.call @memcmp(%8, %9, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %16 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %15, %16 {alignment = 4 : i64} : i32, !llvm.ptr + %17 = llvm.call @memcmp(%8, %10, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %18 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %17, %18 {alignment = 4 : i64} : i32, !llvm.ptr + %19 = llvm.call @memcmp(%8, %11, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %20 = llvm.getelementptr %arg0[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %19, %20 {alignment = 4 : i64} : i32, !llvm.ptr + %21 = llvm.call @memcmp(%8, %12, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %22 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %21, %22 {alignment = 4 : i64} : i32, !llvm.ptr + %23 = llvm.call @memcmp(%8, %13, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %24 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %23, %24 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @call_memcmp_a_ax_n(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("01230123") : !llvm.array<8 x i8> + %1 = llvm.mlir.addressof @a01230123 : !llvm.ptr + %2 = llvm.mlir.addressof @ax : !llvm.ptr + %3 = llvm.call @memcmp(%1, %2, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %3, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_memcmp_a_c_n(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("01230129") : !llvm.array<8 x i8> + %1 = llvm.mlir.addressof @c01230129 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(2 : i64) : i64 + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.constant(4 : i64) : i64 + %7 = llvm.mlir.constant(5 : i64) : i64 + %8 = llvm.mlir.constant("01230123") : !llvm.array<8 x i8> + %9 = llvm.mlir.addressof @a01230123 : !llvm.ptr + %10 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %11 = llvm.getelementptr %1[%2, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %12 = llvm.getelementptr %1[%2, %5] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %13 = llvm.getelementptr %1[%2, %6] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %14 = llvm.getelementptr %1[%2, %7] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %15 = llvm.call @memcmp(%9, %1, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %15, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %16 = llvm.call @memcmp(%9, %10, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %17 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %16, %17 {alignment = 4 : i64} : i32, !llvm.ptr + %18 = llvm.call @memcmp(%9, %11, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %19 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %18, %19 {alignment = 4 : i64} : i32, !llvm.ptr + %20 = llvm.call @memcmp(%9, %12, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %21 = llvm.getelementptr %arg0[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %20, %21 {alignment = 4 : i64} : i32, !llvm.ptr + %22 = llvm.call @memcmp(%9, %13, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %23 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %22, %23 {alignment = 4 : i64} : i32, !llvm.ptr + %24 = llvm.call @memcmp(%9, %13, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %25 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %24, %25 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_memcmp_a_d_n(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("01230123") : !llvm.array<8 x i8> + %1 = llvm.mlir.addressof @a01230123 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(6 : i64) : i64 + %5 = llvm.mlir.constant("9123012") : !llvm.array<7 x i8> + %6 = llvm.mlir.addressof @d9123012 : !llvm.ptr + %7 = llvm.mlir.constant(2 : i64) : i64 + %8 = llvm.mlir.constant(3 : i64) : i64 + %9 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %10 = llvm.getelementptr %1[%2, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %11 = llvm.getelementptr %6[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %12 = llvm.getelementptr %6[%2, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %13 = llvm.call @memcmp(%1, %6, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %13, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %14 = llvm.call @memcmp(%1, %11, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %15 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %14, %15 {alignment = 4 : i64} : i32, !llvm.ptr + %16 = llvm.call @memcmp(%9, %11, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %17 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %16, %17 {alignment = 4 : i64} : i32, !llvm.ptr + %18 = llvm.call @memcmp(%10, %12, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %19 = llvm.getelementptr %arg0[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %18, %19 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_memcmp_a_d_nz(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant("01230123") : !llvm.array<8 x i8> + %2 = llvm.mlir.addressof @a01230123 : !llvm.ptr + %3 = llvm.mlir.constant("9123012") : !llvm.array<7 x i8> + %4 = llvm.mlir.addressof @d9123012 : !llvm.ptr + %5 = llvm.or %arg1, %0 : i64 + %6 = llvm.call @memcmp(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %6, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/memcmp-6.ll.mlir b/test/LLVMDialect/InstCombine/memcmp-6.ll.mlir index 86e0761ae..92b75b561 100644 --- a/test/LLVMDialect/InstCombine/memcmp-6.ll.mlir +++ b/test/LLVMDialect/InstCombine/memcmp-6.ll.mlir @@ -1,68 +1,58 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a", type = !llvm.array<7 x i8>, value = "abcdef\7F"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "b", type = !llvm.array<7 x i8>, value = "abcdef\80"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memcmp", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @b} : () -> !llvm.ptr> - %4 = "llvm.mlir.addressof"() {global_name = @b} : () -> !llvm.ptr> - %5 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %6 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %7 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %8 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %9 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %10 = "llvm.getelementptr"(%9, %8, %7) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %11 = "llvm.getelementptr"(%6, %8, %5) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %12 = "llvm.getelementptr"(%4, %8, %7) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %13 = "llvm.getelementptr"(%3, %8, %5) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %14 = "llvm.call"(%10, %12, %2) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %15 = "llvm.getelementptr"(%arg0, %8) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%14, %15) : (i32, !llvm.ptr) -> () - %16 = "llvm.call"(%12, %10, %2) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %17 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%16, %17) : (i32, !llvm.ptr) -> () - %18 = "llvm.call"(%11, %13, %1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %19 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%18, %19) : (i32, !llvm.ptr) -> () - %20 = "llvm.call"(%13, %11, %1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %21 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%20, %21) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memcmp_cst_cst", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @b} : () -> !llvm.ptr> - %4 = "llvm.mlir.addressof"() {global_name = @b} : () -> !llvm.ptr> - %5 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %6 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %7 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %8 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %9 = "llvm.getelementptr"(%8, %7, %7) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %10 = "llvm.getelementptr"(%6, %7, %5) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %11 = "llvm.getelementptr"(%4, %7, %7) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %12 = "llvm.getelementptr"(%3, %7, %5) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %13 = "llvm.call"(%9, %11, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %14 = "llvm.getelementptr"(%arg0, %7) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%13, %14) : (i32, !llvm.ptr) -> () - %15 = "llvm.call"(%11, %9, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %16 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%15, %16) : (i32, !llvm.ptr) -> () - %17 = "llvm.call"(%10, %12, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %18 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%17, %18) : (i32, !llvm.ptr) -> () - %19 = "llvm.call"(%12, %10, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %20 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%19, %20) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memcmp_cst_var", type = !llvm.func, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a("abcdef\7F") {addr_space = 0 : i32} + llvm.mlir.global external constant @b("abcdef\80") {addr_space = 0 : i32} + llvm.func @memcmp(!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.func @fold_memcmp_cst_cst(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("abcdef\7F") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(5 : i64) : i64 + %4 = llvm.mlir.constant(6 : i64) : i64 + %5 = llvm.mlir.constant("abcdef\80") : !llvm.array<7 x i8> + %6 = llvm.mlir.addressof @b : !llvm.ptr + %7 = llvm.mlir.constant(2 : i64) : i64 + %8 = llvm.mlir.constant(1 : i64) : i64 + %9 = llvm.mlir.constant(3 : i64) : i64 + %10 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %11 = llvm.getelementptr %1[%2, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %12 = llvm.getelementptr %6[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %13 = llvm.getelementptr %6[%2, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %14 = llvm.call @memcmp(%10, %12, %7) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %14, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %15 = llvm.call @memcmp(%12, %10, %7) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %16 = llvm.getelementptr %arg0[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %15, %16 {alignment = 4 : i64} : i32, !llvm.ptr + %17 = llvm.call @memcmp(%11, %13, %8) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %18 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %17, %18 {alignment = 4 : i64} : i32, !llvm.ptr + %19 = llvm.call @memcmp(%13, %11, %8) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %20 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %19, %20 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_memcmp_cst_var(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("abcdef\7F") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(6 : i64) : i64 + %4 = llvm.mlir.constant("abcdef\80") : !llvm.array<7 x i8> + %5 = llvm.mlir.addressof @b : !llvm.ptr + %6 = llvm.mlir.constant(1 : i64) : i64 + %7 = llvm.mlir.constant(2 : i64) : i64 + %8 = llvm.mlir.constant(3 : i64) : i64 + %9 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %10 = llvm.getelementptr %5[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %11 = llvm.call @memcmp(%1, %5, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %11, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %12 = llvm.call @memcmp(%5, %1, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %13 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %12, %13 {alignment = 4 : i64} : i32, !llvm.ptr + %14 = llvm.call @memcmp(%9, %10, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %15 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %14, %15 {alignment = 4 : i64} : i32, !llvm.ptr + %16 = llvm.call @memcmp(%10, %9, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %17 = llvm.getelementptr %arg0[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %16, %17 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/memcmp-7.ll.mlir b/test/LLVMDialect/InstCombine/memcmp-7.ll.mlir new file mode 100644 index 000000000..17b1448a0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/memcmp-7.ll.mlir @@ -0,0 +1,102 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @i32a(dense<[4386, 13124]> : tensor<2xi16>) {addr_space = 0 : i32} : !llvm.array<2 x i16> + llvm.mlir.global external constant @i32b(dense<[4386, 13124]> : tensor<2xi16>) {addr_space = 0 : i32} : !llvm.array<2 x i16> + llvm.mlir.global external constant @a() {addr_space = 0 : i32} : !llvm.array<1 x struct<"struct.A", (array<4 x i8>)>> { + %0 = llvm.mlir.constant("\01\02\03\04") : !llvm.array<4 x i8> + %1 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<"struct.A", (array<4 x i8>)> + %3 = llvm.mlir.undef : !llvm.array<1 x struct<"struct.A", (array<4 x i8>)>> + %4 = llvm.insertvalue %2, %3[0] : !llvm.array<1 x struct<"struct.A", (array<4 x i8>)>> + llvm.return %4 : !llvm.array<1 x struct<"struct.A", (array<4 x i8>)>> + } + llvm.mlir.global external constant @b() {addr_space = 0 : i32} : !llvm.array<1 x struct<"struct.B", (array<2 x i8>, array<2 x i8>)>> { + %0 = llvm.mlir.constant("\03\04") : !llvm.array<2 x i8> + %1 = llvm.mlir.constant("\01\02") : !llvm.array<2 x i8> + %2 = llvm.mlir.undef : !llvm.struct<"struct.B", (array<2 x i8>, array<2 x i8>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.B", (array<2 x i8>, array<2 x i8>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.B", (array<2 x i8>, array<2 x i8>)> + %5 = llvm.mlir.undef : !llvm.array<1 x struct<"struct.B", (array<2 x i8>, array<2 x i8>)>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<1 x struct<"struct.B", (array<2 x i8>, array<2 x i8>)>> + llvm.return %6 : !llvm.array<1 x struct<"struct.B", (array<2 x i8>, array<2 x i8>)>> + } + llvm.func @memcmp(!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.func @fold_memcmp_i32a_i32b_pIb(%arg0: i32, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<[4386, 13124]> : tensor<2xi16>) : !llvm.array<2 x i16> + %1 = llvm.mlir.addressof @i32a : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.addressof @i32b : !llvm.ptr + %4 = llvm.mlir.constant(1 : i64) : i64 + %5 = llvm.mlir.constant(2 : i64) : i64 + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.mlir.constant(3 : i64) : i64 + %8 = llvm.getelementptr %1[%2] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %9 = llvm.getelementptr %3[%2] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %10 = llvm.call @memcmp(%8, %8, %4) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %10, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %11 = llvm.getelementptr %arg1[%2] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %12 = llvm.call @memcmp(%8, %8, %5) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %12, %11 {alignment = 4 : i64} : i32, !llvm.ptr + %13 = llvm.getelementptr %arg1[%6] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %14 = llvm.call @memcmp(%8, %8, %7) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %14, %13 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_memcmp_A_B_pIb(%arg0: i32, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant("\01\02\03\04") : !llvm.array<4 x i8> + %1 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<"struct.A", (array<4 x i8>)> + %3 = llvm.mlir.undef : !llvm.array<1 x struct<"struct.A", (array<4 x i8>)>> + %4 = llvm.insertvalue %2, %3[0] : !llvm.array<1 x struct<"struct.A", (array<4 x i8>)>> + %5 = llvm.mlir.addressof @a : !llvm.ptr + %6 = llvm.mlir.constant("\03\04") : !llvm.array<2 x i8> + %7 = llvm.mlir.constant("\01\02") : !llvm.array<2 x i8> + %8 = llvm.mlir.undef : !llvm.struct<"struct.B", (array<2 x i8>, array<2 x i8>)> + %9 = llvm.insertvalue %7, %8[0] : !llvm.struct<"struct.B", (array<2 x i8>, array<2 x i8>)> + %10 = llvm.insertvalue %6, %9[1] : !llvm.struct<"struct.B", (array<2 x i8>, array<2 x i8>)> + %11 = llvm.mlir.undef : !llvm.array<1 x struct<"struct.B", (array<2 x i8>, array<2 x i8>)>> + %12 = llvm.insertvalue %10, %11[0] : !llvm.array<1 x struct<"struct.B", (array<2 x i8>, array<2 x i8>)>> + %13 = llvm.mlir.addressof @b : !llvm.ptr + %14 = llvm.mlir.constant(1 : i64) : i64 + %15 = llvm.mlir.constant(1 : i32) : i32 + %16 = llvm.mlir.constant(2 : i64) : i64 + %17 = llvm.mlir.constant(2 : i32) : i32 + %18 = llvm.mlir.constant(3 : i64) : i64 + %19 = llvm.mlir.constant(3 : i32) : i32 + %20 = llvm.mlir.constant(4 : i64) : i64 + %21 = llvm.mlir.constant(4 : i32) : i32 + %22 = llvm.mlir.constant(5 : i32) : i32 + %23 = llvm.mlir.constant(6 : i32) : i32 + %24 = llvm.call @memcmp(%5, %13, %14) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %24, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %25 = llvm.getelementptr %arg1[%15] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %26 = llvm.call @memcmp(%5, %13, %16) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %26, %25 {alignment = 4 : i64} : i32, !llvm.ptr + %27 = llvm.getelementptr %arg1[%17] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %28 = llvm.call @memcmp(%5, %13, %18) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %28, %27 {alignment = 4 : i64} : i32, !llvm.ptr + %29 = llvm.getelementptr %arg1[%19] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %30 = llvm.call @memcmp(%5, %13, %20) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %30, %29 {alignment = 4 : i64} : i32, !llvm.ptr + %31 = llvm.getelementptr %13[%15] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %32 = llvm.getelementptr %arg1[%21] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %33 = llvm.call @memcmp(%5, %31, %14) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %33, %32 {alignment = 4 : i64} : i32, !llvm.ptr + %34 = llvm.getelementptr %arg1[%22] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %35 = llvm.call @memcmp(%5, %31, %16) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %35, %34 {alignment = 4 : i64} : i32, !llvm.ptr + %36 = llvm.getelementptr %arg1[%23] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %37 = llvm.call @memcmp(%5, %31, %18) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %37, %36 {alignment = 4 : i64} : i32, !llvm.ptr + %38 = llvm.getelementptr %5[%15] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %39 = llvm.getelementptr %arg1[%21] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %40 = llvm.call @memcmp(%38, %13, %14) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %40, %39 {alignment = 4 : i64} : i32, !llvm.ptr + %41 = llvm.getelementptr %arg1[%22] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %42 = llvm.call @memcmp(%38, %13, %16) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %42, %41 {alignment = 4 : i64} : i32, !llvm.ptr + %43 = llvm.getelementptr %arg1[%23] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %44 = llvm.call @memcmp(%38, %13, %18) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %44, %43 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/memcmp-8.ll.mlir b/test/LLVMDialect/InstCombine/memcmp-8.ll.mlir index cbfda3a17..3e39d2809 100644 --- a/test/LLVMDialect/InstCombine/memcmp-8.ll.mlir +++ b/test/LLVMDialect/InstCombine/memcmp-8.ll.mlir @@ -1,40 +1,33 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a5", type = !llvm.array<5 x i8>, value = "12345"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memcmp", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%4, %5, %arg0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "fold_memcmp_a5_a5p5_n", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%0, %2, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%4, %5, %arg0) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "fold_memcmp_a5p5_a5p5_n", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %arg0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%4, %5, %arg1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "fold_memcmp_a5pi_a5p5_n", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a5("12345") {addr_space = 0 : i32} + llvm.func @memcmp(!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.func @fold_memcmp_a5_a5p5_n(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.call @memcmp(%1, %4, %arg0) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %5 : i32 + } + llvm.func @fold_memcmp_a5p5_a5p5_n(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @memcmp(%4, %5, %arg0) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %6 : i32 + } + llvm.func @fold_memcmp_a5pi_a5p5_n(%arg0: i32, %arg1: i64) -> i32 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @memcmp(%4, %5, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/memcmp-constant-fold.ll.mlir b/test/LLVMDialect/InstCombine/memcmp-constant-fold.ll.mlir index edb26b357..a5cec5c39 100644 --- a/test/LLVMDialect/InstCombine/memcmp-constant-fold.ll.mlir +++ b/test/LLVMDialect/InstCombine/memcmp-constant-fold.ll.mlir @@ -1,57 +1,44 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = "charbuf", type = !llvm.array<4 x i8>, value = "\00\00\00\01"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = "intbuf_unaligned", type = !llvm.array<4 x i16>, value = dense<[1, 2, 3, 4]> : tensor<4xi16>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = "intbuf", type = !llvm.array<2 x i32>, value = dense<[0, 1]> : tensor<2xi32>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memcmp", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @charbuf} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %6 = "llvm.icmp"(%5, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_4bytes_unaligned_constant_i8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @intbuf_unaligned} : () -> !llvm.ptr> - %3 = "llvm.bitcast"(%2) : (!llvm.ptr>) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %5 = "llvm.icmp"(%4, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_4bytes_unaligned_constant_i16", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @intbuf} : () -> !llvm.ptr> - %3 = "llvm.bitcast"(%2) : (!llvm.ptr>) -> !llvm.ptr - %4 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %6 = "llvm.mlir.addressof"() {global_name = @intbuf} : () -> !llvm.ptr> - %7 = "llvm.getelementptr"(%6, %5, %4) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %8 = "llvm.bitcast"(%7) : (!llvm.ptr) -> !llvm.ptr - %9 = "llvm.call"(%8, %3, %1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %10 = "llvm.icmp"(%9, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%10) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_3bytes_aligned_constant_i32", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %2 = "llvm.bitcast"(%arg0) : (!llvm.ptr) -> !llvm.ptr - %3 = "llvm.load"(%2) : (!llvm.ptr) -> i32 - %4 = "llvm.call"(%arg0, %arg1, %1) {callee = @memcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %5 = "llvm.icmp"(%4, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "memcmp_4bytes_one_unaligned_i8", type = !llvm.func, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private unnamed_addr constant @charbuf("\00\00\00\01") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @intbuf_unaligned(dense<[1, 2, 3, 4]> : tensor<4xi16>) {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : !llvm.array<4 x i16> + llvm.mlir.global private unnamed_addr constant @intbuf(dense<[0, 1]> : tensor<2xi32>) {addr_space = 0 : i32, alignment = 4 : i64, dso_local} : !llvm.array<2 x i32> + llvm.func @memcmp(!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.func @memcmp_4bytes_unaligned_constant_i8(%arg0: !llvm.ptr {llvm.align = 4 : i64}) -> i1 { + %0 = llvm.mlir.constant("\00\00\00\01") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @charbuf : !llvm.ptr + %2 = llvm.mlir.constant(4 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @memcmp(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "eq" %4, %3 : i32 + llvm.return %5 : i1 + } + llvm.func @memcmp_4bytes_unaligned_constant_i16(%arg0: !llvm.ptr {llvm.align = 4 : i64}) -> i1 { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : tensor<4xi16>) : !llvm.array<4 x i16> + %1 = llvm.mlir.addressof @intbuf_unaligned : !llvm.ptr + %2 = llvm.mlir.constant(4 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @memcmp(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "eq" %4, %3 : i32 + llvm.return %5 : i1 + } + llvm.func @memcmp_3bytes_aligned_constant_i32(%arg0: !llvm.ptr {llvm.align = 4 : i64}) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<[0, 1]> : tensor<2xi32>) : !llvm.array<2 x i32> + %3 = llvm.mlir.addressof @intbuf : !llvm.ptr + %4 = llvm.getelementptr inbounds %3[%1, %0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<2 x i32> + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.call @memcmp(%4, %3, %5) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %8 = llvm.icmp "eq" %7, %6 : i32 + llvm.return %8 : i1 + } + llvm.func @memcmp_4bytes_one_unaligned_i8(%arg0: !llvm.ptr {llvm.align = 4 : i64}, %arg1: !llvm.ptr {llvm.align = 1 : i64}) -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %3 = llvm.call @memcmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/memcpy-1.ll.mlir b/test/LLVMDialect/InstCombine/memcpy-1.ll.mlir index 44868cb53..42cc94e0b 100644 --- a/test/LLVMDialect/InstCombine/memcpy-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/memcpy-1.ll.mlir @@ -1,33 +1,25 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memcpy", type = !llvm.func (ptr, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify1", type = !llvm.func (ptr, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify2", type = !llvm.func (ptr, ptr, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "get_dest", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.call"() {callee = @get_dest, fastmathFlags = #llvm.fastmath<>} : () -> !llvm.ptr - %1 = "llvm.call"(%0, %arg0, %arg1) {callee = @memcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify3", type = !llvm.func (ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_no_incompatible_attr", type = !llvm.func (ptr, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func (ptr, ptr, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @memcpy(!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.func @test_simplify1(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memcpy(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test_simplify2(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr attributes {passthrough = ["strictfp"]} { + %0 = llvm.call @memcpy(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @get_dest() -> !llvm.ptr + llvm.func @test_simplify3(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.call @get_dest() : () -> !llvm.ptr + %1 = llvm.call @memcpy(%0, %arg0, %arg1) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test_no_incompatible_attr(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memcpy(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test_no_simplify1(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memcpy(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memcpy-2.ll.mlir b/test/LLVMDialect/InstCombine/memcpy-2.ll.mlir index f4a683639..a5264f91f 100644 --- a/test/LLVMDialect/InstCombine/memcpy-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/memcpy-2.ll.mlir @@ -1,10 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memcpy", type = !llvm.func, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i8 - "llvm.return"(%0) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func, ptr, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @memcpy(!llvm.ptr, !llvm.ptr, i32) -> i8 + llvm.func @test_no_simplify1(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> i8 { + %0 = llvm.call @memcpy(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> i8 + llvm.return %0 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/memcpy-addrspace.ll.mlir b/test/LLVMDialect/InstCombine/memcpy-addrspace.ll.mlir index b7e62141e..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/memcpy-addrspace.ll.mlir +++ b/test/LLVMDialect/InstCombine/memcpy-addrspace.ll.mlir @@ -1,117 +0,0 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = "test.data", type = !llvm.array<8 x i32>, value = dense<[0, 1, 2, 3, 4, 5, 6, 7]> : tensor<8xi32>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @test.data} : () -> !llvm.ptr> - %4 = "llvm.bitcast"(%3) : (!llvm.ptr>) -> !llvm.ptr - %5 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %6 = "llvm.alloca"(%5) : (i32) -> !llvm.ptr> - %7 = "llvm.bitcast"(%6) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%7, %4, %2, %1) {callee = @llvm.memcpy.p0i8.p2i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - %8 = "llvm.getelementptr"(%6, %0, %arg1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %9 = "llvm.load"(%8) : (!llvm.ptr) -> i32 - %10 = "llvm.getelementptr"(%arg0, %arg1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%9, %10) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_load", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @test.data} : () -> !llvm.ptr> - %3 = "llvm.bitcast"(%2) : (!llvm.ptr>) -> !llvm.ptr - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.alloca"(%4) : (i32) -> !llvm.ptr> - %6 = "llvm.bitcast"(%5) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%6, %3, %1, %0) {callee = @llvm.memcpy.p0i8.p2i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - %7 = "llvm.bitcast"(%6) : (!llvm.ptr) -> !llvm.ptr - %8 = "llvm.getelementptr"(%7, %arg1) : (!llvm.ptr, i64) -> !llvm.ptr - %9 = "llvm.load"(%8) : (!llvm.ptr) -> i32 - %10 = "llvm.getelementptr"(%arg0, %arg1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%9, %10) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_load_bitcast_chain", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @test.data} : () -> !llvm.ptr> - %4 = "llvm.bitcast"(%3) : (!llvm.ptr>) -> !llvm.ptr - %5 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %6 = "llvm.alloca"(%5) : (i32) -> !llvm.ptr> - %7 = "llvm.bitcast"(%6) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%7, %4, %2, %1) {callee = @llvm.memcpy.p0i8.p2i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - %8 = "llvm.getelementptr"(%6, %0, %arg1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %9 = "llvm.call"(%8) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - %10 = "llvm.getelementptr"(%arg0, %arg1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%9, %10) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_call", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @test.data} : () -> !llvm.ptr> - %4 = "llvm.bitcast"(%3) : (!llvm.ptr>) -> !llvm.ptr - %5 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %6 = "llvm.alloca"(%5) : (i32) -> !llvm.ptr> - %7 = "llvm.bitcast"(%6) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%7, %4, %2, %1) {callee = @llvm.memcpy.p0i8.p2i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - %8 = "llvm.getelementptr"(%6, %0, %arg1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %9 = "llvm.call"(%8) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - %10 = "llvm.getelementptr"(%arg0, %arg1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%9, %10) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_call_no_null_opt", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @test.data} : () -> !llvm.ptr> - %4 = "llvm.bitcast"(%3) : (!llvm.ptr>) -> !llvm.ptr - %5 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %6 = "llvm.alloca"(%5) : (i32) -> !llvm.ptr> - %7 = "llvm.bitcast"(%6) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%7, %4, %2, %1) {callee = @llvm.memcpy.p0i8.p2i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - %8 = "llvm.getelementptr"(%6, %0, %arg1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %9 = "llvm.load"(%8) : (!llvm.ptr) -> i32 - %10 = "llvm.getelementptr"(%arg0, %arg1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%9, %10) : (i32, !llvm.ptr) -> () - %11 = "llvm.call"(%8) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - %12 = "llvm.getelementptr"(%arg0, %arg2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%11, %12) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_load_and_call", type = !llvm.func, i64, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @test.data} : () -> !llvm.ptr> - %4 = "llvm.bitcast"(%3) : (!llvm.ptr>) -> !llvm.ptr - %5 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %6 = "llvm.alloca"(%5) : (i32) -> !llvm.ptr> - %7 = "llvm.bitcast"(%6) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%7, %4, %2, %1) {callee = @llvm.memcpy.p0i8.p2i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - %8 = "llvm.getelementptr"(%6, %0, %arg1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %9 = "llvm.load"(%8) : (!llvm.ptr) -> i32 - %10 = "llvm.getelementptr"(%arg0, %arg1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%9, %10) : (i32, !llvm.ptr) -> () - %11 = "llvm.call"(%8) {callee = @foo, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - %12 = "llvm.getelementptr"(%arg0, %arg2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%11, %12) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_load_and_call_no_null_opt", type = !llvm.func, i64, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memcpy.p0i8.p2i8.i64", type = !llvm.func, ptr, i64, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/memcpy-from-global.ll.mlir b/test/LLVMDialect/InstCombine/memcpy-from-global.ll.mlir new file mode 100644 index 000000000..0d3ff15f1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/memcpy-from-global.ll.mlir @@ -0,0 +1,453 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "big">>} { + llvm.mlir.global internal constant @C.0.1248(dense<"0x000080BF000080BF000080BF00000000000080BF000080BF00000000000080BF000080BF000080BF000000000000803F000080BF000080BF0000803F00000000000080BF00000000000080BF000080BF000080BF00000000000080BF0000803F000080BF000000000000803F000080BF000080BF000000000000803F0000803F000080BF0000803F000080BF00000000000080BF0000803F00000000000080BF000080BF0000803F000000000000803F000080BF0000803F0000803F0000000000000000000080BF000080BF000080BF00000000000080BF000080BF0000803F00000000000080BF0000803F000080BF00000000000080BF0000803F0000803F0000803F000080BF000080BF000000000000803F000080BF00000000000080BF0000803F000080BF000000000000803F0000803F000080BF0000803F000000000000803F00000000000080BF000080BF0000803F00000000000080BF0000803F0000803F000000000000803F000080BF0000803F000000000000803F0000803F0000803F0000803F000080BF000000000000803F0000803F00000000000080BF0000803F0000803F000000000000803F0000803F0000803F0000803F00000000000000000000803F000080BF000080BF000000000000803F000080BF0000803F000000000000803F0000803F000080BF000000000000803F0000803F0000803F"> : tensor<128xf32>) {addr_space = 0 : i32, alignment = 32 : i64, dso_local} : !llvm.array<128 x f32> + llvm.mlir.global external constant @G() {addr_space = 0 : i32} : !llvm.struct<"T", (i8, array<123 x i8>)> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<123xi8>) : !llvm.array<123 x i8> + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.mlir.undef : !llvm.struct<"T", (i8, array<123 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"T", (i8, array<123 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"T", (i8, array<123 x i8>)> + llvm.return %5 : !llvm.struct<"T", (i8, array<123 x i8>)> + } + llvm.mlir.global external constant @H() {addr_space = 0 : i32, alignment = 16 : i64} : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %3 = llvm.insertvalue %0, %2[1] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %4 = llvm.insertvalue %0, %3[2] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %5 = llvm.insertvalue %0, %4[3] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %6 = llvm.insertvalue %0, %5[4] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %7 = llvm.mlir.undef : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %8 = llvm.insertvalue %6, %7[0] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %9 = llvm.insertvalue %6, %8[1] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + llvm.return %9 : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + } + llvm.mlir.global internal constant @I(dense<0.000000e+00> : tensor<4xf32>) {addr_space = 1 : i32, alignment = 4 : i64, dso_local} : !llvm.array<4 x f32> + llvm.mlir.global external local_unnamed_addr @bbb(dense<0> : tensor<1000000xi8>) {addr_space = 0 : i32, alignment = 16 : i64} : !llvm.array<1000000 x i8> + llvm.mlir.global internal unnamed_addr constant @_ZL3KKK("\01\01\02") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.func @test1(%arg0: i32, %arg1: f32, %arg2: f32, %arg3: f32, %arg4: f32) -> f32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(dense<"0x000080BF000080BF000080BF00000000000080BF000080BF00000000000080BF000080BF000080BF000000000000803F000080BF000080BF0000803F00000000000080BF00000000000080BF000080BF000080BF00000000000080BF0000803F000080BF000000000000803F000080BF000080BF000000000000803F0000803F000080BF0000803F000080BF00000000000080BF0000803F00000000000080BF000080BF0000803F000000000000803F000080BF0000803F0000803F0000000000000000000080BF000080BF000080BF00000000000080BF000080BF0000803F00000000000080BF0000803F000080BF00000000000080BF0000803F0000803F0000803F000080BF000080BF000000000000803F000080BF00000000000080BF0000803F000080BF000000000000803F0000803F000080BF0000803F000000000000803F00000000000080BF000080BF0000803F00000000000080BF0000803F0000803F000000000000803F000080BF0000803F000000000000803F0000803F0000803F0000803F000080BF000000000000803F0000803F00000000000080BF0000803F0000803F000000000000803F0000803F0000803F0000803F00000000000000000000803F000080BF000080BF000000000000803F000080BF0000803F000000000000803F0000803F000080BF000000000000803F0000803F0000803F"> : tensor<128xf32>) : !llvm.array<128 x f32> + %2 = llvm.mlir.addressof @C.0.1248 : !llvm.ptr + %3 = llvm.mlir.constant(512 : i64) : i64 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(124 : i32) : i32 + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %8 = llvm.mlir.constant(3 : i32) : i32 + %9 = llvm.alloca %0 x !llvm.array<128 x f32> {alignment = 16 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%9, %2, %3) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + %10 = llvm.shl %arg0, %4 : i32 + %11 = llvm.and %10, %5 : i32 + %12 = llvm.getelementptr %9[%6, %11] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<128 x f32> + %13 = llvm.load %12 {alignment = 4 : i64} : !llvm.ptr -> f32 + %14 = llvm.fmul %13, %arg1 : f32 + %15 = llvm.fadd %14, %7 : f32 + %16 = llvm.or %11, %0 : i32 + %17 = llvm.getelementptr %9[%6, %16] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<128 x f32> + %18 = llvm.load %17 {alignment = 4 : i64} : !llvm.ptr -> f32 + %19 = llvm.fmul %18, %arg2 : f32 + %20 = llvm.fadd %19, %15 : f32 + %21 = llvm.or %11, %4 : i32 + %22 = llvm.getelementptr %9[%6, %21] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<128 x f32> + %23 = llvm.load %22 {alignment = 4 : i64} : !llvm.ptr -> f32 + %24 = llvm.fmul %23, %arg3 : f32 + %25 = llvm.fadd %24, %20 : f32 + %26 = llvm.or %11, %8 : i32 + %27 = llvm.getelementptr %9[%6, %26] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<128 x f32> + %28 = llvm.load %27 {alignment = 4 : i64} : !llvm.ptr -> f32 + %29 = llvm.fmul %28, %arg4 : f32 + %30 = llvm.fadd %29, %25 : f32 + llvm.return %30 : f32 + } + llvm.func @test2() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<123xi8>) : !llvm.array<123 x i8> + %3 = llvm.mlir.constant(1 : i8) : i8 + %4 = llvm.mlir.undef : !llvm.struct<"T", (i8, array<123 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"T", (i8, array<123 x i8>)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"T", (i8, array<123 x i8>)> + %7 = llvm.mlir.addressof @G : !llvm.ptr + %8 = llvm.mlir.constant(124 : i64) : i64 + %9 = llvm.alloca %0 x !llvm.struct<"T", (i8, array<123 x i8>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %10 = llvm.alloca %0 x !llvm.struct<"T", (i8, array<123 x i8>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%9, %7, %8) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + "llvm.intr.memcpy"(%10, %9, %8) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @bar(%10) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test2_no_null_opt() attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<123xi8>) : !llvm.array<123 x i8> + %3 = llvm.mlir.constant(1 : i8) : i8 + %4 = llvm.mlir.undef : !llvm.struct<"T", (i8, array<123 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"T", (i8, array<123 x i8>)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"T", (i8, array<123 x i8>)> + %7 = llvm.mlir.addressof @G : !llvm.ptr + %8 = llvm.mlir.constant(124 : i64) : i64 + %9 = llvm.alloca %0 x !llvm.struct<"T", (i8, array<123 x i8>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %10 = llvm.alloca %0 x !llvm.struct<"T", (i8, array<123 x i8>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%9, %7, %8) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + "llvm.intr.memcpy"(%10, %9, %8) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @bar(%10) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test2_addrspacecast() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<123xi8>) : !llvm.array<123 x i8> + %3 = llvm.mlir.constant(1 : i8) : i8 + %4 = llvm.mlir.undef : !llvm.struct<"T", (i8, array<123 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"T", (i8, array<123 x i8>)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"T", (i8, array<123 x i8>)> + %7 = llvm.mlir.addressof @G : !llvm.ptr + %8 = llvm.mlir.constant(124 : i64) : i64 + %9 = llvm.alloca %0 x !llvm.struct<"T", (i8, array<123 x i8>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %10 = llvm.alloca %0 x !llvm.struct<"T", (i8, array<123 x i8>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %11 = llvm.addrspacecast %9 : !llvm.ptr to !llvm.ptr<1> + %12 = llvm.addrspacecast %10 : !llvm.ptr to !llvm.ptr<1> + "llvm.intr.memcpy"(%11, %7, %8) <{isVolatile = false}> : (!llvm.ptr<1>, !llvm.ptr, i64) -> () + "llvm.intr.memcpy"(%12, %11, %8) <{isVolatile = false}> : (!llvm.ptr<1>, !llvm.ptr<1>, i64) -> () + llvm.call @bar_as1(%12) : (!llvm.ptr<1>) -> () + llvm.return + } + llvm.func @bar(!llvm.ptr) + llvm.func @bar_as1(!llvm.ptr<1>) + llvm.func @test3() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<123xi8>) : !llvm.array<123 x i8> + %3 = llvm.mlir.constant(1 : i8) : i8 + %4 = llvm.mlir.undef : !llvm.struct<"T", (i8, array<123 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"T", (i8, array<123 x i8>)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"T", (i8, array<123 x i8>)> + %7 = llvm.mlir.addressof @G : !llvm.ptr + %8 = llvm.mlir.constant(124 : i64) : i64 + %9 = llvm.alloca %0 x !llvm.struct<"T", (i8, array<123 x i8>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%9, %7, %8) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @bar(%9) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test3_addrspacecast() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<123xi8>) : !llvm.array<123 x i8> + %3 = llvm.mlir.constant(1 : i8) : i8 + %4 = llvm.mlir.undef : !llvm.struct<"T", (i8, array<123 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"T", (i8, array<123 x i8>)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"T", (i8, array<123 x i8>)> + %7 = llvm.mlir.addressof @G : !llvm.ptr + %8 = llvm.addrspacecast %7 : !llvm.ptr to !llvm.ptr<1> + %9 = llvm.mlir.constant(124 : i64) : i64 + %10 = llvm.alloca %0 x !llvm.struct<"T", (i8, array<123 x i8>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%10, %8, %9) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr<1>, i64) -> () + llvm.call @bar(%10) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test4() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<123xi8>) : !llvm.array<123 x i8> + %3 = llvm.mlir.constant(1 : i8) : i8 + %4 = llvm.mlir.undef : !llvm.struct<"T", (i8, array<123 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"T", (i8, array<123 x i8>)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"T", (i8, array<123 x i8>)> + %7 = llvm.mlir.addressof @G : !llvm.ptr + %8 = llvm.mlir.constant(124 : i64) : i64 + %9 = llvm.alloca %0 x !llvm.struct<"T", (i8, array<123 x i8>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%9, %7, %8) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @baz(%9) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test5() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<123xi8>) : !llvm.array<123 x i8> + %3 = llvm.mlir.constant(1 : i8) : i8 + %4 = llvm.mlir.undef : !llvm.struct<"T", (i8, array<123 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"T", (i8, array<123 x i8>)> + %6 = llvm.insertvalue %2, %5[1] : !llvm.struct<"T", (i8, array<123 x i8>)> + %7 = llvm.mlir.addressof @G : !llvm.ptr + %8 = llvm.mlir.constant(124 : i64) : i64 + %9 = llvm.alloca %0 x !llvm.struct<"T", (i8, array<123 x i8>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start -1, %9 : !llvm.ptr + "llvm.intr.memcpy"(%9, %7, %8) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @baz(%9) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @baz(!llvm.ptr {llvm.byval = i8}) + llvm.func @test6() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %4 = llvm.insertvalue %1, %3[1] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %5 = llvm.insertvalue %1, %4[2] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %6 = llvm.insertvalue %1, %5[3] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[4] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %8 = llvm.mlir.undef : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %9 = llvm.insertvalue %7, %8[0] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %10 = llvm.insertvalue %7, %9[1] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %11 = llvm.mlir.addressof @H : !llvm.ptr + %12 = llvm.mlir.constant(20 : i64) : i64 + %13 = llvm.alloca %0 x !llvm.struct<"U", (i32, i32, i32, i32, i32)> {alignment = 16 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%13, %11, %12) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @bar(%13) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test7() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %4 = llvm.insertvalue %1, %3[1] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %5 = llvm.insertvalue %1, %4[2] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %6 = llvm.insertvalue %1, %5[3] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[4] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %8 = llvm.mlir.undef : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %9 = llvm.insertvalue %7, %8[0] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %10 = llvm.insertvalue %7, %9[1] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %11 = llvm.mlir.addressof @H : !llvm.ptr + %12 = llvm.mlir.constant(20 : i64) : i64 + %13 = llvm.alloca %0 x !llvm.struct<"U", (i32, i32, i32, i32, i32)> {alignment = 16 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%13, %11, %12) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @bar(%13) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test8() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.undef : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %5 = llvm.insertvalue %2, %4[1] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[2] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %7 = llvm.insertvalue %2, %6[3] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %8 = llvm.insertvalue %2, %7[4] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %9 = llvm.mlir.undef : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %10 = llvm.insertvalue %8, %9[0] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %11 = llvm.insertvalue %8, %10[1] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %12 = llvm.mlir.addressof @H : !llvm.ptr + %13 = llvm.getelementptr inbounds %12[%1, %0] : (!llvm.ptr, i64, i32) -> !llvm.ptr, !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %14 = llvm.mlir.constant(20 : i64) : i64 + %15 = llvm.alloca %0 x !llvm.struct<"U", (i32, i32, i32, i32, i32)> {alignment = 16 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%15, %13, %14) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @bar(%15) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test8_addrspacecast() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.undef : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %5 = llvm.insertvalue %2, %4[1] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[2] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %7 = llvm.insertvalue %2, %6[3] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %8 = llvm.insertvalue %2, %7[4] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %9 = llvm.mlir.undef : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %10 = llvm.insertvalue %8, %9[0] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %11 = llvm.insertvalue %8, %10[1] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %12 = llvm.mlir.addressof @H : !llvm.ptr + %13 = llvm.getelementptr inbounds %12[%1, %0] : (!llvm.ptr, i64, i32) -> !llvm.ptr, !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %14 = llvm.addrspacecast %13 : !llvm.ptr to !llvm.ptr<1> + %15 = llvm.mlir.constant(20 : i64) : i64 + %16 = llvm.alloca %0 x !llvm.struct<"U", (i32, i32, i32, i32, i32)> {alignment = 16 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%16, %14, %15) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr<1>, i64) -> () + llvm.call @bar(%16) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test9() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.undef : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %5 = llvm.insertvalue %2, %4[1] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[2] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %7 = llvm.insertvalue %2, %6[3] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %8 = llvm.insertvalue %2, %7[4] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %9 = llvm.mlir.undef : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %10 = llvm.insertvalue %8, %9[0] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %11 = llvm.insertvalue %8, %10[1] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %12 = llvm.mlir.addressof @H : !llvm.ptr + %13 = llvm.getelementptr inbounds %12[%1, %0] : (!llvm.ptr, i64, i32) -> !llvm.ptr, !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %14 = llvm.mlir.constant(20 : i64) : i64 + %15 = llvm.alloca %0 x !llvm.struct<"U", (i32, i32, i32, i32, i32)> {alignment = 4 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%15, %13, %14) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @bar(%15) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test9_addrspacecast() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.undef : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %5 = llvm.insertvalue %2, %4[1] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %6 = llvm.insertvalue %2, %5[2] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %7 = llvm.insertvalue %2, %6[3] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %8 = llvm.insertvalue %2, %7[4] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %9 = llvm.mlir.undef : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %10 = llvm.insertvalue %8, %9[0] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %11 = llvm.insertvalue %8, %10[1] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %12 = llvm.mlir.addressof @H : !llvm.ptr + %13 = llvm.getelementptr inbounds %12[%1, %0] : (!llvm.ptr, i64, i32) -> !llvm.ptr, !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %14 = llvm.addrspacecast %13 : !llvm.ptr to !llvm.ptr<1> + %15 = llvm.mlir.constant(20 : i64) : i64 + %16 = llvm.alloca %0 x !llvm.struct<"U", (i32, i32, i32, i32, i32)> {alignment = 4 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%16, %14, %15) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr<1>, i64) -> () + llvm.call @bar(%16) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test9_small_global() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant("\01\01\02") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @_ZL3KKK : !llvm.ptr + %3 = llvm.mlir.constant(3 : i64) : i64 + %4 = llvm.mlir.constant(0 : i8) : i8 + %5 = llvm.mlir.constant(dense<0> : tensor<1000000xi8>) : !llvm.array<1000000 x i8> + %6 = llvm.mlir.addressof @bbb : !llvm.ptr + %7 = llvm.mlir.constant(1000000 : i64) : i64 + %8 = llvm.alloca %0 x !llvm.array<1000000 x i8> {alignment = 16 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%8, %2, %3) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + "llvm.intr.memcpy"(%6, %8, %7) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } + llvm.func @test10_same_global() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant("\01\01\02") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @_ZL3KKK : !llvm.ptr + %3 = llvm.mlir.constant(3 : i64) : i64 + %4 = llvm.mlir.constant(0 : i8) : i8 + %5 = llvm.mlir.constant(dense<0> : tensor<1000000xi8>) : !llvm.array<1000000 x i8> + %6 = llvm.mlir.addressof @bbb : !llvm.ptr + %7 = llvm.alloca %0 x !llvm.array<3 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%7, %2, %3) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + "llvm.intr.memcpy"(%6, %7, %3) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } + llvm.func @test11(%arg0: i64) -> f32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(dense<0.000000e+00> : tensor<4xf32>) : !llvm.array<4 x f32> + %3 = llvm.mlir.addressof @I : !llvm.ptr<1> + %4 = llvm.mlir.constant(16 : i64) : i64 + %5 = llvm.mlir.constant(0 : i64) : i64 + %6 = llvm.alloca %0 x !llvm.array<4 x f32> {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 16, %6 : !llvm.ptr + "llvm.intr.memcpy"(%6, %3, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr<1>, i64) -> () + %7 = llvm.getelementptr inbounds %6[%5, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x f32> + %8 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.return %8 : f32 + } + llvm.func @test11_volatile(%arg0: i64) -> f32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(dense<0.000000e+00> : tensor<4xf32>) : !llvm.array<4 x f32> + %3 = llvm.mlir.addressof @I : !llvm.ptr<1> + %4 = llvm.mlir.constant(16 : i64) : i64 + %5 = llvm.mlir.constant(0 : i64) : i64 + %6 = llvm.alloca %0 x !llvm.array<4 x f32> {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 16, %6 : !llvm.ptr + "llvm.intr.memcpy"(%6, %3, %4) <{isVolatile = true}> : (!llvm.ptr, !llvm.ptr<1>, i64) -> () + %7 = llvm.getelementptr inbounds %6[%5, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x f32> + %8 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.return %8 : f32 + } + llvm.func @memcpy_from_readonly_noalias(%arg0: !llvm.ptr {llvm.align = 8 : i64, llvm.dereferenceable = 124 : i64, llvm.noalias, llvm.readonly}) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(124 : i64) : i64 + %2 = llvm.alloca %0 x !llvm.struct<"T", (i8, array<123 x i8>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%2, %arg0, %1) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @bar(%2) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @memcpy_from_just_readonly(%arg0: !llvm.ptr {llvm.align = 8 : i64, llvm.dereferenceable = 124 : i64, llvm.readonly}) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(124 : i64) : i64 + %2 = llvm.alloca %0 x !llvm.struct<"T", (i8, array<123 x i8>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%2, %arg0, %1) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @bar(%2) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @volatile_memcpy() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %4 = llvm.insertvalue %1, %3[1] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %5 = llvm.insertvalue %1, %4[2] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %6 = llvm.insertvalue %1, %5[3] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[4] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %8 = llvm.mlir.undef : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %9 = llvm.insertvalue %7, %8[0] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %10 = llvm.insertvalue %7, %9[1] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %11 = llvm.mlir.addressof @H : !llvm.ptr + %12 = llvm.mlir.constant(20 : i64) : i64 + %13 = llvm.alloca %0 x !llvm.struct<"U", (i32, i32, i32, i32, i32)> {alignment = 16 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%13, %11, %12) <{isVolatile = true}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @bar(%13) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @memcpy_to_nocapture_readonly() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %4 = llvm.insertvalue %1, %3[1] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %5 = llvm.insertvalue %1, %4[2] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %6 = llvm.insertvalue %1, %5[3] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[4] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %8 = llvm.mlir.undef : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %9 = llvm.insertvalue %7, %8[0] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %10 = llvm.insertvalue %7, %9[1] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %11 = llvm.mlir.addressof @H : !llvm.ptr + %12 = llvm.mlir.constant(20 : i64) : i64 + %13 = llvm.alloca %0 x !llvm.struct<"U", (i32, i32, i32, i32, i32)> {alignment = 16 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%13, %11, %12) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @bar(%13) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @memcpy_to_capturing_readonly() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %4 = llvm.insertvalue %1, %3[1] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %5 = llvm.insertvalue %1, %4[2] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %6 = llvm.insertvalue %1, %5[3] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[4] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %8 = llvm.mlir.undef : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %9 = llvm.insertvalue %7, %8[0] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %10 = llvm.insertvalue %7, %9[1] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %11 = llvm.mlir.addressof @H : !llvm.ptr + %12 = llvm.mlir.constant(20 : i64) : i64 + %13 = llvm.alloca %0 x !llvm.struct<"U", (i32, i32, i32, i32, i32)> {alignment = 16 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%13, %11, %12) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @bar(%13) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @memcpy_to_aliased_nocapture_readonly() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %4 = llvm.insertvalue %1, %3[1] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %5 = llvm.insertvalue %1, %4[2] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %6 = llvm.insertvalue %1, %5[3] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %7 = llvm.insertvalue %1, %6[4] : !llvm.struct<"U", (i32, i32, i32, i32, i32)> + %8 = llvm.mlir.undef : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %9 = llvm.insertvalue %7, %8[0] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %10 = llvm.insertvalue %7, %9[1] : !llvm.array<2 x struct<"U", (i32, i32, i32, i32, i32)>> + %11 = llvm.mlir.addressof @H : !llvm.ptr + %12 = llvm.mlir.constant(20 : i64) : i64 + %13 = llvm.alloca %0 x !llvm.struct<"U", (i32, i32, i32, i32, i32)> {alignment = 16 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%13, %11, %12) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.call @two_params(%13, %13) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @two_params(!llvm.ptr {llvm.nocapture, llvm.readonly}, !llvm.ptr {llvm.nocapture}) +} diff --git a/test/LLVMDialect/InstCombine/memcpy-to-load.ll.mlir b/test/LLVMDialect/InstCombine/memcpy-to-load.ll.mlir index a3a4236ed..e8eb23f06 100644 --- a/test/LLVMDialect/InstCombine/memcpy-to-load.ll.mlir +++ b/test/LLVMDialect/InstCombine/memcpy-to-load.ll.mlir @@ -1,54 +1,46 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memcpy.p0i8.p0i8.i32", type = !llvm.func, ptr, i32, i1)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "copy_1_byte", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "copy_2_bytes", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "copy_3_bytes", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "copy_4_bytes", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "copy_5_bytes", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "copy_8_bytes", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "copy_16_bytes", type = !llvm.func, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +#alias_scope_domain = #llvm.alias_scope_domain, description = "The domain"> +#alias_scope_domain1 = #llvm.alias_scope_domain> +#alias_scope = #llvm.alias_scope, domain = #alias_scope_domain> +#alias_scope1 = #llvm.alias_scope, domain = #alias_scope_domain1> +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @copy_1_byte(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @copy_2_bytes(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(2 : i32) : i32 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @copy_3_bytes(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(3 : i32) : i32 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @copy_4_bytes(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(4 : i32) : i32 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @copy_5_bytes(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(5 : i32) : i32 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @copy_8_bytes(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(8 : i32) : i32 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @copy_16_bytes(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(16 : i32) : i32 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @copy_8_bytes_noalias(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(8 : i32) : i32 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{alias_scopes = [#alias_scope], isVolatile = false, noalias_scopes = [#alias_scope1]}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/memcpy.ll.mlir b/test/LLVMDialect/InstCombine/memcpy.ll.mlir index 62867d88b..1ece151fd 100644 --- a/test/LLVMDialect/InstCombine/memcpy.ll.mlir +++ b/test/LLVMDialect/InstCombine/memcpy.ll.mlir @@ -1,39 +1,24 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "UnknownConstant", type = i128} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memcpy.p0i8.p0i8.i32", type = !llvm.func, ptr, i32, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memcpy.p0i8.p0i8.i64", type = !llvm.func, ptr, i64, i1)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - "llvm.call"(%arg0, %arg0, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - "llvm.call"(%arg0, %arg0, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 17179869184 : i64} : () -> i64 - "llvm.call"(%arg0, %arg1, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @UnknownConstant} : () -> !llvm.ptr - %3 = "llvm.bitcast"(%2) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%3, %arg0, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "memcpy_to_constant", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @UnknownConstant() {addr_space = 0 : i32} : i128 + llvm.func @test1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(100 : i32) : i32 + "llvm.intr.memcpy"(%arg0, %arg0, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @test2(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(100 : i32) : i32 + "llvm.intr.memcpy"(%arg0, %arg0, %0) <{isVolatile = true}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @test3(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(17179869184 : i64) : i64 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } + llvm.func @memcpy_to_constant(%arg0: !llvm.ptr) { + %0 = llvm.mlir.addressof @UnknownConstant : !llvm.ptr + %1 = llvm.mlir.constant(16 : i32) : i32 + "llvm.intr.memcpy"(%0, %arg0, %1) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/memcpy_alloca.ll.mlir b/test/LLVMDialect/InstCombine/memcpy_alloca.ll.mlir index eef768dd3..484df00ef 100644 --- a/test/LLVMDialect/InstCombine/memcpy_alloca.ll.mlir +++ b/test/LLVMDialect/InstCombine/memcpy_alloca.ll.mlir @@ -1,76 +1,50 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - "llvm.call"(%arg0, %5, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %3 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.alloca"(%4) : (i32) -> !llvm.ptr> - %6 = "llvm.getelementptr"(%5, %3, %3) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - "llvm.store"(%2, %6) : (i8, !llvm.ptr) -> () - "llvm.call"(%arg0, %6, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - "llvm.call"(%arg0, %5, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr> - %4 = "llvm.bitcast"(%3) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%arg0, %4, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr> - %4 = "llvm.bitcast"(%3) : (!llvm.ptr>) -> !llvm.ptr - %5 = "llvm.getelementptr"(%4, %2) : (!llvm.ptr, i32) -> !llvm.ptr - %6 = "llvm.bitcast"(%5) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%arg0, %6, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 42 : i16} : () -> i16 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.alloca"(%3) : (i32) -> !llvm.ptr> - %5 = "llvm.bitcast"(%4) : (!llvm.ptr>) -> !llvm.ptr - %6 = "llvm.getelementptr"(%5, %3) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%2, %6) : (i16, !llvm.ptr) -> () - %7 = "llvm.bitcast"(%6) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%arg0, %7, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memcpy.p0i8.p0i8.i64", type = !llvm.func, ptr, i64, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(7 : i64) : i64 + %2 = llvm.alloca %0 x !llvm.array<7 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%arg0, %2, %1) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } + llvm.func @test2(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(7 : i64) : i64 + %3 = llvm.alloca %0 x !llvm.array<7 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %3 {alignment = 1 : i64} : i8, !llvm.ptr + "llvm.intr.memcpy"(%arg0, %3, %2) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } + llvm.func @test3(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(7 : i64) : i64 + %2 = llvm.alloca %0 x !llvm.array<7 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%arg0, %2, %1) <{isVolatile = true}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } + llvm.func @test4(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(7 : i64) : i64 + %2 = llvm.alloca %0 x !llvm.array<7 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%arg0, %2, %1) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } + llvm.func @test5(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.alloca %0 x !llvm.array<7 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + %3 = llvm.getelementptr %2[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + "llvm.intr.memcpy"(%arg0, %3, %1) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } + llvm.func @test6(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(42 : i16) : i16 + %2 = llvm.mlir.constant(7 : i64) : i64 + %3 = llvm.alloca %0 x !llvm.array<7 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + %4 = llvm.getelementptr %3[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i16 + llvm.store %1, %4 {alignment = 2 : i64} : i16, !llvm.ptr + "llvm.intr.memcpy"(%arg0, %4, %2) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/memcpy_chk-1.ll.mlir b/test/LLVMDialect/InstCombine/memcpy_chk-1.ll.mlir new file mode 100644 index 000000000..5c703f4bf --- /dev/null +++ b/test/LLVMDialect/InstCombine/memcpy_chk-1.ll.mlir @@ -0,0 +1,175 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @t1() {addr_space = 0 : i32} : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + llvm.return %7 : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + } + llvm.mlir.global common @t2() {addr_space = 0 : i32} : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + llvm.return %7 : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + } + llvm.mlir.global common @t3() {addr_space = 0 : i32} : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<2048xi8>) : !llvm.array<2048 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + llvm.return %7 : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + } + llvm.func @test_simplify1() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %8 = llvm.mlir.addressof @t1 : !llvm.ptr + %9 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %10 = llvm.insertvalue %3, %9[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %11 = llvm.insertvalue %3, %10[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %12 = llvm.insertvalue %1, %11[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %13 = llvm.mlir.addressof @t2 : !llvm.ptr + %14 = llvm.mlir.constant(1824 : i64) : i64 + %15 = llvm.call @__memcpy_chk(%8, %13, %14, %14) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %15 : !llvm.ptr + } + llvm.func @test_simplify2() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %8 = llvm.mlir.addressof @t1 : !llvm.ptr + %9 = llvm.mlir.constant(dense<0> : tensor<2048xi8>) : !llvm.array<2048 x i8> + %10 = llvm.mlir.undef : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %11 = llvm.insertvalue %3, %10[0] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %12 = llvm.insertvalue %3, %11[1] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %13 = llvm.insertvalue %9, %12[2] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %14 = llvm.mlir.addressof @t3 : !llvm.ptr + %15 = llvm.mlir.constant(1824 : i64) : i64 + %16 = llvm.mlir.constant(2848 : i64) : i64 + %17 = llvm.call @__memcpy_chk(%8, %14, %15, %16) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %17 : !llvm.ptr + } + llvm.func @test_simplify3() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %8 = llvm.mlir.addressof @t1 : !llvm.ptr + %9 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %10 = llvm.insertvalue %3, %9[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %11 = llvm.insertvalue %3, %10[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %12 = llvm.insertvalue %1, %11[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %13 = llvm.mlir.addressof @t2 : !llvm.ptr + %14 = llvm.mlir.constant(1824 : i64) : i64 + %15 = llvm.call @__memcpy_chk(%8, %13, %14, %14) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %15 : !llvm.ptr + } + llvm.func @test_no_simplify1() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<2048xi8>) : !llvm.array<2048 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %8 = llvm.mlir.addressof @t3 : !llvm.ptr + %9 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %10 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %11 = llvm.insertvalue %3, %10[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %12 = llvm.insertvalue %3, %11[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %13 = llvm.insertvalue %9, %12[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %14 = llvm.mlir.addressof @t1 : !llvm.ptr + %15 = llvm.mlir.constant(2848 : i64) : i64 + %16 = llvm.mlir.constant(1824 : i64) : i64 + %17 = llvm.call @__memcpy_chk(%8, %14, %15, %16) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %17 : !llvm.ptr + } + llvm.func @test_no_simplify2() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %8 = llvm.mlir.addressof @t1 : !llvm.ptr + %9 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %10 = llvm.insertvalue %3, %9[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %11 = llvm.insertvalue %3, %10[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %12 = llvm.insertvalue %1, %11[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %13 = llvm.mlir.addressof @t2 : !llvm.ptr + %14 = llvm.mlir.constant(1024 : i64) : i64 + %15 = llvm.mlir.constant(0 : i64) : i64 + %16 = llvm.call @__memcpy_chk(%8, %13, %14, %15) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %16 : !llvm.ptr + } + llvm.func @test_no_simplify3(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64, %arg3: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1824 : i64) : i64 + %1 = llvm.call @__memcpy_chk(%arg0, %arg1, %0, %0) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test_simplify_return_indcall(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %8 = llvm.mlir.addressof @t2 : !llvm.ptr + %9 = llvm.mlir.constant(1824 : i64) : i64 + %10 = llvm.call %arg0() : !llvm.ptr, () -> !llvm.ptr + %11 = llvm.call @__memcpy_chk(%10, %8, %9, %9) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %11 : !llvm.ptr + } + llvm.func @test_no_incompatible_attr(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %8 = llvm.mlir.addressof @t1 : !llvm.ptr + %9 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %10 = llvm.insertvalue %3, %9[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %11 = llvm.insertvalue %3, %10[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %12 = llvm.insertvalue %1, %11[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %13 = llvm.mlir.addressof @t2 : !llvm.ptr + %14 = llvm.mlir.constant(1824 : i64) : i64 + %15 = llvm.call @__memcpy_chk(%8, %13, %14, %14) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %15 : !llvm.ptr + } + llvm.func @__memcpy_chk(!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr +} diff --git a/test/LLVMDialect/InstCombine/memcpy_chk-2.ll.mlir b/test/LLVMDialect/InstCombine/memcpy_chk-2.ll.mlir new file mode 100644 index 000000000..01765da9f --- /dev/null +++ b/test/LLVMDialect/InstCombine/memcpy_chk-2.ll.mlir @@ -0,0 +1,44 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @t1() {addr_space = 0 : i32} : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + llvm.return %7 : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + } + llvm.mlir.global common @t2() {addr_space = 0 : i32} : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + llvm.return %7 : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + } + llvm.func @test_no_simplify() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %8 = llvm.mlir.addressof @t1 : !llvm.ptr + %9 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %10 = llvm.insertvalue %3, %9[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %11 = llvm.insertvalue %3, %10[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %12 = llvm.insertvalue %1, %11[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %13 = llvm.mlir.addressof @t2 : !llvm.ptr + %14 = llvm.mlir.constant(1824 : i64) : i64 + %15 = llvm.call @__memcpy_chk(%8, %13, %14) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return + } + llvm.func @__memcpy_chk(!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr +} diff --git a/test/LLVMDialect/InstCombine/memmove-1.ll.mlir b/test/LLVMDialect/InstCombine/memmove-1.ll.mlir index b29710a52..3f5a21644 100644 --- a/test/LLVMDialect/InstCombine/memmove-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/memmove-1.ll.mlir @@ -1,25 +1,19 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memmove", type = !llvm.func (ptr, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memmove, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify1", type = !llvm.func (ptr, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memmove, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify2", type = !llvm.func (ptr, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memmove, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func (ptr, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memmove, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_no_incompatible_attr", type = !llvm.func (ptr, ptr, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @memmove(!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.func @test_simplify1(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memmove(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test_simplify2(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memmove(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test_no_simplify1(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memmove(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test_no_incompatible_attr(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memmove(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memmove-2.ll.mlir b/test/LLVMDialect/InstCombine/memmove-2.ll.mlir index 376b98deb..73694e454 100644 --- a/test/LLVMDialect/InstCombine/memmove-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/memmove-2.ll.mlir @@ -1,10 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memmove", type = !llvm.func, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memmove, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i8 - "llvm.return"(%0) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func, ptr, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @memmove(!llvm.ptr, !llvm.ptr, i32) -> i8 + llvm.func @test_no_simplify1(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> i8 { + %0 = llvm.call @memmove(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> i8 + llvm.return %0 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/memmove.ll.mlir b/test/LLVMDialect/InstCombine/memmove.ll.mlir index b7a0a5e45..b9943ab57 100644 --- a/test/LLVMDialect/InstCombine/memmove.ll.mlir +++ b/test/LLVMDialect/InstCombine/memmove.ll.mlir @@ -1,66 +1,49 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 1 : i64, sym_name = "S", type = !llvm.array<33 x i8>, value = "panic: restorelist inconsistency\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "h", type = !llvm.array<2 x i8>, value = "h\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hel", type = !llvm.array<4 x i8>, value = "hel\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello_u", type = !llvm.array<8 x i8>, value = "hello_u\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "UnknownConstant", type = i128} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.call"(%arg0, %arg1, %1, %0) {callee = @llvm.memmove.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @S} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - "llvm.call"(%arg0, %3, %arg1, %0) {callee = @llvm.memmove.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = false} : () -> i1 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.mlir.addressof"() {global_name = @hello_u} : () -> !llvm.ptr> - %5 = "llvm.mlir.addressof"() {global_name = @hel} : () -> !llvm.ptr> - %6 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %7 = "llvm.mlir.addressof"() {global_name = @h} : () -> !llvm.ptr> - %8 = "llvm.getelementptr"(%7, %6, %6) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %9 = "llvm.getelementptr"(%5, %6, %6) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %10 = "llvm.getelementptr"(%4, %6, %6) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %11 = "llvm.getelementptr"(%arg0, %6, %6) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - "llvm.call"(%11, %8, %3, %2) {callee = @llvm.memmove.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.call"(%11, %9, %1, %2) {callee = @llvm.memmove.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.call"(%11, %10, %0, %2) {callee = @llvm.memmove.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - "llvm.call"(%arg0, %arg0, %1, %0) {callee = @llvm.memmove.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @UnknownConstant} : () -> !llvm.ptr - %3 = "llvm.bitcast"(%2) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%3, %arg0, %1, %0) {callee = @llvm.memmove.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "memmove_to_constant", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memmove.p0i8.p0i8.i32", type = !llvm.func, ptr, i32, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal constant @S("panic: restorelist inconsistency\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global external constant @h("h\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hel("hel\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hello_u("hello_u\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @UnknownConstant() {addr_space = 0 : i32} : i128 + llvm.func @test1(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + "llvm.intr.memmove"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @test2(%arg0: !llvm.ptr, %arg1: i32) { + %0 = llvm.mlir.constant("panic: restorelist inconsistency\00") : !llvm.array<33 x i8> + %1 = llvm.mlir.addressof @S : !llvm.ptr + "llvm.intr.memmove"(%arg0, %1, %arg1) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @test3(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant("h\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @h : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant("hel\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.addressof @hel : !llvm.ptr + %5 = llvm.mlir.constant("hello_u\00") : !llvm.array<8 x i8> + %6 = llvm.mlir.addressof @hello_u : !llvm.ptr + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.mlir.constant(4 : i32) : i32 + %9 = llvm.mlir.constant(8 : i32) : i32 + %10 = llvm.getelementptr %1[%2, %2] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<2 x i8> + %11 = llvm.getelementptr %4[%2, %2] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<4 x i8> + %12 = llvm.getelementptr %6[%2, %2] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<8 x i8> + %13 = llvm.getelementptr %arg0[%2, %2] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<1024 x i8> + "llvm.intr.memmove"(%13, %10, %7) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + "llvm.intr.memmove"(%13, %11, %8) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + "llvm.intr.memmove"(%13, %12, %9) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return %2 : i32 + } + llvm.func @test4(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(100 : i32) : i32 + "llvm.intr.memmove"(%arg0, %arg0, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } + llvm.func @memmove_to_constant(%arg0: !llvm.ptr) { + %0 = llvm.mlir.addressof @UnknownConstant : !llvm.ptr + %1 = llvm.mlir.constant(16 : i32) : i32 + "llvm.intr.memmove"(%0, %arg0, %1) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/memmove_chk-1.ll.mlir b/test/LLVMDialect/InstCombine/memmove_chk-1.ll.mlir new file mode 100644 index 000000000..2746e5899 --- /dev/null +++ b/test/LLVMDialect/InstCombine/memmove_chk-1.ll.mlir @@ -0,0 +1,160 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @t1() {addr_space = 0 : i32} : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + llvm.return %7 : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + } + llvm.mlir.global common @t2() {addr_space = 0 : i32} : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + llvm.return %7 : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + } + llvm.mlir.global common @t3() {addr_space = 0 : i32} : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<2048xi8>) : !llvm.array<2048 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + llvm.return %7 : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + } + llvm.func @test_simplify1() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %8 = llvm.mlir.addressof @t1 : !llvm.ptr + %9 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %10 = llvm.insertvalue %3, %9[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %11 = llvm.insertvalue %3, %10[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %12 = llvm.insertvalue %1, %11[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %13 = llvm.mlir.addressof @t2 : !llvm.ptr + %14 = llvm.mlir.constant(1824 : i64) : i64 + %15 = llvm.call @__memmove_chk(%8, %13, %14, %14) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %15 : !llvm.ptr + } + llvm.func @test_simplify2() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %8 = llvm.mlir.addressof @t1 : !llvm.ptr + %9 = llvm.mlir.constant(dense<0> : tensor<2048xi8>) : !llvm.array<2048 x i8> + %10 = llvm.mlir.undef : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %11 = llvm.insertvalue %3, %10[0] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %12 = llvm.insertvalue %3, %11[1] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %13 = llvm.insertvalue %9, %12[2] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %14 = llvm.mlir.addressof @t3 : !llvm.ptr + %15 = llvm.mlir.constant(1824 : i64) : i64 + %16 = llvm.mlir.constant(2848 : i64) : i64 + %17 = llvm.call @__memmove_chk(%8, %14, %15, %16) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %17 : !llvm.ptr + } + llvm.func @test_simplify3() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %8 = llvm.mlir.addressof @t1 : !llvm.ptr + %9 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %10 = llvm.insertvalue %3, %9[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %11 = llvm.insertvalue %3, %10[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %12 = llvm.insertvalue %1, %11[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %13 = llvm.mlir.addressof @t2 : !llvm.ptr + %14 = llvm.mlir.constant(1824 : i64) : i64 + %15 = llvm.call @__memmove_chk(%8, %13, %14, %14) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %15 : !llvm.ptr + } + llvm.func @test_no_simplify1() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<2048xi8>) : !llvm.array<2048 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T3", (array<100 x i32>, array<100 x i32>, array<2048 x i8>)> + %8 = llvm.mlir.addressof @t3 : !llvm.ptr + %9 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %10 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %11 = llvm.insertvalue %3, %10[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %12 = llvm.insertvalue %3, %11[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %13 = llvm.insertvalue %9, %12[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %14 = llvm.mlir.addressof @t1 : !llvm.ptr + %15 = llvm.mlir.constant(2848 : i64) : i64 + %16 = llvm.mlir.constant(1824 : i64) : i64 + %17 = llvm.call @__memmove_chk(%8, %14, %15, %16) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %17 : !llvm.ptr + } + llvm.func @test_no_simplify2() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %8 = llvm.mlir.addressof @t1 : !llvm.ptr + %9 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %10 = llvm.insertvalue %3, %9[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %11 = llvm.insertvalue %3, %10[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %12 = llvm.insertvalue %1, %11[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %13 = llvm.mlir.addressof @t2 : !llvm.ptr + %14 = llvm.mlir.constant(1024 : i64) : i64 + %15 = llvm.mlir.constant(0 : i64) : i64 + %16 = llvm.call @__memmove_chk(%8, %13, %14, %15) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %16 : !llvm.ptr + } + llvm.func @test_no_simplify3(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64, %arg3: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1824 : i64) : i64 + %1 = llvm.call @__memmove_chk(%arg0, %arg1, %0, %0) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test_no_incompatible_attr(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %8 = llvm.mlir.addressof @t1 : !llvm.ptr + %9 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %10 = llvm.insertvalue %3, %9[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %11 = llvm.insertvalue %3, %10[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %12 = llvm.insertvalue %1, %11[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %13 = llvm.mlir.addressof @t2 : !llvm.ptr + %14 = llvm.mlir.constant(1824 : i64) : i64 + %15 = llvm.call @__memmove_chk(%8, %13, %14, %14) : (!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr + llvm.return %15 : !llvm.ptr + } + llvm.func @__memmove_chk(!llvm.ptr, !llvm.ptr, i64, i64) -> !llvm.ptr +} diff --git a/test/LLVMDialect/InstCombine/memmove_chk-2.ll.mlir b/test/LLVMDialect/InstCombine/memmove_chk-2.ll.mlir new file mode 100644 index 000000000..aea5ba42c --- /dev/null +++ b/test/LLVMDialect/InstCombine/memmove_chk-2.ll.mlir @@ -0,0 +1,44 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @t1() {addr_space = 0 : i32} : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + llvm.return %7 : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + } + llvm.mlir.global common @t2() {addr_space = 0 : i32} : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + llvm.return %7 : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + } + llvm.func @test_no_simplify() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T1", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %8 = llvm.mlir.addressof @t1 : !llvm.ptr + %9 = llvm.mlir.undef : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %10 = llvm.insertvalue %3, %9[0] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %11 = llvm.insertvalue %3, %10[1] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %12 = llvm.insertvalue %1, %11[2] : !llvm.struct<"struct.T2", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %13 = llvm.mlir.addressof @t2 : !llvm.ptr + %14 = llvm.mlir.constant(1824 : i64) : i64 + %15 = llvm.call @__memmove_chk(%8, %13, %14) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return + } + llvm.func @__memmove_chk(!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr +} diff --git a/test/LLVMDialect/InstCombine/mempcpy.ll.mlir b/test/LLVMDialect/InstCombine/mempcpy.ll.mlir index 6aa6646f7..ea1f85f35 100644 --- a/test/LLVMDialect/InstCombine/mempcpy.ll.mlir +++ b/test/LLVMDialect/InstCombine/mempcpy.ll.mlir @@ -1,45 +1,37 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @mempcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memcpy_nonconst_n", type = !llvm.func (ptr, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @mempcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memcpy_nonconst_n_copy_attrs", type = !llvm.func (ptr, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @mempcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "memcpy_nonconst_n_unused_retval", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @mempcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memcpy_small_const_n", type = !llvm.func (ptr, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1024 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @mempcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memcpy_big_const_n", type = !llvm.func (ptr, ptr)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.undef"() : () -> i32 - %1 = "llvm.mlir.undef"() : () -> i64 - %2 = "llvm.mlir.null"() : () -> !llvm.ptr - %3 = "llvm.mlir.undef"() : () -> !llvm.ptr - %4 = "llvm.call"(%3, %2, %1) {callee = @mempcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "PR48810", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @mempcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "memcpy_no_simplify1", type = !llvm.func (ptr, ptr, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "mempcpy", type = !llvm.func (ptr, ptr, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @memcpy_nonconst_n(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg2: i64) -> !llvm.ptr { + %0 = llvm.call @mempcpy(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @memcpy_nonconst_n_copy_attrs(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg2: i64) -> !llvm.ptr { + %0 = llvm.call @mempcpy(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @memcpy_nonconst_n_unused_retval(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg2: i64) { + %0 = llvm.call @mempcpy(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return + } + llvm.func @memcpy_small_const_n(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> !llvm.ptr { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.call @mempcpy(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @memcpy_big_const_n(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> !llvm.ptr { + %0 = llvm.mlir.constant(1024 : i64) : i64 + %1 = llvm.call @mempcpy(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @PR48810() -> i32 { + %0 = llvm.mlir.undef : !llvm.ptr + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.undef : i64 + %3 = llvm.mlir.undef : i32 + %4 = llvm.call @mempcpy(%0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return %3 : i32 + } + llvm.func @memcpy_no_simplify1(%arg0: !llvm.ptr, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg2: i64) -> !llvm.ptr { + %0 = llvm.call @mempcpy(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @mempcpy(!llvm.ptr, !llvm.ptr {llvm.nocapture, llvm.readonly}, i64) -> !llvm.ptr +} diff --git a/test/LLVMDialect/InstCombine/memrchr-2.ll.mlir b/test/LLVMDialect/InstCombine/memrchr-2.ll.mlir index d61d50d75..b57521a92 100644 --- a/test/LLVMDialect/InstCombine/memrchr-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/memrchr-2.ll.mlir @@ -1,56 +1,39 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "ax", type = !llvm.array<0 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "ax1", type = !llvm.array<1 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a12345", type = !llvm.array<5 x i8>, value = "\01\02\03\04\05"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memrchr", type = !llvm.func (ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4294967296 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_memrchr_a12345_c_ui32max_p1", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4294967297 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @ax1} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_memrchr_ax1_c_ui32max_p2", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4294967297 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_memrchr_ax_c_ui32max_p2", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_memrchr_a12345_c_6", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_memrchr_a12345_c_szmax", type = !llvm.func (i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @ax() {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.mlir.global external @ax1() {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external constant @a12345("\01\02\03\04\05") {addr_space = 0 : i32} + llvm.func @memrchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @call_memrchr_a12345_c_ui32max_p1(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(4294967296 : i64) : i64 + %3 = llvm.call @memrchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @call_memrchr_ax1_c_ui32max_p2(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.addressof @ax1 : !llvm.ptr + %1 = llvm.mlir.constant(4294967297 : i64) : i64 + %2 = llvm.call @memrchr(%0, %arg0, %1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @call_memrchr_ax_c_ui32max_p2(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(4294967297 : i64) : i64 + %2 = llvm.call @memrchr(%0, %arg0, %1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @call_memrchr_a12345_c_6(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(6 : i64) : i64 + %3 = llvm.call @memrchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @call_memrchr_a12345_c_szmax(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(-1 : i64) : i64 + %3 = llvm.call @memrchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memrchr-3.ll.mlir b/test/LLVMDialect/InstCombine/memrchr-3.ll.mlir index 541dbe6e9..cffe9ba7b 100644 --- a/test/LLVMDialect/InstCombine/memrchr-3.ll.mlir +++ b/test/LLVMDialect/InstCombine/memrchr-3.ll.mlir @@ -1,234 +1,200 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "ax", type = !llvm.array<0 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a12345", type = !llvm.array<5 x i8>, value = "\01\02\03\04\05"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a123123", type = !llvm.array<6 x i8>, value = "\01\02\03\01\02\03"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memrchr", type = !llvm.func (ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_ax_c_0", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a12345_3_0", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a12345_1_1", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a12345_5_1", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a123123} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a123123_1_1", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a123123} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a123123_3_1", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_ax_c_1", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a12345_5_5", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a12345_5_4", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a12345_4_5", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a12345p1_1_4", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %3, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%5, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%6) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a12345p1_2_4", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a12345_2_5", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%2, %0, %arg0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%3) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a12345_0_n", type = !llvm.func (i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0, %arg0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a12345_3_n", type = !llvm.func (i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0, %arg0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a12345_5_n", type = !llvm.func (i64)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a123123} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a123123_3_5", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a123123} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a123123_3_6", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a123123} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a123123_2_6", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a123123} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a123123_1_6", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a123123} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a123123_0_6", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @a123123} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%2, %0, %arg0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%3) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a123123_0_n", type = !llvm.func (i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a123123} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0, %arg0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_memrchr_a123123_3_n", type = !llvm.func (i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a123123} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0, %arg0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_memrchr_a123123_2_n", type = !llvm.func (i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a123123} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0, %arg0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_memrchr_a123123_1_n", type = !llvm.func (i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @ax() {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.mlir.global external constant @a12345("\01\02\03\04\05") {addr_space = 0 : i32} + llvm.mlir.global external constant @a123123("\01\02\03\01\02\03") {addr_space = 0 : i32} + llvm.func @memrchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @fold_memrchr_ax_c_0(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.call @memrchr(%0, %arg0, %1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @fold_memrchr_a12345_3_0() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memrchr_a12345_1_1() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memrchr_a12345_5_1() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(5 : i32) : i32 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memrchr_a123123_1_1() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\01\02\03") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @a123123 : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memrchr_a123123_3_1() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\01\02\03") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @a123123 : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memrchr_ax_c_1(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.call @memrchr(%0, %arg0, %1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @fold_memrchr_a12345_5_5() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(5 : i32) : i32 + %3 = llvm.mlir.constant(5 : i64) : i64 + %4 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memrchr_a12345_5_4() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(5 : i32) : i32 + %3 = llvm.mlir.constant(4 : i64) : i64 + %4 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memrchr_a12345_4_5() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.constant(5 : i64) : i64 + %4 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memrchr_a12345p1_1_4() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(4 : i64) : i64 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @memrchr(%5, %3, %4) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @fold_memrchr_a12345p1_2_4() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(4 : i64) : i64 + %6 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %7 = llvm.call @memrchr(%6, %4, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %7 : !llvm.ptr + } + llvm.func @fold_memrchr_a12345_2_5() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(5 : i64) : i64 + %4 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memrchr_a12345_0_n(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @memrchr(%1, %2, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @fold_memrchr_a12345_3_n(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.call @memrchr(%1, %2, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @fold_memrchr_a12345_5_n(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant(5 : i32) : i32 + %3 = llvm.call @memrchr(%1, %2, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @fold_memrchr_a123123_3_5() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\01\02\03") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @a123123 : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(5 : i64) : i64 + %4 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memrchr_a123123_3_6() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\01\02\03") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @a123123 : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(6 : i64) : i64 + %4 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memrchr_a123123_2_6() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\01\02\03") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @a123123 : !llvm.ptr + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(6 : i64) : i64 + %4 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memrchr_a123123_1_6() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\01\02\03") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @a123123 : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(6 : i64) : i64 + %4 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memrchr_a123123_0_6() -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\01\02\03") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @a123123 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(6 : i64) : i64 + %4 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @fold_memrchr_a123123_0_n(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\01\02\03") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @a123123 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @memrchr(%1, %2, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @call_memrchr_a123123_3_n(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\01\02\03") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @a123123 : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.call @memrchr(%1, %2, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @call_memrchr_a123123_2_n(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\01\02\03") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @a123123 : !llvm.ptr + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.call @memrchr(%1, %2, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @call_memrchr_a123123_1_n(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\02\03\01\02\03") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @a123123 : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.call @memrchr(%1, %2, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memrchr-4.ll.mlir b/test/LLVMDialect/InstCombine/memrchr-4.ll.mlir index 6d1684d19..a2145c412 100644 --- a/test/LLVMDialect/InstCombine/memrchr-4.ll.mlir +++ b/test/LLVMDialect/InstCombine/memrchr-4.ll.mlir @@ -1,61 +1,45 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a11111", type = !llvm.array<5 x i8>, value = "\01\01\01\01\01"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a1110111", type = !llvm.array<7 x i8>, value = "\01\01\01\00\01\01\01"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memrchr", type = !llvm.func (ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @a11111} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a11111_c_5", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @a11111} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%2, %arg0, %arg1) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%3) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a11111_c_n", type = !llvm.func (i32, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @a1110111} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a1110111_c_3", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @a1110111} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_memrchr_a1110111_c_4", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @a1110111} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_memrchr_a1110111_c_7", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @a1110111} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%2, %arg0, %arg1) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - "llvm.return"(%3) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_memrchr_a1110111_c_n", type = !llvm.func (i32, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a11111("\01\01\01\01\01") {addr_space = 0 : i32} + llvm.mlir.global external constant @a1110111("\01\01\01\00\01\01\01") {addr_space = 0 : i32} + llvm.func @memrchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @fold_memrchr_a11111_c_5(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\01\01") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a11111 : !llvm.ptr + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.call @memrchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @fold_memrchr_a11111_c_n(%arg0: i32, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\01\01") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a11111 : !llvm.ptr + %2 = llvm.call @memrchr(%1, %arg0, %arg1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @fold_memrchr_a1110111_c_3(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\00\01\01\01") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @a1110111 : !llvm.ptr + %2 = llvm.mlir.constant(3 : i64) : i64 + %3 = llvm.call @memrchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @call_memrchr_a1110111_c_4(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\00\01\01\01") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @a1110111 : !llvm.ptr + %2 = llvm.mlir.constant(4 : i64) : i64 + %3 = llvm.call @memrchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @call_memrchr_a1110111_c_7(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\00\01\01\01") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @a1110111 : !llvm.ptr + %2 = llvm.mlir.constant(7 : i64) : i64 + %3 = llvm.call @memrchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @call_memrchr_a1110111_c_n(%arg0: i32, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\00\01\01\01") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @a1110111 : !llvm.ptr + %2 = llvm.call @memrchr(%1, %arg0, %arg1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memrchr-5.ll.mlir b/test/LLVMDialect/InstCombine/memrchr-5.ll.mlir index 7d062bdc9..4d2f534ac 100644 --- a/test/LLVMDialect/InstCombine/memrchr-5.ll.mlir +++ b/test/LLVMDialect/InstCombine/memrchr-5.ll.mlir @@ -1,165 +1,151 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a", type = !llvm.array<5 x i32>, value = dense<[1633837924, 1701209960, 1768581996, 1835954032, 1633837924]> : tensor<5xi32>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memrchr", type = !llvm.func (ptr, i32, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 113 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 112 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 111 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %7 = "llvm.mlir.constant"() {value = 110 : i32} : () -> i32 - %8 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %9 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %10 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %11 = "llvm.mlir.constant"() {value = 99 : i32} : () -> i32 - %12 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %13 = "llvm.mlir.constant"() {value = 98 : i32} : () -> i32 - %14 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %15 = "llvm.mlir.constant"() {value = 97 : i32} : () -> i32 - %16 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %17 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %18 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %19 = "llvm.getelementptr"(%18, %17, %17) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %20 = "llvm.bitcast"(%19) : (!llvm.ptr) -> !llvm.ptr - %21 = "llvm.ptrtoint"(%16) : (!llvm.ptr>) -> i64 - %22 = "llvm.call"(%20, %15, %14) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %23 = "llvm.ptrtoint"(%22) : (!llvm.ptr) -> i64 - %24 = "llvm.sub"(%23, %21) : (i64, i64) -> i64 - %25 = "llvm.getelementptr"(%arg0, %17) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%24, %25) : (i64, !llvm.ptr) -> () - %26 = "llvm.call"(%20, %13, %14) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %27 = "llvm.ptrtoint"(%26) : (!llvm.ptr) -> i64 - %28 = "llvm.sub"(%27, %21) : (i64, i64) -> i64 - %29 = "llvm.getelementptr"(%arg0, %12) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%28, %29) : (i64, !llvm.ptr) -> () - %30 = "llvm.call"(%20, %11, %14) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %31 = "llvm.ptrtoint"(%30) : (!llvm.ptr) -> i64 - %32 = "llvm.sub"(%31, %21) : (i64, i64) -> i64 - %33 = "llvm.getelementptr"(%arg0, %10) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%32, %33) : (i64, !llvm.ptr) -> () - %34 = "llvm.call"(%20, %9, %14) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %35 = "llvm.ptrtoint"(%34) : (!llvm.ptr) -> i64 - %36 = "llvm.sub"(%35, %21) : (i64, i64) -> i64 - %37 = "llvm.getelementptr"(%arg0, %8) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%36, %37) : (i64, !llvm.ptr) -> () - %38 = "llvm.call"(%20, %7, %14) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %39 = "llvm.ptrtoint"(%38) : (!llvm.ptr) -> i64 - %40 = "llvm.sub"(%39, %21) : (i64, i64) -> i64 - %41 = "llvm.getelementptr"(%arg0, %6) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%40, %41) : (i64, !llvm.ptr) -> () - %42 = "llvm.call"(%20, %5, %14) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %43 = "llvm.ptrtoint"(%42) : (!llvm.ptr) -> i64 - %44 = "llvm.sub"(%43, %21) : (i64, i64) -> i64 - %45 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%44, %45) : (i64, !llvm.ptr) -> () - %46 = "llvm.call"(%20, %3, %14) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %47 = "llvm.ptrtoint"(%46) : (!llvm.ptr) -> i64 - %48 = "llvm.sub"(%47, %21) : (i64, i64) -> i64 - %49 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%48, %49) : (i64, !llvm.ptr) -> () - %50 = "llvm.call"(%20, %1, %14) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %51 = "llvm.ptrtoint"(%50) : (!llvm.ptr) -> i64 - %52 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%51, %52) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a_16", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 97 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 104 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %7 = "llvm.mlir.constant"() {value = 103 : i32} : () -> i32 - %8 = "llvm.mlir.constant"() {value = 102 : i32} : () -> i32 - %9 = "llvm.mlir.constant"() {value = 12 : i64} : () -> i64 - %10 = "llvm.mlir.constant"() {value = 101 : i32} : () -> i32 - %11 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %12 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %13 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %14 = "llvm.getelementptr"(%13, %12, %11) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %15 = "llvm.bitcast"(%14) : (!llvm.ptr) -> !llvm.ptr - %16 = "llvm.ptrtoint"(%15) : (!llvm.ptr) -> i64 - %17 = "llvm.call"(%15, %10, %9) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %18 = "llvm.ptrtoint"(%17) : (!llvm.ptr) -> i64 - %19 = "llvm.sub"(%18, %16) : (i64, i64) -> i64 - %20 = "llvm.getelementptr"(%arg0, %12) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%19, %20) : (i64, !llvm.ptr) -> () - %21 = "llvm.call"(%15, %8, %9) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %22 = "llvm.ptrtoint"(%21) : (!llvm.ptr) -> i64 - %23 = "llvm.sub"(%22, %16) : (i64, i64) -> i64 - %24 = "llvm.getelementptr"(%arg0, %11) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%23, %24) : (i64, !llvm.ptr) -> () - %25 = "llvm.call"(%15, %7, %9) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %26 = "llvm.ptrtoint"(%25) : (!llvm.ptr) -> i64 - %27 = "llvm.sub"(%26, %16) : (i64, i64) -> i64 - %28 = "llvm.getelementptr"(%arg0, %6) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%27, %28) : (i64, !llvm.ptr) -> () - %29 = "llvm.call"(%15, %5, %9) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %30 = "llvm.ptrtoint"(%29) : (!llvm.ptr) -> i64 - %31 = "llvm.sub"(%30, %16) : (i64, i64) -> i64 - %32 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%31, %32) : (i64, !llvm.ptr) -> () - %33 = "llvm.call"(%15, %3, %9) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %34 = "llvm.ptrtoint"(%33) : (!llvm.ptr) -> i64 - %35 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%34, %35) : (i64, !llvm.ptr) -> () - %36 = "llvm.call"(%15, %1, %9) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %37 = "llvm.ptrtoint"(%36) : (!llvm.ptr) -> i64 - %38 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%37, %38) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a_p1_16", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 101 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 100 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 99 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %7 = "llvm.mlir.constant"() {value = 98 : i32} : () -> i32 - %8 = "llvm.mlir.constant"() {value = 20 : i64} : () -> i64 - %9 = "llvm.mlir.constant"() {value = 97 : i32} : () -> i32 - %10 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %11 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %12 = "llvm.getelementptr"(%11, %10, %10) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %13 = "llvm.bitcast"(%12) : (!llvm.ptr) -> !llvm.ptr - %14 = "llvm.ptrtoint"(%13) : (!llvm.ptr) -> i64 - %15 = "llvm.call"(%13, %9, %8) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %16 = "llvm.ptrtoint"(%15) : (!llvm.ptr) -> i64 - %17 = "llvm.sub"(%16, %14) : (i64, i64) -> i64 - %18 = "llvm.getelementptr"(%arg0, %10) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%17, %18) : (i64, !llvm.ptr) -> () - %19 = "llvm.call"(%13, %7, %8) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %20 = "llvm.ptrtoint"(%19) : (!llvm.ptr) -> i64 - %21 = "llvm.sub"(%20, %14) : (i64, i64) -> i64 - %22 = "llvm.getelementptr"(%arg0, %6) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%21, %22) : (i64, !llvm.ptr) -> () - %23 = "llvm.call"(%13, %5, %8) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %24 = "llvm.ptrtoint"(%23) : (!llvm.ptr) -> i64 - %25 = "llvm.sub"(%24, %14) : (i64, i64) -> i64 - %26 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%25, %26) : (i64, !llvm.ptr) -> () - %27 = "llvm.call"(%13, %3, %8) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %28 = "llvm.ptrtoint"(%27) : (!llvm.ptr) -> i64 - %29 = "llvm.sub"(%28, %14) : (i64, i64) -> i64 - %30 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%29, %30) : (i64, !llvm.ptr) -> () - %31 = "llvm.call"(%13, %1, %8) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i64) -> !llvm.ptr - %32 = "llvm.ptrtoint"(%31) : (!llvm.ptr) -> i64 - %33 = "llvm.sub"(%32, %14) : (i64, i64) -> i64 - %34 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%33, %34) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_memrchr_a_20", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a(dense<[1633837924, 1701209960, 1768581996, 1835954032, 1633837924]> : tensor<5xi32>) {addr_space = 0 : i32} : !llvm.array<5 x i32> + llvm.func @memrchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @fold_memrchr_a_16(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<[1633837924, 1701209960, 1768581996, 1835954032, 1633837924]> : tensor<5xi32>) : !llvm.array<5 x i32> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(97 : i32) : i32 + %3 = llvm.mlir.constant(16 : i64) : i64 + %4 = llvm.mlir.constant(98 : i32) : i32 + %5 = llvm.mlir.constant(1 : i64) : i64 + %6 = llvm.mlir.constant(99 : i32) : i32 + %7 = llvm.mlir.constant(2 : i64) : i64 + %8 = llvm.mlir.constant(100 : i32) : i32 + %9 = llvm.mlir.constant(3 : i64) : i64 + %10 = llvm.mlir.constant(110 : i32) : i32 + %11 = llvm.mlir.constant(4 : i64) : i64 + %12 = llvm.mlir.constant(111 : i32) : i32 + %13 = llvm.mlir.constant(6 : i64) : i64 + %14 = llvm.mlir.constant(112 : i32) : i32 + %15 = llvm.mlir.constant(7 : i64) : i64 + %16 = llvm.mlir.constant(113 : i32) : i32 + %17 = llvm.mlir.constant(8 : i64) : i64 + %18 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %19 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %20 = llvm.ptrtoint %19 : !llvm.ptr to i64 + %21 = llvm.sub %20, %18 : i64 + llvm.store %21, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %22 = llvm.call @memrchr(%1, %4, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %23 = llvm.ptrtoint %22 : !llvm.ptr to i64 + %24 = llvm.sub %23, %18 : i64 + %25 = llvm.getelementptr %arg0[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %24, %25 {alignment = 4 : i64} : i64, !llvm.ptr + %26 = llvm.call @memrchr(%1, %6, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %27 = llvm.ptrtoint %26 : !llvm.ptr to i64 + %28 = llvm.sub %27, %18 : i64 + %29 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %28, %29 {alignment = 4 : i64} : i64, !llvm.ptr + %30 = llvm.call @memrchr(%1, %8, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %31 = llvm.ptrtoint %30 : !llvm.ptr to i64 + %32 = llvm.sub %31, %18 : i64 + %33 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %32, %33 {alignment = 4 : i64} : i64, !llvm.ptr + %34 = llvm.call @memrchr(%1, %10, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %35 = llvm.ptrtoint %34 : !llvm.ptr to i64 + %36 = llvm.sub %35, %18 : i64 + %37 = llvm.getelementptr %arg0[%11] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %36, %37 {alignment = 4 : i64} : i64, !llvm.ptr + %38 = llvm.call @memrchr(%1, %12, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %39 = llvm.ptrtoint %38 : !llvm.ptr to i64 + %40 = llvm.sub %39, %18 : i64 + %41 = llvm.getelementptr %arg0[%13] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %40, %41 {alignment = 4 : i64} : i64, !llvm.ptr + %42 = llvm.call @memrchr(%1, %14, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %43 = llvm.ptrtoint %42 : !llvm.ptr to i64 + %44 = llvm.sub %43, %18 : i64 + %45 = llvm.getelementptr %arg0[%15] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %44, %45 {alignment = 4 : i64} : i64, !llvm.ptr + %46 = llvm.call @memrchr(%1, %16, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %47 = llvm.ptrtoint %46 : !llvm.ptr to i64 + %48 = llvm.getelementptr %arg0[%17] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %47, %48 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_memrchr_a_p1_16(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<[1633837924, 1701209960, 1768581996, 1835954032, 1633837924]> : tensor<5xi32>) : !llvm.array<5 x i32> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(101 : i32) : i32 + %5 = llvm.mlir.constant(12 : i64) : i64 + %6 = llvm.mlir.constant(102 : i32) : i32 + %7 = llvm.mlir.constant(103 : i32) : i32 + %8 = llvm.mlir.constant(2 : i64) : i64 + %9 = llvm.mlir.constant(104 : i32) : i32 + %10 = llvm.mlir.constant(3 : i64) : i64 + %11 = llvm.mlir.constant(97 : i32) : i32 + %12 = llvm.mlir.constant(4 : i64) : i64 + %13 = llvm.mlir.constant(100 : i32) : i32 + %14 = llvm.mlir.constant(5 : i64) : i64 + %15 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<5 x i32> + %16 = llvm.ptrtoint %15 : !llvm.ptr to i64 + %17 = llvm.call @memrchr(%15, %4, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %18 = llvm.ptrtoint %17 : !llvm.ptr to i64 + %19 = llvm.sub %18, %16 : i64 + llvm.store %19, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %20 = llvm.call @memrchr(%15, %6, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %21 = llvm.ptrtoint %20 : !llvm.ptr to i64 + %22 = llvm.sub %21, %16 : i64 + %23 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %22, %23 {alignment = 4 : i64} : i64, !llvm.ptr + %24 = llvm.call @memrchr(%15, %7, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %25 = llvm.ptrtoint %24 : !llvm.ptr to i64 + %26 = llvm.sub %25, %16 : i64 + %27 = llvm.getelementptr %arg0[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %26, %27 {alignment = 4 : i64} : i64, !llvm.ptr + %28 = llvm.call @memrchr(%15, %9, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %29 = llvm.ptrtoint %28 : !llvm.ptr to i64 + %30 = llvm.sub %29, %16 : i64 + %31 = llvm.getelementptr %arg0[%10] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %30, %31 {alignment = 4 : i64} : i64, !llvm.ptr + %32 = llvm.call @memrchr(%15, %11, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %33 = llvm.ptrtoint %32 : !llvm.ptr to i64 + %34 = llvm.getelementptr %arg0[%12] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %33, %34 {alignment = 4 : i64} : i64, !llvm.ptr + %35 = llvm.call @memrchr(%15, %13, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %36 = llvm.ptrtoint %35 : !llvm.ptr to i64 + %37 = llvm.getelementptr %arg0[%14] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %36, %37 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_memrchr_a_20(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<[1633837924, 1701209960, 1768581996, 1835954032, 1633837924]> : tensor<5xi32>) : !llvm.array<5 x i32> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(97 : i32) : i32 + %3 = llvm.mlir.constant(20 : i64) : i64 + %4 = llvm.mlir.constant(98 : i32) : i32 + %5 = llvm.mlir.constant(1 : i64) : i64 + %6 = llvm.mlir.constant(99 : i32) : i32 + %7 = llvm.mlir.constant(2 : i64) : i64 + %8 = llvm.mlir.constant(100 : i32) : i32 + %9 = llvm.mlir.constant(3 : i64) : i64 + %10 = llvm.mlir.constant(101 : i32) : i32 + %11 = llvm.mlir.constant(4 : i64) : i64 + %12 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %13 = llvm.call @memrchr(%1, %2, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %14 = llvm.ptrtoint %13 : !llvm.ptr to i64 + %15 = llvm.sub %14, %12 : i64 + llvm.store %15, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %16 = llvm.call @memrchr(%1, %4, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %17 = llvm.ptrtoint %16 : !llvm.ptr to i64 + %18 = llvm.sub %17, %12 : i64 + %19 = llvm.getelementptr %arg0[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %18, %19 {alignment = 4 : i64} : i64, !llvm.ptr + %20 = llvm.call @memrchr(%1, %6, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %21 = llvm.ptrtoint %20 : !llvm.ptr to i64 + %22 = llvm.sub %21, %12 : i64 + %23 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %22, %23 {alignment = 4 : i64} : i64, !llvm.ptr + %24 = llvm.call @memrchr(%1, %8, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %25 = llvm.ptrtoint %24 : !llvm.ptr to i64 + %26 = llvm.sub %25, %12 : i64 + %27 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %26, %27 {alignment = 4 : i64} : i64, !llvm.ptr + %28 = llvm.call @memrchr(%1, %10, %3) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %29 = llvm.ptrtoint %28 : !llvm.ptr to i64 + %30 = llvm.sub %29, %12 : i64 + %31 = llvm.getelementptr %arg0[%11] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %30, %31 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/memrchr-7.ll.mlir b/test/LLVMDialect/InstCombine/memrchr-7.ll.mlir new file mode 100644 index 000000000..c3fc208e8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/memrchr-7.ll.mlir @@ -0,0 +1,62 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a5("12345") {addr_space = 0 : i32} + llvm.func @memrchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @call_memrchr_ap5_c_1_eq_a(%arg0: i32, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.mlir.constant(1 : i64) : i64 + %6 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %7 = llvm.getelementptr %1[%4, %2] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %8 = llvm.call @memrchr(%6, %arg0, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %9 = llvm.icmp "eq" %8, %7 : !llvm.ptr + llvm.return %9 : i1 + } + llvm.func @call_memrchr_ap5_c_5_eq_a(%arg0: i32, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.mlir.constant(5 : i64) : i64 + %6 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %7 = llvm.getelementptr %1[%4, %2] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %8 = llvm.call @memrchr(%6, %arg0, %5) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %9 = llvm.icmp "eq" %8, %7 : !llvm.ptr + llvm.return %9 : i1 + } + llvm.func @fold_memrchr_ap5_c_n_eq_a(%arg0: i32, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.call @memrchr(%4, %arg0, %arg1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %6 = llvm.icmp "eq" %5, %1 : !llvm.ptr + llvm.return %6 : i1 + } + llvm.func @fold_memrchr_ap5_c_n_eqz(%arg0: i32, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.zero : !llvm.ptr + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @memrchr(%5, %arg0, %arg1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %7 = llvm.icmp "eq" %6, %4 : !llvm.ptr + llvm.return %7 : i1 + } + llvm.func @fold_memrchr_a_nul_n_eqz(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.zero : !llvm.ptr + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @memrchr(%5, %2, %arg0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %7 = llvm.icmp "eq" %6, %4 : !llvm.ptr + llvm.return %7 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/memrchr-8.ll.mlir b/test/LLVMDialect/InstCombine/memrchr-8.ll.mlir new file mode 100644 index 000000000..7b7da61a3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/memrchr-8.ll.mlir @@ -0,0 +1,36 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a5("12345") {addr_space = 0 : i32} + llvm.func @memrchr(!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.func @call_memrchr_a_c_9_eq_a(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(9 : i64) : i64 + %3 = llvm.call @memrchr(%1, %arg0, %2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %4 = llvm.icmp "eq" %3, %1 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @call_memrchr_a_c_n_eq_a(%arg0: i32, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.call @memrchr(%1, %arg0, %arg1) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %3 = llvm.icmp "eq" %2, %1 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @call_memrchr_s_c_17_eq_s(%arg0: !llvm.ptr, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(17 : i64) : i64 + %1 = llvm.call @memrchr(%arg0, %arg1, %0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %2 = llvm.icmp "eq" %1, %arg0 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @call_memrchr_s_c_9_neq_s(%arg0: !llvm.ptr, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.call @memrchr(%arg0, %arg1, %0) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %2 = llvm.icmp "ne" %1, %arg0 : !llvm.ptr + llvm.return %2 : i1 + } + llvm.func @fold_memrchr_s_c_n_eq_s(%arg0: !llvm.ptr, %arg1: i32, %arg2: i64) -> i1 { + %0 = llvm.call @memrchr(%arg0, %arg1, %arg2) : (!llvm.ptr, i32, i64) -> !llvm.ptr + %1 = llvm.icmp "eq" %0, %arg0 : !llvm.ptr + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/memrchr.ll.mlir b/test/LLVMDialect/InstCombine/memrchr.ll.mlir index 8f9f73134..5dc89ceab 100644 --- a/test/LLVMDialect/InstCombine/memrchr.ll.mlir +++ b/test/LLVMDialect/InstCombine/memrchr.ll.mlir @@ -1,33 +1,26 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memrchr", type = !llvm.func (ptr, i32, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i32) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func (ptr, i32, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i32) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func (ptr, i32, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i32) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func (ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i32) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func (ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @memrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i32) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func (ptr, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @memrchr(!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.func @test1(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memrchr(%arg0, %arg1, %arg2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test2(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memrchr(%arg0, %arg1, %arg2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test3(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.call @memrchr(%arg0, %arg1, %0) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test4(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.call @memrchr(%arg0, %arg1, %0) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test5(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @memrchr(%arg0, %arg1, %0) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memset-1.ll.mlir b/test/LLVMDialect/InstCombine/memset-1.ll.mlir new file mode 100644 index 000000000..68983e48a --- /dev/null +++ b/test/LLVMDialect/InstCombine/memset-1.ll.mlir @@ -0,0 +1,117 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @memset(!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.func @malloc(i32) -> (!llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind"]} + llvm.func @test_simplify1(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memset(%arg0, %arg1, %arg2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test_simplify1_tail(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memset(%arg0, %arg1, %arg2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test_simplify1_musttail(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memset(%arg0, %arg1, %arg2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @pr25892_lite(%arg0: i32) -> !llvm.ptr attributes {passthrough = ["nounwind", "ssp", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @malloc(%arg0) : (i32) -> !llvm.ptr + %2 = llvm.call @memset(%1, %0, %arg0) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @malloc_and_memset_intrinsic(%arg0: i32) -> !llvm.ptr attributes {passthrough = ["nounwind", "ssp", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.call @malloc(%arg0) : (i32) -> !llvm.ptr + "llvm.intr.memset"(%1, %0, %arg0) <{isVolatile = false}> : (!llvm.ptr, i8, i32) -> () + llvm.return %1 : !llvm.ptr + } + llvm.func @notmalloc_memset(%arg0: i32, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call %arg1(%arg0) : !llvm.ptr, (i32) -> !llvm.ptr + %2 = llvm.call @memset(%1, %0, %arg0) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @pr25892(%arg0: i32) -> !llvm.ptr attributes {passthrough = ["nounwind", "ssp", ["uwtable", "2"]]} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.call @malloc(%arg0) : (i32) -> !llvm.ptr + %3 = llvm.icmp "eq" %2, %0 : !llvm.ptr + llvm.cond_br %3, ^bb2(%0 : !llvm.ptr), ^bb1 + ^bb1: // pred: ^bb0 + %4 = llvm.call @memset(%2, %1, %arg0) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.br ^bb2(%2 : !llvm.ptr) + ^bb2(%5: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + llvm.return %5 : !llvm.ptr + } + llvm.func @buffer_is_modified_then_memset(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.call @malloc(%arg0) : (i32) -> !llvm.ptr + llvm.store %0, %2 {alignment = 1 : i64} : i8, !llvm.ptr + %3 = llvm.call @memset(%2, %1, %arg0) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @memset_size_select(%arg0: i1, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(50 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.call @memset(%arg1, %2, %3) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memset_size_select2(%arg0: i1, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(50 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.call @memset(%arg1, %2, %3) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memset_size_select3(%arg0: i1, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(50 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.call @memset(%arg1, %2, %3) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memset_size_select4(%arg0: i1, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(50 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.call @memset(%arg1, %2, %3) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @memset_size_ashr(%arg0: i1, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.ashr %0, %arg2 : i32 + %3 = llvm.call @memset(%arg1, %1, %2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @memset_attrs1(%arg0: i1, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @memset(%arg1, %0, %arg2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @memset_attrs2(%arg0: i1, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @memset(%arg1, %0, %arg2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @memset_attrs3(%arg0: i1, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @memset(%arg1, %0, %arg2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @memset_attrs4(%arg0: i1, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @memset(%arg1, %0, %arg2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test_no_incompatible_attr(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @memset(%arg0, %arg1, %arg2) : (!llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/memset-2.ll.mlir b/test/LLVMDialect/InstCombine/memset-2.ll.mlir index d4bf111fb..1bcd555a8 100644 --- a/test/LLVMDialect/InstCombine/memset-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/memset-2.ll.mlir @@ -1,10 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "memset", type = !llvm.func, i32, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @memset, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i32) -> i8 - "llvm.return"(%0) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func, i32, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @memset(!llvm.ptr, i32, i32) -> i8 + llvm.func @test_no_simplify1(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32) -> i8 { + %0 = llvm.call @memset(%arg0, %arg1, %arg2) : (!llvm.ptr, i32, i32) -> i8 + llvm.return %0 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/memset.ll.mlir b/test/LLVMDialect/InstCombine/memset.ll.mlir index ccb3058c1..444719477 100644 --- a/test/LLVMDialect/InstCombine/memset.ll.mlir +++ b/test/LLVMDialect/InstCombine/memset.ll.mlir @@ -1,65 +1,48 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "Unknown", type = i128} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = false} : () -> i1 - %5 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %6 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %7 = "llvm.getelementptr"(%arg0, %6, %6) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - "llvm.call"(%7, %5, %6, %4) {callee = @llvm.memset.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i1) -> () - "llvm.call"(%7, %5, %3, %4) {callee = @llvm.memset.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i1) -> () - "llvm.call"(%7, %5, %2, %4) {callee = @llvm.memset.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i1) -> () - "llvm.call"(%7, %5, %1, %4) {callee = @llvm.memset.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i1) -> () - "llvm.call"(%7, %5, %0, %4) {callee = @llvm.memset.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i1) -> () - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %3 = "llvm.mlir.addressof"() {global_name = @Unknown} : () -> !llvm.ptr - %4 = "llvm.bitcast"(%3) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%4, %2, %1, %0) {callee = @llvm.memset.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "memset_to_constant", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.undef"() : () -> i8 - "llvm.call"(%arg0, %2, %1, %0) {callee = @llvm.memset.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "memset_undef", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.undef"() : () -> i8 - "llvm.call"(%arg0, %2, %1, %0) {callee = @llvm.memset.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "memset_undef_volatile", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.undef"() : () -> i8 - "llvm.call"(%arg0, %2, %1, %0) {callee = @llvm.memset.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "memset_poison", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.undef"() : () -> i8 - "llvm.call"(%arg0, %2, %1, %0) {callee = @llvm.memset.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i32, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "memset_poison_volatile", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memset.p0i8.i32", type = !llvm.func, i8, i32, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @Unknown() {addr_space = 0 : i32} : i128 + llvm.func @test(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(4 : i32) : i32 + %5 = llvm.mlir.constant(8 : i32) : i32 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i32) -> () + "llvm.intr.memset"(%arg0, %0, %2) <{isVolatile = false}> : (!llvm.ptr, i8, i32) -> () + "llvm.intr.memset"(%arg0, %0, %3) <{isVolatile = false}> : (!llvm.ptr, i8, i32) -> () + "llvm.intr.memset"(%arg0, %0, %4) <{isVolatile = false}> : (!llvm.ptr, i8, i32) -> () + "llvm.intr.memset"(%arg0, %0, %5) <{isVolatile = false}> : (!llvm.ptr, i8, i32) -> () + llvm.return %1 : i32 + } + llvm.func @memset_to_constant() { + %0 = llvm.mlir.addressof @Unknown : !llvm.ptr + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(16 : i32) : i32 + "llvm.intr.memset"(%0, %1, %2) <{isVolatile = false}> : (!llvm.ptr, i8, i32) -> () + llvm.return + } + llvm.func @memset_undef(%arg0: !llvm.ptr) { + %0 = llvm.mlir.undef : i8 + %1 = llvm.mlir.constant(8 : i32) : i32 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i32) -> () + llvm.return + } + llvm.func @memset_undef_volatile(%arg0: !llvm.ptr) { + %0 = llvm.mlir.undef : i8 + %1 = llvm.mlir.constant(8 : i32) : i32 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = true}> : (!llvm.ptr, i8, i32) -> () + llvm.return + } + llvm.func @memset_poison(%arg0: !llvm.ptr) { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(8 : i32) : i32 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = false}> : (!llvm.ptr, i8, i32) -> () + llvm.return + } + llvm.func @memset_poison_volatile(%arg0: !llvm.ptr) { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(8 : i32) : i32 + "llvm.intr.memset"(%arg0, %0, %1) <{isVolatile = true}> : (!llvm.ptr, i8, i32) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/memset2.ll.mlir b/test/LLVMDialect/InstCombine/memset2.ll.mlir index 696c35d28..6bd905c92 100644 --- a/test/LLVMDialect/InstCombine/memset2.ll.mlir +++ b/test/LLVMDialect/InstCombine/memset2.ll.mlir @@ -1,17 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, i8, i8, i8, array<5 x i8>)>, 1>): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %3 = "llvm.mlir.constant"() {value = 9 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %6 = "llvm.getelementptr"(%arg0, %5, %4, %3) : (!llvm.ptr, i8, i8, i8, array<5 x i8>)>, 1>, i32, i32, i32) -> !llvm.ptr - "llvm.call"(%6, %2, %1, %0) {callee = @llvm.memset.p1i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8, i64, i1) -> () - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func, i8, i8, i8, array<5 x i8>)>, 1>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memset.p1i8.i64", type = !llvm.func, i8, i64, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: !llvm.ptr<1> {llvm.nocapture}) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.mlir.constant(8 : i64) : i64 + %5 = llvm.getelementptr inbounds %arg0[%0, 0, %2] : (!llvm.ptr<1>, i32, i32) -> !llvm.ptr<1>, !llvm.struct<"struct.Moves", (array<9 x i8>, i8, i8, i8, array<5 x i8>)> + "llvm.intr.memset"(%5, %3, %4) <{isVolatile = false}> : (!llvm.ptr<1>, i8, i64) -> () + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/memset_chk-1.ll.mlir b/test/LLVMDialect/InstCombine/memset_chk-1.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/memset_chk-2.ll.mlir b/test/LLVMDialect/InstCombine/memset_chk-2.ll.mlir new file mode 100644 index 000000000..1ae7e2dda --- /dev/null +++ b/test/LLVMDialect/InstCombine/memset_chk-2.ll.mlir @@ -0,0 +1,28 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @t() {addr_space = 0 : i32} : !llvm.struct<"struct.T", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + llvm.return %7 : !llvm.struct<"struct.T", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + } + llvm.func @test_no_simplify() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : tensor<100xi32>) : !llvm.array<100 x i32> + %4 = llvm.mlir.undef : !llvm.struct<"struct.T", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.T", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %6 = llvm.insertvalue %3, %5[1] : !llvm.struct<"struct.T", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %7 = llvm.insertvalue %1, %6[2] : !llvm.struct<"struct.T", (array<100 x i32>, array<100 x i32>, array<1024 x i8>)> + %8 = llvm.mlir.addressof @t : !llvm.ptr + %9 = llvm.mlir.constant(1824 : i64) : i64 + %10 = llvm.call @__memset_chk(%8, %2, %9) : (!llvm.ptr, i32, i64) -> !llvm.ptr + llvm.return + } + llvm.func @__memset_chk(!llvm.ptr, i32, i64) -> !llvm.ptr +} diff --git a/test/LLVMDialect/InstCombine/merge-icmp.ll.mlir b/test/LLVMDialect/InstCombine/merge-icmp.ll.mlir new file mode 100644 index 000000000..19f922b34 --- /dev/null +++ b/test/LLVMDialect/InstCombine/merge-icmp.ll.mlir @@ -0,0 +1,248 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use.i1(i1) + llvm.func @use.i8(i8) + llvm.func @use.i16(i16) + llvm.func @and_test1(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-256 : i16) : i16 + %2 = llvm.mlir.constant(17664 : i16) : i16 + %3 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i16 + %4 = llvm.trunc %3 : i16 to i8 + %5 = llvm.icmp "eq" %4, %0 : i8 + %6 = llvm.and %3, %1 : i16 + %7 = llvm.icmp "eq" %6, %2 : i16 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @and_test1_logical(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-256 : i16) : i16 + %2 = llvm.mlir.constant(17664 : i16) : i16 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i16 + %5 = llvm.trunc %4 : i16 to i8 + %6 = llvm.icmp "eq" %5, %0 : i8 + %7 = llvm.and %4, %1 : i16 + %8 = llvm.icmp "eq" %7, %2 : i16 + %9 = llvm.select %6, %8, %3 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @and_test1_vector(%arg0: !llvm.ptr) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-256> : vector<2xi16>) : vector<2xi16> + %2 = llvm.mlir.constant(dense<17664> : vector<2xi16>) : vector<2xi16> + %3 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> vector<2xi16> + %4 = llvm.trunc %3 : vector<2xi16> to vector<2xi8> + %5 = llvm.icmp "eq" %4, %0 : vector<2xi8> + %6 = llvm.and %3, %1 : vector<2xi16> + %7 = llvm.icmp "eq" %6, %2 : vector<2xi16> + %8 = llvm.and %5, %7 : vector<2xi1> + llvm.return %8 : vector<2xi1> + } + llvm.func @and_test2(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-256 : i16) : i16 + %1 = llvm.mlir.constant(32512 : i16) : i16 + %2 = llvm.mlir.constant(69 : i8) : i8 + %3 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i16 + %4 = llvm.and %3, %0 : i16 + %5 = llvm.icmp "eq" %4, %1 : i16 + %6 = llvm.trunc %3 : i16 to i8 + %7 = llvm.icmp "eq" %6, %2 : i8 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @and_test2_logical(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-256 : i16) : i16 + %1 = llvm.mlir.constant(32512 : i16) : i16 + %2 = llvm.mlir.constant(69 : i8) : i8 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i16 + %5 = llvm.and %4, %0 : i16 + %6 = llvm.icmp "eq" %5, %1 : i16 + %7 = llvm.trunc %4 : i16 to i8 + %8 = llvm.icmp "eq" %7, %2 : i8 + %9 = llvm.select %6, %8, %3 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @and_test2_vector(%arg0: !llvm.ptr) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-256> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<32512> : vector<2xi16>) : vector<2xi16> + %2 = llvm.mlir.constant(dense<69> : vector<2xi8>) : vector<2xi8> + %3 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> vector<2xi16> + %4 = llvm.and %3, %0 : vector<2xi16> + %5 = llvm.icmp "eq" %4, %1 : vector<2xi16> + %6 = llvm.trunc %3 : vector<2xi16> to vector<2xi8> + %7 = llvm.icmp "eq" %6, %2 : vector<2xi8> + %8 = llvm.and %5, %7 : vector<2xi1> + llvm.return %8 : vector<2xi1> + } + llvm.func @or_basic(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-256 : i16) : i16 + %2 = llvm.mlir.constant(17664 : i16) : i16 + %3 = llvm.trunc %arg0 : i16 to i8 + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.and %arg0, %1 : i16 + %6 = llvm.icmp "ne" %5, %2 : i16 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_basic_commuted(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(-256 : i16) : i16 + %1 = llvm.mlir.constant(32512 : i16) : i16 + %2 = llvm.mlir.constant(69 : i8) : i8 + %3 = llvm.and %arg0, %0 : i16 + %4 = llvm.icmp "ne" %3, %1 : i16 + %5 = llvm.trunc %arg0 : i16 to i8 + %6 = llvm.icmp "ne" %5, %2 : i8 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_vector(%arg0: vector<2xi16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-256> : vector<2xi16>) : vector<2xi16> + %2 = llvm.mlir.constant(dense<17664> : vector<2xi16>) : vector<2xi16> + %3 = llvm.trunc %arg0 : vector<2xi16> to vector<2xi8> + %4 = llvm.icmp "ne" %3, %0 : vector<2xi8> + %5 = llvm.and %arg0, %1 : vector<2xi16> + %6 = llvm.icmp "ne" %5, %2 : vector<2xi16> + %7 = llvm.or %4, %6 : vector<2xi1> + llvm.return %7 : vector<2xi1> + } + llvm.func @or_nontrivial_mask1(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(3840 : i16) : i16 + %2 = llvm.mlir.constant(1280 : i16) : i16 + %3 = llvm.trunc %arg0 : i16 to i8 + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.and %arg0, %1 : i16 + %6 = llvm.icmp "ne" %5, %2 : i16 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_nontrivial_mask2(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-4096 : i16) : i16 + %2 = llvm.mlir.constant(20480 : i16) : i16 + %3 = llvm.trunc %arg0 : i16 to i8 + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.and %arg0, %1 : i16 + %6 = llvm.icmp "ne" %5, %2 : i16 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_extra_use1(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-4096 : i16) : i16 + %2 = llvm.mlir.constant(20480 : i16) : i16 + %3 = llvm.trunc %arg0 : i16 to i8 + %4 = llvm.icmp "ne" %3, %0 : i8 + llvm.call @use.i1(%4) : (i1) -> () + %5 = llvm.and %arg0, %1 : i16 + %6 = llvm.icmp "ne" %5, %2 : i16 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_extra_use2(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-4096 : i16) : i16 + %2 = llvm.mlir.constant(20480 : i16) : i16 + %3 = llvm.trunc %arg0 : i16 to i8 + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.and %arg0, %1 : i16 + %6 = llvm.icmp "ne" %5, %2 : i16 + llvm.call @use.i1(%6) : (i1) -> () + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_extra_use3(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-4096 : i16) : i16 + %2 = llvm.mlir.constant(20480 : i16) : i16 + %3 = llvm.trunc %arg0 : i16 to i8 + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.and %arg0, %1 : i16 + %6 = llvm.icmp "ne" %5, %2 : i16 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_extra_use4(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-4096 : i16) : i16 + %2 = llvm.mlir.constant(20480 : i16) : i16 + %3 = llvm.trunc %arg0 : i16 to i8 + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.and %arg0, %1 : i16 + llvm.call @use.i16(%5) : (i16) -> () + %6 = llvm.icmp "ne" %5, %2 : i16 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_wrong_pred1(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-256 : i16) : i16 + %2 = llvm.mlir.constant(17664 : i16) : i16 + %3 = llvm.trunc %arg0 : i16 to i8 + %4 = llvm.icmp "eq" %3, %0 : i8 + %5 = llvm.and %arg0, %1 : i16 + %6 = llvm.icmp "ne" %5, %2 : i16 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_wrong_pred2(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-256 : i16) : i16 + %2 = llvm.mlir.constant(17664 : i16) : i16 + %3 = llvm.trunc %arg0 : i16 to i8 + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.and %arg0, %1 : i16 + %6 = llvm.icmp "eq" %5, %2 : i16 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_wrong_pred3(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-256 : i16) : i16 + %2 = llvm.mlir.constant(17664 : i16) : i16 + %3 = llvm.trunc %arg0 : i16 to i8 + %4 = llvm.icmp "eq" %3, %0 : i8 + %5 = llvm.and %arg0, %1 : i16 + %6 = llvm.icmp "eq" %5, %2 : i16 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_wrong_op(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-256 : i16) : i16 + %2 = llvm.mlir.constant(17664 : i16) : i16 + %3 = llvm.trunc %arg0 : i16 to i8 + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.and %arg1, %1 : i16 + %6 = llvm.icmp "ne" %5, %2 : i16 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_wrong_const1(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-256 : i16) : i16 + %2 = llvm.mlir.constant(17665 : i16) : i16 + %3 = llvm.trunc %arg0 : i16 to i8 + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.and %arg0, %1 : i16 + %6 = llvm.icmp "ne" %5, %2 : i16 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_wrong_const2(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-255 : i16) : i16 + %2 = llvm.mlir.constant(17665 : i16) : i16 + %3 = llvm.trunc %arg0 : i16 to i8 + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.and %arg0, %1 : i16 + %6 = llvm.icmp "ne" %5, %2 : i16 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/merging-multiple-stores-into-successor.ll.mlir b/test/LLVMDialect/InstCombine/merging-multiple-stores-into-successor.ll.mlir new file mode 100644 index 000000000..1a6203c76 --- /dev/null +++ b/test/LLVMDialect/InstCombine/merging-multiple-stores-into-successor.ll.mlir @@ -0,0 +1,194 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @var_7() {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.mlir.global external @var_1() {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.mlir.global external @var_0() {addr_space = 0 : i32, alignment = 2 : i64} : i16 + llvm.mlir.global external @var_5() {addr_space = 0 : i32, alignment = 8 : i64} : i64 + llvm.mlir.global external @arr_2() {addr_space = 0 : i32, alignment = 4 : i64} : !llvm.array<0 x i32> + llvm.mlir.global external @arr_4() {addr_space = 0 : i32, alignment = 2 : i64} : !llvm.array<0 x i16> + llvm.mlir.global external @arr_3() {addr_space = 0 : i32, alignment = 16 : i64} : !llvm.array<8 x i32> + llvm.func @_Z4testv() { + %0 = llvm.mlir.addressof @var_7 : !llvm.ptr + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.addressof @var_1 : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.addressof @var_0 : !llvm.ptr + %5 = llvm.mlir.addressof @var_5 : !llvm.ptr + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.mlir.addressof @arr_2 : !llvm.ptr + %8 = llvm.mlir.addressof @arr_4 : !llvm.ptr + %9 = llvm.mlir.addressof @arr_3 : !llvm.ptr + %10 = llvm.mlir.constant(1 : i64) : i64 + %11 = llvm.mlir.constant(0 : i64) : i64 + %12 = llvm.getelementptr inbounds %7[%11, %10] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %13 = llvm.getelementptr inbounds %8[%11, %10] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i16> + %14 = llvm.getelementptr inbounds %9[%11, %10] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i32> + %15 = llvm.load %0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %16 = llvm.icmp "eq" %15, %1 : i8 + %17 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %18 = llvm.icmp "eq" %17, %3 : i32 + %19 = llvm.load %4 {alignment = 2 : i64} : !llvm.ptr -> i16 + %20 = llvm.sext %19 : i16 to i64 + %21 = llvm.load %5 {alignment = 8 : i64} : !llvm.ptr -> i64 + %22 = llvm.select %18, %21, %20 : i1, i64 + %23 = llvm.sext %19 : i16 to i32 + llvm.cond_br %16, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.store %6, %7 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %19, %8 {alignment = 2 : i64} : i16, !llvm.ptr + llvm.store %23, %9 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %6, %12 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %19, %13 {alignment = 2 : i64} : i16, !llvm.ptr + llvm.store %23, %14 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 + ^bb2: // pred: ^bb0 + %24 = llvm.trunc %22 : i64 to i32 + llvm.store %24, %7 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %19, %8 {alignment = 2 : i64} : i16, !llvm.ptr + llvm.store %23, %9 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %24, %12 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %19, %13 {alignment = 2 : i64} : i16, !llvm.ptr + llvm.store %23, %14 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + llvm.return + } + llvm.func @diff_types_same_width_merge(%arg0: i1, %arg1: f16, %arg2: i16) -> f16 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x f16 {alignment = 2 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.store %arg1, %1 {alignment = 2 : i64} : f16, !llvm.ptr + llvm.br ^bb3 + ^bb2: // pred: ^bb0 + llvm.store %arg2, %1 {alignment = 2 : i64} : i16, !llvm.ptr + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + %2 = llvm.load %1 {alignment = 2 : i64} : !llvm.ptr -> f16 + llvm.return %2 : f16 + } + llvm.func @diff_types_diff_width_no_merge(%arg0: i1, %arg1: i32, %arg2: i64) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.store %arg1, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 + ^bb2: // pred: ^bb0 + llvm.store %arg2, %1 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %2 : i32 + } + llvm.func @vec_no_merge(%arg0: i1, %arg1: vector<2xi32>, %arg2: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.store %arg1, %1 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + llvm.br ^bb3 + ^bb2: // pred: ^bb0 + llvm.store %arg2, %1 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + %2 = llvm.load %1 {alignment = 16 : i64} : !llvm.ptr -> vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @one_elem_struct_merge(%arg0: i1, %arg1: !llvm.struct<"struct.half", (f16)>, %arg2: f16) -> !llvm.struct<"struct.half", (f16)> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.store %arg1, %1 {alignment = 2 : i64} : !llvm.struct<"struct.half", (f16)>, !llvm.ptr + llvm.br ^bb3 + ^bb2: // pred: ^bb0 + llvm.store %arg2, %1 {alignment = 2 : i64} : f16, !llvm.ptr + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + %2 = llvm.load %1 {alignment = 2 : i64} : !llvm.ptr -> !llvm.struct<"struct.half", (f16)> + llvm.return %2 : !llvm.struct<"struct.half", (f16)> + } + llvm.func @multi_elem_struct_no_merge(%arg0: i1, %arg1: !llvm.struct<"struct.tup", (f16, i32)>, %arg2: f16) -> !llvm.struct<"struct.tup", (f16, i32)> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.store %arg1, %1 {alignment = 4 : i64} : !llvm.struct<"struct.tup", (f16, i32)>, !llvm.ptr + llvm.br ^bb3 + ^bb2: // pred: ^bb0 + llvm.store %arg2, %1 {alignment = 2 : i64} : f16, !llvm.ptr + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> !llvm.struct<"struct.tup", (f16, i32)> + llvm.return %2 : !llvm.struct<"struct.tup", (f16, i32)> + } + llvm.func @same_types_diff_align_no_merge(%arg0: i1, %arg1: i16, %arg2: i16) -> i16 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i16 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.store %arg1, %1 {alignment = 8 : i64} : i16, !llvm.ptr + llvm.br ^bb3 + ^bb2: // pred: ^bb0 + llvm.store %arg2, %1 {alignment = 4 : i64} : i16, !llvm.ptr + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + %2 = llvm.load %1 {alignment = 2 : i64} : !llvm.ptr -> i16 + llvm.return %2 : i16 + } + llvm.func @ptrtoint_merge(%arg0: i1, %arg1: i64, %arg2: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.store %arg1, %1 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.br ^bb3 + ^bb2: // pred: ^bb0 + llvm.store %arg2, %1 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i64 + llvm.return %2 : i64 + } + llvm.func @inttoptr_merge(%arg0: i1, %arg1: i64, %arg2: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.store %arg1, %1 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.br ^bb3 + ^bb2: // pred: ^bb0 + llvm.store %arg2, %1 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + %2 = llvm.load %1 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @pr46688(%arg0: i1, %arg1: i32, %arg2: i16, %arg3: !llvm.ptr, %arg4: !llvm.ptr) { + %0 = llvm.mlir.constant(65535 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.zext %arg2 : i16 to i32 + %2 = llvm.lshr %1, %arg1 : i32 + %3 = llvm.lshr %2, %arg1 : i32 + %4 = llvm.lshr %3, %arg1 : i32 + %5 = llvm.lshr %4, %arg1 : i32 + %6 = llvm.trunc %5 : i32 to i16 + llvm.store %6, %arg3 {alignment = 2 : i64} : i16, !llvm.ptr + %7 = llvm.and %5, %0 : i32 + llvm.store %7, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 + ^bb2: // pred: ^bb0 + %8 = llvm.zext %arg2 : i16 to i32 + %9 = llvm.lshr %8, %arg1 : i32 + %10 = llvm.lshr %9, %arg1 : i32 + %11 = llvm.lshr %10, %arg1 : i32 + %12 = llvm.lshr %11, %arg1 : i32 + %13 = llvm.trunc %12 : i32 to i16 + llvm.store %13, %arg3 {alignment = 2 : i64} : i16, !llvm.ptr + llvm.store %12, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/min-positive.ll.mlir b/test/LLVMDialect/InstCombine/min-positive.ll.mlir new file mode 100644 index 000000000..9542db191 --- /dev/null +++ b/test/LLVMDialect/InstCombine/min-positive.ll.mlir @@ -0,0 +1,89 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g() {addr_space = 0 : i32} : i32 + llvm.func @smin(%arg0: i32) -> i1 { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.load %0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %3 = llvm.icmp "slt" %2, %arg0 : i32 + %4 = llvm.select %3, %2, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @smin_int(%arg0: i32) -> i1 { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.load %0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %3 = llvm.intr.smin(%2, %arg0) : (i32, i32) -> i32 + %4 = llvm.icmp "sgt" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @smin_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.or %4, %1 : vector<2xi32> + %6 = llvm.icmp "slt" %5, %arg1 : vector<2xi32> + %7 = llvm.select %6, %5, %arg1 : vector<2xi1>, vector<2xi32> + %8 = llvm.icmp "sgt" %7, %3 : vector<2xi32> + llvm.return %8 : vector<2xi1> + } + llvm.func @smin_commute(%arg0: i32) -> i1 { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.load %0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %3 = llvm.icmp "slt" %arg0, %2 : i32 + %4 = llvm.select %3, %arg0, %2 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @smin_commute_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.or %4, %1 : vector<2xi32> + %6 = llvm.icmp "slt" %arg1, %5 : vector<2xi32> + %7 = llvm.select %6, %arg1, %5 : vector<2xi1>, vector<2xi32> + %8 = llvm.icmp "sgt" %7, %3 : vector<2xi32> + llvm.return %8 : vector<2xi1> + } + llvm.func @smin_commute_vec_poison_elts(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.undef : vector<2xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi32> + %9 = llvm.and %arg0, %0 : vector<2xi32> + %10 = llvm.or %9, %1 : vector<2xi32> + %11 = llvm.icmp "slt" %arg1, %10 : vector<2xi32> + %12 = llvm.select %11, %arg1, %10 : vector<2xi1>, vector<2xi32> + %13 = llvm.icmp "sgt" %12, %8 : vector<2xi32> + llvm.return %13 : vector<2xi1> + } + llvm.func @maybe_not_positive(%arg0: i32) -> i1 { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.load %0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %3 = llvm.icmp "slt" %2, %arg0 : i32 + %4 = llvm.select %3, %2, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @maybe_not_positive_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "slt" %3, %arg1 : vector<2xi32> + %5 = llvm.select %4, %3, %arg1 : vector<2xi1>, vector<2xi32> + %6 = llvm.icmp "sgt" %5, %2 : vector<2xi32> + llvm.return %6 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/minimum.ll.mlir b/test/LLVMDialect/InstCombine/minimum.ll.mlir new file mode 100644 index 000000000..528f7a184 --- /dev/null +++ b/test/LLVMDialect/InstCombine/minimum.ll.mlir @@ -0,0 +1,288 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @constant_fold_minimum_f32() -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.intr.minimum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_minimum_f32_inv() -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.minimum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_minimum_f32_nan0() -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.intr.minimum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_minimum_f32_nan1() -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %2 = llvm.intr.minimum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_minimum_f32_nan_nan() -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.intr.minimum(%0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_minimum_f32_p0_p0() -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.intr.minimum(%0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_minimum_f32_p0_n0() -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.intr.minimum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_minimum_f32_n0_p0() -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.intr.minimum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_minimum_f32_n0_n0() -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.intr.minimum(%0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_minimum_v4f32() -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 8.000000e+00, 3.000000e+00, 9.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[2.000000e+00, 2.000000e+00, 1.000000e+01, 5.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.intr.minimum(%0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @constant_fold_minimum_f64() -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.intr.minimum(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @constant_fold_minimum_f64_nan0() -> f64 { + %0 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.intr.minimum(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @constant_fold_minimum_f64_nan1() -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %2 = llvm.intr.minimum(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @constant_fold_minimum_f64_nan_nan() -> f64 { + %0 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %1 = llvm.intr.minimum(%0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @canonicalize_constant_minimum_f32(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.minimum(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @minimum_f32_nan_val(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.intr.minimum(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @minimum_f32_val_nan(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.intr.minimum(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @minimum_f32_1_minimum_val_p0(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.minimum(%arg0, %0) : (f32, f32) -> f32 + %3 = llvm.intr.minimum(%2, %1) : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minimum_f32_1_minimum_p0_val_fast(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.minimum(%0, %arg0) : (f32, f32) -> f32 + %3 = llvm.intr.minimum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minimum_f32_1_minimum_p0_val_fmf1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.minimum(%0, %arg0) : (f32, f32) -> f32 + %3 = llvm.intr.minimum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minimum_f32_1_minimum_p0_val_fmf2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.minimum(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.intr.minimum(%2, %1) : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minimum_f32_1_minimum_p0_val_fmf3(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.minimum(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.intr.minimum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minimum_f32_p0_minimum_val_n0(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.intr.minimum(%arg0, %0) : (f32, f32) -> f32 + %3 = llvm.intr.minimum(%2, %1) : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minimum_f32_1_minimum_p0_val(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.minimum(%0, %arg0) : (f32, f32) -> f32 + %3 = llvm.intr.minimum(%2, %1) : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minimum_f32_1_minimum_val_p0_val_v2f32(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.constant(dense<1.000000e+00> : vector<2xf32>) : vector<2xf32> + %3 = llvm.intr.minimum(%arg0, %1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + %4 = llvm.intr.minimum(%3, %2) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @minimum4(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: f32) -> f32 { + %0 = llvm.intr.minimum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.minimum(%arg2, %arg3) : (f32, f32) -> f32 + %2 = llvm.intr.minimum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @minimum_x_maximum_x_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.maximum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.minimum(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @maximum_x_minimum_x_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.minimum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maximum(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @neg_neg(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.fsub %0, %arg1 : f64 + %3 = llvm.intr.minimum(%1, %2) : (f64, f64) -> f64 + llvm.return %3 : f64 + } + llvm.func @unary_neg_neg(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.fneg %arg1 : f64 + %2 = llvm.intr.minimum(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @neg_neg_vec_fmf(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %2 = llvm.fsub %0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %3 = llvm.intr.minimum(%1, %2) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @unary_neg_neg_vec_fmf(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %1 = llvm.fneg %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %2 = llvm.intr.minimum(%0, %1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @use(f64) + llvm.func @neg_neg_extra_use_x(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.fsub %0, %arg1 : f64 + %3 = llvm.intr.minimum(%1, %2) : (f64, f64) -> f64 + llvm.call @use(%1) : (f64) -> () + llvm.return %3 : f64 + } + llvm.func @unary_neg_neg_extra_use_x(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.fneg %arg1 : f64 + %2 = llvm.intr.minimum(%0, %1) : (f64, f64) -> f64 + llvm.call @use(%0) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @neg_neg_extra_use_y(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.fsub %0, %arg1 : f64 + %3 = llvm.intr.minimum(%1, %2) : (f64, f64) -> f64 + llvm.call @use(%2) : (f64) -> () + llvm.return %3 : f64 + } + llvm.func @unary_neg_neg_extra_use_y(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.fneg %arg1 : f64 + %2 = llvm.intr.minimum(%0, %1) : (f64, f64) -> f64 + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @neg_neg_extra_use_x_and_y(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.fsub %0, %arg1 : f64 + %3 = llvm.intr.minimum(%1, %2) : (f64, f64) -> f64 + llvm.call @use(%1) : (f64) -> () + llvm.call @use(%2) : (f64) -> () + llvm.return %3 : f64 + } + llvm.func @unary_neg_neg_extra_use_x_and_y(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.fneg %arg1 : f64 + %2 = llvm.intr.minimum(%0, %1) : (f64, f64) -> f64 + llvm.call @use(%0) : (f64) -> () + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @reduce_precision(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.minimum(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @reduce_precision_fmf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.minimum(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @negated_op(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.intr.minimum(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @negated_op_fmf_commute_vec(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.fneg %arg0 : vector<2xf64> + %1 = llvm.intr.minimum(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @negated_op_extra_use(%arg0: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + llvm.call @use(%0) : (f64) -> () + %1 = llvm.intr.minimum(%0, %arg0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pr71548() { + %0 = llvm.mlir.zero : !llvm.ptr<1> + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.load %0 atomic unordered {alignment = 8 : i64} : !llvm.ptr<1> -> f64 + %4 = llvm.load %0 atomic unordered {alignment = 4 : i64} : !llvm.ptr<1> -> i32 + %5 = llvm.sitofp %4 : i32 to f64 + %6 = llvm.intr.minimum(%3, %5) : (f64, f64) -> f64 + %7 = llvm.fcmp "ult" %6, %1 : f64 + %8 = llvm.icmp "eq" %4, %2 : i32 + %9 = llvm.or %7, %8 : i1 + "llvm.intr.assume"(%9) : (i1) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/minmax-demandbits.ll.mlir b/test/LLVMDialect/InstCombine/minmax-demandbits.ll.mlir new file mode 100644 index 000000000..21836b11e --- /dev/null +++ b/test/LLVMDialect/InstCombine/minmax-demandbits.ll.mlir @@ -0,0 +1,160 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @and_umax_less(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(-32 : i32) : i32 + %2 = llvm.icmp "ugt" %0, %arg0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @and_umax_muchless(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(-32 : i32) : i32 + %2 = llvm.icmp "ugt" %0, %arg0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @and_umax_more(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-32 : i32) : i32 + %2 = llvm.icmp "ugt" %0, %arg0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @shr_umax(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.icmp "ugt" %0, %arg0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.lshr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @t_0_1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @t_0_10(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @t_1_10(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @t_2_4(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @t_2_192(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(-64 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @t_2_63_or(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(63 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.or %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @f_1_1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.icmp "ugt" %arg0, %0 : i8 + %2 = llvm.select %1, %arg0, %0 : i1, i8 + %3 = llvm.and %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @f_32_32(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(32 : i8) : i8 + %1 = llvm.mlir.constant(-32 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @f_191_192(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-65 : i8) : i8 + %1 = llvm.mlir.constant(-64 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @f_10_1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @and_umin(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(-32 : i32) : i32 + %2 = llvm.icmp "ult" %0, %arg0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @or_umin(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.icmp "ult" %0, %arg0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.or %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @or_min_31_30(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-30 : i8) : i8 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.icmp "ult" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.or %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @and_min_7_7(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-7 : i8) : i8 + %1 = llvm.mlir.constant(-8 : i8) : i8 + %2 = llvm.icmp "ult" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @and_min_7_8(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-8 : i8) : i8 + %1 = llvm.icmp "ult" %arg0, %0 : i8 + %2 = llvm.select %1, %arg0, %0 : i1, i8 + %3 = llvm.and %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @and_min_7_9(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-9 : i8) : i8 + %1 = llvm.mlir.constant(-8 : i8) : i8 + %2 = llvm.icmp "ult" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/minmax-fold.ll.mlir b/test/LLVMDialect/InstCombine/minmax-fold.ll.mlir new file mode 100644 index 000000000..ef222e735 --- /dev/null +++ b/test/LLVMDialect/InstCombine/minmax-fold.ll.mlir @@ -0,0 +1,929 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t1(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.select %1, %arg0, %0 : i1, i32 + %3 = llvm.sext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @t2(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(5 : i64) : i64 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sext %arg0 : i32 to i64 + %4 = llvm.select %2, %3, %1 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @t3(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(5 : i64) : i64 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.zext %arg0 : i32 to i64 + %4 = llvm.select %2, %1, %3 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @t4(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(5 : i64) : i64 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i64 + %3 = llvm.trunc %arg0 : i64 to i32 + %4 = llvm.select %2, %3, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @t5(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(5 : i64) : i64 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.zext %arg0 : i32 to i64 + %4 = llvm.select %2, %1, %3 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @t6(%arg0: i32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.select %1, %arg0, %0 : i1, i32 + %3 = llvm.sitofp %2 : i32 to f32 + llvm.return %3 : f32 + } + llvm.func @t7(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(-32768 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i16) : i16 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.trunc %arg0 : i32 to i16 + %4 = llvm.select %2, %3, %1 : i1, i16 + llvm.return %4 : i16 + } + llvm.func @t8(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-32767 : i64) : i64 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i64 + %3 = llvm.select %2, %arg0, %0 : i1, i64 + %4 = llvm.trunc %3 : i64 to i32 + %5 = llvm.icmp "slt" %arg1, %1 : i32 + %6 = llvm.select %5, %1, %4 : i1, i32 + %7 = llvm.icmp "ne" %6, %arg1 : i32 + %8 = llvm.zext %7 : i1 to i32 + llvm.return %8 : i32 + } + llvm.func @t9(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(4294967295 : i64) : i64 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sext %arg0 : i32 to i64 + %4 = llvm.select %2, %3, %1 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @t10(%arg0: i32) -> f32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %2 = llvm.sitofp %arg0 : i32 to f32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.select %3, %2, %1 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @t11(%arg0: i64) -> f32 { + %0 = llvm.mlir.constant(255 : i64) : i64 + %1 = llvm.mlir.constant(2.550000e+02 : f32) : f32 + %2 = llvm.sitofp %arg0 : i64 to f32 + %3 = llvm.icmp "sgt" %arg0, %0 : i64 + %4 = llvm.select %3, %2, %1 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @bitcasts_fcmp_1(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<4xi32> { + %0 = llvm.bitcast %arg0 : vector<2xi64> to vector<4xf32> + %1 = llvm.bitcast %arg1 : vector<2xi64> to vector<4xf32> + %2 = llvm.fcmp "olt" %1, %0 : vector<4xf32> + %3 = llvm.bitcast %arg0 : vector<2xi64> to vector<4xi32> + %4 = llvm.bitcast %arg1 : vector<2xi64> to vector<4xi32> + %5 = llvm.select %2, %3, %4 : vector<4xi1>, vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @bitcasts_fcmp_2(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<4xi32> { + %0 = llvm.bitcast %arg0 : vector<2xi64> to vector<4xf32> + %1 = llvm.bitcast %arg1 : vector<2xi64> to vector<4xf32> + %2 = llvm.fcmp "olt" %0, %1 : vector<4xf32> + %3 = llvm.bitcast %arg0 : vector<2xi64> to vector<4xi32> + %4 = llvm.bitcast %arg1 : vector<2xi64> to vector<4xi32> + %5 = llvm.select %2, %3, %4 : vector<4xi1>, vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @bitcasts_icmp(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<4xf32> { + %0 = llvm.bitcast %arg0 : vector<2xi64> to vector<4xi32> + %1 = llvm.bitcast %arg1 : vector<2xi64> to vector<4xi32> + %2 = llvm.icmp "slt" %1, %0 : vector<4xi32> + %3 = llvm.bitcast %arg0 : vector<2xi64> to vector<4xf32> + %4 = llvm.bitcast %arg1 : vector<2xi64> to vector<4xf32> + %5 = llvm.select %2, %3, %4 : vector<4xi1>, vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @test68(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(11 : i32) : i32 + %1 = llvm.mlir.constant(92 : i32) : i32 + %2 = llvm.icmp "slt" %0, %arg0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.icmp "slt" %1, %3 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test68vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<11> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<92> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "slt" %0, %arg0 : vector<2xi32> + %3 = llvm.select %2, %0, %arg0 : vector<2xi1>, vector<2xi32> + %4 = llvm.icmp "slt" %1, %3 : vector<2xi32> + %5 = llvm.select %4, %1, %3 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test69(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(83 : i32) : i32 + %2 = llvm.icmp "ult" %0, %arg0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.icmp "ult" %1, %3 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test70(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(75 : i32) : i32 + %1 = llvm.mlir.constant(36 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test71(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(68 : i32) : i32 + %1 = llvm.mlir.constant(47 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.icmp "ult" %3, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test72(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(92 : i32) : i32 + %1 = llvm.mlir.constant(11 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.icmp "sgt" %3, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test72vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<92> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<11> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %0, %arg0 : vector<2xi1>, vector<2xi32> + %4 = llvm.icmp "sgt" %3, %1 : vector<2xi32> + %5 = llvm.select %4, %1, %3 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test73(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(83 : i32) : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.icmp "ugt" %3, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test74(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(36 : i32) : i32 + %1 = llvm.mlir.constant(75 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test75(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(47 : i32) : i32 + %1 = llvm.mlir.constant(68 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.icmp "ult" %3, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @clamp_signed1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.icmp "slt" %arg0, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @clamp_signed2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.icmp "sgt" %arg0, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @clamp_signed3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.icmp "sgt" %arg0, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @clamp_signed4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.icmp "slt" %arg0, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @clamp_unsigned1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.icmp "ult" %arg0, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @clamp_unsigned2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.icmp "ugt" %arg0, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @clamp_unsigned3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.icmp "ugt" %arg0, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @clamp_unsigned4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.icmp "ult" %arg0, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @clamp_check_for_no_infinite_loop1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.icmp "slt" %arg0, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @clamp_check_for_no_infinite_loop2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-255 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.icmp "slt" %arg0, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @clamp_check_for_no_infinite_loop3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg0, %0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %1 : i32 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %6 = llvm.icmp "slt" %4, %2 : i32 + %7 = llvm.select %6, %4, %2 : i1, i32 + %8 = llvm.shl %7, %2 overflow : i32 + llvm.return %8 : i32 + ^bb2: // pred: ^bb0 + llvm.return %1 : i32 + } + llvm.func @PR31751_umin1(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %1, %arg0 : i1, i32 + %4 = llvm.sitofp %3 : i32 to f64 + llvm.return %4 : f64 + } + llvm.func @PR31751_umin2(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.icmp "ult" %arg0, %0 : i32 + %2 = llvm.select %1, %arg0, %0 : i1, i32 + %3 = llvm.sitofp %2 : i32 to f64 + llvm.return %3 : f64 + } + llvm.func @PR31751_umin3(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.icmp "ugt" %arg0, %0 : i32 + %2 = llvm.select %1, %0, %arg0 : i1, i32 + %3 = llvm.sitofp %2 : i32 to f64 + llvm.return %3 : f64 + } + llvm.func @PR31751_umax1(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %1, %arg0 : i1, i32 + %4 = llvm.sitofp %3 : i32 to f64 + llvm.return %4 : f64 + } + llvm.func @PR31751_umax2(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.icmp "ugt" %arg0, %0 : i32 + %2 = llvm.select %1, %arg0, %0 : i1, i32 + %3 = llvm.sitofp %2 : i32 to f64 + llvm.return %3 : f64 + } + llvm.func @PR31751_umax3(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.icmp "ult" %arg0, %0 : i32 + %2 = llvm.select %1, %0, %arg0 : i1, i32 + %3 = llvm.sitofp %2 : i32 to f64 + llvm.return %3 : f64 + } + llvm.func @bitcast_scalar_smax(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.bitcast %arg0 : f32 to i32 + %1 = llvm.bitcast %arg1 : f32 to i32 + %2 = llvm.icmp "sgt" %0, %1 : i32 + %3 = llvm.select %2, %0, %1 : i1, i32 + %4 = llvm.bitcast %3 : i32 to f32 + llvm.return %4 : f32 + } + llvm.func @bitcast_scalar_umax(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.bitcast %arg0 : f32 to i32 + %1 = llvm.bitcast %arg1 : f32 to i32 + %2 = llvm.icmp "ugt" %0, %1 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @bitcast_vector_smin(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xf32> { + %0 = llvm.bitcast %arg0 : vector<8xf32> to vector<8xi32> + %1 = llvm.bitcast %arg1 : vector<8xf32> to vector<8xi32> + %2 = llvm.icmp "slt" %0, %1 : vector<8xi32> + %3 = llvm.select %2, %0, %1 : vector<8xi1>, vector<8xi32> + %4 = llvm.bitcast %3 : vector<8xi32> to vector<8xf32> + llvm.return %4 : vector<8xf32> + } + llvm.func @bitcast_vector_umin(%arg0: vector<8xf32>, %arg1: vector<8xf32>) -> vector<8xf32> { + %0 = llvm.bitcast %arg0 : vector<8xf32> to vector<8xi32> + %1 = llvm.bitcast %arg1 : vector<8xf32> to vector<8xi32> + %2 = llvm.icmp "slt" %0, %1 : vector<8xi32> + %3 = llvm.select %2, %arg0, %arg1 : vector<8xi1>, vector<8xf32> + llvm.return %3 : vector<8xf32> + } + llvm.func @look_through_cast1(%arg0: i32) -> (i8 {llvm.zeroext}) { + %0 = llvm.mlir.constant(511 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.trunc %arg0 : i32 to i8 + %4 = llvm.select %2, %3, %1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @look_through_cast2(%arg0: i32) -> (i8 {llvm.zeroext}) { + %0 = llvm.mlir.constant(510 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.trunc %arg0 : i32 to i8 + %4 = llvm.select %2, %3, %1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @min_through_cast_vec1(%arg0: vector<2xi32>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[510, 511]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-2, -1]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.icmp "slt" %arg0, %0 : vector<2xi32> + %3 = llvm.trunc %arg0 : vector<2xi32> to vector<2xi8> + %4 = llvm.select %2, %3, %1 : vector<2xi1>, vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @min_through_cast_vec2(%arg0: vector<2xi32>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<511> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.icmp "slt" %arg0, %0 : vector<2xi32> + %3 = llvm.trunc %arg0 : vector<2xi32> to vector<2xi8> + %4 = llvm.select %2, %3, %1 : vector<2xi1>, vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @common_factor_smin(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "slt" %arg1, %arg2 : i32 + %3 = llvm.select %2, %arg1, %arg2 : i1, i32 + %4 = llvm.icmp "slt" %1, %3 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @common_factor_smax(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.icmp "sgt" %arg0, %arg1 : vector<2xi32> + %1 = llvm.select %0, %arg0, %arg1 : vector<2xi1>, vector<2xi32> + %2 = llvm.icmp "sgt" %arg2, %arg1 : vector<2xi32> + %3 = llvm.select %2, %arg2, %arg1 : vector<2xi1>, vector<2xi32> + %4 = llvm.icmp "sgt" %1, %3 : vector<2xi32> + %5 = llvm.select %4, %1, %3 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @common_factor_umin(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.icmp "ult" %arg1, %arg2 : vector<2xi32> + %1 = llvm.select %0, %arg1, %arg2 : vector<2xi1>, vector<2xi32> + %2 = llvm.icmp "ult" %arg0, %arg1 : vector<2xi32> + %3 = llvm.select %2, %arg0, %arg1 : vector<2xi1>, vector<2xi32> + %4 = llvm.icmp "ult" %1, %3 : vector<2xi32> + %5 = llvm.select %4, %1, %3 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @common_factor_umax(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.icmp "ugt" %arg1, %arg2 : i32 + %1 = llvm.select %0, %arg1, %arg2 : i1, i32 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i32 + %3 = llvm.select %2, %arg1, %arg0 : i1, i32 + %4 = llvm.icmp "ugt" %1, %3 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @extra_use(i32) + llvm.func @common_factor_umax_extra_use_lhs(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.icmp "ugt" %arg1, %arg2 : i32 + %1 = llvm.select %0, %arg1, %arg2 : i1, i32 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i32 + %3 = llvm.select %2, %arg1, %arg0 : i1, i32 + %4 = llvm.icmp "ugt" %1, %3 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.call @extra_use(%1) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @common_factor_umax_extra_use_rhs(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.icmp "ugt" %arg1, %arg2 : i32 + %1 = llvm.select %0, %arg1, %arg2 : i1, i32 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i32 + %3 = llvm.select %2, %arg1, %arg0 : i1, i32 + %4 = llvm.icmp "ugt" %1, %3 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.call @extra_use(%3) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @common_factor_umax_extra_use_both(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.icmp "ugt" %arg1, %arg2 : i32 + %1 = llvm.select %0, %arg1, %arg2 : i1, i32 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i32 + %3 = llvm.select %2, %arg1, %arg0 : i1, i32 + %4 = llvm.icmp "ugt" %1, %3 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.call @extra_use(%1) : (i32) -> () + llvm.call @extra_use(%3) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @not_min_of_min(%arg0: i8, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(16 : i8) : i8 + %3 = llvm.fcmp "ult" %arg1, %0 {fastmathFlags = #llvm.fastmath} : f32 + %4 = llvm.select %3, %arg1, %0 : i1, f32 + %5 = llvm.fcmp "ult" %arg1, %1 {fastmathFlags = #llvm.fastmath} : f32 + %6 = llvm.select %5, %arg1, %1 : i1, f32 + %7 = llvm.icmp "ult" %arg0, %2 : i8 + %8 = llvm.select %7, %4, %6 : i1, f32 + llvm.return %8 : f32 + } + llvm.func @add_umin(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_umin_constant_limit(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(41 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_umin_simplify(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.add %arg0, %0 overflow : i32 + %2 = llvm.icmp "ult" %1, %0 : i32 + %3 = llvm.select %2, %1, %0 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @add_umin_simplify2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(43 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_umin_wrong_pred(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_umin_wrong_wrap(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_umin_extra_use(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + llvm.store %2, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_umin_vec(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<240> : vector<2xi16>) : vector<2xi16> + %2 = llvm.add %arg0, %0 overflow : vector<2xi16> + %3 = llvm.icmp "ult" %2, %1 : vector<2xi16> + %4 = llvm.select %3, %2, %1 : vector<2xi1>, vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @add_umax(%arg0: i37) -> i37 { + %0 = llvm.mlir.constant(5 : i37) : i37 + %1 = llvm.mlir.constant(42 : i37) : i37 + %2 = llvm.add %arg0, %0 overflow : i37 + %3 = llvm.icmp "ugt" %2, %1 : i37 + %4 = llvm.select %3, %2, %1 : i1, i37 + llvm.return %4 : i37 + } + llvm.func @add_umax_constant_limit(%arg0: i37) -> i37 { + %0 = llvm.mlir.constant(81 : i37) : i37 + %1 = llvm.mlir.constant(82 : i37) : i37 + %2 = llvm.add %arg0, %0 overflow : i37 + %3 = llvm.icmp "ugt" %2, %1 : i37 + %4 = llvm.select %3, %2, %1 : i1, i37 + llvm.return %4 : i37 + } + llvm.func @add_umax_simplify(%arg0: i37) -> i37 { + %0 = llvm.mlir.constant(42 : i37) : i37 + %1 = llvm.add %arg0, %0 overflow : i37 + %2 = llvm.icmp "ugt" %1, %0 : i37 + %3 = llvm.select %2, %1, %0 : i1, i37 + llvm.return %3 : i37 + } + llvm.func @add_umax_simplify2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(57 : i32) : i32 + %1 = llvm.mlir.constant(56 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_umax_wrong_pred(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_umax_wrong_wrap(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_umax_extra_use(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + llvm.store %2, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.icmp "ugt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_umax_vec(%arg0: vector<2xi33>) -> vector<2xi33> { + %0 = llvm.mlir.constant(5 : i33) : i33 + %1 = llvm.mlir.constant(dense<5> : vector<2xi33>) : vector<2xi33> + %2 = llvm.mlir.constant(240 : i33) : i33 + %3 = llvm.mlir.constant(dense<240> : vector<2xi33>) : vector<2xi33> + %4 = llvm.add %arg0, %1 overflow : vector<2xi33> + %5 = llvm.icmp "ugt" %4, %3 : vector<2xi33> + %6 = llvm.select %5, %4, %3 : vector<2xi1>, vector<2xi33> + llvm.return %6 : vector<2xi33> + } + llvm.func @PR14613_umin(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.add %2, %0 overflow : i32 + %4 = llvm.icmp "ult" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + %6 = llvm.trunc %5 : i32 to i8 + llvm.return %6 : i8 + } + llvm.func @PR14613_umax(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.add %2, %0 overflow : i32 + %4 = llvm.icmp "ugt" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + %6 = llvm.trunc %5 : i32 to i8 + llvm.return %6 : i8 + } + llvm.func @add_smin(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_smin_constant_limit(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(2147483643 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_smin_simplify(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(2147483644 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_smin_simplify2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(2147483645 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_smin_wrong_pred(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_smin_wrong_wrap(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_smin_extra_use(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + llvm.store %2, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_smin_vec(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<240> : vector<2xi16>) : vector<2xi16> + %2 = llvm.add %arg0, %0 overflow : vector<2xi16> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi16> + %4 = llvm.select %3, %2, %1 : vector<2xi1>, vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @add_smax(%arg0: i37) -> i37 { + %0 = llvm.mlir.constant(5 : i37) : i37 + %1 = llvm.mlir.constant(42 : i37) : i37 + %2 = llvm.add %arg0, %0 overflow : i37 + %3 = llvm.icmp "sgt" %2, %1 : i37 + %4 = llvm.select %3, %2, %1 : i1, i37 + llvm.return %4 : i37 + } + llvm.func @add_smax_constant_limit(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(125 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + %4 = llvm.select %3, %2, %1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @add_smax_simplify(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(126 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + %4 = llvm.select %3, %2, %1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @add_smax_simplify2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.icmp "sgt" %2, %1 : i8 + %4 = llvm.select %3, %2, %1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @add_smax_wrong_pred(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_smax_wrong_wrap(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_smax_extra_use(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + llvm.store %2, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.icmp "sgt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @add_smax_vec(%arg0: vector<2xi33>) -> vector<2xi33> { + %0 = llvm.mlir.constant(5 : i33) : i33 + %1 = llvm.mlir.constant(dense<5> : vector<2xi33>) : vector<2xi33> + %2 = llvm.mlir.constant(240 : i33) : i33 + %3 = llvm.mlir.constant(dense<240> : vector<2xi33>) : vector<2xi33> + %4 = llvm.add %arg0, %1 overflow : vector<2xi33> + %5 = llvm.icmp "sgt" %4, %3 : vector<2xi33> + %6 = llvm.select %5, %4, %3 : vector<2xi1>, vector<2xi33> + llvm.return %6 : vector<2xi33> + } + llvm.func @PR14613_smin(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(55 : i32) : i32 + %2 = llvm.sext %arg0 : i8 to i32 + %3 = llvm.add %2, %0 overflow : i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + %6 = llvm.trunc %5 : i32 to i8 + llvm.return %6 : i8 + } + llvm.func @PR14613_smax(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(55 : i32) : i32 + %2 = llvm.sext %arg0 : i8 to i32 + %3 = llvm.add %2, %0 overflow : i32 + %4 = llvm.icmp "sgt" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + %6 = llvm.trunc %5 : i32 to i8 + llvm.return %6 : i8 + } + llvm.func @PR46271(%arg0: vector<2xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.icmp "sgt" %arg0, %0 : vector<2xi8> + %10 = llvm.select %9, %arg0, %7 : vector<2xi1>, vector<2xi8> + %11 = llvm.xor %10, %7 : vector<2xi8> + %12 = llvm.extractelement %11[%8 : i32] : vector<2xi8> + llvm.return %12 : i8 + } + llvm.func @twoway_clamp_lt(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(13768 : i32) : i32 + %1 = llvm.mlir.constant(13767 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.icmp "sgt" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @twoway_clamp_gt(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(13767 : i32) : i32 + %1 = llvm.mlir.constant(13768 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @twoway_clamp_gt_nonconst(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.add %arg1, %0 : i32 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test_umax_smax1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.intr.smax(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.intr.umax(%2, %1) : (i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @test_umax_smax2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(20 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.intr.smax(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.intr.umax(%2, %1) : (i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @test_umax_smax_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[0, 20]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[1, 10]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.smax(%arg0, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + %3 = llvm.intr.umax(%2, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @test_smin_umin1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(20 : i32) : i32 + %2 = llvm.intr.umin(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.intr.smin(%2, %1) : (i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @test_smin_umin2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(20 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.intr.umin(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.intr.smin(%2, %1) : (i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @test_smin_umin_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[10, 20]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[20, 10]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.umin(%arg0, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + %3 = llvm.intr.smin(%2, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @test_umax_smax3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.intr.smax(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.intr.umax(%2, %1) : (i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @test_umax_smax4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-20 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.intr.smax(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.intr.umax(%2, %1) : (i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @test_smin_umin3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(-20 : i32) : i32 + %2 = llvm.intr.umin(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.intr.smin(%2, %1) : (i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @test_smin_umin4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-20 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.intr.umin(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.intr.smin(%2, %1) : (i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @test_umax_nonminmax(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %2 = llvm.intr.umax(%1, %0) : (i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @test_umax_smax_vec_neg(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[0, -20]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[1, 10]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.smax(%arg0, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + %3 = llvm.intr.umax(%2, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + llvm.return %3 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/minmax-fp.ll.mlir b/test/LLVMDialect/InstCombine/minmax-fp.ll.mlir new file mode 100644 index 000000000..073ab9d60 --- /dev/null +++ b/test/LLVMDialect/InstCombine/minmax-fp.ll.mlir @@ -0,0 +1,250 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t1(%arg0: f32) -> f64 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ult" %arg0, %0 : f32 + %2 = llvm.select %1, %arg0, %0 : i1, f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @t2(%arg0: f32) -> f64 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(5.000000e+00 : f64) : f64 + %2 = llvm.fcmp "ult" %arg0, %0 : f32 + %3 = llvm.fpext %arg0 : f32 to f64 + %4 = llvm.select %2, %3, %1 : i1, f64 + llvm.return %4 : f64 + } + llvm.func @t4(%arg0: f64) -> f32 { + %0 = llvm.mlir.constant(5.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ult" %arg0, %0 : f64 + %3 = llvm.fptrunc %arg0 : f64 to f32 + %4 = llvm.select %2, %3, %1 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @t5(%arg0: f32) -> f64 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(5.001000e+00 : f64) : f64 + %2 = llvm.fcmp "ult" %arg0, %0 : f32 + %3 = llvm.fpext %arg0 : f32 to f64 + %4 = llvm.select %2, %3, %1 : i1, f64 + llvm.return %4 : f64 + } + llvm.func @not_maxnum(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.select %2, %1, %arg0 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @t6(%arg0: f32) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.fcmp "ult" %arg0, %0 : f32 + %3 = llvm.fpext %arg0 : f32 to f64 + %4 = llvm.select %2, %3, %1 : i1, f64 + llvm.return %4 : f64 + } + llvm.func @t7(%arg0: f32) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %2 = llvm.fcmp "ult" %arg0, %0 : f32 + %3 = llvm.fpext %arg0 : f32 to f64 + %4 = llvm.select %2, %3, %1 : i1, f64 + llvm.return %4 : f64 + } + llvm.func @fmin_fmin_zero_mismatch(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %1 : i1, f32 + %4 = llvm.fcmp "olt" %3, %1 : f32 + %5 = llvm.select %4, %3, %1 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @fmax_fmax_zero_mismatch(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ogt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %1 : i1, f32 + %4 = llvm.fcmp "ogt" %0, %3 : f32 + %5 = llvm.select %4, %1, %3 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @t8(%arg0: f32) -> i64 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(5 : i64) : i64 + %2 = llvm.fcmp "ult" %arg0, %0 : f32 + %3 = llvm.fptoui %arg0 : f32 to i64 + %4 = llvm.select %2, %3, %1 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @t9(%arg0: f32) -> i8 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.fcmp "ult" %arg0, %0 : f32 + %3 = llvm.fptosi %arg0 : f32 to i8 + %4 = llvm.select %2, %3, %1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @t11(%arg0: f32, %arg1: f32) -> i8 { + %0 = llvm.fcmp "ult" %arg1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fptosi %arg0 : f32 to i8 + %2 = llvm.fptosi %arg1 : f32 to i8 + %3 = llvm.select %0, %2, %1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @t12(%arg0: f32, %arg1: f32) -> i8 { + %0 = llvm.fcmp "ult" %arg1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.fptosi %arg0 : f32 to i8 + %2 = llvm.fptosi %arg1 : f32 to i8 + %3 = llvm.select %0, %2, %1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @t13(%arg0: f32) -> i8 { + %0 = llvm.mlir.constant(1.500000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.fcmp "ult" %arg0, %0 : f32 + %3 = llvm.fptosi %arg0 : f32 to i8 + %4 = llvm.select %2, %3, %1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @t14(%arg0: f32) -> i8 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.fcmp "ule" %arg0, %0 : f32 + %3 = llvm.fptosi %arg0 : f32 to i8 + %4 = llvm.select %2, %3, %1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @t14_commute(%arg0: f32) -> i8 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.fcmp "ule" %arg0, %0 : f32 + %3 = llvm.fptosi %arg0 : f32 to i8 + %4 = llvm.select %2, %1, %3 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @t15(%arg0: f32) -> i8 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.fcmp "ule" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.fptosi %arg0 : f32 to i8 + %4 = llvm.select %2, %3, %1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @t16(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sitofp %arg0 : i32 to f64 + %4 = llvm.select %2, %3, %1 : i1, f64 + llvm.return %4 : f64 + } + llvm.func @t17(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sitofp %arg0 : i32 to f64 + %4 = llvm.select %2, %3, %1 : i1, f64 + llvm.return %4 : f64 + } + llvm.func @fneg_fmax(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.fneg %arg1 : f32 + %2 = llvm.fcmp "ogt" %0, %1 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %0, %1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @fsub_fmax(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fsub %0, %arg0 : vector<2xf32> + %2 = llvm.fsub %0, %arg1 : vector<2xf32> + %3 = llvm.fcmp "uge" %1, %2 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %4 = llvm.select %3, %1, %2 : vector<2xi1>, vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fsub_fmin(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fsub %0, %arg0 : vector<2xf64> + %2 = llvm.fsub %0, %arg1 : vector<2xf64> + %3 = llvm.fcmp "olt" %1, %2 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %4 = llvm.select %3, %1, %2 : vector<2xi1>, vector<2xf64> + llvm.return %4 : vector<2xf64> + } + llvm.func @fneg_fmin(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.fneg %arg1 : f64 + %2 = llvm.fcmp "ule" %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %2, %0, %1 : i1, f64 + llvm.return %3 : f64 + } + llvm.func @maxnum_ogt_fmf_on_select(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "ogt" %arg0, %arg1 : f32 + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @maxnum_oge_fmf_on_select(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fcmp "oge" %arg0, %arg1 : vector<2xf32> + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xi1>, vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @maxnum_ogt_fmf_on_fcmp(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %0, %arg0, %arg1 : i1, f32 + llvm.return %1 : f32 + } + llvm.func @maxnum_oge_fmf_on_fcmp(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %1 = llvm.select %0, %arg0, %arg1 : vector<2xi1>, vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @maxnum_no_nsz(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "ogt" %arg0, %arg1 : f32 + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @maxnum_no_nnan(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "oge" %arg0, %arg1 : f32 + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @minnum_olt_fmf_on_select(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "olt" %arg0, %arg1 : f32 + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @minnum_ole_fmf_on_select(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fcmp "ole" %arg0, %arg1 : vector<2xf32> + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xi1>, vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @minnum_olt_fmf_on_fcmp(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %0, %arg0, %arg1 : i1, f32 + llvm.return %1 : f32 + } + llvm.func @minnum_ole_fmf_on_fcmp(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %1 = llvm.select %0, %arg0, %arg1 : vector<2xi1>, vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @minnum_no_nsz(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "olt" %arg0, %arg1 : f32 + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @minnum_no_nnan(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "ole" %arg0, %arg1 : f32 + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @pr64937_preserve_min_idiom(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(3.276700e+04 : f32) : f32 + %1 = llvm.mlir.constant(6.553600e+04 : f32) : f32 + %2 = llvm.fcmp "olt" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %2, %arg0, %0 {fastmathFlags = #llvm.fastmath} : i1, f32 + %4 = llvm.fmul %3, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/minmax-intrinsics.ll.mlir b/test/LLVMDialect/InstCombine/minmax-intrinsics.ll.mlir new file mode 100644 index 000000000..d88a6bd7c --- /dev/null +++ b/test/LLVMDialect/InstCombine/minmax-intrinsics.ll.mlir @@ -0,0 +1,1518 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g() {addr_space = 0 : i32, alignment = 4 : i64, dso_local} : i32 + llvm.func @use(i8) + llvm.func @use_vec(vector<3xi8>) + llvm.func @umin_known_bits(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.intr.umin(%2, %arg1) : (i8, i8) -> i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @umax_known_bits(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.intr.umax(%1, %arg1) : (i8, i8) -> i8 + %3 = llvm.and %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @smin_known_bits(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.intr.smin(%1, %arg1) : (i8, i8) -> i8 + %3 = llvm.and %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @smax_known_bits(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.intr.smax(%2, %arg1) : (i8, i8) -> i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @smax_sext(%arg0: i5, %arg1: i5) -> i8 { + %0 = llvm.sext %arg0 : i5 to i8 + %1 = llvm.sext %arg1 : i5 to i8 + %2 = llvm.intr.smax(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smin_sext(%arg0: i5, %arg1: i5) -> i8 { + %0 = llvm.sext %arg0 : i5 to i8 + %1 = llvm.sext %arg1 : i5 to i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.intr.smin(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umax_sext(%arg0: i5, %arg1: i5) -> i8 { + %0 = llvm.sext %arg0 : i5 to i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.sext %arg1 : i5 to i8 + %2 = llvm.intr.umax(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin_sext(%arg0: vector<3xi5>, %arg1: vector<3xi5>) -> vector<3xi8> { + %0 = llvm.sext %arg0 : vector<3xi5> to vector<3xi8> + %1 = llvm.sext %arg1 : vector<3xi5> to vector<3xi8> + %2 = llvm.intr.umin(%0, %1) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %2 : vector<3xi8> + } + llvm.func @smax_zext(%arg0: i5, %arg1: i5) -> i8 { + %0 = llvm.zext %arg0 : i5 to i8 + %1 = llvm.zext %arg1 : i5 to i8 + %2 = llvm.intr.smax(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smin_zext(%arg0: i5, %arg1: i5) -> i8 { + %0 = llvm.zext %arg0 : i5 to i8 + %1 = llvm.zext %arg1 : i5 to i8 + %2 = llvm.intr.smin(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umax_zext(%arg0: i5, %arg1: i5) -> i8 { + %0 = llvm.zext %arg0 : i5 to i8 + %1 = llvm.zext %arg1 : i5 to i8 + %2 = llvm.intr.umax(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin_zext(%arg0: i5, %arg1: i5) -> i8 { + %0 = llvm.zext %arg0 : i5 to i8 + %1 = llvm.zext %arg1 : i5 to i8 + %2 = llvm.intr.umin(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin_zext_types(%arg0: i6, %arg1: i5) -> i8 { + %0 = llvm.zext %arg0 : i6 to i8 + %1 = llvm.zext %arg1 : i5 to i8 + %2 = llvm.intr.umin(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin_ext(%arg0: i5, %arg1: i5) -> i8 { + %0 = llvm.sext %arg0 : i5 to i8 + %1 = llvm.zext %arg1 : i5 to i8 + %2 = llvm.intr.umin(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin_zext_uses(%arg0: i5, %arg1: i5) -> i8 { + %0 = llvm.zext %arg0 : i5 to i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.zext %arg1 : i5 to i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.intr.umin(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smax_sext_constant(%arg0: i5) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.sext %arg0 : i5 to i8 + %2 = llvm.intr.smax(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smax_sext_constant_big(%arg0: i5) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.sext %arg0 : i5 to i8 + %2 = llvm.intr.smax(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smax_zext_constant(%arg0: i5) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.zext %arg0 : i5 to i8 + %2 = llvm.intr.smax(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smin_sext_constant(%arg0: vector<3xi5>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[7, 15, -16]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.sext %arg0 : vector<3xi5> to vector<3xi8> + %2 = llvm.intr.smin(%1, %0) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %2 : vector<3xi8> + } + llvm.func @smin_zext_constant(%arg0: i5) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.zext %arg0 : i5 to i8 + %2 = llvm.intr.smin(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umax_sext_constant(%arg0: i5) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.sext %arg0 : i5 to i8 + %2 = llvm.intr.umax(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umax_sext_constant_big(%arg0: i5) -> i8 { + %0 = llvm.mlir.constant(126 : i8) : i8 + %1 = llvm.sext %arg0 : i5 to i8 + %2 = llvm.intr.umax(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umax_zext_constant(%arg0: vector<3xi5>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[7, 15, 31]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.zext %arg0 : vector<3xi5> to vector<3xi8> + %2 = llvm.intr.umax(%1, %0) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %2 : vector<3xi8> + } + llvm.func @umax_zext_constant_big(%arg0: i5) -> i8 { + %0 = llvm.mlir.constant(126 : i8) : i8 + %1 = llvm.zext %arg0 : i5 to i8 + %2 = llvm.intr.umax(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin_sext_constant(%arg0: i5) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.sext %arg0 : i5 to i8 + %2 = llvm.intr.umin(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin_sext_constant_big(%arg0: i5) -> i8 { + %0 = llvm.mlir.constant(126 : i8) : i8 + %1 = llvm.sext %arg0 : i5 to i8 + %2 = llvm.intr.umin(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin_zext_constant(%arg0: i5) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.zext %arg0 : i5 to i8 + %2 = llvm.intr.umin(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin_zext_constant_big(%arg0: i5) -> i8 { + %0 = llvm.mlir.constant(126 : i8) : i8 + %1 = llvm.zext %arg0 : i5 to i8 + %2 = llvm.intr.umin(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin_zext_constant_uses(%arg0: i5) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.zext %arg0 : i5 to i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.intr.umin(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smax_of_nots(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.intr.smax(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @smin_of_nots(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.undef : vector<3xi8> + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<3xi8> + %12 = llvm.mlir.constant(1 : i32) : i32 + %13 = llvm.insertelement %0, %11[%12 : i32] : vector<3xi8> + %14 = llvm.mlir.constant(2 : i32) : i32 + %15 = llvm.insertelement %1, %13[%14 : i32] : vector<3xi8> + %16 = llvm.xor %arg0, %8 : vector<3xi8> + %17 = llvm.xor %arg1, %15 : vector<3xi8> + %18 = llvm.intr.smin(%16, %17) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %18 : vector<3xi8> + } + llvm.func @umax_of_nots(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.intr.umax(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @umin_of_nots(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.intr.umin(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @umin_of_nots_uses(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.intr.umin(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @smax_of_not_and_const(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(42 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.intr.smax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @smin_of_not_and_const(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(43 : i8) : i8 + %10 = llvm.mlir.constant(42 : i8) : i8 + %11 = llvm.mlir.undef : vector<3xi8> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.insertelement %10, %11[%12 : i32] : vector<3xi8> + %14 = llvm.mlir.constant(1 : i32) : i32 + %15 = llvm.insertelement %0, %13[%14 : i32] : vector<3xi8> + %16 = llvm.mlir.constant(2 : i32) : i32 + %17 = llvm.insertelement %9, %15[%16 : i32] : vector<3xi8> + %18 = llvm.xor %arg0, %8 : vector<3xi8> + %19 = llvm.intr.smin(%17, %18) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %19 : vector<3xi8> + } + llvm.func @umax_of_not_and_const(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(44 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.intr.umax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @umin_of_not_and_const(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(-45 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.intr.umin(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @umin_of_not_and_smax(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.xor %arg2, %0 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.intr.smax(%2, %3) : (i8, i8) -> i8 + %5 = llvm.intr.umin(%4, %1) : (i8, i8) -> i8 + llvm.return %5 : i8 + } + llvm.func @smin_of_umax_and_not(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.xor %arg2, %0 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.intr.umax(%2, %3) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%1, %4) : (i8, i8) -> i8 + llvm.return %5 : i8 + } + llvm.func @umin_of_not_and_nontrivial_const(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.addressof @umin_of_not_and_nontrivial_const : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.intr.umin(%2, %3) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @umin_of_not_and_const_uses(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(-45 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.intr.umin(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @not_smax_of_nots(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.intr.smax(%1, %2) : (i8, i8) -> i8 + %4 = llvm.xor %3, %0 : i8 + llvm.return %4 : i8 + } + llvm.func @not_smin_of_nots(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.xor %3, %0 : i8 + llvm.return %4 : i8 + } + llvm.func @not_umax_of_not(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.intr.umax(%1, %arg1) : (i8, i8) -> i8 + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @not_umin_of_not(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.intr.umin(%1, %arg1) : (i8, i8) -> i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @not_umin_of_not_constant_op(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(42 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.intr.umin(%2, %1) : (i8, i8) -> i8 + %4 = llvm.xor %3, %0 : i8 + llvm.return %4 : i8 + } + llvm.func @smax_negation(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.sub %arg1, %arg0 : i8 + %2 = llvm.intr.smax(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smax_negation_nsw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 overflow : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + %2 = llvm.intr.smax(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smax_negation_not_nsw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 overflow : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + %2 = llvm.intr.smax(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smax_negation_vec(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.sub %8, %arg0 : vector<3xi8> + %10 = llvm.intr.smax(%arg0, %9) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %10 : vector<3xi8> + } + llvm.func @smin_negation(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.sub %arg1, %arg0 : i8 + %2 = llvm.intr.smin(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umax_negation(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 overflow : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + %2 = llvm.intr.umax(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin_negation(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.intr.umin(%1, %arg0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smax_negation_uses(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.sub %arg1, %arg0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.intr.smax(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @clamp_two_vals_smax_smin(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(43 : i8) : i8 + %2 = llvm.intr.smax(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.smin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @clamp_two_vals_smin_smax(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<42> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(dense<41> : vector<3xi8>) : vector<3xi8> + %2 = llvm.intr.smin(%arg0, %0) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + %3 = llvm.intr.smax(%2, %1) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @clamp_two_vals_umax_umin(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(43 : i8) : i8 + %2 = llvm.intr.umax(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.umin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @clamp_two_vals_umin_umax(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(41 : i8) : i8 + %2 = llvm.intr.umin(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.umax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @clamp_two_vals_smax_umin(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(43 : i8) : i8 + %2 = llvm.intr.smax(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.umin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @clamp_three_vals_smax_smin(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(44 : i8) : i8 + %2 = llvm.intr.smax(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.smin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @clamp_two_vals_umax_umin_edge(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.intr.umax(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.umin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @clamp_two_vals_umin_umax_edge(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.intr.umin(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.umax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @clamp_two_vals_smax_smin_edge(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.intr.smax(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.smin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @clamp_two_vals_smin_smax_edge(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.intr.smin(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.smax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @umin_non_zero_idiom1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.intr.umin(%arg0, %0) : (i8, i8) -> i8 + llvm.return %1 : i8 + } + llvm.func @umin_non_zero_idiom2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.intr.umin(%0, %arg0) : (i8, i8) -> i8 + llvm.return %1 : i8 + } + llvm.func @umin_non_zero_idiom3(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<3xi8>) : vector<3xi8> + %1 = llvm.intr.umin(%arg0, %0) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %1 : vector<3xi8> + } + llvm.func @umin_non_zero_idiom4(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.intr.umin(%arg0, %8) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %9 : vector<3xi8> + } + llvm.func @umin_eq_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.umin(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @umin_eq_zero2(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<3xi8>) : vector<3xi8> + %2 = llvm.intr.umin(%arg0, %arg1) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + %3 = llvm.icmp "eq" %2, %1 : vector<3xi8> + llvm.return %3 : vector<3xi1> + } + llvm.func @umin_ne_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.umin(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @umin_ne_zero2(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<3xi8>) : vector<3xi8> + %2 = llvm.intr.umin(%arg0, %arg1) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + %3 = llvm.icmp "ne" %2, %1 : vector<3xi8> + llvm.return %3 : vector<3xi1> + } + llvm.func @smax(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.intr.smax(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.intr.smax(%arg0, %arg2) : (i8, i8) -> i8 + %2 = llvm.intr.smax(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smin(%arg0: vector<3xi8>, %arg1: vector<3xi8>, %arg2: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.intr.smin(%arg1, %arg0) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + %1 = llvm.intr.smin(%arg0, %arg2) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + %2 = llvm.intr.smin(%0, %1) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %2 : vector<3xi8> + } + llvm.func @umax(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.intr.umax(%arg0, %arg1) : (i8, i8) -> i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.intr.umax(%arg2, %arg0) : (i8, i8) -> i8 + %2 = llvm.intr.umax(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.intr.umin(%arg1, %arg0) : (i8, i8) -> i8 + %1 = llvm.intr.umin(%arg2, %arg0) : (i8, i8) -> i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.intr.umin(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smax_uses(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.intr.smax(%arg0, %arg1) : (i8, i8) -> i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.intr.smax(%arg0, %arg2) : (i8, i8) -> i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.intr.smax(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smax_no_common_op(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.intr.smax(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.intr.smax(%arg3, %arg2) : (i8, i8) -> i8 + %2 = llvm.intr.smax(%0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umax_demand_lshr(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.intr.umax(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.lshr %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @umax_demand_and(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.intr.umax(%0, %arg0) : (i8, i8) -> i8 + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @umin_demand_or_31_30(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-30 : i8) : i8 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.intr.umin(%0, %arg0) : (i8, i8) -> i8 + %3 = llvm.or %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @umin_demand_and_7_8(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-7 : i8) : i8 + %1 = llvm.mlir.constant(-8 : i8) : i8 + %2 = llvm.intr.umin(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.and %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @neg_neg_nsw_smax(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.sub %0, %arg1 overflow : i8 + %3 = llvm.intr.smax(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @neg_neg_nsw_smin(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<3xi8>) : vector<3xi8> + %2 = llvm.sub %1, %arg0 overflow : vector<3xi8> + %3 = llvm.sub %1, %arg1 overflow : vector<3xi8> + %4 = llvm.intr.smin(%2, %3) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %4 : vector<3xi8> + } + llvm.func @neg_neg_nsw_smax_use0(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.sub %0, %arg1 overflow : i8 + %3 = llvm.intr.smax(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @neg_neg_nsw_smin_use1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.sub %0, %arg1 overflow : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @neg_neg_nsw_smin_use2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.sub %0, %arg1 overflow : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @neg_neg_smax(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.sub %0, %arg1 overflow : i8 + %3 = llvm.intr.smax(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @neg_neg_smin(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.sub %0, %arg1 overflow : i8 + %3 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @neg_neg_nsw_umin(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 overflow : i8 + %2 = llvm.sub %0, %arg1 overflow : i8 + %3 = llvm.intr.umin(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @freeToInvertSub(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + llvm.call @use(%1) : (i8) -> () + llvm.call @use(%2) : (i8) -> () + llvm.call @use(%3) : (i8) -> () + %4 = llvm.intr.umax(%1, %2) : (i8, i8) -> i8 + %5 = llvm.sub %3, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @freeToInvertSub_uses(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + llvm.call @use(%1) : (i8) -> () + llvm.call @use(%2) : (i8) -> () + llvm.call @use(%3) : (i8) -> () + %4 = llvm.intr.umax(%1, %2) : (i8, i8) -> i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.sub %3, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @freeToInvert(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + llvm.call @use(%1) : (i8) -> () + llvm.call @use(%2) : (i8) -> () + llvm.call @use(%3) : (i8) -> () + %4 = llvm.intr.umax(%1, %2) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%4, %3) : (i8, i8) -> i8 + %6 = llvm.xor %5, %0 : i8 + llvm.return %6 : i8 + } + llvm.func @freeToInvert_use1(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + llvm.call @use(%1) : (i8) -> () + llvm.call @use(%2) : (i8) -> () + llvm.call @use(%3) : (i8) -> () + %4 = llvm.intr.umax(%1, %2) : (i8, i8) -> i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.intr.smin(%4, %3) : (i8, i8) -> i8 + %6 = llvm.xor %5, %0 : i8 + llvm.return %6 : i8 + } + llvm.func @freeToInvert_use2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + llvm.call @use(%1) : (i8) -> () + llvm.call @use(%2) : (i8) -> () + llvm.call @use(%3) : (i8) -> () + %4 = llvm.intr.umax(%1, %2) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%4, %3) : (i8, i8) -> i8 + llvm.call @use(%5) : (i8) -> () + %6 = llvm.xor %5, %0 : i8 + llvm.return %6 : i8 + } + llvm.func @freeToInvert_use3(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + llvm.call @use(%1) : (i8) -> () + llvm.call @use(%2) : (i8) -> () + llvm.call @use(%3) : (i8) -> () + %4 = llvm.intr.umax(%1, %2) : (i8, i8) -> i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.intr.smin(%4, %3) : (i8, i8) -> i8 + llvm.call @use(%5) : (i8) -> () + %6 = llvm.xor %5, %0 : i8 + llvm.return %6 : i8 + } + llvm.func @freeToInvert_two_minmax_ops(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.xor %arg3, %0 : i8 + llvm.call @use(%1) : (i8) -> () + llvm.call @use(%2) : (i8) -> () + llvm.call @use(%3) : (i8) -> () + llvm.call @use(%4) : (i8) -> () + %5 = llvm.intr.umax(%1, %2) : (i8, i8) -> i8 + %6 = llvm.intr.smax(%4, %3) : (i8, i8) -> i8 + %7 = llvm.intr.smin(%5, %6) : (i8, i8) -> i8 + %8 = llvm.xor %7, %0 : i8 + llvm.return %8 : i8 + } + llvm.func @freeToInvert_two_minmax_ops_use1(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.xor %arg3, %0 : i8 + llvm.call @use(%1) : (i8) -> () + llvm.call @use(%2) : (i8) -> () + llvm.call @use(%3) : (i8) -> () + llvm.call @use(%4) : (i8) -> () + %5 = llvm.intr.umax(%1, %2) : (i8, i8) -> i8 + llvm.call @use(%5) : (i8) -> () + %6 = llvm.intr.smax(%4, %3) : (i8, i8) -> i8 + %7 = llvm.intr.smin(%5, %6) : (i8, i8) -> i8 + %8 = llvm.xor %7, %0 : i8 + llvm.return %8 : i8 + } + llvm.func @freeToInvert_two_minmax_ops_use2(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.xor %arg3, %0 : i8 + llvm.call @use(%1) : (i8) -> () + llvm.call @use(%2) : (i8) -> () + llvm.call @use(%3) : (i8) -> () + llvm.call @use(%4) : (i8) -> () + %5 = llvm.intr.umax(%1, %2) : (i8, i8) -> i8 + %6 = llvm.intr.smax(%4, %3) : (i8, i8) -> i8 + llvm.call @use(%6) : (i8) -> () + %7 = llvm.intr.smin(%5, %6) : (i8, i8) -> i8 + %8 = llvm.xor %7, %0 : i8 + llvm.return %8 : i8 + } + llvm.func @freeToInvert_two_minmax_ops_use3(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.xor %arg3, %0 : i8 + llvm.call @use(%1) : (i8) -> () + llvm.call @use(%2) : (i8) -> () + llvm.call @use(%3) : (i8) -> () + llvm.call @use(%4) : (i8) -> () + %5 = llvm.intr.umax(%1, %2) : (i8, i8) -> i8 + llvm.call @use(%5) : (i8) -> () + %6 = llvm.intr.smax(%4, %3) : (i8, i8) -> i8 + llvm.call @use(%6) : (i8) -> () + %7 = llvm.intr.smin(%5, %6) : (i8, i8) -> i8 + %8 = llvm.xor %7, %0 : i8 + llvm.return %8 : i8 + } + llvm.func @sub_not_min_max(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.xor %arg2, %0 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%4, %3) : (i8, i8) -> i8 + %6 = llvm.sub %1, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @sub_not_min_max_uses1(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.xor %arg2, %0 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%4, %3) : (i8, i8) -> i8 + %6 = llvm.sub %1, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @sub_not_min_max_uses2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.xor %arg2, %0 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.intr.smin(%4, %3) : (i8, i8) -> i8 + %6 = llvm.sub %1, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @use4(i8, i8, i8, i8) + llvm.func @cmyk(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%4, %3) : (i8, i8) -> i8 + %6 = llvm.sub %1, %5 : i8 + %7 = llvm.sub %2, %5 : i8 + %8 = llvm.sub %3, %5 : i8 + llvm.call @use4(%6, %7, %8, %5) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk_commute1(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%3, %4) : (i8, i8) -> i8 + %6 = llvm.sub %1, %5 : i8 + %7 = llvm.sub %2, %5 : i8 + %8 = llvm.sub %3, %5 : i8 + llvm.call @use4(%6, %7, %8, %5) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk_commute2(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.intr.smin(%2, %1) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%3, %4) : (i8, i8) -> i8 + %6 = llvm.sub %1, %5 : i8 + %7 = llvm.sub %2, %5 : i8 + %8 = llvm.sub %3, %5 : i8 + llvm.call @use4(%6, %7, %8, %5) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk_commute3(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.intr.smin(%2, %1) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%4, %3) : (i8, i8) -> i8 + %6 = llvm.sub %1, %5 : i8 + %7 = llvm.sub %2, %5 : i8 + %8 = llvm.sub %3, %5 : i8 + llvm.call @use4(%6, %7, %8, %5) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk_commute4(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.intr.smin(%2, %1) : (i8, i8) -> i8 + %5 = llvm.intr.umin(%4, %3) : (i8, i8) -> i8 + %6 = llvm.sub %3, %5 : i8 + %7 = llvm.sub %1, %5 : i8 + %8 = llvm.sub %2, %5 : i8 + llvm.call @use4(%7, %8, %6, %5) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk_commute5(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.intr.smax(%2, %1) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%4, %3) : (i8, i8) -> i8 + %6 = llvm.sub %1, %5 : i8 + %7 = llvm.sub %3, %5 : i8 + %8 = llvm.sub %2, %5 : i8 + llvm.call @use4(%6, %8, %7, %5) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk_commute6(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%4, %3) : (i8, i8) -> i8 + %6 = llvm.sub %5, %1 : i8 + %7 = llvm.sub %5, %2 : i8 + %8 = llvm.sub %5, %3 : i8 + llvm.call @use4(%6, %7, %8, %5) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk_commute7(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%3, %4) : (i8, i8) -> i8 + %6 = llvm.sub %5, %1 : i8 + %7 = llvm.sub %5, %2 : i8 + %8 = llvm.sub %5, %3 : i8 + llvm.call @use4(%6, %7, %8, %5) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk_commute8(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.intr.smin(%2, %1) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%3, %4) : (i8, i8) -> i8 + %6 = llvm.sub %5, %1 : i8 + %7 = llvm.sub %5, %2 : i8 + %8 = llvm.sub %5, %3 : i8 + llvm.call @use4(%6, %7, %8, %5) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk_commute9(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.intr.smin(%2, %1) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%4, %3) : (i8, i8) -> i8 + %6 = llvm.sub %5, %1 : i8 + %7 = llvm.sub %5, %2 : i8 + %8 = llvm.sub %5, %3 : i8 + llvm.call @use4(%6, %7, %8, %5) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk_commute10(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.intr.smin(%2, %1) : (i8, i8) -> i8 + %5 = llvm.intr.umin(%4, %3) : (i8, i8) -> i8 + %6 = llvm.sub %3, %5 : i8 + %7 = llvm.sub %5, %1 : i8 + %8 = llvm.sub %2, %5 : i8 + llvm.call @use4(%7, %8, %6, %5) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @cmyk_commute11(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.intr.smax(%2, %1) : (i8, i8) -> i8 + %5 = llvm.intr.smin(%4, %3) : (i8, i8) -> i8 + %6 = llvm.sub %1, %5 : i8 + %7 = llvm.sub %5, %3 : i8 + %8 = llvm.sub %5, %2 : i8 + llvm.call @use4(%6, %8, %7, %5) : (i8, i8, i8, i8) -> () + llvm.return + } + llvm.func @smax_offset(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(-124 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.intr.smax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @smax_offset_limit(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(-125 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.intr.smax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @smax_offset_overflow(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(-126 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.intr.smax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @smax_offset_may_wrap(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(-124 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.intr.smax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @smax_offset_uses(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(-124 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.intr.smax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @smin_offset(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<124> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(dense<-3> : vector<3xi8>) : vector<3xi8> + %2 = llvm.add %arg0, %0 overflow : vector<3xi8> + %3 = llvm.intr.smin(%2, %1) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @smin_offset_limit(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(125 : i8) : i8 + %1 = llvm.mlir.constant(-3 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.intr.smin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @smin_offset_overflow(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(126 : i8) : i8 + %1 = llvm.mlir.constant(-3 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.intr.smin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @smin_offset_may_wrap(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(124 : i8) : i8 + %1 = llvm.mlir.constant(-3 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.intr.smin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @smin_offset_uses(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(124 : i8) : i8 + %1 = llvm.mlir.constant(-3 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.intr.smin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @umax_offset(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<127> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(dense<-126> : vector<3xi8>) : vector<3xi8> + %2 = llvm.add %arg0, %0 overflow : vector<3xi8> + %3 = llvm.intr.umax(%2, %1) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @umax_offset_limit(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.add %arg0, %0 overflow : i8 + %2 = llvm.intr.umax(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umax_offset_overflow(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.intr.umax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @umax_offset_may_wrap(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.intr.umax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @umax_offset_uses(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.intr.umax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @umin_offset(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-5 : i8) : i8 + %1 = llvm.mlir.constant(-4 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.intr.umin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @umin_offset_limit(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-4 : i8) : i8 + %1 = llvm.add %arg0, %0 overflow : i8 + %2 = llvm.intr.umin(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin_offset_overflow(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-3 : i8) : i8 + %1 = llvm.mlir.constant(-4 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.intr.umin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @umin_offset_may_wrap(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-5 : i8) : i8 + %1 = llvm.mlir.constant(-4 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.intr.umin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @umin_offset_uses(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-5 : i8) : i8 + %1 = llvm.mlir.constant(-4 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.intr.umin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @umax_vector_splat_poison(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(64 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(dense<[13, -126, -126]> : vector<3xi8>) : vector<3xi8> + %10 = llvm.add %arg0, %8 overflow : vector<3xi8> + %11 = llvm.intr.umax(%10, %9) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %11 : vector<3xi8> + } + llvm.func @smax_offset_simplify(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(50 : i8) : i8 + %1 = llvm.mlir.constant(-124 : i8) : i8 + %2 = llvm.add %0, %arg0 overflow : i8 + %3 = llvm.intr.smax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @smax_smax_reassoc_constants(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[42, 43, 44]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(dense<[43, -43, 0]> : vector<3xi8>) : vector<3xi8> + %2 = llvm.intr.smax(%arg0, %0) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + %3 = llvm.intr.smax(%2, %1) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @smin_smin_reassoc_constants(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(97 : i8) : i8 + %1 = llvm.mlir.constant(-3 : i8) : i8 + %2 = llvm.intr.smin(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @umax_umax_reassoc_constants(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[42, 43, 44]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(-113 : i8) : i8 + %3 = llvm.mlir.constant(43 : i8) : i8 + %4 = llvm.mlir.undef : vector<3xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<3xi8> + %11 = llvm.intr.umax(%arg0, %0) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + %12 = llvm.intr.umax(%11, %10) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %12 : vector<3xi8> + } + llvm.func @umin_umin_reassoc_constants(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-116 : i8) : i8 + %1 = llvm.mlir.constant(42 : i8) : i8 + %2 = llvm.intr.umin(%0, %arg0) : (i8, i8) -> i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.intr.umin(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @smin_smax_reassoc_constants(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(97 : i8) : i8 + %1 = llvm.mlir.constant(-3 : i8) : i8 + %2 = llvm.intr.smin(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.smax(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @smax_smax_reassoc_constant(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.intr.smax(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.intr.smax(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smin_smin_reassoc_constant(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[43, -43, 0]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.intr.smin(%arg0, %arg1) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + %2 = llvm.intr.smin(%1, %0) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %2 : vector<3xi8> + } + llvm.func @umax_umax_reassoc_constant(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.intr.umax(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.intr.umax(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin_umin_reassoc_constant(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[43, -43, 0]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.intr.umin(%arg0, %arg1) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + %2 = llvm.intr.umin(%1, %0) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %2 : vector<3xi8> + } + llvm.func @umin_umin_reassoc_constant_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.intr.umin(%arg0, %arg1) : (i8, i8) -> i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.intr.umin(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smax_smax_reassoc_constant_sink(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.intr.smax(%arg0, %0) : (i8, i8) -> i8 + %2 = llvm.intr.smax(%1, %arg1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smin_smin_reassoc_constant_sink(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[43, -43, 0]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.intr.smin(%arg0, %0) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + %2 = llvm.intr.smin(%1, %arg1) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %2 : vector<3xi8> + } + llvm.func @umax_umax_reassoc_constant_sink(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.intr.umax(%arg0, %0) : (i8, i8) -> i8 + %2 = llvm.intr.umax(%1, %arg1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umin_umin_reassoc_constant_sink(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[43, -43, 0]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.intr.umin(%arg0, %0) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + %2 = llvm.intr.umin(%1, %arg1) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %2 : vector<3xi8> + } + llvm.func @umin_umin_reassoc_constant_sink_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.intr.umin(%arg0, %0) : (i8, i8) -> i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.intr.umin(%1, %arg1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smax_smax_smax_reassoc_constants(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(126 : i8) : i8 + %2 = llvm.intr.smax(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.smax(%arg1, %2) : (i8, i8) -> i8 + %4 = llvm.intr.smax(%3, %1) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @smax_smax_smax_reassoc_constants_swap(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(126 : i8) : i8 + %2 = llvm.intr.smax(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.smax(%2, %arg1) : (i8, i8) -> i8 + %4 = llvm.intr.smax(%3, %1) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @smin_smin_smin_reassoc_constants(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(126 : i8) : i8 + %2 = llvm.intr.smin(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.smin(%arg1, %2) : (i8, i8) -> i8 + %4 = llvm.intr.smin(%3, %1) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @umax_umax_reassoc_constantexpr_sink(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.addressof @umax_umax_reassoc_constantexpr_sink : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i8 + %3 = llvm.intr.umax(%arg0, %0) : (i8, i8) -> i8 + %4 = llvm.intr.umax(%3, %2) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @smax_unary_shuffle_ops(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.poison : vector<3xi8> + %1 = llvm.shufflevector %arg0, %0 [1, 0, 2] : vector<3xi8> + %2 = llvm.shufflevector %arg1, %0 [1, 0, 2] : vector<3xi8> + %3 = llvm.intr.smax(%1, %2) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @smin_unary_shuffle_ops_use_poison_mask_elt(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.poison : vector<3xi8> + %1 = llvm.shufflevector %arg0, %0 [-1, 0, 2] : vector<3xi8> + llvm.call @use_vec(%1) : (vector<3xi8>) -> () + %2 = llvm.shufflevector %arg1, %0 [-1, 0, 2] : vector<3xi8> + %3 = llvm.intr.smin(%1, %2) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @umax_unary_shuffle_ops_use_widening(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<3xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.shufflevector %arg0, %0 [1, 0, 0] : vector<2xi8> + %2 = llvm.shufflevector %arg1, %0 [1, 0, 0] : vector<2xi8> + llvm.call @use_vec(%2) : (vector<3xi8>) -> () + %3 = llvm.intr.umax(%1, %2) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @umin_unary_shuffle_ops_narrowing(%arg0: vector<4xi8>, %arg1: vector<4xi8>) -> vector<3xi8> { + %0 = llvm.mlir.poison : vector<4xi8> + %1 = llvm.shufflevector %arg0, %0 [1, 0, 3] : vector<4xi8> + %2 = llvm.shufflevector %arg1, %0 [1, 0, 3] : vector<4xi8> + %3 = llvm.intr.umin(%1, %2) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @smax_unary_shuffle_ops_unshuffled_op(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.poison : vector<3xi8> + %1 = llvm.shufflevector %arg0, %0 [0, 0, 2] : vector<3xi8> + %2 = llvm.intr.smax(%1, %arg1) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %2 : vector<3xi8> + } + llvm.func @smax_unary_shuffle_ops_wrong_mask(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.poison : vector<3xi8> + %1 = llvm.shufflevector %arg0, %0 [0, 0, 2] : vector<3xi8> + %2 = llvm.shufflevector %arg1, %0 [1, 0, 2] : vector<3xi8> + %3 = llvm.intr.smax(%1, %2) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @smax_unary_shuffle_ops_wrong_shuf(%arg0: vector<3xi8>, %arg1: vector<3xi8>, %arg2: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.shufflevector %arg0, %arg2 [1, 0, 3] : vector<3xi8> + %1 = llvm.shufflevector %arg1, %arg2 [1, 0, 3] : vector<3xi8> + %2 = llvm.intr.smax(%0, %1) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %2 : vector<3xi8> + } + llvm.func @smin_unary_shuffle_ops_uses(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.poison : vector<3xi8> + %1 = llvm.shufflevector %arg0, %0 [1, 0, 2] : vector<3xi8> + llvm.call @use_vec(%1) : (vector<3xi8>) -> () + %2 = llvm.shufflevector %arg1, %0 [1, 0, 2] : vector<3xi8> + llvm.call @use_vec(%2) : (vector<3xi8>) -> () + %3 = llvm.intr.smin(%1, %2) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @PR57986() -> i1 { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i1 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.intr.umin(%1, %2) : (i1, i1) -> i1 + llvm.return %3 : i1 + } + llvm.func @fold_umax_with_knownbits_info(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.shl %arg1, %0 : i8 + %3 = llvm.sub %1, %2 : i8 + %4 = llvm.intr.umax(%3, %0) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @fold_umax_with_knownbits_info_poison_in_splat(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.poison : i8 + %3 = llvm.mlir.undef : vector<3xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi8> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi8> + %10 = llvm.or %arg0, %0 : vector<3xi8> + %11 = llvm.shl %arg1, %0 : vector<3xi8> + %12 = llvm.sub %10, %11 : vector<3xi8> + %13 = llvm.intr.umax(%12, %9) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %13 : vector<3xi8> + } + llvm.func @fold_umin_with_knownbits_info(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.shl %arg1, %1 : i8 + %4 = llvm.sub %2, %3 : i8 + %5 = llvm.intr.umin(%4, %0) : (i8, i8) -> i8 + llvm.return %5 : i8 + } + llvm.func @fold_umin_with_knownbits_info_poison_in_splat(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(dense<2> : vector<3xi8>) : vector<3xi8> + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.mlir.poison : i8 + %4 = llvm.mlir.undef : vector<3xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %2, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %3, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %2, %8[%9 : i32] : vector<3xi8> + %11 = llvm.or %arg0, %0 : vector<3xi8> + %12 = llvm.shl %arg1, %1 : vector<3xi8> + %13 = llvm.sub %11, %12 : vector<3xi8> + %14 = llvm.intr.umin(%13, %10) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %14 : vector<3xi8> + } + llvm.func @fold_umax_with_knownbits_info_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.shl %arg1, %1 : i8 + %4 = llvm.sub %2, %3 : i8 + %5 = llvm.intr.umax(%4, %1) : (i8, i8) -> i8 + llvm.return %5 : i8 + } + llvm.func @fold_umin_with_knownbits_info_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.or %arg0, %0 : i8 + %4 = llvm.shl %arg1, %1 : i8 + %5 = llvm.sub %3, %4 : i8 + %6 = llvm.intr.umin(%5, %2) : (i8, i8) -> i8 + llvm.return %6 : i8 + } + llvm.func @test_umax_and(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.intr.umax(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_umin_and(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.intr.umin(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_smax_and(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.intr.smax(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_smin_and(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_smin_and_mismatch(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.mlir.constant(-32 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.intr.smin(%2, %3) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @test_smin_and_non_negated_pow2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(31 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_smin_and_multiuse(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(31 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.and %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/minmax-of-minmax.ll.mlir b/test/LLVMDialect/InstCombine/minmax-of-minmax.ll.mlir new file mode 100644 index 000000000..287948c9c --- /dev/null +++ b/test/LLVMDialect/InstCombine/minmax-of-minmax.ll.mlir @@ -0,0 +1,182 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @smax_of_smax_smin_commute0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "slt" %arg1, %arg0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "sgt" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @smax_of_smax_smin_commute1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "sgt" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @smax_of_smax_smin_commute2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "slt" %arg1, %arg0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "slt" %1, %3 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @smax_of_smax_smin_commute3(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.icmp "sgt" %arg0, %arg1 : vector<2xi32> + %1 = llvm.select %0, %arg1, %arg0 : vector<2xi1>, vector<2xi32> + %2 = llvm.icmp "sgt" %arg0, %arg1 : vector<2xi32> + %3 = llvm.select %2, %arg0, %arg1 : vector<2xi1>, vector<2xi32> + %4 = llvm.icmp "slt" %1, %3 : vector<2xi32> + %5 = llvm.select %4, %3, %1 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @smin_of_smin_smax_commute0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "sgt" %arg1, %arg0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "sgt" %1, %3 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @smin_of_smin_smax_commute1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "slt" %arg0, %arg1 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "sgt" %1, %3 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @smin_of_smin_smax_commute2(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.icmp "sgt" %arg0, %arg1 : vector<2xi32> + %1 = llvm.select %0, %arg0, %arg1 : vector<2xi1>, vector<2xi32> + %2 = llvm.icmp "slt" %arg0, %arg1 : vector<2xi32> + %3 = llvm.select %2, %arg0, %arg1 : vector<2xi1>, vector<2xi32> + %4 = llvm.icmp "slt" %3, %1 : vector<2xi32> + %5 = llvm.select %4, %3, %1 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @smin_of_smin_smax_commute3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "sgt" %arg1, %arg0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @umax_of_umax_umin_commute0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "ult" %arg1, %arg0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "ugt" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @umax_of_umax_umin_commute1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "ugt" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @umax_of_umax_umin_commute2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "ult" %arg1, %arg0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "ult" %1, %3 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @umax_of_umax_umin_commute3(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.icmp "ugt" %arg0, %arg1 : vector<2xi32> + %1 = llvm.select %0, %arg1, %arg0 : vector<2xi1>, vector<2xi32> + %2 = llvm.icmp "ugt" %arg0, %arg1 : vector<2xi32> + %3 = llvm.select %2, %arg0, %arg1 : vector<2xi1>, vector<2xi32> + %4 = llvm.icmp "ult" %1, %3 : vector<2xi32> + %5 = llvm.select %4, %3, %1 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @umin_of_umin_umax_commute0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "ugt" %1, %3 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @umin_of_umin_umax_commute1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "ult" %arg0, %arg1 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "ugt" %1, %3 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @umin_of_umin_umax_commute2(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.icmp "ugt" %arg0, %arg1 : vector<2xi32> + %1 = llvm.select %0, %arg0, %arg1 : vector<2xi1>, vector<2xi32> + %2 = llvm.icmp "ult" %arg0, %arg1 : vector<2xi32> + %3 = llvm.select %2, %arg0, %arg1 : vector<2xi1>, vector<2xi32> + %4 = llvm.icmp "ult" %3, %1 : vector<2xi32> + %5 = llvm.select %4, %3, %1 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @umin_of_umin_umax_commute3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "ult" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @umin_of_smin_umax_wrong_pattern(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "sgt" %arg1, %arg0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "ugt" %1, %3 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @smin_of_umin_umax_wrong_pattern2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "ult" %arg0, %arg1 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "sgt" %1, %3 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @umin_of_umin_umax_wrong_operand(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.icmp "ugt" %arg0, %arg1 : vector<2xi32> + %1 = llvm.select %0, %arg0, %arg1 : vector<2xi1>, vector<2xi32> + %2 = llvm.icmp "ult" %arg0, %arg2 : vector<2xi32> + %3 = llvm.select %2, %arg0, %arg2 : vector<2xi1>, vector<2xi32> + %4 = llvm.icmp "ult" %3, %1 : vector<2xi32> + %5 = llvm.select %4, %3, %1 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @umin_of_umin_umax_wrong_operand2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.icmp "ult" %arg0, %arg2 : i32 + %1 = llvm.select %0, %arg2, %arg0 : i1, i32 + %2 = llvm.icmp "ugt" %arg1, %arg0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, i32 + %4 = llvm.icmp "ult" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/minmax-of-xor-x.ll.mlir b/test/LLVMDialect/InstCombine/minmax-of-xor-x.ll.mlir new file mode 100644 index 000000000..c14bbdf5d --- /dev/null +++ b/test/LLVMDialect/InstCombine/minmax-of-xor-x.ll.mlir @@ -0,0 +1,101 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @barrier() + llvm.func @umax_xor_Cpow2(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg0, %0 : vector<2xi8> + %2 = llvm.intr.umax(%arg0, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @umin_xor_Cpow2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(64 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.intr.umin(%arg0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smax_xor_Cpow2_pos(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(32 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.intr.smax(%arg0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @smin_xor_Cpow2_pos(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg0, %0 : vector<2xi8> + %2 = llvm.intr.smin(%arg0, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @smax_xor_Cpow2_neg(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg0, %0 : vector<2xi8> + %2 = llvm.intr.smax(%arg0, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @smin_xor_Cpow2_neg(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.intr.smin(%arg0, %1) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @umax_xor_pow2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + %2 = llvm.and %arg1, %1 : i8 + %3 = llvm.xor %arg0, %2 : i8 + %4 = llvm.intr.umax(%arg0, %3) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @umin_xor_pow2(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.sub %1, %arg1 : vector<2xi8> + %3 = llvm.and %arg1, %2 : vector<2xi8> + %4 = llvm.xor %arg0, %3 : vector<2xi8> + %5 = llvm.intr.umin(%arg0, %4) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @smax_xor_pow2_unk(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + %2 = llvm.and %arg1, %1 : i8 + %3 = llvm.xor %arg0, %2 : i8 + %4 = llvm.intr.smax(%arg0, %3) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @smin_xor_pow2_unk(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.sub %1, %arg1 : vector<2xi8> + %3 = llvm.and %arg1, %2 : vector<2xi8> + %4 = llvm.xor %arg0, %3 : vector<2xi8> + %5 = llvm.intr.smin(%arg0, %4) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @smax_xor_pow2_neg(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + %2 = llvm.and %arg1, %1 : i8 + %3 = llvm.icmp "slt" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.xor %arg0, %2 : i8 + %5 = llvm.intr.smax(%arg0, %4) : (i8, i8) -> i8 + llvm.return %5 : i8 + ^bb2: // pred: ^bb0 + llvm.call @barrier() : () -> () + llvm.return %0 : i8 + } + llvm.func @smin_xor_pow2_pos(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + %2 = llvm.and %arg1, %1 : i8 + %3 = llvm.icmp "sgt" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.xor %arg0, %2 : i8 + %5 = llvm.intr.smin(%arg0, %4) : (i8, i8) -> i8 + llvm.return %5 : i8 + ^bb2: // pred: ^bb0 + llvm.call @barrier() : () -> () + llvm.return %0 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/minnum.ll.mlir b/test/LLVMDialect/InstCombine/minnum.ll.mlir new file mode 100644 index 000000000..2db6e7f0b --- /dev/null +++ b/test/LLVMDialect/InstCombine/minnum.ll.mlir @@ -0,0 +1,290 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @constant_fold_minnum_f32() -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.intr.minnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_minnum_f32_inv() -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.minnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_minnum_f32_nan0() -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.intr.minnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_minnum_f32_nan1() -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %2 = llvm.intr.minnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_minnum_f32_nan_nan() -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.intr.minnum(%0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_minnum_f32_p0_p0() -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.intr.minnum(%0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_minnum_f32_p0_n0() -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.intr.minnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_minnum_f32_n0_p0() -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.intr.minnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @constant_fold_minnum_f32_n0_n0() -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.intr.minnum(%0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @constant_fold_minnum_v4f32() -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 8.000000e+00, 3.000000e+00, 9.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[2.000000e+00, 2.000000e+00, 1.000000e+01, 5.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.intr.minnum(%0, %1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @constant_fold_minnum_f64() -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.intr.minnum(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @constant_fold_minnum_f64_nan0() -> f64 { + %0 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %1 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %2 = llvm.intr.minnum(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @constant_fold_minnum_f64_nan1() -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %2 = llvm.intr.minnum(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @constant_fold_minnum_f64_nan_nan() -> f64 { + %0 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %1 = llvm.intr.minnum(%0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @canonicalize_constant_minnum_f32(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.intr.minnum(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @minnum_f32_nan_val(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.intr.minnum(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @minnum_f32_val_nan(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.intr.minnum(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @minnum_f32_1_minnum_val_p0(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.minnum(%arg0, %0) : (f32, f32) -> f32 + %3 = llvm.intr.minnum(%2, %1) : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minnum_f32_1_minnum_p0_val_fast(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.minnum(%0, %arg0) : (f32, f32) -> f32 + %3 = llvm.intr.minnum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minnum_f32_1_minnum_p0_val_fmf1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.minnum(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.intr.minnum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minnum_f32_1_minnum_p0_val_fmf2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.minnum(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.intr.minnum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minnum_f32_1_minnum_p0_val_fmf3(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.minnum(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.intr.minnum(%2, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minnum_f32_p0_minnum_val_n0(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.intr.minnum(%arg0, %0) : (f32, f32) -> f32 + %3 = llvm.intr.minnum(%2, %1) : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minnum_f32_1_minnum_p0_val(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.intr.minnum(%0, %arg0) : (f32, f32) -> f32 + %3 = llvm.intr.minnum(%2, %1) : (f32, f32) -> f32 + llvm.return %3 : f32 + } + llvm.func @minnum_f32_1_minnum_val_p0_val_v2f32(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.constant(dense<1.000000e+00> : vector<2xf32>) : vector<2xf32> + %3 = llvm.intr.minnum(%arg0, %1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + %4 = llvm.intr.minnum(%3, %2) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @minnum4(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: f32) -> f32 { + %0 = llvm.intr.minnum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.minnum(%arg2, %arg3) : (f32, f32) -> f32 + %2 = llvm.intr.minnum(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @minnum_x_maxnum_x_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.maxnum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.minnum(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @maxnum_x_minnum_x_y(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.intr.minnum(%arg0, %arg1) : (f32, f32) -> f32 + %1 = llvm.intr.maxnum(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @neg_neg(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.fsub %0, %arg1 : f64 + %3 = llvm.intr.minnum(%1, %2) : (f64, f64) -> f64 + llvm.return %3 : f64 + } + llvm.func @unary_neg_neg(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.fneg %arg1 : f64 + %2 = llvm.intr.minnum(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @neg_neg_vec_fmf(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %2 = llvm.fsub %0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %3 = llvm.intr.minnum(%1, %2) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @unary_neg_neg_vec_fmf(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %1 = llvm.fneg %arg1 {fastmathFlags = #llvm.fastmath} : vector<2xf64> + %2 = llvm.intr.minnum(%0, %1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @use(f64) + llvm.func @neg_neg_extra_use_x(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.fsub %0, %arg1 : f64 + %3 = llvm.intr.minnum(%1, %2) : (f64, f64) -> f64 + llvm.call @use(%1) : (f64) -> () + llvm.return %3 : f64 + } + llvm.func @unary_neg_neg_extra_use_x(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.fneg %arg1 : f64 + %2 = llvm.intr.minnum(%0, %1) : (f64, f64) -> f64 + llvm.call @use(%0) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @neg_neg_extra_use_y(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.fsub %0, %arg1 : f64 + %3 = llvm.intr.minnum(%1, %2) : (f64, f64) -> f64 + llvm.call @use(%2) : (f64) -> () + llvm.return %3 : f64 + } + llvm.func @unary_neg_neg_extra_use_y(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.fneg %arg1 : f64 + %2 = llvm.intr.minnum(%0, %1) : (f64, f64) -> f64 + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @neg_neg_extra_use_x_and_y(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.fsub %0, %arg0 : f64 + %2 = llvm.fsub %0, %arg1 : f64 + %3 = llvm.intr.minnum(%1, %2) : (f64, f64) -> f64 + llvm.call @use(%1) : (f64) -> () + llvm.call @use(%2) : (f64) -> () + llvm.return %3 : f64 + } + llvm.func @unary_neg_neg_extra_use_x_and_y(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + %1 = llvm.fneg %arg1 : f64 + %2 = llvm.intr.minnum(%0, %1) : (f64, f64) -> f64 + llvm.call @use(%0) : (f64) -> () + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @reduce_precision(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.minnum(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @reduce_precision_fmf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.minnum(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @reduce_precision_multi_use_0(%arg0: f32, %arg1: f32, %arg2: !llvm.ptr) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + llvm.store %0, %arg2 {alignment = 8 : i64} : f64, !llvm.ptr + %2 = llvm.intr.minnum(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @reduce_precision_multi_use_1(%arg0: f32, %arg1: f32, %arg2: !llvm.ptr) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + llvm.store %1, %arg2 {alignment = 8 : i64} : f64, !llvm.ptr + %2 = llvm.intr.minnum(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @negated_op(%arg0: f32) -> f32 { + %0 = llvm.fneg %arg0 : f32 + %1 = llvm.intr.minnum(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @negated_op_fmf_commute_vec(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.fneg %arg0 : vector<2xf64> + %1 = llvm.intr.minnum(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @negated_op_extra_use(%arg0: f64) -> f64 { + %0 = llvm.fneg %arg0 : f64 + llvm.call @use(%0) : (f64) -> () + %1 = llvm.intr.minnum(%0, %arg0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/misc-2002.ll.mlir b/test/LLVMDialect/InstCombine/misc-2002.ll.mlir index 178c407aa..559c899a1 100644 --- a/test/LLVMDialect/InstCombine/misc-2002.ll.mlir +++ b/test/LLVMDialect/InstCombine/misc-2002.ll.mlir @@ -1,33 +1,28 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.add"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "hang_2002-03-11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.mul"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.sub"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_failure_2002-05-14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.trunc"(%arg0) : (i64) -> i8 - %1 = "llvm.zext"(%0) : (i8) -> i64 - "llvm.return"(%1) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "cast_test_2002-08-02", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.sub"(%1, %arg0) : (i32, i32) -> i32 - %3 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - %4 = "llvm.add"(%3, %0) : (i32, i32) -> i32 - %5 = "llvm.add"(%arg0, %4) : (i32, i32) -> i32 - %6 = "llvm.add"(%2, %5) : (i32, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "missed_const_prop_2002-12-05", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @"hang_2002-03-11"(%arg0: i32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + llvm.return + } + llvm.func @"sub_failure_2002-05-14"(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mul %arg0, %arg1 : i32 + %2 = llvm.sub %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @"cast_test_2002-08-02"(%arg0: i64) -> i64 { + %0 = llvm.trunc %arg0 : i64 to i8 + %1 = llvm.zext %0 : i8 to i64 + llvm.return %1 : i64 + } + llvm.func @"missed_const_prop_2002-12-05"(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.sub %0, %1 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.add %arg0, %4 : i32 + %6 = llvm.add %2, %5 : i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/modulo.ll.mlir b/test/LLVMDialect/InstCombine/modulo.ll.mlir new file mode 100644 index 000000000..e8b51e231 --- /dev/null +++ b/test/LLVMDialect/InstCombine/modulo.ll.mlir @@ -0,0 +1,107 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @modulo2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i32 + %5 = llvm.add %4, %2 overflow : i32 + llvm.return %5 : i32 + } + llvm.func @modulo2_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.srem %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "slt" %3, %2 : vector<2xi32> + %5 = llvm.select %4, %0, %2 : vector<2xi1>, vector<2xi32> + %6 = llvm.add %5, %3 overflow : vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @modulo3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i32 + %5 = llvm.add %4, %2 overflow : i32 + llvm.return %5 : i32 + } + llvm.func @modulo3_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.srem %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "slt" %3, %2 : vector<2xi32> + %5 = llvm.select %4, %0, %2 : vector<2xi1>, vector<2xi32> + %6 = llvm.add %5, %3 overflow : vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @modulo4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i32 + %5 = llvm.add %4, %2 overflow : i32 + llvm.return %5 : i32 + } + llvm.func @modulo4_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.srem %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "slt" %3, %2 : vector<2xi32> + %5 = llvm.select %4, %0, %2 : vector<2xi1>, vector<2xi32> + %6 = llvm.add %5, %3 overflow : vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @modulo7(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i32 + %5 = llvm.add %4, %2 overflow : i32 + llvm.return %5 : i32 + } + llvm.func @modulo7_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.srem %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "slt" %3, %2 : vector<2xi32> + %5 = llvm.select %4, %0, %2 : vector<2xi1>, vector<2xi32> + %6 = llvm.add %5, %3 overflow : vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @modulo32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i32 + %5 = llvm.add %4, %2 overflow : i32 + llvm.return %5 : i32 + } + llvm.func @modulo32_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.srem %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "slt" %3, %2 : vector<2xi32> + %5 = llvm.select %4, %0, %2 : vector<2xi1>, vector<2xi32> + %6 = llvm.add %5, %3 overflow : vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @modulo16_32_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[16, 32]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.srem %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "slt" %3, %2 : vector<2xi32> + %5 = llvm.select %4, %0, %2 : vector<2xi1>, vector<2xi32> + %6 = llvm.add %5, %3 overflow : vector<2xi32> + llvm.return %6 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/mul-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/mul-inseltpoison.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/mul-masked-bits.ll.mlir b/test/LLVMDialect/InstCombine/mul-masked-bits.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/mul-min-max.ll.mlir b/test/LLVMDialect/InstCombine/mul-min-max.ll.mlir new file mode 100644 index 000000000..231317a05 --- /dev/null +++ b/test/LLVMDialect/InstCombine/mul-min-max.ll.mlir @@ -0,0 +1,38 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @umul_min_max(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.umax(%arg0, %arg1) : (i32, i32) -> i32 + %1 = llvm.intr.umin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.mul %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @umul_min_max_comm(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.umax(%arg1, %arg0) : (i32, i32) -> i32 + %1 = llvm.intr.umin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.mul %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @umul_min_max_nuw_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.umax(%arg0, %arg1) : (i32, i32) -> i32 + %1 = llvm.intr.umin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.mul %1, %0 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @smul_min_max(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.smax(%arg0, %arg1) : (i32, i32) -> i32 + %1 = llvm.intr.smin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.mul %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @smul_min_max_comm(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.smax(%arg1, %arg0) : (i32, i32) -> i32 + %1 = llvm.intr.smin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.mul %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @smul_min_max_nuw_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.intr.smax(%arg0, %arg1) : (i32, i32) -> i32 + %1 = llvm.intr.smin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.mul %1, %0 overflow : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/mul-pow2.ll.mlir b/test/LLVMDialect/InstCombine/mul-pow2.ll.mlir new file mode 100644 index 000000000..769ee6919 --- /dev/null +++ b/test/LLVMDialect/InstCombine/mul-pow2.ll.mlir @@ -0,0 +1,83 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use_i8(i8) + llvm.func @mul_selectp2_x(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.select %arg1, %0, %1 : i1, i8 + %3 = llvm.mul %2, %arg0 : i8 + llvm.return %3 : i8 + } + llvm.func @mul_selectp2_x_propegate_nuw(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.select %arg1, %0, %1 : i1, i8 + %3 = llvm.mul %2, %arg0 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @mul_selectp2_x_multiuse_fixme(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.select %arg1, %0, %1 : i1, i8 + %3 = llvm.mul %2, %arg0 : i8 + llvm.call @use_i8(%2) : (i8) -> () + llvm.return %3 : i8 + } + llvm.func @mul_selectp2_x_non_const(%arg0: i8, %arg1: i1, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.shl %0, %arg2 : i8 + %3 = llvm.select %arg1, %1, %2 : i1, i8 + %4 = llvm.mul %3, %arg0 : i8 + llvm.return %4 : i8 + } + llvm.func @mul_selectp2_x_non_const_multiuse(%arg0: i8, %arg1: i1, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.shl %0, %arg2 : i8 + %3 = llvm.select %arg1, %1, %2 : i1, i8 + %4 = llvm.mul %3, %arg0 : i8 + llvm.call @use_i8(%2) : (i8) -> () + llvm.return %4 : i8 + } + llvm.func @mul_x_selectp2(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(8 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mul %arg0, %arg0 : i8 + %3 = llvm.select %arg1, %0, %1 : i1, i8 + %4 = llvm.mul %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @mul_select_nonp2_x_fail(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.select %arg1, %0, %1 : i1, i8 + %3 = llvm.mul %2, %arg0 : i8 + llvm.return %3 : i8 + } + llvm.func @mul_x_selectp2_vec(%arg0: vector<2xi8>, %arg1: i1) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[8, 16]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[4, 1]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mul %arg0, %arg0 : vector<2xi8> + %3 = llvm.select %arg1, %0, %1 : i1, vector<2xi8> + %4 = llvm.mul %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @shl_add_log_may_cause_poison_pr62175_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.shl %0, %arg0 : i8 + %2 = llvm.mul %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @shl_add_log_may_cause_poison_pr62175_with_nuw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.shl %0, %arg0 overflow : i8 + %2 = llvm.mul %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @shl_add_log_may_cause_poison_pr62175_with_nsw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.shl %0, %arg0 overflow : i8 + %2 = llvm.mul %arg1, %1 : i8 + llvm.return %2 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/mul.ll.mlir b/test/LLVMDialect/InstCombine/mul.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/mul_fold.ll.mlir b/test/LLVMDialect/InstCombine/mul_fold.ll.mlir new file mode 100644 index 000000000..06834681e --- /dev/null +++ b/test/LLVMDialect/InstCombine/mul_fold.ll.mlir @@ -0,0 +1,515 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) -> i8 + llvm.func @use16(i16) -> i16 + llvm.func @use32(i32) -> i32 + llvm.func @use64(i64) -> i64 + llvm.func @use128(i128) -> i128 + llvm.func @use130(i130) -> i130 + llvm.func @use_v2i8(vector<2xi8>) -> vector<2xi8> + llvm.func @mul8_low_A0_B0(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.lshr %arg0, %1 : i8 + %4 = llvm.and %arg1, %0 : i8 + %5 = llvm.lshr %arg1, %1 : i8 + %6 = llvm.mul %5, %arg0 : i8 + %7 = llvm.mul %3, %arg1 : i8 + %8 = llvm.mul %4, %2 : i8 + %9 = llvm.add %6, %7 : i8 + %10 = llvm.shl %9, %1 : i8 + %11 = llvm.add %10, %8 : i8 + llvm.return %11 : i8 + } + llvm.func @mul8_low_A0_B1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.call @use8(%arg0) : (i8) -> i8 + %3 = llvm.and %2, %0 : i8 + %4 = llvm.lshr %2, %1 : i8 + %5 = llvm.and %arg1, %0 : i8 + %6 = llvm.lshr %arg1, %1 : i8 + %7 = llvm.mul %2, %6 : i8 + %8 = llvm.mul %4, %arg1 : i8 + %9 = llvm.mul %5, %3 : i8 + %10 = llvm.add %7, %8 : i8 + %11 = llvm.shl %10, %1 : i8 + %12 = llvm.add %9, %11 : i8 + llvm.return %12 : i8 + } + llvm.func @mul8_low_A0_B2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.call @use8(%arg1) : (i8) -> i8 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.lshr %arg0, %1 : i8 + %5 = llvm.and %2, %0 : i8 + %6 = llvm.lshr %2, %1 : i8 + %7 = llvm.mul %6, %arg0 : i8 + %8 = llvm.mul %2, %4 : i8 + %9 = llvm.mul %5, %3 : i8 + %10 = llvm.add %8, %7 : i8 + %11 = llvm.shl %10, %1 : i8 + %12 = llvm.add %11, %9 : i8 + llvm.return %12 : i8 + } + llvm.func @mul8_low_A0_B3(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.call @use8(%arg0) : (i8) -> i8 + %3 = llvm.call @use8(%arg1) : (i8) -> i8 + %4 = llvm.and %2, %0 : i8 + %5 = llvm.lshr %2, %1 : i8 + %6 = llvm.and %3, %0 : i8 + %7 = llvm.lshr %3, %1 : i8 + %8 = llvm.mul %2, %7 : i8 + %9 = llvm.mul %3, %5 : i8 + %10 = llvm.mul %6, %4 : i8 + %11 = llvm.add %9, %8 : i8 + %12 = llvm.shl %11, %1 : i8 + %13 = llvm.add %10, %12 : i8 + llvm.return %13 : i8 + } + llvm.func @mul16_low_A1_B0(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(255 : i16) : i16 + %1 = llvm.mlir.constant(8 : i16) : i16 + %2 = llvm.mlir.addressof @use16 : !llvm.ptr + %3 = llvm.and %arg0, %0 : i16 + %4 = llvm.lshr %arg0, %1 : i16 + %5 = llvm.and %arg1, %0 : i16 + %6 = llvm.lshr %arg1, %1 : i16 + %7 = llvm.mul %3, %6 : i16 + llvm.call %2(%7) : !llvm.ptr, (i16) -> () + %8 = llvm.mul %5, %4 : i16 + llvm.call %2(%8) : !llvm.ptr, (i16) -> () + %9 = llvm.mul %5, %3 : i16 + %10 = llvm.add %7, %8 : i16 + %11 = llvm.shl %10, %1 : i16 + %12 = llvm.add %11, %9 : i16 + llvm.return %12 : i16 + } + llvm.func @mul16_low_A1_B1(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(255 : i16) : i16 + %1 = llvm.mlir.constant(8 : i16) : i16 + %2 = llvm.mlir.addressof @use16 : !llvm.ptr + %3 = llvm.and %arg0, %0 : i16 + %4 = llvm.lshr %arg0, %1 : i16 + %5 = llvm.and %arg1, %0 : i16 + %6 = llvm.lshr %arg1, %1 : i16 + %7 = llvm.mul %3, %6 : i16 + llvm.call %2(%7) : !llvm.ptr, (i16) -> () + %8 = llvm.mul %4, %5 : i16 + llvm.call %2(%8) : !llvm.ptr, (i16) -> () + %9 = llvm.mul %5, %3 : i16 + %10 = llvm.add %7, %8 : i16 + %11 = llvm.shl %10, %1 : i16 + %12 = llvm.add %9, %11 : i16 + llvm.return %12 : i16 + } + llvm.func @mul16_low_A1_B2(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(255 : i16) : i16 + %1 = llvm.mlir.constant(8 : i16) : i16 + %2 = llvm.mlir.addressof @use16 : !llvm.ptr + %3 = llvm.and %arg0, %0 : i16 + %4 = llvm.lshr %arg0, %1 : i16 + %5 = llvm.and %arg1, %0 : i16 + %6 = llvm.lshr %arg1, %1 : i16 + %7 = llvm.mul %6, %3 : i16 + llvm.call %2(%7) : !llvm.ptr, (i16) -> () + %8 = llvm.mul %5, %4 : i16 + llvm.call %2(%8) : !llvm.ptr, (i16) -> () + %9 = llvm.mul %5, %3 : i16 + %10 = llvm.add %8, %7 : i16 + %11 = llvm.shl %10, %1 : i16 + %12 = llvm.add %11, %9 : i16 + llvm.return %12 : i16 + } + llvm.func @mul16_low_A1_B3(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(255 : i16) : i16 + %1 = llvm.mlir.constant(8 : i16) : i16 + %2 = llvm.mlir.addressof @use16 : !llvm.ptr + %3 = llvm.and %arg0, %0 : i16 + %4 = llvm.lshr %arg0, %1 : i16 + %5 = llvm.and %arg1, %0 : i16 + %6 = llvm.lshr %arg1, %1 : i16 + %7 = llvm.mul %3, %6 : i16 + llvm.call %2(%7) : !llvm.ptr, (i16) -> () + %8 = llvm.mul %5, %4 : i16 + llvm.call %2(%8) : !llvm.ptr, (i16) -> () + %9 = llvm.mul %5, %3 : i16 + %10 = llvm.add %8, %7 : i16 + %11 = llvm.shl %10, %1 : i16 + %12 = llvm.add %9, %11 : i16 + llvm.return %12 : i16 + } + llvm.func @mul32_low_A2_B0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.addressof @use32 : !llvm.ptr + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %arg1, %0 : i32 + %6 = llvm.lshr %arg1, %1 : i32 + %7 = llvm.mul %6, %3 : i32 + llvm.call %2(%7) : !llvm.ptr, (i32) -> () + %8 = llvm.mul %4, %arg1 : i32 + %9 = llvm.mul %5, %3 : i32 + %10 = llvm.add %7, %8 : i32 + %11 = llvm.shl %10, %1 : i32 + %12 = llvm.add %11, %9 : i32 + llvm.return %12 : i32 + } + llvm.func @mul32_low_A2_B1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.addressof @use32 : !llvm.ptr + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %arg1, %0 : i32 + %6 = llvm.lshr %arg1, %1 : i32 + %7 = llvm.mul %6, %3 : i32 + llvm.call %2(%7) : !llvm.ptr, (i32) -> () + %8 = llvm.mul %4, %arg1 : i32 + %9 = llvm.mul %5, %3 : i32 + %10 = llvm.add %7, %8 : i32 + %11 = llvm.shl %10, %1 : i32 + %12 = llvm.add %9, %11 : i32 + llvm.return %12 : i32 + } + llvm.func @mul32_low_A2_B2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.addressof @use32 : !llvm.ptr + %3 = llvm.call @use32(%arg1) : (i32) -> i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.lshr %arg0, %1 : i32 + %6 = llvm.and %3, %0 : i32 + %7 = llvm.lshr %3, %1 : i32 + %8 = llvm.mul %4, %7 : i32 + llvm.call %2(%8) : !llvm.ptr, (i32) -> () + %9 = llvm.mul %3, %5 : i32 + %10 = llvm.mul %6, %4 : i32 + %11 = llvm.add %9, %8 : i32 + %12 = llvm.shl %11, %1 : i32 + %13 = llvm.add %12, %10 : i32 + llvm.return %13 : i32 + } + llvm.func @mul32_low_A2_B3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.addressof @use32 : !llvm.ptr + %3 = llvm.call @use32(%arg1) : (i32) -> i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.lshr %arg0, %1 : i32 + %6 = llvm.and %3, %0 : i32 + %7 = llvm.lshr %3, %1 : i32 + %8 = llvm.mul %7, %4 : i32 + llvm.call %2(%8) : !llvm.ptr, (i32) -> () + %9 = llvm.mul %3, %5 : i32 + %10 = llvm.mul %6, %4 : i32 + %11 = llvm.add %9, %8 : i32 + %12 = llvm.shl %11, %1 : i32 + %13 = llvm.add %10, %12 : i32 + llvm.return %13 : i32 + } + llvm.func @mul64_low_A3_B0(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.mlir.addressof @use64 : !llvm.ptr + %3 = llvm.and %arg0, %0 : i64 + %4 = llvm.lshr %arg0, %1 : i64 + %5 = llvm.and %arg1, %0 : i64 + %6 = llvm.lshr %arg1, %1 : i64 + %7 = llvm.mul %6, %arg0 : i64 + %8 = llvm.mul %4, %5 : i64 + llvm.call %2(%8) : !llvm.ptr, (i64) -> () + %9 = llvm.mul %5, %3 : i64 + %10 = llvm.add %7, %8 : i64 + %11 = llvm.shl %10, %1 : i64 + %12 = llvm.add %11, %9 : i64 + llvm.return %12 : i64 + } + llvm.func @mul64_low_A3_B1(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.mlir.addressof @use64 : !llvm.ptr + %3 = llvm.and %arg0, %0 : i64 + %4 = llvm.lshr %arg0, %1 : i64 + %5 = llvm.and %arg1, %0 : i64 + %6 = llvm.lshr %arg1, %1 : i64 + %7 = llvm.mul %6, %arg0 : i64 + %8 = llvm.mul %4, %5 : i64 + llvm.call %2(%8) : !llvm.ptr, (i64) -> () + %9 = llvm.mul %5, %3 : i64 + %10 = llvm.add %7, %8 : i64 + %11 = llvm.shl %10, %1 : i64 + %12 = llvm.add %9, %11 : i64 + llvm.return %12 : i64 + } + llvm.func @mul64_low_A3_B2(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.mlir.addressof @use64 : !llvm.ptr + %3 = llvm.call @use64(%arg0) : (i64) -> i64 + %4 = llvm.and %3, %0 : i64 + %5 = llvm.lshr %3, %1 : i64 + %6 = llvm.and %arg1, %0 : i64 + %7 = llvm.lshr %arg1, %1 : i64 + %8 = llvm.mul %3, %7 : i64 + %9 = llvm.mul %5, %6 : i64 + llvm.call %2(%9) : !llvm.ptr, (i64) -> () + %10 = llvm.mul %6, %4 : i64 + %11 = llvm.add %9, %8 : i64 + %12 = llvm.shl %11, %1 : i64 + %13 = llvm.add %12, %10 : i64 + llvm.return %13 : i64 + } + llvm.func @mul64_low_A3_B3(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.mlir.addressof @use64 : !llvm.ptr + %3 = llvm.call @use64(%arg0) : (i64) -> i64 + %4 = llvm.and %3, %0 : i64 + %5 = llvm.lshr %3, %1 : i64 + %6 = llvm.and %arg1, %0 : i64 + %7 = llvm.lshr %arg1, %1 : i64 + %8 = llvm.mul %3, %7 : i64 + %9 = llvm.mul %6, %5 : i64 + llvm.call %2(%9) : !llvm.ptr, (i64) -> () + %10 = llvm.mul %6, %4 : i64 + %11 = llvm.add %9, %8 : i64 + %12 = llvm.shl %11, %1 : i64 + %13 = llvm.add %10, %12 : i64 + llvm.return %13 : i64 + } + llvm.func @mul32_low_one_extra_user(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.addressof @use32 : !llvm.ptr + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %arg1, %0 : i32 + %6 = llvm.lshr %arg1, %1 : i32 + %7 = llvm.mul %6, %3 : i32 + %8 = llvm.mul %5, %4 : i32 + %9 = llvm.mul %5, %3 : i32 + %10 = llvm.add %7, %8 : i32 + llvm.call %2(%10) : !llvm.ptr, (i32) -> () + %11 = llvm.shl %10, %1 : i32 + %12 = llvm.add %11, %9 : i32 + llvm.return %12 : i32 + } + llvm.func @mul8_low(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.lshr %arg0, %1 : i8 + %4 = llvm.and %arg1, %0 : i8 + %5 = llvm.lshr %arg1, %1 : i8 + %6 = llvm.mul %5, %2 : i8 + %7 = llvm.mul %4, %3 : i8 + %8 = llvm.mul %4, %2 : i8 + %9 = llvm.add %6, %7 : i8 + %10 = llvm.shl %9, %1 : i8 + %11 = llvm.add %10, %8 : i8 + llvm.return %11 : i8 + } + llvm.func @mul16_low(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(255 : i16) : i16 + %1 = llvm.mlir.constant(8 : i16) : i16 + %2 = llvm.and %arg0, %0 : i16 + %3 = llvm.lshr %arg0, %1 : i16 + %4 = llvm.and %arg1, %0 : i16 + %5 = llvm.lshr %arg1, %1 : i16 + %6 = llvm.mul %5, %2 : i16 + %7 = llvm.mul %4, %3 : i16 + %8 = llvm.mul %4, %2 : i16 + %9 = llvm.add %6, %7 : i16 + %10 = llvm.shl %9, %1 : i16 + %11 = llvm.add %10, %8 : i16 + llvm.return %11 : i16 + } + llvm.func @mul32_low(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.lshr %arg0, %1 : i32 + %4 = llvm.and %arg1, %0 : i32 + %5 = llvm.lshr %arg1, %1 : i32 + %6 = llvm.mul %5, %2 : i32 + %7 = llvm.mul %4, %3 : i32 + %8 = llvm.mul %4, %2 : i32 + %9 = llvm.add %6, %7 : i32 + %10 = llvm.shl %9, %1 : i32 + %11 = llvm.add %10, %8 : i32 + llvm.return %11 : i32 + } + llvm.func @mul64_low(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.lshr %arg0, %1 : i64 + %4 = llvm.and %arg1, %0 : i64 + %5 = llvm.lshr %arg1, %1 : i64 + %6 = llvm.mul %5, %2 : i64 + %7 = llvm.mul %4, %3 : i64 + %8 = llvm.mul %4, %2 : i64 + %9 = llvm.add %6, %7 : i64 + %10 = llvm.shl %9, %1 : i64 + %11 = llvm.add %10, %8 : i64 + llvm.return %11 : i64 + } + llvm.func @mul128_low(%arg0: i128, %arg1: i128) -> i128 { + %0 = llvm.mlir.constant(18446744073709551615 : i128) : i128 + %1 = llvm.mlir.constant(64 : i128) : i128 + %2 = llvm.and %arg0, %0 : i128 + %3 = llvm.lshr %arg0, %1 : i128 + %4 = llvm.and %arg1, %0 : i128 + %5 = llvm.lshr %arg1, %1 : i128 + %6 = llvm.mul %5, %2 : i128 + %7 = llvm.mul %4, %3 : i128 + %8 = llvm.mul %4, %2 : i128 + %9 = llvm.add %6, %7 : i128 + %10 = llvm.shl %9, %1 : i128 + %11 = llvm.add %10, %8 : i128 + llvm.return %11 : i128 + } + llvm.func @mul_v2i8_low(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<4> : vector<2xi8>) : vector<2xi8> + %2 = llvm.and %arg0, %0 : vector<2xi8> + %3 = llvm.lshr %arg0, %1 : vector<2xi8> + %4 = llvm.and %arg1, %0 : vector<2xi8> + %5 = llvm.lshr %arg1, %1 : vector<2xi8> + %6 = llvm.mul %5, %2 : vector<2xi8> + %7 = llvm.mul %4, %3 : vector<2xi8> + %8 = llvm.mul %4, %2 : vector<2xi8> + %9 = llvm.add %6, %7 : vector<2xi8> + %10 = llvm.shl %9, %1 : vector<2xi8> + %11 = llvm.add %10, %8 : vector<2xi8> + llvm.return %11 : vector<2xi8> + } + llvm.func @mul_v2i8_low_one_extra_user(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<4> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.addressof @use_v2i8 : !llvm.ptr + %3 = llvm.and %arg0, %0 : vector<2xi8> + %4 = llvm.lshr %arg0, %1 : vector<2xi8> + %5 = llvm.and %arg1, %0 : vector<2xi8> + %6 = llvm.lshr %arg1, %1 : vector<2xi8> + %7 = llvm.mul %6, %3 : vector<2xi8> + %8 = llvm.mul %5, %4 : vector<2xi8> + llvm.call %2(%8) : !llvm.ptr, (vector<2xi8>) -> () + %9 = llvm.mul %5, %3 : vector<2xi8> + %10 = llvm.add %7, %8 : vector<2xi8> + %11 = llvm.shl %10, %1 : vector<2xi8> + %12 = llvm.add %11, %9 : vector<2xi8> + llvm.return %12 : vector<2xi8> + } + llvm.func @mul130_low(%arg0: i130, %arg1: i130) -> i130 { + %0 = llvm.mlir.constant(36893488147419103231 : i130) : i130 + %1 = llvm.mlir.constant(65 : i130) : i130 + %2 = llvm.and %arg0, %0 : i130 + %3 = llvm.lshr %arg0, %1 : i130 + %4 = llvm.and %arg1, %0 : i130 + %5 = llvm.lshr %arg1, %1 : i130 + %6 = llvm.mul %5, %2 : i130 + %7 = llvm.mul %4, %3 : i130 + %8 = llvm.mul %4, %2 : i130 + %9 = llvm.add %6, %7 : i130 + %10 = llvm.shl %9, %1 : i130 + %11 = llvm.add %10, %8 : i130 + llvm.return %11 : i130 + } + llvm.func @mul130_low_one_extra_user(%arg0: i130, %arg1: i130) -> i130 { + %0 = llvm.mlir.constant(36893488147419103231 : i130) : i130 + %1 = llvm.mlir.constant(65 : i130) : i130 + %2 = llvm.mlir.addressof @use130 : !llvm.ptr + %3 = llvm.and %arg0, %0 : i130 + %4 = llvm.lshr %arg0, %1 : i130 + %5 = llvm.and %arg1, %0 : i130 + %6 = llvm.lshr %arg1, %1 : i130 + %7 = llvm.mul %6, %3 : i130 + llvm.call %2(%7) : !llvm.ptr, (i130) -> () + %8 = llvm.mul %5, %4 : i130 + %9 = llvm.mul %5, %3 : i130 + %10 = llvm.add %7, %8 : i130 + %11 = llvm.shl %10, %1 : i130 + %12 = llvm.add %11, %9 : i130 + llvm.return %12 : i130 + } + llvm.func @mul9_low(%arg0: i9, %arg1: i9) -> i9 { + %0 = llvm.mlir.constant(15 : i9) : i9 + %1 = llvm.mlir.constant(4 : i9) : i9 + %2 = llvm.and %arg0, %0 : i9 + %3 = llvm.lshr %arg0, %1 : i9 + %4 = llvm.and %arg1, %0 : i9 + %5 = llvm.lshr %arg1, %1 : i9 + %6 = llvm.mul %5, %2 : i9 + %7 = llvm.mul %4, %3 : i9 + %8 = llvm.mul %4, %2 : i9 + %9 = llvm.add %6, %7 : i9 + %10 = llvm.shl %9, %1 : i9 + %11 = llvm.add %10, %8 : i9 + llvm.return %11 : i9 + } + llvm.func @mul64_low_no_and(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.lshr %arg0, %0 : i64 + %2 = llvm.lshr %arg1, %0 : i64 + %3 = llvm.mul %2, %arg0 : i64 + %4 = llvm.mul %arg1, %1 : i64 + %5 = llvm.mul %arg1, %arg0 : i64 + %6 = llvm.add %3, %4 : i64 + %7 = llvm.shl %6, %0 : i64 + %8 = llvm.add %7, %5 : i64 + llvm.return %8 : i64 + } + llvm.func @mul16_low_miss_shift_amount(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(127 : i16) : i16 + %1 = llvm.mlir.constant(8 : i16) : i16 + %2 = llvm.and %arg0, %0 : i16 + %3 = llvm.lshr %arg0, %1 : i16 + %4 = llvm.and %arg1, %0 : i16 + %5 = llvm.lshr %arg1, %1 : i16 + %6 = llvm.mul %5, %2 : i16 + %7 = llvm.mul %4, %3 : i16 + %8 = llvm.mul %4, %2 : i16 + %9 = llvm.add %6, %7 : i16 + %10 = llvm.shl %9, %1 : i16 + %11 = llvm.add %10, %8 : i16 + llvm.return %11 : i16 + } + llvm.func @mul8_low_miss_half_width(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.lshr %arg0, %1 : i8 + %4 = llvm.and %arg1, %0 : i8 + %5 = llvm.lshr %arg1, %1 : i8 + %6 = llvm.mul %5, %2 : i8 + %7 = llvm.mul %4, %3 : i8 + %8 = llvm.mul %4, %2 : i8 + %9 = llvm.add %6, %7 : i8 + %10 = llvm.shl %9, %1 : i8 + %11 = llvm.add %10, %8 : i8 + llvm.return %11 : i8 + } + llvm.func @mul32_low_extra_shl_use(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.addressof @use32 : !llvm.ptr + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %arg1, %0 : i32 + %6 = llvm.lshr %arg1, %1 : i32 + %7 = llvm.mul %6, %3 : i32 + %8 = llvm.mul %5, %4 : i32 + %9 = llvm.mul %5, %3 : i32 + %10 = llvm.add %7, %8 : i32 + %11 = llvm.shl %10, %1 : i32 + llvm.call %2(%11) : !llvm.ptr, (i32) -> () + %12 = llvm.add %11, %9 : i32 + llvm.return %12 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/mul_full_32.ll.mlir b/test/LLVMDialect/InstCombine/mul_full_32.ll.mlir new file mode 100644 index 000000000..bce1d27a5 --- /dev/null +++ b/test/LLVMDialect/InstCombine/mul_full_32.ll.mlir @@ -0,0 +1,56 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @mul_full_64(%arg0: i64, %arg1: i64) -> !llvm.struct<(i64, i64)> { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.mlir.undef : !llvm.struct<(i64, i64)> + %3 = llvm.and %arg0, %0 : i64 + %4 = llvm.lshr %arg0, %1 : i64 + %5 = llvm.and %arg1, %0 : i64 + %6 = llvm.lshr %arg1, %1 : i64 + %7 = llvm.mul %5, %3 overflow : i64 + %8 = llvm.mul %5, %4 overflow : i64 + %9 = llvm.mul %6, %3 overflow : i64 + %10 = llvm.mul %6, %4 overflow : i64 + %11 = llvm.and %7, %0 : i64 + %12 = llvm.lshr %7, %1 : i64 + %13 = llvm.add %12, %8 : i64 + %14 = llvm.and %13, %0 : i64 + %15 = llvm.lshr %13, %1 : i64 + %16 = llvm.add %14, %9 : i64 + %17 = llvm.shl %16, %1 : i64 + %18 = llvm.lshr %16, %1 : i64 + %19 = llvm.add %15, %10 : i64 + %20 = llvm.or %17, %11 : i64 + %21 = llvm.add %19, %18 : i64 + %22 = llvm.insertvalue %20, %2[0] : !llvm.struct<(i64, i64)> + %23 = llvm.insertvalue %21, %22[1] : !llvm.struct<(i64, i64)> + llvm.return %23 : !llvm.struct<(i64, i64)> + } + llvm.func @mul_full_32(%arg0: i32, %arg1: i32) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %arg1, %0 : i32 + %6 = llvm.lshr %arg1, %1 : i32 + %7 = llvm.mul %5, %3 overflow : i32 + %8 = llvm.mul %5, %4 overflow : i32 + %9 = llvm.mul %6, %3 overflow : i32 + %10 = llvm.mul %6, %4 overflow : i32 + %11 = llvm.and %7, %0 : i32 + %12 = llvm.lshr %7, %1 : i32 + %13 = llvm.add %12, %8 : i32 + %14 = llvm.and %13, %0 : i32 + %15 = llvm.lshr %13, %1 : i32 + %16 = llvm.add %14, %9 : i32 + %17 = llvm.shl %16, %1 : i32 + %18 = llvm.lshr %16, %1 : i32 + %19 = llvm.add %15, %10 : i32 + %20 = llvm.or %17, %11 : i32 + %21 = llvm.add %19, %18 : i32 + %22 = llvm.insertvalue %20, %2[0] : !llvm.struct<(i32, i32)> + %23 = llvm.insertvalue %21, %22[1] : !llvm.struct<(i32, i32)> + llvm.return %23 : !llvm.struct<(i32, i32)> + } +} diff --git a/test/LLVMDialect/InstCombine/mul_full_64.ll.mlir b/test/LLVMDialect/InstCombine/mul_full_64.ll.mlir new file mode 100644 index 000000000..cdf43f11e --- /dev/null +++ b/test/LLVMDialect/InstCombine/mul_full_64.ll.mlir @@ -0,0 +1,343 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @mul_full_64_variant0(%arg0: i64, %arg1: i64) -> !llvm.struct<(i64, i64)> { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.mlir.undef : !llvm.struct<(i64, i64)> + %3 = llvm.and %arg0, %0 : i64 + %4 = llvm.lshr %arg0, %1 : i64 + %5 = llvm.and %arg1, %0 : i64 + %6 = llvm.lshr %arg1, %1 : i64 + %7 = llvm.mul %5, %3 overflow : i64 + %8 = llvm.mul %5, %4 overflow : i64 + %9 = llvm.mul %6, %3 overflow : i64 + %10 = llvm.mul %6, %4 overflow : i64 + %11 = llvm.and %7, %0 : i64 + %12 = llvm.lshr %7, %1 : i64 + %13 = llvm.add %12, %8 : i64 + %14 = llvm.and %13, %0 : i64 + %15 = llvm.lshr %13, %1 : i64 + %16 = llvm.add %14, %9 : i64 + %17 = llvm.shl %16, %1 : i64 + %18 = llvm.lshr %16, %1 : i64 + %19 = llvm.add %15, %10 : i64 + %20 = llvm.or %17, %11 : i64 + %21 = llvm.add %19, %18 : i64 + %22 = llvm.insertvalue %20, %2[0] : !llvm.struct<(i64, i64)> + %23 = llvm.insertvalue %21, %22[1] : !llvm.struct<(i64, i64)> + llvm.return %23 : !llvm.struct<(i64, i64)> + } + llvm.func @mul_full_64_variant1(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr {llvm.nocapture}) -> i64 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.lshr %arg0, %1 : i64 + %4 = llvm.and %arg1, %0 : i64 + %5 = llvm.lshr %arg1, %1 : i64 + %6 = llvm.mul %5, %3 overflow : i64 + %7 = llvm.mul %4, %3 overflow : i64 + %8 = llvm.mul %5, %2 overflow : i64 + %9 = llvm.mul %4, %2 overflow : i64 + %10 = llvm.lshr %9, %1 : i64 + %11 = llvm.add %10, %7 : i64 + %12 = llvm.lshr %11, %1 : i64 + %13 = llvm.add %12, %6 : i64 + %14 = llvm.and %11, %0 : i64 + %15 = llvm.add %14, %8 : i64 + %16 = llvm.lshr %15, %1 : i64 + %17 = llvm.add %13, %16 : i64 + llvm.store %17, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + %18 = llvm.mul %arg1, %arg0 : i64 + llvm.return %18 : i64 + } + llvm.func @mul_full_64_variant2(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr {llvm.nocapture}) -> i64 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.lshr %arg0, %1 : i64 + %4 = llvm.and %arg1, %0 : i64 + %5 = llvm.lshr %arg1, %1 : i64 + %6 = llvm.mul %5, %3 overflow : i64 + %7 = llvm.mul %4, %3 overflow : i64 + %8 = llvm.mul %5, %2 overflow : i64 + %9 = llvm.mul %4, %2 overflow : i64 + %10 = llvm.lshr %9, %1 : i64 + %11 = llvm.add %10, %7 : i64 + %12 = llvm.lshr %11, %1 : i64 + %13 = llvm.add %12, %6 : i64 + %14 = llvm.and %11, %0 : i64 + %15 = llvm.add %14, %8 : i64 + %16 = llvm.lshr %15, %1 : i64 + %17 = llvm.add %13, %16 : i64 + llvm.store %17, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + %18 = llvm.shl %15, %1 : i64 + %19 = llvm.and %9, %0 : i64 + %20 = llvm.or %18, %19 : i64 + llvm.return %20 : i64 + } + llvm.func @mul_full_64_variant3(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr {llvm.nocapture}) -> i64 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.lshr %arg0, %1 : i64 + %4 = llvm.and %arg1, %0 : i64 + %5 = llvm.lshr %arg1, %1 : i64 + %6 = llvm.mul %5, %3 overflow : i64 + %7 = llvm.mul %4, %3 overflow : i64 + %8 = llvm.mul %5, %2 overflow : i64 + %9 = llvm.mul %4, %2 overflow : i64 + %10 = llvm.lshr %9, %1 : i64 + %11 = llvm.add %10, %7 : i64 + %12 = llvm.lshr %11, %1 : i64 + %13 = llvm.add %12, %6 : i64 + %14 = llvm.and %11, %0 : i64 + %15 = llvm.add %14, %8 : i64 + %16 = llvm.lshr %15, %1 : i64 + %17 = llvm.add %13, %16 : i64 + llvm.store %17, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + %18 = llvm.add %8, %7 : i64 + %19 = llvm.shl %18, %1 : i64 + %20 = llvm.add %19, %9 : i64 + llvm.return %20 : i64 + } + llvm.func @mul_full_32(%arg0: i32, %arg1: i32) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %arg1, %0 : i32 + %6 = llvm.lshr %arg1, %1 : i32 + %7 = llvm.mul %5, %3 overflow : i32 + %8 = llvm.mul %5, %4 overflow : i32 + %9 = llvm.mul %6, %3 overflow : i32 + %10 = llvm.mul %6, %4 overflow : i32 + %11 = llvm.and %7, %0 : i32 + %12 = llvm.lshr %7, %1 : i32 + %13 = llvm.add %12, %8 : i32 + %14 = llvm.and %13, %0 : i32 + %15 = llvm.lshr %13, %1 : i32 + %16 = llvm.add %14, %9 : i32 + %17 = llvm.shl %16, %1 : i32 + %18 = llvm.lshr %16, %1 : i32 + %19 = llvm.add %15, %10 : i32 + %20 = llvm.or %17, %11 : i32 + %21 = llvm.add %19, %18 : i32 + %22 = llvm.insertvalue %20, %2[0] : !llvm.struct<(i32, i32)> + %23 = llvm.insertvalue %21, %22[1] : !llvm.struct<(i32, i32)> + llvm.return %23 : !llvm.struct<(i32, i32)> + } + llvm.func @get_number() -> i64 + llvm.func @mul_full_64_variant0_1() -> !llvm.struct<(i64, i64)> { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.mlir.undef : !llvm.struct<(i64, i64)> + %3 = llvm.call @get_number() : () -> i64 + %4 = llvm.and %3, %0 : i64 + %5 = llvm.lshr %3, %1 : i64 + %6 = llvm.call @get_number() : () -> i64 + %7 = llvm.lshr %6, %1 : i64 + %8 = llvm.and %6, %0 : i64 + %9 = llvm.mul %4, %7 overflow : i64 + %10 = llvm.mul %5, %7 overflow : i64 + %11 = llvm.mul %5, %8 overflow : i64 + %12 = llvm.mul %4, %8 overflow : i64 + %13 = llvm.lshr %12, %1 : i64 + %14 = llvm.add %13, %9 : i64 + %15 = llvm.and %14, %0 : i64 + %16 = llvm.add %15, %11 : i64 + %17 = llvm.lshr %14, %1 : i64 + %18 = llvm.add %17, %10 : i64 + %19 = llvm.lshr %16, %1 : i64 + %20 = llvm.add %18, %19 : i64 + %21 = llvm.shl %16, %1 : i64 + %22 = llvm.and %12, %0 : i64 + %23 = llvm.or %21, %22 : i64 + %24 = llvm.insertvalue %23, %2[0] : !llvm.struct<(i64, i64)> + %25 = llvm.insertvalue %20, %24[1] : !llvm.struct<(i64, i64)> + llvm.return %25 : !llvm.struct<(i64, i64)> + } + llvm.func @mul_full_64_variant0_2() -> !llvm.struct<(i64, i64)> { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.mlir.undef : !llvm.struct<(i64, i64)> + %3 = llvm.call @get_number() : () -> i64 + %4 = llvm.call @get_number() : () -> i64 + %5 = llvm.and %4, %0 : i64 + %6 = llvm.lshr %4, %1 : i64 + %7 = llvm.lshr %3, %1 : i64 + %8 = llvm.and %3, %0 : i64 + %9 = llvm.mul %7, %6 overflow : i64 + %10 = llvm.mul %8, %6 overflow : i64 + %11 = llvm.mul %7, %5 overflow : i64 + %12 = llvm.mul %8, %5 overflow : i64 + %13 = llvm.lshr %12, %1 : i64 + %14 = llvm.add %11, %13 : i64 + %15 = llvm.and %14, %0 : i64 + %16 = llvm.add %10, %15 : i64 + %17 = llvm.lshr %14, %1 : i64 + %18 = llvm.add %17, %9 : i64 + %19 = llvm.lshr %16, %1 : i64 + %20 = llvm.add %19, %18 : i64 + %21 = llvm.shl %16, %1 : i64 + %22 = llvm.and %12, %0 : i64 + %23 = llvm.or %22, %21 : i64 + %24 = llvm.insertvalue %23, %2[0] : !llvm.struct<(i64, i64)> + %25 = llvm.insertvalue %20, %24[1] : !llvm.struct<(i64, i64)> + llvm.return %25 : !llvm.struct<(i64, i64)> + } + llvm.func @umulh_64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.lshr %arg0, %1 : i64 + %4 = llvm.and %arg1, %0 : i64 + %5 = llvm.lshr %arg1, %1 : i64 + %6 = llvm.mul %4, %2 overflow : i64 + %7 = llvm.mul %4, %3 overflow : i64 + %8 = llvm.mul %5, %2 overflow : i64 + %9 = llvm.mul %5, %3 overflow : i64 + %10 = llvm.lshr %6, %1 : i64 + %11 = llvm.add %10, %7 : i64 + %12 = llvm.and %11, %0 : i64 + %13 = llvm.lshr %11, %1 : i64 + %14 = llvm.add %12, %8 : i64 + %15 = llvm.lshr %14, %1 : i64 + %16 = llvm.add %13, %9 : i64 + %17 = llvm.add %16, %15 : i64 + llvm.return %17 : i64 + } + llvm.func @mullo(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.lshr %arg0, %1 : i64 + %4 = llvm.and %arg1, %0 : i64 + %5 = llvm.lshr %arg1, %1 : i64 + %6 = llvm.mul %4, %2 overflow : i64 + %7 = llvm.mul %4, %3 overflow : i64 + %8 = llvm.mul %5, %2 overflow : i64 + %9 = llvm.and %6, %0 : i64 + %10 = llvm.lshr %6, %1 : i64 + %11 = llvm.add %10, %7 : i64 + %12 = llvm.and %11, %0 : i64 + %13 = llvm.add %12, %8 : i64 + %14 = llvm.shl %13, %1 : i64 + %15 = llvm.or %14, %9 : i64 + llvm.return %15 : i64 + } + llvm.func @mullo_variant3(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.lshr %arg0, %1 : i64 + %4 = llvm.and %arg1, %0 : i64 + %5 = llvm.lshr %arg1, %1 : i64 + %6 = llvm.mul %4, %2 overflow : i64 + %7 = llvm.mul %4, %3 overflow : i64 + %8 = llvm.mul %5, %2 overflow : i64 + %9 = llvm.add %8, %7 : i64 + %10 = llvm.shl %9, %1 : i64 + %11 = llvm.add %10, %6 : i64 + llvm.return %11 : i64 + } + llvm.func @eat_i64(i64) + llvm.func @eat_i128(i128) + llvm.func @mullo_duplicate(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.mul %arg0, %arg1 : i64 + llvm.call @eat_i64(%2) : (i64) -> () + %3 = llvm.and %arg0, %0 : i64 + %4 = llvm.lshr %arg0, %1 : i64 + %5 = llvm.and %arg1, %0 : i64 + %6 = llvm.lshr %arg1, %1 : i64 + %7 = llvm.mul %5, %3 overflow : i64 + %8 = llvm.mul %5, %4 overflow : i64 + %9 = llvm.mul %6, %3 overflow : i64 + %10 = llvm.and %7, %0 : i64 + %11 = llvm.lshr %7, %1 : i64 + %12 = llvm.add %11, %8 : i64 + %13 = llvm.and %12, %0 : i64 + %14 = llvm.add %13, %9 : i64 + %15 = llvm.shl %14, %1 : i64 + %16 = llvm.or %15, %10 : i64 + llvm.return %16 : i64 + } + llvm.func @mul_full_64_duplicate(%arg0: i64, %arg1: i64) -> !llvm.struct<(i64, i64)> { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.mlir.undef : !llvm.struct<(i64, i64)> + %3 = llvm.zext %arg0 : i64 to i128 + %4 = llvm.zext %arg1 : i64 to i128 + %5 = llvm.mul %3, %4 : i128 + llvm.call @eat_i128(%5) : (i128) -> () + %6 = llvm.and %arg0, %0 : i64 + %7 = llvm.lshr %arg0, %1 : i64 + %8 = llvm.and %arg1, %0 : i64 + %9 = llvm.lshr %arg1, %1 : i64 + %10 = llvm.mul %8, %6 overflow : i64 + %11 = llvm.mul %8, %7 overflow : i64 + %12 = llvm.mul %9, %6 overflow : i64 + %13 = llvm.mul %9, %7 overflow : i64 + %14 = llvm.and %10, %0 : i64 + %15 = llvm.lshr %10, %1 : i64 + %16 = llvm.add %15, %11 : i64 + %17 = llvm.and %16, %0 : i64 + %18 = llvm.lshr %16, %1 : i64 + %19 = llvm.add %17, %12 : i64 + %20 = llvm.shl %19, %1 : i64 + %21 = llvm.lshr %19, %1 : i64 + %22 = llvm.add %18, %13 : i64 + %23 = llvm.or %20, %14 : i64 + %24 = llvm.add %22, %21 : i64 + %25 = llvm.insertvalue %23, %2[0] : !llvm.struct<(i64, i64)> + %26 = llvm.insertvalue %24, %25[1] : !llvm.struct<(i64, i64)> + llvm.return %26 : !llvm.struct<(i64, i64)> + } + llvm.func @umulhi_64_v2() -> i64 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.call @get_number() : () -> i64 + %3 = llvm.call @get_number() : () -> i64 + %4 = llvm.and %3, %0 : i64 + %5 = llvm.lshr %3, %1 : i64 + %6 = llvm.lshr %2, %1 : i64 + %7 = llvm.and %2, %0 : i64 + %8 = llvm.mul %6, %5 overflow : i64 + %9 = llvm.mul %7, %5 overflow : i64 + %10 = llvm.mul %6, %4 overflow : i64 + %11 = llvm.mul %7, %4 overflow : i64 + %12 = llvm.lshr %11, %1 : i64 + %13 = llvm.add %10, %12 : i64 + %14 = llvm.and %13, %0 : i64 + %15 = llvm.add %9, %14 : i64 + %16 = llvm.lshr %13, %1 : i64 + %17 = llvm.add %16, %8 : i64 + %18 = llvm.lshr %15, %1 : i64 + %19 = llvm.add %18, %17 : i64 + llvm.return %19 : i64 + } + llvm.func @umulhi_64_v3() -> i64 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(4294967295 : i64) : i64 + %2 = llvm.call @get_number() : () -> i64 + %3 = llvm.lshr %2, %0 : i64 + %4 = llvm.and %2, %1 : i64 + %5 = llvm.call @get_number() : () -> i64 + %6 = llvm.and %5, %1 : i64 + %7 = llvm.lshr %5, %0 : i64 + %8 = llvm.mul %3, %7 overflow : i64 + %9 = llvm.mul %4, %7 overflow : i64 + %10 = llvm.mul %3, %6 overflow : i64 + %11 = llvm.mul %4, %6 overflow : i64 + %12 = llvm.lshr %11, %0 : i64 + %13 = llvm.add %10, %12 : i64 + %14 = llvm.and %13, %1 : i64 + %15 = llvm.add %9, %14 : i64 + %16 = llvm.lshr %13, %0 : i64 + %17 = llvm.add %16, %8 : i64 + %18 = llvm.lshr %15, %0 : i64 + %19 = llvm.add %18, %17 : i64 + llvm.return %19 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/multi-size-address-space-pointer.ll.mlir b/test/LLVMDialect/InstCombine/multi-size-address-space-pointer.ll.mlir new file mode 100644 index 000000000..734cfb677 --- /dev/null +++ b/test/LLVMDialect/InstCombine/multi-size-address-space-pointer.ll.mlir @@ -0,0 +1,73 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<16> : vector<4xi64>>, #dlti.dl_entry, dense<16> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<64> : vector<4xi64>>, #dlti.dl_entry, dense<8> : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_as0(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %2 : i32 + } + llvm.func @test_as1(%arg0: !llvm.ptr<1>) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr<1>, i32) -> !llvm.ptr<1>, i32 + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr<1> -> i32 + llvm.return %2 : i32 + } + llvm.func @test_as2(%arg0: !llvm.ptr<2>) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr<2>, i32) -> !llvm.ptr<2>, i32 + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr<2> -> i32 + llvm.return %2 : i32 + } + llvm.func @test_as3(%arg0: !llvm.ptr<3>) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr<3>, i32) -> !llvm.ptr<3>, i32 + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr<3> -> i32 + llvm.return %2 : i32 + } + llvm.func @test_combine_ptrtoint(%arg0: !llvm.ptr<2>) -> i32 { + %0 = llvm.ptrtoint %arg0 : !llvm.ptr<2> to i8 + %1 = llvm.inttoptr %0 : i8 to !llvm.ptr<2> + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr<2> -> i32 + llvm.return %2 : i32 + } + llvm.func @test_combine_inttoptr(%arg0: i8) -> i8 { + %0 = llvm.inttoptr %arg0 : i8 to !llvm.ptr<2> + %1 = llvm.ptrtoint %0 : !llvm.ptr<2> to i8 + llvm.return %1 : i8 + } + llvm.func @test_combine_vector_ptrtoint(%arg0: !llvm.vec<2 x ptr<2>>) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.ptrtoint %arg0 : !llvm.vec<2 x ptr<2>> to vector<2xi8> + %2 = llvm.inttoptr %1 : vector<2xi8> to !llvm.vec<2 x ptr<2>> + %3 = llvm.extractelement %2[%0 : i32] : !llvm.vec<2 x ptr<2>> + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr<2> -> i32 + llvm.return %4 : i32 + } + llvm.func @test_combine_vector_inttoptr(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.inttoptr %arg0 : vector<2xi8> to !llvm.vec<2 x ptr<2>> + %1 = llvm.ptrtoint %0 : !llvm.vec<2 x ptr<2>> to vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @shrink_gep_constant_index_64_as2(%arg0: !llvm.ptr<2>) -> !llvm.ptr<2> { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr<2>, i64) -> !llvm.ptr<2>, i32 + llvm.return %1 : !llvm.ptr<2> + } + llvm.func @shrink_gep_constant_index_32_as2(%arg0: !llvm.ptr<2>) -> !llvm.ptr<2> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr<2>, i32) -> !llvm.ptr<2>, i32 + llvm.return %1 : !llvm.ptr<2> + } + llvm.func @shrink_gep_constant_index_64_as3(%arg0: !llvm.ptr<3>) -> !llvm.ptr<3> { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr<3>, i64) -> !llvm.ptr<3>, i32 + llvm.return %1 : !llvm.ptr<3> + } + llvm.func @shrink_gep_variable_index_64_as2(%arg0: !llvm.ptr<2>, %arg1: i64) -> !llvm.ptr<2> { + %0 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr<2>, i64) -> !llvm.ptr<2>, i32 + llvm.return %0 : !llvm.ptr<2> + } + llvm.func @grow_gep_variable_index_8_as1(%arg0: !llvm.ptr<1>, %arg1: i8) -> !llvm.ptr<1> { + %0 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr<1>, i8) -> !llvm.ptr<1>, i32 + llvm.return %0 : !llvm.ptr<1> + } +} diff --git a/test/LLVMDialect/InstCombine/multi-use-load-casts.ll.mlir b/test/LLVMDialect/InstCombine/multi-use-load-casts.ll.mlir new file mode 100644 index 000000000..41e4abff8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/multi-use-load-casts.ll.mlir @@ -0,0 +1,63 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<64> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @t0(%arg0: i1 {llvm.zeroext}, %arg1: i1 {llvm.zeroext}, %arg2: !llvm.ptr {llvm.nocapture, llvm.readonly}) { + %0 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> i64 + llvm.cond_br %arg0, ^bb1, ^bb4 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg1, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.call @abort() : () -> () + llvm.unreachable + ^bb3: // pred: ^bb1 + %1 = llvm.inttoptr %0 : i64 to !llvm.ptr + llvm.call @sink0(%1) : (!llvm.ptr) -> () + llvm.br ^bb5 + ^bb4: // pred: ^bb0 + %2 = llvm.inttoptr %0 : i64 to !llvm.ptr + llvm.call @sink1(%2) : (!llvm.ptr) -> () + llvm.br ^bb5 + ^bb5: // 2 preds: ^bb3, ^bb4 + llvm.return + } + llvm.func @n1(%arg0: i1 {llvm.zeroext}, %arg1: i1 {llvm.zeroext}, %arg2: !llvm.ptr {llvm.nocapture, llvm.readonly}) { + %0 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> i64 + llvm.cond_br %arg0, ^bb1, ^bb4 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg1, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.call @abort() : () -> () + llvm.unreachable + ^bb3: // pred: ^bb1 + %1 = llvm.inttoptr %0 : i64 to !llvm.ptr + llvm.call @sink0(%1) : (!llvm.ptr) -> () + llvm.br ^bb5 + ^bb4: // pred: ^bb0 + %2 = llvm.bitcast %0 : i64 to vector<2xi32> + llvm.call @sink2(%2) : (vector<2xi32>) -> () + llvm.br ^bb5 + ^bb5: // 2 preds: ^bb3, ^bb4 + llvm.return + } + llvm.func @n2(%arg0: i1 {llvm.zeroext}, %arg1: i1 {llvm.zeroext}, %arg2: !llvm.ptr {llvm.nocapture, llvm.readonly}) { + %0 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> i64 + llvm.cond_br %arg0, ^bb1, ^bb4 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg1, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.call @abort() : () -> () + llvm.unreachable + ^bb3: // pred: ^bb1 + %1 = llvm.inttoptr %0 : i64 to !llvm.ptr + llvm.call @sink0(%1) : (!llvm.ptr) -> () + llvm.br ^bb5 + ^bb4: // pred: ^bb0 + llvm.call @sink3(%0) : (i64) -> () + llvm.br ^bb5 + ^bb5: // 2 preds: ^bb3, ^bb4 + llvm.return + } + llvm.func @abort() + llvm.func @sink0(!llvm.ptr) + llvm.func @sink1(!llvm.ptr) + llvm.func @sink2(vector<2xi32>) + llvm.func @sink3(i64) +} diff --git a/test/LLVMDialect/InstCombine/multi-use-or.ll.mlir b/test/LLVMDialect/InstCombine/multi-use-or.ll.mlir index 03aca2cfd..053dfb522 100644 --- a/test/LLVMDialect/InstCombine/multi-use-or.ll.mlir +++ b/test/LLVMDialect/InstCombine/multi-use-or.ll.mlir @@ -1,20 +1,18 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64, %arg2: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 128 : i192} : () -> i192 - %1 = "llvm.bitcast"(%arg0) : (f64) -> i64 - %2 = "llvm.zext"(%1) : (i64) -> i192 - %3 = "llvm.bitcast"(%arg1) : (f64) -> i64 - %4 = "llvm.zext"(%3) : (i64) -> i192 - %5 = "llvm.shl"(%4, %0) : (i192, i192) -> i192 - %6 = "llvm.or"(%2, %5) : (i192, i192) -> i192 - %7 = "llvm.trunc"(%6) : (i192) -> i64 - %8 = "llvm.bitcast"(%7) : (i64) -> f64 - %9 = "llvm.lshr"(%6, %0) : (i192, i192) -> i192 - %10 = "llvm.trunc"(%9) : (i192) -> i64 - %11 = "llvm.bitcast"(%10) : (i64) -> f64 - %12 = "llvm.fadd"(%8, %11) : (f64, f64) -> f64 - "llvm.return"(%12) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "ScaleObjectAdd", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @ScaleObjectAdd(%arg0: f64, %arg1: f64, %arg2: f64) -> f64 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(128 : i192) : i192 + %1 = llvm.bitcast %arg0 : f64 to i64 + %2 = llvm.zext %1 : i64 to i192 + %3 = llvm.bitcast %arg1 : f64 to i64 + %4 = llvm.zext %3 : i64 to i192 + %5 = llvm.shl %4, %0 : i192 + %6 = llvm.or %2, %5 : i192 + %7 = llvm.trunc %6 : i192 to i64 + %8 = llvm.bitcast %7 : i64 to f64 + %9 = llvm.lshr %6, %0 : i192 + %10 = llvm.trunc %9 : i192 to i64 + %11 = llvm.bitcast %10 : i64 to f64 + %12 = llvm.fadd %8, %11 : f64 + llvm.return %12 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/multiple-uses-load-bitcast-select.ll.mlir b/test/LLVMDialect/InstCombine/multiple-uses-load-bitcast-select.ll.mlir new file mode 100644 index 000000000..65aa4bec6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/multiple-uses-load-bitcast-select.ll.mlir @@ -0,0 +1,15 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @PR35618(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x f64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %2 = llvm.alloca %0 x f64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %3 = llvm.load %1 {alignment = 8 : i64} : !llvm.ptr -> f64 + %4 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> f64 + %5 = llvm.fcmp "olt" %3, %4 : f64 + %6 = llvm.select %5, %1, %2 : i1, !llvm.ptr + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i64 + llvm.store %7, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.store %7, %arg1 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/musttail-thunk.ll.mlir b/test/LLVMDialect/InstCombine/musttail-thunk.ll.mlir new file mode 100644 index 000000000..13b7a1e8f --- /dev/null +++ b/test/LLVMDialect/InstCombine/musttail-thunk.ll.mlir @@ -0,0 +1,18 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @call_thunk(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.addressof @inc_first_arg_thunk : !llvm.ptr + %1 = llvm.call %0(%arg0, %arg1) : !llvm.ptr, (i32, i32) -> i32 + llvm.return %1 : i32 + } + llvm.func internal @inc_first_arg_thunk(%arg0: i32, ...) attributes {dso_local, passthrough = ["thunk"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.addressof @plus : !llvm.ptr + %2 = llvm.add %arg0, %0 : i32 + llvm.call %1(%2) vararg(!llvm.func) : !llvm.ptr, (i32) -> () + llvm.return + } + llvm.func internal @plus(%arg0: i32, %arg1: i32) -> i32 attributes {dso_local} { + %0 = llvm.add %arg0, %arg1 : i32 + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/narrow-math.ll.mlir b/test/LLVMDialect/InstCombine/narrow-math.ll.mlir index 1717301a4..976ab3093 100644 --- a/test/LLVMDialect/InstCombine/narrow-math.ll.mlir +++ b/test/LLVMDialect/InstCombine/narrow-math.ll.mlir @@ -1,398 +1,353 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "callee", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%arg0, %0) : (i32, i32) -> i32 - %4 = "llvm.sext"(%2) : (i32) -> i64 - %5 = "llvm.sext"(%3) : (i32) -> i64 - %6 = "llvm.add"(%4, %5) : (i64, i64) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "sext_sext_add", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.lshr"(%arg0, %0) : (i32, i32) -> i32 - %4 = "llvm.sext"(%2) : (i32) -> i64 - %5 = "llvm.zext"(%3) : (i32) -> i64 - %6 = "llvm.add"(%4, %5) : (i64, i64) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "sext_zext_add_mismatched_exts", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 7 : i16} : () -> i16 - %2 = "llvm.ashr"(%arg0, %1) : (i16, i16) -> i16 - %3 = "llvm.ashr"(%arg1, %0) : (i32, i32) -> i32 - %4 = "llvm.sext"(%2) : (i16) -> i64 - %5 = "llvm.sext"(%3) : (i32) -> i64 - %6 = "llvm.add"(%4, %5) : (i64, i64) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "sext_sext_add_mismatched_types", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%arg0, %0) : (i32, i32) -> i32 - %4 = "llvm.sext"(%2) : (i32) -> i64 - "llvm.call"(%4) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - %5 = "llvm.sext"(%3) : (i32) -> i64 - %6 = "llvm.add"(%4, %5) : (i64, i64) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "sext_sext_add_extra_use1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%arg0, %0) : (i32, i32) -> i32 - %4 = "llvm.sext"(%2) : (i32) -> i64 - %5 = "llvm.sext"(%3) : (i32) -> i64 - "llvm.call"(%5) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - %6 = "llvm.add"(%4, %5) : (i64, i64) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "sext_sext_add_extra_use2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%arg0, %0) : (i32, i32) -> i32 - %4 = "llvm.sext"(%2) : (i32) -> i64 - "llvm.call"(%4) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - %5 = "llvm.sext"(%3) : (i32) -> i64 - "llvm.call"(%5) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - %6 = "llvm.add"(%4, %5) : (i64, i64) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "sext_sext_add_extra_use3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %1 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %2 = "llvm.sext"(%0) : (i32) -> i64 - %3 = "llvm.sext"(%1) : (i32) -> i64 - %4 = "llvm.add"(%2, %3) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %1 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %2 = "llvm.add"(%0, %1) : (i32, i32) -> i32 - %3 = "llvm.sext"(%2) : (i32) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %1 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %2 = "llvm.sext"(%0) : (i32) -> i64 - %3 = "llvm.sext"(%1) : (i32) -> i64 - %4 = "llvm.mul"(%2, %3) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %1 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %2 = "llvm.mul"(%0, %1) : (i32, i32) -> i32 - %3 = "llvm.sext"(%2) : (i32) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1073741823 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.sext"(%2) : (i32) -> i64 - %4 = "llvm.add"(%3, %0) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1073741823 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.sext"(%2) : (i32) -> i64 - "llvm.call"(%3) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - %4 = "llvm.add"(%3, %0) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "sext_add_constant_extra_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1073741823> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.sext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.add"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test5_splat", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[1, 2]> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.sext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.add"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test5_vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1073741824 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.sext"(%2) : (i32) -> i64 - %4 = "llvm.add"(%3, %0) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-1073741824> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.sext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.add"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test6_splat", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[-1, -2]> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.sext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.add"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test6_vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[-1, 1]> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.sext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.add"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test6_vec2", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2147483647 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.zext"(%2) : (i32) -> i64 - %4 = "llvm.add"(%3, %0) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<2147483647> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.lshr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.zext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.add"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test7_splat", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[1, 2]> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.lshr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.zext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.add"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test7_vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32767 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.sext"(%2) : (i32) -> i64 - %4 = "llvm.mul"(%3, %0) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<32767> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<16> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.sext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.mul"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test8_splat", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[32767, 16384]> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<16> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.sext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.mul"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test8_vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[32767, -32767]> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<16> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.sext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.mul"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test8_vec2", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -32767 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.sext"(%2) : (i32) -> i64 - %4 = "llvm.mul"(%3, %0) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test9", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-32767> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<16> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.sext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.mul"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test9_splat", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[-32767, -10]> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<16> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.sext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.mul"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test9_vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 65535 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.zext"(%2) : (i32) -> i64 - %4 = "llvm.mul"(%3, %0) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<65535> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<16> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.lshr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.zext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.mul"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test10_splat", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[65535, 2]> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<16> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.lshr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.zext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.mul"(%3, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test10_vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %1 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %2 = "llvm.sext"(%0) : (i32) -> i64 - %3 = "llvm.sext"(%1) : (i32) -> i64 - %4 = "llvm.add"(%2, %3) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %1 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %2 = "llvm.sext"(%0) : (i32) -> i64 - %3 = "llvm.sext"(%1) : (i32) -> i64 - %4 = "llvm.mul"(%2, %3) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %1 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %2 = "llvm.sext"(%0) : (i32) -> i64 - %3 = "llvm.sext"(%1) : (i32) -> i64 - %4 = "llvm.sub"(%2, %3) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %1 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %2 = "llvm.zext"(%0) : (i32) -> i64 - %3 = "llvm.zext"(%1) : (i32) -> i64 - %4 = "llvm.sub"(%2, %3) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.sext"(%2) : (i32) -> i64 - %4 = "llvm.sub"(%0, %3) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<8> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.sext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.sub"(%0, %3) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test15vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4294967294 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.zext"(%2) : (i32) -> i64 - %4 = "llvm.sub"(%0, %3) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test16", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<4294967294> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.lshr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.zext"(%2) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.sub"(%0, %3) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%4) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "test16vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %1 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %2 = "llvm.zext"(%0) : (i32) -> i64 - %3 = "llvm.zext"(%1) : (i32) -> i64 - %4 = "llvm.sub"(%2, %3) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test17", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2147481648 : i64} : () -> i64 - %1 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %2 = "llvm.sext"(%1) : (i32) -> i64 - %3 = "llvm.sub"(%0, %2) : (i64, i64) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test18", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2147481648 : i64} : () -> i64 - %1 = "llvm.call"() {callee = @callee, fastmathFlags = #llvm.fastmath<>} : () -> i32 - %2 = "llvm.sext"(%1) : (i32) -> i64 - %3 = "llvm.sub"(%0, %2) : (i64, i64) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test19", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @callee() -> i32 + llvm.func @use(i64) + llvm.func @sext_sext_add(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.ashr %arg0, %1 : i32 + %4 = llvm.sext %2 : i32 to i64 + %5 = llvm.sext %3 : i32 to i64 + %6 = llvm.add %4, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @sext_zext_add_mismatched_exts(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.lshr %arg0, %1 : i32 + %4 = llvm.sext %2 : i32 to i64 + %5 = llvm.zext %3 : i32 to i64 + %6 = llvm.add %4, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @sext_sext_add_mismatched_types(%arg0: i16, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(7 : i16) : i16 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i16 + %3 = llvm.ashr %arg1, %1 : i32 + %4 = llvm.sext %2 : i16 to i64 + %5 = llvm.sext %3 : i32 to i64 + %6 = llvm.add %4, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @sext_sext_add_extra_use1(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.ashr %arg0, %1 : i32 + %4 = llvm.sext %2 : i32 to i64 + llvm.call @use(%4) : (i64) -> () + %5 = llvm.sext %3 : i32 to i64 + %6 = llvm.add %4, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @sext_sext_add_extra_use2(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.ashr %arg0, %1 : i32 + %4 = llvm.sext %2 : i32 to i64 + %5 = llvm.sext %3 : i32 to i64 + llvm.call @use(%5) : (i64) -> () + %6 = llvm.add %4, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @sext_sext_add_extra_use3(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.ashr %arg0, %1 : i32 + %4 = llvm.sext %2 : i32 to i64 + llvm.call @use(%4) : (i64) -> () + %5 = llvm.sext %3 : i32 to i64 + llvm.call @use(%5) : (i64) -> () + %6 = llvm.add %4, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @test1(%arg0: i32) -> i64 { + %0 = llvm.call @callee() : () -> i32 + %1 = llvm.call @callee() : () -> i32 + %2 = llvm.sext %0 : i32 to i64 + %3 = llvm.sext %1 : i32 to i64 + %4 = llvm.add %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @test2(%arg0: i32) -> i64 { + %0 = llvm.call @callee() : () -> i32 + %1 = llvm.call @callee() : () -> i32 + %2 = llvm.add %0, %1 : i32 + %3 = llvm.sext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @test3(%arg0: i32) -> i64 { + %0 = llvm.call @callee() : () -> i32 + %1 = llvm.call @callee() : () -> i32 + %2 = llvm.sext %0 : i32 to i64 + %3 = llvm.sext %1 : i32 to i64 + %4 = llvm.mul %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @test4(%arg0: i32) -> i64 { + %0 = llvm.call @callee() : () -> i32 + %1 = llvm.call @callee() : () -> i32 + %2 = llvm.mul %0, %1 : i32 + %3 = llvm.sext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @test5(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(1073741823 : i64) : i64 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.sext %2 : i32 to i64 + %4 = llvm.add %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @sext_add_constant_extra_use(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(1073741823 : i64) : i64 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.sext %2 : i32 to i64 + llvm.call @use(%3) : (i64) -> () + %4 = llvm.add %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @test5_splat(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1073741823> : vector<2xi64>) : vector<2xi64> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.sext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.add %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test5_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.sext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.add %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test6(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1073741824 : i64) : i64 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.sext %2 : i32 to i64 + %4 = llvm.add %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @test6_splat(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1073741824> : vector<2xi64>) : vector<2xi64> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.sext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.add %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test6_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-1, -2]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.sext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.add %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test6_vec2(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-1, 1]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.sext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.add %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test7(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + %4 = llvm.add %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @test7_splat(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<2147483647> : vector<2xi64>) : vector<2xi64> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.add %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test7_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.add %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test8(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(32767 : i64) : i64 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.sext %2 : i32 to i64 + %4 = llvm.mul %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @test8_splat(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<32767> : vector<2xi64>) : vector<2xi64> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.sext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.mul %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test8_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[32767, 16384]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.sext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.mul %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test8_vec2(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[32767, -32767]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.sext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.mul %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test9(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(-32767 : i64) : i64 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.sext %2 : i32 to i64 + %4 = llvm.mul %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @test9_splat(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-32767> : vector<2xi64>) : vector<2xi64> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.sext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.mul %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test9_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-32767, -10]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.sext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.mul %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test10(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + %4 = llvm.mul %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @test10_splat(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<65535> : vector<2xi64>) : vector<2xi64> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.mul %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test10_vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[65535, 2]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.mul %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test11(%arg0: i32) -> i64 { + %0 = llvm.call @callee() : () -> i32 + %1 = llvm.call @callee() : () -> i32 + %2 = llvm.sext %0 : i32 to i64 + %3 = llvm.sext %1 : i32 to i64 + %4 = llvm.add %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @test12(%arg0: i32) -> i64 { + %0 = llvm.call @callee() : () -> i32 + %1 = llvm.call @callee() : () -> i32 + %2 = llvm.sext %0 : i32 to i64 + %3 = llvm.sext %1 : i32 to i64 + %4 = llvm.mul %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @test13(%arg0: i32) -> i64 { + %0 = llvm.call @callee() : () -> i32 + %1 = llvm.call @callee() : () -> i32 + %2 = llvm.sext %0 : i32 to i64 + %3 = llvm.sext %1 : i32 to i64 + %4 = llvm.sub %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @test14(%arg0: i32) -> i64 { + %0 = llvm.call @callee() : () -> i32 + %1 = llvm.call @callee() : () -> i32 + %2 = llvm.zext %0 : i32 to i64 + %3 = llvm.zext %1 : i32 to i64 + %4 = llvm.sub %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @test15(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(8 : i64) : i64 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.sext %2 : i32 to i64 + %4 = llvm.sub %1, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @test15vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<8> : vector<2xi64>) : vector<2xi64> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.sext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.sub %1, %3 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test16(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(4294967294 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + %4 = llvm.sub %1, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @test16vec(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<4294967294> : vector<2xi64>) : vector<2xi64> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.sub %1, %3 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test17(%arg0: i32) -> i64 { + %0 = llvm.call @callee() : () -> i32 + %1 = llvm.call @callee() : () -> i32 + %2 = llvm.zext %0 : i32 to i64 + %3 = llvm.zext %1 : i32 to i64 + %4 = llvm.sub %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @test18(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(2147481648 : i64) : i64 + %1 = llvm.call @callee() : () -> i32 + %2 = llvm.sext %1 : i32 to i64 + %3 = llvm.sub %0, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @test19(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(-2147481648 : i64) : i64 + %1 = llvm.call @callee() : () -> i32 + %2 = llvm.sext %1 : i32 to i64 + %3 = llvm.sub %0, %2 : i64 + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/narrow-switch.ll.mlir b/test/LLVMDialect/InstCombine/narrow-switch.ll.mlir new file mode 100644 index 000000000..10398af33 --- /dev/null +++ b/test/LLVMDialect/InstCombine/narrow-switch.ll.mlir @@ -0,0 +1,175 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @a(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.mlir.global external @njob(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.func @positive1(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(231 : i32) : i32 + %2 = llvm.mlir.constant(123 : i32) : i32 + %3 = llvm.mlir.constant(213 : i32) : i32 + %4 = llvm.mlir.constant(24 : i32) : i32 + %5 = llvm.and %arg0, %0 : i64 + llvm.switch %5 : i64, ^bb3 [ + 10: ^bb4(%1 : i32), + 100: ^bb1, + 1001: ^bb2 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb4(%3 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb4(%2 : i32) + ^bb3: // pred: ^bb0 + llvm.br ^bb4(%4 : i32) + ^bb4(%6: i32): // 4 preds: ^bb0, ^bb1, ^bb2, ^bb3 + llvm.return %6 : i32 + } + llvm.func @negative1(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(-4294967296 : i64) : i64 + %1 = llvm.mlir.constant(231 : i32) : i32 + %2 = llvm.mlir.constant(123 : i32) : i32 + %3 = llvm.mlir.constant(213 : i32) : i32 + %4 = llvm.mlir.constant(24 : i32) : i32 + %5 = llvm.or %arg0, %0 : i64 + llvm.switch %5 : i64, ^bb3 [ + 18446744073709551606: ^bb4(%1 : i32), + 18446744073709551516: ^bb1, + 18446744073709550615: ^bb2 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb4(%3 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb4(%2 : i32) + ^bb3: // pred: ^bb0 + llvm.br ^bb4(%4 : i32) + ^bb4(%6: i32): // 4 preds: ^bb0, ^bb1, ^bb2, ^bb3 + llvm.return %6 : i32 + } + llvm.func @trunc72to68(%arg0: i72) -> i32 { + %0 = llvm.mlir.constant(295147905179352825855 : i72) : i72 + %1 = llvm.mlir.constant(231 : i32) : i32 + %2 = llvm.mlir.constant(123 : i32) : i32 + %3 = llvm.mlir.constant(213 : i32) : i32 + %4 = llvm.mlir.constant(24 : i32) : i32 + %5 = llvm.and %arg0, %0 : i72 + llvm.switch %5 : i72, ^bb3 [ + 10: ^bb4(%1 : i32), + 100: ^bb1, + 1001: ^bb2 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb4(%3 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb4(%2 : i32) + ^bb3: // pred: ^bb0 + llvm.br ^bb4(%4 : i32) + ^bb4(%6: i32): // 4 preds: ^bb0, ^bb1, ^bb2, ^bb3 + llvm.return %6 : i32 + } + llvm.func @trunc64to58(%arg0: i64) { + %0 = llvm.mlir.constant(15 : i64) : i64 + %1 = llvm.mlir.constant(-6425668444178048401 : i64) : i64 + %2 = llvm.mlir.constant(5170979678563097242 : i64) : i64 + %3 = llvm.mlir.constant(1627972535142754813 : i64) : i64 + %4 = llvm.and %arg0, %0 : i64 + %5 = llvm.mul %4, %1 : i64 + %6 = llvm.add %5, %2 : i64 + %7 = llvm.mul %6, %3 : i64 + llvm.switch %7 : i64, ^bb3 [ + 847514119312061490: ^bb1, + 866231301959785189: ^bb2 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb3 + ^bb2: // pred: ^bb0 + llvm.br ^bb3 + ^bb3: // 3 preds: ^bb0, ^bb1, ^bb2 + llvm.return + } + llvm.func @PR31260(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(-126 : i8) : i8 + %2 = llvm.mlir.constant(5 : i8) : i8 + %3 = llvm.mlir.constant(3 : i8) : i8 + %4 = llvm.mlir.constant(1 : i8) : i8 + %5 = llvm.and %arg0, %0 : i8 + %6 = llvm.add %5, %1 overflow : i8 + llvm.switch %6 : i8, ^bb1 [ + 130: ^bb2, + 132: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.return %4 : i8 + ^bb2: // pred: ^bb0 + llvm.return %3 : i8 + ^bb3: // pred: ^bb0 + llvm.return %2 : i8 + } + llvm.func @trunc32to16(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(1034460917 : i32) : i32 + %2 = llvm.mlir.constant(16 : i32) : i32 + %3 = llvm.mlir.constant(-917677090 : i32) : i32 + %4 = llvm.mlir.constant(92 : i32) : i32 + %5 = llvm.mlir.constant(91 : i32) : i32 + %6 = llvm.mlir.constant(90 : i32) : i32 + %7 = llvm.mlir.constant(113 : i32) : i32 + %8 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %9 = llvm.xor %arg0, %1 : i32 + %10 = llvm.lshr %9, %2 : i32 + %11 = llvm.add %10, %3 : i32 + llvm.switch %11 : i32, ^bb4 [ + 3377290269: ^bb1, + 3377290207: ^bb2, + 3377290306: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.store %6, %8 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb5 + ^bb2: // pred: ^bb0 + llvm.store %5, %8 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb5 + ^bb3: // pred: ^bb0 + llvm.store %4, %8 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb5 + ^bb4: // pred: ^bb0 + llvm.store %7, %8 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb5 + ^bb5: // 4 preds: ^bb1, ^bb2, ^bb3, ^bb4 + %12 = llvm.load %8 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %12 : i32 + } + llvm.func @goo() -> i32 + llvm.func @PR29009() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @njob : !llvm.ptr + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.addressof @a : !llvm.ptr + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.mlir.constant(6 : i32) : i32 + llvm.br ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb6 + %7 = llvm.load volatile %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + %8 = llvm.icmp "ne" %7, %0 : i32 + llvm.cond_br %8, ^bb2, ^bb7 + ^bb2: // pred: ^bb1 + %9 = llvm.call @goo() : () -> i32 + %10 = llvm.and %9, %2 : i32 + llvm.switch %10 : i32, ^bb3 [ + 0: ^bb4, + 3: ^bb5 + ] + ^bb3: // pred: ^bb2 + llvm.store %6, %4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb6 + ^bb4: // pred: ^bb2 + llvm.store %5, %4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb6 + ^bb5: // pred: ^bb2 + llvm.store %3, %4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb6 + ^bb6: // 3 preds: ^bb3, ^bb4, ^bb5 + llvm.br ^bb1 + ^bb7: // pred: ^bb1 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/narrow.ll.mlir b/test/LLVMDialect/InstCombine/narrow.ll.mlir new file mode 100644 index 000000000..07cb56091 --- /dev/null +++ b/test/LLVMDialect/InstCombine/narrow.ll.mlir @@ -0,0 +1,110 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.zext %0 : i1 to i32 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.and %1, %3 : i32 + %5 = llvm.trunc %4 : i32 to i1 + llvm.return %5 : i1 + } + llvm.func @shrink_xor(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.xor %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @shrink_xor_vec(%arg0: vector<2xi64>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi64>) : vector<2xi64> + %1 = llvm.xor %arg0, %0 : vector<2xi64> + %2 = llvm.trunc %1 : vector<2xi64> to vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @shrink_or(%arg0: i6) -> i3 { + %0 = llvm.mlir.constant(-31 : i6) : i6 + %1 = llvm.or %arg0, %0 : i6 + %2 = llvm.trunc %1 : i6 to i3 + llvm.return %2 : i3 + } + llvm.func @shrink_or_vec(%arg0: vector<2xi16>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[-1, 256]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.or %arg0, %0 : vector<2xi16> + %2 = llvm.trunc %1 : vector<2xi16> to vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @shrink_and(%arg0: i64) -> i31 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.and %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i31 + llvm.return %2 : i31 + } + llvm.func @shrink_and_vec(%arg0: vector<2xi33>) -> vector<2xi32> { + %0 = llvm.mlir.constant(6 : i33) : i33 + %1 = llvm.mlir.constant(-4294967296 : i33) : i33 + %2 = llvm.mlir.constant(dense<[-4294967296, 6]> : vector<2xi33>) : vector<2xi33> + %3 = llvm.and %arg0, %2 : vector<2xi33> + %4 = llvm.trunc %3 : vector<2xi33> to vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @searchArray1(%arg0: i32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(1000 : i32) : i32 + llvm.br ^bb1(%0, %1 : i32, i8) + ^bb1(%4: i32, %5: i8): // 2 preds: ^bb0, ^bb1 + %6 = llvm.getelementptr %arg1[%4] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + %8 = llvm.icmp "eq" %7, %arg0 : i32 + %9 = llvm.zext %8 : i1 to i8 + %10 = llvm.or %5, %9 : i8 + %11 = llvm.add %4, %2 : i32 + %12 = llvm.icmp "eq" %11, %3 : i32 + llvm.cond_br %12, ^bb2, ^bb1(%11, %10 : i32, i8) + ^bb2: // pred: ^bb1 + %13 = llvm.icmp "ne" %10, %1 : i8 + llvm.return %13 : i1 + } + llvm.func @searchArray2(%arg0: i32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(1000 : i64) : i64 + %4 = llvm.mlir.constant(0 : i8) : i8 + llvm.br ^bb1(%0, %1 : i64, i8) + ^bb1(%5: i64, %6: i8): // 2 preds: ^bb0, ^bb1 + %7 = llvm.getelementptr %arg1[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %8 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + %9 = llvm.icmp "eq" %8, %arg0 : i32 + %10 = llvm.zext %9 : i1 to i8 + %11 = llvm.and %6, %10 : i8 + %12 = llvm.add %5, %2 : i64 + %13 = llvm.icmp "eq" %12, %3 : i64 + llvm.cond_br %13, ^bb2, ^bb1(%12, %11 : i64, i8) + ^bb2: // pred: ^bb1 + %14 = llvm.icmp "ne" %11, %4 : i8 + llvm.return %14 : i1 + } + llvm.func @shrinkLogicAndPhi1(%arg0: i8, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(21 : i32) : i32 + %1 = llvm.mlir.constant(33 : i32) : i32 + llvm.cond_br %arg1, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : i32) + ^bb2(%2: i32): // 2 preds: ^bb0, ^bb1 + %3 = llvm.zext %arg0 : i8 to i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @shrinkLogicAndPhi2(%arg0: i8, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(21 : i32) : i32 + %1 = llvm.mlir.constant(33 : i32) : i32 + llvm.cond_br %arg1, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : i32) + ^bb2(%2: i32): // 2 preds: ^bb0, ^bb1 + %3 = llvm.zext %arg0 : i8 to i32 + %4 = llvm.xor %3, %2 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/neg-alloca.ll.mlir b/test/LLVMDialect/InstCombine/neg-alloca.ll.mlir index ffc56f103..5b1245a68 100644 --- a/test/LLVMDialect/InstCombine/neg-alloca.ll.mlir +++ b/test/LLVMDialect/InstCombine/neg-alloca.ll.mlir @@ -1,16 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 24 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = -4 : i64} : () -> i64 - %2 = "llvm.mul"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.add"(%2, %0) : (i64, i64) -> i64 - %4 = "llvm.alloca"(%3) : (i64) -> !llvm.ptr - %5 = "llvm.bitcast"(%4) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%5) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(!llvm.ptr) + llvm.func @foo(%arg0: i64) { + %0 = llvm.mlir.constant(-4 : i64) : i64 + %1 = llvm.mlir.constant(24 : i64) : i64 + %2 = llvm.mul %arg0, %0 overflow : i64 + %3 = llvm.add %2, %1 overflow : i64 + %4 = llvm.alloca %3 x i8 {alignment = 4 : i64} : (i64) -> !llvm.ptr + llvm.call @use(%4) : (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/negated-bitmask.ll.mlir b/test/LLVMDialect/InstCombine/negated-bitmask.ll.mlir new file mode 100644 index 000000000..88d7f9339 --- /dev/null +++ b/test/LLVMDialect/InstCombine/negated-bitmask.ll.mlir @@ -0,0 +1,208 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @neg_mask1_lshr(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.lshr %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.sub %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @sub_mask1_lshr(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.and %2, %0 : i8 + %4 = llvm.sub %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @neg_mask1_lshr_vector_uniform(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %4 = llvm.lshr %arg0, %0 : vector<4xi32> + %5 = llvm.and %4, %1 : vector<4xi32> + %6 = llvm.sub %3, %5 : vector<4xi32> + llvm.return %6 : vector<4xi32> + } + llvm.func @neg_mask1_lshr_vector_nonuniform(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[3, 4, 5, 6]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %4 = llvm.lshr %arg0, %0 : vector<4xi32> + %5 = llvm.and %4, %1 : vector<4xi32> + %6 = llvm.sub %3, %5 : vector<4xi32> + llvm.return %6 : vector<4xi32> + } + llvm.func @sub_mask1_lshr_vector_nonuniform(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[3, 4, 5, 6]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<[5, 0, -1, 65556]> : vector<4xi32>) : vector<4xi32> + %3 = llvm.lshr %arg0, %0 : vector<4xi32> + %4 = llvm.and %3, %1 : vector<4xi32> + %5 = llvm.sub %2, %4 : vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @sub_mask1_trunc_lshr(%arg0: i64) -> i8 { + %0 = llvm.mlir.constant(15 : i64) : i64 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(10 : i8) : i8 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i8 + %5 = llvm.and %4, %1 : i8 + %6 = llvm.sub %2, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @sub_sext_mask1_trunc_lshr(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(15 : i64) : i64 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(10 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i64 + %4 = llvm.trunc %3 : i64 to i8 + %5 = llvm.and %4, %1 : i8 + %6 = llvm.sext %5 : i8 to i32 + %7 = llvm.sub %2, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @sub_zext_trunc_lshr(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(15 : i64) : i64 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i1 + %4 = llvm.zext %3 : i1 to i32 + %5 = llvm.sub %1, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @neg_mask2_lshr(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.lshr %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.sub %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @neg_mask2_lshr_outofbounds(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(8 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.lshr %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.sub %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @neg_mask1_lshr_vector_var(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %4 = llvm.and %3, %0 : vector<2xi32> + %5 = llvm.sub %2, %4 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @neg_mask1_lshr_extrause_mask(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.lshr %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.sub %2, %4 : i8 + llvm.call @usei8(%4) : (i8) -> () + llvm.return %5 : i8 + } + llvm.func @neg_mask1_lshr_extrause_lshr(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.lshr %arg0, %0 : vector<2xi32> + %5 = llvm.and %4, %1 : vector<2xi32> + %6 = llvm.sub %3, %5 : vector<2xi32> + llvm.call @usev2i32(%4) : (vector<2xi32>) -> () + llvm.return %6 : vector<2xi32> + } + llvm.func @neg_signbit(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.zext %2 : i8 to i32 + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @neg_signbit_use1(%arg0: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(0 : i64) : i64 + %8 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %9 = llvm.lshr %arg0, %6 : vector<2xi32> + llvm.call @usev2i32(%9) : (vector<2xi32>) -> () + %10 = llvm.zext %9 : vector<2xi32> to vector<2xi64> + %11 = llvm.sub %8, %10 : vector<2xi64> + llvm.return %11 : vector<2xi64> + } + llvm.func @neg_signbit_use2(%arg0: i5) -> i8 { + %0 = llvm.mlir.constant(4 : i5) : i5 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i5 + %3 = llvm.zext %2 : i5 to i8 + llvm.call @usei8(%3) : (i8) -> () + %4 = llvm.sub %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @neg_not_signbit1(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.zext %2 : i8 to i32 + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @neg_not_signbit2(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.zext %2 : i8 to i32 + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @neg_not_signbit3(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.zext %2 : i8 to i32 + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @neg_mask(%arg0: i32, %arg1: i16) -> i32 { + %0 = llvm.mlir.constant(15 : i16) : i16 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.sext %arg1 : i16 to i32 + %3 = llvm.sub %arg0, %2 overflow : i32 + %4 = llvm.lshr %arg1, %0 : i16 + %5 = llvm.zext %4 : i16 to i32 + %6 = llvm.sub %1, %5 overflow : i32 + %7 = llvm.and %3, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @neg_mask_const(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(1000 : i32) : i32 + %1 = llvm.mlir.constant(15 : i16) : i16 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sext %arg0 : i16 to i32 + %4 = llvm.sub %0, %3 overflow : i32 + %5 = llvm.lshr %arg0, %1 : i16 + %6 = llvm.zext %5 : i16 to i32 + %7 = llvm.sub %2, %6 overflow : i32 + %8 = llvm.and %4, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @usei8(i8) + llvm.func @usev2i32(vector<2xi32>) +} diff --git a/test/LLVMDialect/InstCombine/nested-select.ll.mlir b/test/LLVMDialect/InstCombine/nested-select.ll.mlir new file mode 100644 index 000000000..e5e40c045 --- /dev/null +++ b/test/LLVMDialect/InstCombine/nested-select.ll.mlir @@ -0,0 +1,355 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use.i1(i1) + llvm.func @use.i8(i8) + llvm.func @andcond(%arg0: i1, %arg1: i1, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + %2 = llvm.select %arg0, %arg2, %arg3 : i1, i8 + %3 = llvm.select %1, %arg4, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @orcond(%arg0: i1, %arg1: i1, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + %2 = llvm.select %arg0, %arg2, %arg3 : i1, i8 + %3 = llvm.select %1, %2, %arg4 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @andcond.extrause0(%arg0: i1, %arg1: i1, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + llvm.call @use.i1(%1) : (i1) -> () + %2 = llvm.select %arg0, %arg2, %arg3 : i1, i8 + %3 = llvm.select %1, %arg4, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @orcond.extrause0(%arg0: i1, %arg1: i1, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + llvm.call @use.i1(%1) : (i1) -> () + %2 = llvm.select %arg0, %arg2, %arg3 : i1, i8 + %3 = llvm.select %1, %2, %arg4 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @andcond.extrause1(%arg0: i1, %arg1: i1, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + %2 = llvm.select %arg0, %arg2, %arg3 : i1, i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.select %1, %arg4, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @orcond.extrause1(%arg0: i1, %arg1: i1, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + %2 = llvm.select %arg0, %arg2, %arg3 : i1, i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.select %1, %2, %arg4 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @andcond.extrause2(%arg0: i1, %arg1: i1, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + llvm.call @use.i1(%1) : (i1) -> () + %2 = llvm.select %arg0, %arg2, %arg3 : i1, i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.select %1, %arg4, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @orcond.extrause2(%arg0: i1, %arg1: i1, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + llvm.call @use.i1(%1) : (i1) -> () + %2 = llvm.select %arg0, %arg2, %arg3 : i1, i8 + llvm.call @use.i8(%2) : (i8) -> () + %3 = llvm.select %1, %2, %arg4 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @andcond.different.inner.cond(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i8, %arg4: i8, %arg5: i8) -> i8 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg2, %0 : i1, i1 + %2 = llvm.select %arg1, %arg3, %arg4 : i1, i8 + %3 = llvm.select %1, %arg5, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @orcond.different.inner.cond(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i8, %arg4: i8, %arg5: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg2 : i1, i1 + %2 = llvm.select %arg1, %arg3, %arg4 : i1, i8 + %3 = llvm.select %1, %2, %arg5 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @andcond.different.inner.cond.both.inverted(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1, %arg5: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.select %2, %arg2, %1 : i1, i1 + %4 = llvm.xor %arg1, %0 : i1 + %5 = llvm.select %4, %arg4, %1 : i1, i1 + %6 = llvm.select %3, %arg5, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @orcond.different.inner.cond.both.inverted(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1, %arg5: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.select %1, %0, %arg2 : i1, i1 + %3 = llvm.xor %arg1, %0 : i1 + %4 = llvm.select %3, %0, %arg3 : i1, i1 + %5 = llvm.select %2, %4, %arg5 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @andcond.different.inner.cond.inverted.in.outer.cond(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1, %arg5: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.select %2, %arg2, %1 : i1, i1 + %4 = llvm.select %arg1, %arg4, %1 : i1, i1 + %5 = llvm.select %3, %arg5, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @orcond.different.inner.cond.inverted.in.outer.cond(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1, %arg5: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.select %1, %0, %arg2 : i1, i1 + %3 = llvm.select %arg1, %0, %arg3 : i1, i1 + %4 = llvm.select %2, %3, %arg5 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @andcond.different.inner.cond.inverted.in.inner.sel(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1, %arg5: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %arg2, %0 : i1, i1 + %3 = llvm.xor %arg1, %1 : i1 + %4 = llvm.select %3, %arg4, %0 : i1, i1 + %5 = llvm.select %2, %arg5, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @orcond.different.inner.cond.inverted.in.inner.sel(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1, %arg5: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg2 : i1, i1 + %2 = llvm.xor %arg1, %0 : i1 + %3 = llvm.select %2, %0, %arg3 : i1, i1 + %4 = llvm.select %1, %3, %arg5 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @D139275_c4001580(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i8, %arg4: i8, %arg5: i8) -> i8 { + %0 = llvm.xor %arg0, %arg1 : i1 + %1 = llvm.and %arg2, %arg1 : i1 + %2 = llvm.select %0, %arg3, %arg4 : i1, i8 + %3 = llvm.select %1, %arg5, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @andcond.001.inv.outer.cond(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %arg1, %0 : i1, i1 + %3 = llvm.select %arg0, %arg2, %arg3 : i1, i1 + %4 = llvm.xor %2, %1 : i1 + %5 = llvm.select %4, %3, %0 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @orcond.001.inv.outer.cond(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + %2 = llvm.select %arg0, %arg2, %arg3 : i1, i1 + %3 = llvm.xor %1, %0 : i1 + %4 = llvm.select %3, %0, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @andcond.010.inv.inner.cond.in.inner.sel(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %arg1, %0 : i1, i1 + %3 = llvm.xor %arg0, %1 : i1 + %4 = llvm.select %3, %arg3, %0 : i1, i1 + %5 = llvm.select %2, %arg4, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @orcond.010.inv.inner.cond.in.inner.sel(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.select %2, %0, %arg2 : i1, i1 + %4 = llvm.select %1, %3, %arg4 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @andcond.100.inv.inner.cond.in.outer.cond(%arg0: i1, %arg1: i1, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.select %2, %arg1, %1 : i1, i1 + %4 = llvm.select %arg0, %arg2, %arg3 : i1, i8 + %5 = llvm.select %3, %arg4, %4 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @orcond.100.inv.inner.cond.in.outer.cond(%arg0: i1, %arg1: i1, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.select %1, %0, %arg1 : i1, i1 + %3 = llvm.select %arg0, %arg2, %arg3 : i1, i8 + %4 = llvm.select %2, %3, %arg4 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @andcond.011.inv.outer.cond.inv.inner.cond.in.inner.sel(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %arg1, %0 : i1, i1 + %3 = llvm.xor %arg0, %1 : i1 + %4 = llvm.select %3, %1, %arg3 : i1, i1 + %5 = llvm.xor %2, %1 : i1 + llvm.call @use.i1(%4) : (i1) -> () + %6 = llvm.select %5, %4, %0 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @orcond.011.inv.outer.cond.inv.inner.cond.in.inner.sel(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg0, %0, %arg1 : i1, i1 + %3 = llvm.xor %arg0, %0 : i1 + %4 = llvm.select %3, %arg2, %1 : i1, i1 + llvm.call @use.i1(%4) : (i1) -> () + %5 = llvm.xor %2, %0 : i1 + %6 = llvm.select %5, %0, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @andcond.101.inv.outer.cond.inv.inner.cond.in.outer.cond(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.select %2, %arg1, %1 : i1, i1 + %4 = llvm.select %arg0, %arg2, %arg3 : i1, i1 + llvm.call @use.i1(%4) : (i1) -> () + %5 = llvm.xor %3, %0 : i1 + %6 = llvm.select %5, %4, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @orcond.101.inv.outer.cond.inv.inner.cond.in.outer.cond(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.select %1, %0, %arg1 : i1, i1 + %3 = llvm.select %arg0, %arg2, %arg3 : i1, i1 + llvm.call @use.i1(%3) : (i1) -> () + %4 = llvm.xor %2, %0 : i1 + %5 = llvm.select %4, %0, %3 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @andcond.110.inv.inner.cond.in.inner.sel.inv.inner.cond.in.outer.cond(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.select %2, %arg1, %1 : i1, i1 + %4 = llvm.xor %arg0, %0 : i1 + %5 = llvm.select %4, %arg3, %1 : i1, i1 + %6 = llvm.select %3, %arg4, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @orcond.110.inv.inner.cond.in.inner.sel.inv.inner.cond.in.outer.cond(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.select %1, %0, %arg1 : i1, i1 + %3 = llvm.xor %arg0, %0 : i1 + %4 = llvm.select %3, %0, %arg2 : i1, i1 + %5 = llvm.select %2, %4, %arg4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @andcond.111.inv.all.conds(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.select %2, %arg1, %1 : i1, i1 + llvm.call @use.i1(%3) : (i1) -> () + %4 = llvm.xor %arg0, %0 : i1 + %5 = llvm.select %4, %arg3, %1 : i1, i1 + llvm.call @use.i1(%5) : (i1) -> () + %6 = llvm.xor %3, %0 : i1 + %7 = llvm.select %6, %5, %1 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @orcond.111.inv.all.conds(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.select %1, %0, %arg1 : i1, i1 + llvm.call @use.i1(%2) : (i1) -> () + %3 = llvm.xor %arg0, %0 : i1 + %4 = llvm.select %3, %0, %arg2 : i1, i1 + llvm.call @use.i1(%4) : (i1) -> () + %5 = llvm.xor %2, %0 : i1 + %6 = llvm.select %5, %0, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @test_implied_true(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(5 : i8) : i8 + %3 = llvm.mlir.constant(20 : i8) : i8 + %4 = llvm.icmp "slt" %arg0, %0 : i8 + %5 = llvm.icmp "slt" %arg0, %1 : i8 + %6 = llvm.select %4, %1, %2 : i1, i8 + %7 = llvm.select %5, %6, %3 : i1, i8 + llvm.return %7 : i8 + } + llvm.func @test_implied_true_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %4 = llvm.mlir.constant(dense<20> : vector<2xi8>) : vector<2xi8> + %5 = llvm.icmp "slt" %arg0, %0 : vector<2xi8> + %6 = llvm.icmp "slt" %arg0, %2 : vector<2xi8> + %7 = llvm.select %5, %2, %3 : vector<2xi1>, vector<2xi8> + %8 = llvm.select %6, %7, %4 : vector<2xi1>, vector<2xi8> + llvm.return %8 : vector<2xi8> + } + llvm.func @test_implied_true_falseval(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(5 : i8) : i8 + %3 = llvm.mlir.constant(20 : i8) : i8 + %4 = llvm.icmp "slt" %arg0, %0 : i8 + %5 = llvm.icmp "sgt" %arg0, %1 : i8 + %6 = llvm.select %4, %1, %2 : i1, i8 + %7 = llvm.select %5, %3, %6 : i1, i8 + llvm.return %7 : i8 + } + llvm.func @test_implied_false(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(5 : i8) : i8 + %3 = llvm.mlir.constant(20 : i8) : i8 + %4 = llvm.icmp "sgt" %arg0, %0 : i8 + %5 = llvm.icmp "slt" %arg0, %1 : i8 + %6 = llvm.select %4, %1, %2 : i1, i8 + %7 = llvm.select %5, %6, %3 : i1, i8 + llvm.return %7 : i8 + } + llvm.func @test_imply_fail(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-10 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(5 : i8) : i8 + %3 = llvm.mlir.constant(20 : i8) : i8 + %4 = llvm.icmp "slt" %arg0, %0 : i8 + %5 = llvm.icmp "slt" %arg0, %1 : i8 + %6 = llvm.select %4, %1, %2 : i1, i8 + %7 = llvm.select %5, %6, %3 : i1, i8 + llvm.return %7 : i8 + } + llvm.func @test_imply_type_mismatch(%arg0: vector<2xi8>, %arg1: i8) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %4 = llvm.mlir.constant(dense<20> : vector<2xi8>) : vector<2xi8> + %5 = llvm.icmp "slt" %arg0, %0 : vector<2xi8> + %6 = llvm.icmp "slt" %arg1, %1 : i8 + %7 = llvm.select %5, %2, %3 : vector<2xi1>, vector<2xi8> + %8 = llvm.select %6, %7, %4 : i1, vector<2xi8> + llvm.return %8 : vector<2xi8> + } + llvm.func @test_dont_crash(%arg0: i1, %arg1: vector<4xi1>, %arg2: vector<4xi1>) -> vector<4xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %2 = llvm.select %arg0, %arg1, %1 : i1, vector<4xi1> + %3 = llvm.and %2, %arg2 : vector<4xi1> + llvm.return %3 : vector<4xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/new-delete-itanium-32.ll.mlir b/test/LLVMDialect/InstCombine/new-delete-itanium-32.ll.mlir index a0c4b3133..b81bc7580 100644 --- a/test/LLVMDialect/InstCombine/new-delete-itanium-32.ll.mlir +++ b/test/LLVMDialect/InstCombine/new-delete-itanium-32.ll.mlir @@ -1,61 +1,44 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_Znwj", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_Znaj", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_ZnwjSt11align_val_t", type = !llvm.func (i32, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_ZnajSt11align_val_t", type = !llvm.func (i32, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_ZnwjSt11align_val_tRKSt9nothrow_t", type = !llvm.func (i32, i32, ptr>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_ZnajSt11align_val_tRKSt9nothrow_t", type = !llvm.func (i32, i32, ptr>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_ZdlPvj", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_ZdaPvj", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_ZdlPvSt11align_val_t", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_ZdaPvSt11align_val_t", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_ZdlPvjSt11align_val_t", type = !llvm.func, i32, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_ZdaPvjSt11align_val_t", type = !llvm.func, i32, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_ZdlPvSt11align_val_tRKSt9nothrow_t", type = !llvm.func, i32, ptr>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_ZdaPvSt11align_val_tRKSt9nothrow_t", type = !llvm.func, i32, ptr>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.assume", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 32 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.alloca"(%4) : (i32) -> !llvm.ptr> - %6 = "llvm.call"(%3) {callee = @_Znwj, fastmathFlags = #llvm.fastmath<>} : (i32) -> !llvm.ptr - "llvm.call"(%6, %3) {callee = @_ZdlPvj, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> () - %7 = "llvm.call"(%3) {callee = @_Znaj, fastmathFlags = #llvm.fastmath<>} : (i32) -> !llvm.ptr - "llvm.call"(%7, %3) {callee = @_ZdaPvj, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> () - %8 = "llvm.call"(%3, %2) {callee = @_ZnwjSt11align_val_t, fastmathFlags = #llvm.fastmath<>} : (i32, i32) -> !llvm.ptr - "llvm.call"(%8, %2) {callee = @_ZdlPvSt11align_val_t, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> () - %9 = "llvm.call"(%3, %2) {callee = @_ZnajSt11align_val_t, fastmathFlags = #llvm.fastmath<>} : (i32, i32) -> !llvm.ptr - "llvm.call"(%9, %2) {callee = @_ZdaPvSt11align_val_t, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> () - %10 = "llvm.call"(%3, %2, %5) {callee = @_ZnwjSt11align_val_tRKSt9nothrow_t, fastmathFlags = #llvm.fastmath<>} : (i32, i32, !llvm.ptr>) -> !llvm.ptr - "llvm.call"(%10, %2, %5) {callee = @_ZdlPvSt11align_val_tRKSt9nothrow_t, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, !llvm.ptr>) -> () - %11 = "llvm.call"(%3, %2, %5) {callee = @_ZnajSt11align_val_tRKSt9nothrow_t, fastmathFlags = #llvm.fastmath<>} : (i32, i32, !llvm.ptr>) -> !llvm.ptr - "llvm.call"(%11, %2, %5) {callee = @_ZdaPvSt11align_val_tRKSt9nothrow_t, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, !llvm.ptr>) -> () - %12 = "llvm.call"(%3, %2) {callee = @_ZnwjSt11align_val_t, fastmathFlags = #llvm.fastmath<>} : (i32, i32) -> !llvm.ptr - "llvm.call"(%12, %3, %2) {callee = @_ZdlPvjSt11align_val_t, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i32) -> () - %13 = "llvm.call"(%3, %2) {callee = @_ZnajSt11align_val_t, fastmathFlags = #llvm.fastmath<>} : (i32, i32) -> !llvm.ptr - "llvm.call"(%13, %3, %2) {callee = @_ZdaPvjSt11align_val_t, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i32) -> () - %14 = "llvm.call"(%3, %1) {callee = @_ZnajSt11align_val_t, fastmathFlags = #llvm.fastmath<>} : (i32, i32) -> !llvm.ptr - "llvm.call"(%0) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.call"(%14, %3, %1) {callee = @_ZdaPvjSt11align_val_t, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i32) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "elim_new_delete_pairs", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @_Znwj(i32) -> !llvm.ptr + llvm.func @_Znaj(i32) -> !llvm.ptr + llvm.func @_ZnwjSt11align_val_t(i32, i32) -> !llvm.ptr + llvm.func @_ZnajSt11align_val_t(i32, i32) -> !llvm.ptr + llvm.func @_ZnwjSt11align_val_tRKSt9nothrow_t(i32, i32, !llvm.ptr) -> !llvm.ptr + llvm.func @_ZnajSt11align_val_tRKSt9nothrow_t(i32, i32, !llvm.ptr) -> !llvm.ptr + llvm.func @_ZdlPvj(!llvm.ptr, i32) + llvm.func @_ZdaPvj(!llvm.ptr, i32) + llvm.func @_ZdlPvSt11align_val_t(!llvm.ptr, i32) + llvm.func @_ZdaPvSt11align_val_t(!llvm.ptr, i32) + llvm.func @_ZdlPvjSt11align_val_t(!llvm.ptr, i32, i32) + llvm.func @_ZdaPvjSt11align_val_t(!llvm.ptr, i32, i32) + llvm.func @_ZdlPvSt11align_val_tRKSt9nothrow_t(!llvm.ptr, i32, !llvm.ptr) + llvm.func @_ZdaPvSt11align_val_tRKSt9nothrow_t(!llvm.ptr, i32, !llvm.ptr) + llvm.func @elim_new_delete_pairs() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.mlir.constant(16 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.alloca %0 x !llvm.struct<"nothrow_t", ()> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %6 = llvm.call @_Znwj(%1) : (i32) -> !llvm.ptr + llvm.call @_ZdlPvj(%6, %1) : (!llvm.ptr, i32) -> () + %7 = llvm.call @_Znaj(%1) : (i32) -> !llvm.ptr + llvm.call @_ZdaPvj(%7, %1) : (!llvm.ptr, i32) -> () + %8 = llvm.call @_ZnwjSt11align_val_t(%1, %2) : (i32, i32) -> !llvm.ptr + llvm.call @_ZdlPvSt11align_val_t(%8, %2) : (!llvm.ptr, i32) -> () + %9 = llvm.call @_ZnajSt11align_val_t(%1, %2) : (i32, i32) -> !llvm.ptr + llvm.call @_ZdaPvSt11align_val_t(%9, %2) : (!llvm.ptr, i32) -> () + %10 = llvm.call @_ZnwjSt11align_val_tRKSt9nothrow_t(%1, %2, %5) : (i32, i32, !llvm.ptr) -> !llvm.ptr + llvm.call @_ZdlPvSt11align_val_tRKSt9nothrow_t(%10, %2, %5) : (!llvm.ptr, i32, !llvm.ptr) -> () + %11 = llvm.call @_ZnajSt11align_val_tRKSt9nothrow_t(%1, %2, %5) : (i32, i32, !llvm.ptr) -> !llvm.ptr + llvm.call @_ZdaPvSt11align_val_tRKSt9nothrow_t(%11, %2, %5) : (!llvm.ptr, i32, !llvm.ptr) -> () + %12 = llvm.call @_ZnwjSt11align_val_t(%1, %2) : (i32, i32) -> !llvm.ptr + llvm.call @_ZdlPvjSt11align_val_t(%12, %1, %2) : (!llvm.ptr, i32, i32) -> () + %13 = llvm.call @_ZnajSt11align_val_t(%1, %2) : (i32, i32) -> !llvm.ptr + llvm.call @_ZdaPvjSt11align_val_t(%13, %1, %2) : (!llvm.ptr, i32, i32) -> () + %14 = llvm.call @_ZnajSt11align_val_t(%1, %3) : (i32, i32) -> !llvm.ptr + "llvm.intr.assume"(%4) : (i1) -> () + llvm.call @_ZdaPvjSt11align_val_t(%14, %1, %3) : (!llvm.ptr, i32, i32) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/new-delete-itanium.ll.mlir b/test/LLVMDialect/InstCombine/new-delete-itanium.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/new-delete-msvc.ll.mlir b/test/LLVMDialect/InstCombine/new-delete-msvc.ll.mlir index 7da627ac4..1a1acaf3e 100644 --- a/test/LLVMDialect/InstCombine/new-delete-msvc.ll.mlir +++ b/test/LLVMDialect/InstCombine/new-delete-msvc.ll.mlir @@ -1,13 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "\01??2@YAPEAX_K@Z", type = !llvm.func (i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "\01??3@YAXPEAX@Z", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %1 = "llvm.call"(%0) {callee = @"\01??2@YAPEAX_K@Z", fastmathFlags = #llvm.fastmath<>} : (i64) -> !llvm.ptr - "llvm.call"(%1) {callee = @"\01??3@YAXPEAX@Z", fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test9", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @"\01??2@YAPEAX_K@Z"(i64) -> (!llvm.ptr {llvm.noalias}) attributes {passthrough = ["nobuiltin"]} + llvm.func @"\01??3@YAXPEAX@Z"(!llvm.ptr) attributes {passthrough = ["nobuiltin"]} + llvm.func @test9() { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.call @"\01??2@YAPEAX_K@Z"(%0) : (i64) -> !llvm.ptr + llvm.call @"\01??3@YAXPEAX@Z"(%1) : (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/no-negzero.ll.mlir b/test/LLVMDialect/InstCombine/no-negzero.ll.mlir index cb471b190..b518cb7d6 100644 --- a/test/LLVMDialect/InstCombine/no-negzero.ll.mlir +++ b/test/LLVMDialect/InstCombine/no-negzero.ll.mlir @@ -1,29 +1,25 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.000000e+00 : f64} : () -> f64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %4 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %5 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %6 = "llvm.bitcast"(%1) : (i32) -> i32 - "llvm.store"(%arg0, %3) : (f64, !llvm.ptr) -> () - %7 = "llvm.load"(%3) : (!llvm.ptr) -> f64 - %8 = "llvm.call"(%7) {callee = @fabs, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %9 = "llvm.call"(%8) {callee = @sqrt, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %10 = "llvm.fadd"(%9, %0) : (f64, f64) -> f64 - "llvm.store"(%10, %5) : (f64, !llvm.ptr) -> () - %11 = "llvm.load"(%5) : (!llvm.ptr) -> f64 - "llvm.store"(%11, %4) : (f64, !llvm.ptr) -> () - "llvm.br"()[^bb1] : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @mysqrt(%arg0: f64) -> f64 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %3 = llvm.alloca %0 x f64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x f64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %5 = llvm.alloca %0 x f64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %6 = llvm.bitcast %1 : i32 to i32 + llvm.store %arg0, %3 {alignment = 4 : i64} : f64, !llvm.ptr + %7 = llvm.load %3 {alignment = 8 : i64} : !llvm.ptr -> f64 + %8 = llvm.call @fabs(%7) : (f64) -> f64 + %9 = llvm.call @sqrt(%8) : (f64) -> f64 + %10 = llvm.fadd %9, %2 : f64 + llvm.store %10, %5 {alignment = 8 : i64} : f64, !llvm.ptr + %11 = llvm.load %5 {alignment = 8 : i64} : !llvm.ptr -> f64 + llvm.store %11, %4 {alignment = 8 : i64} : f64, !llvm.ptr + llvm.br ^bb1 ^bb1: // pred: ^bb0 - %12 = "llvm.load"(%4) : (!llvm.ptr) -> f64 - "llvm.return"(%12) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "mysqrt", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fabs", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sqrt", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %12 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> f64 + llvm.return %12 : f64 + } + llvm.func @fabs(f64) -> f64 + llvm.func @sqrt(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} +} diff --git a/test/LLVMDialect/InstCombine/no-unwind-inline-asm.ll.mlir b/test/LLVMDialect/InstCombine/no-unwind-inline-asm.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/no_cgscc_assert.ll.mlir b/test/LLVMDialect/InstCombine/no_cgscc_assert.ll.mlir index 20d774dfd..3285bf5cb 100644 --- a/test/LLVMDialect/InstCombine/no_cgscc_assert.ll.mlir +++ b/test/LLVMDialect/InstCombine/no_cgscc_assert.ll.mlir @@ -1,11 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fmul"(%arg0, %arg0) : (f32, f32) -> f32 - %1 = "llvm.call"(%0) {callee = @sqrtf, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sqrtf", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bar(%arg0: f32) -> f32 { + %0 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.call @sqrtf(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @sqrtf(f32) -> f32 +} diff --git a/test/LLVMDialect/InstCombine/no_sink_instruction.ll.mlir b/test/LLVMDialect/InstCombine/no_sink_instruction.ll.mlir index 95cb2d9a4..fa0cb4678 100644 --- a/test/LLVMDialect/InstCombine/no_sink_instruction.ll.mlir +++ b/test/LLVMDialect/InstCombine/no_sink_instruction.ll.mlir @@ -1,13 +1,11 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.sdiv"(%arg1, %arg2) : (i32, i32) -> i32 - %1 = "llvm.add"(%arg2, %arg1) : (i32, i32) -> i32 - "llvm.cond_br"(%arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.sdiv %arg1, %arg2 : i32 + %1 = llvm.add %arg2, %arg1 : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.return"(%1) : (i32) -> () + llvm.return %1 : i32 ^bb2: // pred: ^bb0 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/noalias-scope-decl.ll.mlir b/test/LLVMDialect/InstCombine/noalias-scope-decl.ll.mlir new file mode 100644 index 000000000..47b406de5 --- /dev/null +++ b/test/LLVMDialect/InstCombine/noalias-scope-decl.ll.mlir @@ -0,0 +1,105 @@ +#alias_scope_domain = #llvm.alias_scope_domain> +#alias_scope = #llvm.alias_scope, domain = #alias_scope_domain> +#alias_scope1 = #llvm.alias_scope, domain = #alias_scope_domain> +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test01(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(43 : i8) : i8 + llvm.intr.experimental.noalias.scope.decl #alias_scope + llvm.store %0, %arg0 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.store %1, %arg1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } + llvm.func @test02_keep(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(43 : i8) : i8 + llvm.intr.experimental.noalias.scope.decl #alias_scope + llvm.store %0, %arg0 {alias_scopes = [#alias_scope], alignment = 1 : i64} : i8, !llvm.ptr + llvm.store %1, %arg1 {alignment = 1 : i64, noalias_scopes = [#alias_scope, #alias_scope1]} : i8, !llvm.ptr + llvm.return + } + llvm.func @test03(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(43 : i8) : i8 + llvm.intr.experimental.noalias.scope.decl #alias_scope + llvm.store %0, %arg0 {alias_scopes = [#alias_scope1], alignment = 1 : i64} : i8, !llvm.ptr + llvm.store %1, %arg1 {alignment = 1 : i64, noalias_scopes = [#alias_scope, #alias_scope1]} : i8, !llvm.ptr + llvm.return + } + llvm.func @test04_keep(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(43 : i8) : i8 + llvm.intr.experimental.noalias.scope.decl #alias_scope + llvm.store %0, %arg0 {alias_scopes = [#alias_scope, #alias_scope1], alignment = 1 : i64} : i8, !llvm.ptr + llvm.store %1, %arg1 {alignment = 1 : i64, noalias_scopes = [#alias_scope, #alias_scope1]} : i8, !llvm.ptr + llvm.return + } + llvm.func @test05_keep(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(43 : i8) : i8 + llvm.intr.experimental.noalias.scope.decl #alias_scope + llvm.store %0, %arg0 {alias_scopes = [#alias_scope, #alias_scope1], alignment = 1 : i64} : i8, !llvm.ptr + llvm.store %1, %arg1 {alignment = 1 : i64, noalias_scopes = [#alias_scope]} : i8, !llvm.ptr + llvm.return + } + llvm.func @test06(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(43 : i8) : i8 + llvm.intr.experimental.noalias.scope.decl #alias_scope + llvm.store %0, %arg0 {alias_scopes = [#alias_scope, #alias_scope1], alignment = 1 : i64} : i8, !llvm.ptr + llvm.store %1, %arg1 {alignment = 1 : i64, noalias_scopes = [#alias_scope1]} : i8, !llvm.ptr + llvm.return + } + llvm.func @test07(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(43 : i8) : i8 + llvm.intr.experimental.noalias.scope.decl #alias_scope + llvm.store %0, %arg0 {alias_scopes = [#alias_scope], alignment = 1 : i64} : i8, !llvm.ptr + llvm.store %1, %arg1 {alignment = 1 : i64, noalias_scopes = [#alias_scope1]} : i8, !llvm.ptr + llvm.return + } + llvm.func @test08(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(43 : i8) : i8 + llvm.intr.experimental.noalias.scope.decl #alias_scope + llvm.store %0, %arg0 {alias_scopes = [#alias_scope1], alignment = 1 : i64} : i8, !llvm.ptr + llvm.store %1, %arg1 {alignment = 1 : i64, noalias_scopes = [#alias_scope]} : i8, !llvm.ptr + llvm.return + } + llvm.func @test11(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i8) : i8 + llvm.intr.experimental.noalias.scope.decl #alias_scope + llvm.store %0, %arg0 {alias_scopes = [#alias_scope], alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } + llvm.func @test12(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i8) : i8 + llvm.intr.experimental.noalias.scope.decl #alias_scope + llvm.store %0, %arg0 {alias_scopes = [#alias_scope1], alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } + llvm.func @test13(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i8) : i8 + llvm.intr.experimental.noalias.scope.decl #alias_scope + llvm.store %0, %arg0 {alias_scopes = [#alias_scope, #alias_scope1], alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } + llvm.func @test14(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i8) : i8 + llvm.intr.experimental.noalias.scope.decl #alias_scope + llvm.store %0, %arg0 {alignment = 1 : i64, noalias_scopes = [#alias_scope]} : i8, !llvm.ptr + llvm.return + } + llvm.func @test15(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i8) : i8 + llvm.intr.experimental.noalias.scope.decl #alias_scope + llvm.store %0, %arg0 {alignment = 1 : i64, noalias_scopes = [#alias_scope1]} : i8, !llvm.ptr + llvm.return + } + llvm.func @test16(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i8) : i8 + llvm.intr.experimental.noalias.scope.decl #alias_scope + llvm.store %0, %arg0 {alignment = 1 : i64, noalias_scopes = [#alias_scope, #alias_scope1]} : i8, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/non-integral-pointers.ll.mlir b/test/LLVMDialect/InstCombine/non-integral-pointers.ll.mlir index 999012592..e843d70eb 100644 --- a/test/LLVMDialect/InstCombine/non-integral-pointers.ll.mlir +++ b/test/LLVMDialect/InstCombine/non-integral-pointers.ll.mlir @@ -1,63 +1,50 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 50 : i64} : () -> i64 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr - %2 = "llvm.getelementptr"(%1, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "f_0", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 50 : i64} : () -> i64 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr - %2 = "llvm.getelementptr"(%1, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "f_1", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - "llvm.store"(%0, %arg1) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "f_2", type = !llvm.func>, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - "llvm.store"(%0, %arg1) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "f_3", type = !llvm.func>, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i64} : () -> i64 - %1 = "llvm.load"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.call"() {callee = @alloc, fastmathFlags = #llvm.fastmath<>} : () -> !llvm.ptr - %3 = "llvm.addrspacecast"(%2) : (!llvm.ptr) -> !llvm.ptr - %4 = "llvm.bitcast"(%3) : (!llvm.ptr) -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %0) : (!llvm.ptr>, i64) -> !llvm.ptr> - "llvm.store"(%1, %5) : (!llvm.ptr, !llvm.ptr>) -> () - %6 = "llvm.bitcast"(%5) : (!llvm.ptr>) -> !llvm.ptr - %7 = "llvm.load"(%6) : (!llvm.ptr) -> i64 - "llvm.return"(%7) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "g", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, 4>): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i64} : () -> i64 - %1 = "llvm.load"(%arg0) : (!llvm.ptr, 4>) -> !llvm.ptr - %2 = "llvm.call"() {callee = @alloc, fastmathFlags = #llvm.fastmath<>} : () -> !llvm.ptr - %3 = "llvm.bitcast"(%2) : (!llvm.ptr) -> !llvm.ptr, 4> - %4 = "llvm.getelementptr"(%3, %0) : (!llvm.ptr, 4>, i64) -> !llvm.ptr, 4> - "llvm.store"(%1, %4) : (!llvm.ptr, !llvm.ptr, 4>) -> () - %5 = "llvm.bitcast"(%4) : (!llvm.ptr, 4>) -> !llvm.ptr - %6 = "llvm.load"(%5) : (!llvm.ptr) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "g2", type = !llvm.func, 4>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "alloc", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @f_5} : () -> !llvm.ptr> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>) -> !llvm.ptr)>> - %2 = "llvm.call"(%1, %arg0) : (!llvm.ptr)>>, !llvm.ptr) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "f_4", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "f_5", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f_0() -> !llvm.ptr<4> { + %0 = llvm.mlir.zero : !llvm.ptr<4> + %1 = llvm.mlir.constant(50 : i64) : i64 + %2 = llvm.getelementptr %0[%1] : (!llvm.ptr<4>, i64) -> !llvm.ptr<4>, i8 + llvm.return %2 : !llvm.ptr<4> + } + llvm.func @f_1() -> !llvm.ptr<3> { + %0 = llvm.mlir.zero : !llvm.ptr<3> + %1 = llvm.mlir.constant(50 : i64) : i64 + %2 = llvm.getelementptr %0[%1] : (!llvm.ptr<3>, i64) -> !llvm.ptr<3>, i8 + llvm.return %2 : !llvm.ptr<3> + } + llvm.func @f_2(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr<4> + llvm.store %0, %arg1 {alignment = 8 : i64} : !llvm.ptr<4>, !llvm.ptr + llvm.return + } + llvm.func @f_3(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr<3> + llvm.store %0, %arg1 {alignment = 8 : i64} : !llvm.ptr<3>, !llvm.ptr + llvm.return + } + llvm.func @g(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr<4> + %2 = llvm.call @alloc() : () -> !llvm.ptr<4> + %3 = llvm.addrspacecast %2 : !llvm.ptr<4> to !llvm.ptr + %4 = llvm.getelementptr %3[%0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr<4> + llvm.store %1, %4 {alignment = 8 : i64} : !llvm.ptr<4>, !llvm.ptr + %5 = llvm.load %4 {alignment = 8 : i64} : !llvm.ptr -> i64 + llvm.return %5 : i64 + } + llvm.func @g2(%arg0: !llvm.ptr<4>) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr<4> -> !llvm.ptr + %2 = llvm.call @alloc() : () -> !llvm.ptr<4> + %3 = llvm.getelementptr %2[%0] : (!llvm.ptr<4>, i64) -> !llvm.ptr<4>, !llvm.ptr + llvm.store %1, %3 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr<4> + %4 = llvm.load %3 {alignment = 8 : i64} : !llvm.ptr<4> -> i64 + llvm.return %4 : i64 + } + llvm.func @alloc() -> !llvm.ptr<4> + llvm.func @f_4(%arg0: !llvm.ptr<4>) -> i64 { + %0 = llvm.mlir.addressof @f_5 : !llvm.ptr + %1 = llvm.call %0(%arg0) : !llvm.ptr, (!llvm.ptr<4>) -> i64 + llvm.return %1 : i64 + } + llvm.func @f_5(i64) -> i64 +} diff --git a/test/LLVMDialect/InstCombine/nonnull-attribute.ll.mlir b/test/LLVMDialect/InstCombine/nonnull-attribute.ll.mlir new file mode 100644 index 000000000..bd13e70b8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/nonnull-attribute.ll.mlir @@ -0,0 +1,13 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @as0() {addr_space = 0 : i32} : i32 + llvm.mlir.global external @as1() {addr_space = 1 : i32} : i32 + llvm.func @addrspace0(!llvm.ptr) + llvm.func @addrspace1(!llvm.ptr<1>) + llvm.func @test() { + %0 = llvm.mlir.addressof @as0 : !llvm.ptr + %1 = llvm.mlir.addressof @as1 : !llvm.ptr<1> + llvm.call @addrspace0(%0) : (!llvm.ptr) -> () + llvm.call @addrspace1(%1) : (!llvm.ptr<1>) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/nonnull-select.ll.mlir b/test/LLVMDialect/InstCombine/nonnull-select.ll.mlir new file mode 100644 index 000000000..bd94a843a --- /dev/null +++ b/test/LLVMDialect/InstCombine/nonnull-select.ll.mlir @@ -0,0 +1,54 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pr48975(%arg0: !llvm.ptr) -> (!llvm.ptr {llvm.nonnull}) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %2 = llvm.icmp "eq" %1, %0 : !llvm.ptr + %3 = llvm.select %2, %0, %arg0 : i1, !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @nonnull_ret(%arg0: i1, %arg1: !llvm.ptr) -> (!llvm.ptr {llvm.nonnull}) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.select %arg0, %arg1, %0 : i1, !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @nonnull_ret2(%arg0: i1, %arg1: !llvm.ptr) -> (!llvm.ptr {llvm.nonnull}) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.select %arg0, %0, %arg1 : i1, !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @nonnull_noundef_ret(%arg0: i1, %arg1: !llvm.ptr) -> (!llvm.ptr {llvm.nonnull, llvm.noundef}) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.select %arg0, %arg1, %0 : i1, !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @nonnull_noundef_ret2(%arg0: i1, %arg1: !llvm.ptr) -> (!llvm.ptr {llvm.nonnull, llvm.noundef}) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.select %arg0, %0, %arg1 : i1, !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @nonnull_call(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.select %arg0, %arg1, %0 : i1, !llvm.ptr + llvm.call @f(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @nonnull_call2(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.select %arg0, %0, %arg1 : i1, !llvm.ptr + llvm.call @f(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @nonnull_noundef_call(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.select %arg0, %arg1, %0 : i1, !llvm.ptr + llvm.call @f(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @nonnull_noundef_call2(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.select %arg0, %0, %arg1 : i1, !llvm.ptr + llvm.call @f(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @f(!llvm.ptr) +} diff --git a/test/LLVMDialect/InstCombine/not-add.ll.mlir b/test/LLVMDialect/InstCombine/not-add.ll.mlir new file mode 100644 index 000000000..d26412362 --- /dev/null +++ b/test/LLVMDialect/InstCombine/not-add.ll.mlir @@ -0,0 +1,162 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global extern_weak @g() {addr_space = 0 : i32} : i32 + llvm.func @use(i8) + llvm.func @basic(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.add %1, %arg1 : i8 + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @basic_com_add(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + %2 = llvm.add %arg0, %1 : i8 + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @basic_use_xor(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.add %1, %arg1 : i8 + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @basic_use_add(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.add %1, %arg1 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @basic_use_both(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.add %1, %arg1 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @basic_preserve_nsw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.add %1, %arg1 overflow : i8 + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @basic_preserve_nuw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.add %1, %arg1 overflow : i8 + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @basic_preserve_nuw_nsw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.add %1, %arg1 overflow : i8 + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @vector_test(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.xor %arg0, %0 : vector<4xi32> + %2 = llvm.add %1, %arg1 : vector<4xi32> + %3 = llvm.xor %2, %0 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @vector_test_poison(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.undef : vector<4xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.insertelement %0, %11[%12 : i32] : vector<4xi32> + %14 = llvm.mlir.constant(1 : i32) : i32 + %15 = llvm.insertelement %0, %13[%14 : i32] : vector<4xi32> + %16 = llvm.mlir.constant(2 : i32) : i32 + %17 = llvm.insertelement %1, %15[%16 : i32] : vector<4xi32> + %18 = llvm.mlir.constant(3 : i32) : i32 + %19 = llvm.insertelement %1, %17[%18 : i32] : vector<4xi32> + %20 = llvm.xor %arg0, %10 : vector<4xi32> + %21 = llvm.add %20, %arg1 : vector<4xi32> + %22 = llvm.xor %21, %19 : vector<4xi32> + llvm.return %22 : vector<4xi32> + } + llvm.func @vector_test_poison_nsw_nuw(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.undef : vector<4xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.insertelement %0, %11[%12 : i32] : vector<4xi32> + %14 = llvm.mlir.constant(1 : i32) : i32 + %15 = llvm.insertelement %0, %13[%14 : i32] : vector<4xi32> + %16 = llvm.mlir.constant(2 : i32) : i32 + %17 = llvm.insertelement %1, %15[%16 : i32] : vector<4xi32> + %18 = llvm.mlir.constant(3 : i32) : i32 + %19 = llvm.insertelement %1, %17[%18 : i32] : vector<4xi32> + %20 = llvm.xor %arg0, %10 : vector<4xi32> + %21 = llvm.add %20, %arg1 overflow : vector<4xi32> + %22 = llvm.xor %21, %19 : vector<4xi32> + llvm.return %22 : vector<4xi32> + } + llvm.func @pr50308(%arg0: i1, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %2 = llvm.add %1, %arg1 overflow : i32 + %3 = llvm.xor %2, %arg2 : i32 + %4 = llvm.add %1, %3 overflow : i32 + llvm.br ^bb2(%4 : i32) + ^bb2(%5: i32): // 2 preds: ^bb0, ^bb1 + %6 = llvm.sub %arg3, %5 overflow : i32 + llvm.return %6 : i32 + } + llvm.func @pr50370(%arg0: i32) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.addressof @g : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(65536 : i32) : i32 + %4 = llvm.mlir.constant(2147483647 : i32) : i32 + %5 = llvm.mlir.undef : i32 + %6 = llvm.mlir.undef : !llvm.ptr + %7 = llvm.xor %arg0, %0 : i32 + %8 = llvm.icmp "eq" %1, %2 : !llvm.ptr + %9 = llvm.zext %8 : i1 to i32 + %10 = llvm.or %9, %0 : i32 + %11 = llvm.or %10, %3 : i32 + %12 = llvm.ashr %3, %11 : i32 + %13 = llvm.srem %12, %7 : i32 + %14 = llvm.sdiv %11, %4 : i32 + %15 = llvm.add %13, %14 : i32 + %16 = llvm.srem %12, %15 : i32 + %17 = llvm.add %13, %12 : i32 + %18 = llvm.shl %14, %16 : i32 + %19 = llvm.xor %17, %18 : i32 + %20 = llvm.or %17, %5 : i32 + %21 = llvm.xor %19, %20 : i32 + llvm.store %21, %6 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/not.ll.mlir b/test/LLVMDialect/InstCombine/not.ll.mlir new file mode 100644 index 000000000..1322084e1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/not.ll.mlir @@ -0,0 +1,652 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use1(i1) + llvm.func @use8(i8) + llvm.func @f1() + llvm.func @f2() + llvm.func @test1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @invert_icmp(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "sle" %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @invert_fcmp(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f32 + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @not_not_cmp(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.icmp "slt" %1, %2 : i32 + llvm.return %3 : i1 + } + llvm.func @not_not_cmp_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.xor %arg0, %0 : vector<2xi32> + %2 = llvm.xor %arg1, %0 : vector<2xi32> + %3 = llvm.icmp "ugt" %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @not_cmp_constant(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @not_cmp_constant_vector(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %2 = llvm.xor %arg0, %0 : vector<2xi32> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test7(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.icmp "sle" %arg0, %arg1 : vector<2xi32> + %3 = llvm.xor %2, %1 : vector<2xi1> + llvm.return %3 : vector<2xi1> + } + llvm.func @not_ashr_not(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.ashr %1, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @not_ashr_const(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %0, %arg0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_ashr_const_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.ashr %0, %arg0 : vector<2xi8> + %3 = llvm.xor %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @not_lshr_const_negative(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_lshr_const(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_lshr_const_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %0, %arg0 : vector<2xi8> + %3 = llvm.xor %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @not_sub(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.xor %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @not_sub_extra_use(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + llvm.store %2, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.xor %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @not_sub_splat(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<123> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %0, %arg0 : vector<2xi32> + %3 = llvm.xor %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @not_sub_extra_use_splat(%arg0: vector<2xi32>, %arg1: !llvm.ptr) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<123> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %0, %arg0 : vector<2xi32> + llvm.store %2, %arg1 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + %3 = llvm.xor %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @not_sub_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 123]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %0, %arg0 : vector<2xi32> + %3 = llvm.xor %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @not_sub_extra_use_vec(%arg0: vector<2xi32>, %arg1: !llvm.ptr) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[123, 42]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %0, %arg0 : vector<2xi32> + llvm.store %2, %arg1 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + %3 = llvm.xor %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @not_add(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.xor %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @not_add_splat(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<123> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %arg0, %0 : vector<2xi32> + %3 = llvm.xor %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @not_add_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 123]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %arg0, %0 : vector<2xi32> + %3 = llvm.xor %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @not_select_cmp_cmp(%arg0: i32, %arg1: i32, %arg2: f32, %arg3: f32, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "sle" %arg0, %arg1 : i32 + %2 = llvm.fcmp "ugt" %arg2, %arg3 : f32 + %3 = llvm.select %arg4, %1, %2 : i1, i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @not_select_cmp_cmp_extra_use1(%arg0: i32, %arg1: i32, %arg2: f32, %arg3: f32, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "sle" %arg0, %arg1 : i32 + llvm.call @use1(%1) : (i1) -> () + %2 = llvm.fcmp "ugt" %arg2, %arg3 : f32 + %3 = llvm.select %arg4, %1, %2 : i1, i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @not_select_cmp_cmp_extra_use2(%arg0: i32, %arg1: i32, %arg2: f32, %arg3: f32, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "sle" %arg0, %arg1 : i32 + %2 = llvm.fcmp "ugt" %arg2, %arg3 : f32 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.select %arg4, %1, %2 : i1, i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @not_select_cmp_cmp_extra_use3(%arg0: i32, %arg1: i32, %arg2: f32, %arg3: f32, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "sle" %arg0, %arg1 : i32 + llvm.call @use1(%1) : (i1) -> () + %2 = llvm.fcmp "ugt" %arg2, %arg3 : f32 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.select %arg4, %1, %2 : i1, i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @not_select_cmp_cmp_extra_use4(%arg0: i32, %arg1: i32, %arg2: f32, %arg3: f32, %arg4: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "sle" %arg0, %arg1 : i32 + %2 = llvm.fcmp "ugt" %arg2, %arg3 : f32 + %3 = llvm.select %arg4, %1, %2 : i1, i1 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @not_select_cmpt(%arg0: f64, %arg1: f64, %arg2: i1, %arg3: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.select %arg3, %1, %arg2 : i1, i1 + %3 = llvm.xor %2, %0 : i1 + llvm.return %3 : i1 + } + llvm.func @not_select_cmpf(%arg0: i1, %arg1: i32, %arg2: i32, %arg3: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "ugt" %arg1, %arg2 : i32 + %2 = llvm.select %arg3, %arg0, %1 : i1, i1 + %3 = llvm.xor %2, %0 : i1 + llvm.return %3 : i1 + } + llvm.func @not_select_cmpt_extra_use(%arg0: f64, %arg1: f64, %arg2: i1, %arg3: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + llvm.call @use1(%1) : (i1) -> () + %2 = llvm.select %arg3, %1, %arg2 : i1, i1 + %3 = llvm.xor %2, %0 : i1 + llvm.return %3 : i1 + } + llvm.func @not_select_cmpf_extra_use(%arg0: i1, %arg1: i32, %arg2: i32, %arg3: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "ugt" %arg1, %arg2 : i32 + llvm.call @use1(%1) : (i1) -> () + %2 = llvm.select %arg3, %arg0, %1 : i1, i1 + %3 = llvm.xor %2, %0 : i1 + llvm.return %3 : i1 + } + llvm.func @not_or_neg(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.sub %0, %arg1 : i8 + %3 = llvm.or %2, %arg0 : i8 + %4 = llvm.xor %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @not_or_neg_commute_vec(%arg0: vector<3xi5>, %arg1: vector<3xi5>) -> vector<3xi5> { + %0 = llvm.mlir.constant(3 : i5) : i5 + %1 = llvm.mlir.constant(2 : i5) : i5 + %2 = llvm.mlir.constant(1 : i5) : i5 + %3 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi5>) : vector<3xi5> + %4 = llvm.mlir.poison : i5 + %5 = llvm.mlir.constant(0 : i5) : i5 + %6 = llvm.mlir.undef : vector<3xi5> + %7 = llvm.mlir.constant(0 : i32) : i32 + %8 = llvm.insertelement %5, %6[%7 : i32] : vector<3xi5> + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.insertelement %5, %8[%9 : i32] : vector<3xi5> + %11 = llvm.mlir.constant(2 : i32) : i32 + %12 = llvm.insertelement %4, %10[%11 : i32] : vector<3xi5> + %13 = llvm.mlir.constant(-1 : i5) : i5 + %14 = llvm.mlir.undef : vector<3xi5> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %13, %14[%15 : i32] : vector<3xi5> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %4, %16[%17 : i32] : vector<3xi5> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %13, %18[%19 : i32] : vector<3xi5> + %21 = llvm.mul %arg1, %3 : vector<3xi5> + %22 = llvm.sub %12, %arg0 : vector<3xi5> + %23 = llvm.or %21, %22 : vector<3xi5> + %24 = llvm.xor %23, %20 : vector<3xi5> + llvm.return %24 : vector<3xi5> + } + llvm.func @not_or_neg_use1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.or %2, %arg0 : i8 + %4 = llvm.xor %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @not_or_neg_use2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.sub %0, %arg1 : i8 + %3 = llvm.or %2, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.xor %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @not_select_bool(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %arg1, %arg2 : i1, i1 + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @not_select_bool_const1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @not_select_bool_const2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %arg1, %0 : i1, i1 + %3 = llvm.xor %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @not_select_bool_const3(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @not_select_bool_const4(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %0, %arg1 : i1, i1 + %3 = llvm.xor %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @not_logicalAnd_not_op0(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.xor %arg0, %1 : vector<2xi1> + %5 = llvm.select %4, %arg1, %3 : vector<2xi1>, vector<2xi1> + %6 = llvm.xor %5, %1 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @not_logicalAnd_not_op1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg1, %0 : i1 + %3 = llvm.select %arg0, %2, %1 : i1, i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @not_logicalAnd_not_op0_use1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.select %2, %arg1, %1 : i1, i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @not_logicalAnd_not_op0_use2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.select %2, %arg1, %1 : i1, i1 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @not_logicalOr_not_op0(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.xor %arg0, %1 : vector<2xi1> + %3 = llvm.select %2, %1, %arg1 : vector<2xi1>, vector<2xi1> + %4 = llvm.xor %3, %1 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @not_logicalOr_not_op1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg1, %0 : i1 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + %3 = llvm.xor %2, %0 : i1 + llvm.return %3 : i1 + } + llvm.func @not_logicalOr_not_op0_use1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + llvm.call @use1(%1) : (i1) -> () + %2 = llvm.select %1, %0, %arg1 : i1, i1 + %3 = llvm.xor %2, %0 : i1 + llvm.return %3 : i1 + } + llvm.func @not_logicalOr_not_op0_use2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.select %1, %0, %arg1 : i1, i1 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.xor %2, %0 : i1 + llvm.return %3 : i1 + } + llvm.func @bitcast_to_wide_elts_sext_bool(%arg0: vector<4xi1>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi64>) : vector<2xi64> + %1 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %2 = llvm.bitcast %1 : vector<4xi32> to vector<2xi64> + %3 = llvm.xor %2, %0 : vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @bitcast_to_narrow_elts_sext_bool(%arg0: vector<4xi1>) -> vector<8xi16> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi16>) : vector<8xi16> + %1 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %2 = llvm.bitcast %1 : vector<4xi32> to vector<8xi16> + %3 = llvm.xor %2, %0 : vector<8xi16> + llvm.return %3 : vector<8xi16> + } + llvm.func @bitcast_to_vec_sext_bool(%arg0: i1) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi16>) : vector<2xi16> + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.bitcast %1 : i32 to vector<2xi16> + %3 = llvm.xor %2, %0 : vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @bitcast_to_scalar_sext_bool(%arg0: vector<4xi1>) -> i128 { + %0 = llvm.mlir.constant(-1 : i128) : i128 + %1 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %2 = llvm.bitcast %1 : vector<4xi32> to i128 + %3 = llvm.xor %2, %0 : i128 + llvm.return %3 : i128 + } + llvm.func @bitcast_to_vec_sext_bool_use1(%arg0: i1) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.sext %arg0 : i1 to i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.bitcast %2 : i8 to vector<2xi4> + %4 = llvm.xor %3, %1 : vector<2xi4> + llvm.return %4 : vector<2xi4> + } + llvm.func @bitcast_to_scalar_sext_bool_use2(%arg0: vector<4xi1>) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.sext %arg0 : vector<4xi1> to vector<4xi2> + %2 = llvm.bitcast %1 : vector<4xi2> to i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.xor %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @invert_both_cmp_operands_add(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.add %arg1, %2 : i32 + %4 = llvm.icmp "sgt" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @invert_both_cmp_operands_sub(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.sub %2, %arg1 : i32 + %4 = llvm.icmp "ult" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @invert_both_cmp_operands_complex(%arg0: i1, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg2, %0 : i32 + %3 = llvm.xor %arg3, %0 : i32 + %4 = llvm.add %arg3, %1 : i32 + %5 = llvm.select %arg0, %4, %2 : i1, i32 + %6 = llvm.icmp "sle" %5, %3 : i32 + llvm.return %6 : i1 + } + llvm.func @test_sext(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.sext %2 : i1 to i32 + %4 = llvm.add %arg1, %3 : i32 + %5 = llvm.xor %4, %1 : i32 + llvm.return %5 : i32 + } + llvm.func @test_sext_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.icmp "eq" %arg0, %1 : vector<2xi32> + %4 = llvm.sext %3 : vector<2xi1> to vector<2xi32> + %5 = llvm.add %arg1, %4 : vector<2xi32> + %6 = llvm.xor %5, %2 : vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @test_zext_nneg(%arg0: i32, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-5 : i64) : i64 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + %4 = llvm.add %arg1, %1 : i64 + %5 = llvm.add %3, %arg2 : i64 + %6 = llvm.sub %4, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @test_trunc(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.zext %arg0 : i8 to i32 + %4 = llvm.add %3, %0 overflow : i32 + %5 = llvm.ashr %4, %1 : i32 + %6 = llvm.trunc %5 : i32 to i8 + %7 = llvm.xor %6, %2 : i8 + llvm.return %7 : i8 + } + llvm.func @test_trunc_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %3 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + %4 = llvm.add %3, %0 overflow : vector<2xi32> + %5 = llvm.ashr %4, %1 : vector<2xi32> + %6 = llvm.trunc %5 : vector<2xi32> to vector<2xi8> + %7 = llvm.xor %6, %2 : vector<2xi8> + llvm.return %7 : vector<2xi8> + } + llvm.func @test_zext(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.add %arg1, %3 : i32 + %5 = llvm.xor %4, %1 : i32 + llvm.return %5 : i32 + } + llvm.func @test_invert_demorgan_or(%arg0: i32, %arg1: i32, %arg2: i1) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.icmp "ne" %arg1, %0 : i32 + %4 = llvm.or %2, %3 : i1 + %5 = llvm.xor %arg2, %1 : i1 + %6 = llvm.or %5, %4 : i1 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @f1() : () -> () + llvm.unreachable + ^bb2: // pred: ^bb0 + llvm.call @f2() : () -> () + llvm.unreachable + } + llvm.func @test_invert_demorgan_or2(%arg0: i64, %arg1: i64, %arg2: i64) -> i1 { + %0 = llvm.mlir.constant(23 : i64) : i64 + %1 = llvm.mlir.constant(59 : i64) : i64 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "ugt" %arg0, %0 : i64 + %4 = llvm.icmp "ugt" %arg1, %1 : i64 + %5 = llvm.or %3, %4 : i1 + %6 = llvm.icmp "ugt" %arg2, %1 : i64 + %7 = llvm.or %5, %6 : i1 + %8 = llvm.xor %7, %2 : i1 + llvm.return %8 : i1 + } + llvm.func @test_invert_demorgan_or3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(178206 : i32) : i32 + %1 = llvm.mlir.constant(-195102 : i32) : i32 + %2 = llvm.mlir.constant(1506 : i32) : i32 + %3 = llvm.mlir.constant(-201547 : i32) : i32 + %4 = llvm.mlir.constant(716213 : i32) : i32 + %5 = llvm.mlir.constant(-918000 : i32) : i32 + %6 = llvm.mlir.constant(196112 : i32) : i32 + %7 = llvm.mlir.constant(true) : i1 + %8 = llvm.icmp "eq" %arg0, %0 : i32 + %9 = llvm.add %arg1, %1 : i32 + %10 = llvm.icmp "ult" %9, %2 : i32 + %11 = llvm.add %arg1, %3 : i32 + %12 = llvm.icmp "ult" %11, %4 : i32 + %13 = llvm.add %arg1, %5 : i32 + %14 = llvm.icmp "ult" %13, %6 : i32 + %15 = llvm.or %8, %10 : i1 + %16 = llvm.or %15, %12 : i1 + %17 = llvm.or %16, %14 : i1 + %18 = llvm.xor %17, %7 : i1 + llvm.return %18 : i1 + } + llvm.func @test_invert_demorgan_logical_or(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(27 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "eq" %arg0, %0 : i64 + %4 = llvm.icmp "eq" %arg1, %1 : i64 + %5 = llvm.select %3, %2, %4 : i1, i1 + %6 = llvm.icmp "eq" %arg0, %1 : i64 + %7 = llvm.or %6, %5 : i1 + %8 = llvm.xor %7, %2 : i1 + llvm.return %8 : i1 + } + llvm.func @test_invert_demorgan_and(%arg0: i32, %arg1: i32, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.icmp "ne" %arg1, %0 : i32 + %4 = llvm.and %2, %3 : i1 + %5 = llvm.xor %arg2, %1 : i1 + %6 = llvm.and %5, %4 : i1 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @f1() : () -> () + llvm.unreachable + ^bb2: // pred: ^bb0 + llvm.call @f2() : () -> () + llvm.unreachable + } + llvm.func @test_invert_demorgan_and2(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(9223372036854775807 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.add %arg0, %0 : i64 + %3 = llvm.and %2, %0 : i64 + %4 = llvm.xor %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @test_invert_demorgan_and3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(4095 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.add %arg1, %3 : i32 + %5 = llvm.and %4, %1 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @test_invert_demorgan_logical_and(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(27 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.icmp "eq" %arg0, %0 : i64 + %5 = llvm.icmp "eq" %arg1, %1 : i64 + %6 = llvm.select %4, %5, %2 : i1, i1 + %7 = llvm.icmp "eq" %arg0, %1 : i64 + %8 = llvm.or %7, %6 : i1 + %9 = llvm.xor %8, %3 : i1 + llvm.return %9 : i1 + } + llvm.func @test_invert_demorgan_and_multiuse(%arg0: i32, %arg1: i32, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "ne" %arg1, %0 : i32 + %4 = llvm.and %2, %3 : i1 + %5 = llvm.xor %arg2, %1 : i1 + %6 = llvm.and %5, %4 : i1 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @f1() : () -> () + llvm.unreachable + ^bb2: // pred: ^bb0 + llvm.call @f2() : () -> () + llvm.unreachable + } +} diff --git a/test/LLVMDialect/InstCombine/nothrow.ll.mlir b/test/LLVMDialect/InstCombine/nothrow.ll.mlir index 81ad15c9e..25899604d 100644 --- a/test/LLVMDialect/InstCombine/nothrow.ll.mlir +++ b/test/LLVMDialect/InstCombine/nothrow.ll.mlir @@ -1,10 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "t1", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @t1, fastmathFlags = #llvm.fastmath<>} : (i32) -> f64 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "t2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t1(i32) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["willreturn"]} + llvm.func @t2() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.call @t1(%0) : (i32) -> f64 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/nsw-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/nsw-inseltpoison.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/nsw.ll.mlir b/test/LLVMDialect/InstCombine/nsw.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/obfuscated_splat.ll.mlir b/test/LLVMDialect/InstCombine/obfuscated_splat.ll.mlir new file mode 100644 index 000000000..8c8be8e78 --- /dev/null +++ b/test/LLVMDialect/InstCombine/obfuscated_splat.ll.mlir @@ -0,0 +1,20 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_undef(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> vector<4xf32> + %2 = llvm.shufflevector %1, %0 [0, 0, -1, -1] : vector<4xf32> + %3 = llvm.shufflevector %2, %1 [0, 1, 4, -1] : vector<4xf32> + %4 = llvm.shufflevector %3, %1 [0, 1, 2, 4] : vector<4xf32> + llvm.store %4, %arg1 {alignment = 16 : i64} : vector<4xf32>, !llvm.ptr + llvm.return + } + llvm.func @test_poison(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> vector<4xf32> + %2 = llvm.shufflevector %1, %0 [0, 0, -1, -1] : vector<4xf32> + %3 = llvm.shufflevector %2, %1 [0, 1, 4, -1] : vector<4xf32> + %4 = llvm.shufflevector %3, %1 [0, 1, 2, 4] : vector<4xf32> + llvm.store %4, %arg1 {alignment = 16 : i64} : vector<4xf32>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/object-size-opaque.ll.mlir b/test/LLVMDialect/InstCombine/object-size-opaque.ll.mlir index 37cab90b7..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/object-size-opaque.ll.mlir +++ b/test/LLVMDialect/InstCombine/object-size-opaque.ll.mlir @@ -1,13 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.call"(%1, %0, %0, %0) {callee = @llvm.objectsize.i64.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i1, i1, i1) -> i64 - "llvm.store"(%2, %arg1) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func>, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.objectsize.i64.p0i8", type = !llvm.func, i1, i1, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/objsize-64.ll.mlir b/test/LLVMDialect/InstCombine/objsize-64.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/objsize-address-space.ll.mlir b/test/LLVMDialect/InstCombine/objsize-address-space.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/objsize.ll.mlir b/test/LLVMDialect/InstCombine/objsize.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/odr-linkage.ll.mlir b/test/LLVMDialect/InstCombine/odr-linkage.ll.mlir index 4142a7fd7..743209ba3 100644 --- a/test/LLVMDialect/InstCombine/odr-linkage.ll.mlir +++ b/test/LLVMDialect/InstCombine/odr-linkage.ll.mlir @@ -1,25 +1,24 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 2 : i64, sym_name = "g1", type = i32, value = 1 : i32} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 8 : i64, sym_name = "g2", type = i32, value = 2 : i32} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 9 : i64, sym_name = "g3", type = i32, value = 3 : i32} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 1 : i64, sym_name = "g4", type = i32, value = 4 : i32} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @g4} : () -> !llvm.ptr - %1 = "llvm.mlir.addressof"() {global_name = @g3} : () -> !llvm.ptr - %2 = "llvm.mlir.addressof"() {global_name = @g2} : () -> !llvm.ptr - %3 = "llvm.mlir.addressof"() {global_name = @g1} : () -> !llvm.ptr - %4 = "llvm.load"(%3) : (!llvm.ptr) -> i32 - %5 = "llvm.load"(%2) : (!llvm.ptr) -> i32 - %6 = "llvm.load"(%1) : (!llvm.ptr) -> i32 - %7 = "llvm.load"(%0) : (!llvm.ptr) -> i32 - %8 = "llvm.add"(%4, %5) : (i32, i32) -> i32 - %9 = "llvm.add"(%8, %6) : (i32, i32) -> i32 - %10 = "llvm.add"(%9, %7) : (i32, i32) -> i32 - "llvm.return"(%10) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global available_externally constant @g1(1 : i32) {addr_space = 0 : i32} : i32 + llvm.mlir.global linkonce_odr constant @g2(2 : i32) {addr_space = 0 : i32} : i32 + llvm.mlir.global weak_odr constant @g3(3 : i32) {addr_space = 0 : i32} : i32 + llvm.mlir.global internal constant @g4(4 : i32) {addr_space = 0 : i32, dso_local} : i32 + llvm.func @test() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.addressof @g1 : !llvm.ptr + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.addressof @g2 : !llvm.ptr + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.mlir.addressof @g3 : !llvm.ptr + %6 = llvm.mlir.constant(4 : i32) : i32 + %7 = llvm.mlir.addressof @g4 : !llvm.ptr + %8 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + %9 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + %10 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + %11 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + %12 = llvm.add %8, %9 : i32 + %13 = llvm.add %12, %10 : i32 + %14 = llvm.add %13, %11 : i32 + llvm.return %14 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/omit-urem-of-power-of-two-or-zero-when-comparing-with-zero.ll.mlir b/test/LLVMDialect/InstCombine/omit-urem-of-power-of-two-or-zero-when-comparing-with-zero.ll.mlir new file mode 100644 index 000000000..f6364e9a3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/omit-urem-of-power-of-two-or-zero-when-comparing-with-zero.ll.mlir @@ -0,0 +1,146 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0_scalar_urem_by_const(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.urem %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @p1_scalar_urem_by_nonconst(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.or %arg1, %1 : i32 + %5 = llvm.urem %3, %4 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @p2_scalar_shifted_urem_by_const(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %arg1 : i32 + %5 = llvm.urem %4, %1 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @p3_scalar_shifted2_urem_by_const(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %arg1 : i32 + %5 = llvm.urem %4, %1 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } + llvm.func @p4_vector_urem_by_const__splat(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<128> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<6> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %4 = llvm.and %arg0, %0 : vector<4xi32> + %5 = llvm.urem %4, %1 : vector<4xi32> + %6 = llvm.icmp "eq" %5, %3 : vector<4xi32> + llvm.return %6 : vector<4xi1> + } + llvm.func @p5_vector_urem_by_const__nonsplat(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<[128, 2, 4, 8]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[3, 5, 6, 9]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %4 = llvm.and %arg0, %0 : vector<4xi32> + %5 = llvm.urem %4, %1 : vector<4xi32> + %6 = llvm.icmp "eq" %5, %3 : vector<4xi32> + llvm.return %6 : vector<4xi1> + } + llvm.func @p6_vector_urem_by_const__nonsplat_poison0(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(dense<6> : vector<4xi32>) : vector<4xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %14 = llvm.and %arg0, %10 : vector<4xi32> + %15 = llvm.urem %14, %11 : vector<4xi32> + %16 = llvm.icmp "eq" %15, %13 : vector<4xi32> + llvm.return %16 : vector<4xi1> + } + llvm.func @p7_vector_urem_by_const__nonsplat_poison2(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<128> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<6> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.poison : i32 + %4 = llvm.mlir.undef : vector<4xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %2, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %3, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %2, %10[%11 : i32] : vector<4xi32> + %13 = llvm.and %arg0, %0 : vector<4xi32> + %14 = llvm.urem %13, %1 : vector<4xi32> + %15 = llvm.icmp "eq" %14, %12 : vector<4xi32> + llvm.return %15 : vector<4xi1> + } + llvm.func @p8_vector_urem_by_const__nonsplat_poison3(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(dense<6> : vector<4xi32>) : vector<4xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.mlir.undef : vector<4xi32> + %14 = llvm.mlir.constant(0 : i32) : i32 + %15 = llvm.insertelement %12, %13[%14 : i32] : vector<4xi32> + %16 = llvm.mlir.constant(1 : i32) : i32 + %17 = llvm.insertelement %12, %15[%16 : i32] : vector<4xi32> + %18 = llvm.mlir.constant(2 : i32) : i32 + %19 = llvm.insertelement %1, %17[%18 : i32] : vector<4xi32> + %20 = llvm.mlir.constant(3 : i32) : i32 + %21 = llvm.insertelement %12, %19[%20 : i32] : vector<4xi32> + %22 = llvm.and %arg0, %10 : vector<4xi32> + %23 = llvm.urem %22, %11 : vector<4xi32> + %24 = llvm.icmp "eq" %23, %21 : vector<4xi32> + llvm.return %24 : vector<4xi1> + } + llvm.func @n0_urem_of_maybe_not_power_of_two(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.urem %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @n1_urem_by_maybe_power_of_two(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.or %arg1, %1 : i32 + %5 = llvm.urem %3, %4 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/onehot_merge.ll.mlir b/test/LLVMDialect/InstCombine/onehot_merge.ll.mlir new file mode 100644 index 000000000..5af37b0ea --- /dev/null +++ b/test/LLVMDialect/InstCombine/onehot_merge.ll.mlir @@ -0,0 +1,730 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @and_consts(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.and %0, %arg0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %2, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @and_consts_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.and %0, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %2, %arg0 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.select %5, %3, %7 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @and_consts_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %0, %arg0 : vector<2xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi32> + %6 = llvm.and %3, %arg0 : vector<2xi32> + %7 = llvm.icmp "eq" %6, %2 : vector<2xi32> + %8 = llvm.or %5, %7 : vector<2xi1> + llvm.return %8 : vector<2xi1> + } + llvm.func @foo1_and(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.shl %0, %arg2 : i32 + %4 = llvm.and %2, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %3, %arg0 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.shl %0, %arg2 : i32 + %5 = llvm.and %3, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %4, %arg0 : i32 + %8 = llvm.icmp "eq" %7, %1 : i32 + %9 = llvm.select %6, %2, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @foo1_and_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.shl %0, %arg1 : vector<2xi32> + %4 = llvm.shl %0, %arg2 : vector<2xi32> + %5 = llvm.and %3, %arg0 : vector<2xi32> + %6 = llvm.icmp "eq" %5, %2 : vector<2xi32> + %7 = llvm.and %4, %arg0 : vector<2xi32> + %8 = llvm.icmp "eq" %7, %2 : vector<2xi32> + %9 = llvm.or %6, %8 : vector<2xi1> + llvm.return %9 : vector<2xi1> + } + llvm.func @foo1_and_commuted(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mul %arg0, %arg0 : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.shl %0, %arg2 : i32 + %5 = llvm.and %2, %3 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %4, %2 : i32 + %8 = llvm.icmp "eq" %7, %1 : i32 + %9 = llvm.or %6, %8 : i1 + llvm.return %9 : i1 + } + llvm.func @foo1_and_commuted_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mul %arg0, %arg0 : i32 + %4 = llvm.shl %0, %arg1 : i32 + %5 = llvm.shl %0, %arg2 : i32 + %6 = llvm.and %3, %4 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.and %5, %3 : i32 + %9 = llvm.icmp "eq" %8, %1 : i32 + %10 = llvm.select %7, %2, %9 : i1, i1 + llvm.return %10 : i1 + } + llvm.func @foo1_and_commuted_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mul %arg0, %arg0 : vector<2xi32> + %4 = llvm.shl %0, %arg1 : vector<2xi32> + %5 = llvm.shl %0, %arg2 : vector<2xi32> + %6 = llvm.and %3, %4 : vector<2xi32> + %7 = llvm.icmp "eq" %6, %2 : vector<2xi32> + %8 = llvm.and %5, %3 : vector<2xi32> + %9 = llvm.icmp "eq" %8, %2 : vector<2xi32> + %10 = llvm.or %7, %9 : vector<2xi1> + llvm.return %10 : vector<2xi1> + } + llvm.func @or_consts(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.and %0, %arg0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %2, %arg0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @or_consts_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %0, %arg0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %2, %arg0 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.select %5, %7, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @or_consts_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %0, %arg0 : vector<2xi32> + %5 = llvm.icmp "ne" %4, %2 : vector<2xi32> + %6 = llvm.and %3, %arg0 : vector<2xi32> + %7 = llvm.icmp "ne" %6, %2 : vector<2xi32> + %8 = llvm.and %5, %7 : vector<2xi1> + llvm.return %8 : vector<2xi1> + } + llvm.func @foo1_or(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.shl %0, %arg2 : i32 + %4 = llvm.and %2, %arg0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.and %3, %arg0 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_or_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.shl %0, %arg2 : i32 + %5 = llvm.and %3, %arg0 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %4, %arg0 : i32 + %8 = llvm.icmp "ne" %7, %1 : i32 + %9 = llvm.select %6, %8, %2 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @foo1_or_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.shl %0, %arg1 : vector<2xi32> + %4 = llvm.shl %0, %arg2 : vector<2xi32> + %5 = llvm.and %3, %arg0 : vector<2xi32> + %6 = llvm.icmp "ne" %5, %2 : vector<2xi32> + %7 = llvm.and %4, %arg0 : vector<2xi32> + %8 = llvm.icmp "ne" %7, %2 : vector<2xi32> + %9 = llvm.and %6, %8 : vector<2xi1> + llvm.return %9 : vector<2xi1> + } + llvm.func @foo1_or_commuted(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mul %arg0, %arg0 : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.shl %0, %arg2 : i32 + %5 = llvm.and %2, %3 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + %7 = llvm.and %4, %2 : i32 + %8 = llvm.icmp "ne" %7, %1 : i32 + %9 = llvm.and %6, %8 : i1 + llvm.return %9 : i1 + } + llvm.func @foo1_or_commuted_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mul %arg0, %arg0 : i32 + %4 = llvm.shl %0, %arg1 : i32 + %5 = llvm.shl %0, %arg2 : i32 + %6 = llvm.and %3, %4 : i32 + %7 = llvm.icmp "ne" %6, %1 : i32 + %8 = llvm.and %5, %3 : i32 + %9 = llvm.icmp "ne" %8, %1 : i32 + %10 = llvm.select %7, %9, %2 : i1, i1 + llvm.return %10 : i1 + } + llvm.func @foo1_or_commuted_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mul %arg0, %arg0 : vector<2xi32> + %4 = llvm.shl %0, %arg1 : vector<2xi32> + %5 = llvm.shl %0, %arg2 : vector<2xi32> + %6 = llvm.and %3, %4 : vector<2xi32> + %7 = llvm.icmp "ne" %6, %2 : vector<2xi32> + %8 = llvm.and %5, %3 : vector<2xi32> + %9 = llvm.icmp "ne" %8, %2 : vector<2xi32> + %10 = llvm.and %7, %9 : vector<2xi1> + llvm.return %10 : vector<2xi1> + } + llvm.func @foo1_and_signbit_lshr(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.lshr %1, %arg2 : i32 + %5 = llvm.and %3, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + %7 = llvm.and %4, %arg0 : i32 + %8 = llvm.icmp "eq" %7, %2 : i32 + %9 = llvm.or %6, %8 : i1 + llvm.return %9 : i1 + } + llvm.func @foo1_and_signbit_lshr_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.shl %0, %arg1 : i32 + %5 = llvm.lshr %1, %arg2 : i32 + %6 = llvm.and %4, %arg0 : i32 + %7 = llvm.icmp "eq" %6, %2 : i32 + %8 = llvm.and %5, %arg0 : i32 + %9 = llvm.icmp "eq" %8, %2 : i32 + %10 = llvm.select %7, %3, %9 : i1, i1 + llvm.return %10 : i1 + } + llvm.func @foo1_and_signbit_lshr_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.shl %0, %arg1 : vector<2xi32> + %5 = llvm.lshr %1, %arg2 : vector<2xi32> + %6 = llvm.and %4, %arg0 : vector<2xi32> + %7 = llvm.icmp "eq" %6, %3 : vector<2xi32> + %8 = llvm.and %5, %arg0 : vector<2xi32> + %9 = llvm.icmp "eq" %8, %3 : vector<2xi32> + %10 = llvm.or %7, %9 : vector<2xi1> + llvm.return %10 : vector<2xi1> + } + llvm.func @foo1_or_signbit_lshr(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.lshr %1, %arg2 : i32 + %5 = llvm.and %3, %arg0 : i32 + %6 = llvm.icmp "ne" %5, %2 : i32 + %7 = llvm.and %4, %arg0 : i32 + %8 = llvm.icmp "ne" %7, %2 : i32 + %9 = llvm.and %6, %8 : i1 + llvm.return %9 : i1 + } + llvm.func @foo1_or_signbit_lshr_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.shl %0, %arg1 : i32 + %5 = llvm.lshr %1, %arg2 : i32 + %6 = llvm.and %4, %arg0 : i32 + %7 = llvm.icmp "ne" %6, %2 : i32 + %8 = llvm.and %5, %arg0 : i32 + %9 = llvm.icmp "ne" %8, %2 : i32 + %10 = llvm.select %7, %9, %3 : i1, i1 + llvm.return %10 : i1 + } + llvm.func @foo1_or_signbit_lshr_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.shl %0, %arg1 : vector<2xi32> + %5 = llvm.lshr %1, %arg2 : vector<2xi32> + %6 = llvm.and %4, %arg0 : vector<2xi32> + %7 = llvm.icmp "ne" %6, %3 : vector<2xi32> + %8 = llvm.and %5, %arg0 : vector<2xi32> + %9 = llvm.icmp "ne" %8, %3 : vector<2xi32> + %10 = llvm.and %7, %9 : vector<2xi1> + llvm.return %10 : vector<2xi1> + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.and %3, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.shl %arg0, %arg2 : i32 + %7 = llvm.icmp "sgt" %6, %2 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.shl %0, %arg1 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.shl %arg0, %arg2 : i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + %9 = llvm.select %6, %3, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @foo1_or_signbit_lshr_without_shifting_signbit(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.shl %arg0, %arg2 : i32 + %6 = llvm.icmp "slt" %5, %1 : i32 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @foo1_or_signbit_lshr_without_shifting_signbit_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.and %3, %arg0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.shl %arg0, %arg2 : i32 + %7 = llvm.icmp "slt" %6, %1 : i32 + %8 = llvm.select %5, %7, %2 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_both_sides(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.icmp "sgt" %1, %0 : i32 + %3 = llvm.shl %arg0, %arg2 : i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + %5 = llvm.or %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_both_sides_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.icmp "sgt" %2, %0 : i32 + %4 = llvm.shl %arg0, %arg2 : i32 + %5 = llvm.icmp "sgt" %4, %0 : i32 + %6 = llvm.select %3, %1, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @foo1_or_signbit_lshr_without_shifting_signbit_both_sides(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + %3 = llvm.shl %arg0, %arg2 : i32 + %4 = llvm.icmp "slt" %3, %0 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @foo1_or_signbit_lshr_without_shifting_signbit_both_sides_splat(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.shl %arg0, %arg1 : vector<2xi32> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi32> + %4 = llvm.shl %arg0, %arg2 : vector<2xi32> + %5 = llvm.icmp "slt" %4, %1 : vector<2xi32> + %6 = llvm.and %3, %5 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @foo1_or_signbit_lshr_without_shifting_signbit_both_sides_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.icmp "slt" %2, %0 : i32 + %4 = llvm.shl %arg0, %arg2 : i32 + %5 = llvm.icmp "slt" %4, %0 : i32 + %6 = llvm.select %3, %5, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @foo1_and_extra_use_shl(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + llvm.store %2, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.shl %0, %arg2 : i32 + %4 = llvm.and %2, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %3, %arg0 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_extra_use_shl_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.shl %0, %arg1 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.shl %0, %arg2 : i32 + %5 = llvm.and %3, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %4, %arg0 : i32 + %8 = llvm.icmp "eq" %7, %1 : i32 + %9 = llvm.select %6, %2, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @foo1_and_extra_use_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.shl %0, %arg2 : i32 + %4 = llvm.and %2, %arg0 : i32 + llvm.store %4, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %3, %arg0 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_extra_use_and_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.shl %0, %arg2 : i32 + %5 = llvm.and %3, %arg0 : i32 + llvm.store %5, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %4, %arg0 : i32 + %8 = llvm.icmp "eq" %7, %1 : i32 + %9 = llvm.select %6, %2, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @foo1_and_extra_use_cmp(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.shl %0, %arg2 : i32 + %4 = llvm.and %2, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.store %5, %arg3 {alignment = 1 : i64} : i1, !llvm.ptr + %6 = llvm.and %3, %arg0 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_extra_use_cmp_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.shl %0, %arg2 : i32 + %5 = llvm.and %3, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + llvm.store %6, %arg3 {alignment = 1 : i64} : i1, !llvm.ptr + %7 = llvm.and %4, %arg0 : i32 + %8 = llvm.icmp "eq" %7, %1 : i32 + %9 = llvm.select %6, %2, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @foo1_and_extra_use_shl2(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.shl %0, %arg2 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.and %2, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %3, %arg0 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_extra_use_shl2_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.shl %0, %arg2 : i32 + llvm.store %4, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.and %3, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %4, %arg0 : i32 + %8 = llvm.icmp "eq" %7, %1 : i32 + %9 = llvm.select %6, %2, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @foo1_and_extra_use_and2(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.shl %0, %arg2 : i32 + %4 = llvm.and %2, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %3, %arg0 : i32 + llvm.store %6, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_extra_use_and2_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.shl %0, %arg2 : i32 + %5 = llvm.and %3, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %4, %arg0 : i32 + llvm.store %7, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %8 = llvm.icmp "eq" %7, %1 : i32 + %9 = llvm.select %6, %2, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @foo1_and_extra_use_cmp2(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.shl %0, %arg2 : i32 + %4 = llvm.and %2, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.and %3, %arg0 : i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + llvm.store %7, %arg3 {alignment = 1 : i64} : i1, !llvm.ptr + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_extra_use_cmp2_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.shl %0, %arg2 : i32 + %5 = llvm.and %3, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.and %4, %arg0 : i32 + %8 = llvm.icmp "eq" %7, %1 : i32 + llvm.store %8, %arg3 {alignment = 1 : i64} : i1, !llvm.ptr + %9 = llvm.select %6, %2, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_extra_use_shl1(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.and %3, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.shl %arg0, %arg2 : i32 + %7 = llvm.icmp "sgt" %6, %2 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_extra_use_shl1_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.shl %0, %arg1 : i32 + llvm.store %4, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.shl %arg0, %arg2 : i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + %9 = llvm.select %6, %3, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_extra_use_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.and %3, %arg0 : i32 + llvm.store %4, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.shl %arg0, %arg2 : i32 + %7 = llvm.icmp "sgt" %6, %2 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_extra_use_and_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.shl %0, %arg1 : i32 + %5 = llvm.and %4, %arg0 : i32 + llvm.store %5, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.shl %arg0, %arg2 : i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + %9 = llvm.select %6, %3, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_extra_use_cmp1(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.and %3, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.store %5, %arg3 {alignment = 1 : i64} : i1, !llvm.ptr + %6 = llvm.shl %arg0, %arg2 : i32 + %7 = llvm.icmp "sgt" %6, %2 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_extra_use_cmp1_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.shl %0, %arg1 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + llvm.store %6, %arg3 {alignment = 1 : i64} : i1, !llvm.ptr + %7 = llvm.shl %arg0, %arg2 : i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + %9 = llvm.select %6, %3, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_extra_use_shl2(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.and %3, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.shl %arg0, %arg2 : i32 + llvm.store %6, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %7 = llvm.icmp "sgt" %6, %2 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_extra_use_shl2_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.shl %0, %arg1 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.shl %arg0, %arg2 : i32 + llvm.store %7, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %8 = llvm.icmp "sgt" %7, %2 : i32 + %9 = llvm.select %6, %3, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_extra_use_cmp2(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.and %3, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.shl %arg0, %arg2 : i32 + %7 = llvm.icmp "sgt" %6, %2 : i32 + llvm.store %7, %arg3 {alignment = 1 : i64} : i1, !llvm.ptr + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_extra_use_cmp2_logical(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.shl %0, %arg1 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.shl %arg0, %arg2 : i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + llvm.store %8, %arg3 {alignment = 1 : i64} : i1, !llvm.ptr + %9 = llvm.select %6, %3, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_not_pwr2(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.and %3, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.shl %arg0, %arg2 : i32 + %7 = llvm.icmp "sgt" %6, %2 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @foo1_and_signbit_lshr_without_shifting_signbit_not_pwr2_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.shl %0, %arg1 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.shl %arg0, %arg2 : i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + %9 = llvm.select %6, %3, %8 : i1, i1 + llvm.return %9 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/opaque-ptr.ll.mlir b/test/LLVMDialect/InstCombine/opaque-ptr.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/opaque.ll.mlir b/test/LLVMDialect/InstCombine/opaque.ll.mlir index e67a734bf..d5d5daedb 100644 --- a/test/LLVMDialect/InstCombine/opaque.ll.mlir +++ b/test/LLVMDialect/InstCombine/opaque.ll.mlir @@ -1,25 +1,12 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "_swift_slowAlloc", type = !llvm.ptr (i64, i64)>>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memcpy.p0i8.p0i8.i64", type = !llvm.func, ptr, i64, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "rt_swift_slowAlloc", type = !llvm.func (i64, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>, %arg2: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 40 : i64} : () -> i64 - %3 = "llvm.bitcast"(%arg1) : (!llvm.ptr>) -> !llvm.ptr, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>)>, struct<"Si", packed (i64)>, struct<"SQ", packed (array<8 x i8>)>, struct<"SQ", packed (array<8 x i8>)>, struct<"Si", packed (i64)>, struct<"swift.opaque", opaque>)>> - %4 = "llvm.call"(%2, %1) {callee = @rt_swift_slowAlloc, fastmathFlags = #llvm.fastmath<>} : (i64, i64) -> !llvm.ptr - %5 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr> - "llvm.store"(%4, %5) : (!llvm.ptr, !llvm.ptr>) -> () - %6 = "llvm.bitcast"(%4) : (!llvm.ptr) -> !llvm.ptr, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>)>, struct<"Si", packed (i64)>, struct<"SQ", packed (array<8 x i8>)>, struct<"SQ", packed (array<8 x i8>)>, struct<"Si", packed (i64)>, struct<"swift.opaque", opaque>)>> - %7 = "llvm.bitcast"(%6) : (!llvm.ptr, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>)>, struct<"Si", packed (i64)>, struct<"SQ", packed (array<8 x i8>)>, struct<"SQ", packed (array<8 x i8>)>, struct<"Si", packed (i64)>, struct<"swift.opaque", opaque>)>>) -> !llvm.ptr - %8 = "llvm.bitcast"(%3) : (!llvm.ptr, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>)>, struct<"Si", packed (i64)>, struct<"SQ", packed (array<8 x i8>)>, struct<"SQ", packed (array<8 x i8>)>, struct<"Si", packed (i64)>, struct<"swift.opaque", opaque>)>>) -> !llvm.ptr - "llvm.call"(%7, %8, %2, %0) {callee = @llvm.memcpy.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - %9 = "llvm.bitcast"(%6) : (!llvm.ptr, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>, struct<"Vs4Int8", packed (i8)>)>, struct<"Si", packed (i64)>, struct<"SQ", packed (array<8 x i8>)>, struct<"SQ", packed (array<8 x i8>)>, struct<"Si", packed (i64)>, struct<"swift.opaque", opaque>)>>) -> !llvm.ptr> - "llvm.return"(%9) : (!llvm.ptr>) -> () - }) {linkage = 10 : i64, sym_name = "_TwTkV", type = !llvm.func> (ptr>, ptr>, ptr>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @_swift_slowAlloc() {addr_space = 0 : i32} : !llvm.ptr + llvm.func @rt_swift_slowAlloc(i64, i64) -> !llvm.ptr + llvm.func @_TwTkV(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(40 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.call @rt_swift_slowAlloc(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.store %2, %arg0 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + "llvm.intr.memcpy"(%2, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/operand-complexity.ll.mlir b/test/LLVMDialect/InstCombine/operand-complexity.ll.mlir new file mode 100644 index 000000000..358d11802 --- /dev/null +++ b/test/LLVMDialect/InstCombine/operand-complexity.ll.mlir @@ -0,0 +1,114 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @neg(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.udiv %arg0, %0 : i8 + %3 = llvm.sub %1, %arg0 : i8 + %4 = llvm.xor %3, %2 : i8 + llvm.return %4 : i8 + } + llvm.func @neg_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.udiv %arg0, %0 : vector<2xi8> + %4 = llvm.sub %2, %arg0 : vector<2xi8> + %5 = llvm.xor %4, %3 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @neg_vec_poison(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.udiv %arg0, %0 : vector<2xi8> + %9 = llvm.sub %7, %arg0 : vector<2xi8> + %10 = llvm.xor %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @not(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.udiv %arg0, %0 : i8 + %3 = llvm.xor %1, %arg0 : i8 + %4 = llvm.mul %3, %2 : i8 + llvm.return %4 : i8 + } + llvm.func @not_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.udiv %arg0, %0 : vector<2xi8> + %3 = llvm.xor %1, %arg0 : vector<2xi8> + %4 = llvm.mul %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @not_vec_poison(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.udiv %arg0, %0 : vector<2xi8> + %9 = llvm.xor %7, %arg0 : vector<2xi8> + %10 = llvm.mul %9, %8 : vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @use(f32) + llvm.func @use_vec(vector<2xf32>) + llvm.func @fneg(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.fdiv %arg0, %0 : f32 + %3 = llvm.fsub %1, %arg0 : f32 + %4 = llvm.fmul %3, %2 : f32 + llvm.call @use(%3) : (f32) -> () + llvm.return %4 : f32 + } + llvm.func @unary_fneg(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %1 = llvm.fdiv %arg0, %0 : f32 + %2 = llvm.fneg %arg0 : f32 + %3 = llvm.fmul %2, %1 : f32 + llvm.call @use(%2) : (f32) -> () + llvm.return %3 : f32 + } + llvm.func @fneg_vec(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.fdiv %arg0, %0 : vector<2xf32> + %3 = llvm.fsub %1, %arg0 : vector<2xf32> + %4 = llvm.fmul %3, %2 : vector<2xf32> + llvm.call @use_vec(%3) : (vector<2xf32>) -> () + llvm.return %4 : vector<2xf32> + } + llvm.func @fneg_vec_poison(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.poison : f32 + %2 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %3 = llvm.mlir.undef : vector<2xf32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xf32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xf32> + %8 = llvm.fdiv %arg0, %0 : vector<2xf32> + %9 = llvm.fsub %7, %arg0 : vector<2xf32> + %10 = llvm.fmul %9, %8 : vector<2xf32> + llvm.call @use_vec(%9) : (vector<2xf32>) -> () + llvm.return %10 : vector<2xf32> + } + llvm.func @unary_fneg_vec(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[4.200000e+01, -4.200000e+01]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.fdiv %arg0, %0 : vector<2xf32> + %2 = llvm.fneg %arg0 : vector<2xf32> + %3 = llvm.fmul %2, %1 : vector<2xf32> + llvm.call @use_vec(%2) : (vector<2xf32>) -> () + llvm.return %3 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/opts-tuples-extract-intrinsic.ll.mlir b/test/LLVMDialect/InstCombine/opts-tuples-extract-intrinsic.ll.mlir index 71c7ae5c7..f5782afa6 100644 --- a/test/LLVMDialect/InstCombine/opts-tuples-extract-intrinsic.ll.mlir +++ b/test/LLVMDialect/InstCombine/opts-tuples-extract-intrinsic.ll.mlir @@ -1,31 +1,17 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec, %arg1: !llvm.vec): // no predecessors - %0 = "llvm.mlir.constant"() {value = 48 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.vector.insert.nxv64i8.nxv16i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec, !llvm.vec, i64) -> !llvm.vec - %2 = "llvm.call"(%1, %0) {callee = @llvm.vector.extract.nxv16i8.nxv64i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec, i64) -> !llvm.vec - "llvm.return"(%2) : (!llvm.vec) -> () - }) {linkage = 10 : i64, sym_name = "test_extract_insert_same_idx", type = !llvm.func (vec, vec)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec, %arg1: !llvm.vec): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 48 : i64} : () -> i64 - %2 = "llvm.call"(%arg0, %arg1, %1) {callee = @llvm.vector.insert.nxv64i8.nxv16i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec, !llvm.vec, i64) -> !llvm.vec - %3 = "llvm.call"(%2, %0) {callee = @llvm.vector.extract.nxv16i8.nxv64i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec, i64) -> !llvm.vec - "llvm.return"(%3) : (!llvm.vec) -> () - }) {linkage = 10 : i64, sym_name = "test_extract_insert_dif_idx", type = !llvm.func (vec, vec)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec, %arg1: !llvm.vec): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.vector.insert.nxv64i8.nxv16i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec, !llvm.vec, i64) -> !llvm.vec - %2 = "llvm.call"(%1, %0) {callee = @llvm.vector.extract.nxv32i8.nxv64i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec, i64) -> !llvm.vec - "llvm.return"(%2) : (!llvm.vec) -> () - }) {linkage = 10 : i64, sym_name = "neg_test_extract_insert_same_idx_dif_ret_size", type = !llvm.func (vec, vec)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.insert.nxv64i8.nxv16i8", type = !llvm.func (vec, vec, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.extract.nxv16i8.nxv64i8", type = !llvm.func (vec, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.extract.nxv32i8.nxv64i8", type = !llvm.func (vec, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_extract_insert_same_idx(%arg0: !llvm.vec, %arg1: !llvm.vec) -> !llvm.vec { + %0 = llvm.intr.vector.insert %arg1, %arg0[48] : !llvm.vec into !llvm.vec + %1 = llvm.intr.vector.extract %0[48] : !llvm.vec from !llvm.vec + llvm.return %1 : !llvm.vec + } + llvm.func @test_extract_insert_dif_idx(%arg0: !llvm.vec, %arg1: !llvm.vec) -> !llvm.vec { + %0 = llvm.intr.vector.insert %arg1, %arg0[48] : !llvm.vec into !llvm.vec + %1 = llvm.intr.vector.extract %0[0] : !llvm.vec from !llvm.vec + llvm.return %1 : !llvm.vec + } + llvm.func @neg_test_extract_insert_same_idx_dif_ret_size(%arg0: !llvm.vec, %arg1: !llvm.vec) -> !llvm.vec { + %0 = llvm.intr.vector.insert %arg1, %arg0[32] : !llvm.vec into !llvm.vec + %1 = llvm.intr.vector.extract %0[32] : !llvm.vec from !llvm.vec + llvm.return %1 : !llvm.vec + } +} diff --git a/test/LLVMDialect/InstCombine/or-concat.ll.mlir b/test/LLVMDialect/InstCombine/or-concat.ll.mlir index fcc38f415..061db1afa 100644 --- a/test/LLVMDialect/InstCombine/or-concat.ll.mlir +++ b/test/LLVMDialect/InstCombine/or-concat.ll.mlir @@ -1,167 +1,146 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %1 = "llvm.lshr"(%arg0, %0) : (i64, i64) -> i64 - %2 = "llvm.trunc"(%1) : (i64) -> i32 - %3 = "llvm.trunc"(%arg0) : (i64) -> i32 - %4 = "llvm.call"(%2) {callee = @llvm.bswap.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %5 = "llvm.call"(%3) {callee = @llvm.bswap.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %6 = "llvm.zext"(%4) : (i32) -> i64 - %7 = "llvm.zext"(%5) : (i32) -> i64 - %8 = "llvm.shl"(%7, %0) : (i64, i64) -> i64 - %9 = "llvm.or"(%6, %8) : (i64, i64) -> i64 - "llvm.return"(%9) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "concat_bswap32_unary_split", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<32> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.lshr"(%arg0, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %2 = "llvm.trunc"(%1) : (vector<2xi64>) -> vector<2xi32> - %3 = "llvm.trunc"(%arg0) : (vector<2xi64>) -> vector<2xi32> - %4 = "llvm.call"(%2) {callee = @llvm.bswap.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<2xi32>) -> vector<2xi32> - %5 = "llvm.call"(%3) {callee = @llvm.bswap.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<2xi32>) -> vector<2xi32> - %6 = "llvm.zext"(%4) : (vector<2xi32>) -> vector<2xi64> - %7 = "llvm.zext"(%5) : (vector<2xi32>) -> vector<2xi64> - %8 = "llvm.shl"(%7, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %9 = "llvm.or"(%6, %8) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%9) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "concat_bswap32_unary_split_vector", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %1 = "llvm.lshr"(%arg0, %0) : (i64, i64) -> i64 - %2 = "llvm.trunc"(%1) : (i64) -> i32 - %3 = "llvm.trunc"(%arg0) : (i64) -> i32 - %4 = "llvm.call"(%2) {callee = @llvm.bswap.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %5 = "llvm.call"(%3) {callee = @llvm.bswap.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %6 = "llvm.zext"(%4) : (i32) -> i64 - %7 = "llvm.zext"(%5) : (i32) -> i64 - %8 = "llvm.shl"(%6, %0) : (i64, i64) -> i64 - %9 = "llvm.or"(%7, %8) : (i64, i64) -> i64 - "llvm.return"(%9) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "concat_bswap32_unary_flip", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<32> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.lshr"(%arg0, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %2 = "llvm.trunc"(%1) : (vector<2xi64>) -> vector<2xi32> - %3 = "llvm.trunc"(%arg0) : (vector<2xi64>) -> vector<2xi32> - %4 = "llvm.call"(%2) {callee = @llvm.bswap.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<2xi32>) -> vector<2xi32> - %5 = "llvm.call"(%3) {callee = @llvm.bswap.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<2xi32>) -> vector<2xi32> - %6 = "llvm.zext"(%4) : (vector<2xi32>) -> vector<2xi64> - %7 = "llvm.zext"(%5) : (vector<2xi32>) -> vector<2xi64> - %8 = "llvm.shl"(%6, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %9 = "llvm.or"(%7, %8) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%9) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "concat_bswap32_unary_flip_vector", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %1 = "llvm.call"(%arg0) {callee = @llvm.bswap.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %2 = "llvm.call"(%arg1) {callee = @llvm.bswap.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %3 = "llvm.zext"(%1) : (i32) -> i64 - %4 = "llvm.zext"(%2) : (i32) -> i64 - %5 = "llvm.shl"(%4, %0) : (i64, i64) -> i64 - %6 = "llvm.or"(%3, %5) : (i64, i64) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "concat_bswap32_binary", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<32> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.call"(%arg0) {callee = @llvm.bswap.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<2xi32>) -> vector<2xi32> - %2 = "llvm.call"(%arg1) {callee = @llvm.bswap.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<2xi32>) -> vector<2xi32> - %3 = "llvm.zext"(%1) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.zext"(%2) : (vector<2xi32>) -> vector<2xi64> - %5 = "llvm.shl"(%4, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %6 = "llvm.or"(%3, %5) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%6) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "concat_bswap32_binary_vector", type = !llvm.func (vector<2xi32>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.bswap.i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.bswap.v2i32", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %1 = "llvm.lshr"(%arg0, %0) : (i64, i64) -> i64 - %2 = "llvm.trunc"(%1) : (i64) -> i32 - %3 = "llvm.trunc"(%arg0) : (i64) -> i32 - %4 = "llvm.call"(%2) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %5 = "llvm.call"(%3) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %6 = "llvm.zext"(%4) : (i32) -> i64 - %7 = "llvm.zext"(%5) : (i32) -> i64 - %8 = "llvm.shl"(%7, %0) : (i64, i64) -> i64 - %9 = "llvm.or"(%6, %8) : (i64, i64) -> i64 - "llvm.return"(%9) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "concat_bitreverse32_unary_split", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<32> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.lshr"(%arg0, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %2 = "llvm.trunc"(%1) : (vector<2xi64>) -> vector<2xi32> - %3 = "llvm.trunc"(%arg0) : (vector<2xi64>) -> vector<2xi32> - %4 = "llvm.call"(%2) {callee = @llvm.bitreverse.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<2xi32>) -> vector<2xi32> - %5 = "llvm.call"(%3) {callee = @llvm.bitreverse.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<2xi32>) -> vector<2xi32> - %6 = "llvm.zext"(%4) : (vector<2xi32>) -> vector<2xi64> - %7 = "llvm.zext"(%5) : (vector<2xi32>) -> vector<2xi64> - %8 = "llvm.shl"(%7, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %9 = "llvm.or"(%6, %8) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%9) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "concat_bitreverse32_unary_split_vector", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %1 = "llvm.lshr"(%arg0, %0) : (i64, i64) -> i64 - %2 = "llvm.trunc"(%1) : (i64) -> i32 - %3 = "llvm.trunc"(%arg0) : (i64) -> i32 - %4 = "llvm.call"(%2) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %5 = "llvm.call"(%3) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %6 = "llvm.zext"(%4) : (i32) -> i64 - %7 = "llvm.zext"(%5) : (i32) -> i64 - %8 = "llvm.shl"(%6, %0) : (i64, i64) -> i64 - %9 = "llvm.or"(%7, %8) : (i64, i64) -> i64 - "llvm.return"(%9) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "concat_bitreverse32_unary_flip", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<32> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.lshr"(%arg0, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %2 = "llvm.trunc"(%1) : (vector<2xi64>) -> vector<2xi32> - %3 = "llvm.trunc"(%arg0) : (vector<2xi64>) -> vector<2xi32> - %4 = "llvm.call"(%2) {callee = @llvm.bitreverse.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<2xi32>) -> vector<2xi32> - %5 = "llvm.call"(%3) {callee = @llvm.bitreverse.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<2xi32>) -> vector<2xi32> - %6 = "llvm.zext"(%4) : (vector<2xi32>) -> vector<2xi64> - %7 = "llvm.zext"(%5) : (vector<2xi32>) -> vector<2xi64> - %8 = "llvm.shl"(%6, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %9 = "llvm.or"(%7, %8) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%9) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "concat_bitreverse32_unary_flip_vector", type = !llvm.func (vector<2xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %1 = "llvm.call"(%arg0) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %2 = "llvm.call"(%arg1) {callee = @llvm.bitreverse.i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - %3 = "llvm.zext"(%1) : (i32) -> i64 - %4 = "llvm.zext"(%2) : (i32) -> i64 - %5 = "llvm.shl"(%4, %0) : (i64, i64) -> i64 - %6 = "llvm.or"(%3, %5) : (i64, i64) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "concat_bitreverse32_binary", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<32> : vector<2xi64>} : () -> vector<2xi64> - %1 = "llvm.call"(%arg0) {callee = @llvm.bitreverse.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<2xi32>) -> vector<2xi32> - %2 = "llvm.call"(%arg1) {callee = @llvm.bitreverse.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<2xi32>) -> vector<2xi32> - %3 = "llvm.zext"(%1) : (vector<2xi32>) -> vector<2xi64> - %4 = "llvm.zext"(%2) : (vector<2xi32>) -> vector<2xi64> - %5 = "llvm.shl"(%4, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - %6 = "llvm.or"(%3, %5) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%6) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "concat_bitreverse32_binary_vector", type = !llvm.func (vector<2xi32>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.bitreverse.i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.bitreverse.v2i32", type = !llvm.func (vector<2xi32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @concat_bswap32_unary_split(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.lshr %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i32 + %3 = llvm.trunc %arg0 : i64 to i32 + %4 = llvm.intr.bswap(%2) : (i32) -> i32 + %5 = llvm.intr.bswap(%3) : (i32) -> i32 + %6 = llvm.zext %4 : i32 to i64 + %7 = llvm.zext %5 : i32 to i64 + %8 = llvm.shl %7, %0 overflow : i64 + %9 = llvm.or %6, %8 : i64 + llvm.return %9 : i64 + } + llvm.func @concat_bswap32_unary_split_vector(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi64>) : vector<2xi64> + %1 = llvm.lshr %arg0, %0 : vector<2xi64> + %2 = llvm.trunc %1 : vector<2xi64> to vector<2xi32> + %3 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %4 = llvm.intr.bswap(%2) : (vector<2xi32>) -> vector<2xi32> + %5 = llvm.intr.bswap(%3) : (vector<2xi32>) -> vector<2xi32> + %6 = llvm.zext %4 : vector<2xi32> to vector<2xi64> + %7 = llvm.zext %5 : vector<2xi32> to vector<2xi64> + %8 = llvm.shl %7, %0 overflow : vector<2xi64> + %9 = llvm.or %6, %8 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @concat_bswap32_unary_flip(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.lshr %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i32 + %3 = llvm.trunc %arg0 : i64 to i32 + %4 = llvm.intr.bswap(%2) : (i32) -> i32 + %5 = llvm.intr.bswap(%3) : (i32) -> i32 + %6 = llvm.zext %4 : i32 to i64 + %7 = llvm.zext %5 : i32 to i64 + %8 = llvm.shl %6, %0 overflow : i64 + %9 = llvm.or %7, %8 : i64 + llvm.return %9 : i64 + } + llvm.func @concat_bswap32_unary_flip_vector(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi64>) : vector<2xi64> + %1 = llvm.lshr %arg0, %0 : vector<2xi64> + %2 = llvm.trunc %1 : vector<2xi64> to vector<2xi32> + %3 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %4 = llvm.intr.bswap(%2) : (vector<2xi32>) -> vector<2xi32> + %5 = llvm.intr.bswap(%3) : (vector<2xi32>) -> vector<2xi32> + %6 = llvm.zext %4 : vector<2xi32> to vector<2xi64> + %7 = llvm.zext %5 : vector<2xi32> to vector<2xi64> + %8 = llvm.shl %6, %0 overflow : vector<2xi64> + %9 = llvm.or %7, %8 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @concat_bswap32_binary(%arg0: i32, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.intr.bswap(%arg0) : (i32) -> i32 + %2 = llvm.intr.bswap(%arg1) : (i32) -> i32 + %3 = llvm.zext %1 : i32 to i64 + %4 = llvm.zext %2 : i32 to i64 + %5 = llvm.shl %4, %0 overflow : i64 + %6 = llvm.or %3, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @concat_bswap32_binary_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi64>) : vector<2xi64> + %1 = llvm.intr.bswap(%arg0) : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.intr.bswap(%arg1) : (vector<2xi32>) -> vector<2xi32> + %3 = llvm.zext %1 : vector<2xi32> to vector<2xi64> + %4 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + %5 = llvm.shl %4, %0 overflow : vector<2xi64> + %6 = llvm.or %3, %5 : vector<2xi64> + llvm.return %6 : vector<2xi64> + } + llvm.func @concat_bitreverse32_unary_split(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.lshr %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i32 + %3 = llvm.trunc %arg0 : i64 to i32 + %4 = llvm.intr.bitreverse(%2) : (i32) -> i32 + %5 = llvm.intr.bitreverse(%3) : (i32) -> i32 + %6 = llvm.zext %4 : i32 to i64 + %7 = llvm.zext %5 : i32 to i64 + %8 = llvm.shl %7, %0 overflow : i64 + %9 = llvm.or %6, %8 : i64 + llvm.return %9 : i64 + } + llvm.func @concat_bitreverse32_unary_split_vector(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi64>) : vector<2xi64> + %1 = llvm.lshr %arg0, %0 : vector<2xi64> + %2 = llvm.trunc %1 : vector<2xi64> to vector<2xi32> + %3 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %4 = llvm.intr.bitreverse(%2) : (vector<2xi32>) -> vector<2xi32> + %5 = llvm.intr.bitreverse(%3) : (vector<2xi32>) -> vector<2xi32> + %6 = llvm.zext %4 : vector<2xi32> to vector<2xi64> + %7 = llvm.zext %5 : vector<2xi32> to vector<2xi64> + %8 = llvm.shl %7, %0 overflow : vector<2xi64> + %9 = llvm.or %6, %8 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @concat_bitreverse32_unary_flip(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.lshr %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i32 + %3 = llvm.trunc %arg0 : i64 to i32 + %4 = llvm.intr.bitreverse(%2) : (i32) -> i32 + %5 = llvm.intr.bitreverse(%3) : (i32) -> i32 + %6 = llvm.zext %4 : i32 to i64 + %7 = llvm.zext %5 : i32 to i64 + %8 = llvm.shl %6, %0 overflow : i64 + %9 = llvm.or %7, %8 : i64 + llvm.return %9 : i64 + } + llvm.func @concat_bitreverse32_unary_flip_vector(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi64>) : vector<2xi64> + %1 = llvm.lshr %arg0, %0 : vector<2xi64> + %2 = llvm.trunc %1 : vector<2xi64> to vector<2xi32> + %3 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %4 = llvm.intr.bitreverse(%2) : (vector<2xi32>) -> vector<2xi32> + %5 = llvm.intr.bitreverse(%3) : (vector<2xi32>) -> vector<2xi32> + %6 = llvm.zext %4 : vector<2xi32> to vector<2xi64> + %7 = llvm.zext %5 : vector<2xi32> to vector<2xi64> + %8 = llvm.shl %6, %0 overflow : vector<2xi64> + %9 = llvm.or %7, %8 : vector<2xi64> + llvm.return %9 : vector<2xi64> + } + llvm.func @concat_bitreverse32_binary(%arg0: i32, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.intr.bitreverse(%arg0) : (i32) -> i32 + %2 = llvm.intr.bitreverse(%arg1) : (i32) -> i32 + %3 = llvm.zext %1 : i32 to i64 + %4 = llvm.zext %2 : i32 to i64 + %5 = llvm.shl %4, %0 overflow : i64 + %6 = llvm.or %3, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @concat_bitreverse32_binary_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi64>) : vector<2xi64> + %1 = llvm.intr.bitreverse(%arg0) : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.intr.bitreverse(%arg1) : (vector<2xi32>) -> vector<2xi32> + %3 = llvm.zext %1 : vector<2xi32> to vector<2xi64> + %4 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + %5 = llvm.shl %4, %0 overflow : vector<2xi64> + %6 = llvm.or %3, %5 : vector<2xi64> + llvm.return %6 : vector<2xi64> + } +} diff --git a/test/LLVMDialect/InstCombine/or-fcmp.ll.mlir b/test/LLVMDialect/InstCombine/or-fcmp.ll.mlir new file mode 100644 index 000000000..c887d1f90 --- /dev/null +++ b/test/LLVMDialect/InstCombine/or-fcmp.ll.mlir @@ -0,0 +1,2920 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @PR1738(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "uno" %arg0, %0 : f64 + %2 = llvm.fcmp "uno" %arg1, %0 : f64 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @PR1738_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.fcmp "uno" %arg0, %0 : f64 + %3 = llvm.fcmp "uno" %arg1, %0 : f64 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @PR1738_vec_undef(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.undef : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.mlir.undef : vector<2xf64> + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<2xf64> + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<2xf64> + %12 = llvm.fcmp "uno" %arg0, %6 : vector<2xf64> + %13 = llvm.fcmp "uno" %arg1, %11 : vector<2xf64> + %14 = llvm.or %12, %13 : vector<2xi1> + llvm.return %14 : vector<2xi1> + } + llvm.func @PR1738_vec_poison(%arg0: vector<2xf64>, %arg1: vector<2xf64>) -> vector<2xi1> { + %0 = llvm.mlir.poison : f64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.mlir.undef : vector<2xf64> + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<2xf64> + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<2xf64> + %12 = llvm.fcmp "uno" %arg0, %6 : vector<2xf64> + %13 = llvm.fcmp "uno" %arg1, %11 : vector<2xf64> + %14 = llvm.or %12, %13 : vector<2xi1> + llvm.return %14 : vector<2xi1> + } + llvm.func @PR41069(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uno" %arg2, %0 : f64 + %3 = llvm.or %1, %2 : i1 + %4 = llvm.fcmp "uno" %arg3, %0 : f64 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @PR41069_logical(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %3 = llvm.fcmp "uno" %arg2, %0 : f64 + %4 = llvm.select %2, %1, %3 : i1, i1 + %5 = llvm.fcmp "uno" %arg3, %0 : f64 + %6 = llvm.select %4, %1, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @PR41069_commute(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uno" %arg2, %0 : f64 + %3 = llvm.or %1, %2 : i1 + %4 = llvm.fcmp "uno" %arg3, %0 : f64 + %5 = llvm.or %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @PR41069_commute_logical(%arg0: f64, %arg1: f64, %arg2: f64, %arg3: f64) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %3 = llvm.fcmp "uno" %arg2, %0 : f64 + %4 = llvm.select %2, %1, %3 : i1, i1 + %5 = llvm.fcmp "uno" %arg3, %0 : f64 + %6 = llvm.select %5, %1, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @PR41069_vec(%arg0: vector<2xi1>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.undef : vector<2xf32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : vector<2xf32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<2xf32> + %8 = llvm.fcmp "uno" %arg1, %1 : vector<2xf32> + %9 = llvm.or %8, %arg0 : vector<2xi1> + %10 = llvm.fcmp "uno" %arg2, %7 : vector<2xf32> + %11 = llvm.or %9, %10 : vector<2xi1> + llvm.return %11 : vector<2xi1> + } + llvm.func @PR41069_vec_poison(%arg0: vector<2xi1>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.poison : f32 + %3 = llvm.mlir.undef : vector<2xf32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : vector<2xf32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<2xf32> + %8 = llvm.fcmp "uno" %arg1, %1 : vector<2xf32> + %9 = llvm.or %8, %arg0 : vector<2xi1> + %10 = llvm.fcmp "uno" %arg2, %7 : vector<2xf32> + %11 = llvm.or %9, %10 : vector<2xi1> + llvm.return %11 : vector<2xi1> + } + llvm.func @PR41069_vec_commute(%arg0: vector<2xi1>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.undef : vector<2xf32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : vector<2xf32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<2xf32> + %8 = llvm.fcmp "uno" %arg1, %1 : vector<2xf32> + %9 = llvm.or %8, %arg0 : vector<2xi1> + %10 = llvm.fcmp "uno" %arg2, %7 : vector<2xf32> + %11 = llvm.or %10, %9 : vector<2xi1> + llvm.return %11 : vector<2xi1> + } + llvm.func @PR41069_vec_commute_poison(%arg0: vector<2xi1>, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.poison : f32 + %3 = llvm.mlir.undef : vector<2xf32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : vector<2xf32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<2xf32> + %8 = llvm.fcmp "uno" %arg1, %1 : vector<2xf32> + %9 = llvm.or %8, %arg0 : vector<2xi1> + %10 = llvm.fcmp "uno" %arg2, %7 : vector<2xf32> + %11 = llvm.or %10, %9 : vector<2xi1> + llvm.return %11 : vector<2xi1> + } + llvm.func @fcmp_uno_nonzero(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.fcmp "uno" %arg0, %0 : f32 + %3 = llvm.fcmp "uno" %arg1, %1 : f32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @fcmp_uno_nonzero_logical(%arg0: f32, %arg1: f32) -> i1 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.fcmp "uno" %arg0, %0 : f32 + %4 = llvm.fcmp "uno" %arg1, %1 : f32 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @fcmp_uno_nonzero_vec(%arg0: vector<3xf32>, %arg1: vector<3xf32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.constant(dense<[3.000000e+00, 2.000000e+00, 1.000000e+00]> : vector<3xf32>) : vector<3xf32> + %2 = llvm.fcmp "uno" %arg0, %0 : vector<3xf32> + %3 = llvm.fcmp "uno" %arg1, %1 : vector<3xf32> + %4 = llvm.or %2, %3 : vector<3xi1> + llvm.return %4 : vector<3xi1> + } + llvm.func @auto_gen_0(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_0_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_0_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_1(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_1_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_1_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_2(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_2_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_2_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_3(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_3_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_3_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_4(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_4_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_4_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_5(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_5_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_5_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_6(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_6_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_6_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_7(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_7_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_7_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_8(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_8_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_8_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_9(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_9_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_9_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_10(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_10_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_10_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_11(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_11_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_11_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_12(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_12_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_12_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_13(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_13_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_13_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_14(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_14_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_14_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_15(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_15_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_15_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_16(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_16_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_16_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_17(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_17_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_17_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_18(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_18_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_18_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_19(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_19_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_19_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_20(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_20_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_20_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_21(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "one" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_21_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_21_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_22(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "one" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_22_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_22_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_23(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "one" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_23_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_23_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_24(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "one" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_24_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_24_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_25(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "one" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_25_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_25_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_26(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "one" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_26_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_26_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_27(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "one" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_27_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_27_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_28(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_28_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_28_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_29(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_29_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_29_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_30(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_30_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_30_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_31(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_31_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_31_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_32(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_32_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_32_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_33(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_33_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_33_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_34(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_34_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_34_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_35(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_35_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_35_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_36(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_36_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_36_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_37(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_37_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_37_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_38(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_38_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_38_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_39(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_39_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_39_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_40(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_40_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_40_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_41(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_41_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_41_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_42(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_42_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_42_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_43(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_43_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_43_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_44(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_44_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_44_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_45(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_45_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_45_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_46(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_46_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_46_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_47(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_47_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_47_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_48(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_48_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_48_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_49(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_49_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_49_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_50(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_50_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_50_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_51(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_51_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_51_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_52(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_52_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_52_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_53(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_53_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_53_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_54(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_54_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_54_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_55(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_55_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_55_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_56(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_56_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_56_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_57(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_57_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_57_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_58(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_58_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_58_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_59(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_59_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_59_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_60(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_60_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_60_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_61(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_61_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_61_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_62(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_62_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_62_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_63(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_63_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_63_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_64(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_64_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_64_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_65(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_65_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_65_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_66(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_66_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_66_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_67(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_67_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_67_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_68(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_68_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_68_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_69(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_69_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_69_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_70(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_70_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_70_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_71(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_71_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_71_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_72(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_72_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_72_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_73(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_73_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_73_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_74(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_74_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_74_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_75(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_75_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_75_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_76(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_76_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_76_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_77(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_77_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_77_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_78(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_78_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_78_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_79(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_79_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_79_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_80(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_80_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_80_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_81(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_81_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_81_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_82(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_82_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_82_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_83(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_83_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_83_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_84(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_84_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_84_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_85(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_85_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_85_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_86(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_86_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_86_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_87(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_87_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_87_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_88(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_88_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_88_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_89(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_89_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_89_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_90(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_90_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_90_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_91(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_91_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_91_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_92(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_92_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_92_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_93(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_93_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_93_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_94(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_94_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_94_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_95(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_95_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_95_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_96(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_96_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_96_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_97(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_97_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_97_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_98(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_98_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_98_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_99(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_99_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_99_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_100(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_100_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_100_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_101(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_101_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_101_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_102(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_102_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_102_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_103(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_103_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_103_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_104(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "une" %arg0, %arg1 : f64 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_104_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "une" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_104_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_105(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_105_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_105_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_106(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_106_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_106_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_107(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_107_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_107_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_108(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_108_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_108_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_109(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_109_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_109_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_110(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_110_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_110_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_111(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_111_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_111_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_112(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_112_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_112_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_113(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_113_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_113_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_114(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_114_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_114_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_115(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_115_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_115_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_116(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_116_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_116_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_117(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_117_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_117_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_118(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_118_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "une" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_118_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_119(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_119_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_119_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_120(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_120_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_120_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_false" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_121(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_121_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_121_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_122(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_122_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_122_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_123(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_123_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_123_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "oge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_124(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_124_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_124_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_125(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_125_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_125_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ole" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_126(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "one" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_126_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_126_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "one" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_127(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_127_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_127_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ord" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_128(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_128_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_128_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_129(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_129_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_129_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_130(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_130_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_130_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_131(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_131_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_131_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_132(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_132_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_132_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_133(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "une" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_133_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "une" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_133_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_134(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_134_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uno" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_134_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "uno" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_135(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @auto_gen_135_logical(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %2 = llvm.fcmp "_true" %arg0, %arg1 : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @auto_gen_135_logical_fmf(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.fcmp "_true" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @intersect_fmf_1(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @intersect_fmf_2(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @intersect_fmf_3(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "olt" %arg0, %arg1 : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @intersect_fmf_4(%arg0: f64, %arg1: f64) -> i1 { + %0 = llvm.fcmp "olt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/or-shifted-masks.ll.mlir b/test/LLVMDialect/InstCombine/or-shifted-masks.ll.mlir index 669f45a51..261e4cd42 100644 --- a/test/LLVMDialect/InstCombine/or-shifted-masks.ll.mlir +++ b/test/LLVMDialect/InstCombine/or-shifted-masks.ll.mlir @@ -1,212 +1,197 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 60 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 15 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %4 = "llvm.shl"(%arg0, %3) : (i32, i32) -> i32 - %5 = "llvm.and"(%4, %2) : (i32, i32) -> i32 - %6 = "llvm.shl"(%arg0, %1) : (i32, i32) -> i32 - %7 = "llvm.and"(%6, %0) : (i32, i32) -> i32 - %8 = "llvm.or"(%5, %7) : (i32, i32) -> i32 - "llvm.return"(%8) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "or_and_shifts1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 896 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %4 = "llvm.shl"(%arg0, %3) : (i32, i32) -> i32 - %5 = "llvm.and"(%4, %2) : (i32, i32) -> i32 - %6 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - %7 = "llvm.and"(%6, %0) : (i32, i32) -> i32 - %8 = "llvm.or"(%5, %7) : (i32, i32) -> i32 - "llvm.return"(%8) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "or_and_shifts2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 28 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %4 = "llvm.and"(%arg0, %3) : (i32, i32) -> i32 - %5 = "llvm.shl"(%4, %2) : (i32, i32) -> i32 - %6 = "llvm.shl"(%arg0, %1) : (i32, i32) -> i32 - %7 = "llvm.and"(%6, %0) : (i32, i32) -> i32 - %8 = "llvm.or"(%5, %7) : (i32, i32) -> i32 - "llvm.return"(%8) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "or_and_shift_shift_and", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 6 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %4 = "llvm.and"(%arg0, %3) : (i32, i32) -> i32 - %5 = "llvm.and"(%arg0, %2) : (i32, i32) -> i32 - %6 = "llvm.shl"(%4, %1) : (i32, i32) -> i32 - %7 = "llvm.lshr"(%4, %0) : (i32, i32) -> i32 - %8 = "llvm.shl"(%5, %1) : (i32, i32) -> i32 - %9 = "llvm.lshr"(%5, %0) : (i32, i32) -> i32 - %10 = "llvm.or"(%6, %8) : (i32, i32) -> i32 - %11 = "llvm.or"(%7, %9) : (i32, i32) -> i32 - %12 = "llvm.or"(%11, %10) : (i32, i32) -> i32 - "llvm.return"(%12) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "multiuse1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 96 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 24 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 6 : i32} : () -> i32 - %5 = "llvm.and"(%arg0, %4) : (i32, i32) -> i32 - %6 = "llvm.shl"(%5, %3) : (i32, i32) -> i32 - %7 = "llvm.shl"(%5, %2) : (i32, i32) -> i32 - %8 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %9 = "llvm.shl"(%8, %3) : (i32, i32) -> i32 - %10 = "llvm.shl"(%8, %2) : (i32, i32) -> i32 - %11 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - %12 = "llvm.shl"(%11, %3) : (i32, i32) -> i32 - %13 = "llvm.shl"(%11, %2) : (i32, i32) -> i32 - %14 = "llvm.or"(%6, %9) : (i32, i32) -> i32 - %15 = "llvm.or"(%12, %14) : (i32, i32) -> i32 - %16 = "llvm.or"(%13, %10) : (i32, i32) -> i32 - %17 = "llvm.or"(%7, %16) : (i32, i32) -> i32 - %18 = "llvm.or"(%15, %17) : (i32, i32) -> i32 - "llvm.return"(%18) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "multiuse2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 15 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1920 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 6 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 96 : i32} : () -> i32 - %5 = "llvm.and"(%arg0, %4) : (i32, i32) -> i32 - %6 = "llvm.shl"(%5, %3) : (i32, i32) -> i32 - %7 = "llvm.lshr"(%5, %2) : (i32, i32) -> i32 - %8 = "llvm.shl"(%arg0, %3) : (i32, i32) -> i32 - %9 = "llvm.and"(%8, %1) : (i32, i32) -> i32 - %10 = "llvm.or"(%6, %9) : (i32, i32) -> i32 - %11 = "llvm.lshr"(%arg0, %2) : (i32, i32) -> i32 - %12 = "llvm.and"(%11, %0) : (i32, i32) -> i32 - %13 = "llvm.or"(%7, %12) : (i32, i32) -> i32 - %14 = "llvm.or"(%13, %10) : (i32, i32) -> i32 - "llvm.return"(%14) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "multiuse3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 15360 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 17 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 480 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 22 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 100663296 : i32} : () -> i32 - %6 = "llvm.and"(%arg0, %5) : (i32, i32) -> i32 - %7 = "llvm.icmp"(%arg0, %4) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%7)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @or_and_shifts1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.constant(5 : i32) : i32 + %3 = llvm.mlir.constant(60 : i32) : i32 + %4 = llvm.shl %arg0, %0 : i32 + %5 = llvm.and %4, %1 : i32 + %6 = llvm.shl %arg0, %2 : i32 + %7 = llvm.and %6, %3 : i32 + %8 = llvm.or %5, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @or_and_shifts2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(896 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.constant(7 : i32) : i32 + %4 = llvm.shl %arg0, %0 : i32 + %5 = llvm.and %4, %1 : i32 + %6 = llvm.lshr %arg0, %2 : i32 + %7 = llvm.and %6, %3 : i32 + %8 = llvm.or %5, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @or_and_shift_shift_and(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(28 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.shl %4, %1 : i32 + %6 = llvm.shl %arg0, %2 : i32 + %7 = llvm.and %6, %3 : i32 + %8 = llvm.or %5, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @multiuse1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.constant(6 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.and %arg0, %1 : i32 + %6 = llvm.shl %4, %2 overflow : i32 + %7 = llvm.lshr %4, %3 : i32 + %8 = llvm.shl %5, %2 overflow : i32 + %9 = llvm.lshr %5, %3 : i32 + %10 = llvm.or %6, %8 : i32 + %11 = llvm.or %7, %9 : i32 + %12 = llvm.or %11, %10 : i32 + llvm.return %12 : i32 + } + llvm.func @multiuse2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(24 : i32) : i32 + %4 = llvm.mlir.constant(96 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.shl %5, %1 overflow : i32 + %7 = llvm.shl %5, %2 overflow : i32 + %8 = llvm.and %arg0, %3 : i32 + %9 = llvm.shl %8, %1 overflow : i32 + %10 = llvm.shl %8, %2 overflow : i32 + %11 = llvm.and %arg0, %4 : i32 + %12 = llvm.shl %11, %1 overflow : i32 + %13 = llvm.shl %11, %2 overflow : i32 + %14 = llvm.or %6, %9 : i32 + %15 = llvm.or %12, %14 : i32 + %16 = llvm.or %13, %10 : i32 + %17 = llvm.or %7, %16 : i32 + %18 = llvm.or %15, %17 : i32 + llvm.return %18 : i32 + } + llvm.func @multiuse3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(96 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(1920 : i32) : i32 + %4 = llvm.mlir.constant(15 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.shl %5, %1 overflow : i32 + %7 = llvm.lshr %5, %2 : i32 + %8 = llvm.shl %arg0, %1 : i32 + %9 = llvm.and %8, %3 : i32 + %10 = llvm.or %6, %9 : i32 + %11 = llvm.lshr %arg0, %2 : i32 + %12 = llvm.and %11, %4 : i32 + %13 = llvm.or %7, %12 : i32 + %14 = llvm.or %13, %10 : i32 + llvm.return %14 : i32 + } + llvm.func local_unnamed_addr @multiuse4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(100663296 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(17 : i32) : i32 + %3 = llvm.mlir.constant(15360 : i32) : i32 + %4 = llvm.mlir.constant(22 : i32) : i32 + %5 = llvm.mlir.constant(480 : i32) : i32 + %6 = llvm.and %arg0, %0 : i32 + %7 = llvm.icmp "sgt" %arg0, %1 : i32 + llvm.cond_br %7, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %8 = "llvm.lshr"(%6, %3) : (i32, i32) -> i32 - %9 = "llvm.lshr"(%arg0, %3) : (i32, i32) -> i32 - %10 = "llvm.and"(%9, %2) : (i32, i32) -> i32 - %11 = "llvm.or"(%10, %8) : (i32, i32) -> i32 - "llvm.br"(%11)[^bb3] : (i32) -> () + %8 = llvm.lshr %6, %4 : i32 + %9 = llvm.lshr %arg0, %4 : i32 + %10 = llvm.and %9, %5 : i32 + %11 = llvm.or %10, %8 : i32 + llvm.br ^bb3(%11 : i32) ^bb2: // pred: ^bb0 - %12 = "llvm.lshr"(%6, %1) : (i32, i32) -> i32 - %13 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - %14 = "llvm.and"(%13, %0) : (i32, i32) -> i32 - %15 = "llvm.or"(%14, %12) : (i32, i32) -> i32 - "llvm.br"(%15)[^bb3] : (i32) -> () + %12 = llvm.lshr %6, %2 : i32 + %13 = llvm.lshr %arg0, %2 : i32 + %14 = llvm.and %13, %3 : i32 + %15 = llvm.or %14, %12 : i32 + llvm.br ^bb3(%15 : i32) ^bb3(%16: i32): // 2 preds: ^bb1, ^bb2 - "llvm.return"(%16) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "multiuse4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 348160 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5570560 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1360 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 21760 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %6 = "llvm.shl"(%arg0, %5) : (i32, i32) -> i32 - %7 = "llvm.icmp"(%arg0, %4) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%7)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.return %16 : i32 + } + llvm.func local_unnamed_addr @multiuse5(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(5570560 : i32) : i32 + %3 = llvm.mlir.constant(348160 : i32) : i32 + %4 = llvm.mlir.constant(21760 : i32) : i32 + %5 = llvm.mlir.constant(1360 : i32) : i32 + %6 = llvm.shl %arg0, %0 : i32 + %7 = llvm.icmp "sgt" %arg0, %1 : i32 + llvm.cond_br %7, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %8 = "llvm.and"(%6, %3) : (i32, i32) -> i32 - %9 = "llvm.and"(%arg0, %2) : (i32, i32) -> i32 - %10 = "llvm.shl"(%9, %5) : (i32, i32) -> i32 - %11 = "llvm.or"(%10, %8) : (i32, i32) -> i32 - "llvm.br"(%11)[^bb3] : (i32) -> () + %8 = llvm.and %6, %4 : i32 + %9 = llvm.and %arg0, %5 : i32 + %10 = llvm.shl %9, %0 overflow : i32 + %11 = llvm.or %10, %8 : i32 + llvm.br ^bb3(%11 : i32) ^bb2: // pred: ^bb0 - %12 = "llvm.and"(%6, %1) : (i32, i32) -> i32 - %13 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - %14 = "llvm.shl"(%13, %5) : (i32, i32) -> i32 - %15 = "llvm.or"(%14, %12) : (i32, i32) -> i32 - "llvm.br"(%15)[^bb3] : (i32) -> () + %12 = llvm.and %6, %2 : i32 + %13 = llvm.and %arg0, %3 : i32 + %14 = llvm.shl %13, %0 overflow : i32 + %15 = llvm.or %14, %12 : i32 + llvm.br ^bb3(%15 : i32) ^bb3(%16: i32): // 2 preds: ^bb1, ^bb2 - "llvm.return"(%16) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "multiuse5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 255 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.or"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "shl_mask", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 255 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.or"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "shl_mask_wrong_shl_const", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i37): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i37} : () -> i37 - %1 = "llvm.mlir.constant"() {value = 255 : i37} : () -> i37 - %2 = "llvm.and"(%arg0, %1) : (i37, i37) -> i37 - %3 = "llvm.shl"(%2, %0) : (i37, i37) -> i37 - %4 = "llvm.or"(%2, %3) : (i37, i37) -> i37 - "llvm.return"(%4) : (i37) -> () - }) {linkage = 10 : i64, sym_name = "shl_mask_weird_type", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 255 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%2, %0) : (i32, i32) -> i32 - "llvm.store"(%3, %arg1) : (i32, !llvm.ptr) -> () - %4 = "llvm.or"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "shl_mask_extra_use", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 65537 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 255 : i32} : () -> i32 - %3 = "llvm.and"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.mul"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.shl"(%3, %0) : (i32, i32) -> i32 - %6 = "llvm.or"(%4, %5) : (i32, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "shl_mul_mask", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 65535 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 255 : i32} : () -> i32 - %3 = "llvm.and"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.mul"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.shl"(%3, %0) : (i32, i32) -> i32 - %6 = "llvm.or"(%4, %5) : (i32, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "shl_mul_mask_wrong_mul_const", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %16 : i32 + } + llvm.func @shl_mask(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + %4 = llvm.or %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @shl_mask_wrong_shl_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + %4 = llvm.or %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @shl_mask_weird_type(%arg0: i37) -> i37 { + %0 = llvm.mlir.constant(255 : i37) : i37 + %1 = llvm.mlir.constant(8 : i37) : i37 + %2 = llvm.and %arg0, %0 : i37 + %3 = llvm.shl %2, %1 : i37 + %4 = llvm.or %2, %3 : i37 + llvm.return %4 : i37 + } + llvm.func @shl_mask_extra_use(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.store %3, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.or %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @shl_mul_mask(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(65537 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.mul %3, %1 : i32 + %5 = llvm.shl %3, %2 : i32 + %6 = llvm.or %4, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @shl_mul_mask_wrong_mul_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.mul %3, %1 : i32 + %5 = llvm.shl %3, %2 : i32 + %6 = llvm.or %4, %5 : i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/or-xor-xor.ll.mlir b/test/LLVMDialect/InstCombine/or-xor-xor.ll.mlir new file mode 100644 index 000000000..fad6c0ef8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/or-xor-xor.ll.mlir @@ -0,0 +1,75 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use.i3(i1) + llvm.func @use.i5(i5) + llvm.func @use.i32(i5) + llvm.func @or_xor_xor_normal_variant1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.and %arg0, %arg1 : i1 + %1 = llvm.xor %0, %arg0 : i1 + %2 = llvm.xor %0, %arg1 : i1 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @or_xor_xor_normal_variant2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.and %arg0, %arg1 : i8 + %1 = llvm.xor %0, %arg1 : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.or %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @or_xor_xor_normal_variant3(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.and %arg1, %arg0 : i16 + %1 = llvm.xor %arg1, %0 : i16 + %2 = llvm.xor %arg0, %0 : i16 + %3 = llvm.or %1, %2 : i16 + llvm.return %3 : i16 + } + llvm.func @or_xor_xor_normal_variant4(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.and %arg1, %arg0 : i64 + %1 = llvm.xor %0, %arg1 : i64 + %2 = llvm.xor %0, %arg0 : i64 + %3 = llvm.or %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @or_xor_xor_normal_binops(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg0, %arg2 : i32 + %1 = llvm.xor %arg1, %arg2 : i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.xor %1, %2 : i32 + %4 = llvm.xor %0, %2 : i32 + %5 = llvm.or %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @or_xor_xor_normal_vector(%arg0: vector<3xi1>, %arg1: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.and %arg0, %arg1 : vector<3xi1> + %1 = llvm.xor %0, %arg1 : vector<3xi1> + %2 = llvm.xor %0, %arg0 : vector<3xi1> + %3 = llvm.or %1, %2 : vector<3xi1> + llvm.return %3 : vector<3xi1> + } + llvm.func @or_xor_xor_normal_multiple_uses_and(%arg0: i3, %arg1: i3) -> i3 { + %0 = llvm.mlir.addressof @use.i3 : !llvm.ptr + %1 = llvm.and %arg0, %arg1 : i3 + llvm.call %0(%1) : !llvm.ptr, (i3) -> () + %2 = llvm.xor %arg1, %1 : i3 + %3 = llvm.xor %arg0, %1 : i3 + %4 = llvm.or %2, %3 : i3 + llvm.return %4 : i3 + } + llvm.func @or_xor_xor_negative_multiple_uses_xor1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.addressof @use.i32 : !llvm.ptr + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %1, %arg1 : i32 + llvm.call %0(%2) : !llvm.ptr, (i32) -> () + %3 = llvm.xor %1, %arg0 : i32 + %4 = llvm.or %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @or_xor_xor_negative_multiple_uses_xor2(%arg0: i5, %arg1: i5) -> i5 { + %0 = llvm.and %arg0, %arg1 : i5 + %1 = llvm.xor %0, %arg1 : i5 + %2 = llvm.xor %0, %arg0 : i5 + llvm.call @use.i5(%2) : (i5) -> () + %3 = llvm.or %1, %2 : i5 + llvm.return %3 : i5 + } +} diff --git a/test/LLVMDialect/InstCombine/or-xor.ll.mlir b/test/LLVMDialect/InstCombine/or-xor.ll.mlir new file mode 100644 index 000000000..78a2649f6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/or-xor.ll.mlir @@ -0,0 +1,860 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @test1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg0, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg0, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test4(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.or %arg1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test5(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %arg1 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.or %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test5_commuted(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg0, %arg1 : vector<2xi4> + %3 = llvm.xor %arg0, %1 : vector<2xi4> + %4 = llvm.or %3, %2 : vector<2xi4> + llvm.return %4 : vector<2xi4> + } + llvm.func @test5_commuted_x_y(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.xor %arg1, %arg0 : i64 + %2 = llvm.xor %arg0, %0 : i64 + %3 = llvm.or %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @test5_extra_use_not(%arg0: i8, %arg1: i8, %arg2: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %arg1 : i8 + %2 = llvm.xor %arg0, %0 : i8 + llvm.store %2, %arg2 {alignment = 1 : i64} : i8, !llvm.ptr + %3 = llvm.or %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @test5_extra_use_xor(%arg0: i65, %arg1: i65, %arg2: !llvm.ptr) -> i65 { + %0 = llvm.mlir.constant(-1 : i65) : i65 + %1 = llvm.xor %arg0, %arg1 : i65 + llvm.store %1, %arg2 {alignment = 4 : i64} : i65, !llvm.ptr + %2 = llvm.xor %arg0, %0 : i65 + %3 = llvm.or %2, %1 : i65 + llvm.return %3 : i65 + } + llvm.func @test5_extra_use_not_xor(%arg0: i16, %arg1: i16, %arg2: !llvm.ptr, %arg3: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(-1 : i16) : i16 + %1 = llvm.xor %arg0, %arg1 : i16 + llvm.store %1, %arg3 {alignment = 2 : i64} : i16, !llvm.ptr + %2 = llvm.xor %arg0, %0 : i16 + llvm.store %2, %arg2 {alignment = 2 : i64} : i16, !llvm.ptr + %3 = llvm.or %2, %1 : i16 + llvm.return %3 : i16 + } + llvm.func @xor_common_op_commute0(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.xor %arg0, %arg1 : i8 + %1 = llvm.or %0, %arg0 : i8 + llvm.return %1 : i8 + } + llvm.func @xor_common_op_commute1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.xor %arg1, %arg0 : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.or %0, %arg0 : i8 + llvm.return %1 : i8 + } + llvm.func @xor_common_op_commute2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %1, %arg1 : i8 + %3 = llvm.or %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @xor_common_op_commute3(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.mul %arg1, %arg1 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.or %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @test8(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %1 : i32 + %3 = llvm.or %arg1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test9(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %1, %arg1 : i32 + %3 = llvm.or %arg0, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test10(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %2, %arg1 : i32 + %4 = llvm.or %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test10_commuted(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %2, %arg1 : i32 + %4 = llvm.or %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @test10_extrause(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + llvm.store %2, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.xor %2, %arg1 : i32 + %4 = llvm.or %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test10_commuted_extrause(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + llvm.store %2, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.xor %2, %arg1 : i32 + %4 = llvm.or %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @test10_canonical(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.xor %arg0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.or %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test11(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %2, %arg1 : i32 + %4 = llvm.and %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test12(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %1, %arg1 : i32 + %3 = llvm.or %arg0, %arg1 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test12_commuted(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %1, %arg1 : i32 + %3 = llvm.or %arg1, %arg0 : i32 + %4 = llvm.and %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test13(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.xor %arg1, %arg0 : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @test14(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.or %arg0, %1 : i32 + %4 = llvm.or %2, %arg1 : i32 + %5 = llvm.xor %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test14_commuted(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.or %1, %arg0 : i32 + %4 = llvm.or %2, %arg1 : i32 + %5 = llvm.xor %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test15(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.and %2, %arg1 : i32 + %5 = llvm.xor %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test15_commuted(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.and %1, %arg0 : i32 + %4 = llvm.and %2, %arg1 : i32 + %5 = llvm.xor %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @or_and_xor_not_constant_commute0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.xor %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.and %arg1, %1 : i32 + %5 = llvm.or %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @or_and_xor_not_constant_commute1(%arg0: i9, %arg1: i9) -> i9 { + %0 = llvm.mlir.constant(42 : i9) : i9 + %1 = llvm.mlir.constant(-43 : i9) : i9 + %2 = llvm.xor %arg1, %arg0 : i9 + %3 = llvm.and %2, %0 : i9 + %4 = llvm.and %arg1, %1 : i9 + %5 = llvm.or %3, %4 : i9 + llvm.return %5 : i9 + } + llvm.func @or_and_xor_not_constant_commute2_splat(%arg0: vector<2xi9>, %arg1: vector<2xi9>) -> vector<2xi9> { + %0 = llvm.mlir.constant(42 : i9) : i9 + %1 = llvm.mlir.constant(dense<42> : vector<2xi9>) : vector<2xi9> + %2 = llvm.mlir.constant(-43 : i9) : i9 + %3 = llvm.mlir.constant(dense<-43> : vector<2xi9>) : vector<2xi9> + %4 = llvm.xor %arg1, %arg0 : vector<2xi9> + %5 = llvm.and %4, %1 : vector<2xi9> + %6 = llvm.and %arg1, %3 : vector<2xi9> + %7 = llvm.or %6, %5 : vector<2xi9> + llvm.return %7 : vector<2xi9> + } + llvm.func @or_and_xor_not_constant_commute3_splat(%arg0: vector<2xi9>, %arg1: vector<2xi9>) -> vector<2xi9> { + %0 = llvm.mlir.constant(42 : i9) : i9 + %1 = llvm.mlir.constant(dense<42> : vector<2xi9>) : vector<2xi9> + %2 = llvm.mlir.constant(-43 : i9) : i9 + %3 = llvm.mlir.constant(dense<-43> : vector<2xi9>) : vector<2xi9> + %4 = llvm.xor %arg0, %arg1 : vector<2xi9> + %5 = llvm.and %4, %1 : vector<2xi9> + %6 = llvm.and %arg1, %3 : vector<2xi9> + %7 = llvm.or %6, %5 : vector<2xi9> + llvm.return %7 : vector<2xi9> + } + llvm.func @not_or(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_or_xor(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(12 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.or %3, %1 : i8 + %5 = llvm.xor %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @xor_or(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(32 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @xor_or2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(33 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @xor_or_xor(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(33 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(12 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.or %3, %1 : i8 + %5 = llvm.xor %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @or_xor_or(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(33 : i8) : i8 + %1 = llvm.mlir.constant(12 : i8) : i8 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.or %arg0, %0 : i8 + %4 = llvm.xor %3, %1 : i8 + %5 = llvm.or %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @test17(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(33 : i8) : i8 + %1 = llvm.xor %arg1, %arg0 : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.xor %2, %arg1 : i8 + %4 = llvm.or %1, %3 : i8 + %5 = llvm.mul %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @test18(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(33 : i8) : i8 + %1 = llvm.xor %arg1, %arg0 : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.xor %2, %arg1 : i8 + %4 = llvm.or %3, %1 : i8 + %5 = llvm.mul %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @test19(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.or %arg0, %arg1 : i32 + %4 = llvm.or %2, %1 : i32 + %5 = llvm.xor %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test20(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.or %arg0, %arg1 : i32 + %4 = llvm.or %1, %2 : i32 + %5 = llvm.xor %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test21(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.or %2, %1 : i32 + %4 = llvm.or %arg0, %arg1 : i32 + %5 = llvm.xor %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test22(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.or %2, %1 : i32 + %4 = llvm.or %arg1, %arg0 : i32 + %5 = llvm.xor %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test23(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(13 : i8) : i8 + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.mlir.constant(12 : i8) : i8 + %4 = llvm.or %arg0, %0 : i8 + %5 = llvm.xor %4, %1 : i8 + %6 = llvm.or %5, %2 : i8 + %7 = llvm.xor %6, %3 : i8 + llvm.return %7 : i8 + } + llvm.func @test23v(%arg0: vector<2xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<[-2, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<13> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i8) : i8 + %4 = llvm.mlir.constant(12 : i8) : i8 + %5 = llvm.or %arg0, %0 : vector<2xi8> + %6 = llvm.xor %5, %1 : vector<2xi8> + %7 = llvm.extractelement %6[%2 : i32] : vector<2xi8> + %8 = llvm.or %7, %3 : i8 + %9 = llvm.xor %8, %4 : i8 + llvm.return %9 : i8 + } + llvm.func @PR45977_f1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.and %1, %arg1 : i32 + %3 = llvm.or %arg0, %arg1 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @PR45977_f2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.or %arg0, %2 : i32 + %4 = llvm.xor %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @or_xor_common_op_commute0(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.or %arg0, %arg1 : i8 + %1 = llvm.xor %arg0, %arg2 : i8 + %2 = llvm.or %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @or_xor_common_op_commute1(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.or %arg1, %arg0 : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.xor %arg0, %arg2 : i8 + %2 = llvm.or %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @or_xor_common_op_commute2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.or %arg0, %arg1 : i8 + %1 = llvm.xor %arg2, %arg0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.or %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @or_xor_common_op_commute3(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.or %arg1, %arg0 : i8 + llvm.call @use(%0) : (i8) -> () + %1 = llvm.xor %arg2, %arg0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.or %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @or_xor_common_op_commute4(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.or %arg0, %arg1 : vector<2xi8> + %1 = llvm.xor %arg0, %arg2 : vector<2xi8> + %2 = llvm.or %1, %0 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @or_xor_common_op_commute5(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.or %arg1, %arg0 : i8 + %1 = llvm.xor %arg0, %arg2 : i8 + %2 = llvm.or %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @or_xor_common_op_commute6(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.or %arg0, %arg1 : i8 + %1 = llvm.xor %arg2, %arg0 : i8 + %2 = llvm.or %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @or_xor_common_op_commute7(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.or %arg1, %arg0 : i8 + %1 = llvm.xor %arg2, %arg0 : i8 + %2 = llvm.or %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @or_xor_notcommon_op(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.or %arg0, %arg1 : i8 + %1 = llvm.xor %arg3, %arg2 : i8 + %2 = llvm.or %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @or_not_xor_common_op_commute0(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.xor %arg0, %0 : i4 + %2 = llvm.xor %arg0, %arg1 : i4 + %3 = llvm.or %1, %arg2 : i4 + %4 = llvm.or %3, %2 : i4 + llvm.return %4 : i4 + } + llvm.func @or_not_xor_common_op_commute1(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.xor %arg0, %arg1 : i8 + %3 = llvm.or %1, %arg2 : i8 + %4 = llvm.or %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @or_not_xor_common_op_commute2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.sub %0, %arg2 : i8 + %3 = llvm.xor %arg0, %1 : i8 + %4 = llvm.xor %arg0, %arg1 : i8 + %5 = llvm.or %2, %3 : i8 + %6 = llvm.or %4, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @or_not_xor_common_op_commute3(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.sub %0, %arg2 : i8 + %3 = llvm.xor %arg0, %1 : i8 + %4 = llvm.xor %arg0, %arg1 : i8 + %5 = llvm.or %2, %3 : i8 + %6 = llvm.or %5, %4 : i8 + llvm.return %6 : i8 + } + llvm.func @or_not_xor_common_op_commute4(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg0, %1 : vector<2xi4> + %3 = llvm.xor %arg1, %arg0 : vector<2xi4> + %4 = llvm.or %2, %arg2 : vector<2xi4> + %5 = llvm.or %4, %3 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @or_not_xor_common_op_commute5(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %arg0 : i8 + %3 = llvm.or %1, %arg2 : i8 + %4 = llvm.or %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @or_not_xor_common_op_commute6(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.sub %0, %arg2 : i8 + %3 = llvm.xor %arg0, %1 : i8 + %4 = llvm.xor %arg1, %arg0 : i8 + %5 = llvm.or %2, %3 : i8 + %6 = llvm.or %4, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @or_not_xor_common_op_commute7(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.sub %0, %arg2 : i8 + %3 = llvm.xor %arg0, %1 : i8 + %4 = llvm.xor %arg1, %arg0 : i8 + %5 = llvm.or %2, %3 : i8 + %6 = llvm.or %5, %4 : i8 + llvm.return %6 : i8 + } + llvm.func @or_not_xor_common_op_use1(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg0, %arg1 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.or %1, %arg2 : i8 + %4 = llvm.or %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @or_not_xor_common_op_use2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg0, %arg1 : i8 + %3 = llvm.or %1, %arg2 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.or %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @or_nand_xor_common_op_commute0(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.and %arg0, %arg2 : i4 + %2 = llvm.xor %1, %0 : i4 + %3 = llvm.xor %arg0, %arg1 : i4 + %4 = llvm.or %2, %3 : i4 + llvm.return %4 : i4 + } + llvm.func @or_nand_xor_common_op_commute1(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.poison : i4 + %2 = llvm.mlir.undef : vector<2xi4> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi4> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi4> + %7 = llvm.and %arg2, %arg0 : vector<2xi4> + %8 = llvm.xor %7, %6 : vector<2xi4> + %9 = llvm.xor %arg0, %arg1 : vector<2xi4> + %10 = llvm.or %9, %8 : vector<2xi4> + llvm.return %10 : vector<2xi4> + } + llvm.func @or_nand_xor_common_op_commute2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.and %arg0, %arg2 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.xor %arg1, %arg0 : i8 + %4 = llvm.or %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @or_nand_xor_common_op_commute3(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.and %arg2, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.xor %arg1, %arg0 : i8 + %4 = llvm.or %3, %2 : i8 + llvm.return %4 : i8 + } + llvm.func @or_nand_xor_common_op_commute3_use2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.and %arg2, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + %3 = llvm.xor %arg1, %arg0 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.or %3, %2 : i8 + llvm.return %4 : i8 + } + llvm.func @or_nand_xor_common_op_commute3_use3(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.and %arg2, %arg0 : i8 + %2 = llvm.xor %1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.xor %arg1, %arg0 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.or %3, %2 : i8 + llvm.return %4 : i8 + } + llvm.func @PR75692_1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(-5 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @PR75692_2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(-4 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @PR75692_3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(-5 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %arg1, %1 : i32 + %4 = llvm.or %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @or_xor_not(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %1 : i32 + %3 = llvm.or %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @or_xor_not_uses1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.addressof @use : !llvm.ptr + %2 = llvm.xor %arg1, %0 : i32 + llvm.call %1(%2) : !llvm.ptr, (i32) -> () + %3 = llvm.xor %arg0, %2 : i32 + %4 = llvm.or %3, %arg1 : i32 + llvm.return %4 : i32 + } + llvm.func @or_xor_not_uses2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.addressof @use : !llvm.ptr + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.xor %arg0, %2 : i32 + llvm.call %1(%3) : !llvm.ptr, (i32) -> () + %4 = llvm.or %3, %arg1 : i32 + llvm.return %4 : i32 + } + llvm.func @or_xor_and_commuted1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mul %arg1, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %2, %arg0 : i32 + %4 = llvm.or %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @or_xor_and_commuted2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mul %arg1, %arg1 : i32 + %2 = llvm.mul %arg0, %arg0 : i32 + %3 = llvm.xor %1, %0 : i32 + %4 = llvm.xor %2, %3 : i32 + %5 = llvm.or %4, %1 : i32 + llvm.return %5 : i32 + } + llvm.func @or_xor_tree_0000(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %1, %2 : i32 + %5 = llvm.xor %2, %3 : i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.or %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_0001(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %2, %1 : i32 + %5 = llvm.xor %2, %3 : i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.or %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_0010(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %1, %2 : i32 + %5 = llvm.xor %3, %2 : i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.or %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_0011(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %2, %1 : i32 + %5 = llvm.xor %3, %2 : i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.or %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_0100(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %1, %2 : i32 + %5 = llvm.xor %2, %3 : i32 + %6 = llvm.xor %1, %5 : i32 + %7 = llvm.or %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_0101(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %2, %1 : i32 + %5 = llvm.xor %2, %3 : i32 + %6 = llvm.xor %1, %5 : i32 + %7 = llvm.or %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_0110(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %1, %2 : i32 + %5 = llvm.xor %3, %2 : i32 + %6 = llvm.xor %1, %5 : i32 + %7 = llvm.or %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_0111(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %2, %1 : i32 + %5 = llvm.xor %3, %2 : i32 + %6 = llvm.xor %1, %5 : i32 + %7 = llvm.or %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_1000(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %1, %2 : i32 + %5 = llvm.xor %2, %3 : i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.or %6, %4 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_1001(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %2, %1 : i32 + %5 = llvm.xor %2, %3 : i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.or %6, %4 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_1010(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %1, %2 : i32 + %5 = llvm.xor %3, %2 : i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.or %6, %4 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_1011(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %2, %1 : i32 + %5 = llvm.xor %3, %2 : i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.or %6, %4 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_1100(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %1, %2 : i32 + %5 = llvm.xor %2, %3 : i32 + %6 = llvm.xor %1, %5 : i32 + %7 = llvm.or %6, %4 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_1101(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %2, %1 : i32 + %5 = llvm.xor %2, %3 : i32 + %6 = llvm.xor %1, %5 : i32 + %7 = llvm.or %6, %4 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_1110(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %1, %2 : i32 + %5 = llvm.xor %3, %2 : i32 + %6 = llvm.xor %1, %5 : i32 + %7 = llvm.or %6, %4 : i32 + llvm.return %7 : i32 + } + llvm.func @or_xor_tree_1111(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.mul %arg2, %0 : i32 + %4 = llvm.xor %2, %1 : i32 + %5 = llvm.xor %3, %2 : i32 + %6 = llvm.xor %1, %5 : i32 + %7 = llvm.or %6, %4 : i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/or.ll.mlir b/test/LLVMDialect/InstCombine/or.ll.mlir new file mode 100644 index 000000000..b8a1a4d91 --- /dev/null +++ b/test/LLVMDialect/InstCombine/or.ll.mlir @@ -0,0 +1,1293 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @test12(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test13(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test14(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test14_commuted(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.icmp "ult" %arg1, %arg0 : i32 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test14_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "ult" %arg0, %arg1 : i32 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @test15(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.or %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test15_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "ult" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg0, %arg1 : i32 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @test16(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test17(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test18(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(50 : i32) : i32 + %2 = llvm.icmp "sge" %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test18_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(50 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "sge" %arg0, %0 : i32 + %4 = llvm.icmp "slt" %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @test18vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<100> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<50> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "sge" %arg0, %0 : vector<2xi32> + %3 = llvm.icmp "slt" %arg0, %1 : vector<2xi32> + %4 = llvm.or %2, %3 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @test20(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + llvm.return %2 : i32 + } + llvm.func @test21(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.or %5, %4 : i32 + llvm.return %6 : i32 + } + llvm.func @test22(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test23(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.constant(-32768 : i16) : i16 + %2 = llvm.mlir.constant(8193 : i16) : i16 + %3 = llvm.lshr %arg0, %0 : i16 + %4 = llvm.or %3, %1 : i16 + %5 = llvm.xor %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @test23vec(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<-32768> : vector<2xi16>) : vector<2xi16> + %2 = llvm.mlir.constant(dense<8193> : vector<2xi16>) : vector<2xi16> + %3 = llvm.lshr %arg0, %0 : vector<2xi16> + %4 = llvm.or %3, %1 : vector<2xi16> + %5 = llvm.xor %4, %2 : vector<2xi16> + llvm.return %5 : vector<2xi16> + } + llvm.func @test25(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(57 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg1, %1 : i32 + %5 = llvm.or %3, %4 : i1 + %6 = llvm.xor %5, %2 : i1 + llvm.return %6 : i1 + } + llvm.func @test25_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(57 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg1, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i1 + %6 = llvm.xor %5, %2 : i1 + llvm.return %6 : i1 + } + llvm.func @and_icmp_eq_0(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.icmp "eq" %arg1, %0 : i32 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @and_icmp_eq_0_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "eq" %arg0, %1 : vector<2xi32> + %3 = llvm.icmp "eq" %arg1, %1 : vector<2xi32> + %4 = llvm.and %2, %3 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @and_icmp_eq_0_vector_poison1(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.icmp "eq" %arg0, %6 : vector<2xi32> + %8 = llvm.icmp "eq" %arg1, %6 : vector<2xi32> + %9 = llvm.and %7, %8 : vector<2xi1> + llvm.return %9 : vector<2xi1> + } + llvm.func @and_icmp_eq_0_vector_poison2(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.undef : vector<2xi32> + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<2xi32> + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<2xi32> + %12 = llvm.icmp "eq" %arg0, %6 : vector<2xi32> + %13 = llvm.icmp "eq" %arg1, %11 : vector<2xi32> + %14 = llvm.and %12, %13 : vector<2xi1> + llvm.return %14 : vector<2xi1> + } + llvm.func @and_icmp_eq_0_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.icmp "eq" %arg1, %0 : i32 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @test27(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.ptrtoint %arg0 : !llvm.ptr to i32 + %2 = llvm.ptrtoint %arg1 : !llvm.ptr to i32 + %3 = llvm.or %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test27vec(%arg0: !llvm.vec<2 x ptr>, %arg1: !llvm.vec<2 x ptr>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.ptrtoint %arg0 : !llvm.vec<2 x ptr> to vector<2xi32> + %3 = llvm.ptrtoint %arg1 : !llvm.vec<2 x ptr> to vector<2xi32> + %4 = llvm.or %2, %3 : vector<2xi32> + %5 = llvm.icmp "eq" %4, %1 : vector<2xi32> + llvm.return %5 : vector<2xi1> + } + llvm.func @test28(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %0 : i32 + %2 = llvm.icmp "ne" %arg1, %0 : i32 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @test28_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i32 + %3 = llvm.icmp "ne" %arg1, %0 : i32 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @test29(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.ptrtoint %arg0 : !llvm.ptr to i32 + %2 = llvm.ptrtoint %arg1 : !llvm.ptr to i32 + %3 = llvm.or %1, %2 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @test29vec(%arg0: !llvm.vec<2 x ptr>, %arg1: !llvm.vec<2 x ptr>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.ptrtoint %arg0 : !llvm.vec<2 x ptr> to vector<2xi32> + %3 = llvm.ptrtoint %arg1 : !llvm.vec<2 x ptr> to vector<2xi32> + %4 = llvm.or %2, %3 : vector<2xi32> + %5 = llvm.icmp "ne" %4, %1 : vector<2xi32> + llvm.return %5 : vector<2xi1> + } + llvm.func @test30(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32962 : i32) : i32 + %1 = llvm.mlir.constant(-65536 : i32) : i32 + %2 = llvm.mlir.constant(40186 : i32) : i32 + %3 = llvm.or %arg0, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.and %3, %2 : i32 + %6 = llvm.or %5, %4 : i32 + llvm.return %6 : i32 + } + llvm.func @test30vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<32962> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-65536> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<40186> : vector<2xi32>) : vector<2xi32> + %3 = llvm.or %arg0, %0 : vector<2xi32> + %4 = llvm.and %arg0, %1 : vector<2xi32> + %5 = llvm.and %3, %2 : vector<2xi32> + %6 = llvm.or %5, %4 : vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @test31(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(194 : i64) : i64 + %1 = llvm.mlir.constant(250 : i64) : i64 + %2 = llvm.mlir.constant(32768 : i64) : i64 + %3 = llvm.mlir.constant(4294941696 : i64) : i64 + %4 = llvm.or %arg0, %0 : i64 + %5 = llvm.and %4, %1 : i64 + %6 = llvm.or %arg0, %2 : i64 + %7 = llvm.and %6, %3 : i64 + %8 = llvm.or %5, %7 : i64 + llvm.return %8 : i64 + } + llvm.func @test31vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<194> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<250> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.constant(dense<32768> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mlir.constant(dense<4294941696> : vector<2xi64>) : vector<2xi64> + %4 = llvm.or %arg0, %0 : vector<2xi64> + %5 = llvm.and %4, %1 : vector<2xi64> + %6 = llvm.or %arg0, %2 : vector<2xi64> + %7 = llvm.and %6, %3 : vector<2xi64> + %8 = llvm.or %5, %7 : vector<2xi64> + llvm.return %8 : vector<2xi64> + } + llvm.func @test32(%arg0: vector<4xi1>, %arg1: vector<4xi32>, %arg2: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %2 = llvm.and %arg1, %1 : vector<4xi32> + %3 = llvm.xor %1, %0 : vector<4xi32> + %4 = llvm.and %arg2, %3 : vector<4xi32> + %5 = llvm.or %4, %2 : vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @test33(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.or %arg0, %arg1 : i1 + %1 = llvm.or %0, %arg0 : i1 + llvm.return %1 : i1 + } + llvm.func @test33_logical(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + %2 = llvm.select %1, %0, %arg0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @test34(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.or %arg1, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @test35(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1135 : i32) : i32 + %1 = llvm.or %arg0, %0 : i32 + %2 = llvm.or %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @test36(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(23 : i32) : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.mlir.constant(25 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.or %3, %4 : i1 + %6 = llvm.icmp "eq" %arg0, %2 : i32 + %7 = llvm.or %5, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @test36_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(23 : i32) : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(25 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %0 : i32 + %5 = llvm.icmp "eq" %arg0, %1 : i32 + %6 = llvm.select %4, %2, %5 : i1, i1 + %7 = llvm.icmp "eq" %arg0, %3 : i32 + %8 = llvm.select %6, %2, %7 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @test37(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.mlir.constant(23 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = llvm.icmp "ult" %3, %1 : i32 + %5 = llvm.icmp "eq" %arg0, %2 : i32 + %6 = llvm.or %4, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @test37_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.mlir.constant(23 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.add %arg0, %0 : i32 + %5 = llvm.icmp "ult" %4, %1 : i32 + %6 = llvm.icmp "eq" %arg0, %2 : i32 + %7 = llvm.select %5, %3, %6 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @test37_uniform(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<30> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<23> : vector<2xi32>) : vector<2xi32> + %3 = llvm.add %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "ult" %3, %1 : vector<2xi32> + %5 = llvm.icmp "eq" %arg0, %2 : vector<2xi32> + %6 = llvm.or %4, %5 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @test37_poison(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(30 : i32) : i32 + %8 = llvm.mlir.undef : vector<2xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi32> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi32> + %13 = llvm.mlir.constant(23 : i32) : i32 + %14 = llvm.mlir.undef : vector<2xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %13, %14[%15 : i32] : vector<2xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<2xi32> + %19 = llvm.add %arg0, %6 : vector<2xi32> + %20 = llvm.icmp "ult" %19, %12 : vector<2xi32> + %21 = llvm.icmp "eq" %arg0, %18 : vector<2xi32> + %22 = llvm.or %20, %21 : vector<2xi1> + llvm.return %22 : vector<2xi1> + } + llvm.func @test38(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(23 : i32) : i32 + %2 = llvm.mlir.constant(30 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.icmp "ult" %3, %2 : i32 + %6 = llvm.or %4, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @test38_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(23 : i32) : i32 + %2 = llvm.mlir.constant(30 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.add %arg0, %0 : i32 + %5 = llvm.icmp "eq" %arg0, %1 : i32 + %6 = llvm.icmp "ult" %4, %2 : i32 + %7 = llvm.select %5, %3, %6 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @test38_nonuniform(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[7, 24]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[23, 8]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[30, 32]> : vector<2xi32>) : vector<2xi32> + %3 = llvm.add %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "eq" %arg0, %1 : vector<2xi32> + %5 = llvm.icmp "ult" %3, %2 : vector<2xi32> + %6 = llvm.or %4, %5 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @test39a(%arg0: i32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.bitcast %arg1 : f32 to i32 + %4 = llvm.xor %2, %1 : i32 + %5 = llvm.and %4, %3 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @test39b(%arg0: i32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.bitcast %arg1 : f32 to i32 + %4 = llvm.xor %2, %1 : i32 + %5 = llvm.and %3, %4 : i32 + %6 = llvm.or %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @test39c(%arg0: i32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.bitcast %arg1 : f32 to i32 + %4 = llvm.xor %2, %1 : i32 + %5 = llvm.and %4, %3 : i32 + %6 = llvm.or %2, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @test39d(%arg0: i32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.bitcast %arg1 : f32 to i32 + %4 = llvm.xor %2, %1 : i32 + %5 = llvm.and %3, %4 : i32 + %6 = llvm.or %2, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @test40(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.or %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test40b(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.or %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test40c(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.or %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test40d(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.or %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test45(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.or %arg1, %arg2 : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.or %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @test45_uses1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.or %arg1, %arg2 : i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.or %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @test45_uses2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.or %arg1, %arg2 : i32 + %1 = llvm.and %arg0, %0 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.or %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @test45_commuted1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mul %arg1, %arg1 : i32 + %1 = llvm.or %0, %arg2 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.or %0, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test45_commuted2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mul %arg1, %arg1 : i32 + %1 = llvm.mul %arg0, %arg0 : i32 + %2 = llvm.or %0, %arg2 : i32 + %3 = llvm.and %1, %2 : i32 + %4 = llvm.or %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @test45_commuted3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mul %arg1, %arg1 : i32 + %1 = llvm.mul %arg2, %arg2 : i32 + %2 = llvm.or %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.or %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @test46(%arg0: i8 {llvm.signext}) -> i1 { + %0 = llvm.mlir.constant(-97 : i8) : i8 + %1 = llvm.mlir.constant(26 : i8) : i8 + %2 = llvm.mlir.constant(-65 : i8) : i8 + %3 = llvm.add %arg0, %0 : i8 + %4 = llvm.icmp "ult" %3, %1 : i8 + %5 = llvm.add %arg0, %2 : i8 + %6 = llvm.icmp "ult" %5, %1 : i8 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @test46_logical(%arg0: i8 {llvm.signext}) -> i1 { + %0 = llvm.mlir.constant(-97 : i8) : i8 + %1 = llvm.mlir.constant(26 : i8) : i8 + %2 = llvm.mlir.constant(-65 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.add %arg0, %0 : i8 + %5 = llvm.icmp "ult" %4, %1 : i8 + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.icmp "ult" %6, %1 : i8 + %8 = llvm.select %5, %3, %7 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @test46_uniform(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-97> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<26> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<-65> : vector<2xi8>) : vector<2xi8> + %3 = llvm.add %arg0, %0 : vector<2xi8> + %4 = llvm.icmp "ult" %3, %1 : vector<2xi8> + %5 = llvm.add %arg0, %2 : vector<2xi8> + %6 = llvm.icmp "ult" %5, %1 : vector<2xi8> + %7 = llvm.or %4, %6 : vector<2xi1> + llvm.return %7 : vector<2xi1> + } + llvm.func @test46_poison(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-97 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(26 : i8) : i8 + %8 = llvm.mlir.undef : vector<2xi8> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi8> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi8> + %13 = llvm.mlir.constant(-65 : i8) : i8 + %14 = llvm.mlir.undef : vector<2xi8> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %13, %14[%15 : i32] : vector<2xi8> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<2xi8> + %19 = llvm.add %arg0, %6 : vector<2xi8> + %20 = llvm.icmp "ult" %19, %12 : vector<2xi8> + %21 = llvm.add %arg0, %18 : vector<2xi8> + %22 = llvm.icmp "ult" %21, %12 : vector<2xi8> + %23 = llvm.or %20, %22 : vector<2xi1> + llvm.return %23 : vector<2xi1> + } + llvm.func @two_ranges_to_mask_and_range_degenerate(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(12 : i16) : i16 + %1 = llvm.mlir.constant(16 : i16) : i16 + %2 = llvm.mlir.constant(28 : i16) : i16 + %3 = llvm.icmp "ult" %arg0, %0 : i16 + %4 = llvm.icmp "uge" %arg0, %1 : i16 + %5 = llvm.icmp "ult" %arg0, %2 : i16 + %6 = llvm.and %4, %5 : i1 + %7 = llvm.or %3, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @test47(%arg0: i8 {llvm.signext}) -> i1 { + %0 = llvm.mlir.constant(-65 : i8) : i8 + %1 = llvm.mlir.constant(26 : i8) : i8 + %2 = llvm.mlir.constant(-97 : i8) : i8 + %3 = llvm.add %arg0, %0 : i8 + %4 = llvm.icmp "ule" %3, %1 : i8 + %5 = llvm.add %arg0, %2 : i8 + %6 = llvm.icmp "ule" %5, %1 : i8 + %7 = llvm.or %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @test47_logical(%arg0: i8 {llvm.signext}) -> i1 { + %0 = llvm.mlir.constant(-65 : i8) : i8 + %1 = llvm.mlir.constant(26 : i8) : i8 + %2 = llvm.mlir.constant(-97 : i8) : i8 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.add %arg0, %0 : i8 + %5 = llvm.icmp "ule" %4, %1 : i8 + %6 = llvm.add %arg0, %2 : i8 + %7 = llvm.icmp "ule" %6, %1 : i8 + %8 = llvm.select %5, %3, %7 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @test47_nonuniform(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-65, -97]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<26> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<[-97, -65]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.add %arg0, %0 : vector<2xi8> + %4 = llvm.icmp "ule" %3, %1 : vector<2xi8> + %5 = llvm.add %arg0, %2 : vector<2xi8> + %6 = llvm.icmp "ule" %5, %1 : vector<2xi8> + %7 = llvm.or %4, %6 : vector<2xi1> + llvm.return %7 : vector<2xi1> + } + llvm.func @test49(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1000 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.constant(123 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @test49vec(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1000> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<123> : vector<2xi32>) : vector<2xi32> + %3 = llvm.select %arg0, %0, %1 : i1, vector<2xi32> + %4 = llvm.or %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test49vec2(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[1000, 2500]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[10, 30]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[123, 333]> : vector<2xi32>) : vector<2xi32> + %3 = llvm.select %arg0, %0, %1 : i1, vector<2xi32> + %4 = llvm.or %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test50(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1000 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.constant(123 : i32) : i32 + llvm.cond_br %arg0, ^bb2(%0 : i32), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : i32) + ^bb2(%3: i32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @test50vec(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1000> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<123> : vector<2xi32>) : vector<2xi32> + llvm.cond_br %arg0, ^bb2(%0 : vector<2xi32>), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : vector<2xi32>) + ^bb2(%3: vector<2xi32>): // 2 preds: ^bb0, ^bb1 + %4 = llvm.or %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test50vec2(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[1000, 2500]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[10, 30]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[123, 333]> : vector<2xi32>) : vector<2xi32> + llvm.cond_br %arg0, ^bb2(%0 : vector<2xi32>), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : vector<2xi32>) + ^bb2(%3: vector<2xi32>): // 2 preds: ^bb0, ^bb1 + %4 = llvm.or %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @or_andn_cmp_1(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %2 = llvm.icmp "sle" %arg0, %arg1 : i32 + %3 = llvm.icmp "ugt" %arg2, %0 : i32 + %4 = llvm.and %3, %2 : i1 + %5 = llvm.or %1, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @or_andn_cmp_1_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %4 = llvm.icmp "sle" %arg0, %arg1 : i32 + %5 = llvm.icmp "ugt" %arg2, %0 : i32 + %6 = llvm.select %5, %4, %1 : i1, i1 + %7 = llvm.select %3, %2, %6 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @or_andn_cmp_2(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[42, 47]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "sge" %arg0, %arg1 : vector<2xi32> + %2 = llvm.icmp "slt" %arg0, %arg1 : vector<2xi32> + %3 = llvm.icmp "ugt" %arg2, %0 : vector<2xi32> + %4 = llvm.and %3, %2 : vector<2xi1> + %5 = llvm.or %4, %1 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @or_andn_cmp_3(%arg0: i72, %arg1: i72, %arg2: i72) -> i1 { + %0 = llvm.mlir.constant(42 : i72) : i72 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i72 + %2 = llvm.icmp "ule" %arg0, %arg1 : i72 + %3 = llvm.icmp "ugt" %arg2, %0 : i72 + %4 = llvm.and %2, %3 : i1 + %5 = llvm.or %1, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @or_andn_cmp_3_logical(%arg0: i72, %arg1: i72, %arg2: i72) -> i1 { + %0 = llvm.mlir.constant(42 : i72) : i72 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "ugt" %arg0, %arg1 : i72 + %4 = llvm.icmp "ule" %arg0, %arg1 : i72 + %5 = llvm.icmp "ugt" %arg2, %0 : i72 + %6 = llvm.select %4, %5, %1 : i1, i1 + %7 = llvm.select %3, %2, %6 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @or_andn_cmp_4(%arg0: vector<3xi32>, %arg1: vector<3xi32>, %arg2: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<[42, 43, -1]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.icmp "eq" %arg0, %arg1 : vector<3xi32> + %2 = llvm.icmp "ne" %arg0, %arg1 : vector<3xi32> + %3 = llvm.icmp "ugt" %arg2, %0 : vector<3xi32> + %4 = llvm.and %2, %3 : vector<3xi1> + %5 = llvm.or %4, %1 : vector<3xi1> + llvm.return %5 : vector<3xi1> + } + llvm.func @orn_and_cmp_1(%arg0: i37, %arg1: i37, %arg2: i37) -> i1 { + %0 = llvm.mlir.constant(42 : i37) : i37 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i37 + %2 = llvm.icmp "sle" %arg0, %arg1 : i37 + %3 = llvm.icmp "ugt" %arg2, %0 : i37 + %4 = llvm.and %3, %1 : i1 + %5 = llvm.or %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @orn_and_cmp_1_logical(%arg0: i37, %arg1: i37, %arg2: i37) -> i1 { + %0 = llvm.mlir.constant(42 : i37) : i37 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "sgt" %arg0, %arg1 : i37 + %4 = llvm.icmp "sle" %arg0, %arg1 : i37 + %5 = llvm.icmp "ugt" %arg2, %0 : i37 + %6 = llvm.select %5, %3, %1 : i1, i1 + %7 = llvm.select %4, %2, %6 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @orn_and_cmp_2(%arg0: i16, %arg1: i16, %arg2: i16) -> i1 { + %0 = llvm.mlir.constant(42 : i16) : i16 + %1 = llvm.icmp "sge" %arg0, %arg1 : i16 + %2 = llvm.icmp "slt" %arg0, %arg1 : i16 + %3 = llvm.icmp "ugt" %arg2, %0 : i16 + %4 = llvm.and %3, %1 : i1 + %5 = llvm.or %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @orn_and_cmp_2_logical(%arg0: i16, %arg1: i16, %arg2: i16) -> i1 { + %0 = llvm.mlir.constant(42 : i16) : i16 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "sge" %arg0, %arg1 : i16 + %4 = llvm.icmp "slt" %arg0, %arg1 : i16 + %5 = llvm.icmp "ugt" %arg2, %0 : i16 + %6 = llvm.select %5, %3, %1 : i1, i1 + %7 = llvm.select %6, %2, %4 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @orn_and_cmp_3(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<[42, 0, 1, -1]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.icmp "ugt" %arg0, %arg1 : vector<4xi32> + %2 = llvm.icmp "ule" %arg0, %arg1 : vector<4xi32> + %3 = llvm.icmp "ugt" %arg2, %0 : vector<4xi32> + %4 = llvm.and %1, %3 : vector<4xi1> + %5 = llvm.or %2, %4 : vector<4xi1> + llvm.return %5 : vector<4xi1> + } + llvm.func @orn_and_cmp_4(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "ne" %arg0, %arg1 : i32 + %3 = llvm.icmp "ugt" %arg2, %0 : i32 + %4 = llvm.and %1, %3 : i1 + %5 = llvm.or %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @orn_and_cmp_4_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "eq" %arg0, %arg1 : i32 + %4 = llvm.icmp "ne" %arg0, %arg1 : i32 + %5 = llvm.icmp "ugt" %arg2, %0 : i32 + %6 = llvm.select %3, %5, %1 : i1, i1 + %7 = llvm.select %6, %2, %4 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @test51(%arg0: vector<16xi1>, %arg1: vector<16xi1>) -> vector<16xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(dense<[true, true, true, true, false, true, true, false, false, true, true, false, false, false, false, false]> : vector<16xi1>) : vector<16xi1> + %3 = llvm.mlir.constant(dense<[false, false, false, false, true, false, false, true, true, false, false, true, true, true, true, true]> : vector<16xi1>) : vector<16xi1> + %4 = llvm.and %arg0, %2 : vector<16xi1> + %5 = llvm.and %arg1, %3 : vector<16xi1> + %6 = llvm.or %4, %5 : vector<16xi1> + llvm.return %6 : vector<16xi1> + } + llvm.func @PR46712(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i64) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.or %arg0, %arg1 : i1 + %5 = llvm.sext %4 : i1 to i32 + %6 = llvm.icmp "sge" %5, %0 : i32 + %7 = llvm.zext %6 : i1 to i64 + llvm.cond_br %arg2, ^bb1, ^bb2(%1 : i1) + ^bb1: // pred: ^bb0 + %8 = llvm.icmp "eq" %7, %2 : i64 + %9 = llvm.icmp "ne" %arg3, %2 : i64 + %10 = llvm.and %8, %9 : i1 + %11 = llvm.select %10, %1, %3 : i1, i1 + llvm.br ^bb2(%11 : i1) + ^bb2(%12: i1): // 2 preds: ^bb0, ^bb1 + %13 = llvm.zext %12 : i1 to i32 + llvm.return %13 : i32 + } + llvm.func @PR46712_logical(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i64) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.select %arg0, %0, %arg1 : i1, i1 + %5 = llvm.sext %4 : i1 to i32 + %6 = llvm.icmp "sge" %5, %1 : i32 + %7 = llvm.zext %6 : i1 to i64 + llvm.cond_br %arg2, ^bb1, ^bb2(%2 : i1) + ^bb1: // pred: ^bb0 + %8 = llvm.icmp "eq" %7, %3 : i64 + %9 = llvm.icmp "ne" %arg3, %3 : i64 + %10 = llvm.select %8, %9, %2 : i1, i1 + %11 = llvm.select %10, %2, %0 : i1, i1 + llvm.br ^bb2(%11 : i1) + ^bb2(%12: i1): // 2 preds: ^bb0, ^bb1 + %13 = llvm.zext %12 : i1 to i32 + llvm.return %13 : i32 + } + llvm.func @PR38929(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.and %1, %arg1 : i32 + %3 = llvm.or %arg1, %arg0 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.or %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.or %arg1, %arg0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.or %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg1, %arg0 : i32 + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @test3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg0, %arg1 : i32 + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @test4_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.or %arg1, %arg0 : vector<2xi32> + %2 = llvm.xor %1, %0 : vector<2xi32> + %3 = llvm.xor %arg1, %arg0 : vector<2xi32> + %4 = llvm.or %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test5_use(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg1, %arg0 : i32 + llvm.call @use(%2) : (i32) -> () + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @test5_use2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.xor %arg1, %arg0 : i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @test5_use3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.xor %arg1, %arg0 : i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @ashr_bitwidth_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.or %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @ashr_bitwidth_mask_vec_commute(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[42, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mul %arg1, %0 : vector<2xi8> + %3 = llvm.ashr %arg0, %1 : vector<2xi8> + %4 = llvm.or %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @ashr_bitwidth_mask_use(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.ashr %arg0, %0 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.or %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @ashr_not_bitwidth_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + %2 = llvm.or %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @lshr_bitwidth_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.lshr %arg0, %0 : i8 + %2 = llvm.or %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @cmp_overlap(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.sub %0, %arg0 : i32 + %4 = llvm.icmp "sgt" %3, %1 : i32 + %5 = llvm.or %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @cmp_overlap_splat(%arg0: vector<2xi5>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i5) : i5 + %1 = llvm.mlir.constant(dense<0> : vector<2xi5>) : vector<2xi5> + %2 = llvm.mlir.constant(-1 : i5) : i5 + %3 = llvm.mlir.constant(dense<-1> : vector<2xi5>) : vector<2xi5> + %4 = llvm.icmp "slt" %arg0, %1 : vector<2xi5> + %5 = llvm.sub %1, %arg0 : vector<2xi5> + %6 = llvm.icmp "sgt" %5, %3 : vector<2xi5> + %7 = llvm.or %4, %6 : vector<2xi1> + llvm.return %7 : vector<2xi1> + } + llvm.func @mul_no_common_bits(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %arg1, %1 : i32 + %4 = llvm.mul %2, %3 : i32 + %5 = llvm.or %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @mul_no_common_bits_const_op(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.mul %2, %1 : i32 + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @mul_no_common_bits_commute(%arg0: vector<2xi12>) -> vector<2xi12> { + %0 = llvm.mlir.constant(1 : i12) : i12 + %1 = llvm.mlir.constant(dense<1> : vector<2xi12>) : vector<2xi12> + %2 = llvm.mlir.constant(16 : i12) : i12 + %3 = llvm.mlir.constant(14 : i12) : i12 + %4 = llvm.mlir.constant(dense<[14, 16]> : vector<2xi12>) : vector<2xi12> + %5 = llvm.and %arg0, %1 : vector<2xi12> + %6 = llvm.mul %5, %4 : vector<2xi12> + %7 = llvm.or %5, %6 : vector<2xi12> + llvm.return %7 : vector<2xi12> + } + llvm.func @mul_no_common_bits_commute2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %arg1, %1 : i32 + %4 = llvm.mul %3, %2 : i32 + %5 = llvm.or %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @mul_no_common_bits_disjoint(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mul %arg0, %arg1 : i32 + %1 = llvm.or %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @mul_no_common_bits_const_op_disjoint(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.or %1, %arg0 : i32 + llvm.return %2 : i32 + } + llvm.func @mul_no_common_bits_uses(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %arg1, %1 : i32 + %4 = llvm.mul %2, %3 : i32 + llvm.call @use(%4) : (i32) -> () + %5 = llvm.or %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @mul_no_common_bits_const_op_uses(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.mul %2, %1 : i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @mul_common_bits(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.mul %2, %1 : i32 + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @and_or_not_or_logical_vec(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %6 = llvm.icmp "eq" %arg0, %1 : vector<4xi32> + %7 = llvm.icmp "eq" %arg1, %1 : vector<4xi32> + %8 = llvm.xor %6, %3 : vector<4xi1> + %9 = llvm.select %7, %8, %5 : vector<4xi1>, vector<4xi1> + %10 = llvm.or %7, %6 : vector<4xi1> + %11 = llvm.xor %10, %3 : vector<4xi1> + %12 = llvm.or %9, %11 : vector<4xi1> + llvm.return %12 : vector<4xi1> + } + llvm.func @drop_disjoint(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.or %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @assoc_cast_assoc_disjoint(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.or %arg0, %0 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.or %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @test_or_and_disjoint(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(7 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %6 = llvm.and %arg0, %3 : i32 + %7 = llvm.or %6, %1 : i32 + llvm.return %7 : i32 + ^bb2: // pred: ^bb0 + llvm.return %2 : i32 + } + llvm.func @test_or_and_mixed(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(27 : i32) : i32 + %1 = llvm.mlir.constant(11 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(7 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %6 = llvm.and %arg0, %3 : i32 + %7 = llvm.or %6, %1 : i32 + llvm.return %7 : i32 + ^bb2: // pred: ^bb0 + llvm.return %2 : i32 + } + llvm.func @test_or_and_disjoint_fail(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(7 : i32) : i32 + %4 = llvm.mlir.constant(8 : i32) : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %7 = llvm.and %arg0, %3 : i32 + %8 = llvm.or %7, %4 : i32 + llvm.return %8 : i32 + ^bb2: // pred: ^bb0 + llvm.return %2 : i32 + } + llvm.func @test_or_and_disjoint_multiuse(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(7 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %6 = llvm.and %arg0, %3 : i32 + llvm.call @use(%6) : (i32) -> () + %7 = llvm.or %6, %1 : i32 + llvm.return %7 : i32 + ^bb2: // pred: ^bb0 + llvm.return %2 : i32 + } + llvm.func @test_or_and_xor_constant(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %2, %arg1 : i32 + %4 = llvm.or %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @test_or_and_xor(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg0, %arg1 : i32 + %1 = llvm.and %0, %arg2 : i32 + %2 = llvm.or %1, %arg0 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_and_xor_commuted1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg1, %arg0 : i32 + %1 = llvm.and %0, %arg2 : i32 + %2 = llvm.or %1, %arg0 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_and_xor_commuted2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mul %arg2, %arg2 : i32 + %1 = llvm.xor %arg0, %arg1 : i32 + %2 = llvm.and %0, %1 : i32 + %3 = llvm.or %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @test_or_and_xor_commuted3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mul %arg0, %arg0 : i32 + %1 = llvm.xor %0, %arg1 : i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.or %0, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test_or_and_xor_multiuse1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg0, %arg1 : i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.and %0, %arg2 : i32 + %2 = llvm.or %1, %arg0 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_and_xor_mismatched_op(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.xor %arg0, %arg1 : i32 + %1 = llvm.and %0, %arg2 : i32 + %2 = llvm.or %1, %arg3 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_and_xor_multiuse2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg0, %arg1 : i32 + %1 = llvm.and %0, %arg2 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.or %1, %arg0 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_add_xor(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg0, %arg1 : i32 + %1 = llvm.add %0, %arg2 : i32 + %2 = llvm.or %1, %arg0 : i32 + llvm.return %2 : i32 + } + llvm.func @test_or_and_and_multiuse(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.and %arg0, %arg1 : i32 + %1 = llvm.and %0, %arg2 : i32 + llvm.call @use(%0) : (i32) -> () + llvm.call @use(%1) : (i32) -> () + %2 = llvm.or %1, %arg0 : i32 + llvm.return %2 : i32 + } + llvm.func @or_xor_and(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.and %arg1, %arg2 : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.or %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @or_xor_and_uses1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.and %arg1, %arg2 : i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.or %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @or_xor_and_uses2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.and %arg1, %arg2 : i32 + %1 = llvm.xor %arg0, %0 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.or %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @or_xor_and_commuted1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mul %arg1, %arg1 : i32 + %1 = llvm.and %0, %arg2 : i32 + %2 = llvm.xor %1, %arg0 : i32 + %3 = llvm.or %0, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @or_xor_and_commuted2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mul %arg1, %arg1 : i32 + %1 = llvm.mul %arg0, %arg0 : i32 + %2 = llvm.and %0, %arg2 : i32 + %3 = llvm.xor %1, %2 : i32 + %4 = llvm.or %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @or_xor_and_commuted3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mul %arg1, %arg1 : i32 + %1 = llvm.mul %arg2, %arg2 : i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.xor %2, %arg0 : i32 + %4 = llvm.or %3, %0 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/oss_fuzz_32759.ll.mlir b/test/LLVMDialect/InstCombine/oss_fuzz_32759.ll.mlir index 678836900..7ab597d49 100644 --- a/test/LLVMDialect/InstCombine/oss_fuzz_32759.ll.mlir +++ b/test/LLVMDialect/InstCombine/oss_fuzz_32759.ll.mlir @@ -1,21 +1,19 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 123 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 2147483647 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - "llvm.cond_br"(%arg1, %3)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @oss_fuzz_32759(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.mlir.constant(123 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + llvm.cond_br %arg1, ^bb1, ^bb2(%0 : i32) ^bb1: // pred: ^bb0 - %4 = "llvm.zext"(%arg0) : (i1) -> i32 - %5 = "llvm.shl"(%4, %2) : (i32, i32) -> i32 - %6 = "llvm.ashr"(%5, %2) : (i32, i32) -> i32 - %7 = "llvm.srem"(%6, %1) : (i32, i32) -> i32 - %8 = "llvm.xor"(%7, %6) : (i32, i32) -> i32 - "llvm.br"(%8)[^bb2] : (i32) -> () + %4 = llvm.zext %arg0 : i1 to i32 + %5 = llvm.shl %4, %1 : i32 + %6 = llvm.ashr %5, %1 : i32 + %7 = llvm.srem %6, %2 : i32 + %8 = llvm.xor %7, %6 : i32 + llvm.br ^bb2(%8 : i32) ^bb2(%9: i32): // 2 preds: ^bb0, ^bb1 - %10 = "llvm.icmp"(%9, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%10) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "oss_fuzz_32759", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %10 = llvm.icmp "eq" %9, %3 : i32 + llvm.return %10 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/osx-names.ll.mlir b/test/LLVMDialect/InstCombine/osx-names.ll.mlir index fec9ec595..7f2e6101e 100644 --- a/test/LLVMDialect/InstCombine/osx-names.ll.mlir +++ b/test/LLVMDialect/InstCombine/osx-names.ll.mlir @@ -1,25 +1,17 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str", type = !llvm.array<13 x i8>, value = "Hello world\0A\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str2", type = !llvm.array<3 x i8>, value = "%s\00"} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, i32, i32, i16, i16, struct<"struct.__sbuf", (ptr, i32)>, i32, ptr, ptr)>>, ptr, ptr, i32)>>, ptr, i64, i32)>>, ptr, ptr, i32)>>, struct<"struct.__sbuf", (ptr, i32)>, ptr>, i32, array<3 x i8>, array<1 x i8>, struct<"struct.__sbuf", (ptr, i32)>, i32, i64)>>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%arg0, %2) {callee = @fprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i32, i16, i16, struct<"struct.__sbuf", (ptr, i32)>, i32, ptr, ptr)>>, ptr, ptr, i32)>>, ptr, i64, i32)>>, ptr, ptr, i32)>>, struct<"struct.__sbuf", (ptr, i32)>, ptr>, i32, array<3 x i8>, array<1 x i8>, struct<"struct.__sbuf", (ptr, i32)>, i32, i64)>>, !llvm.ptr) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func, i32, i32, i16, i16, struct<"struct.__sbuf", (ptr, i32)>, i32, ptr, ptr)>>, ptr, ptr, i32)>>, ptr, i64, i32)>>, ptr, ptr, i32)>>, struct<"struct.__sbuf", (ptr, i32)>, ptr>, i32, array<3 x i8>, array<1 x i8>, struct<"struct.__sbuf", (ptr, i32)>, i32, i64)>>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, i32, i32, i16, i16, struct<"struct.__sbuf", (ptr, i32)>, i32, ptr, ptr)>>, ptr, ptr, i32)>>, ptr, i64, i32)>>, ptr, ptr, i32)>>, struct<"struct.__sbuf", (ptr, i32)>, ptr>, i32, array<3 x i8>, array<1 x i8>, struct<"struct.__sbuf", (ptr, i32)>, i32, i64)>>, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @".str2"} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%arg0, %2, %arg1) {callee = @fprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i32, i16, i16, struct<"struct.__sbuf", (ptr, i32)>, i32, ptr, ptr)>>, ptr, ptr, i32)>>, ptr, i64, i32)>>, ptr, ptr, i32)>>, struct<"struct.__sbuf", (ptr, i32)>, ptr>, i32, array<3 x i8>, array<1 x i8>, struct<"struct.__sbuf", (ptr, i32)>, i32, i64)>>, !llvm.ptr, !llvm.ptr) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func, i32, i32, i16, i16, struct<"struct.__sbuf", (ptr, i32)>, i32, ptr, ptr)>>, ptr, ptr, i32)>>, ptr, i64, i32)>>, ptr, ptr, i32)>>, struct<"struct.__sbuf", (ptr, i32)>, ptr>, i32, array<3 x i8>, array<1 x i8>, struct<"struct.__sbuf", (ptr, i32)>, i32, i64)>>, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fprintf", type = !llvm.func, i32, i32, i16, i16, struct<"struct.__sbuf", (ptr, i32)>, i32, ptr, ptr)>>, ptr, ptr, i32)>>, ptr, i64, i32)>>, ptr, ptr, i32)>>, struct<"struct.__sbuf", (ptr, i32)>, ptr>, i32, array<3 x i8>, array<1 x i8>, struct<"struct.__sbuf", (ptr, i32)>, i32, i64)>>, ptr, ...)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private unnamed_addr constant @".str"("Hello world\0A\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str2"("%s\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.func @test1(%arg0: !llvm.ptr) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant("Hello world\0A\00") : !llvm.array<13 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.call @fprintf(%arg0, %1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test2(%arg0: !llvm.ptr, %arg1: !llvm.ptr) attributes {passthrough = ["nounwind", "ssp"]} { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @".str2" : !llvm.ptr + %2 = llvm.call @fprintf(%arg0, %1, %arg1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @fprintf(!llvm.ptr, !llvm.ptr, ...) -> i32 attributes {passthrough = ["nounwind"]} +} diff --git a/test/LLVMDialect/InstCombine/out-of-bounds-indexes.ll.mlir b/test/LLVMDialect/InstCombine/out-of-bounds-indexes.ll.mlir new file mode 100644 index 000000000..5f7d3e3e3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/out-of-bounds-indexes.ll.mlir @@ -0,0 +1,28 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_out_of_bounds(%arg0: i32, %arg1: i1, %arg2: i1) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + "llvm.intr.assume"(%5) : (i1) -> () + llvm.return %3 : i32 + } + llvm.func @test_non64bit(%arg0: i128) -> i128 { + %0 = llvm.mlir.constant(3 : i128) : i128 + %1 = llvm.mlir.constant(-1 : i128) : i128 + %2 = llvm.mlir.constant(1 : i128) : i128 + %3 = llvm.and %arg0, %0 : i128 + %4 = llvm.lshr %3, %1 : i128 + %5 = llvm.icmp "eq" %4, %2 : i128 + "llvm.intr.assume"(%5) : (i1) -> () + llvm.return %3 : i128 + } + llvm.func @inselt_bad_index(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(4294967296 : i64) : i64 + %2 = llvm.insertelement %0, %arg0[%1 : i64] : vector<4xf64> + llvm.return %2 : vector<4xf64> + } +} diff --git a/test/LLVMDialect/InstCombine/out-of-tree-allocator-optimizes-away.ll.mlir b/test/LLVMDialect/InstCombine/out-of-tree-allocator-optimizes-away.ll.mlir new file mode 100644 index 000000000..fcc355606 --- /dev/null +++ b/test/LLVMDialect/InstCombine/out-of-tree-allocator-optimizes-away.ll.mlir @@ -0,0 +1,18 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @alloc_elides_test(%arg0: i32) { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(8 : i64) : i64 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.call @__rust_alloc(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.store %2, %5 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.call @__rust_realloc(%5, %0, %1, %3) : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr + llvm.store %4, %6 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.call @__rust_dealloc(%6, %0, %1) : (!llvm.ptr, i64, i64) -> () + llvm.return + } + llvm.func @__rust_alloc(i64, i64 {llvm.allocalign}) -> (!llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind", ["allockind", "41"], ["allocsize", "4294967295"], ["alloc-family", "__rust_alloc"]]} + llvm.func @__rust_realloc(!llvm.ptr {llvm.allocptr}, i64, i64 {llvm.allocalign}, i64) -> (!llvm.ptr {llvm.noalias}) attributes {passthrough = ["nounwind", ["allockind", "41"], ["allocsize", "17179869183"], ["alloc-family", "__rust_alloc"]]} + llvm.func @__rust_dealloc(!llvm.ptr {llvm.allocptr}, i64, i64) attributes {passthrough = ["nounwind", ["allockind", "4"], ["alloc-family", "__rust_alloc"]]} +} diff --git a/test/LLVMDialect/InstCombine/overflow-mul.ll.mlir b/test/LLVMDialect/InstCombine/overflow-mul.ll.mlir new file mode 100644 index 000000000..11967c1db --- /dev/null +++ b/test/LLVMDialect/InstCombine/overflow-mul.ll.mlir @@ -0,0 +1,176 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @pr21445_data() {addr_space = 0 : i32} : i32 + llvm.func @use.i64(i64) + llvm.func @pr4917_1(%arg0: i32, %arg1: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.zext %arg0 : i32 to i64 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.mul %1, %2 : i64 + %4 = llvm.icmp "ugt" %3, %0 : i64 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @pr4917_1a(%arg0: i32, %arg1: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(4294967296 : i64) : i64 + %1 = llvm.zext %arg0 : i32 to i64 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.mul %1, %2 : i64 + %4 = llvm.icmp "uge" %3, %0 : i64 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @pr4917_2(%arg0: i32, %arg1: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(111 : i32) : i32 + %2 = llvm.zext %arg0 : i32 to i64 + %3 = llvm.zext %arg1 : i32 to i64 + %4 = llvm.mul %2, %3 : i64 + %5 = llvm.icmp "ugt" %4, %0 : i64 + %6 = llvm.trunc %4 : i64 to i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @pr4917_3(%arg0: i32, %arg1: i32) -> i64 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(111 : i64) : i64 + %2 = llvm.zext %arg0 : i32 to i64 + %3 = llvm.zext %arg1 : i32 to i64 + %4 = llvm.mul %2, %3 : i64 + %5 = llvm.icmp "ugt" %4, %0 : i64 + %6 = llvm.select %5, %4, %1 : i1, i64 + llvm.return %6 : i64 + } + llvm.func @pr4917_4(%arg0: i32, %arg1: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.zext %arg0 : i32 to i64 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.mul %1, %2 : i64 + %4 = llvm.icmp "ule" %3, %0 : i64 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @pr4917_4a(%arg0: i32, %arg1: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(4294967296 : i64) : i64 + %1 = llvm.zext %arg0 : i32 to i64 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.mul %1, %2 : i64 + %4 = llvm.icmp "ult" %3, %0 : i64 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @pr4917_5(%arg0: i32, %arg1: i8) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(111 : i32) : i32 + %2 = llvm.zext %arg0 : i32 to i64 + %3 = llvm.zext %arg1 : i8 to i64 + %4 = llvm.mul %2, %3 : i64 + %5 = llvm.icmp "ugt" %4, %0 : i64 + %6 = llvm.trunc %4 : i64 to i32 + %7 = llvm.select %5, %6, %1 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @pr4918_1(%arg0: i32, %arg1: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.zext %arg0 : i32 to i64 + %1 = llvm.zext %arg1 : i32 to i64 + %2 = llvm.mul %0, %1 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.zext %3 : i32 to i64 + %5 = llvm.icmp "ne" %2, %4 : i64 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @pr4918_2(%arg0: i32, %arg1: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.zext %arg0 : i32 to i64 + %1 = llvm.zext %arg1 : i32 to i64 + %2 = llvm.mul %0, %1 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.zext %3 : i32 to i64 + %5 = llvm.icmp "eq" %2, %4 : i64 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @pr4918_3(%arg0: i32, %arg1: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.zext %arg0 : i32 to i64 + %1 = llvm.zext %arg1 : i32 to i64 + %2 = llvm.mul %0, %1 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.zext %3 : i32 to i64 + %5 = llvm.icmp "ne" %4, %2 : i64 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @pr20113(%arg0: vector<4xi16>, %arg1: vector<4xi16>) -> vector<4xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.zext %arg0 : vector<4xi16> to vector<4xi32> + %3 = llvm.zext %arg1 : vector<4xi16> to vector<4xi32> + %4 = llvm.mul %3, %2 : vector<4xi32> + %5 = llvm.icmp "sge" %4, %1 : vector<4xi32> + %6 = llvm.sext %5 : vector<4xi1> to vector<4xi32> + llvm.return %6 : vector<4xi32> + } + llvm.func @pr21445(%arg0: i8) -> i1 { + %0 = llvm.mlir.addressof @pr21445_data : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i8 + %2 = llvm.mlir.constant(255 : i32) : i32 + %3 = llvm.zext %arg0 : i8 to i32 + %4 = llvm.zext %1 : i8 to i32 + %5 = llvm.mul %3, %4 : i32 + %6 = llvm.and %5, %2 : i32 + %7 = llvm.icmp "ne" %5, %6 : i32 + llvm.return %7 : i1 + } + llvm.func @mul_may_overflow(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4294967295 : i34) : i34 + %1 = llvm.zext %arg0 : i32 to i34 + %2 = llvm.zext %arg1 : i32 to i34 + %3 = llvm.mul %1, %2 : i34 + %4 = llvm.icmp "ule" %3, %0 : i34 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @mul_known_nuw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4294967295 : i34) : i34 + %1 = llvm.zext %arg0 : i32 to i34 + %2 = llvm.zext %arg1 : i32 to i34 + %3 = llvm.mul %1, %2 overflow : i34 + %4 = llvm.icmp "ule" %3, %0 : i34 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @extra_and_use(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.zext %arg0 : i32 to i64 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.mul %1, %2 : i64 + %4 = llvm.icmp "ugt" %3, %0 : i64 + %5 = llvm.and %3, %0 : i64 + llvm.call @use.i64(%5) : (i64) -> () + %6 = llvm.zext %4 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @extra_and_use_small_mask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(268435455 : i64) : i64 + %2 = llvm.zext %arg0 : i32 to i64 + %3 = llvm.zext %arg1 : i32 to i64 + %4 = llvm.mul %2, %3 : i64 + %5 = llvm.icmp "ugt" %4, %0 : i64 + %6 = llvm.and %4, %1 : i64 + llvm.call @use.i64(%6) : (i64) -> () + %7 = llvm.zext %5 : i1 to i32 + llvm.return %7 : i32 + } + llvm.func @extra_and_use_mask_too_large(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(68719476735 : i64) : i64 + %2 = llvm.zext %arg0 : i32 to i64 + %3 = llvm.zext %arg1 : i32 to i64 + %4 = llvm.mul %2, %3 : i64 + %5 = llvm.icmp "ugt" %4, %0 : i64 + %6 = llvm.and %4, %1 : i64 + llvm.call @use.i64(%6) : (i64) -> () + %7 = llvm.zext %5 : i1 to i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/overflow.ll.mlir b/test/LLVMDialect/InstCombine/overflow.ll.mlir new file mode 100644 index 000000000..751aad77e --- /dev/null +++ b/test/LLVMDialect/InstCombine/overflow.ll.mlir @@ -0,0 +1,81 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @throwAnExceptionOrWhatever() + llvm.func @test1(%arg0: i32, %arg1: i32) -> i32 attributes {passthrough = ["nounwind", "ssp"]} { + %0 = llvm.mlir.constant(2147483648 : i64) : i64 + %1 = llvm.mlir.constant(4294967295 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.add %3, %2 overflow : i64 + %5 = llvm.add %4, %0 : i64 + %6 = llvm.icmp "ugt" %5, %1 : i64 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @throwAnExceptionOrWhatever() : () -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + %7 = llvm.trunc %4 : i64 to i32 + llvm.return %7 : i32 + } + llvm.func @test2(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 attributes {passthrough = ["nounwind", "ssp"]} { + %0 = llvm.mlir.constant(2147483648 : i64) : i64 + %1 = llvm.mlir.constant(4294967295 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.add %3, %2 overflow : i64 + %5 = llvm.add %4, %0 : i64 + llvm.store %5, %arg2 {alignment = 4 : i64} : i64, !llvm.ptr + %6 = llvm.icmp "ugt" %5, %1 : i64 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @throwAnExceptionOrWhatever() : () -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + %7 = llvm.trunc %4 : i64 to i32 + llvm.return %7 : i32 + } + llvm.func @test3(%arg0: i32, %arg1: i32) -> i64 attributes {passthrough = ["nounwind", "ssp"]} { + %0 = llvm.mlir.constant(2147483648 : i64) : i64 + %1 = llvm.mlir.constant(4294967295 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.add %3, %2 overflow : i64 + %5 = llvm.add %4, %0 : i64 + %6 = llvm.icmp "ugt" %5, %1 : i64 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @throwAnExceptionOrWhatever() : () -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i64 + } + llvm.func @test4(%arg0: i8 {llvm.signext}, %arg1: i8 {llvm.signext}) -> (i8 {llvm.zeroext}) attributes {passthrough = ["nounwind", "ssp"]} { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.sext %arg0 : i8 to i32 + %3 = llvm.sext %arg1 : i8 to i32 + %4 = llvm.add %3, %2 overflow : i32 + %5 = llvm.add %4, %0 overflow : i32 + %6 = llvm.icmp "ugt" %5, %1 : i32 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @throwAnExceptionOrWhatever() : () -> () + llvm.unreachable + ^bb2: // pred: ^bb0 + %7 = llvm.trunc %4 : i32 to i8 + llvm.return %7 : i8 + } + llvm.func @test8(%arg0: i64, %arg1: i64) -> i32 attributes {passthrough = ["nounwind", "ssp"]} { + %0 = llvm.mlir.constant(2147483648 : i64) : i64 + %1 = llvm.mlir.constant(4294967295 : i64) : i64 + %2 = llvm.add %arg0, %arg1 : i64 + %3 = llvm.add %2, %0 : i64 + %4 = llvm.icmp "ugt" %3, %1 : i64 + llvm.cond_br %4, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @throwAnExceptionOrWhatever() : () -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + %5 = llvm.trunc %2 : i64 to i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/overflow_to_sat.ll.mlir b/test/LLVMDialect/InstCombine/overflow_to_sat.ll.mlir new file mode 100644 index 000000000..5251f5c8a --- /dev/null +++ b/test/LLVMDialect/InstCombine/overflow_to_sat.ll.mlir @@ -0,0 +1,498 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @uadd(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = "llvm.intr.uadd.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i32, i1)> + %4 = llvm.select %2, %0, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @usub(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i32, i1)> + %4 = llvm.select %2, %0, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @sadd_x_lt_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "slt" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_x_lt_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "slt" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_x_le_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sle" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_x_le_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sle" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_x_gt_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sgt" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_x_gt_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sgt" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_x_ge_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sge" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_x_ge_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sge" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_y_lt_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "slt" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_y_lt_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "slt" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_y_le_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sle" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_y_le_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sle" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_y_gt_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sgt" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_y_gt_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sgt" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_y_ge_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sge" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_y_ge_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sge" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_x_lt_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "slt" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_x_lt_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "slt" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_x_le_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sle" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_x_le_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sle" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_x_lt2_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "slt" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_x_lt2_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "slt" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_x_gt_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sgt" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_x_gt_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sgt" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_x_ge_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sge" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_x_ge_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sge" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_x_gt2_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sgt" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_x_gt2_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sgt" %arg0, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_y_lt_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "slt" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_y_lt_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "slt" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_y_le_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sle" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_y_le_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sle" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_y_gt_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sgt" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_y_gt_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sgt" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_y_ge_min(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.mlir.constant(-128 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sge" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @ssub_y_ge_max(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.mlir.constant(127 : i8) : i8 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %6 = llvm.icmp "sge" %arg1, %0 : i8 + %7 = llvm.select %6, %1, %2 : i1, i8 + %8 = llvm.select %4, %7, %5 : i1, i8 + llvm.return %8 : i8 + } + llvm.func @sadd_i32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(2147483647 : i32) : i32 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i32, i1)> + %6 = llvm.icmp "slt" %arg0, %0 : i32 + %7 = llvm.select %6, %1, %2 : i1, i32 + %8 = llvm.select %4, %7, %5 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @ssub_i32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(2147483647 : i32) : i32 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i32, i1)> + %6 = llvm.icmp "slt" %arg0, %0 : i32 + %7 = llvm.select %6, %1, %2 : i1, i32 + %8 = llvm.select %4, %7, %5 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @sadd_bounds(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-128 : i32) : i32 + %2 = llvm.mlir.constant(127 : i32) : i32 + %3 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i32, i1)> + %6 = llvm.icmp "slt" %arg0, %0 : i32 + %7 = llvm.select %6, %1, %2 : i1, i32 + %8 = llvm.select %4, %7, %5 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @ssub_bounds(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-128 : i32) : i32 + %2 = llvm.mlir.constant(127 : i32) : i32 + %3 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %3[0] : !llvm.struct<(i32, i1)> + %6 = llvm.icmp "slt" %arg0, %0 : i32 + %7 = llvm.select %6, %1, %2 : i1, i32 + %8 = llvm.select %4, %7, %5 : i1, i32 + llvm.return %8 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-a.ll.mlir b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-a.ll.mlir new file mode 100644 index 000000000..c350dd163 --- /dev/null +++ b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-a.ll.mlir @@ -0,0 +1,220 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @t0_basic(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(-1 : i64) : i64 + %3 = llvm.mlir.constant(32 : i32) : i32 + %4 = llvm.add %arg1, %0 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.shl %1, %5 : i64 + %7 = llvm.add %6, %2 : i64 + %8 = llvm.sub %3, %arg1 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use64(%7) : (i64) -> () + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.and %7, %arg0 : i64 + %10 = llvm.trunc %9 : i64 to i32 + %11 = llvm.shl %10, %8 : i32 + llvm.return %11 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @use8xi64(vector<8xi64>) + llvm.func @t1_vec_splat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi32>) : vector<8xi32> + %1 = llvm.mlir.constant(dense<1> : vector<8xi64>) : vector<8xi64> + %2 = llvm.mlir.constant(dense<-1> : vector<8xi64>) : vector<8xi64> + %3 = llvm.mlir.constant(dense<32> : vector<8xi32>) : vector<8xi32> + %4 = llvm.add %arg1, %0 : vector<8xi32> + %5 = llvm.zext %4 : vector<8xi32> to vector<8xi64> + %6 = llvm.shl %1, %5 : vector<8xi64> + %7 = llvm.add %6, %2 : vector<8xi64> + %8 = llvm.sub %3, %arg1 : vector<8xi32> + llvm.call @use8xi32(%4) : (vector<8xi32>) -> () + llvm.call @use8xi64(%5) : (vector<8xi64>) -> () + llvm.call @use8xi64(%6) : (vector<8xi64>) -> () + llvm.call @use8xi64(%7) : (vector<8xi64>) -> () + llvm.call @use8xi32(%8) : (vector<8xi32>) -> () + %9 = llvm.and %7, %arg0 : vector<8xi64> + %10 = llvm.trunc %9 : vector<8xi64> to vector<8xi32> + %11 = llvm.shl %10, %8 : vector<8xi32> + llvm.return %11 : vector<8xi32> + } + llvm.func @t2_vec_splat_poison(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<8xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi32> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi32> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi32> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi32> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi32> + %19 = llvm.mlir.constant(1 : i64) : i64 + %20 = llvm.mlir.poison : i64 + %21 = llvm.mlir.undef : vector<8xi64> + %22 = llvm.mlir.constant(0 : i32) : i32 + %23 = llvm.insertelement %19, %21[%22 : i32] : vector<8xi64> + %24 = llvm.mlir.constant(1 : i32) : i32 + %25 = llvm.insertelement %19, %23[%24 : i32] : vector<8xi64> + %26 = llvm.mlir.constant(2 : i32) : i32 + %27 = llvm.insertelement %19, %25[%26 : i32] : vector<8xi64> + %28 = llvm.mlir.constant(3 : i32) : i32 + %29 = llvm.insertelement %19, %27[%28 : i32] : vector<8xi64> + %30 = llvm.mlir.constant(4 : i32) : i32 + %31 = llvm.insertelement %19, %29[%30 : i32] : vector<8xi64> + %32 = llvm.mlir.constant(5 : i32) : i32 + %33 = llvm.insertelement %19, %31[%32 : i32] : vector<8xi64> + %34 = llvm.mlir.constant(6 : i32) : i32 + %35 = llvm.insertelement %20, %33[%34 : i32] : vector<8xi64> + %36 = llvm.mlir.constant(7 : i32) : i32 + %37 = llvm.insertelement %19, %35[%36 : i32] : vector<8xi64> + %38 = llvm.mlir.constant(-1 : i64) : i64 + %39 = llvm.mlir.undef : vector<8xi64> + %40 = llvm.mlir.constant(0 : i32) : i32 + %41 = llvm.insertelement %38, %39[%40 : i32] : vector<8xi64> + %42 = llvm.mlir.constant(1 : i32) : i32 + %43 = llvm.insertelement %38, %41[%42 : i32] : vector<8xi64> + %44 = llvm.mlir.constant(2 : i32) : i32 + %45 = llvm.insertelement %38, %43[%44 : i32] : vector<8xi64> + %46 = llvm.mlir.constant(3 : i32) : i32 + %47 = llvm.insertelement %38, %45[%46 : i32] : vector<8xi64> + %48 = llvm.mlir.constant(4 : i32) : i32 + %49 = llvm.insertelement %38, %47[%48 : i32] : vector<8xi64> + %50 = llvm.mlir.constant(5 : i32) : i32 + %51 = llvm.insertelement %38, %49[%50 : i32] : vector<8xi64> + %52 = llvm.mlir.constant(6 : i32) : i32 + %53 = llvm.insertelement %20, %51[%52 : i32] : vector<8xi64> + %54 = llvm.mlir.constant(7 : i32) : i32 + %55 = llvm.insertelement %38, %53[%54 : i32] : vector<8xi64> + %56 = llvm.mlir.constant(32 : i32) : i32 + %57 = llvm.mlir.undef : vector<8xi32> + %58 = llvm.mlir.constant(0 : i32) : i32 + %59 = llvm.insertelement %56, %57[%58 : i32] : vector<8xi32> + %60 = llvm.mlir.constant(1 : i32) : i32 + %61 = llvm.insertelement %56, %59[%60 : i32] : vector<8xi32> + %62 = llvm.mlir.constant(2 : i32) : i32 + %63 = llvm.insertelement %56, %61[%62 : i32] : vector<8xi32> + %64 = llvm.mlir.constant(3 : i32) : i32 + %65 = llvm.insertelement %56, %63[%64 : i32] : vector<8xi32> + %66 = llvm.mlir.constant(4 : i32) : i32 + %67 = llvm.insertelement %56, %65[%66 : i32] : vector<8xi32> + %68 = llvm.mlir.constant(5 : i32) : i32 + %69 = llvm.insertelement %56, %67[%68 : i32] : vector<8xi32> + %70 = llvm.mlir.constant(6 : i32) : i32 + %71 = llvm.insertelement %1, %69[%70 : i32] : vector<8xi32> + %72 = llvm.mlir.constant(7 : i32) : i32 + %73 = llvm.insertelement %56, %71[%72 : i32] : vector<8xi32> + %74 = llvm.add %arg1, %18 : vector<8xi32> + %75 = llvm.zext %74 : vector<8xi32> to vector<8xi64> + %76 = llvm.shl %37, %75 : vector<8xi64> + %77 = llvm.add %76, %55 : vector<8xi64> + %78 = llvm.sub %73, %arg1 : vector<8xi32> + llvm.call @use8xi32(%74) : (vector<8xi32>) -> () + llvm.call @use8xi64(%75) : (vector<8xi64>) -> () + llvm.call @use8xi64(%76) : (vector<8xi64>) -> () + llvm.call @use8xi64(%77) : (vector<8xi64>) -> () + llvm.call @use8xi32(%78) : (vector<8xi32>) -> () + %79 = llvm.and %77, %arg0 : vector<8xi64> + %80 = llvm.trunc %79 : vector<8xi64> to vector<8xi32> + %81 = llvm.shl %80, %78 : vector<8xi32> + llvm.return %81 : vector<8xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<[-33, -32, -31, -1, 0, 1, 31, 32]> : vector<8xi32>) : vector<8xi32> + %1 = llvm.mlir.constant(dense<1> : vector<8xi64>) : vector<8xi64> + %2 = llvm.mlir.constant(dense<-1> : vector<8xi64>) : vector<8xi64> + %3 = llvm.mlir.constant(dense<32> : vector<8xi32>) : vector<8xi32> + %4 = llvm.add %arg1, %0 : vector<8xi32> + %5 = llvm.zext %4 : vector<8xi32> to vector<8xi64> + %6 = llvm.shl %1, %5 : vector<8xi64> + %7 = llvm.add %6, %2 : vector<8xi64> + %8 = llvm.sub %3, %arg1 : vector<8xi32> + llvm.call @use8xi32(%4) : (vector<8xi32>) -> () + llvm.call @use8xi64(%5) : (vector<8xi64>) -> () + llvm.call @use8xi64(%6) : (vector<8xi64>) -> () + llvm.call @use8xi64(%7) : (vector<8xi64>) -> () + llvm.call @use8xi32(%8) : (vector<8xi32>) -> () + %9 = llvm.and %7, %arg0 : vector<8xi64> + %10 = llvm.trunc %9 : vector<8xi64> to vector<8xi32> + %11 = llvm.shl %10, %8 : vector<8xi32> + llvm.return %11 : vector<8xi32> + } + llvm.func @n4_extrause0(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(-1 : i64) : i64 + %3 = llvm.mlir.constant(32 : i32) : i32 + %4 = llvm.add %arg1, %0 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.shl %1, %5 : i64 + %7 = llvm.add %6, %2 : i64 + %8 = llvm.sub %3, %arg1 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use64(%7) : (i64) -> () + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.and %7, %arg0 : i64 + llvm.call @use64(%9) : (i64) -> () + %10 = llvm.trunc %9 : i64 to i32 + %11 = llvm.shl %10, %8 : i32 + llvm.return %11 : i32 + } + llvm.func @n5_extrause1(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(-1 : i64) : i64 + %3 = llvm.mlir.constant(32 : i32) : i32 + %4 = llvm.add %arg1, %0 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.shl %1, %5 : i64 + %7 = llvm.add %6, %2 : i64 + %8 = llvm.sub %3, %arg1 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use64(%7) : (i64) -> () + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.and %7, %arg0 : i64 + %10 = llvm.trunc %9 : i64 to i32 + llvm.call @use32(%10) : (i32) -> () + %11 = llvm.shl %10, %8 : i32 + llvm.return %11 : i32 + } + llvm.func @n6_extrause2(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(-1 : i64) : i64 + %3 = llvm.mlir.constant(32 : i32) : i32 + %4 = llvm.add %arg1, %0 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.shl %1, %5 : i64 + %7 = llvm.add %6, %2 : i64 + %8 = llvm.sub %3, %arg1 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use64(%7) : (i64) -> () + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.and %7, %arg0 : i64 + llvm.call @use64(%9) : (i64) -> () + %10 = llvm.trunc %9 : i64 to i32 + llvm.call @use32(%10) : (i32) -> () + %11 = llvm.shl %10, %8 : i32 + llvm.return %11 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-b.ll.mlir b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-b.ll.mlir new file mode 100644 index 000000000..e8c750823 --- /dev/null +++ b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-b.ll.mlir @@ -0,0 +1,216 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @t0_basic(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.add %arg1, %0 : i32 + %4 = llvm.zext %3 : i32 to i64 + %5 = llvm.shl %1, %4 : i64 + %6 = llvm.xor %5, %1 : i64 + %7 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.and %6, %arg0 : i64 + %9 = llvm.trunc %8 : i64 to i32 + %10 = llvm.shl %9, %7 : i32 + llvm.return %10 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @use8xi64(vector<8xi64>) + llvm.func @t1_vec_splat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi32>) : vector<8xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<8xi64>) : vector<8xi64> + %2 = llvm.mlir.constant(dense<32> : vector<8xi32>) : vector<8xi32> + %3 = llvm.add %arg1, %0 : vector<8xi32> + %4 = llvm.zext %3 : vector<8xi32> to vector<8xi64> + %5 = llvm.shl %1, %4 : vector<8xi64> + %6 = llvm.xor %5, %1 : vector<8xi64> + %7 = llvm.sub %2, %arg1 : vector<8xi32> + llvm.call @use8xi32(%3) : (vector<8xi32>) -> () + llvm.call @use8xi64(%4) : (vector<8xi64>) -> () + llvm.call @use8xi64(%5) : (vector<8xi64>) -> () + llvm.call @use8xi64(%6) : (vector<8xi64>) -> () + llvm.call @use8xi32(%7) : (vector<8xi32>) -> () + %8 = llvm.and %6, %arg0 : vector<8xi64> + %9 = llvm.trunc %8 : vector<8xi64> to vector<8xi32> + %10 = llvm.shl %9, %7 : vector<8xi32> + llvm.return %10 : vector<8xi32> + } + llvm.func @t2_vec_splat_poison(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<8xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi32> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi32> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi32> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi32> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi32> + %19 = llvm.mlir.constant(-1 : i64) : i64 + %20 = llvm.mlir.poison : i64 + %21 = llvm.mlir.undef : vector<8xi64> + %22 = llvm.mlir.constant(0 : i32) : i32 + %23 = llvm.insertelement %19, %21[%22 : i32] : vector<8xi64> + %24 = llvm.mlir.constant(1 : i32) : i32 + %25 = llvm.insertelement %19, %23[%24 : i32] : vector<8xi64> + %26 = llvm.mlir.constant(2 : i32) : i32 + %27 = llvm.insertelement %19, %25[%26 : i32] : vector<8xi64> + %28 = llvm.mlir.constant(3 : i32) : i32 + %29 = llvm.insertelement %19, %27[%28 : i32] : vector<8xi64> + %30 = llvm.mlir.constant(4 : i32) : i32 + %31 = llvm.insertelement %19, %29[%30 : i32] : vector<8xi64> + %32 = llvm.mlir.constant(5 : i32) : i32 + %33 = llvm.insertelement %19, %31[%32 : i32] : vector<8xi64> + %34 = llvm.mlir.constant(6 : i32) : i32 + %35 = llvm.insertelement %20, %33[%34 : i32] : vector<8xi64> + %36 = llvm.mlir.constant(7 : i32) : i32 + %37 = llvm.insertelement %19, %35[%36 : i32] : vector<8xi64> + %38 = llvm.mlir.constant(32 : i32) : i32 + %39 = llvm.mlir.undef : vector<8xi32> + %40 = llvm.mlir.constant(0 : i32) : i32 + %41 = llvm.insertelement %38, %39[%40 : i32] : vector<8xi32> + %42 = llvm.mlir.constant(1 : i32) : i32 + %43 = llvm.insertelement %38, %41[%42 : i32] : vector<8xi32> + %44 = llvm.mlir.constant(2 : i32) : i32 + %45 = llvm.insertelement %38, %43[%44 : i32] : vector<8xi32> + %46 = llvm.mlir.constant(3 : i32) : i32 + %47 = llvm.insertelement %38, %45[%46 : i32] : vector<8xi32> + %48 = llvm.mlir.constant(4 : i32) : i32 + %49 = llvm.insertelement %38, %47[%48 : i32] : vector<8xi32> + %50 = llvm.mlir.constant(5 : i32) : i32 + %51 = llvm.insertelement %38, %49[%50 : i32] : vector<8xi32> + %52 = llvm.mlir.constant(6 : i32) : i32 + %53 = llvm.insertelement %1, %51[%52 : i32] : vector<8xi32> + %54 = llvm.mlir.constant(7 : i32) : i32 + %55 = llvm.insertelement %38, %53[%54 : i32] : vector<8xi32> + %56 = llvm.add %arg1, %18 : vector<8xi32> + %57 = llvm.zext %56 : vector<8xi32> to vector<8xi64> + %58 = llvm.shl %37, %57 : vector<8xi64> + %59 = llvm.xor %58, %37 : vector<8xi64> + %60 = llvm.sub %55, %arg1 : vector<8xi32> + llvm.call @use8xi32(%56) : (vector<8xi32>) -> () + llvm.call @use8xi64(%57) : (vector<8xi64>) -> () + llvm.call @use8xi64(%58) : (vector<8xi64>) -> () + llvm.call @use8xi64(%59) : (vector<8xi64>) -> () + llvm.call @use8xi32(%60) : (vector<8xi32>) -> () + %61 = llvm.and %59, %arg0 : vector<8xi64> + %62 = llvm.trunc %61 : vector<8xi64> to vector<8xi32> + %63 = llvm.shl %62, %60 : vector<8xi32> + llvm.return %63 : vector<8xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<[-33, -32, -31, -1, 0, 1, 31, 32]> : vector<8xi32>) : vector<8xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<8xi64>) : vector<8xi64> + %2 = llvm.mlir.constant(dense<32> : vector<8xi32>) : vector<8xi32> + %3 = llvm.add %arg1, %0 : vector<8xi32> + %4 = llvm.zext %3 : vector<8xi32> to vector<8xi64> + %5 = llvm.shl %1, %4 : vector<8xi64> + %6 = llvm.xor %5, %1 : vector<8xi64> + %7 = llvm.sub %2, %arg1 : vector<8xi32> + llvm.call @use8xi32(%3) : (vector<8xi32>) -> () + llvm.call @use8xi64(%4) : (vector<8xi64>) -> () + llvm.call @use8xi64(%5) : (vector<8xi64>) -> () + llvm.call @use8xi64(%6) : (vector<8xi64>) -> () + llvm.call @use8xi32(%7) : (vector<8xi32>) -> () + %8 = llvm.and %6, %arg0 : vector<8xi64> + %9 = llvm.trunc %8 : vector<8xi64> to vector<8xi32> + %10 = llvm.shl %9, %7 : vector<8xi32> + llvm.return %10 : vector<8xi32> + } + llvm.func @t4_allones_trunc(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.mlir.constant(4294967295 : i64) : i64 + %3 = llvm.mlir.constant(32 : i32) : i32 + %4 = llvm.add %arg1, %0 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.shl %1, %5 : i64 + %7 = llvm.xor %6, %2 : i64 + %8 = llvm.sub %3, %arg1 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use64(%7) : (i64) -> () + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.and %7, %arg0 : i64 + %10 = llvm.trunc %9 : i64 to i32 + %11 = llvm.shl %10, %8 : i32 + llvm.return %11 : i32 + } + llvm.func @n5_extrause0(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.add %arg1, %0 : i32 + %4 = llvm.zext %3 : i32 to i64 + %5 = llvm.shl %1, %4 : i64 + %6 = llvm.xor %5, %1 : i64 + %7 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.and %6, %arg0 : i64 + llvm.call @use64(%8) : (i64) -> () + %9 = llvm.trunc %8 : i64 to i32 + %10 = llvm.shl %9, %7 : i32 + llvm.return %10 : i32 + } + llvm.func @n6_extrause1(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.add %arg1, %0 : i32 + %4 = llvm.zext %3 : i32 to i64 + %5 = llvm.shl %1, %4 : i64 + %6 = llvm.xor %5, %1 : i64 + %7 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.and %6, %arg0 : i64 + %9 = llvm.trunc %8 : i64 to i32 + llvm.call @use32(%9) : (i32) -> () + %10 = llvm.shl %9, %7 : i32 + llvm.return %10 : i32 + } + llvm.func @n7_extrause2(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.add %arg1, %0 : i32 + %4 = llvm.zext %3 : i32 to i64 + %5 = llvm.shl %1, %4 : i64 + %6 = llvm.xor %5, %1 : i64 + %7 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use64(%6) : (i64) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.and %6, %arg0 : i64 + llvm.call @use64(%8) : (i64) -> () + %9 = llvm.trunc %8 : i64 to i32 + llvm.call @use32(%9) : (i32) -> () + %10 = llvm.shl %9, %7 : i32 + llvm.return %10 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-c.ll.mlir b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-c.ll.mlir new file mode 100644 index 000000000..92de235ee --- /dev/null +++ b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-c.ll.mlir @@ -0,0 +1,186 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @t0_basic(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(-33 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.lshr %0, %2 : i64 + %4 = llvm.add %arg1, %1 : i32 + llvm.call @use64(%2) : (i64) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.and %3, %arg0 : i64 + %6 = llvm.trunc %5 : i64 to i32 + %7 = llvm.shl %6, %4 : i32 + llvm.return %7 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @use8xi64(vector<8xi64>) + llvm.func @t1_vec_splat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi64>) : vector<8xi64> + %1 = llvm.mlir.constant(dense<-33> : vector<8xi32>) : vector<8xi32> + %2 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %3 = llvm.lshr %0, %2 : vector<8xi64> + %4 = llvm.add %arg1, %1 : vector<8xi32> + llvm.call @use8xi64(%2) : (vector<8xi64>) -> () + llvm.call @use8xi64(%3) : (vector<8xi64>) -> () + llvm.call @use8xi32(%4) : (vector<8xi32>) -> () + %5 = llvm.and %3, %arg0 : vector<8xi64> + %6 = llvm.trunc %5 : vector<8xi64> to vector<8xi32> + %7 = llvm.shl %6, %4 : vector<8xi32> + llvm.return %7 : vector<8xi32> + } + llvm.func @t2_vec_splat_poison(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<8xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi64> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi64> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi64> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi64> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi64> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi64> + %19 = llvm.mlir.constant(-33 : i32) : i32 + %20 = llvm.mlir.poison : i32 + %21 = llvm.mlir.undef : vector<8xi32> + %22 = llvm.mlir.constant(0 : i32) : i32 + %23 = llvm.insertelement %19, %21[%22 : i32] : vector<8xi32> + %24 = llvm.mlir.constant(1 : i32) : i32 + %25 = llvm.insertelement %19, %23[%24 : i32] : vector<8xi32> + %26 = llvm.mlir.constant(2 : i32) : i32 + %27 = llvm.insertelement %19, %25[%26 : i32] : vector<8xi32> + %28 = llvm.mlir.constant(3 : i32) : i32 + %29 = llvm.insertelement %19, %27[%28 : i32] : vector<8xi32> + %30 = llvm.mlir.constant(4 : i32) : i32 + %31 = llvm.insertelement %19, %29[%30 : i32] : vector<8xi32> + %32 = llvm.mlir.constant(5 : i32) : i32 + %33 = llvm.insertelement %19, %31[%32 : i32] : vector<8xi32> + %34 = llvm.mlir.constant(6 : i32) : i32 + %35 = llvm.insertelement %20, %33[%34 : i32] : vector<8xi32> + %36 = llvm.mlir.constant(7 : i32) : i32 + %37 = llvm.insertelement %19, %35[%36 : i32] : vector<8xi32> + %38 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %39 = llvm.lshr %18, %38 : vector<8xi64> + %40 = llvm.add %arg1, %37 : vector<8xi32> + llvm.call @use8xi64(%38) : (vector<8xi64>) -> () + llvm.call @use8xi64(%39) : (vector<8xi64>) -> () + llvm.call @use8xi32(%40) : (vector<8xi32>) -> () + %41 = llvm.and %39, %arg0 : vector<8xi64> + %42 = llvm.trunc %41 : vector<8xi64> to vector<8xi32> + %43 = llvm.shl %42, %40 : vector<8xi32> + llvm.return %43 : vector<8xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<8xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi64> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi64> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi64> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi64> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi64> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi64> + %19 = llvm.mlir.constant(65 : i32) : i32 + %20 = llvm.mlir.poison : i32 + %21 = llvm.mlir.constant(64 : i32) : i32 + %22 = llvm.mlir.constant(63 : i32) : i32 + %23 = llvm.mlir.constant(-32 : i32) : i32 + %24 = llvm.mlir.constant(-33 : i32) : i32 + %25 = llvm.mlir.constant(-63 : i32) : i32 + %26 = llvm.mlir.constant(-64 : i32) : i32 + %27 = llvm.mlir.undef : vector<8xi32> + %28 = llvm.mlir.constant(0 : i32) : i32 + %29 = llvm.insertelement %26, %27[%28 : i32] : vector<8xi32> + %30 = llvm.mlir.constant(1 : i32) : i32 + %31 = llvm.insertelement %25, %29[%30 : i32] : vector<8xi32> + %32 = llvm.mlir.constant(2 : i32) : i32 + %33 = llvm.insertelement %24, %31[%32 : i32] : vector<8xi32> + %34 = llvm.mlir.constant(3 : i32) : i32 + %35 = llvm.insertelement %23, %33[%34 : i32] : vector<8xi32> + %36 = llvm.mlir.constant(4 : i32) : i32 + %37 = llvm.insertelement %22, %35[%36 : i32] : vector<8xi32> + %38 = llvm.mlir.constant(5 : i32) : i32 + %39 = llvm.insertelement %21, %37[%38 : i32] : vector<8xi32> + %40 = llvm.mlir.constant(6 : i32) : i32 + %41 = llvm.insertelement %20, %39[%40 : i32] : vector<8xi32> + %42 = llvm.mlir.constant(7 : i32) : i32 + %43 = llvm.insertelement %19, %41[%42 : i32] : vector<8xi32> + %44 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %45 = llvm.lshr %18, %44 : vector<8xi64> + %46 = llvm.add %arg1, %43 : vector<8xi32> + llvm.call @use8xi64(%44) : (vector<8xi64>) -> () + llvm.call @use8xi64(%45) : (vector<8xi64>) -> () + llvm.call @use8xi32(%46) : (vector<8xi32>) -> () + %47 = llvm.and %45, %arg0 : vector<8xi64> + %48 = llvm.trunc %47 : vector<8xi64> to vector<8xi32> + %49 = llvm.shl %48, %46 : vector<8xi32> + llvm.return %49 : vector<8xi32> + } + llvm.func @n4_extrause0(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(-33 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.lshr %0, %2 : i64 + %4 = llvm.add %arg1, %1 : i32 + llvm.call @use64(%2) : (i64) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.and %3, %arg0 : i64 + llvm.call @use64(%5) : (i64) -> () + %6 = llvm.trunc %5 : i64 to i32 + %7 = llvm.shl %6, %4 : i32 + llvm.return %7 : i32 + } + llvm.func @n5_extrause1(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(-33 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.lshr %0, %2 : i64 + %4 = llvm.add %arg1, %1 : i32 + llvm.call @use64(%2) : (i64) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.and %3, %arg0 : i64 + %6 = llvm.trunc %5 : i64 to i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %6, %4 : i32 + llvm.return %7 : i32 + } + llvm.func @n6_extrause2(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(-33 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.lshr %0, %2 : i64 + %4 = llvm.add %arg1, %1 : i32 + llvm.call @use64(%2) : (i64) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.and %3, %arg0 : i64 + llvm.call @use64(%5) : (i64) -> () + %6 = llvm.trunc %5 : i64 to i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %6, %4 : i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-d.ll.mlir b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-d.ll.mlir new file mode 100644 index 000000000..18ba88926 --- /dev/null +++ b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-d.ll.mlir @@ -0,0 +1,212 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @t0_basic(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(-33 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.shl %0, %2 : i64 + %4 = llvm.lshr %3, %2 : i64 + %5 = llvm.add %arg1, %1 : i32 + llvm.call @use64(%2) : (i64) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.and %4, %arg0 : i64 + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.shl %7, %5 : i32 + llvm.return %8 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @use8xi64(vector<8xi64>) + llvm.func @t1_vec_splat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi64>) : vector<8xi64> + %1 = llvm.mlir.constant(dense<-33> : vector<8xi32>) : vector<8xi32> + %2 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %3 = llvm.shl %0, %2 : vector<8xi64> + %4 = llvm.lshr %3, %2 : vector<8xi64> + %5 = llvm.add %arg1, %1 : vector<8xi32> + llvm.call @use8xi64(%2) : (vector<8xi64>) -> () + llvm.call @use8xi64(%3) : (vector<8xi64>) -> () + llvm.call @use8xi64(%4) : (vector<8xi64>) -> () + llvm.call @use8xi32(%5) : (vector<8xi32>) -> () + %6 = llvm.and %4, %arg0 : vector<8xi64> + %7 = llvm.trunc %6 : vector<8xi64> to vector<8xi32> + %8 = llvm.shl %7, %5 : vector<8xi32> + llvm.return %8 : vector<8xi32> + } + llvm.func @t2_vec_splat_poison(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<8xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi64> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi64> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi64> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi64> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi64> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi64> + %19 = llvm.mlir.constant(-33 : i32) : i32 + %20 = llvm.mlir.poison : i32 + %21 = llvm.mlir.undef : vector<8xi32> + %22 = llvm.mlir.constant(0 : i32) : i32 + %23 = llvm.insertelement %19, %21[%22 : i32] : vector<8xi32> + %24 = llvm.mlir.constant(1 : i32) : i32 + %25 = llvm.insertelement %19, %23[%24 : i32] : vector<8xi32> + %26 = llvm.mlir.constant(2 : i32) : i32 + %27 = llvm.insertelement %19, %25[%26 : i32] : vector<8xi32> + %28 = llvm.mlir.constant(3 : i32) : i32 + %29 = llvm.insertelement %19, %27[%28 : i32] : vector<8xi32> + %30 = llvm.mlir.constant(4 : i32) : i32 + %31 = llvm.insertelement %19, %29[%30 : i32] : vector<8xi32> + %32 = llvm.mlir.constant(5 : i32) : i32 + %33 = llvm.insertelement %19, %31[%32 : i32] : vector<8xi32> + %34 = llvm.mlir.constant(6 : i32) : i32 + %35 = llvm.insertelement %20, %33[%34 : i32] : vector<8xi32> + %36 = llvm.mlir.constant(7 : i32) : i32 + %37 = llvm.insertelement %19, %35[%36 : i32] : vector<8xi32> + %38 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %39 = llvm.shl %18, %38 : vector<8xi64> + %40 = llvm.lshr %39, %38 : vector<8xi64> + %41 = llvm.add %arg1, %37 : vector<8xi32> + llvm.call @use8xi64(%38) : (vector<8xi64>) -> () + llvm.call @use8xi64(%39) : (vector<8xi64>) -> () + llvm.call @use8xi64(%40) : (vector<8xi64>) -> () + llvm.call @use8xi32(%41) : (vector<8xi32>) -> () + %42 = llvm.and %40, %arg0 : vector<8xi64> + %43 = llvm.trunc %42 : vector<8xi64> to vector<8xi32> + %44 = llvm.shl %43, %41 : vector<8xi32> + llvm.return %44 : vector<8xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<8xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi64> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi64> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi64> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi64> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi64> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi64> + %19 = llvm.mlir.constant(65 : i32) : i32 + %20 = llvm.mlir.poison : i32 + %21 = llvm.mlir.constant(64 : i32) : i32 + %22 = llvm.mlir.constant(63 : i32) : i32 + %23 = llvm.mlir.constant(-32 : i32) : i32 + %24 = llvm.mlir.constant(-33 : i32) : i32 + %25 = llvm.mlir.constant(-63 : i32) : i32 + %26 = llvm.mlir.constant(-64 : i32) : i32 + %27 = llvm.mlir.undef : vector<8xi32> + %28 = llvm.mlir.constant(0 : i32) : i32 + %29 = llvm.insertelement %26, %27[%28 : i32] : vector<8xi32> + %30 = llvm.mlir.constant(1 : i32) : i32 + %31 = llvm.insertelement %25, %29[%30 : i32] : vector<8xi32> + %32 = llvm.mlir.constant(2 : i32) : i32 + %33 = llvm.insertelement %24, %31[%32 : i32] : vector<8xi32> + %34 = llvm.mlir.constant(3 : i32) : i32 + %35 = llvm.insertelement %23, %33[%34 : i32] : vector<8xi32> + %36 = llvm.mlir.constant(4 : i32) : i32 + %37 = llvm.insertelement %22, %35[%36 : i32] : vector<8xi32> + %38 = llvm.mlir.constant(5 : i32) : i32 + %39 = llvm.insertelement %21, %37[%38 : i32] : vector<8xi32> + %40 = llvm.mlir.constant(6 : i32) : i32 + %41 = llvm.insertelement %20, %39[%40 : i32] : vector<8xi32> + %42 = llvm.mlir.constant(7 : i32) : i32 + %43 = llvm.insertelement %19, %41[%42 : i32] : vector<8xi32> + %44 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %45 = llvm.shl %18, %44 : vector<8xi64> + %46 = llvm.lshr %45, %44 : vector<8xi64> + %47 = llvm.add %arg1, %43 : vector<8xi32> + llvm.call @use8xi64(%44) : (vector<8xi64>) -> () + llvm.call @use8xi64(%45) : (vector<8xi64>) -> () + llvm.call @use8xi64(%46) : (vector<8xi64>) -> () + llvm.call @use8xi32(%47) : (vector<8xi32>) -> () + %48 = llvm.and %46, %arg0 : vector<8xi64> + %49 = llvm.trunc %48 : vector<8xi64> to vector<8xi32> + %50 = llvm.shl %49, %47 : vector<8xi32> + llvm.return %50 : vector<8xi32> + } + llvm.func @n4_extrause0(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(-33 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.shl %0, %2 : i64 + %4 = llvm.lshr %3, %2 : i64 + %5 = llvm.add %arg1, %1 : i32 + llvm.call @use64(%2) : (i64) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.and %4, %arg0 : i64 + llvm.call @use64(%6) : (i64) -> () + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.shl %7, %5 : i32 + llvm.return %8 : i32 + } + llvm.func @n5_extrause1(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(-33 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.shl %0, %2 : i64 + %4 = llvm.lshr %3, %2 : i64 + %5 = llvm.add %arg1, %1 : i32 + llvm.call @use64(%2) : (i64) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.and %4, %arg0 : i64 + %7 = llvm.trunc %6 : i64 to i32 + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.shl %7, %5 : i32 + llvm.return %8 : i32 + } + llvm.func @n6_extrause2(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(-33 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.shl %0, %2 : i64 + %4 = llvm.lshr %3, %2 : i64 + %5 = llvm.add %arg1, %1 : i32 + llvm.call @use64(%2) : (i64) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.and %4, %arg0 : i64 + llvm.call @use64(%6) : (i64) -> () + %7 = llvm.trunc %6 : i64 to i32 + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.shl %7, %5 : i32 + llvm.return %8 : i32 + } + llvm.func @PR51351(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(-33 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.shl %0, %2 : i64 + %4 = llvm.ashr %3, %2 : i64 + %5 = llvm.add %arg1, %1 : i32 + %6 = llvm.and %4, %arg0 : i64 + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.shl %7, %5 : i32 + llvm.return %8 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-e.ll.mlir b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-e.ll.mlir new file mode 100644 index 000000000..c72198c03 --- /dev/null +++ b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-e.ll.mlir @@ -0,0 +1,143 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @t0_basic(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.zext %arg1 : i32 to i64 + %2 = llvm.shl %arg0, %1 : i64 + %3 = llvm.add %arg1, %0 : i32 + llvm.call @use64(%1) : (i64) -> () + llvm.call @use64(%2) : (i64) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.lshr %2, %1 : i64 + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.shl %5, %3 : i32 + llvm.return %6 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @use8xi64(vector<8xi64>) + llvm.func @t1_vec_splat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-33> : vector<8xi32>) : vector<8xi32> + %1 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %2 = llvm.shl %arg0, %1 : vector<8xi64> + %3 = llvm.add %arg1, %0 : vector<8xi32> + llvm.call @use8xi64(%1) : (vector<8xi64>) -> () + llvm.call @use8xi64(%2) : (vector<8xi64>) -> () + llvm.call @use8xi32(%3) : (vector<8xi32>) -> () + %4 = llvm.lshr %2, %1 : vector<8xi64> + %5 = llvm.trunc %4 : vector<8xi64> to vector<8xi32> + %6 = llvm.shl %5, %3 : vector<8xi32> + llvm.return %6 : vector<8xi32> + } + llvm.func @t2_vec_splat_undef(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<8xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi32> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi32> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi32> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi32> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi32> + %19 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %20 = llvm.shl %arg0, %19 : vector<8xi64> + %21 = llvm.add %arg1, %18 : vector<8xi32> + llvm.call @use8xi64(%19) : (vector<8xi64>) -> () + llvm.call @use8xi64(%20) : (vector<8xi64>) -> () + llvm.call @use8xi32(%21) : (vector<8xi32>) -> () + %22 = llvm.lshr %20, %19 : vector<8xi64> + %23 = llvm.trunc %22 : vector<8xi64> to vector<8xi32> + %24 = llvm.shl %23, %21 : vector<8xi32> + llvm.return %24 : vector<8xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(65 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(64 : i32) : i32 + %3 = llvm.mlir.constant(63 : i32) : i32 + %4 = llvm.mlir.constant(-32 : i32) : i32 + %5 = llvm.mlir.constant(-33 : i32) : i32 + %6 = llvm.mlir.constant(-63 : i32) : i32 + %7 = llvm.mlir.constant(-64 : i32) : i32 + %8 = llvm.mlir.undef : vector<8xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<8xi32> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %6, %10[%11 : i32] : vector<8xi32> + %13 = llvm.mlir.constant(2 : i32) : i32 + %14 = llvm.insertelement %5, %12[%13 : i32] : vector<8xi32> + %15 = llvm.mlir.constant(3 : i32) : i32 + %16 = llvm.insertelement %4, %14[%15 : i32] : vector<8xi32> + %17 = llvm.mlir.constant(4 : i32) : i32 + %18 = llvm.insertelement %3, %16[%17 : i32] : vector<8xi32> + %19 = llvm.mlir.constant(5 : i32) : i32 + %20 = llvm.insertelement %2, %18[%19 : i32] : vector<8xi32> + %21 = llvm.mlir.constant(6 : i32) : i32 + %22 = llvm.insertelement %1, %20[%21 : i32] : vector<8xi32> + %23 = llvm.mlir.constant(7 : i32) : i32 + %24 = llvm.insertelement %0, %22[%23 : i32] : vector<8xi32> + %25 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %26 = llvm.shl %arg0, %25 : vector<8xi64> + %27 = llvm.add %arg1, %24 : vector<8xi32> + llvm.call @use8xi64(%25) : (vector<8xi64>) -> () + llvm.call @use8xi64(%26) : (vector<8xi64>) -> () + llvm.call @use8xi32(%27) : (vector<8xi32>) -> () + %28 = llvm.lshr %26, %25 : vector<8xi64> + %29 = llvm.trunc %28 : vector<8xi64> to vector<8xi32> + %30 = llvm.shl %29, %27 : vector<8xi32> + llvm.return %30 : vector<8xi32> + } + llvm.func @n4_extrause0(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.zext %arg1 : i32 to i64 + %2 = llvm.shl %arg0, %1 : i64 + %3 = llvm.add %arg1, %0 : i32 + llvm.call @use64(%1) : (i64) -> () + llvm.call @use64(%2) : (i64) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.lshr %2, %1 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.shl %5, %3 : i32 + llvm.return %6 : i32 + } + llvm.func @n5_extrause1(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.zext %arg1 : i32 to i64 + %2 = llvm.shl %arg0, %1 : i64 + %3 = llvm.add %arg1, %0 : i32 + llvm.call @use64(%1) : (i64) -> () + llvm.call @use64(%2) : (i64) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.lshr %2, %1 : i64 + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.shl %5, %3 : i32 + llvm.return %6 : i32 + } + llvm.func @n6_extrause2(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.zext %arg1 : i32 to i64 + %2 = llvm.shl %arg0, %1 : i64 + %3 = llvm.add %arg1, %0 : i32 + llvm.call @use64(%1) : (i64) -> () + llvm.call @use64(%2) : (i64) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.lshr %2, %1 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.shl %5, %3 : i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-a.ll.mlir b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-a.ll.mlir new file mode 100644 index 000000000..8c320ad34 --- /dev/null +++ b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-a.ll.mlir @@ -0,0 +1,138 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @t0_basic(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.add %arg1, %0 : i32 + %4 = llvm.shl %1, %3 : i32 + %5 = llvm.add %4, %0 : i32 + %6 = llvm.and %5, %arg0 : i32 + %7 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.shl %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @t1_vec_splat(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi32>) : vector<8xi32> + %1 = llvm.mlir.constant(dense<1> : vector<8xi32>) : vector<8xi32> + %2 = llvm.mlir.constant(dense<32> : vector<8xi32>) : vector<8xi32> + %3 = llvm.add %arg1, %0 : vector<8xi32> + %4 = llvm.shl %1, %3 : vector<8xi32> + %5 = llvm.add %4, %0 : vector<8xi32> + %6 = llvm.and %5, %arg0 : vector<8xi32> + %7 = llvm.sub %2, %arg1 : vector<8xi32> + llvm.call @use8xi32(%3) : (vector<8xi32>) -> () + llvm.call @use8xi32(%4) : (vector<8xi32>) -> () + llvm.call @use8xi32(%5) : (vector<8xi32>) -> () + llvm.call @use8xi32(%7) : (vector<8xi32>) -> () + %8 = llvm.shl %6, %7 : vector<8xi32> + llvm.return %8 : vector<8xi32> + } + llvm.func @t1_vec_splat_poison(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<8xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi32> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi32> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi32> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi32> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi32> + %19 = llvm.mlir.constant(1 : i32) : i32 + %20 = llvm.mlir.undef : vector<8xi32> + %21 = llvm.mlir.constant(0 : i32) : i32 + %22 = llvm.insertelement %19, %20[%21 : i32] : vector<8xi32> + %23 = llvm.mlir.constant(1 : i32) : i32 + %24 = llvm.insertelement %19, %22[%23 : i32] : vector<8xi32> + %25 = llvm.mlir.constant(2 : i32) : i32 + %26 = llvm.insertelement %19, %24[%25 : i32] : vector<8xi32> + %27 = llvm.mlir.constant(3 : i32) : i32 + %28 = llvm.insertelement %19, %26[%27 : i32] : vector<8xi32> + %29 = llvm.mlir.constant(4 : i32) : i32 + %30 = llvm.insertelement %19, %28[%29 : i32] : vector<8xi32> + %31 = llvm.mlir.constant(5 : i32) : i32 + %32 = llvm.insertelement %19, %30[%31 : i32] : vector<8xi32> + %33 = llvm.mlir.constant(6 : i32) : i32 + %34 = llvm.insertelement %1, %32[%33 : i32] : vector<8xi32> + %35 = llvm.mlir.constant(7 : i32) : i32 + %36 = llvm.insertelement %19, %34[%35 : i32] : vector<8xi32> + %37 = llvm.mlir.constant(32 : i32) : i32 + %38 = llvm.mlir.undef : vector<8xi32> + %39 = llvm.mlir.constant(0 : i32) : i32 + %40 = llvm.insertelement %37, %38[%39 : i32] : vector<8xi32> + %41 = llvm.mlir.constant(1 : i32) : i32 + %42 = llvm.insertelement %37, %40[%41 : i32] : vector<8xi32> + %43 = llvm.mlir.constant(2 : i32) : i32 + %44 = llvm.insertelement %37, %42[%43 : i32] : vector<8xi32> + %45 = llvm.mlir.constant(3 : i32) : i32 + %46 = llvm.insertelement %37, %44[%45 : i32] : vector<8xi32> + %47 = llvm.mlir.constant(4 : i32) : i32 + %48 = llvm.insertelement %37, %46[%47 : i32] : vector<8xi32> + %49 = llvm.mlir.constant(5 : i32) : i32 + %50 = llvm.insertelement %37, %48[%49 : i32] : vector<8xi32> + %51 = llvm.mlir.constant(6 : i32) : i32 + %52 = llvm.insertelement %1, %50[%51 : i32] : vector<8xi32> + %53 = llvm.mlir.constant(7 : i32) : i32 + %54 = llvm.insertelement %37, %52[%53 : i32] : vector<8xi32> + %55 = llvm.add %arg1, %18 : vector<8xi32> + %56 = llvm.shl %36, %55 : vector<8xi32> + %57 = llvm.add %56, %18 : vector<8xi32> + %58 = llvm.and %57, %arg0 : vector<8xi32> + %59 = llvm.sub %54, %arg1 : vector<8xi32> + llvm.call @use8xi32(%55) : (vector<8xi32>) -> () + llvm.call @use8xi32(%56) : (vector<8xi32>) -> () + llvm.call @use8xi32(%57) : (vector<8xi32>) -> () + llvm.call @use8xi32(%59) : (vector<8xi32>) -> () + %60 = llvm.shl %58, %59 : vector<8xi32> + llvm.return %60 : vector<8xi32> + } + llvm.func @t2_vec_nonsplat(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<[-33, -32, -31, -1, 0, 1, 31, 32]> : vector<8xi32>) : vector<8xi32> + %1 = llvm.mlir.constant(dense<1> : vector<8xi32>) : vector<8xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<8xi32>) : vector<8xi32> + %3 = llvm.mlir.constant(dense<32> : vector<8xi32>) : vector<8xi32> + %4 = llvm.add %arg1, %0 : vector<8xi32> + %5 = llvm.shl %1, %4 : vector<8xi32> + %6 = llvm.add %5, %2 : vector<8xi32> + %7 = llvm.and %6, %arg0 : vector<8xi32> + %8 = llvm.sub %3, %arg1 : vector<8xi32> + llvm.call @use8xi32(%4) : (vector<8xi32>) -> () + llvm.call @use8xi32(%5) : (vector<8xi32>) -> () + llvm.call @use8xi32(%6) : (vector<8xi32>) -> () + llvm.call @use8xi32(%8) : (vector<8xi32>) -> () + %9 = llvm.shl %7, %8 : vector<8xi32> + llvm.return %9 : vector<8xi32> + } + llvm.func @n3_extrause(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.add %arg1, %0 : i32 + %4 = llvm.shl %1, %3 : i32 + %5 = llvm.add %4, %0 : i32 + %6 = llvm.and %5, %arg0 : i32 + %7 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.shl %6, %7 : i32 + llvm.return %8 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-b.ll.mlir b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-b.ll.mlir new file mode 100644 index 000000000..d26252d12 --- /dev/null +++ b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-b.ll.mlir @@ -0,0 +1,116 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @t0_basic(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.add %arg1, %0 : i32 + %3 = llvm.shl %0, %2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @t1_vec_splat(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi32>) : vector<8xi32> + %1 = llvm.mlir.constant(dense<32> : vector<8xi32>) : vector<8xi32> + %2 = llvm.add %arg1, %0 : vector<8xi32> + %3 = llvm.shl %0, %2 : vector<8xi32> + %4 = llvm.xor %3, %0 : vector<8xi32> + %5 = llvm.and %4, %arg0 : vector<8xi32> + %6 = llvm.sub %1, %arg1 : vector<8xi32> + llvm.call @use8xi32(%2) : (vector<8xi32>) -> () + llvm.call @use8xi32(%3) : (vector<8xi32>) -> () + llvm.call @use8xi32(%4) : (vector<8xi32>) -> () + llvm.call @use8xi32(%6) : (vector<8xi32>) -> () + %7 = llvm.shl %5, %6 : vector<8xi32> + llvm.return %7 : vector<8xi32> + } + llvm.func @t1_vec_splat_poison(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<8xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi32> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi32> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi32> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi32> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi32> + %19 = llvm.mlir.constant(32 : i32) : i32 + %20 = llvm.mlir.undef : vector<8xi32> + %21 = llvm.mlir.constant(0 : i32) : i32 + %22 = llvm.insertelement %19, %20[%21 : i32] : vector<8xi32> + %23 = llvm.mlir.constant(1 : i32) : i32 + %24 = llvm.insertelement %19, %22[%23 : i32] : vector<8xi32> + %25 = llvm.mlir.constant(2 : i32) : i32 + %26 = llvm.insertelement %19, %24[%25 : i32] : vector<8xi32> + %27 = llvm.mlir.constant(3 : i32) : i32 + %28 = llvm.insertelement %19, %26[%27 : i32] : vector<8xi32> + %29 = llvm.mlir.constant(4 : i32) : i32 + %30 = llvm.insertelement %19, %28[%29 : i32] : vector<8xi32> + %31 = llvm.mlir.constant(5 : i32) : i32 + %32 = llvm.insertelement %19, %30[%31 : i32] : vector<8xi32> + %33 = llvm.mlir.constant(6 : i32) : i32 + %34 = llvm.insertelement %1, %32[%33 : i32] : vector<8xi32> + %35 = llvm.mlir.constant(7 : i32) : i32 + %36 = llvm.insertelement %19, %34[%35 : i32] : vector<8xi32> + %37 = llvm.add %arg1, %18 : vector<8xi32> + %38 = llvm.shl %18, %37 : vector<8xi32> + %39 = llvm.xor %38, %18 : vector<8xi32> + %40 = llvm.and %39, %arg0 : vector<8xi32> + %41 = llvm.sub %36, %arg1 : vector<8xi32> + llvm.call @use8xi32(%37) : (vector<8xi32>) -> () + llvm.call @use8xi32(%38) : (vector<8xi32>) -> () + llvm.call @use8xi32(%39) : (vector<8xi32>) -> () + llvm.call @use8xi32(%41) : (vector<8xi32>) -> () + %42 = llvm.shl %40, %41 : vector<8xi32> + llvm.return %42 : vector<8xi32> + } + llvm.func @t2_vec_nonsplat(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<[-33, -32, -31, -1, 0, 1, 31, 32]> : vector<8xi32>) : vector<8xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<8xi32>) : vector<8xi32> + %2 = llvm.mlir.constant(dense<32> : vector<8xi32>) : vector<8xi32> + %3 = llvm.add %arg1, %0 : vector<8xi32> + %4 = llvm.shl %1, %3 : vector<8xi32> + %5 = llvm.xor %4, %1 : vector<8xi32> + %6 = llvm.and %5, %arg0 : vector<8xi32> + %7 = llvm.sub %2, %arg1 : vector<8xi32> + llvm.call @use8xi32(%3) : (vector<8xi32>) -> () + llvm.call @use8xi32(%4) : (vector<8xi32>) -> () + llvm.call @use8xi32(%5) : (vector<8xi32>) -> () + llvm.call @use8xi32(%7) : (vector<8xi32>) -> () + %8 = llvm.shl %6, %7 : vector<8xi32> + llvm.return %8 : vector<8xi32> + } + llvm.func @n3_extrause(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.add %arg1, %0 : i32 + %3 = llvm.shl %0, %2 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-c.ll.mlir b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-c.ll.mlir new file mode 100644 index 000000000..aba9ba6e4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-c.ll.mlir @@ -0,0 +1,74 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @t0_basic(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.lshr %0, %arg1 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.add %arg1, %0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @t1_vec_splat(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi32>) : vector<8xi32> + %1 = llvm.lshr %0, %arg1 : vector<8xi32> + %2 = llvm.and %1, %arg0 : vector<8xi32> + %3 = llvm.add %arg1, %0 : vector<8xi32> + llvm.call @use8xi32(%1) : (vector<8xi32>) -> () + llvm.call @use8xi32(%3) : (vector<8xi32>) -> () + %4 = llvm.shl %2, %3 : vector<8xi32> + llvm.return %4 : vector<8xi32> + } + llvm.func @t1_vec_splat_poison(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<8xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi32> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi32> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi32> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi32> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi32> + %19 = llvm.lshr %18, %arg1 : vector<8xi32> + %20 = llvm.and %19, %arg0 : vector<8xi32> + %21 = llvm.add %arg1, %18 : vector<8xi32> + llvm.call @use8xi32(%19) : (vector<8xi32>) -> () + llvm.call @use8xi32(%21) : (vector<8xi32>) -> () + %22 = llvm.shl %20, %21 : vector<8xi32> + llvm.return %22 : vector<8xi32> + } + llvm.func @t1_vec_nonsplat(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi32>) : vector<8xi32> + %1 = llvm.mlir.constant(dense<[-32, -31, -1, 0, 1, 31, 32, 33]> : vector<8xi32>) : vector<8xi32> + %2 = llvm.lshr %0, %arg1 : vector<8xi32> + %3 = llvm.and %2, %arg0 : vector<8xi32> + %4 = llvm.add %arg1, %1 : vector<8xi32> + llvm.call @use8xi32(%2) : (vector<8xi32>) -> () + llvm.call @use8xi32(%4) : (vector<8xi32>) -> () + %5 = llvm.shl %3, %4 : vector<8xi32> + llvm.return %5 : vector<8xi32> + } + llvm.func @n3_extrause(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.lshr %0, %arg1 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.add %arg1, %0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %2, %3 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-d.ll.mlir b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-d.ll.mlir new file mode 100644 index 000000000..fec3b5881 --- /dev/null +++ b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-d.ll.mlir @@ -0,0 +1,84 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @t0_basic(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.add %arg1, %0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.shl %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @t2_vec_splat(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi32>) : vector<8xi32> + %1 = llvm.shl %0, %arg1 : vector<8xi32> + %2 = llvm.lshr %1, %arg1 : vector<8xi32> + %3 = llvm.and %2, %arg0 : vector<8xi32> + %4 = llvm.add %arg1, %0 : vector<8xi32> + llvm.call @use8xi32(%1) : (vector<8xi32>) -> () + llvm.call @use8xi32(%2) : (vector<8xi32>) -> () + llvm.call @use8xi32(%4) : (vector<8xi32>) -> () + %5 = llvm.shl %3, %4 : vector<8xi32> + llvm.return %5 : vector<8xi32> + } + llvm.func @t2_vec_splat_poison(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<8xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi32> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi32> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi32> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi32> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi32> + %19 = llvm.shl %18, %arg1 : vector<8xi32> + %20 = llvm.lshr %19, %arg1 : vector<8xi32> + %21 = llvm.and %20, %arg0 : vector<8xi32> + %22 = llvm.add %arg1, %18 : vector<8xi32> + llvm.call @use8xi32(%19) : (vector<8xi32>) -> () + llvm.call @use8xi32(%20) : (vector<8xi32>) -> () + llvm.call @use8xi32(%22) : (vector<8xi32>) -> () + %23 = llvm.shl %21, %22 : vector<8xi32> + llvm.return %23 : vector<8xi32> + } + llvm.func @t2_vec_nonsplat(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi32>) : vector<8xi32> + %1 = llvm.mlir.constant(dense<[-32, -31, -1, 0, 1, 31, 32, 33]> : vector<8xi32>) : vector<8xi32> + %2 = llvm.shl %0, %arg1 : vector<8xi32> + %3 = llvm.lshr %2, %arg1 : vector<8xi32> + %4 = llvm.and %3, %arg0 : vector<8xi32> + %5 = llvm.add %arg1, %1 : vector<8xi32> + llvm.call @use8xi32(%2) : (vector<8xi32>) -> () + llvm.call @use8xi32(%3) : (vector<8xi32>) -> () + llvm.call @use8xi32(%5) : (vector<8xi32>) -> () + %6 = llvm.shl %4, %5 : vector<8xi32> + llvm.return %6 : vector<8xi32> + } + llvm.func @n3_extrause(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.add %arg1, %0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.shl %3, %4 : i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-e.ll.mlir b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-e.ll.mlir new file mode 100644 index 000000000..4489e51a0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/partally-redundant-left-shift-input-masking-variant-e.ll.mlir @@ -0,0 +1,73 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @t0_basic(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + %3 = llvm.add %arg1, %0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @t1_vec_splat(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi32>) : vector<8xi32> + %1 = llvm.shl %arg0, %arg1 : vector<8xi32> + %2 = llvm.lshr %1, %arg1 : vector<8xi32> + %3 = llvm.add %arg1, %0 : vector<8xi32> + llvm.call @use8xi32(%1) : (vector<8xi32>) -> () + llvm.call @use8xi32(%3) : (vector<8xi32>) -> () + %4 = llvm.shl %2, %3 : vector<8xi32> + llvm.return %4 : vector<8xi32> + } + llvm.func @t1_vec_splat_undef(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<8xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi32> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi32> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi32> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi32> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi32> + %19 = llvm.shl %arg0, %arg1 : vector<8xi32> + %20 = llvm.lshr %19, %arg1 : vector<8xi32> + %21 = llvm.add %arg1, %18 : vector<8xi32> + llvm.call @use8xi32(%19) : (vector<8xi32>) -> () + llvm.call @use8xi32(%21) : (vector<8xi32>) -> () + %22 = llvm.shl %20, %21 : vector<8xi32> + llvm.return %22 : vector<8xi32> + } + llvm.func @t1_vec_nonsplat(%arg0: vector<8xi32>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<[-32, -31, -1, 0, 1, 31, 32, 33]> : vector<8xi32>) : vector<8xi32> + %1 = llvm.shl %arg0, %arg1 : vector<8xi32> + %2 = llvm.lshr %1, %arg1 : vector<8xi32> + %3 = llvm.add %arg1, %0 : vector<8xi32> + llvm.call @use8xi32(%1) : (vector<8xi32>) -> () + llvm.call @use8xi32(%3) : (vector<8xi32>) -> () + %4 = llvm.shl %2, %3 : vector<8xi32> + llvm.return %4 : vector<8xi32> + } + llvm.func @n3_extrause(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + %3 = llvm.add %arg1, %0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %2, %3 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/phi-aware-aggregate-reconstruction.ll.mlir b/test/LLVMDialect/InstCombine/phi-aware-aggregate-reconstruction.ll.mlir new file mode 100644 index 000000000..886fc0bb3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/phi-aware-aggregate-reconstruction.ll.mlir @@ -0,0 +1,232 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo() + llvm.func @bar() + llvm.func @baz() + llvm.func @qux() + llvm.func @quux() + llvm.func @geni1() -> i1 + llvm.func @usei32(i32) + llvm.func @usei32i32agg(!llvm.struct<(i32, i32)>) + llvm.func @test0(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + llvm.call @foo() : () -> () + llvm.br ^bb3(%1, %2 : i32, i32) + ^bb2: // pred: ^bb0 + %3 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + %4 = llvm.extractvalue %arg1[1] : !llvm.struct<(i32, i32)> + llvm.call @bar() : () -> () + llvm.br ^bb3(%3, %4 : i32, i32) + ^bb3(%5: i32, %6: i32): // 2 preds: ^bb1, ^bb2 + llvm.call @baz() : () -> () + %7 = llvm.insertvalue %5, %0[0] : !llvm.struct<(i32, i32)> + %8 = llvm.insertvalue %6, %7[1] : !llvm.struct<(i32, i32)> + llvm.return %8 : !llvm.struct<(i32, i32)> + } + llvm.func @negative_test1(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + %3 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + %4 = llvm.extractvalue %arg1[1] : !llvm.struct<(i32, i32)> + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo() : () -> () + llvm.br ^bb3(%1, %4 : i32, i32) + ^bb2: // pred: ^bb0 + llvm.call @bar() : () -> () + llvm.br ^bb3(%3, %2 : i32, i32) + ^bb3(%5: i32, %6: i32): // 2 preds: ^bb1, ^bb2 + llvm.call @baz() : () -> () + %7 = llvm.insertvalue %5, %0[0] : !llvm.struct<(i32, i32)> + %8 = llvm.insertvalue %6, %7[1] : !llvm.struct<(i32, i32)> + llvm.return %8 : !llvm.struct<(i32, i32)> + } + llvm.func @negative_test2(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + %3 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + %4 = llvm.extractvalue %arg1[1] : !llvm.struct<(i32, i32)> + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo() : () -> () + llvm.br ^bb3(%2, %1 : i32, i32) + ^bb2: // pred: ^bb0 + llvm.call @bar() : () -> () + llvm.br ^bb3(%3, %4 : i32, i32) + ^bb3(%5: i32, %6: i32): // 2 preds: ^bb1, ^bb2 + llvm.call @baz() : () -> () + %7 = llvm.insertvalue %5, %0[0] : !llvm.struct<(i32, i32)> + %8 = llvm.insertvalue %6, %7[1] : !llvm.struct<(i32, i32)> + llvm.return %8 : !llvm.struct<(i32, i32)> + } + llvm.func @test3(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: !llvm.struct<(i32, i32)>, %arg3: i1, %arg4: i1) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + llvm.cond_br %arg3, ^bb1, ^bb5 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg4, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + llvm.br ^bb4(%1, %2 : i32, i32) + ^bb3: // pred: ^bb1 + %3 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + %4 = llvm.extractvalue %arg1[1] : !llvm.struct<(i32, i32)> + llvm.br ^bb4(%3, %4 : i32, i32) + ^bb4(%5: i32, %6: i32): // 2 preds: ^bb2, ^bb3 + llvm.br ^bb6(%5, %6 : i32, i32) + ^bb5: // pred: ^bb0 + %7 = llvm.extractvalue %arg2[0] : !llvm.struct<(i32, i32)> + %8 = llvm.extractvalue %arg2[1] : !llvm.struct<(i32, i32)> + llvm.br ^bb6(%7, %8 : i32, i32) + ^bb6(%9: i32, %10: i32): // 2 preds: ^bb4, ^bb5 + llvm.call @baz() : () -> () + %11 = llvm.insertvalue %9, %0[0] : !llvm.struct<(i32, i32)> + %12 = llvm.insertvalue %10, %11[1] : !llvm.struct<(i32, i32)> + llvm.return %12 : !llvm.struct<(i32, i32)> + } + llvm.func @test4(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + llvm.call @foo() : () -> () + llvm.br ^bb3(%1, %2 : i32, i32) + ^bb2: // pred: ^bb0 + %3 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + %4 = llvm.extractvalue %arg1[1] : !llvm.struct<(i32, i32)> + llvm.call @bar() : () -> () + llvm.br ^bb3(%3, %4 : i32, i32) + ^bb3(%5: i32, %6: i32): // 3 preds: ^bb1, ^bb2, ^bb3 + llvm.call @baz() : () -> () + %7 = llvm.insertvalue %5, %0[0] : !llvm.struct<(i32, i32)> + %8 = llvm.insertvalue %6, %7[1] : !llvm.struct<(i32, i32)> + %9 = llvm.call @geni1() : () -> i1 + llvm.cond_br %9, ^bb4, ^bb3(%5, %6 : i32, i32) + ^bb4: // pred: ^bb3 + llvm.return %8 : !llvm.struct<(i32, i32)> + } + llvm.func @test5(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + llvm.call @foo() : () -> () + llvm.br ^bb3(%1, %2 : i32, i32) + ^bb2: // pred: ^bb0 + %3 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + %4 = llvm.extractvalue %arg1[1] : !llvm.struct<(i32, i32)> + llvm.call @bar() : () -> () + llvm.br ^bb3(%3, %4 : i32, i32) + ^bb3(%5: i32, %6: i32): // 3 preds: ^bb1, ^bb2, ^bb3 + llvm.call @baz() : () -> () + %7 = llvm.insertvalue %5, %0[0] : !llvm.struct<(i32, i32)> + %8 = llvm.insertvalue %6, %7[1] : !llvm.struct<(i32, i32)> + %9 = llvm.extractvalue %8[0] : !llvm.struct<(i32, i32)> + %10 = llvm.extractvalue %8[1] : !llvm.struct<(i32, i32)> + %11 = llvm.call @geni1() : () -> i1 + llvm.cond_br %11, ^bb4, ^bb3(%9, %10 : i32, i32) + ^bb4: // pred: ^bb3 + llvm.return %8 : !llvm.struct<(i32, i32)> + } + llvm.func @test6(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1, %arg3: i1) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + llvm.call @foo() : () -> () + llvm.br ^bb3(%1, %2 : i32, i32) + ^bb2: // pred: ^bb0 + %3 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + %4 = llvm.extractvalue %arg1[1] : !llvm.struct<(i32, i32)> + llvm.call @bar() : () -> () + llvm.br ^bb3(%3, %4 : i32, i32) + ^bb3(%5: i32, %6: i32): // 2 preds: ^bb1, ^bb2 + llvm.call @baz() : () -> () + llvm.cond_br %arg3, ^bb5, ^bb4 + ^bb4: // pred: ^bb3 + llvm.call @qux() : () -> () + llvm.br ^bb5 + ^bb5: // 2 preds: ^bb3, ^bb4 + llvm.call @quux() : () -> () + %7 = llvm.insertvalue %5, %0[0] : !llvm.struct<(i32, i32)> + %8 = llvm.insertvalue %6, %7[1] : !llvm.struct<(i32, i32)> + llvm.return %8 : !llvm.struct<(i32, i32)> + } + llvm.func @negative_test7(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1, %arg3: i1) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + llvm.call @usei32(%1) : (i32) -> () + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + llvm.call @usei32(%2) : (i32) -> () + llvm.br ^bb3(%2 : i32) + ^bb2: // pred: ^bb0 + %3 = llvm.extractvalue %arg1[1] : !llvm.struct<(i32, i32)> + llvm.call @usei32(%3) : (i32) -> () + llvm.br ^bb3(%3 : i32) + ^bb3(%4: i32): // 2 preds: ^bb1, ^bb2 + llvm.call @bar() : () -> () + llvm.br ^bb4 + ^bb4: // pred: ^bb3 + llvm.call @baz() : () -> () + %5 = llvm.insertvalue %1, %0[0] : !llvm.struct<(i32, i32)> + %6 = llvm.insertvalue %4, %5[1] : !llvm.struct<(i32, i32)> + llvm.return %6 : !llvm.struct<(i32, i32)> + } + llvm.func @test8(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1, %arg3: i32, %arg4: i32) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + llvm.call @foo() : () -> () + llvm.switch %arg3 : i32, ^bb3 [ + 4294967254: ^bb4(%1, %2 : i32, i32), + 42: ^bb4(%1, %2 : i32, i32) + ] + ^bb2: // pred: ^bb0 + %3 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + %4 = llvm.extractvalue %arg1[1] : !llvm.struct<(i32, i32)> + llvm.call @bar() : () -> () + llvm.switch %arg4 : i32, ^bb3 [ + 42: ^bb4(%3, %4 : i32, i32), + 4294967254: ^bb4(%3, %4 : i32, i32) + ] + ^bb3: // 2 preds: ^bb1, ^bb2 + llvm.unreachable + ^bb4(%5: i32, %6: i32): // 4 preds: ^bb1, ^bb1, ^bb2, ^bb2 + llvm.call @baz() : () -> () + %7 = llvm.insertvalue %5, %0[0] : !llvm.struct<(i32, i32)> + %8 = llvm.insertvalue %6, %7[1] : !llvm.struct<(i32, i32)> + llvm.return %8 : !llvm.struct<(i32, i32)> + } + llvm.func @test9(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1) -> !llvm.struct<(i32, i32)> { + %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %2 = llvm.extractvalue %arg0[1] : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %1, %0[0] : !llvm.struct<(i32, i32)> + llvm.call @foo() : () -> () + llvm.br ^bb3(%3, %2 : !llvm.struct<(i32, i32)>, i32) + ^bb2: // pred: ^bb0 + %4 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + %5 = llvm.extractvalue %arg1[1] : !llvm.struct<(i32, i32)> + %6 = llvm.insertvalue %4, %0[0] : !llvm.struct<(i32, i32)> + llvm.call @bar() : () -> () + llvm.br ^bb3(%6, %5 : !llvm.struct<(i32, i32)>, i32) + ^bb3(%7: !llvm.struct<(i32, i32)>, %8: i32): // 2 preds: ^bb1, ^bb2 + llvm.call @baz() : () -> () + %9 = llvm.insertvalue %8, %7[1] : !llvm.struct<(i32, i32)> + llvm.return %9 : !llvm.struct<(i32, i32)> + } +} diff --git a/test/LLVMDialect/InstCombine/phi-cse.ll.mlir b/test/LLVMDialect/InstCombine/phi-cse.ll.mlir index c3d5cbe96..84b5a3d8f 100644 --- a/test/LLVMDialect/InstCombine/phi-cse.ll.mlir +++ b/test/LLVMDialect/InstCombine/phi-cse.ll.mlir @@ -1,124 +1,113 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i1, %arg3: !llvm.ptr, %arg4: !llvm.ptr): // no predecessors - "llvm.cond_br"(%arg2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test0(%arg0: i32, %arg1: i32, %arg2: i1, %arg3: !llvm.ptr, %arg4: !llvm.ptr) { + llvm.cond_br %arg2, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.br"(%arg0, %arg0)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%arg0, %arg0 : i32, i32) ^bb2: // pred: ^bb0 - "llvm.br"(%arg1, %arg1)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%arg1, %arg1 : i32, i32) ^bb3(%0: i32, %1: i32): // 2 preds: ^bb1, ^bb2 - "llvm.store"(%0, %arg3) : (i32, !llvm.ptr) -> () - "llvm.store"(%1, %arg4) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test0", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i1, %arg3: !llvm.ptr, %arg4: !llvm.ptr): // no predecessors - "llvm.cond_br"(%arg2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.store %0, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %1, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test1(%arg0: i32, %arg1: i32, %arg2: i1, %arg3: !llvm.ptr, %arg4: !llvm.ptr) { + llvm.cond_br %arg2, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.br"(%arg0, %arg0)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%arg0, %arg0 : i32, i32) ^bb2: // pred: ^bb0 - "llvm.br"(%arg1, %arg1)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%arg1, %arg1 : i32, i32) ^bb3(%0: i32, %1: i32): // 2 preds: ^bb1, ^bb2 - "llvm.store"(%0, %arg3) : (i32, !llvm.ptr) -> () - "llvm.store"(%1, %arg4) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i1, %arg4: !llvm.ptr, %arg5: !llvm.ptr): // no predecessors - "llvm.cond_br"(%arg3)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.store %0, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %1, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @negative_test2(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i1, %arg4: !llvm.ptr, %arg5: !llvm.ptr) { + llvm.cond_br %arg3, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.br"(%arg0, %arg0)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%arg0, %arg0 : i32, i32) ^bb2: // pred: ^bb0 - "llvm.br"(%arg1, %arg2)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%arg1, %arg2 : i32, i32) ^bb3(%0: i32, %1: i32): // 2 preds: ^bb1, ^bb2 - "llvm.store"(%0, %arg4) : (i32, !llvm.ptr) -> () - "llvm.store"(%1, %arg5) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "negative_test2", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i1, %arg4: !llvm.ptr, %arg5: !llvm.ptr): // no predecessors - "llvm.cond_br"(%arg3)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.store %0, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %1, %arg5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @negative_test3(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i1, %arg4: !llvm.ptr, %arg5: !llvm.ptr) { + llvm.cond_br %arg3, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.br"(%arg0, %arg0)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%arg0, %arg0 : i32, i32) ^bb2: // pred: ^bb0 - "llvm.br"(%arg1, %arg2)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%arg1, %arg2 : i32, i32) ^bb3(%0: i32, %1: i32): // 2 preds: ^bb1, ^bb2 - "llvm.store"(%0, %arg4) : (i32, !llvm.ptr) -> () - "llvm.store"(%1, %arg5) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "negative_test3", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i1, %arg3: !llvm.ptr, %arg4: !llvm.ptr): // no predecessors - "llvm.cond_br"(%arg2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.store %0, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %1, %arg5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @negative_test4(%arg0: i32, %arg1: i32, %arg2: i1, %arg3: !llvm.ptr, %arg4: !llvm.ptr) { + llvm.cond_br %arg2, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.br"(%arg0, %arg0)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%arg0, %arg0 : i32, i32) ^bb2: // pred: ^bb0 - "llvm.br"(%arg1, %arg1)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%arg1, %arg1 : i32, i32) ^bb3(%0: i32, %1: i32): // 2 preds: ^bb1, ^bb2 - "llvm.store"(%0, %arg3) : (i32, !llvm.ptr) -> () - "llvm.store"(%1, %arg4) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "negative_test4", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i1, %arg3: !llvm.ptr, %arg4: !llvm.ptr): // no predecessors - "llvm.cond_br"(%arg2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.store %0, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %1, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test5(%arg0: i32, %arg1: i32, %arg2: i1, %arg3: !llvm.ptr, %arg4: !llvm.ptr) { + llvm.cond_br %arg2, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.br"(%arg0, %arg0)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%arg0, %arg0 : i32, i32) ^bb2: // pred: ^bb0 - "llvm.br"(%arg1, %arg1)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%arg1, %arg1 : i32, i32) ^bb3(%0: i32, %1: i32): // 2 preds: ^bb1, ^bb2 - "llvm.store"(%1, %arg4) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i1, %arg3: !llvm.ptr, %arg4: !llvm.ptr): // no predecessors - "llvm.cond_br"(%arg2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.store %1, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test6(%arg0: i32, %arg1: i32, %arg2: i1, %arg3: !llvm.ptr, %arg4: !llvm.ptr) { + llvm.cond_br %arg2, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.br"(%arg0, %arg0)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%arg0, %arg0 : i32, i32) ^bb2: // pred: ^bb0 - "llvm.br"(%arg1, %arg1)[^bb3] : (i32, i32) -> () + llvm.br ^bb3(%arg1, %arg1 : i32, i32) ^bb3(%0: i32, %1: i32): // 2 preds: ^bb1, ^bb2 - "llvm.store"(%0, %arg3) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i16, %arg3: i16, %arg4: i1, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr): // no predecessors - "llvm.cond_br"(%arg4)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.store %0, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test7(%arg0: i32, %arg1: i32, %arg2: i16, %arg3: i16, %arg4: i1, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr) { + llvm.cond_br %arg4, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.br"(%arg2, %arg0, %arg0)[^bb3] : (i16, i32, i32) -> () + llvm.br ^bb3(%arg2, %arg0, %arg0 : i16, i32, i32) ^bb2: // pred: ^bb0 - "llvm.br"(%arg3, %arg1, %arg1)[^bb3] : (i16, i32, i32) -> () + llvm.br ^bb3(%arg3, %arg1, %arg1 : i16, i32, i32) ^bb3(%0: i16, %1: i32, %2: i32): // 2 preds: ^bb1, ^bb2 - "llvm.store"(%1, %arg5) : (i32, !llvm.ptr) -> () - "llvm.store"(%2, %arg6) : (i32, !llvm.ptr) -> () - "llvm.store"(%0, %arg7) : (i16, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test7", type = !llvm.func, ptr, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i16, %arg3: i16, %arg4: i1, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr): // no predecessors - "llvm.cond_br"(%arg4)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.store %1, %arg5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %2, %arg6 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %arg7 {alignment = 2 : i64} : i16, !llvm.ptr + llvm.return + } + llvm.func @test8(%arg0: i32, %arg1: i32, %arg2: i16, %arg3: i16, %arg4: i1, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr) { + llvm.cond_br %arg4, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.br"(%arg0, %arg2, %arg0)[^bb3] : (i32, i16, i32) -> () + llvm.br ^bb3(%arg0, %arg2, %arg0 : i32, i16, i32) ^bb2: // pred: ^bb0 - "llvm.br"(%arg1, %arg3, %arg1)[^bb3] : (i32, i16, i32) -> () + llvm.br ^bb3(%arg1, %arg3, %arg1 : i32, i16, i32) ^bb3(%0: i32, %1: i16, %2: i32): // 2 preds: ^bb1, ^bb2 - "llvm.store"(%0, %arg5) : (i32, !llvm.ptr) -> () - "llvm.store"(%2, %arg6) : (i32, !llvm.ptr) -> () - "llvm.store"(%1, %arg7) : (i16, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test8", type = !llvm.func, ptr, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i16, %arg3: i16, %arg4: i1, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr): // no predecessors - "llvm.cond_br"(%arg4)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.store %0, %arg5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %2, %arg6 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %1, %arg7 {alignment = 2 : i64} : i16, !llvm.ptr + llvm.return + } + llvm.func @test9(%arg0: i32, %arg1: i32, %arg2: i16, %arg3: i16, %arg4: i1, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr) { + llvm.cond_br %arg4, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.br"(%arg0, %arg0, %arg2)[^bb3] : (i32, i32, i16) -> () + llvm.br ^bb3(%arg0, %arg0, %arg2 : i32, i32, i16) ^bb2: // pred: ^bb0 - "llvm.br"(%arg1, %arg1, %arg3)[^bb3] : (i32, i32, i16) -> () + llvm.br ^bb3(%arg1, %arg1, %arg3 : i32, i32, i16) ^bb3(%0: i32, %1: i32, %2: i16): // 2 preds: ^bb1, ^bb2 - "llvm.store"(%0, %arg5) : (i32, !llvm.ptr) -> () - "llvm.store"(%1, %arg6) : (i32, !llvm.ptr) -> () - "llvm.store"(%2, %arg7) : (i16, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test9", type = !llvm.func, ptr, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.store %0, %arg5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %1, %arg6 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %2, %arg7 {alignment = 2 : i64} : i16, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/phi-equal-incoming-pointers.ll.mlir b/test/LLVMDialect/InstCombine/phi-equal-incoming-pointers.ll.mlir new file mode 100644 index 000000000..0019c0000 --- /dev/null +++ b/test/LLVMDialect/InstCombine/phi-equal-incoming-pointers.ll.mlir @@ -0,0 +1,271 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @get_ptr.i8() -> !llvm.ptr + llvm.func @get_ptr.i32() -> !llvm.ptr + llvm.func @foo.i8(!llvm.ptr) + llvm.func @foo.i32(!llvm.ptr) + llvm.func @test_gep_and_bitcast(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.call @get_ptr.i8() : () -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb3(%3, %4 : !llvm.ptr, i32) + ^bb2: // pred: ^bb0 + %5 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %6 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb3(%5, %6 : !llvm.ptr, i32) + ^bb3(%7: !llvm.ptr, %8: i32): // 2 preds: ^bb1, ^bb2 + llvm.store %1, %7 {alignment = 4 : i64} : i32, !llvm.ptr + %9 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + %10 = llvm.select %arg1, %8, %9 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @test_gep_and_bitcast_arg(%arg0: !llvm.ptr, %arg1: i1, %arg2: i1) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + llvm.cond_br %arg1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb3(%2, %3 : !llvm.ptr, i32) + ^bb2: // pred: ^bb0 + %4 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %5 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb3(%4, %5 : !llvm.ptr, i32) + ^bb3(%6: !llvm.ptr, %7: i32): // 2 preds: ^bb1, ^bb2 + llvm.store %1, %6 {alignment = 4 : i64} : i32, !llvm.ptr + %8 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + %9 = llvm.select %arg2, %7, %8 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @test_gep_and_bitcast_phi(%arg0: i1, %arg1: i1, %arg2: i1) -> i32 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(16 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.call @get_ptr.i8() : () -> !llvm.ptr + llvm.br ^bb3(%3, %3 : !llvm.ptr, !llvm.ptr) + ^bb2: // pred: ^bb0 + %4 = llvm.call @get_ptr.i32() : () -> !llvm.ptr + llvm.br ^bb3(%4, %0 : !llvm.ptr, !llvm.ptr) + ^bb3(%5: !llvm.ptr, %6: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.call @foo.i8(%6) : (!llvm.ptr) -> () + llvm.cond_br %arg1, ^bb4, ^bb5 + ^bb4: // pred: ^bb3 + %7 = llvm.getelementptr inbounds %5[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %8 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb6(%7, %8 : !llvm.ptr, i32) + ^bb5: // pred: ^bb3 + %9 = llvm.getelementptr inbounds %5[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %10 = llvm.load %9 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb6(%9, %10 : !llvm.ptr, i32) + ^bb6(%11: !llvm.ptr, %12: i32): // 2 preds: ^bb4, ^bb5 + llvm.store %2, %11 {alignment = 4 : i64} : i32, !llvm.ptr + %13 = llvm.load %11 {alignment = 4 : i64} : !llvm.ptr -> i32 + %14 = llvm.select %arg2, %12, %13 : i1, i32 + llvm.return %14 : i32 + } + llvm.func @test_gep_i32ptr(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.call @get_ptr.i32() : () -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb3(%3, %4 : !llvm.ptr, i32) + ^bb2: // pred: ^bb0 + %5 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %6 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb3(%5, %6 : !llvm.ptr, i32) + ^bb3(%7: !llvm.ptr, %8: i32): // 2 preds: ^bb1, ^bb2 + llvm.store %1, %7 {alignment = 4 : i64} : i32, !llvm.ptr + %9 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + %10 = llvm.select %arg1, %8, %9 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @test_gep_and_bitcast_gep_base_ptr(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.call @get_ptr.i8() : () -> !llvm.ptr + %3 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.getelementptr inbounds %3[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %5 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb3(%4, %5 : !llvm.ptr, i32) + ^bb2: // pred: ^bb0 + %6 = llvm.getelementptr inbounds %3[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb3(%6, %7 : !llvm.ptr, i32) + ^bb3(%8: !llvm.ptr, %9: i32): // 2 preds: ^bb1, ^bb2 + llvm.store %1, %8 {alignment = 4 : i64} : i32, !llvm.ptr + %10 = llvm.load %8 {alignment = 4 : i64} : !llvm.ptr -> i32 + %11 = llvm.select %arg1, %9, %10 : i1, i32 + llvm.return %11 : i32 + } + llvm.func @test_gep_and_bitcast_same_bb(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.call @get_ptr.i8() : () -> !llvm.ptr + %3 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.cond_br %arg0, ^bb2(%3, %4 : !llvm.ptr, i32), ^bb1 + ^bb1: // pred: ^bb0 + %5 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %6 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb2(%5, %6 : !llvm.ptr, i32) + ^bb2(%7: !llvm.ptr, %8: i32): // 2 preds: ^bb0, ^bb1 + llvm.store %1, %7 {alignment = 4 : i64} : i32, !llvm.ptr + %9 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + %10 = llvm.select %arg1, %8, %9 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @test_gep_and_bitcast_same_bb_and_extra_use(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.call @get_ptr.i8() : () -> !llvm.ptr + %3 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.call @foo.i32(%3) : (!llvm.ptr) -> () + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.cond_br %arg0, ^bb2(%3, %4 : !llvm.ptr, i32), ^bb1 + ^bb1: // pred: ^bb0 + %5 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %6 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb2(%5, %6 : !llvm.ptr, i32) + ^bb2(%7: !llvm.ptr, %8: i32): // 2 preds: ^bb0, ^bb1 + llvm.store %1, %7 {alignment = 4 : i64} : i32, !llvm.ptr + %9 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + %10 = llvm.select %arg1, %8, %9 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @test_gep(%arg0: i1, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.call @get_ptr.i8() : () -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.load %3 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.br ^bb3(%3, %4 : !llvm.ptr, i8) + ^bb2: // pred: ^bb0 + %5 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %6 = llvm.load %5 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.br ^bb3(%5, %6 : !llvm.ptr, i8) + ^bb3(%7: !llvm.ptr, %8: i8): // 2 preds: ^bb1, ^bb2 + llvm.store %1, %7 {alignment = 1 : i64} : i8, !llvm.ptr + %9 = llvm.load %7 {alignment = 1 : i64} : !llvm.ptr -> i8 + %10 = llvm.select %arg1, %8, %9 : i1, i8 + llvm.return %10 : i8 + } + llvm.func @test_extra_uses(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.call @get_ptr.i8() : () -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.call @foo.i32(%3) : (!llvm.ptr) -> () + llvm.br ^bb3(%3, %4 : !llvm.ptr, i32) + ^bb2: // pred: ^bb0 + %5 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %6 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.call @foo.i32(%5) : (!llvm.ptr) -> () + llvm.br ^bb3(%5, %6 : !llvm.ptr, i32) + ^bb3(%7: !llvm.ptr, %8: i32): // 2 preds: ^bb1, ^bb2 + llvm.store %1, %7 {alignment = 4 : i64} : i32, !llvm.ptr + %9 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + %10 = llvm.select %arg1, %8, %9 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @test_extra_uses_non_inbounds(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.call @get_ptr.i8() : () -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.getelementptr %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.call @foo.i32(%3) : (!llvm.ptr) -> () + llvm.br ^bb3(%3, %4 : !llvm.ptr, i32) + ^bb2: // pred: ^bb0 + %5 = llvm.getelementptr %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %6 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.call @foo.i32(%5) : (!llvm.ptr) -> () + llvm.br ^bb3(%5, %6 : !llvm.ptr, i32) + ^bb3(%7: !llvm.ptr, %8: i32): // 2 preds: ^bb1, ^bb2 + llvm.store %1, %7 {alignment = 4 : i64} : i32, !llvm.ptr + %9 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + %10 = llvm.select %arg1, %8, %9 : i1, i32 + llvm.return %10 : i32 + } + llvm.func @test_extra_uses_multiple_geps(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(16 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.call @get_ptr.i8() : () -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.getelementptr inbounds %3[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %5 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.call @foo.i32(%4) : (!llvm.ptr) -> () + llvm.br ^bb3(%4, %5 : !llvm.ptr, i32) + ^bb2: // pred: ^bb0 + %6 = llvm.getelementptr %3[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %7 = llvm.getelementptr inbounds %6[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %8 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.call @foo.i32(%7) : (!llvm.ptr) -> () + llvm.br ^bb3(%7, %8 : !llvm.ptr, i32) + ^bb3(%9: !llvm.ptr, %10: i32): // 2 preds: ^bb1, ^bb2 + llvm.store %2, %9 {alignment = 4 : i64} : i32, !llvm.ptr + %11 = llvm.load %9 {alignment = 4 : i64} : !llvm.ptr -> i32 + %12 = llvm.select %arg1, %10, %11 : i1, i32 + llvm.return %12 : i32 + } + llvm.func @test_gep_extra_uses(%arg0: i1, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.call @get_ptr.i8() : () -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.load %3 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.call @foo.i8(%3) : (!llvm.ptr) -> () + llvm.br ^bb3(%3, %4 : !llvm.ptr, i8) + ^bb2: // pred: ^bb0 + %5 = llvm.getelementptr inbounds %2[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %6 = llvm.load %5 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.call @foo.i8(%5) : (!llvm.ptr) -> () + llvm.br ^bb3(%5, %6 : !llvm.ptr, i8) + ^bb3(%7: !llvm.ptr, %8: i8): // 2 preds: ^bb1, ^bb2 + llvm.store %1, %7 {alignment = 1 : i64} : i8, !llvm.ptr + %9 = llvm.load %7 {alignment = 1 : i64} : !llvm.ptr -> i8 + %10 = llvm.select %arg1, %8, %9 : i1, i8 + llvm.return %10 : i8 + } + llvm.func @takeAddress(!llvm.ptr) + llvm.func @test_dont_optimize_swifterror(%arg0: i1, %arg1: i1, %arg2: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + %3 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.call @takeAddress(%2) : (!llvm.ptr) -> () + llvm.call @takeAddress(%3) : (!llvm.ptr) -> () + llvm.store %arg2, %2 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%4 : !llvm.ptr) + ^bb2: // pred: ^bb0 + %5 = llvm.load %3 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%5 : !llvm.ptr) + ^bb3(%6: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.store %1, %2 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %7 = llvm.select %arg1, %6, %1 : i1, !llvm.ptr + llvm.return %7 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/phi-extractvalue.ll.mlir b/test/LLVMDialect/InstCombine/phi-extractvalue.ll.mlir new file mode 100644 index 000000000..5615e03cb --- /dev/null +++ b/test/LLVMDialect/InstCombine/phi-extractvalue.ll.mlir @@ -0,0 +1,248 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @usei32(i32) + llvm.func @test0(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1) -> i32 { + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%0 : i32) + ^bb2: // pred: ^bb0 + %1 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%1 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : i32 + } + llvm.func @test1_extrause0(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1) -> i32 { + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + llvm.call @usei32(%0) : (i32) -> () + llvm.br ^bb3(%0 : i32) + ^bb2: // pred: ^bb0 + %1 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%1 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : i32 + } + llvm.func @test2_extrause1(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1) -> i32 { + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%0 : i32) + ^bb2: // pred: ^bb0 + %1 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + llvm.call @usei32(%1) : (i32) -> () + llvm.br ^bb3(%1 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : i32 + } + llvm.func @test3_extrause2(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1) -> i32 { + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + llvm.call @usei32(%0) : (i32) -> () + llvm.br ^bb3(%0 : i32) + ^bb2: // pred: ^bb0 + %1 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + llvm.call @usei32(%1) : (i32) -> () + llvm.br ^bb3(%1 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : i32 + } + llvm.func @test4(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1) -> i32 { + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%0 : i32) + ^bb2: // pred: ^bb0 + %1 = llvm.extractvalue %arg1[1] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%1 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : i32 + } + llvm.func @test5(%arg0: !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>, %arg1: !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>, %arg2: i1) -> i32 { + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.extractvalue %arg0[0, 0] : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> + llvm.br ^bb3(%0 : i32) + ^bb2: // pred: ^bb0 + %1 = llvm.extractvalue %arg1[0, 0] : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> + llvm.br ^bb3(%1 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : i32 + } + llvm.func @test6(%arg0: !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>, %arg1: !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>, %arg2: i1) -> i32 { + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.extractvalue %arg0[0, 0] : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> + llvm.br ^bb3(%0 : i32) + ^bb2: // pred: ^bb0 + %1 = llvm.extractvalue %arg1[0, 1] : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> + llvm.br ^bb3(%1 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : i32 + } + llvm.func @test7(%arg0: !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>, %arg1: !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>, %arg2: i1) -> i32 { + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.extractvalue %arg0[0, 0] : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> + llvm.br ^bb3(%0 : i32) + ^bb2: // pred: ^bb0 + %1 = llvm.extractvalue %arg1[1, 0] : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> + llvm.br ^bb3(%1 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : i32 + } + llvm.func @test8(%arg0: !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>, %arg1: !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>, %arg2: i1) -> i32 { + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.extractvalue %arg0[0, 0] : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> + llvm.br ^bb3(%0 : i32) + ^bb2: // pred: ^bb0 + %1 = llvm.extractvalue %arg1[1, 1] : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> + llvm.br ^bb3(%1 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : i32 + } + llvm.func @test9(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, struct<(i32, i32)>)>, %arg2: i1) -> i32 { + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%0 : i32) + ^bb2: // pred: ^bb0 + %1 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, struct<(i32, i32)>)> + llvm.br ^bb3(%1 : i32) + ^bb3(%2: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : i32 + } + llvm.func @test10(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1, %arg3: i1) -> i32 { + %0 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + llvm.cond_br %arg2, ^bb4(%0 : i32), ^bb1 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg3, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.br ^bb4(%0 : i32) + ^bb3: // pred: ^bb1 + llvm.br ^bb4(%1 : i32) + ^bb4(%2: i32): // 3 preds: ^bb0, ^bb2, ^bb3 + llvm.return %2 : i32 + } + llvm.func @test11(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i1, %arg3: i1) -> i32 { + %0 = llvm.extractvalue %arg0[0] : !llvm.struct<(i32, i32)> + %1 = llvm.extractvalue %arg1[0] : !llvm.struct<(i32, i32)> + llvm.call @usei32(%0) : (i32) -> () + llvm.cond_br %arg2, ^bb4(%0 : i32), ^bb1 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg3, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.br ^bb4(%0 : i32) + ^bb3: // pred: ^bb1 + llvm.br ^bb4(%1 : i32) + ^bb4(%2: i32): // 3 preds: ^bb0, ^bb2, ^bb3 + llvm.return %2 : i32 + } + llvm.func @extractvalue_of_constant_phi(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<(i32, i32)> + %5 = llvm.mlir.constant(2 : i32) : i32 + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %8 = llvm.insertvalue %6, %7[0] : !llvm.struct<(i32, i32)> + %9 = llvm.insertvalue %5, %8[1] : !llvm.struct<(i32, i32)> + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%9 : !llvm.struct<(i32, i32)>) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%4 : !llvm.struct<(i32, i32)>) + ^bb3(%10: !llvm.struct<(i32, i32)>): // 2 preds: ^bb1, ^bb2 + %11 = llvm.extractvalue %10[0] : !llvm.struct<(i32, i32)> + llvm.return %11 : i32 + } + llvm.func @extractvalue_of_one_constant_phi(%arg0: i1, %arg1: !llvm.struct<(i32, i32)>) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<(i32, i32)> + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%arg1 : !llvm.struct<(i32, i32)>) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%4 : !llvm.struct<(i32, i32)>) + ^bb3(%5: !llvm.struct<(i32, i32)>): // 2 preds: ^bb1, ^bb2 + %6 = llvm.extractvalue %5[0] : !llvm.struct<(i32, i32)> + llvm.return %6 : i32 + } + llvm.func @extractvalue_of_constant_phi_multi_index(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<(i32, i32)> + %5 = llvm.mlir.constant(4 : i32) : i32 + %6 = llvm.mlir.undef : !llvm.struct<(i32, struct<(i32, i32)>)> + %7 = llvm.insertvalue %5, %6[0] : !llvm.struct<(i32, struct<(i32, i32)>)> + %8 = llvm.insertvalue %4, %7[1] : !llvm.struct<(i32, struct<(i32, i32)>)> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.mlir.constant(2 : i32) : i32 + %11 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %12 = llvm.insertvalue %10, %11[0] : !llvm.struct<(i32, i32)> + %13 = llvm.insertvalue %9, %12[1] : !llvm.struct<(i32, i32)> + %14 = llvm.mlir.constant(1 : i32) : i32 + %15 = llvm.mlir.undef : !llvm.struct<(i32, struct<(i32, i32)>)> + %16 = llvm.insertvalue %14, %15[0] : !llvm.struct<(i32, struct<(i32, i32)>)> + %17 = llvm.insertvalue %13, %16[1] : !llvm.struct<(i32, struct<(i32, i32)>)> + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%17 : !llvm.struct<(i32, struct<(i32, i32)>)>) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%8 : !llvm.struct<(i32, struct<(i32, i32)>)>) + ^bb3(%18: !llvm.struct<(i32, struct<(i32, i32)>)>): // 2 preds: ^bb1, ^bb2 + %19 = llvm.extractvalue %18[1, 1] : !llvm.struct<(i32, struct<(i32, i32)>)> + llvm.return %19 : i32 + } + llvm.func @extractvalue_of_one_constant_phi_multi_index(%arg0: i1, %arg1: !llvm.struct<(i32, struct<(i32, i32)>)>) -> i32 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<(i32, i32)> + %5 = llvm.mlir.constant(4 : i32) : i32 + %6 = llvm.mlir.undef : !llvm.struct<(i32, struct<(i32, i32)>)> + %7 = llvm.insertvalue %5, %6[0] : !llvm.struct<(i32, struct<(i32, i32)>)> + %8 = llvm.insertvalue %4, %7[1] : !llvm.struct<(i32, struct<(i32, i32)>)> + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%arg1 : !llvm.struct<(i32, struct<(i32, i32)>)>) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%8 : !llvm.struct<(i32, struct<(i32, i32)>)>) + ^bb3(%9: !llvm.struct<(i32, struct<(i32, i32)>)>): // 2 preds: ^bb1, ^bb2 + %10 = llvm.extractvalue %9[1, 1] : !llvm.struct<(i32, struct<(i32, i32)>)> + llvm.return %10 : i32 + } + llvm.func @extractvalue_of_constant_phi_multiuse(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<(i32, i32)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<(i32, i32)> + %5 = llvm.mlir.constant(2 : i32) : i32 + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.mlir.undef : !llvm.struct<(i32, i32)> + %8 = llvm.insertvalue %6, %7[0] : !llvm.struct<(i32, i32)> + %9 = llvm.insertvalue %5, %8[1] : !llvm.struct<(i32, i32)> + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%9 : !llvm.struct<(i32, i32)>) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%4 : !llvm.struct<(i32, i32)>) + ^bb3(%10: !llvm.struct<(i32, i32)>): // 2 preds: ^bb1, ^bb2 + %11 = llvm.extractvalue %10[0] : !llvm.struct<(i32, i32)> + %12 = llvm.extractvalue %10[1] : !llvm.struct<(i32, i32)> + %13 = llvm.add %11, %12 : i32 + llvm.return %13 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/phi-int2ptr-fold.ll.mlir b/test/LLVMDialect/InstCombine/phi-int2ptr-fold.ll.mlir index 504da5855..ead3221cd 100644 --- a/test/LLVMDialect/InstCombine/phi-int2ptr-fold.ll.mlir +++ b/test/LLVMDialect/InstCombine/phi-int2ptr-fold.ll.mlir @@ -1,77 +1,65 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>, %arg2: i1): // no predecessors - "llvm.cond_br"(%arg2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<64> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<16> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @func(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i1) -> i64 { + llvm.cond_br %arg2, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %0 = "llvm.ptrtoint"(%arg0) : (!llvm.ptr>) -> i64 - %1 = "llvm.inttoptr"(%0) : (i64) -> !llvm.ptr - "llvm.br"(%1)[^bb3] : (!llvm.ptr) -> () + %0 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %1 = llvm.inttoptr %0 : i64 to !llvm.ptr + llvm.br ^bb3(%1 : !llvm.ptr) ^bb2: // pred: ^bb0 - %2 = "llvm.ptrtoint"(%arg1) : (!llvm.ptr>) -> i64 - %3 = "llvm.inttoptr"(%2) : (i64) -> !llvm.ptr - "llvm.br"(%3)[^bb3] : (!llvm.ptr) -> () - ^bb3(%4: !llvm.ptr): // 2 preds: ^bb1, ^bb2 - %5 = "llvm.ptrtoint"(%4) : (!llvm.ptr) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "func", type = !llvm.func>, ptr>, i1)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>, %arg2: i1): // no predecessors - %0 = "llvm.bitcast"(%arg1) : (!llvm.ptr>) -> !llvm.ptr - "llvm.cond_br"(%arg2, %0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, !llvm.ptr) -> () + %2 = llvm.ptrtoint %arg1 : !llvm.ptr to i64 + %3 = llvm.inttoptr %2 : i64 to !llvm.ptr + llvm.br ^bb3(%3 : !llvm.ptr) + ^bb3(%4: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + %5 = llvm.ptrtoint %4 : !llvm.ptr to i64 + llvm.return %5 : i64 + } + llvm.func @func_single_operand(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i1) -> i64 { + llvm.cond_br %arg2, ^bb1, ^bb2(%arg1 : !llvm.ptr) ^bb1: // pred: ^bb0 - %1 = "llvm.ptrtoint"(%arg0) : (!llvm.ptr>) -> i64 - %2 = "llvm.inttoptr"(%1) : (i64) -> !llvm.ptr - "llvm.br"(%2)[^bb2] : (!llvm.ptr) -> () - ^bb2(%3: !llvm.ptr): // 2 preds: ^bb0, ^bb1 - %4 = "llvm.ptrtoint"(%3) : (!llvm.ptr) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "func_single_operand", type = !llvm.func>, ptr>, i1)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>, %arg2: i1): // no predecessors - %0 = "llvm.bitcast"(%arg1) : (!llvm.ptr>) -> !llvm.ptr - "llvm.cond_br"(%arg2, %0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, !llvm.ptr) -> () + %0 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %1 = llvm.inttoptr %0 : i64 to !llvm.ptr + llvm.br ^bb2(%1 : !llvm.ptr) + ^bb2(%2: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %3 = llvm.ptrtoint %2 : !llvm.ptr to i64 + llvm.return %3 : i64 + } + llvm.func @func_pointer_different_types(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i1) -> i64 { + llvm.cond_br %arg2, ^bb1, ^bb2(%arg1 : !llvm.ptr) ^bb1: // pred: ^bb0 - %1 = "llvm.ptrtoint"(%arg0) : (!llvm.ptr>) -> i64 - %2 = "llvm.inttoptr"(%1) : (i64) -> !llvm.ptr - "llvm.br"(%2)[^bb2] : (!llvm.ptr) -> () - ^bb2(%3: !llvm.ptr): // 2 preds: ^bb0, ^bb1 - %4 = "llvm.ptrtoint"(%3) : (!llvm.ptr) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "func_pointer_different_types", type = !llvm.func>, ptr>, i1)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>, %arg2: i1): // no predecessors - %0 = "llvm.bitcast"(%arg1) : (!llvm.ptr>) -> !llvm.ptr - "llvm.cond_br"(%arg2, %0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, !llvm.ptr) -> () + %0 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %1 = llvm.inttoptr %0 : i64 to !llvm.ptr + llvm.br ^bb2(%1 : !llvm.ptr) + ^bb2(%2: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %3 = llvm.ptrtoint %2 : !llvm.ptr to i64 + llvm.return %3 : i64 + } + llvm.func @func_integer_type_too_small(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i1) -> i64 { + llvm.cond_br %arg2, ^bb1, ^bb2(%arg1 : !llvm.ptr) ^bb1: // pred: ^bb0 - %1 = "llvm.ptrtoint"(%arg0) : (!llvm.ptr>) -> i32 - %2 = "llvm.inttoptr"(%1) : (i32) -> !llvm.ptr - "llvm.br"(%2)[^bb2] : (!llvm.ptr) -> () - ^bb2(%3: !llvm.ptr): // 2 preds: ^bb0, ^bb1 - %4 = "llvm.ptrtoint"(%3) : (!llvm.ptr) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "func_integer_type_too_small", type = !llvm.func>, ptr>, i1)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>, %arg2: i1): // no predecessors - %0 = "llvm.bitcast"(%arg1) : (!llvm.ptr>) -> !llvm.ptr - "llvm.cond_br"(%arg2, %0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, !llvm.ptr) -> () + %0 = llvm.ptrtoint %arg0 : !llvm.ptr to i32 + %1 = llvm.inttoptr %0 : i32 to !llvm.ptr + llvm.br ^bb2(%1 : !llvm.ptr) + ^bb2(%2: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %3 = llvm.ptrtoint %2 : !llvm.ptr to i64 + llvm.return %3 : i64 + } + llvm.func @func_phi_not_use_in_ptr2int(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i1) -> !llvm.ptr { + llvm.cond_br %arg2, ^bb1, ^bb2(%arg1 : !llvm.ptr) ^bb1: // pred: ^bb0 - %1 = "llvm.ptrtoint"(%arg0) : (!llvm.ptr>) -> i32 - %2 = "llvm.inttoptr"(%1) : (i32) -> !llvm.ptr - "llvm.br"(%2)[^bb2] : (!llvm.ptr) -> () - ^bb2(%3: !llvm.ptr): // 2 preds: ^bb0, ^bb1 - "llvm.return"(%3) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "func_phi_not_use_in_ptr2int", type = !llvm.func (ptr>, ptr>, i1)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr>, %arg2: i1): // no predecessors - %0 = "llvm.bitcast"(%arg1) : (!llvm.ptr>) -> !llvm.ptr - "llvm.cond_br"(%arg2, %0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, !llvm.ptr) -> () + %0 = llvm.ptrtoint %arg0 : !llvm.ptr to i32 + %1 = llvm.inttoptr %0 : i32 to !llvm.ptr + llvm.br ^bb2(%1 : !llvm.ptr) + ^bb2(%2: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + llvm.return %2 : !llvm.ptr + } + llvm.func @func_ptr_different_addrspace(%arg0: !llvm.ptr<2>, %arg1: !llvm.ptr, %arg2: i1) -> i64 { + llvm.cond_br %arg2, ^bb1, ^bb2(%arg1 : !llvm.ptr) ^bb1: // pred: ^bb0 - %1 = "llvm.ptrtoint"(%arg0) : (!llvm.ptr) -> i64 - %2 = "llvm.inttoptr"(%1) : (i64) -> !llvm.ptr - "llvm.br"(%2)[^bb2] : (!llvm.ptr) -> () - ^bb2(%3: !llvm.ptr): // 2 preds: ^bb0, ^bb1 - %4 = "llvm.ptrtoint"(%3) : (!llvm.ptr) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "func_ptr_different_addrspace", type = !llvm.func, ptr>, i1)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %0 = llvm.ptrtoint %arg0 : !llvm.ptr<2> to i64 + %1 = llvm.inttoptr %0 : i64 to !llvm.ptr + llvm.br ^bb2(%1 : !llvm.ptr) + ^bb2(%2: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %3 = llvm.ptrtoint %2 : !llvm.ptr to i64 + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/phi-known-bits-operand-order.ll.mlir b/test/LLVMDialect/InstCombine/phi-known-bits-operand-order.ll.mlir index 6a030a67d..7045bf046 100644 --- a/test/LLVMDialect/InstCombine/phi-known-bits-operand-order.ll.mlir +++ b/test/LLVMDialect/InstCombine/phi-known-bits-operand-order.ll.mlir @@ -1,45 +1,43 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "cond", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 99 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.br"(%2)[^bb1] : (i32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @cond() -> i1 + llvm.func @phi_recurrence_start_first() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(99 : i32) : i32 + llvm.br ^bb1(%0 : i32) ^bb1(%3: i32): // 2 preds: ^bb0, ^bb4 - %4 = "llvm.call"() {callee = @cond, fastmathFlags = #llvm.fastmath<>} : () -> i1 - "llvm.cond_br"(%4)[^bb2, ^bb5] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %4 = llvm.call @cond() : () -> i1 + llvm.cond_br %4, ^bb2, ^bb5 ^bb2: // pred: ^bb1 - %5 = "llvm.add"(%3, %1) : (i32, i32) -> i32 - "llvm.cond_br"(%4, %5)[^bb3, ^bb4] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i32) -> () + %5 = llvm.add %3, %1 overflow : i32 + llvm.cond_br %4, ^bb3(%5 : i32), ^bb4 ^bb3(%6: i32): // 2 preds: ^bb2, ^bb3 - %7 = "llvm.icmp"(%6, %0) {predicate = 3 : i64} : (i32, i32) -> i1 - %8 = "llvm.add"(%6, %1) : (i32, i32) -> i32 - "llvm.cond_br"(%7, %8)[^bb3, ^bb5] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i32) -> () + %7 = llvm.icmp "sle" %6, %2 : i32 + %8 = llvm.add %6, %1 overflow : i32 + llvm.cond_br %7, ^bb3(%8 : i32), ^bb5 ^bb4: // pred: ^bb2 - "llvm.br"(%5)[^bb1] : (i32) -> () + llvm.br ^bb1(%5 : i32) ^bb5: // 2 preds: ^bb1, ^bb3 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "phi_recurrence_start_first", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 99 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.br"(%2)[^bb1] : (i32) -> () + llvm.return + } + llvm.func @phi_recurrence_step_first() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(99 : i32) : i32 + llvm.br ^bb1(%0 : i32) ^bb1(%3: i32): // 2 preds: ^bb0, ^bb4 - %4 = "llvm.call"() {callee = @cond, fastmathFlags = #llvm.fastmath<>} : () -> i1 - "llvm.cond_br"(%4)[^bb2, ^bb5] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %4 = llvm.call @cond() : () -> i1 + llvm.cond_br %4, ^bb2, ^bb5 ^bb2: // pred: ^bb1 - %5 = "llvm.add"(%3, %1) : (i32, i32) -> i32 - "llvm.cond_br"(%4, %5)[^bb3, ^bb4] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i32) -> () + %5 = llvm.add %3, %1 overflow : i32 + llvm.cond_br %4, ^bb3(%5 : i32), ^bb4 ^bb3(%6: i32): // 2 preds: ^bb2, ^bb3 - %7 = "llvm.icmp"(%6, %0) {predicate = 3 : i64} : (i32, i32) -> i1 - %8 = "llvm.add"(%6, %1) : (i32, i32) -> i32 - "llvm.cond_br"(%7, %8)[^bb3, ^bb5] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i32) -> () + %7 = llvm.icmp "sle" %6, %2 : i32 + %8 = llvm.add %6, %1 overflow : i32 + llvm.cond_br %7, ^bb3(%8 : i32), ^bb5 ^bb4: // pred: ^bb2 - "llvm.br"(%5)[^bb1] : (i32) -> () + llvm.br ^bb1(%5 : i32) ^bb5: // 2 preds: ^bb1, ^bb3 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "phi_recurrence_step_first", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/phi-load-metadata-2.ll.mlir b/test/LLVMDialect/InstCombine/phi-load-metadata-2.ll.mlir index 7d7fe5327..45fcdc870 100644 --- a/test/LLVMDialect/InstCombine/phi-load-metadata-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/phi-load-metadata-2.ll.mlir @@ -1,21 +1,17 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "baz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: !llvm.ptr>, %arg2: !llvm.ptr>): // no predecessors - "llvm.cond_br"(%arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bar() + llvm.func @baz() + llvm.func @test_phi_combine_load_metadata(%arg0: i1, %arg1: !llvm.ptr {llvm.dereferenceable = 8 : i64}, %arg2: !llvm.ptr {llvm.dereferenceable = 8 : i64}) -> !llvm.ptr { + llvm.cond_br %arg0, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.call"() {callee = @bar, fastmathFlags = #llvm.fastmath<>} : () -> () - %0 = "llvm.load"(%arg1) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%0)[^bb3] : (!llvm.ptr) -> () + llvm.call @bar() : () -> () + %0 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%0 : !llvm.ptr) ^bb2: // pred: ^bb0 - "llvm.call"() {callee = @baz, fastmathFlags = #llvm.fastmath<>} : () -> () - %1 = "llvm.load"(%arg2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%1)[^bb3] : (!llvm.ptr) -> () - ^bb3(%2: !llvm.ptr): // 2 preds: ^bb1, ^bb2 - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_phi_combine_load_metadata", type = !llvm.func (i1, ptr>, ptr>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.call @baz() : () -> () + %1 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%1 : !llvm.ptr) + ^bb3(%2: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/phi-load-metadata-3.ll.mlir b/test/LLVMDialect/InstCombine/phi-load-metadata-3.ll.mlir index 7d7fe5327..816e1a478 100644 --- a/test/LLVMDialect/InstCombine/phi-load-metadata-3.ll.mlir +++ b/test/LLVMDialect/InstCombine/phi-load-metadata-3.ll.mlir @@ -1,21 +1,17 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "baz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: !llvm.ptr>, %arg2: !llvm.ptr>): // no predecessors - "llvm.cond_br"(%arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bar() + llvm.func @baz() + llvm.func @test_phi_combine_load_metadata(%arg0: i1, %arg1: !llvm.ptr {llvm.dereferenceable = 8 : i64}, %arg2: !llvm.ptr {llvm.dereferenceable = 8 : i64}) -> !llvm.ptr { + llvm.cond_br %arg0, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.call"() {callee = @bar, fastmathFlags = #llvm.fastmath<>} : () -> () - %0 = "llvm.load"(%arg1) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%0)[^bb3] : (!llvm.ptr) -> () + llvm.call @bar() : () -> () + %0 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%0 : !llvm.ptr) ^bb2: // pred: ^bb0 - "llvm.call"() {callee = @baz, fastmathFlags = #llvm.fastmath<>} : () -> () - %1 = "llvm.load"(%arg2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%1)[^bb3] : (!llvm.ptr) -> () - ^bb3(%2: !llvm.ptr): // 2 preds: ^bb1, ^bb2 - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_phi_combine_load_metadata", type = !llvm.func (i1, ptr>, ptr>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.call @baz() : () -> () + %1 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%1 : !llvm.ptr) + ^bb3(%2: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/phi-load-metadata-4.ll.mlir b/test/LLVMDialect/InstCombine/phi-load-metadata-4.ll.mlir new file mode 100644 index 000000000..318be83d8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/phi-load-metadata-4.ll.mlir @@ -0,0 +1,30 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bar() + llvm.func @baz() + llvm.func @test_phi_combine_load_metadata(%arg0: i1, %arg1: !llvm.ptr {llvm.dereferenceable = 8 : i64}, %arg2: !llvm.ptr {llvm.dereferenceable = 8 : i64}) -> !llvm.ptr { + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @bar() : () -> () + %0 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%0 : !llvm.ptr) + ^bb2: // pred: ^bb0 + llvm.call @baz() : () -> () + %1 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%1 : !llvm.ptr) + ^bb3(%2: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.ptr + } + llvm.func @test_phi_combine_load_metadata_negative(%arg0: i1, %arg1: !llvm.ptr {llvm.dereferenceable = 8 : i64}, %arg2: !llvm.ptr {llvm.dereferenceable = 8 : i64}) -> !llvm.ptr { + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @bar() : () -> () + %0 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%0 : !llvm.ptr) + ^bb2: // pred: ^bb0 + llvm.call @baz() : () -> () + %1 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%1 : !llvm.ptr) + ^bb3(%2: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/phi-load-metadata-dominance.ll.mlir b/test/LLVMDialect/InstCombine/phi-load-metadata-dominance.ll.mlir index 5159bef2e..926ccaf60 100644 --- a/test/LLVMDialect/InstCombine/phi-load-metadata-dominance.ll.mlir +++ b/test/LLVMDialect/InstCombine/phi-load-metadata-dominance.ll.mlir @@ -1,21 +1,17 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "baz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: !llvm.ptr>, %arg2: !llvm.ptr>): // no predecessors - "llvm.cond_br"(%arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bar() + llvm.func @baz() + llvm.func @test_combine_metadata_dominance(%arg0: i1, %arg1: !llvm.ptr {llvm.dereferenceable = 8 : i64}, %arg2: !llvm.ptr {llvm.dereferenceable = 8 : i64}) -> !llvm.ptr { + llvm.cond_br %arg0, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.call"() {callee = @bar, fastmathFlags = #llvm.fastmath<>} : () -> () - %0 = "llvm.load"(%arg1) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%0)[^bb3] : (!llvm.ptr) -> () + llvm.call @bar() : () -> () + %0 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%0 : !llvm.ptr) ^bb2: // pred: ^bb0 - "llvm.call"() {callee = @baz, fastmathFlags = #llvm.fastmath<>} : () -> () - %1 = "llvm.load"(%arg2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%1)[^bb3] : (!llvm.ptr) -> () - ^bb3(%2: !llvm.ptr): // 2 preds: ^bb1, ^bb2 - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_combine_metadata_dominance", type = !llvm.func (i1, ptr>, ptr>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.call @baz() : () -> () + %1 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%1 : !llvm.ptr) + ^bb3(%2: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/phi-load-metadata.ll.mlir b/test/LLVMDialect/InstCombine/phi-load-metadata.ll.mlir index 7d7fe5327..4ce03c57f 100644 --- a/test/LLVMDialect/InstCombine/phi-load-metadata.ll.mlir +++ b/test/LLVMDialect/InstCombine/phi-load-metadata.ll.mlir @@ -1,21 +1,17 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "baz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: !llvm.ptr>, %arg2: !llvm.ptr>): // no predecessors - "llvm.cond_br"(%arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bar() + llvm.func @baz() + llvm.func @test_phi_combine_load_metadata(%arg0: i1, %arg1: !llvm.ptr {llvm.dereferenceable = 8 : i64}, %arg2: !llvm.ptr {llvm.dereferenceable = 8 : i64}) -> !llvm.ptr { + llvm.cond_br %arg0, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.call"() {callee = @bar, fastmathFlags = #llvm.fastmath<>} : () -> () - %0 = "llvm.load"(%arg1) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%0)[^bb3] : (!llvm.ptr) -> () + llvm.call @bar() : () -> () + %0 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%0 : !llvm.ptr) ^bb2: // pred: ^bb0 - "llvm.call"() {callee = @baz, fastmathFlags = #llvm.fastmath<>} : () -> () - %1 = "llvm.load"(%arg2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%1)[^bb3] : (!llvm.ptr) -> () - ^bb3(%2: !llvm.ptr): // 2 preds: ^bb1, ^bb2 - "llvm.return"(%2) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test_phi_combine_load_metadata", type = !llvm.func (i1, ptr>, ptr>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.call @baz() : () -> () + %1 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%1 : !llvm.ptr) + ^bb3(%2: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/phi-merge-gep.ll.mlir b/test/LLVMDialect/InstCombine/phi-merge-gep.ll.mlir new file mode 100644 index 000000000..6e99ac6f2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/phi-merge-gep.ll.mlir @@ -0,0 +1,84 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: i64, %arg6: i64) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.mlir.constant(-1.500000e+00 : f32) : f32 + %3 = llvm.mlir.constant(0.866025388 : f32) : f32 + %4 = llvm.mlir.constant(1 : i64) : i64 + %5 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %6 = llvm.getelementptr inbounds %arg1[%0] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %7 = llvm.mul %arg6, %arg2 : i64 + %8 = llvm.getelementptr inbounds %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %9 = llvm.mul %arg6, %arg2 : i64 + %10 = llvm.getelementptr inbounds %arg1[%9] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %11 = llvm.mul %arg6, %1 : i64 + %12 = llvm.mul %11, %arg2 : i64 + %13 = llvm.getelementptr inbounds %arg0[%12] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %14 = llvm.mul %arg6, %1 : i64 + %15 = llvm.mul %14, %arg2 : i64 + %16 = llvm.getelementptr inbounds %arg1[%15] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %17 = llvm.getelementptr inbounds %arg3[%0] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %18 = llvm.getelementptr inbounds %arg4[%0] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %19 = llvm.mul %arg6, %arg5 : i64 + %20 = llvm.getelementptr inbounds %arg3[%19] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %21 = llvm.mul %arg6, %arg5 : i64 + %22 = llvm.getelementptr inbounds %arg4[%21] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %23 = llvm.mul %arg6, %1 : i64 + %24 = llvm.mul %23, %arg5 : i64 + %25 = llvm.getelementptr inbounds %arg3[%24] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %26 = llvm.mul %arg6, %1 : i64 + %27 = llvm.mul %26, %arg5 : i64 + %28 = llvm.getelementptr inbounds %arg4[%27] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + llvm.br ^bb2(%0, %28, %25, %22, %20, %18, %17, %16, %13, %10, %8, %6, %5 : i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) + ^bb1: // pred: ^bb2 + %29 = llvm.load %76 {alignment = 4 : i64} : !llvm.ptr -> f32 + %30 = llvm.load %75 {alignment = 4 : i64} : !llvm.ptr -> f32 + %31 = llvm.load %74 {alignment = 4 : i64} : !llvm.ptr -> f32 + %32 = llvm.load %73 {alignment = 4 : i64} : !llvm.ptr -> f32 + %33 = llvm.load %72 {alignment = 4 : i64} : !llvm.ptr -> f32 + %34 = llvm.load %71 {alignment = 4 : i64} : !llvm.ptr -> f32 + %35 = llvm.fadd %31, %33 : f32 + %36 = llvm.fadd %32, %34 : f32 + %37 = llvm.fsub %31, %33 : f32 + %38 = llvm.fsub %32, %34 : f32 + %39 = llvm.fadd %29, %35 : f32 + %40 = llvm.fadd %30, %36 : f32 + %41 = llvm.fmul %35, %2 : f32 + %42 = llvm.fmul %36, %2 : f32 + %43 = llvm.fadd %39, %41 : f32 + %44 = llvm.fadd %40, %42 : f32 + %45 = llvm.fmul %37, %3 : f32 + %46 = llvm.fmul %38, %3 : f32 + %47 = llvm.fadd %43, %46 : f32 + %48 = llvm.fsub %44, %45 : f32 + %49 = llvm.fsub %43, %46 : f32 + %50 = llvm.fadd %44, %45 : f32 + llvm.store %39, %70 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %40, %69 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %47, %68 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %48, %67 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %49, %66 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %50, %65 {alignment = 4 : i64} : f32, !llvm.ptr + %51 = llvm.getelementptr inbounds %76[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %52 = llvm.getelementptr inbounds %75[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %53 = llvm.getelementptr inbounds %74[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %54 = llvm.getelementptr inbounds %73[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %55 = llvm.getelementptr inbounds %72[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %56 = llvm.getelementptr inbounds %71[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %57 = llvm.getelementptr inbounds %70[%arg5] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %58 = llvm.getelementptr inbounds %69[%arg5] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %59 = llvm.getelementptr inbounds %68[%arg5] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %60 = llvm.getelementptr inbounds %67[%arg5] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %61 = llvm.getelementptr inbounds %66[%arg5] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %62 = llvm.getelementptr inbounds %65[%arg5] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %63 = llvm.add %64, %4 overflow : i64 + llvm.br ^bb2(%63, %62, %61, %60, %59, %58, %57, %56, %55, %54, %53, %52, %51 : i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) + ^bb2(%64: i64, %65: !llvm.ptr, %66: !llvm.ptr, %67: !llvm.ptr, %68: !llvm.ptr, %69: !llvm.ptr, %70: !llvm.ptr, %71: !llvm.ptr, %72: !llvm.ptr, %73: !llvm.ptr, %74: !llvm.ptr, %75: !llvm.ptr, %76: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %77 = llvm.icmp "slt" %64, %arg6 : i64 + llvm.cond_br %77, ^bb1, ^bb3 + ^bb3: // pred: ^bb2 + llvm.br ^bb4 + ^bb4: // pred: ^bb3 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/phi-of-insertvalues.ll.mlir b/test/LLVMDialect/InstCombine/phi-of-insertvalues.ll.mlir new file mode 100644 index 000000000..97f1ce32f --- /dev/null +++ b/test/LLVMDialect/InstCombine/phi-of-insertvalues.ll.mlir @@ -0,0 +1,133 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @usei32i32agg(!llvm.struct<(i32, i32)>) + llvm.func @test0(%arg0: !llvm.struct<(i32, i32)>, %arg1: i32, %arg2: i32, %arg3: i1) -> !llvm.struct<(i32, i32)> { + llvm.cond_br %arg3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.insertvalue %arg1, %arg0[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%0 : !llvm.struct<(i32, i32)>) + ^bb2: // pred: ^bb0 + %1 = llvm.insertvalue %arg2, %arg0[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%1 : !llvm.struct<(i32, i32)>) + ^bb3(%2: !llvm.struct<(i32, i32)>): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.struct<(i32, i32)> + } + llvm.func @test1_extrause0(%arg0: !llvm.struct<(i32, i32)>, %arg1: i32, %arg2: i32, %arg3: i1) -> !llvm.struct<(i32, i32)> { + llvm.cond_br %arg3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.insertvalue %arg1, %arg0[0] : !llvm.struct<(i32, i32)> + llvm.call @usei32i32agg(%0) : (!llvm.struct<(i32, i32)>) -> () + llvm.br ^bb3(%0 : !llvm.struct<(i32, i32)>) + ^bb2: // pred: ^bb0 + %1 = llvm.insertvalue %arg2, %arg0[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%1 : !llvm.struct<(i32, i32)>) + ^bb3(%2: !llvm.struct<(i32, i32)>): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.struct<(i32, i32)> + } + llvm.func @test2_extrause1(%arg0: !llvm.struct<(i32, i32)>, %arg1: i32, %arg2: i32, %arg3: i1) -> !llvm.struct<(i32, i32)> { + llvm.cond_br %arg3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.insertvalue %arg1, %arg0[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%0 : !llvm.struct<(i32, i32)>) + ^bb2: // pred: ^bb0 + %1 = llvm.insertvalue %arg2, %arg0[0] : !llvm.struct<(i32, i32)> + llvm.call @usei32i32agg(%1) : (!llvm.struct<(i32, i32)>) -> () + llvm.br ^bb3(%1 : !llvm.struct<(i32, i32)>) + ^bb3(%2: !llvm.struct<(i32, i32)>): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.struct<(i32, i32)> + } + llvm.func @test3_extrause2(%arg0: !llvm.struct<(i32, i32)>, %arg1: i32, %arg2: i32, %arg3: i1) -> !llvm.struct<(i32, i32)> { + llvm.cond_br %arg3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.insertvalue %arg1, %arg0[0] : !llvm.struct<(i32, i32)> + llvm.call @usei32i32agg(%0) : (!llvm.struct<(i32, i32)>) -> () + llvm.br ^bb3(%0 : !llvm.struct<(i32, i32)>) + ^bb2: // pred: ^bb0 + %1 = llvm.insertvalue %arg2, %arg0[0] : !llvm.struct<(i32, i32)> + llvm.call @usei32i32agg(%1) : (!llvm.struct<(i32, i32)>) -> () + llvm.br ^bb3(%1 : !llvm.struct<(i32, i32)>) + ^bb3(%2: !llvm.struct<(i32, i32)>): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.struct<(i32, i32)> + } + llvm.func @test4(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i32, %arg3: i1) -> !llvm.struct<(i32, i32)> { + llvm.cond_br %arg3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.insertvalue %arg2, %arg0[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%0 : !llvm.struct<(i32, i32)>) + ^bb2: // pred: ^bb0 + %1 = llvm.insertvalue %arg2, %arg1[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%1 : !llvm.struct<(i32, i32)>) + ^bb3(%2: !llvm.struct<(i32, i32)>): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.struct<(i32, i32)> + } + llvm.func @test5(%arg0: !llvm.struct<(i32, i32)>, %arg1: !llvm.struct<(i32, i32)>, %arg2: i32, %arg3: i32, %arg4: i1) -> !llvm.struct<(i32, i32)> { + llvm.cond_br %arg4, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.insertvalue %arg2, %arg0[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%0 : !llvm.struct<(i32, i32)>) + ^bb2: // pred: ^bb0 + %1 = llvm.insertvalue %arg3, %arg1[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%1 : !llvm.struct<(i32, i32)>) + ^bb3(%2: !llvm.struct<(i32, i32)>): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.struct<(i32, i32)> + } + llvm.func @test6(%arg0: !llvm.struct<(i32, i32)>, %arg1: i32, %arg2: i32, %arg3: i1) -> !llvm.struct<(i32, i32)> { + llvm.cond_br %arg3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.insertvalue %arg1, %arg0[0] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%0 : !llvm.struct<(i32, i32)>) + ^bb2: // pred: ^bb0 + %1 = llvm.insertvalue %arg2, %arg0[1] : !llvm.struct<(i32, i32)> + llvm.br ^bb3(%1 : !llvm.struct<(i32, i32)>) + ^bb3(%2: !llvm.struct<(i32, i32)>): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.struct<(i32, i32)> + } + llvm.func @test7(%arg0: !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>, %arg1: i32, %arg2: i32, %arg3: i1) -> !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> { + llvm.cond_br %arg3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.insertvalue %arg1, %arg0[0, 0] : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> + llvm.br ^bb3(%0 : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>) + ^bb2: // pred: ^bb0 + %1 = llvm.insertvalue %arg2, %arg0[0, 0] : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> + llvm.br ^bb3(%1 : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>) + ^bb3(%2: !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> + } + llvm.func @test8(%arg0: !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>, %arg1: i32, %arg2: i32, %arg3: i1) -> !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> { + llvm.cond_br %arg3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %0 = llvm.insertvalue %arg1, %arg0[0, 0] : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> + llvm.br ^bb3(%0 : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>) + ^bb2: // pred: ^bb0 + %1 = llvm.insertvalue %arg2, %arg0[0, 1] : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> + llvm.br ^bb3(%1 : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>) + ^bb3(%2: !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)>): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : !llvm.struct<(struct<(i32, i32)>, struct<(i32, i32)>)> + } + llvm.func @test9(%arg0: !llvm.struct<(i32, i32)>, %arg1: i32, %arg2: i32, %arg3: i1, %arg4: i1) -> !llvm.struct<(i32, i32)> { + %0 = llvm.insertvalue %arg1, %arg0[0] : !llvm.struct<(i32, i32)> + %1 = llvm.insertvalue %arg2, %arg0[0] : !llvm.struct<(i32, i32)> + llvm.cond_br %arg3, ^bb4(%0 : !llvm.struct<(i32, i32)>), ^bb1 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg4, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.br ^bb4(%0 : !llvm.struct<(i32, i32)>) + ^bb3: // pred: ^bb1 + llvm.br ^bb4(%1 : !llvm.struct<(i32, i32)>) + ^bb4(%2: !llvm.struct<(i32, i32)>): // 3 preds: ^bb0, ^bb2, ^bb3 + llvm.return %2 : !llvm.struct<(i32, i32)> + } + llvm.func @test10(%arg0: !llvm.struct<(i32, i32)>, %arg1: i32, %arg2: i32, %arg3: i1, %arg4: i1) -> !llvm.struct<(i32, i32)> { + %0 = llvm.insertvalue %arg1, %arg0[0] : !llvm.struct<(i32, i32)> + %1 = llvm.insertvalue %arg2, %arg0[0] : !llvm.struct<(i32, i32)> + llvm.call @usei32i32agg(%0) : (!llvm.struct<(i32, i32)>) -> () + llvm.cond_br %arg3, ^bb4(%0 : !llvm.struct<(i32, i32)>), ^bb1 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg4, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.br ^bb4(%0 : !llvm.struct<(i32, i32)>) + ^bb3: // pred: ^bb1 + llvm.br ^bb4(%1 : !llvm.struct<(i32, i32)>) + ^bb4(%2: !llvm.struct<(i32, i32)>): // 3 preds: ^bb0, ^bb2, ^bb3 + llvm.return %2 : !llvm.struct<(i32, i32)> + } +} diff --git a/test/LLVMDialect/InstCombine/phi-pointercasts.ll.mlir b/test/LLVMDialect/InstCombine/phi-pointercasts.ll.mlir new file mode 100644 index 000000000..dae00b40c --- /dev/null +++ b/test/LLVMDialect/InstCombine/phi-pointercasts.ll.mlir @@ -0,0 +1,200 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_bitcast_1(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @use(%arg1) : (!llvm.ptr) -> () + llvm.br ^bb3(%arg1 : !llvm.ptr) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%arg1 : !llvm.ptr) + ^bb3(%1: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.store %0, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } + llvm.func @test_bitcast_2(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%arg1 : !llvm.ptr) + ^bb2: // pred: ^bb0 + llvm.call @use(%arg1) : (!llvm.ptr) -> () + llvm.br ^bb3(%arg1 : !llvm.ptr) + ^bb3(%1: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.store %0, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } + llvm.func @test_bitcast_3(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : !llvm.ptr) + ^bb2: // pred: ^bb0 + llvm.call @use(%1) : (!llvm.ptr) -> () + llvm.br ^bb3(%1 : !llvm.ptr) + ^bb3(%2: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.store %0, %2 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } + llvm.func @test_bitcast_loads_in_different_bbs(%arg0: i1, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.call @use(%1) : (!llvm.ptr) -> () + llvm.br ^bb3(%1 : !llvm.ptr) + ^bb2: // pred: ^bb0 + %2 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb3(%2 : !llvm.ptr) + ^bb3(%3: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.store %0, %3 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } + llvm.func @test_gep_1(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @use.i32(%arg1) : (!llvm.ptr) -> () + llvm.br ^bb3(%arg1 : !llvm.ptr) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%arg1 : !llvm.ptr) + ^bb3(%1: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test_bitcast_not_foldable(%arg0: i1, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%arg1 : !llvm.ptr) + ^bb2: // pred: ^bb0 + llvm.call @use(%arg2) : (!llvm.ptr) -> () + llvm.br ^bb3(%arg2 : !llvm.ptr) + ^bb3(%1: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.store %0, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } + llvm.func @test_bitcast_with_extra_use(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @use(%arg1) : (!llvm.ptr) -> () + llvm.br ^bb3(%arg1 : !llvm.ptr) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%arg1 : !llvm.ptr) + ^bb3(%1: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.store %0, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } + llvm.func @test_bitcast_different_bases(%arg0: i1, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @use(%arg1) : (!llvm.ptr) -> () + llvm.br ^bb3(%arg1 : !llvm.ptr) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%arg2 : !llvm.ptr) + ^bb3(%1: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.store %0, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } + llvm.func @test_bitcast_gep_chains(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @use(%arg1) : (!llvm.ptr) -> () + llvm.br ^bb3(%arg1 : !llvm.ptr) + ^bb2: // pred: ^bb0 + llvm.call @use.i32(%arg1) : (!llvm.ptr) -> () + llvm.br ^bb3(%arg1 : !llvm.ptr) + ^bb3(%1: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + llvm.store %0, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } + llvm.func @test_4_incoming_values_different_bases_1(%arg0: i32, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.switch %arg0 : i32, ^bb6 [ + 0: ^bb1, + 1: ^bb2, + 2: ^bb3, + 3: ^bb4 + ] + ^bb1: // pred: ^bb0 + llvm.call @use(%arg1) : (!llvm.ptr) -> () + llvm.br ^bb5(%arg1 : !llvm.ptr) + ^bb2: // pred: ^bb0 + llvm.br ^bb5(%arg2 : !llvm.ptr) + ^bb3: // pred: ^bb0 + llvm.br ^bb5(%arg1 : !llvm.ptr) + ^bb4: // pred: ^bb0 + llvm.br ^bb5(%arg1 : !llvm.ptr) + ^bb5(%1: !llvm.ptr): // 4 preds: ^bb1, ^bb2, ^bb3, ^bb4 + llvm.store %0, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + ^bb6: // pred: ^bb0 + llvm.return + } + llvm.func @test_4_incoming_values_different_bases_2(%arg0: i32, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.switch %arg0 : i32, ^bb6 [ + 0: ^bb1, + 1: ^bb2, + 2: ^bb3, + 3: ^bb4 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb5(%arg2 : !llvm.ptr) + ^bb2: // pred: ^bb0 + llvm.call @use(%arg1) : (!llvm.ptr) -> () + llvm.br ^bb5(%arg1 : !llvm.ptr) + ^bb3: // pred: ^bb0 + llvm.br ^bb5(%arg1 : !llvm.ptr) + ^bb4: // pred: ^bb0 + llvm.br ^bb5(%arg1 : !llvm.ptr) + ^bb5(%1: !llvm.ptr): // 4 preds: ^bb1, ^bb2, ^bb3, ^bb4 + llvm.store %0, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + ^bb6: // pred: ^bb0 + llvm.return + } + llvm.func @test_4_incoming_values_different_bases_3(%arg0: i32, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.switch %arg0 : i32, ^bb6 [ + 0: ^bb1, + 1: ^bb2, + 2: ^bb3, + 3: ^bb4 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb5(%arg1 : !llvm.ptr) + ^bb2: // pred: ^bb0 + llvm.br ^bb5(%arg1 : !llvm.ptr) + ^bb3: // pred: ^bb0 + llvm.call @use(%arg1) : (!llvm.ptr) -> () + llvm.br ^bb5(%arg1 : !llvm.ptr) + ^bb4: // pred: ^bb0 + llvm.br ^bb5(%arg2 : !llvm.ptr) + ^bb5(%1: !llvm.ptr): // 4 preds: ^bb1, ^bb2, ^bb3, ^bb4 + llvm.store %0, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + ^bb6: // pred: ^bb0 + llvm.return + } + llvm.func @test_addrspacecast_1(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.addrspacecast %arg1 : !llvm.ptr to !llvm.ptr<1> + %2 = llvm.addrspacecast %arg1 : !llvm.ptr to !llvm.ptr<1> + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : !llvm.ptr<1>) + ^bb2: // pred: ^bb0 + llvm.call @use.i8.addrspace1(%2) : (!llvm.ptr<1>) -> () + llvm.br ^bb3(%2 : !llvm.ptr<1>) + ^bb3(%3: !llvm.ptr<1>): // 2 preds: ^bb1, ^bb2 + llvm.store %0, %3 {alignment = 1 : i64} : i8, !llvm.ptr<1> + llvm.return + } + llvm.func @use(!llvm.ptr) + llvm.func @use.i32(!llvm.ptr) + llvm.func @use.i8.addrspace1(!llvm.ptr<1>) +} diff --git a/test/LLVMDialect/InstCombine/phi-preserve-ir-flags.ll.mlir b/test/LLVMDialect/InstCombine/phi-preserve-ir-flags.ll.mlir index d2e1a9455..d5058f8ed 100644 --- a/test/LLVMDialect/InstCombine/phi-preserve-ir-flags.ll.mlir +++ b/test/LLVMDialect/InstCombine/phi-preserve-ir-flags.ll.mlir @@ -1,53 +1,48 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: i1): // no predecessors - "llvm.cond_br"(%arg3)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 64 : i64>>} { + llvm.func @func1(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: i1) -> f32 { + llvm.cond_br %arg3, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %0 = "llvm.fsub"(%arg0, %arg1) : (f32, f32) -> f32 - "llvm.br"(%0)[^bb3] : (f32) -> () + %0 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.br ^bb3(%0 : f32) ^bb2: // pred: ^bb0 - %1 = "llvm.fsub"(%arg0, %arg2) : (f32, f32) -> f32 - "llvm.br"(%1)[^bb3] : (f32) -> () + %1 = llvm.fsub %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + llvm.br ^bb3(%1 : f32) ^bb3(%2: f32): // 2 preds: ^bb1, ^bb2 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "func1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: i1): // no predecessors - "llvm.cond_br"(%arg3)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.return %2 : f32 + } + llvm.func @func2(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: i1) -> f32 { + llvm.cond_br %arg3, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %0 = "llvm.fsub"(%arg0, %arg1) : (f32, f32) -> f32 - "llvm.br"(%0)[^bb3] : (f32) -> () + %0 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.br ^bb3(%0 : f32) ^bb2: // pred: ^bb0 - %1 = "llvm.fsub"(%arg0, %arg2) : (f32, f32) -> f32 - "llvm.br"(%1)[^bb3] : (f32) -> () + %1 = llvm.fsub %arg0, %arg2 : f32 + llvm.br ^bb3(%1 : f32) ^bb3(%2: f32): // 2 preds: ^bb1, ^bb2 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "func2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - "llvm.cond_br"(%arg3)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.return %2 : f32 + } + llvm.func @func3(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: i1) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + llvm.cond_br %arg3, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %1 = "llvm.fsub"(%arg0, %0) : (f32, f32) -> f32 - "llvm.br"(%1)[^bb3] : (f32) -> () + %1 = llvm.fsub %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.br ^bb3(%1 : f32) ^bb2: // pred: ^bb0 - %2 = "llvm.fsub"(%arg1, %0) : (f32, f32) -> f32 - "llvm.br"(%2)[^bb3] : (f32) -> () + %2 = llvm.fsub %arg1, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.br ^bb3(%2 : f32) ^bb3(%3: f32): // 2 preds: ^bb1, ^bb2 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "func3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - "llvm.cond_br"(%arg3)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.return %3 : f32 + } + llvm.func @func4(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: i1) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + llvm.cond_br %arg3, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %1 = "llvm.fsub"(%arg0, %0) : (f32, f32) -> f32 - "llvm.br"(%1)[^bb3] : (f32) -> () + %1 = llvm.fsub %arg0, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.br ^bb3(%1 : f32) ^bb2: // pred: ^bb0 - %2 = "llvm.fsub"(%arg1, %0) : (f32, f32) -> f32 - "llvm.br"(%2)[^bb3] : (f32) -> () + %2 = llvm.fsub %arg1, %0 : f32 + llvm.br ^bb3(%2 : f32) ^bb3(%3: f32): // 2 preds: ^bb1, ^bb2 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "func4", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %3 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/phi-select-constant.ll.mlir b/test/LLVMDialect/InstCombine/phi-select-constant.ll.mlir new file mode 100644 index 000000000..79dfd4434 --- /dev/null +++ b/test/LLVMDialect/InstCombine/phi-select-constant.ll.mlir @@ -0,0 +1,100 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global extern_weak @A() {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.mlir.global extern_weak @B() {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.func @foo(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.addressof @A : !llvm.ptr + %2 = llvm.mlir.addressof @B : !llvm.ptr + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + llvm.cond_br %arg0, ^bb2(%0 : i1), ^bb1 + ^bb1: // pred: ^bb0 + %5 = llvm.icmp "eq" %1, %2 : !llvm.ptr + llvm.br ^bb2(%5 : i1) + ^bb2(%6: i1): // 2 preds: ^bb0, ^bb1 + %7 = llvm.select %6, %3, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @vec1(%arg0: i1) -> vector<4xi64> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense<[true, true, false, false]> : vector<4xi1>) : vector<4xi1> + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.mlir.constant(dense<0> : vector<4xi64>) : vector<4xi64> + %6 = llvm.mlir.constant(dense<[124, 125, 126, 127]> : vector<4xi64>) : vector<4xi64> + llvm.cond_br %arg0, ^bb2(%1 : vector<4xi1>), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%3 : vector<4xi1>) + ^bb2(%7: vector<4xi1>): // 2 preds: ^bb0, ^bb1 + %8 = llvm.select %7, %5, %6 : vector<4xi1>, vector<4xi64> + llvm.return %8 : vector<4xi64> + } + llvm.func @vec2(%arg0: i1) -> vector<4xi64> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(dense<[true, false, true, false]> : vector<4xi1>) : vector<4xi1> + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.mlir.constant(dense<0> : vector<4xi64>) : vector<4xi64> + %6 = llvm.mlir.constant(dense<[124, 125, 126, 127]> : vector<4xi64>) : vector<4xi64> + llvm.cond_br %arg0, ^bb2(%1 : vector<4xi1>), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%3 : vector<4xi1>) + ^bb2(%7: vector<4xi1>): // 2 preds: ^bb0, ^bb1 + %8 = llvm.select %7, %5, %6 : vector<4xi1>, vector<4xi64> + llvm.return %8 : vector<4xi64> + } + llvm.func @vec3(%arg0: i1, %arg1: i1, %arg2: vector<2xi1>, %arg3: vector<2xi8>, %arg4: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(dense<[false, true]> : vector<2xi1>) : vector<2xi1> + %3 = llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : vector<2xi1> + llvm.cond_br %arg0, ^bb1, ^bb3(%2 : vector<2xi1>) + ^bb1: // pred: ^bb0 + llvm.cond_br %arg1, ^bb2, ^bb3(%3 : vector<2xi1>) + ^bb2: // pred: ^bb1 + llvm.br ^bb3(%arg2 : vector<2xi1>) + ^bb3(%4: vector<2xi1>): // 3 preds: ^bb0, ^bb1, ^bb2 + %5 = llvm.select %4, %arg3, %arg4 : vector<2xi1>, vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @PR48369(%arg0: i32, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.br ^bb1(%1 : i1) + ^bb1(%4: i1): // pred: ^bb0 + %5 = llvm.select %4, %2, %0 : i1, i32 + llvm.store %5, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb2 + ^bb2: // pred: ^bb1 + llvm.return + } + llvm.func @sink_to_unreachable_crash(%arg0: i1) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(5 : i16) : i16 + %2 = llvm.select %arg0, %0, %1 : i1, i16 + llvm.br ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb1 + llvm.br ^bb1 + } + llvm.func @phi_trans(%arg0: i1, %arg1: i1, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.add %arg2, %1 : i32 + %4 = llvm.shl %arg2, %1 : i32 + llvm.br ^bb3(%2, %3, %4 : i1, i32, i32) + ^bb2: // pred: ^bb0 + %5 = llvm.mul %arg2, %0 : i32 + %6 = llvm.lshr %arg2, %1 : i32 + llvm.br ^bb3(%arg1, %5, %6 : i1, i32, i32) + ^bb3(%7: i1, %8: i32, %9: i32): // 2 preds: ^bb1, ^bb2 + %10 = llvm.select %7, %8, %9 : i1, i32 + llvm.return %10 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/phi-shifts.ll.mlir b/test/LLVMDialect/InstCombine/phi-shifts.ll.mlir index d767de1b9..370b2b3e1 100644 --- a/test/LLVMDialect/InstCombine/phi-shifts.ll.mlir +++ b/test/LLVMDialect/InstCombine/phi-shifts.ll.mlir @@ -1,18 +1,16 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: !llvm.ptr, %arg2: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 170141183460469231731687303715884105727 : i128} : () -> i128 - %1 = "llvm.mlir.constant"() {value = 64 : i128} : () -> i128 - %2 = "llvm.mlir.constant"() {value = 18446744073709551616 : i128} : () -> i128 - %3 = "llvm.mlir.constant"() {value = 0 : i128} : () -> i128 - "llvm.cond_br"(%arg0, %3)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i128) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fuzz15217(%arg0: i1, %arg1: !llvm.ptr, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i128) : i128 + %1 = llvm.mlir.constant(18446744073709551616 : i128) : i128 + %2 = llvm.mlir.constant(64 : i128) : i128 + %3 = llvm.mlir.constant(170141183460469231731687303715884105727 : i128) : i128 + llvm.cond_br %arg0, ^bb2(%0 : i128), ^bb1 ^bb1: // pred: ^bb0 - "llvm.br"(%2)[^bb2] : (i128) -> () + llvm.br ^bb2(%1 : i128) ^bb2(%4: i128): // 2 preds: ^bb0, ^bb1 - %5 = "llvm.lshr"(%4, %1) : (i128, i128) -> i128 - %6 = "llvm.lshr"(%5, %0) : (i128, i128) -> i128 - %7 = "llvm.trunc"(%6) : (i128) -> i64 - "llvm.return"(%7) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fuzz15217", type = !llvm.func, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %5 = llvm.lshr %4, %2 : i128 + %6 = llvm.lshr %5, %3 : i128 + %7 = llvm.trunc %6 : i128 to i64 + llvm.return %7 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/phi-timeout.ll.mlir b/test/LLVMDialect/InstCombine/phi-timeout.ll.mlir index 213df9cd2..a67aa3d24 100644 --- a/test/LLVMDialect/InstCombine/phi-timeout.ll.mlir +++ b/test/LLVMDialect/InstCombine/phi-timeout.ll.mlir @@ -1,24 +1,21 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.undef"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 0 : i16} : () -> i16 - %3 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - "llvm.br"()[^bb1] : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 64 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @timeout(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.mlir.constant(-1 : i8) : i8 + llvm.br ^bb1 ^bb1: // 2 preds: ^bb0, ^bb3 - %4 = "llvm.getelementptr"(%arg0, %3) : (!llvm.ptr, i32) -> !llvm.ptr - %5 = "llvm.load"(%4) : (!llvm.ptr) -> i16 - %6 = "llvm.icmp"(%5, %2) {predicate = 0 : i64} : (i16, i16) -> i1 - "llvm.cond_br"(%6, %5)[^bb2, ^bb3] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i16) -> () + %3 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i16 + %4 = llvm.load %3 {alignment = 2 : i64} : !llvm.ptr -> i16 + %5 = llvm.icmp "eq" %4, %1 : i16 + llvm.cond_br %5, ^bb2, ^bb3(%4 : i16) ^bb2: // pred: ^bb1 - %7 = "llvm.load"(%4) : (!llvm.ptr) -> i16 - "llvm.br"(%7)[^bb3] : (i16) -> () - ^bb3(%8: i16): // 2 preds: ^bb1, ^bb2 - %9 = "llvm.trunc"(%8) : (i16) -> i8 - %10 = "llvm.add"(%9, %1) : (i8, i8) -> i8 - "llvm.store"(%10, %0) : (i8, !llvm.ptr) -> () - "llvm.br"()[^bb1] : () -> () - }) {linkage = 10 : i64, sym_name = "timeout", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %6 = llvm.load %3 {alignment = 2 : i64} : !llvm.ptr -> i16 + llvm.br ^bb3(%6 : i16) + ^bb3(%7: i16): // 2 preds: ^bb1, ^bb2 + %8 = llvm.trunc %7 : i16 to i8 + %9 = llvm.add %8, %2 : i8 + llvm.store %9, %arg1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.br ^bb1 + } +} diff --git a/test/LLVMDialect/InstCombine/phi.ll.mlir b/test/LLVMDialect/InstCombine/phi.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/pow-0.ll.mlir b/test/LLVMDialect/InstCombine/pow-0.ll.mlir new file mode 100644 index 000000000..90357dc11 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pow-0.ll.mlir @@ -0,0 +1,44 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @minus_zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @fast_zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @fast_minus_zero(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @vec_zero(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.pow(%arg0, %1) : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @vec_minus_zero(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%arg0, %0) : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @vec_fast_zero(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.pow(%arg0, %1) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @vec_fast_minus_zero(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<-0.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } +} diff --git a/test/LLVMDialect/InstCombine/pow-1.ll.mlir b/test/LLVMDialect/InstCombine/pow-1.ll.mlir new file mode 100644 index 000000000..f27b599ad --- /dev/null +++ b/test/LLVMDialect/InstCombine/pow-1.ll.mlir @@ -0,0 +1,363 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @powf(f32, f32) -> f32 + llvm.func @pow(f64, f64) -> f64 + llvm.func @test_simplify1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify1_noerrno(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify1v(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<1.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.intr.pow(%0, %arg0) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @test_simplify2(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify2_noerrno(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify2v(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<1.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%0, %arg0) : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @test_simplify3(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify3_noerrno(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify3n_noerrno(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(2.500000e-01 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify3v(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<2.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.intr.pow(%0, %arg0) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @test_simplify3vn(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<4.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%0, %arg0) : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @test_simplify4(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify4_noerrno(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify4n(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(8.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify4n_noerrno(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(8.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify4v(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<2.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%0, %arg0) : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @test_simplify4vn(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<5.000000e-01> : vector<2xf32>) : vector<2xf32> + %1 = llvm.intr.pow(%0, %arg0) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @test_simplify5(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify5_noerrno(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify5v(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.intr.pow(%arg0, %1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @test_simplify6(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify6_noerrno(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify6v(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf64>) : vector<2xf64> + %2 = llvm.intr.pow(%arg0, %1) : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @powf_libcall_half_ninf(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_libcall_half_ninf_noerrno(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_libcall_half_assume_ninf_noerrno(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %1 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %2 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %3 = llvm.fcmp "one" %2, %0 : f32 + "llvm.intr.assume"(%3) : (i1) -> () + %4 = llvm.call @powf(%arg0, %1) : (f32, f32) -> f32 + llvm.return %4 : f32 + } + llvm.func @powf_libcall_half_ninf_tail(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_libcall_half_ninf_tail_noerrno(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_libcall_half_ninf_musttail(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_libcall_half_ninf_musttail_noerrno(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_libcall_half_no_FMF(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_libcall_half_no_FMF_noerrno(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify9(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0xFF800000 : f32) : f32 + %1 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %2 = llvm.intr.pow(%0, %1) : (f32, f32) -> f32 + llvm.return %2 : f32 + } + llvm.func @test_simplify10(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0xFFF0000000000000 : f64) : f64 + %1 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %2 = llvm.intr.pow(%0, %1) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @test_simplify11(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify11_noerrno(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify11v(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<1.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.intr.pow(%arg0, %0) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @test_simplify12(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify12_noerrno(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify12v(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<1.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%arg0, %0) : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @pow2_strict(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow2_strict_noerrno(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow2_strictv(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<2.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.intr.pow(%arg0, %0) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @pow2_double_strict(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow2_double_strict_noerrno(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow2_double_strictv(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<2.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%arg0, %0) : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @pow2_fast(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow2_fast_noerrno(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_neg1_strict(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_neg1_strict_noerrno(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_neg1_strictv(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<-1.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.intr.pow(%arg0, %0) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @pow_neg1_double_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-1.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_neg1_double_fast_noerrno(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-1.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_neg1_double_fastv(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<-1.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @pow_intrinsic_half_no_FMF(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify18(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+01 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify18_noerrno(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+01 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify19(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+01 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify19_noerrno(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+01 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_libcall_powf_10_f32_noerrno(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+01 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_libcall_pow_10_f64_noerrno(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+01 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_pow_10_f16(%arg0: f16) -> f16 { + %0 = llvm.mlir.constant(1.000000e+01 : f16) : f16 + %1 = llvm.intr.pow(%0, %arg0) : (f16, f16) -> f16 + llvm.return %1 : f16 + } + llvm.func @test_pow_10_f32(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+01 : f32) : f32 + %1 = llvm.intr.pow(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_pow_10_f64(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+01 : f64) : f64 + %1 = llvm.intr.pow(%0, %arg0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_pow_10_fp128(%arg0: f128) -> f128 { + %0 = llvm.mlir.constant(1.000000e+01 : f64) : f64 + %1 = llvm.fpext %0 : f64 to f128 + %2 = llvm.intr.pow(%1, %arg0) : (f128, f128) -> f128 + llvm.return %2 : f128 + } + llvm.func @test_pow_10_bf16(%arg0: bf16) -> bf16 { + %0 = llvm.mlir.constant(1.000000e+01 : bf16) : bf16 + %1 = llvm.intr.pow(%0, %arg0) : (bf16, bf16) -> bf16 + llvm.return %1 : bf16 + } + llvm.func @test_pow_10_v2f16(%arg0: vector<2xf16>) -> vector<2xf16> { + %0 = llvm.mlir.constant(dense<1.000000e+01> : vector<2xf16>) : vector<2xf16> + %1 = llvm.intr.pow(%0, %arg0) : (vector<2xf16>, vector<2xf16>) -> vector<2xf16> + llvm.return %1 : vector<2xf16> + } + llvm.func @test_pow_10_v2f32(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<1.000000e+01> : vector<2xf32>) : vector<2xf32> + %1 = llvm.intr.pow(%0, %arg0) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @test_pow_10_v2f64(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<1.000000e+01> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%0, %arg0) : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @test_pow_10_v2bf16(%arg0: vector<2xbf16>) -> vector<2xbf16> { + %0 = llvm.mlir.constant(dense<1.000000e+01> : vector<2xbf16>) : vector<2xbf16> + %1 = llvm.intr.pow(%0, %arg0) : (vector<2xbf16>, vector<2xbf16>) -> vector<2xbf16> + llvm.return %1 : vector<2xbf16> + } +} diff --git a/test/LLVMDialect/InstCombine/pow-2.ll.mlir b/test/LLVMDialect/InstCombine/pow-2.ll.mlir index bb48b7e4c..c3e371cf9 100644 --- a/test/LLVMDialect/InstCombine/pow-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/pow-2.ll.mlir @@ -1,11 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "pow", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pow(f64, f64) -> f32 + llvm.func @test_no_simplify1(%arg0: f64) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) : (f64, f64) -> f32 + llvm.return %1 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/pow-3.ll.mlir b/test/LLVMDialect/InstCombine/pow-3.ll.mlir index 2a8622b0e..a5134694c 100644 --- a/test/LLVMDialect/InstCombine/pow-3.ll.mlir +++ b/test/LLVMDialect/InstCombine/pow-3.ll.mlir @@ -1,35 +1,27 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "pow", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_libcall", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "sqrt_intrinsic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.fpext"(%arg1) : (f32) -> f64 - %2 = "llvm.call"(%0, %1) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %3 = "llvm.fptrunc"(%2) : (f64) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "shrink_libcall", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.fpext"(%arg1) : (f32) -> f64 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %3 = "llvm.fptrunc"(%2) : (f64) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "shrink_intrinsic", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pow(f64, f64) -> f64 + llvm.func @sqrt_libcall(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sqrt_intrinsic(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @shrink_libcall(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @shrink_intrinsic(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/pow-4.ll.mlir b/test/LLVMDialect/InstCombine/pow-4.ll.mlir index 9f3b499fe..089cfa29b 100644 --- a/test/LLVMDialect/InstCombine/pow-4.ll.mlir +++ b/test/LLVMDialect/InstCombine/pow-4.ll.mlir @@ -1,125 +1,95 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.v2f64", type = !llvm.func (vector<2xf64>, vector<2xf64>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.v2f32", type = !llvm.func (vector<2xf32>, vector<2xf32>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.v4f32", type = !llvm.func (vector<4xf32>, vector<4xf32>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "pow", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4.000000e+00 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_4f", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1.500000e+01> : vector<2xf32>} : () -> vector<2xf32> - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.v2f32, fastmathFlags = #llvm.fastmath<>} : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> - "llvm.return"(%1) : (vector<2xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_15", type = !llvm.func (vector<2xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-7.000000e+00> : vector<2xf64>} : () -> vector<2xf64> - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> - "llvm.return"(%1) : (vector<2xf64>) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_neg_7", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1.900000e+01 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_neg_19", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.123000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_11_23", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3.200000e+01 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3.300000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_33", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.650000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_16_5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1.650000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_neg_16_5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_0_5_libcall", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_neg_0_5_libcall", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -8.500000e+00 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_neg_8_5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<7.500000e+00> : vector<2xf64>} : () -> vector<2xf64> - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> - "llvm.return"(%1) : (vector<2xf64>) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_7_5", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xf32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<3.500000e+00> : vector<4xf32>} : () -> vector<4xf32> - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.v4f32, fastmathFlags = #llvm.fastmath<>} : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - "llvm.return"(%1) : (vector<4xf32>) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify_3_5", type = !llvm.func (vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f64} : () -> f64 - %1 = "llvm.fpext"(%arg0) : (f32) -> f64 - %2 = "llvm.call"(%1, %0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %3 = "llvm.fptrunc"(%2) : (f64) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "shrink_pow_libcall_half", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -0.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "PR43233", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pow(f64, f64) -> f64 + llvm.func @test_simplify_3(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(3.000000e+00 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify_4f(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify_4(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(4.000000e+00 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify_15(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<1.500000e+01> : vector<2xf32>) : vector<2xf32> + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @test_simplify_neg_7(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<-7.000000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @test_simplify_neg_19(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-1.900000e+01 : f32) : f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify_11_23(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.123000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify_32(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(3.200000e+01 : f32) : f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify_33(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(3.300000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify_16_5(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.650000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify_neg_16_5(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-1.650000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify_0_5_libcall(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify_neg_0_5_libcall(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-5.000000e-01 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_simplify_neg_8_5(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-8.500000e+00 : f32) : f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @test_simplify_7_5(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<7.500000e+00> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @test_simplify_3_5(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<3.500000e+00> : vector<4xf32>) : vector<4xf32> + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> + llvm.return %1 : vector<4xf32> + } + llvm.func @shrink_pow_libcall_half(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.fpext %arg0 : f32 to f64 + %2 = llvm.call @pow(%1, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @PR43233(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/pow-cbrt.ll.mlir b/test/LLVMDialect/InstCombine/pow-cbrt.ll.mlir index d1bca3c61..3a733da96 100644 --- a/test/LLVMDialect/InstCombine/pow-cbrt.ll.mlir +++ b/test/LLVMDialect/InstCombine/pow-cbrt.ll.mlir @@ -1,83 +1,64 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.33333333333333331 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_third_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.333333343 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_intrinsic_third_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.33333333333333331 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_third_approx", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.333333343 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_intrinsic_third_approx", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.33333333333333331 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_third_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.333333343 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_libcall_third_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -0.33333333333333331 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_negthird_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -0.333333343 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_intrinsic_negthird_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -0.33333333333333331 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_negthird_approx", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -0.333333343 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_intrinsic_negthird_approx", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -0.33333333333333331 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_negthird_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -0.333333343 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_libcall_negthird_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "pow", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "powf", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pow_intrinsic_third_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.33333333333333331 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_intrinsic_third_fast(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.333333343 : f32) : f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_intrinsic_third_approx(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.33333333333333331 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_intrinsic_third_approx(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.333333343 : f32) : f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_libcall_third_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.33333333333333331 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_libcall_third_fast(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.333333343 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_intrinsic_negthird_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.33333333333333331 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_intrinsic_negthird_fast(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.333333343 : f32) : f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_intrinsic_negthird_approx(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.33333333333333331 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_intrinsic_negthird_approx(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.333333343 : f32) : f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_libcall_negthird_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.33333333333333331 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_libcall_negthird_fast(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.333333343 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow(f64, f64) -> f64 + llvm.func @powf(f32, f32) -> f32 +} diff --git a/test/LLVMDialect/InstCombine/pow-exp-nofastmath.ll.mlir b/test/LLVMDialect/InstCombine/pow-exp-nofastmath.ll.mlir index 97ef1666d..c2b60ae8a 100644 --- a/test/LLVMDialect/InstCombine/pow-exp-nofastmath.ll.mlir +++ b/test/LLVMDialect/InstCombine/pow-exp-nofastmath.ll.mlir @@ -1,13 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "mypow", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f64", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @mypow(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.call @exp(%arg0) : (f64) -> f64 + %1 = llvm.intr.pow(%0, %arg1) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @exp(f64) -> f64 +} diff --git a/test/LLVMDialect/InstCombine/pow-exp.ll.mlir b/test/LLVMDialect/InstCombine/pow-exp.ll.mlir index 1172efcf0..006d467fb 100644 --- a/test/LLVMDialect/InstCombine/pow-exp.ll.mlir +++ b/test/LLVMDialect/InstCombine/pow-exp.ll.mlir @@ -1,317 +1,250 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @expf, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %1 = "llvm.call"(%0, %arg1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_expf", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @expf, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %1 = "llvm.call"(%0, %arg1) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_expf_libcall", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_exp", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%0, %arg1) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_exp_not_intrinsic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f128, %arg1: f128): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @expl, fastmathFlags = #llvm.fastmath<>} : (f128) -> f128 - %1 = "llvm.call"(%0, %arg1) {callee = @llvm.pow.f128, fastmathFlags = #llvm.fastmath<>} : (f128, f128) -> f128 - "llvm.return"(%1) : (f128) -> () - }) {linkage = 10 : i64, sym_name = "powl_expl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f128, %arg1: f128): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @expl, fastmathFlags = #llvm.fastmath<>} : (f128) -> f128 - %1 = "llvm.call"(%0, %arg1) {callee = @llvm.pow.f128, fastmathFlags = #llvm.fastmath<>} : (f128, f128) -> f128 - "llvm.return"(%1) : (f128) -> () - }) {linkage = 10 : i64, sym_name = "powl_expl_not_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp2f, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %1 = "llvm.call"(%0, %arg1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp2f", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp2f, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %1 = "llvm.call"(%0, %arg1) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp2f_not_intrinsic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp2, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_exp2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp2, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%0, %arg1) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_exp2_libcall", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f128, %arg1: f128): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp2l, fastmathFlags = #llvm.fastmath<>} : (f128) -> f128 - %1 = "llvm.call"(%0, %arg1) {callee = @llvm.pow.f128, fastmathFlags = #llvm.fastmath<>} : (f128, f128) -> f128 - "llvm.return"(%1) : (f128) -> () - }) {linkage = 10 : i64, sym_name = "powl_exp2l", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f128, %arg1: f128): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp2l, fastmathFlags = #llvm.fastmath<>} : (f128) -> f128 - %1 = "llvm.call"(%0, %arg1) {callee = @llvm.pow.f128, fastmathFlags = #llvm.fastmath<>} : (f128, f128) -> f128 - "llvm.return"(%1) : (f128) -> () - }) {linkage = 10 : i64, sym_name = "powl_exp2l_not_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp10f, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %1 = "llvm.call"(%0, %arg1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp10f", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp10, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_exp10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f128, %arg1: f128): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @exp10l, fastmathFlags = #llvm.fastmath<>} : (f128) -> f128 - %1 = "llvm.call"(%0, %arg1) {callee = @llvm.pow.f128, fastmathFlags = #llvm.fastmath<>} : (f128, f128) -> f128 - "llvm.return"(%1) : (f128) -> () - }) {linkage = 10 : i64, sym_name = "pow_exp10l", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32, %arg2: !llvm.ptr): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @expf, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %1 = "llvm.call"(%0, %arg1) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.store"(%0, %arg2) : (f32, !llvm.ptr) -> () - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "reuse_fast", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f128, %arg1: f128, %arg2: !llvm.ptr): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @expl, fastmathFlags = #llvm.fastmath<>} : (f128) -> f128 - %1 = "llvm.call"(%0, %arg1) {callee = @powl, fastmathFlags = #llvm.fastmath<>} : (f128, f128) -> f128 - "llvm.store"(%0, %arg2) : (f128, !llvm.ptr) -> () - "llvm.return"(%1) : (f128) -> () - }) {linkage = 10 : i64, sym_name = "reuse_libcall", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg0) : (!llvm.ptr>) -> f64 - %1 = "llvm.call"(%0, %arg1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "function_pointer", type = !llvm.func>, f64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use_d", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use_f", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.69999999999999996 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ok_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.69999999999999996 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ok_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.770000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ok_base2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.010000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ok_base3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ok_ten_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2.1219957904712067E-314 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ok_denorm_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.699999988 : f32} : () -> f32 - %1 = "llvm.call"(%0, %arg0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_ok_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.770000e+01 : f32} : () -> f32 - %1 = "llvm.call"(%0, %arg0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_ok_base2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.010000e+01 : f32} : () -> f32 - %1 = "llvm.call"(%0, %arg0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_ok_base3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.000000e+01 : f32} : () -> f32 - %1 = "llvm.call"(%0, %arg0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_ok_ten_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2.295890e-41 : f32} : () -> f32 - %1 = "llvm.call"(%0, %arg0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_ok_denorm_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_zero_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -0.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_zero_base2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0x7FF0000000000000 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_inf_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0x7FF8000000000000 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_nan_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_negative_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.call"(%1) {callee = @use_d, fastmathFlags = #llvm.fastmath<>} : (f64) -> () - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_multiuse", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.69999999999999996 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ok_base_no_afn", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.69999999999999996 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ok_base_no_nnan", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.69999999999999996 : f64} : () -> f64 - %1 = "llvm.call"(%0, %arg0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_ok_base_no_ninf", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.000000e+00 : f32} : () -> f32 - %1 = "llvm.call"(%0, %arg0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_zero_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -0.000000e+00 : f32} : () -> f32 - %1 = "llvm.call"(%0, %arg0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_zero_base2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0x7F800000 : f32} : () -> f32 - %1 = "llvm.call"(%0, %arg0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_inf_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0x7FC00000 : f32} : () -> f32 - %1 = "llvm.call"(%0, %arg0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_nan_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4.000000e+00 : f32} : () -> f32 - %1 = "llvm.call"(%0, %arg0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_negative_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e+00 : f32} : () -> f32 - %1 = "llvm.call"(%0, %arg0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.call"(%1) {callee = @use_f, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_multiuse", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.699999988 : f32} : () -> f32 - %1 = "llvm.call"(%0, %arg0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_ok_base_no_afn", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f128): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4.17755552565261002676701084286649753E+1233 : f32} : () -> f128 - %1 = "llvm.call"(%0, %arg0) {callee = @powl, fastmathFlags = #llvm.fastmath<>} : (f128, f128) -> f128 - "llvm.return"(%1) : (f128) -> () - }) {linkage = 10 : i64, sym_name = "powl_long_dbl_no_fold", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "expf", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "expl", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp2f", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp2", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp2l", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp10f", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp10", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp10l", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "powf", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "pow", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "powl", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f128", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @powf_expf(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.call @expf(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %1 = llvm.intr.pow(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_expf_libcall(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.call @expf(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %1 = llvm.call @powf(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_exp(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.call @exp(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.intr.pow(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_exp_not_intrinsic(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.call @exp(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.call @pow(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powl_expl(%arg0: f128, %arg1: f128) -> f128 { + %0 = llvm.call @expl(%arg0) {fastmathFlags = #llvm.fastmath} : (f128) -> f128 + %1 = llvm.intr.pow(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f128, f128) -> f128 + llvm.return %1 : f128 + } + llvm.func @powl_expl_not_fast(%arg0: f128, %arg1: f128) -> f128 { + %0 = llvm.call @expl(%arg0) : (f128) -> f128 + %1 = llvm.intr.pow(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f128, f128) -> f128 + llvm.return %1 : f128 + } + llvm.func @powf_exp2f(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.call @exp2f(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %1 = llvm.intr.pow(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_exp2f_not_intrinsic(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.call @exp2f(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %1 = llvm.call @powf(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_exp2(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.call @exp2(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.intr.pow(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_exp2_libcall(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.call @exp2(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.call @pow(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powl_exp2l(%arg0: f128, %arg1: f128) -> f128 { + %0 = llvm.call @exp2l(%arg0) {fastmathFlags = #llvm.fastmath} : (f128) -> f128 + %1 = llvm.intr.pow(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f128, f128) -> f128 + llvm.return %1 : f128 + } + llvm.func @powl_exp2l_not_fast(%arg0: f128, %arg1: f128) -> f128 { + %0 = llvm.call @exp2l(%arg0) : (f128) -> f128 + %1 = llvm.intr.pow(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f128, f128) -> f128 + llvm.return %1 : f128 + } + llvm.func @powf_exp10f(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.call @exp10f(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %1 = llvm.intr.pow(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_exp10(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.call @exp10(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.intr.pow(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_exp10l(%arg0: f128, %arg1: f128) -> f128 { + %0 = llvm.call @exp10l(%arg0) {fastmathFlags = #llvm.fastmath} : (f128) -> f128 + %1 = llvm.intr.pow(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f128, f128) -> f128 + llvm.return %1 : f128 + } + llvm.func @reuse_fast(%arg0: f32, %arg1: f32, %arg2: !llvm.ptr) -> f32 { + %0 = llvm.call @expf(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %1 = llvm.call @powf(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.store %0, %arg2 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.return %1 : f32 + } + llvm.func @reuse_libcall(%arg0: f128, %arg1: f128, %arg2: !llvm.ptr) -> f128 { + %0 = llvm.call @expl(%arg0) : (f128) -> f128 + %1 = llvm.call @powl(%0, %arg1) : (f128, f128) -> f128 + llvm.store %0, %arg2 {alignment = 16 : i64} : f128, !llvm.ptr + llvm.return %1 : f128 + } + llvm.func @function_pointer(%arg0: !llvm.ptr, %arg1: f64) -> f64 { + %0 = llvm.call %arg0() {fastmathFlags = #llvm.fastmath} : !llvm.ptr, () -> f64 + %1 = llvm.intr.pow(%0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @use_d(f64) + llvm.func @use_f(f32) + llvm.func @pow_ok_base(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.69999999999999996 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_ok_base_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.69999999999999996 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_ok_base2(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.770000e+01 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_ok_base3(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.010000e+01 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_ok_ten_base(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+01 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_ok_denorm_base(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(2.1219957904712067E-314 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_ok_base(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.699999988 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_ok_base2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.770000e+01 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_ok_base3(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.010000e+01 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_ok_ten_base(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+01 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_ok_denorm_base(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(2.295890e-41 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_zero_base(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_zero_base2(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-0.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_inf_base(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0x7FF0000000000000 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_nan_base(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0x7FF8000000000000 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_negative_base(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-4.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_multiuse(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.call @use_d(%1) : (f64) -> () + llvm.return %1 : f64 + } + llvm.func @pow_ok_base_no_afn(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.69999999999999996 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_ok_base_no_nnan(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.69999999999999996 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_ok_base_no_ninf(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.69999999999999996 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_zero_base(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_zero_base2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_inf_base(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0x7F800000 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_nan_base(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0x7FC00000 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_negative_base(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-4.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powf_multiuse(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.call @use_f(%1) : (f32) -> () + llvm.return %1 : f32 + } + llvm.func @powf_ok_base_no_afn(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.699999988 : f32) : f32 + %1 = llvm.call @powf(%0, %arg0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @powl_long_dbl_no_fold(%arg0: f128) -> f128 { + %0 = llvm.mlir.constant(4.17755552565261002676701084286649753E+1233 : f128) : f128 + %1 = llvm.call @powl(%0, %arg0) {fastmathFlags = #llvm.fastmath} : (f128, f128) -> f128 + llvm.return %1 : f128 + } + llvm.func @expf(f32) -> f32 + llvm.func @exp(f64) -> f64 + llvm.func @expl(f128) -> f128 + llvm.func @exp2f(f32) -> f32 + llvm.func @exp2(f64) -> f64 + llvm.func @exp2l(f128) -> f128 + llvm.func @exp10f(f32) -> f32 + llvm.func @exp10(f64) -> f64 + llvm.func @exp10l(f128) -> f128 + llvm.func @powf(f32, f32) -> f32 + llvm.func @pow(f64, f64) -> f64 + llvm.func @powl(f128, f128) -> f128 +} diff --git a/test/LLVMDialect/InstCombine/pow-sqrt.ll.mlir b/test/LLVMDialect/InstCombine/pow-sqrt.ll.mlir index c9687835e..565f501f9 100644 --- a/test/LLVMDialect/InstCombine/pow-sqrt.ll.mlir +++ b/test/LLVMDialect/InstCombine/pow-sqrt.ll.mlir @@ -1,186 +1,145 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_half_no_FMF", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_half_no_FMF", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_half_approx", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<5.000000e-01> : vector<2xf64>} : () -> vector<2xf64> - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> - "llvm.return"(%1) : (vector<2xf64>) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_half_approx", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "powf_intrinsic_half_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f64} : () -> f64 - %1 = "llvm.uitofp"(%arg0) : (i32) -> f64 - %2 = "llvm.call"(%1, %0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_half_no_FMF_base_ninf", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_half_ninf", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<5.000000e-01> : vector<2xf64>} : () -> vector<2xf64> - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> - "llvm.return"(%1) : (vector<2xf64>) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_half_ninf", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_half_nsz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_half_nsz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_half_ninf_nsz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_half_ninf_nsz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_half_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_half_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5.000000e-01 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_neghalf_no_FMF", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5.000000e-01 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_neghalf_reassoc_ninf", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5.000000e-01 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_neghalf_afn", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-5.000000e-01> : vector<2xf64>} : () -> vector<2xf64> - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> - "llvm.return"(%1) : (vector<2xf64>) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_neghalf_no_FMF", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-5.000000e-01> : vector<2xf64>} : () -> vector<2xf64> - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> - "llvm.return"(%1) : (vector<2xf64>) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_neghalf_reassoc", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-5.000000e-01> : vector<2xf64>} : () -> vector<2xf64> - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> - "llvm.return"(%1) : (vector<2xf64>) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_neghalf_afn", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_neghalf_ninf", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xf64>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-5.000000e-01> : vector<2xf64>} : () -> vector<2xf64> - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.v2f64, fastmathFlags = #llvm.fastmath<>} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> - "llvm.return"(%1) : (vector<2xf64>) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_neghalf_ninf", type = !llvm.func (vector<2xf64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_neghalf_nsz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_neghalf_nsz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_neghalf_ninf_nsz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5.000000e-01 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_neghalf_ninf_nsz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5.000000e-01 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "pow_libcall_neghalf_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5.000000e-01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_intrinsic_neghalf_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.v2f64", type = !llvm.func (vector<2xf64>, vector<2xf64>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.v2f32", type = !llvm.func (vector<2xf32>, vector<2xf32>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.v4f32", type = !llvm.func (vector<4xf32>, vector<4xf32>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "pow", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "powf", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pow_libcall_half_no_FMF(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_intrinsic_half_no_FMF(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_libcall_half_approx(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_intrinsic_half_approx(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<5.000000e-01> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @powf_intrinsic_half_fast(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_libcall_half_no_FMF_base_ninf(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.uitofp %arg0 : i32 to f64 + %2 = llvm.call @pow(%1, %0) : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @pow_libcall_half_ninf(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_intrinsic_half_ninf(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<5.000000e-01> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @pow_libcall_half_nsz(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_intrinsic_half_nsz(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_libcall_half_ninf_nsz(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_intrinsic_half_ninf_nsz(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_libcall_half_fast(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_intrinsic_half_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5.000000e-01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_libcall_neghalf_no_FMF(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-5.000000e-01 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_libcall_neghalf_reassoc_ninf(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-5.000000e-01 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_libcall_neghalf_afn(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-5.000000e-01 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_intrinsic_neghalf_no_FMF(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<-5.000000e-01> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%arg0, %0) : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @pow_intrinsic_neghalf_reassoc(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<-5.000000e-01> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @pow_intrinsic_neghalf_afn(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<-5.000000e-01> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @pow_libcall_neghalf_ninf(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-5.000000e-01 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_intrinsic_neghalf_ninf(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<-5.000000e-01> : vector<2xf64>) : vector<2xf64> + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf64>, vector<2xf64>) -> vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @pow_libcall_neghalf_nsz(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-5.000000e-01 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_intrinsic_neghalf_nsz(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-5.000000e-01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_intrinsic_neghalf_ninf_nsz(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-5.000000e-01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_libcall_neghalf_ninf_nsz(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-5.000000e-01 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_libcall_neghalf_fast(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(-5.000000e-01 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @pow_intrinsic_neghalf_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-5.000000e-01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow(f64, f64) -> f64 + llvm.func @powf(f32, f32) -> f32 +} diff --git a/test/LLVMDialect/InstCombine/pow-to-ldexp.ll.mlir b/test/LLVMDialect/InstCombine/pow-to-ldexp.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/pow-to-sqrt.ll.mlir b/test/LLVMDialect/InstCombine/pow-to-sqrt.ll.mlir new file mode 100644 index 000000000..c73295030 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pow-to-sqrt.ll.mlir @@ -0,0 +1,8 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pow_to_sqrt(%arg0: f64) { + %0 = llvm.mlir.constant(1.500000e+00 : f64) : f64 + %1 = llvm.call @pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return + } + llvm.func @pow(f64 {llvm.noundef}, f64 {llvm.noundef}) -> f64 +} diff --git a/test/LLVMDialect/InstCombine/pow_fp_int.ll.mlir b/test/LLVMDialect/InstCombine/pow_fp_int.ll.mlir index a4648b120..2a1aee705 100644 --- a/test/LLVMDialect/InstCombine/pow_fp_int.ll.mlir +++ b/test/LLVMDialect/InstCombine/pow_fp_int.ll.mlir @@ -1,290 +1,252 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i32) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_const_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i31): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i31) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f64} : () -> f64 - %1 = "llvm.sitofp"(%arg0) : (i32) -> f64 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_double_const_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i31): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f64} : () -> f64 - %1 = "llvm.uitofp"(%arg0) : (i31) -> f64 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_double_const_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i32) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_double_const_base_2_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.600000e+01 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i32) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_double_const_base_power_of_2_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i31): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i31) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_2_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i31): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.600000e+01 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i31) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_power_of_2_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: i32): // no predecessors - %0 = "llvm.sitofp"(%arg1) : (i32) -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %2 = "llvm.fpext"(%1) : (f32) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_float_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: i31): // no predecessors - %0 = "llvm.uitofp"(%arg1) : (i31) -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %2 = "llvm.fpext"(%1) : (f32) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_float_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: i32): // no predecessors - %0 = "llvm.sitofp"(%arg1) : (i32) -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_double_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: i31): // no predecessors - %0 = "llvm.uitofp"(%arg1) : (i31) -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_double_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i8) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_const_base_fast_i8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_const_base_fast_i16", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i8) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_fast_i8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_fast_i16", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4.000000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp_const_int_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4.000000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp_const2_int_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i32) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_fast_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i32) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_2_fast_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.600000e+01 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i32) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_power_of_2_fast_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: i32): // no predecessors - %0 = "llvm.uitofp"(%arg1) : (i32) -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %2 = "llvm.fpext"(%1) : (f32) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_float_base_fast_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: i32): // no predecessors - %0 = "llvm.uitofp"(%arg1) : (i32) -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_double_base_fast_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i64) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_const_base_fast_i64", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i64) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_fast_i64", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i32) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_const_base_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i32) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i32) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_const_base_2_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.600000e+01 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i32) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_const_base_power_of_2_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i32) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_2_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.600000e+01 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i32) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_power_of_2_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: i32): // no predecessors - %0 = "llvm.sitofp"(%arg1) : (i32) -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %2 = "llvm.fpext"(%1) : (f32) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_float_base_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: i32): // no predecessors - %0 = "llvm.uitofp"(%arg1) : (i32) -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %2 = "llvm.fpext"(%1) : (f32) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_float_base_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: i32): // no predecessors - %0 = "llvm.sitofp"(%arg1) : (i32) -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_double_base_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: i32): // no predecessors - %0 = "llvm.uitofp"(%arg1) : (i32) -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_double_base_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4.000000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp_const_int_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3.750000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp_const_not_int_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3.750000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp_const_not_int_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4.000000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp_const2_int_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f64", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pow_sitofp_const_base_fast(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_fast(%arg0: i31) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i31 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_double_const_base_fast(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f64) : f64 + %1 = llvm.sitofp %arg0 : i32 to f64 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @pow_uitofp_double_const_base_fast(%arg0: i31) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f64) : f64 + %1 = llvm.uitofp %arg0 : i31 to f64 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @pow_sitofp_double_const_base_2_fast(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_double_const_base_power_of_2_fast(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(1.600000e+01 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_2_fast(%arg0: i31) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i31 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_power_of_2_fast(%arg0: i31) -> f64 { + %0 = llvm.mlir.constant(1.600000e+01 : f32) : f32 + %1 = llvm.uitofp %arg0 : i31 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_float_base_fast(%arg0: f32, %arg1: i32) -> f64 { + %0 = llvm.sitofp %arg1 : i32 to f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %2 = llvm.fpext %1 : f32 to f64 + llvm.return %2 : f64 + } + llvm.func @pow_uitofp_float_base_fast(%arg0: f32, %arg1: i31) -> f64 { + %0 = llvm.uitofp %arg1 : i31 to f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %2 = llvm.fpext %1 : f32 to f64 + llvm.return %2 : f64 + } + llvm.func @pow_sitofp_double_base_fast(%arg0: f64, %arg1: i32) -> f64 { + %0 = llvm.sitofp %arg1 : i32 to f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_uitofp_double_base_fast(%arg0: f64, %arg1: i31) -> f64 { + %0 = llvm.uitofp %arg1 : i31 to f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_sitofp_const_base_fast_i8(%arg0: i8) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i8 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_const_base_fast_i16(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_fast_i8(%arg0: i8) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i8 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_fast_i16(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @powf_exp_const_int_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(4.000000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_exp_const2_int_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-4.000000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_uitofp_const_base_fast_i32(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_2_fast_i32(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_power_of_2_fast_i32(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(1.600000e+01 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_float_base_fast_i32(%arg0: f32, %arg1: i32) -> f64 { + %0 = llvm.uitofp %arg1 : i32 to f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %2 = llvm.fpext %1 : f32 to f64 + llvm.return %2 : f64 + } + llvm.func @pow_uitofp_double_base_fast_i32(%arg0: f64, %arg1: i32) -> f64 { + %0 = llvm.uitofp %arg1 : i32 to f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_sitofp_const_base_fast_i64(%arg0: i64) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i64 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_fast_i64(%arg0: i64) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i64 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_const_base_no_fast(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.intr.pow(%0, %1) : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_no_fast(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.intr.pow(%0, %1) : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_const_base_2_no_fast(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.intr.pow(%0, %1) : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_const_base_power_of_2_no_fast(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(1.600000e+01 : f32) : f32 + %1 = llvm.sitofp %arg0 : i32 to f32 + %2 = llvm.intr.pow(%0, %1) : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_2_no_fast(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.intr.pow(%0, %1) : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_power_of_2_no_fast(%arg0: i32) -> f64 { + %0 = llvm.mlir.constant(1.600000e+01 : f32) : f32 + %1 = llvm.uitofp %arg0 : i32 to f32 + %2 = llvm.intr.pow(%0, %1) : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_float_base_no_fast(%arg0: f32, %arg1: i32) -> f64 { + %0 = llvm.sitofp %arg1 : i32 to f32 + %1 = llvm.intr.pow(%arg0, %0) : (f32, f32) -> f32 + %2 = llvm.fpext %1 : f32 to f64 + llvm.return %2 : f64 + } + llvm.func @pow_uitofp_float_base_no_fast(%arg0: f32, %arg1: i32) -> f64 { + %0 = llvm.uitofp %arg1 : i32 to f32 + %1 = llvm.intr.pow(%arg0, %0) : (f32, f32) -> f32 + %2 = llvm.fpext %1 : f32 to f64 + llvm.return %2 : f64 + } + llvm.func @pow_sitofp_double_base_no_fast(%arg0: f64, %arg1: i32) -> f64 { + %0 = llvm.sitofp %arg1 : i32 to f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_uitofp_double_base_no_fast(%arg0: f64, %arg1: i32) -> f64 { + %0 = llvm.uitofp %arg1 : i32 to f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_exp_const_int_no_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(4.000000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_exp_const_not_int_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(3.750000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_exp_const_not_int_no_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(3.750000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_exp_const2_int_no_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-4.000000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_sitofp_const_base_2_no_fast_vector(%arg0: vector<2xi8>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<2.000000e+00> : vector<2xf32>) : vector<2xf32> + %1 = llvm.sitofp %arg0 : vector<2xi8> to vector<2xf32> + %2 = llvm.intr.pow(%0, %1) : (vector<2xf32>, vector<2xf32>) -> vector<2xf32> + llvm.return %2 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/pow_fp_int16.ll.mlir b/test/LLVMDialect/InstCombine/pow_fp_int16.ll.mlir index 006707c1c..902bf9906 100644 --- a/test/LLVMDialect/InstCombine/pow_fp_int16.ll.mlir +++ b/test/LLVMDialect/InstCombine/pow_fp_int16.ll.mlir @@ -1,274 +1,232 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_const_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i15): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i15) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f64} : () -> f64 - %1 = "llvm.sitofp"(%arg0) : (i16) -> f64 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_double_const_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i15): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f64} : () -> f64 - %1 = "llvm.uitofp"(%arg0) : (i15) -> f64 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_double_const_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_double_const_base_2_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.600000e+01 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_double_const_base_power_of_2_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i15): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i15) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_2_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i15): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.600000e+01 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i15) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_power_of_2_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: i16): // no predecessors - %0 = "llvm.sitofp"(%arg1) : (i16) -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %2 = "llvm.fpext"(%1) : (f32) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_float_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: i15): // no predecessors - %0 = "llvm.uitofp"(%arg1) : (i15) -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %2 = "llvm.fpext"(%1) : (f32) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_float_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: i16): // no predecessors - %0 = "llvm.sitofp"(%arg1) : (i16) -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_double_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: i15): // no predecessors - %0 = "llvm.uitofp"(%arg1) : (i15) -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_double_base_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i8) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_const_base_fast_i8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_const_base_fast_i16", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i8) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_fast_i8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_afn_i16", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4.000000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp_const_int_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4.000000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp_const2_int_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_fast_i16", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_2_fast_i16", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.600000e+01 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_power_of_2_fast_i16", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: i16): // no predecessors - %0 = "llvm.uitofp"(%arg1) : (i16) -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %2 = "llvm.fpext"(%1) : (f32) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_float_base_fast_i16", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: i16): // no predecessors - %0 = "llvm.uitofp"(%arg1) : (i16) -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_double_base_fast_i16", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_const_base_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_const_base_2_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.600000e+01 : f32} : () -> f32 - %1 = "llvm.sitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_const_base_power_of_2_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_2_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1.600000e+01 : f32} : () -> f32 - %1 = "llvm.uitofp"(%arg0) : (i16) -> f32 - %2 = "llvm.call"(%0, %1) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %3 = "llvm.fpext"(%2) : (f32) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_const_base_power_of_2_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: i16): // no predecessors - %0 = "llvm.sitofp"(%arg1) : (i16) -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %2 = "llvm.fpext"(%1) : (f32) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_float_base_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: i16): // no predecessors - %0 = "llvm.uitofp"(%arg1) : (i16) -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f32, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - %2 = "llvm.fpext"(%1) : (f32) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_float_base_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: i16): // no predecessors - %0 = "llvm.sitofp"(%arg1) : (i16) -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_sitofp_double_base_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: i16): // no predecessors - %0 = "llvm.uitofp"(%arg1) : (i16) -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "pow_uitofp_double_base_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4.000000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp_const_int_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3.750000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp_const_not_int_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3.750000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp_const_not_int_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = -4.000000e+01 : f64} : () -> f64 - %1 = "llvm.call"(%arg0, %0) {callee = @llvm.pow.f64, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "powf_exp_const2_int_no_fast", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.pow.f64", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pow_sitofp_const_base_fast(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_fast(%arg0: i15) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i15 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_double_const_base_fast(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f64) : f64 + %1 = llvm.sitofp %arg0 : i16 to f64 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @pow_uitofp_double_const_base_fast(%arg0: i15) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f64) : f64 + %1 = llvm.uitofp %arg0 : i15 to f64 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %2 : f64 + } + llvm.func @pow_sitofp_double_const_base_2_fast(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_double_const_base_power_of_2_fast(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(1.600000e+01 : f32) : f32 + %1 = llvm.sitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_2_fast(%arg0: i15) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i15 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_power_of_2_fast(%arg0: i15) -> f64 { + %0 = llvm.mlir.constant(1.600000e+01 : f32) : f32 + %1 = llvm.uitofp %arg0 : i15 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_float_base_fast(%arg0: f32, %arg1: i16) -> f64 { + %0 = llvm.sitofp %arg1 : i16 to f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %2 = llvm.fpext %1 : f32 to f64 + llvm.return %2 : f64 + } + llvm.func @pow_uitofp_float_base_fast(%arg0: f32, %arg1: i15) -> f64 { + %0 = llvm.uitofp %arg1 : i15 to f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %2 = llvm.fpext %1 : f32 to f64 + llvm.return %2 : f64 + } + llvm.func @pow_sitofp_double_base_fast(%arg0: f64, %arg1: i16) -> f64 { + %0 = llvm.sitofp %arg1 : i16 to f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_uitofp_double_base_fast(%arg0: f64, %arg1: i15) -> f64 { + %0 = llvm.uitofp %arg1 : i15 to f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_sitofp_const_base_fast_i8(%arg0: i8) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i8 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_const_base_fast_i16(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_fast_i8(%arg0: i8) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i8 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_afn_i16(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @powf_exp_const_int_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(4.000000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_exp_const2_int_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-4.000000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_uitofp_const_base_fast_i16(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_2_fast_i16(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_power_of_2_fast_i16(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(1.600000e+01 : f32) : f32 + %1 = llvm.uitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_float_base_fast_i16(%arg0: f32, %arg1: i16) -> f64 { + %0 = llvm.uitofp %arg1 : i16 to f32 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %2 = llvm.fpext %1 : f32 to f64 + llvm.return %2 : f64 + } + llvm.func @pow_uitofp_double_base_fast_i16(%arg0: f64, %arg1: i16) -> f64 { + %0 = llvm.uitofp %arg1 : i16 to f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_sitofp_const_base_no_fast(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_no_fast(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_const_base_2_no_fast(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.sitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_const_base_power_of_2_no_fast(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(1.600000e+01 : f32) : f32 + %1 = llvm.sitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_2_no_fast(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.uitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_uitofp_const_base_power_of_2_no_fast(%arg0: i16) -> f64 { + %0 = llvm.mlir.constant(1.600000e+01 : f32) : f32 + %1 = llvm.uitofp %arg0 : i16 to f32 + %2 = llvm.intr.pow(%0, %1) : (f32, f32) -> f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @pow_sitofp_float_base_no_fast(%arg0: f32, %arg1: i16) -> f64 { + %0 = llvm.sitofp %arg1 : i16 to f32 + %1 = llvm.intr.pow(%arg0, %0) : (f32, f32) -> f32 + %2 = llvm.fpext %1 : f32 to f64 + llvm.return %2 : f64 + } + llvm.func @pow_uitofp_float_base_no_fast(%arg0: f32, %arg1: i16) -> f64 { + %0 = llvm.uitofp %arg1 : i16 to f32 + %1 = llvm.intr.pow(%arg0, %0) : (f32, f32) -> f32 + %2 = llvm.fpext %1 : f32 to f64 + llvm.return %2 : f64 + } + llvm.func @pow_sitofp_double_base_no_fast(%arg0: f64, %arg1: i16) -> f64 { + %0 = llvm.sitofp %arg1 : i16 to f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @pow_uitofp_double_base_no_fast(%arg0: f64, %arg1: i16) -> f64 { + %0 = llvm.uitofp %arg1 : i16 to f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_exp_const_int_no_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(4.000000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_exp_const_not_int_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(3.750000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_exp_const_not_int_no_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(3.750000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @powf_exp_const2_int_no_fast(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-4.000000e+01 : f64) : f64 + %1 = llvm.intr.pow(%arg0, %0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/powi.ll.mlir b/test/LLVMDialect/InstCombine/powi.ll.mlir new file mode 100644 index 000000000..1d30d8e26 --- /dev/null +++ b/test/LLVMDialect/InstCombine/powi.ll.mlir @@ -0,0 +1,265 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(f64) + llvm.func @powi_fneg_even_int(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.fneg %arg0 : f64 + %2 = llvm.intr.powi(%1, %0) : (f64, i32) -> f64 + llvm.return %2 : f64 + } + llvm.func @powi_fabs_even_int(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %2 = llvm.intr.powi(%1, %0) : (f64, i32) -> f64 + llvm.return %2 : f64 + } + llvm.func @powi_copysign_even_int(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.intr.copysign(%arg0, %arg1) : (f64, f64) -> f64 + %2 = llvm.intr.powi(%1, %0) : (f64, i32) -> f64 + llvm.return %2 : f64 + } + llvm.func @powi_fneg_odd_int(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.fneg %arg0 : f64 + %2 = llvm.intr.powi(%1, %0) : (f64, i32) -> f64 + llvm.return %2 : f64 + } + llvm.func @powi_fabs_odd_int(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.intr.fabs(%arg0) : (f64) -> f64 + %2 = llvm.intr.powi(%1, %0) : (f64, i32) -> f64 + llvm.return %2 : f64 + } + llvm.func @powi_copysign_odd_int(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.intr.copysign(%arg0, %arg1) : (f64, f64) -> f64 + %2 = llvm.intr.powi(%1, %0) : (f64, i32) -> f64 + llvm.return %2 : f64 + } + llvm.func @powi_fmul_arg0_no_reassoc(%arg0: f64, %arg1: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) : (f64, i32) -> f64 + %1 = llvm.fmul %0, %arg0 : f64 + llvm.return %1 : f64 + } + llvm.func @powi_fmul_arg0(%arg0: f64, %arg1: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) : (f64, i32) -> f64 + %1 = llvm.fmul %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %1 : f64 + } + llvm.func @powi_fmul_arg0_use(%arg0: f64, %arg1: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) : (f64, i32) -> f64 + llvm.call @use(%0) : (f64) -> () + %1 = llvm.fmul %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %1 : f64 + } + llvm.func @powi_fmul_powi_no_reassoc1(%arg0: f64, %arg1: i32, %arg2: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %1 = llvm.intr.powi(%arg0, %arg2) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fmul %1, %0 : f64 + llvm.return %2 : f64 + } + llvm.func @powi_fmul_powi_no_reassoc2(%arg0: f64, %arg1: i32, %arg2: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %1 = llvm.intr.powi(%arg0, %arg2) : (f64, i32) -> f64 + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @powi_fmul_powi_no_reassoc3(%arg0: f64, %arg1: i32, %arg2: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) : (f64, i32) -> f64 + %1 = llvm.intr.powi(%arg0, %arg2) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @powi_fmul_powi(%arg0: f64, %arg1: i32, %arg2: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %1 = llvm.intr.powi(%arg0, %arg2) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @powi_fmul_powi_fast_on_fmul(%arg0: f64, %arg1: i32, %arg2: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %1 = llvm.intr.powi(%arg0, %arg2) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @powi_fmul_powi_fast_on_powi(%arg0: f64, %arg1: i32, %arg2: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %1 = llvm.intr.powi(%arg0, %arg2) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fmul %1, %0 : f64 + llvm.return %2 : f64 + } + llvm.func @powi_fmul_powi_same_power(%arg0: f64, %arg1: i32, %arg2: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %1 = llvm.intr.powi(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @powi_fmul_powi_different_integer_types(%arg0: f64, %arg1: i32, %arg2: i16) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %1 = llvm.intr.powi(%arg0, %arg2) {fastmathFlags = #llvm.fastmath} : (f64, i16) -> f64 + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @powi_fmul_powi_use_first(%arg0: f64, %arg1: i32, %arg2: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + llvm.call @use(%0) : (f64) -> () + %1 = llvm.intr.powi(%arg0, %arg2) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @powi_fmul_powi_use_second(%arg0: f64, %arg1: i32, %arg2: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg2) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + llvm.call @use(%0) : (f64) -> () + %1 = llvm.intr.powi(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @powi_fmul_different_base(%arg0: f64, %arg1: f64, %arg2: i32, %arg3: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg2) : (f64, i32) -> f64 + %1 = llvm.intr.powi(%arg1, %arg3) : (f64, i32) -> f64 + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @different_types_powi(%arg0: f64, %arg1: i32, %arg2: i64) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) : (f64, i32) -> f64 + %1 = llvm.intr.powi(%arg0, %arg2) : (f64, i64) -> f64 + %2 = llvm.fmul %1, %0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_pow_powi(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fdiv %1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_powf_powi(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, i32) -> f32 + %2 = llvm.fdiv %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fdiv_pow_powi_multi_use(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) : (f64, i32) -> f64 + %2 = llvm.fdiv %1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.call @use(%1) : (f64) -> () + llvm.return %2 : f64 + } + llvm.func @fdiv_powf_powi_missing_reassoc(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) : (f32, i32) -> f32 + %2 = llvm.fdiv %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fdiv_powf_powi_missing_reassoc1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, i32) -> f32 + %2 = llvm.fdiv %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fdiv_powf_powi_missing_nnan(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) : (f32, i32) -> f32 + %2 = llvm.fdiv %1, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %2 : f32 + } + llvm.func @fdiv_pow_powi_negative(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) : (f64, i32) -> f64 + %2 = llvm.fdiv %1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_pow_powi_negative_variable(%arg0: f64, %arg1: i32) -> f64 { + %0 = llvm.intr.powi(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %1 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %1 : f64 + } + llvm.func @fdiv_fmul_powi(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fmul %arg1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fdiv %1, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %3 : f64 + } + llvm.func @fdiv_fmul_powi_2(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fdiv %1, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %3 : f64 + } + llvm.func @fdiv_fmul_powi_vector(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>, i32) -> vector<2xf32> + %2 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %3 = llvm.fdiv %1, %2 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @fdiv_fmul_powi_missing_reassoc1(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fdiv %1, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %3 : f64 + } + llvm.func @fdiv_fmul_powi_missing_reassoc2(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fmul %arg0, %arg0 : f64 + %3 = llvm.fdiv %1, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %3 : f64 + } + llvm.func @fdiv_fmul_powi_missing_reassoc3(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) : (f64, i32) -> f64 + %2 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fdiv %1, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %3 : f64 + } + llvm.func @fdiv_fmul_powi_missing_nnan(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fdiv %1, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %3 : f64 + } + llvm.func @fdiv_fmul_powi_negative_wrap(%arg0: f64 {llvm.noundef}) -> f64 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) : (f64, i32) -> f64 + %2 = llvm.fmul %1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @fdiv_fmul_powi_multi_use(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + llvm.call @use(%1) : (f64) -> () + %2 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %3 = llvm.fdiv %1, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %3 : f64 + } + llvm.func @powi_fmul_powi_x(%arg0: f64 {llvm.noundef}) -> f64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f64, i32) -> f64 + %2 = llvm.fmul %1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @powi_fmul_powi_x_multi_use(%arg0: f64 {llvm.noundef}) -> f64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) : (f64, i32) -> f64 + llvm.call @use(%1) : (f64) -> () + %2 = llvm.fmul %1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } + llvm.func @powi_fmul_powi_x_missing_reassoc(%arg0: f64 {llvm.noundef}) -> f64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) : (f64, i32) -> f64 + %2 = llvm.fmul %1, %arg0 : f64 + llvm.return %2 : f64 + } + llvm.func @powi_fmul_powi_x_overflow(%arg0: f64 {llvm.noundef}) -> f64 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.intr.powi(%arg0, %0) : (f64, i32) -> f64 + %2 = llvm.fmul %1, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %2 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/pr12251.ll.mlir b/test/LLVMDialect/InstCombine/pr12251.ll.mlir index d3a1285d2..20359f69c 100644 --- a/test/LLVMDialect/InstCombine/pr12251.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr12251.ll.mlir @@ -1,12 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %2 = "llvm.load"(%arg0) : (!llvm.ptr) -> i8 - %3 = "llvm.and"(%2, %1) : (i8, i8) -> i8 - %4 = "llvm.icmp"(%3, %0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "_Z3fooPb", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @_Z3fooPb(%arg0: !llvm.ptr {llvm.nocapture}) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %3 = llvm.and %2, %0 : i8 + %4 = llvm.icmp "ne" %3, %1 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/pr12338.ll.mlir b/test/LLVMDialect/InstCombine/pr12338.ll.mlir new file mode 100644 index 000000000..50c521e3c --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr12338.ll.mlir @@ -0,0 +1,17 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @entry() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<1xi32>) : vector<1xi32> + %2 = llvm.mlir.constant(dense<92> : vector<1xi32>) : vector<1xi32> + llvm.br ^bb1(%1 : vector<1xi32>) + ^bb1(%3: vector<1xi32>): // 2 preds: ^bb0, ^bb3 + %4 = llvm.sub %1, %3 : vector<1xi32> + llvm.br ^bb2(%4 : vector<1xi32>) + ^bb2(%5: vector<1xi32>): // pred: ^bb1 + llvm.br ^bb3 + ^bb3: // pred: ^bb2 + %6 = llvm.add %5, %2 : vector<1xi32> + %7 = llvm.sub %1, %6 : vector<1xi32> + llvm.br ^bb1(%7 : vector<1xi32>) + } +} diff --git a/test/LLVMDialect/InstCombine/pr14365.ll.mlir b/test/LLVMDialect/InstCombine/pr14365.ll.mlir index 6168da900..64b800afd 100644 --- a/test/LLVMDialect/InstCombine/pr14365.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr14365.ll.mlir @@ -1,49 +1,44 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1431655765 : i32} : () -> i32 - %3 = "llvm.and"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.xor"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.add"(%4, %0) : (i32, i32) -> i32 - %6 = "llvm.add"(%arg0, %5) : (i32, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1> : vector<4xi32>} : () -> vector<4xi32> - %1 = "llvm.mlir.constant"() {value = dense<-1> : vector<4xi32>} : () -> vector<4xi32> - %2 = "llvm.mlir.constant"() {value = dense<1431655765> : vector<4xi32>} : () -> vector<4xi32> - %3 = "llvm.and"(%arg0, %2) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - %4 = "llvm.xor"(%3, %1) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - %5 = "llvm.add"(%4, %0) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - %6 = "llvm.add"(%arg0, %5) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - "llvm.return"(%6) : (vector<4xi32>) -> () - }) {linkage = 10 : i64, sym_name = "test0_vec", type = !llvm.func (vector<4xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1431655765 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.ashr"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.and"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.xor"(%4, %0) : (i32, i32) -> i32 - %6 = "llvm.add"(%5, %2) : (i32, i32) -> i32 - %7 = "llvm.add"(%arg0, %6) : (i32, i32) -> i32 - "llvm.return"(%7) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-1> : vector<4xi32>} : () -> vector<4xi32> - %1 = "llvm.mlir.constant"() {value = dense<1431655765> : vector<4xi32>} : () -> vector<4xi32> - %2 = "llvm.mlir.constant"() {value = dense<1> : vector<4xi32>} : () -> vector<4xi32> - %3 = "llvm.ashr"(%arg0, %2) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - %4 = "llvm.and"(%3, %1) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - %5 = "llvm.xor"(%4, %0) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - %6 = "llvm.add"(%5, %2) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - %7 = "llvm.add"(%arg0, %6) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - "llvm.return"(%7) : (vector<4xi32>) -> () - }) {linkage = 10 : i64, sym_name = "test1_vec", type = !llvm.func (vector<4xi32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1431655765 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.add %4, %2 overflow : i32 + %6 = llvm.add %arg0, %5 overflow : i32 + llvm.return %6 : i32 + } + llvm.func @test0_vec(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<1431655765> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %3 = llvm.and %arg0, %0 : vector<4xi32> + %4 = llvm.xor %3, %1 : vector<4xi32> + %5 = llvm.add %4, %2 overflow : vector<4xi32> + %6 = llvm.add %arg0, %5 overflow : vector<4xi32> + llvm.return %6 : vector<4xi32> + } + llvm.func @test1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(1431655765 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.ashr %arg0, %0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.xor %4, %2 : i32 + %6 = llvm.add %5, %0 overflow : i32 + %7 = llvm.add %arg0, %6 overflow : i32 + llvm.return %7 : i32 + } + llvm.func @test1_vec(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<1431655765> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %3 = llvm.ashr %arg0, %0 : vector<4xi32> + %4 = llvm.and %3, %1 : vector<4xi32> + %5 = llvm.xor %4, %2 : vector<4xi32> + %6 = llvm.add %5, %0 overflow : vector<4xi32> + %7 = llvm.add %arg0, %6 overflow : vector<4xi32> + llvm.return %7 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/pr17827.ll.mlir b/test/LLVMDialect/InstCombine/pr17827.ll.mlir index 8f84eba8c..17bec1016 100644 --- a/test/LLVMDialect/InstCombine/pr17827.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr17827.ll.mlir @@ -1,91 +1,82 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = -64 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 5 : i8} : () -> i8 - %3 = "llvm.shl"(%arg0, %2) : (i8, i8) -> i8 - %4 = "llvm.and"(%3, %1) : (i8, i8) -> i8 - %5 = "llvm.icmp"(%4, %0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_shift_and_cmp_not_changed1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = -64 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 5 : i8} : () -> i8 - %3 = "llvm.ashr"(%arg0, %2) : (i8, i8) -> i8 - %4 = "llvm.and"(%3, %1) : (i8, i8) -> i8 - %5 = "llvm.icmp"(%4, %0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_shift_and_cmp_not_changed2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 5 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 8 : i8} : () -> i8 - %3 = "llvm.mlir.constant"() {value = 6 : i8} : () -> i8 - %4 = "llvm.and"(%arg0, %3) : (i8, i8) -> i8 - %5 = "llvm.and"(%arg1, %2) : (i8, i8) -> i8 - %6 = "llvm.or"(%5, %4) : (i8, i8) -> i8 - %7 = "llvm.shl"(%6, %1) : (i8, i8) -> i8 - %8 = "llvm.ashr"(%7, %1) : (i8, i8) -> i8 - %9 = "llvm.icmp"(%8, %0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%9) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_shift_and_cmp_changed1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.mlir.constant"() {value = dense<5> : vector<2xi8>} : () -> vector<2xi8> - %2 = "llvm.mlir.constant"() {value = dense<8> : vector<2xi8>} : () -> vector<2xi8> - %3 = "llvm.mlir.constant"() {value = dense<6> : vector<2xi8>} : () -> vector<2xi8> - %4 = "llvm.and"(%arg0, %3) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %5 = "llvm.and"(%arg1, %2) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %6 = "llvm.or"(%5, %4) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %7 = "llvm.shl"(%6, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %8 = "llvm.ashr"(%7, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %9 = "llvm.icmp"(%8, %0) {predicate = 2 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%9) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_shift_and_cmp_changed1_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = -64 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 5 : i8} : () -> i8 - %3 = "llvm.shl"(%arg0, %2) : (i8, i8) -> i8 - %4 = "llvm.and"(%3, %1) : (i8, i8) -> i8 - %5 = "llvm.icmp"(%4, %0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_shift_and_cmp_changed2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<32> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.mlir.constant"() {value = dense<-64> : vector<2xi8>} : () -> vector<2xi8> - %2 = "llvm.mlir.constant"() {value = dense<5> : vector<2xi8>} : () -> vector<2xi8> - %3 = "llvm.shl"(%arg0, %2) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %4 = "llvm.and"(%3, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %5 = "llvm.icmp"(%4, %0) {predicate = 6 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_shift_and_cmp_changed2_vec", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = -64 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 5 : i8} : () -> i8 - %3 = "llvm.shl"(%arg0, %2) : (i8, i8) -> i8 - %4 = "llvm.and"(%3, %1) : (i8, i8) -> i8 - %5 = "llvm.icmp"(%4, %0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_shift_and_cmp_changed3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = -64 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 5 : i8} : () -> i8 - %3 = "llvm.lshr"(%arg0, %2) : (i8, i8) -> i8 - %4 = "llvm.and"(%3, %1) : (i8, i8) -> i8 - %5 = "llvm.icmp"(%4, %0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test_shift_and_cmp_changed4", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_shift_and_cmp_not_changed1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-64 : i8) : i8 + %2 = llvm.mlir.constant(32 : i8) : i8 + %3 = llvm.shl %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.icmp "slt" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @test_shift_and_cmp_not_changed2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-64 : i8) : i8 + %2 = llvm.mlir.constant(32 : i8) : i8 + %3 = llvm.ashr %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.icmp "slt" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @test_shift_and_cmp_changed1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(8 : i8) : i8 + %2 = llvm.mlir.constant(5 : i8) : i8 + %3 = llvm.mlir.constant(1 : i8) : i8 + %4 = llvm.and %arg0, %0 : i8 + %5 = llvm.and %arg1, %1 : i8 + %6 = llvm.or %5, %4 : i8 + %7 = llvm.shl %6, %2 : i8 + %8 = llvm.ashr %7, %2 : i8 + %9 = llvm.icmp "slt" %8, %3 : i8 + llvm.return %9 : i1 + } + llvm.func @test_shift_and_cmp_changed1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<8> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %4 = llvm.and %arg0, %0 : vector<2xi8> + %5 = llvm.and %arg1, %1 : vector<2xi8> + %6 = llvm.or %5, %4 : vector<2xi8> + %7 = llvm.shl %6, %2 : vector<2xi8> + %8 = llvm.ashr %7, %2 : vector<2xi8> + %9 = llvm.icmp "slt" %8, %3 : vector<2xi8> + llvm.return %9 : vector<2xi1> + } + llvm.func @test_shift_and_cmp_changed2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-64 : i8) : i8 + %2 = llvm.mlir.constant(32 : i8) : i8 + %3 = llvm.shl %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.icmp "ult" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @test_shift_and_cmp_changed2_vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-64> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<32> : vector<2xi8>) : vector<2xi8> + %3 = llvm.shl %arg0, %0 : vector<2xi8> + %4 = llvm.and %3, %1 : vector<2xi8> + %5 = llvm.icmp "ult" %4, %2 : vector<2xi8> + llvm.return %5 : vector<2xi1> + } + llvm.func @test_shift_and_cmp_changed3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-64 : i8) : i8 + %2 = llvm.mlir.constant(32 : i8) : i8 + %3 = llvm.shl %arg0, %0 overflow : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.icmp "slt" %4, %2 : i8 + llvm.return %5 : i1 + } + llvm.func @test_shift_and_cmp_changed4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-64 : i8) : i8 + %2 = llvm.mlir.constant(32 : i8) : i8 + %3 = llvm.lshr %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.icmp "slt" %4, %2 : i8 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/pr20678.ll.mlir b/test/LLVMDialect/InstCombine/pr20678.ll.mlir new file mode 100644 index 000000000..68386ed9d --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr20678.ll.mlir @@ -0,0 +1,11 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1() -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(dense<[true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false]> : vector<16xi1>) : vector<16xi1> + %3 = llvm.bitcast %2 : vector<16xi1> to i16 + %4 = llvm.mlir.constant(0 : i16) : i16 + %5 = llvm.icmp "ne" %3, %4 : i16 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/pr21199.ll.mlir b/test/LLVMDialect/InstCombine/pr21199.ll.mlir new file mode 100644 index 000000000..bf6fa5c84 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr21199.ll.mlir @@ -0,0 +1,19 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @f(i32) + llvm.func @test(%arg0: i32) { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.select %3, %arg0, %0 : i1, i32 + %5 = llvm.icmp "ult" %1, %4 : i32 + llvm.cond_br %5, ^bb1(%1 : i32), ^bb2 + ^bb1(%6: i32): // 2 preds: ^bb0, ^bb1 + llvm.call @f(%4) : (i32) -> () + %7 = llvm.add %6, %2 : i32 + %8 = llvm.icmp "ult" %7, %4 : i32 + llvm.cond_br %8, ^bb1(%7 : i32), ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/pr21210.ll.mlir b/test/LLVMDialect/InstCombine/pr21210.ll.mlir new file mode 100644 index 000000000..050ea602f --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr21210.ll.mlir @@ -0,0 +1,38 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(i32) + llvm.func @bar(i32) -> i32 + llvm.func @test1(%arg0: i32) { + %0 = llvm.mlir.constant(8 : i32) : i32 + llvm.br ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb1 + %1 = llvm.icmp "ult" %arg0, %0 : i32 + %2 = llvm.select %1, %arg0, %0 : i1, i32 + llvm.call @foo(%2) : (i32) -> () + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.cond_br %3, ^bb2, ^bb1 + ^bb2: // pred: ^bb1 + llvm.return + } + llvm.func @test2(%arg0: i32) { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.mlir.undef : i32 + %4 = llvm.call @bar(%arg0) : (i32) -> i32 + %5 = llvm.icmp "ult" %arg0, %0 : i32 + llvm.cond_br %5, ^bb1, ^bb3(%4 : i32) + ^bb1: // pred: ^bb0 + %6 = llvm.icmp "ult" %4, %1 : i32 + %7 = llvm.select %6, %arg0, %2 : i1, i32 + %8 = llvm.icmp "eq" %7, %2 : i32 + llvm.cond_br %8, ^bb2, ^bb3(%7 : i32) + ^bb2: // pred: ^bb1 + llvm.call @foo(%arg0) : (i32) -> () + llvm.br ^bb3(%3 : i32) + ^bb3(%9: i32): // 3 preds: ^bb0, ^bb1, ^bb2 + llvm.br ^bb4 + ^bb4: // pred: ^bb3 + llvm.call @foo(%9) : (i32) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/pr21651.ll.mlir b/test/LLVMDialect/InstCombine/pr21651.ll.mlir new file mode 100644 index 000000000..f38b48129 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr21651.ll.mlir @@ -0,0 +1,11 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @PR21651() { + %0 = llvm.mlir.constant(0 : i2) : i2 + llvm.switch %0 : i2, ^bb1 [ + 0: ^bb1, + 1: ^bb1 + ] + ^bb1: // 3 preds: ^bb0, ^bb0, ^bb0 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/pr21891.ll.mlir b/test/LLVMDialect/InstCombine/pr21891.ll.mlir index 1343f9b2f..6c7183cee 100644 --- a/test/LLVMDialect/InstCombine/pr21891.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr21891.ll.mlir @@ -1,20 +1,16 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.undef"() : () -> i32 - %2 = "llvm.mlir.constant"() {value = true} : () -> i1 - %3 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %4 = "llvm.icmp"(%arg0, %3) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.call"(%4) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - "llvm.cond_br"(%2, %1)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i32) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.icmp "sgt" %arg0, %0 : i32 + "llvm.intr.assume"(%4) : (i1) -> () + llvm.cond_br %2, ^bb1, ^bb2(%1 : i32) ^bb1: // pred: ^bb0 - %5 = "llvm.shl"(%arg0, %0) : (i32, i32) -> i32 - "llvm.br"(%5)[^bb2] : (i32) -> () + %5 = llvm.shl %arg0, %3 overflow : i32 + llvm.br ^bb2(%5 : i32) ^bb2(%6: i32): // 2 preds: ^bb0, ^bb1 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.assume", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr23751.ll.mlir b/test/LLVMDialect/InstCombine/pr23751.ll.mlir index 78d37710d..4bda55091 100644 --- a/test/LLVMDialect/InstCombine/pr23751.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr23751.ll.mlir @@ -1,16 +1,14 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 5 : i64, sym_name = "d", type = i32, value = 0 : i32} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @d} : () -> !llvm.ptr - %2 = "llvm.zext"(%arg0) : (i8) -> i32 - %3 = "llvm.load"(%1) : (!llvm.ptr) -> i32 - %4 = "llvm.or"(%3, %0) : (i32, i32) -> i32 - %5 = "llvm.add"(%4, %2) : (i32, i32) -> i32 - %6 = "llvm.icmp"(%2, %5) {predicate = 8 : i64} : (i32, i32) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @d(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.func @f(%arg0: i8 {llvm.zeroext}) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @d : !llvm.ptr + %2 = llvm.mlir.constant(-2 : i32) : i32 + %3 = llvm.zext %arg0 : i8 to i32 + %4 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + %5 = llvm.or %4, %2 : i32 + %6 = llvm.add %5, %3 overflow : i32 + %7 = llvm.icmp "ugt" %3, %6 : i32 + llvm.return %7 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/pr23809.ll.mlir b/test/LLVMDialect/InstCombine/pr23809.ll.mlir new file mode 100644 index 000000000..2afb49449 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr23809.ll.mlir @@ -0,0 +1,16 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @icmp(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.icmp "sge" %1, %0 : i32 + "llvm.intr.assume"(%2) : (i1) -> () + llvm.return %1 : i32 + } + llvm.func @fcmp(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fadd %arg0, %arg1 : f32 + %2 = llvm.fcmp "oge" %1, %0 : f32 + "llvm.intr.assume"(%2) : (i1) -> () + llvm.return %1 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr24354.ll.mlir b/test/LLVMDialect/InstCombine/pr24354.ll.mlir new file mode 100644 index 000000000..ed53136fa --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr24354.ll.mlir @@ -0,0 +1,35 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @c(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.mlir.global common @b(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.mlir.global common @a(0 : i16) {addr_space = 0 : i32, alignment = 2 : i64} : i16 + llvm.mlir.global common @d(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.func @fn3() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @c : !llvm.ptr + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(255 : i32) : i32 + %5 = llvm.mlir.constant(254 : i32) : i32 + %6 = llvm.mlir.constant(0 : i16) : i16 + %7 = llvm.mlir.addressof @a : !llvm.ptr + %8 = llvm.mlir.constant(false) : i1 + %9 = llvm.mlir.addressof @d : !llvm.ptr + %10 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + %11 = llvm.icmp "eq" %10, %0 : i32 + llvm.cond_br %11, ^bb1, ^bb2(%2 : i1) + ^bb1: // pred: ^bb0 + %12 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + %13 = llvm.add %4, %12 overflow : i32 + %14 = llvm.icmp "ugt" %13, %5 : i32 + llvm.br ^bb2(%14 : i1) + ^bb2(%15: i1): // 2 preds: ^bb0, ^bb1 + %16 = llvm.zext %15 : i1 to i32 + %17 = llvm.icmp "eq" %16, %0 : i32 + %18 = llvm.load %7 {alignment = 2 : i64} : !llvm.ptr -> i16 + %19 = llvm.icmp "ne" %18, %6 : i16 + %20 = llvm.select %17, %8, %19 : i1, i1 + %21 = llvm.zext %20 : i1 to i32 + llvm.store %21, %9 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/pr24605.ll.mlir b/test/LLVMDialect/InstCombine/pr24605.ll.mlir index a7b8b1e56..c3ae03afc 100644 --- a/test/LLVMDialect/InstCombine/pr24605.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr24605.ll.mlir @@ -1,13 +1,11 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = -117 : i8} : () -> i8 - %2 = "llvm.or"(%arg1, %1) : (i8, i8) -> i8 - %3 = "llvm.add"(%2, %0) : (i8, i8) -> i8 - "llvm.store"(%3, %arg0) : (i8, !llvm.ptr) -> () - %4 = "llvm.icmp"(%2, %3) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func, i8)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @f(%arg0: !llvm.ptr, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-117 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.or %arg1, %0 : i8 + %3 = llvm.add %2, %1 : i8 + llvm.store %3, %arg0 {alignment = 1 : i64} : i8, !llvm.ptr + %4 = llvm.icmp "ugt" %2, %3 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/pr25342.ll.mlir b/test/LLVMDialect/InstCombine/pr25342.ll.mlir new file mode 100644 index 000000000..bbe36b055 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr25342.ll.mlir @@ -0,0 +1,78 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @dd() {addr_space = 0 : i32, alignment = 4 : i64} : !llvm.struct<"struct.std::complex", (struct<(f32, f32)>)> + llvm.mlir.global external @dd2() {addr_space = 0 : i32, alignment = 4 : i64} : !llvm.struct<"struct.std::complex", (struct<(f32, f32)>)> + llvm.func @_Z3fooi(%arg0: i32 {llvm.signext}) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @dd : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.getelementptr inbounds %1[%3, 0, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct.std::complex", (struct<(f32, f32)>)> + %5 = llvm.mlir.addressof @dd2 : !llvm.ptr + %6 = llvm.getelementptr inbounds %5[%3, 0, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct.std::complex", (struct<(f32, f32)>)> + llvm.br ^bb1(%0, %0, %0 : i32, i32, i32) + ^bb1(%7: i32, %8: i32, %9: i32): // 2 preds: ^bb0, ^bb2 + %10 = llvm.icmp "slt" %9, %arg0 : i32 + llvm.cond_br %10, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %11 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> f32 + %12 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> f32 + %13 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> f32 + %14 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %15 = llvm.fmul %11, %13 : f32 + %16 = llvm.fmul %12, %14 : f32 + %17 = llvm.fsub %15, %16 : f32 + %18 = llvm.fmul %12, %13 : f32 + %19 = llvm.fmul %11, %14 : f32 + %20 = llvm.fadd %18, %19 : f32 + %21 = llvm.bitcast %7 : i32 to f32 + %22 = llvm.fadd %17, %21 : f32 + %23 = llvm.bitcast %22 : f32 to i32 + %24 = llvm.bitcast %8 : i32 to f32 + %25 = llvm.fadd %20, %24 : f32 + %26 = llvm.bitcast %25 : f32 to i32 + %27 = llvm.add %9, %2 overflow : i32 + llvm.br ^bb1(%23, %26, %27 : i32, i32, i32) + ^bb3: // pred: ^bb1 + llvm.store %7, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %8, %4 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @multi_phi(%arg0: i32 {llvm.signext}) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @dd : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.getelementptr inbounds %1[%3, 0, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct.std::complex", (struct<(f32, f32)>)> + %5 = llvm.mlir.addressof @dd2 : !llvm.ptr + %6 = llvm.getelementptr inbounds %5[%3, 0, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"struct.std::complex", (struct<(f32, f32)>)> + llvm.br ^bb1(%0, %0 : i32, i32) + ^bb1(%7: i32, %8: i32): // 2 preds: ^bb0, ^bb4 + %9 = llvm.icmp "slt" %8, %arg0 : i32 + llvm.cond_br %9, ^bb2, ^bb5 + ^bb2: // pred: ^bb1 + %10 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> f32 + %11 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> f32 + %12 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> f32 + %13 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> f32 + %14 = llvm.fmul %10, %12 : f32 + %15 = llvm.fmul %11, %13 : f32 + %16 = llvm.fsub %14, %15 : f32 + %17 = llvm.bitcast %7 : i32 to f32 + %18 = llvm.fadd %16, %17 : f32 + %19 = llvm.bitcast %18 : f32 to i32 + %20 = llvm.add %8, %2 overflow : i32 + %21 = llvm.and %20, %2 : i32 + %22 = llvm.icmp "slt" %21, %2 : i32 + llvm.cond_br %22, ^bb3, ^bb4(%19 : i32) + ^bb3: // pred: ^bb2 + %23 = llvm.bitcast %19 : i32 to f32 + %24 = llvm.fadd %16, %23 : f32 + %25 = llvm.bitcast %24 : f32 to i32 + llvm.br ^bb4(%25 : i32) + ^bb4(%26: i32): // 2 preds: ^bb2, ^bb3 + llvm.br ^bb1(%26, %20 : i32, i32) + ^bb5: // pred: ^bb1 + llvm.store %7, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/pr25745.ll.mlir b/test/LLVMDialect/InstCombine/pr25745.ll.mlir new file mode 100644 index 000000000..3279c11f8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr25745.ll.mlir @@ -0,0 +1,15 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use.i1(i1) + llvm.func @use.i64(i64) + llvm.func @f(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i32 to i64 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.sext %2 : i32 to i64 + %4 = llvm.icmp "slt" %arg0, %0 : i32 + %5 = llvm.select %4, %1, %3 : i1, i64 + llvm.call @use.i1(%4) : (i1) -> () + llvm.call @use.i64(%1) : (i64) -> () + llvm.return %5 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/pr2645-0-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/pr2645-0-inseltpoison.ll.mlir new file mode 100644 index 000000000..e554f1119 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr2645-0-inseltpoison.ll.mlir @@ -0,0 +1,30 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func internal @<>(%arg0: !llvm.ptr) attributes {dso_local} { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xf32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.poison : vector<4xf32> + %4 = llvm.mlir.constant(48 : i32) : i32 + %5 = llvm.mlir.constant(2 : i32) : i32 + %6 = llvm.bitcast %arg0 : !llvm.ptr to !llvm.ptr + %7 = llvm.load %6 {alignment = 1 : i64} : !llvm.ptr -> i32 + %8 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %9 = llvm.bitcast %8 : !llvm.ptr to !llvm.ptr + %10 = llvm.load %9 {alignment = 1 : i64} : !llvm.ptr -> i32 + llvm.br ^bb1(%1, %7 : vector<4xf32>, i32) + ^bb1(%11: vector<4xf32>, %12: i32): // 2 preds: ^bb0, ^bb2 + %13 = llvm.icmp "slt" %12, %10 : i32 + llvm.cond_br %13, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %14 = llvm.sitofp %12 : i32 to f32 + %15 = llvm.insertelement %14, %11[%2 : i32] : vector<4xf32> + %16 = llvm.shufflevector %15, %3 [0, 0, 0, 0] : vector<4xf32> + %17 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %18 = llvm.bitcast %17 : !llvm.ptr to !llvm.ptr + llvm.store %16, %18 {alignment = 16 : i64} : vector<4xf32>, !llvm.ptr + %19 = llvm.add %12, %5 : i32 + llvm.br ^bb1(%16, %19 : vector<4xf32>, i32) + ^bb3: // pred: ^bb1 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/pr2645-0.ll.mlir b/test/LLVMDialect/InstCombine/pr2645-0.ll.mlir new file mode 100644 index 000000000..3162b17b8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr2645-0.ll.mlir @@ -0,0 +1,29 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func internal @<>(%arg0: !llvm.ptr) attributes {dso_local} { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xf32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(48 : i32) : i32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.bitcast %arg0 : !llvm.ptr to !llvm.ptr + %6 = llvm.load %5 {alignment = 1 : i64} : !llvm.ptr -> i32 + %7 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %8 = llvm.bitcast %7 : !llvm.ptr to !llvm.ptr + %9 = llvm.load %8 {alignment = 1 : i64} : !llvm.ptr -> i32 + llvm.br ^bb1(%1, %6 : vector<4xf32>, i32) + ^bb1(%10: vector<4xf32>, %11: i32): // 2 preds: ^bb0, ^bb2 + %12 = llvm.icmp "slt" %11, %9 : i32 + llvm.cond_br %12, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %13 = llvm.sitofp %11 : i32 to f32 + %14 = llvm.insertelement %13, %10[%2 : i32] : vector<4xf32> + %15 = llvm.shufflevector %14, %1 [0, 0, 0, 0] : vector<4xf32> + %16 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + %17 = llvm.bitcast %16 : !llvm.ptr to !llvm.ptr + llvm.store %15, %17 {alignment = 16 : i64} : vector<4xf32>, !llvm.ptr + %18 = llvm.add %11, %4 : i32 + llvm.br ^bb1(%15, %18 : vector<4xf32>, i32) + ^bb3: // pred: ^bb1 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/pr26992.ll.mlir b/test/LLVMDialect/InstCombine/pr26992.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/pr26993.ll.mlir b/test/LLVMDialect/InstCombine/pr26993.ll.mlir index 7f3cc5edd..1122c6373 100644 --- a/test/LLVMDialect/InstCombine/pr26993.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr26993.ll.mlir @@ -1,17 +1,14 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @__sinpi, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @__cospi, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "__sinpi", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "__cospi", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1() -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.call @__sinpi(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test2() -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.call @__cospi(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @__sinpi(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @__cospi(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} +} diff --git a/test/LLVMDialect/InstCombine/pr27236.ll.mlir b/test/LLVMDialect/InstCombine/pr27236.ll.mlir new file mode 100644 index 000000000..b1b3df800 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr27236.ll.mlir @@ -0,0 +1,13 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32) -> f32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.icmp "sgt" %0, %arg0 : i32 + %4 = llvm.select %3, %0, %arg0 : i1, i32 + %5 = llvm.sitofp %4 : i32 to f32 + %6 = llvm.icmp "sgt" %4, %1 : i32 + %7 = llvm.select %6, %5, %2 : i1, f32 + llvm.return %7 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr27332.ll.mlir b/test/LLVMDialect/InstCombine/pr27332.ll.mlir new file mode 100644 index 000000000..a156a536a --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr27332.ll.mlir @@ -0,0 +1,16 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: vector<4xf32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.intr.fabs(%arg0) : (vector<4xf32>) -> vector<4xf32> + %3 = llvm.fcmp "olt" %2, %1 : vector<4xf32> + llvm.return %3 : vector<4xi1> + } + llvm.func @fabsf() -> f32 + llvm.func @test2() -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.call @fabsf() : () -> f32 + %2 = llvm.fcmp "olt" %1, %0 : f32 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/pr27343.ll.mlir b/test/LLVMDialect/InstCombine/pr27343.ll.mlir index 2148d0626..219efe9c5 100644 --- a/test/LLVMDialect/InstCombine/pr27343.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr27343.ll.mlir @@ -1,24 +1,21 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -16777216 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - "llvm.store"(%arg0, %2) : (f32, !llvm.ptr) -> () - %3 = "llvm.load"(%2) : (!llvm.ptr) -> f32 - %4 = "llvm.bitcast"(%3) : (f32) -> i32 - %5 = "llvm.shl"(%4, %1) : (i32, i32) -> i32 - %6 = "llvm.icmp"(%5, %0) {predicate = 8 : i64} : (i32, i32) -> i1 - %7 = "llvm.zext"(%6) : (i1) -> i32 - "llvm.return"(%7) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "__isnan", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4608 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %2 = "llvm.shl"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "icmp_shl7", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @__isnan(%arg0: f32) -> i32 attributes {passthrough = ["alwaysinline", "nounwind", "optsize"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-16777216 : i32) : i32 + %2 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %2 {alignment = 4 : i64} : f32, !llvm.ptr + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> f32 + %4 = llvm.bitcast %3 : f32 to i32 + %5 = llvm.shl %4, %0 : i32 + %6 = llvm.icmp "ugt" %5, %1 : i32 + %7 = llvm.zext %6 : i1 to i32 + llvm.return %7 : i32 + } + llvm.func @icmp_shl7(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(4608 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/pr27703.ll.mlir b/test/LLVMDialect/InstCombine/pr27703.ll.mlir index 629a2e92b..5455fb783 100644 --- a/test/LLVMDialect/InstCombine/pr27703.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr27703.ll.mlir @@ -1,15 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.undef"() : () -> !llvm.ptr> - "llvm.br"(%0)[^bb1] : (!llvm.ptr>) -> () - ^bb1(%1: !llvm.ptr>): // 2 preds: ^bb0, ^bb1 - %2 = "llvm.load"(%1) : (!llvm.ptr>) -> !llvm.ptr - %3 = "llvm.bitcast"(%2) : (!llvm.ptr) -> !llvm.ptr> - %4 = "llvm.load"(%3) : (!llvm.ptr>) -> !llvm.ptr - %5 = "llvm.bitcast"(%4) : (!llvm.ptr) -> !llvm.ptr> - "llvm.br"(%5)[^bb1] : (!llvm.ptr>) -> () - ^bb2: // no predecessors - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "mem", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @mem() { + %0 = llvm.mlir.undef : !llvm.ptr + llvm.br ^bb1(%0 : !llvm.ptr) + ^bb1(%1: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %2 = llvm.load %1 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %3 = llvm.bitcast %2 : !llvm.ptr to !llvm.ptr + %4 = llvm.load %3 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.bitcast %4 : !llvm.ptr to !llvm.ptr + llvm.br ^bb1(%5 : !llvm.ptr) + } +} diff --git a/test/LLVMDialect/InstCombine/pr27996.ll.mlir b/test/LLVMDialect/InstCombine/pr27996.ll.mlir index 69b33ba0d..b61d4fa20 100644 --- a/test/LLVMDialect/InstCombine/pr27996.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr27996.ll.mlir @@ -1,49 +1,43 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "i", type = i32, value = 1 : i32} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "f", type = f32, value = 1.100000e+00 : f32} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 5 : i64, sym_name = "cmp", type = i32, value = 0 : i32} : () -> () - "llvm.mlir.global"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 5 : i64, sym_name = "resf", type = !llvm.ptr} : () -> () - "llvm.mlir.global"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 5 : i64, sym_name = "resi", type = !llvm.ptr} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @resi} : () -> !llvm.ptr> - %1 = "llvm.mlir.addressof"() {global_name = @resf} : () -> !llvm.ptr> - %2 = "llvm.mlir.addressof"() {global_name = @f} : () -> !llvm.ptr - %3 = "llvm.bitcast"(%2) : (!llvm.ptr) -> !llvm.ptr - %4 = "llvm.mlir.addressof"() {global_name = @i} : () -> !llvm.ptr - %5 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %6 = "llvm.mlir.addressof"() {global_name = @cmp} : () -> !llvm.ptr - %7 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %8 = "llvm.mlir.addressof"() {global_name = @cmp} : () -> !llvm.ptr - %9 = "llvm.mlir.null"() : () -> !llvm.ptr - "llvm.br"(%9)[^bb1] : (!llvm.ptr) -> () - ^bb1(%10: !llvm.ptr): // 3 preds: ^bb0, ^bb3, ^bb4 - %11 = "llvm.load"(%8) : (!llvm.ptr) -> i32 - %12 = "llvm.ashr"(%11, %7) : (i32, i32) -> i32 - "llvm.store"(%12, %6) : (i32, !llvm.ptr) -> () - %13 = "llvm.icmp"(%12, %5) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%13)[^bb2, ^bb5] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @i(1 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.mlir.global external constant @f(1.100000e+00 : f32) {addr_space = 0 : i32, alignment = 4 : i64} : f32 + llvm.mlir.global common @cmp(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.mlir.global common @resf() {addr_space = 0 : i32, alignment = 8 : i64} : !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.mlir.global common @resi() {addr_space = 0 : i32, alignment = 8 : i64} : !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @foo() -> i32 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @cmp : !llvm.ptr + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.addressof @resf : !llvm.ptr + %5 = llvm.mlir.addressof @resi : !llvm.ptr + %6 = llvm.mlir.constant(1.100000e+00 : f32) : f32 + %7 = llvm.mlir.addressof @f : !llvm.ptr + %8 = llvm.mlir.addressof @i : !llvm.ptr + llvm.br ^bb1(%0 : !llvm.ptr) + ^bb1(%9: !llvm.ptr): // 3 preds: ^bb0, ^bb3, ^bb4 + %10 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %11 = llvm.ashr %10, %3 : i32 + llvm.store %11, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %12 = llvm.icmp "ne" %11, %1 : i32 + llvm.cond_br %12, ^bb2, ^bb5 ^bb2: // pred: ^bb1 - %14 = "llvm.and"(%12, %7) : (i32, i32) -> i32 - %15 = "llvm.icmp"(%14, %5) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%15)[^bb3, ^bb4] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %13 = llvm.and %11, %3 : i32 + %14 = llvm.icmp "ne" %13, %1 : i32 + llvm.cond_br %14, ^bb3, ^bb4 ^bb3: // pred: ^bb2 - "llvm.br"(%4)[^bb1] : (!llvm.ptr) -> () + llvm.br ^bb1(%8 : !llvm.ptr) ^bb4: // pred: ^bb2 - "llvm.br"(%3)[^bb1] : (!llvm.ptr) -> () + llvm.br ^bb1(%7 : !llvm.ptr) ^bb5: // pred: ^bb1 - %16 = "llvm.bitcast"(%10) : (!llvm.ptr) -> !llvm.ptr - "llvm.store"(%16, %1) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.store"(%10, %0) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.store %9, %4 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.store %9, %5 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr28143.ll.mlir b/test/LLVMDialect/InstCombine/pr28143.ll.mlir index de6dda224..2aa4dcf82 100644 --- a/test/LLVMDialect/InstCombine/pr28143.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr28143.ll.mlir @@ -1,9 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - "llvm.call"() {callee = @tan, fastmathFlags = #llvm.fastmath<>} : () -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "tan", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1() { + llvm.call @tan() : () -> () + llvm.return + } + llvm.func @tan() +} diff --git a/test/LLVMDialect/InstCombine/pr28725.ll.mlir b/test/LLVMDialect/InstCombine/pr28725.ll.mlir new file mode 100644 index 000000000..2acf6acf1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr28725.ll.mlir @@ -0,0 +1,27 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1() -> vector<2xi16> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<1> : vector<1xi32>) : vector<1xi32> + %2 = llvm.bitcast %1 : vector<1xi32> to vector<2xi16> + %3 = llvm.extractelement %2[%0 : i32] : vector<2xi16> + %4 = llvm.mlir.constant(0 : i16) : i16 + %5 = llvm.mlir.undef : !llvm.struct<"S", (i16, i32)> + %6 = llvm.insertvalue %4, %5[0] : !llvm.struct<"S", (i16, i32)> + %7 = llvm.insertvalue %0, %6[1] : !llvm.struct<"S", (i16, i32)> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.mlir.undef : !llvm.struct<"S", (i16, i32)> + %10 = llvm.insertvalue %4, %9[0] : !llvm.struct<"S", (i16, i32)> + %11 = llvm.insertvalue %8, %10[1] : !llvm.struct<"S", (i16, i32)> + %12 = llvm.mlir.undef : i16 + %13 = llvm.mlir.undef : vector<2xi16> + %14 = llvm.mlir.constant(0 : i32) : i32 + %15 = llvm.insertelement %12, %13[%14 : i32] : vector<2xi16> + %16 = llvm.mlir.constant(1 : i32) : i32 + %17 = llvm.insertelement %4, %15[%16 : i32] : vector<2xi16> + %18 = llvm.icmp "eq" %3, %4 : i16 + %19 = llvm.select %18, %7, %11 : i1, !llvm.struct<"S", (i16, i32)> + %20 = llvm.extractvalue %19[0] : !llvm.struct<"S", (i16, i32)> + %21 = llvm.insertelement %20, %17[%0 : i32] : vector<2xi16> + llvm.return %21 : vector<2xi16> + } +} diff --git a/test/LLVMDialect/InstCombine/pr2996.ll.mlir b/test/LLVMDialect/InstCombine/pr2996.ll.mlir new file mode 100644 index 000000000..fdc515101 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr2996.ll.mlir @@ -0,0 +1,12 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @func_53(%arg0: i16 {llvm.signext}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-1 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i16 + %4 = llvm.select %3, %1, %2 : i1, i32 + %5 = llvm.call @func_4(%4) vararg(!llvm.func) : (i32) -> i32 + llvm.return + } + llvm.func @func_4(...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/pr30929.ll.mlir b/test/LLVMDialect/InstCombine/pr30929.ll.mlir index 8a1391351..35c9e7f6c 100644 --- a/test/LLVMDialect/InstCombine/pr30929.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr30929.ll.mlir @@ -1,10 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 2.000000e+00 : f32} : () -> f32 - %1 = "llvm.call"(%0) {callee = @acosf, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "main", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "acosf", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @main() { + %0 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %1 = llvm.call @acosf(%0) : (f32) -> f32 + llvm.return + } + llvm.func @acosf(f32) -> f32 +} diff --git a/test/LLVMDialect/InstCombine/pr31990_wrong_memcpy.ll.mlir b/test/LLVMDialect/InstCombine/pr31990_wrong_memcpy.ll.mlir index 3c1fc6689..8dd944556 100644 --- a/test/LLVMDialect/InstCombine/pr31990_wrong_memcpy.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr31990_wrong_memcpy.ll.mlir @@ -1,23 +1,15 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "g", type = i8, value = -1 : i8} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.addressof"() {global_name = @g} : () -> !llvm.ptr - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %4 = "llvm.bitcast"(%3) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%4) {callee = @bar, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - %5 = "llvm.bitcast"(%4) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%5, %1, %2, %0) {callee = @llvm.memcpy.p0i8.p0i8.i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32, i1) -> () - "llvm.call"(%5) {callee = @gaz, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memcpy.p0i8.p0i8.i32", type = !llvm.func, ptr, i32, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gaz", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @g(-1 : i8) {addr_space = 0 : i32} : i8 + llvm.func @foo() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.addressof @g : !llvm.ptr + %3 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.call @bar(%3) : (!llvm.ptr) -> () + "llvm.intr.memcpy"(%3, %2, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.call @gaz(%3) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @bar(!llvm.ptr) + llvm.func @gaz(!llvm.ptr) +} diff --git a/test/LLVMDialect/InstCombine/pr32686.ll.mlir b/test/LLVMDialect/InstCombine/pr32686.ll.mlir new file mode 100644 index 000000000..01b2a485b --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr32686.ll.mlir @@ -0,0 +1,21 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @a(0 : i8) {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.mlir.global external @b() {addr_space = 0 : i32} : i32 + llvm.func @tinkywinky() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.load %1 {alignment = 1 : i64} : !llvm.ptr -> i8 + %6 = llvm.icmp "ne" %5, %0 : i8 + %7 = llvm.xor %6, %2 : i1 + %8 = llvm.zext %7 : i1 to i32 + %9 = llvm.icmp "ne" %1, %3 : !llvm.ptr + %10 = llvm.zext %9 : i1 to i32 + %11 = llvm.xor %10, %4 : i32 + %12 = llvm.or %11, %8 : i32 + llvm.store %12, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/pr33453.ll.mlir b/test/LLVMDialect/InstCombine/pr33453.ll.mlir new file mode 100644 index 000000000..261d05374 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr33453.ll.mlir @@ -0,0 +1,17 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g1() {addr_space = 0 : i32} : i16 + llvm.mlir.global external @g2() {addr_space = 0 : i32} : i16 + llvm.func @patatino() -> f32 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.addressof @g2 : !llvm.ptr + %2 = llvm.getelementptr inbounds %1[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i16 + %3 = llvm.mlir.addressof @g1 : !llvm.ptr + %4 = llvm.icmp "eq" %2, %3 : !llvm.ptr + %5 = llvm.uitofp %4 : i1 to f32 + %6 = llvm.uitofp %4 : i1 to f32 + %7 = llvm.fmul %5, %6 : f32 + %8 = llvm.call @fabsf(%7) : (f32) -> f32 + llvm.return %8 : f32 + } + llvm.func @fabsf(f32) -> f32 +} diff --git a/test/LLVMDialect/InstCombine/pr33689_same_bitwidth.ll.mlir b/test/LLVMDialect/InstCombine/pr33689_same_bitwidth.ll.mlir new file mode 100644 index 000000000..09d28df40 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr33689_same_bitwidth.ll.mlir @@ -0,0 +1,29 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @a() {addr_space = 0 : i32} : i16 + llvm.mlir.global external @b() {addr_space = 0 : i32} : !llvm.ptr + llvm.func @f(%arg0: i1) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.undef : i16 + %2 = llvm.mlir.addressof @b : !llvm.ptr + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.mlir.undef : !llvm.array<1 x ptr> + %5 = llvm.mlir.zero : !llvm.ptr + %6 = llvm.mlir.addressof @a : !llvm.ptr + %7 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %8 = llvm.getelementptr inbounds %7[%1] : (!llvm.ptr, i16) -> !llvm.ptr, i16 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %9 = llvm.insertvalue %7, %4[0] : !llvm.array<1 x ptr> + %10 = llvm.insertvalue %5, %9[0] : !llvm.array<1 x ptr> + %11 = llvm.ptrtoint %7 : !llvm.ptr to i16 + llvm.store %11, %6 {alignment = 2 : i64} : i16, !llvm.ptr + llvm.unreachable + ^bb2: // pred: ^bb0 + %12 = llvm.load %2 {alignment = 2 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store %3, %12 {alignment = 2 : i64} : i16, !llvm.ptr + %13 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + %14 = llvm.sub %13, %0 : i32 + llvm.store %14, %7 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/pr34349.ll.mlir b/test/LLVMDialect/InstCombine/pr34349.ll.mlir index c39dfd948..b2eeceb1e 100644 --- a/test/LLVMDialect/InstCombine/pr34349.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr34349.ll.mlir @@ -1,19 +1,17 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 1 : i8} : () -> i8 - %2 = "llvm.mlir.constant"() {value = 8 : i16} : () -> i16 - %3 = "llvm.mlir.constant"() {value = 71 : i16} : () -> i16 - %4 = "llvm.zext"(%arg0) : (i8) -> i16 - %5 = "llvm.mul"(%4, %3) : (i16, i16) -> i16 - %6 = "llvm.lshr"(%5, %2) : (i16, i16) -> i16 - %7 = "llvm.trunc"(%6) : (i16) -> i8 - %8 = "llvm.sub"(%arg0, %7) : (i8, i8) -> i8 - %9 = "llvm.lshr"(%8, %1) : (i8, i8) -> i8 - %10 = "llvm.add"(%7, %9) : (i8, i8) -> i8 - %11 = "llvm.lshr"(%10, %0) : (i8, i8) -> i8 - "llvm.return"(%11) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "fast_div_201", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fast_div_201(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(71 : i16) : i16 + %1 = llvm.mlir.constant(8 : i16) : i16 + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.mlir.constant(7 : i8) : i8 + %4 = llvm.zext %arg0 : i8 to i16 + %5 = llvm.mul %4, %0 : i16 + %6 = llvm.lshr %5, %1 : i16 + %7 = llvm.trunc %6 : i16 to i8 + %8 = llvm.sub %arg0, %7 : i8 + %9 = llvm.lshr %8, %2 : i8 + %10 = llvm.add %7, %9 : i8 + %11 = llvm.lshr %10, %3 : i8 + llvm.return %11 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/pr34627.ll.mlir b/test/LLVMDialect/InstCombine/pr34627.ll.mlir index c88469932..76bd05dea 100644 --- a/test/LLVMDialect/InstCombine/pr34627.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr34627.ll.mlir @@ -1,11 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.undef"() : () -> vector<2xi16> - %1 = "llvm.mlir.constant"() {value = 0 : i16} : () -> i16 - %2 = "llvm.mlir.null"() : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %0) : (!llvm.ptr>, i16, vector<2xi16>) -> !llvm.vec<2 x ptr> - %4 = "llvm.ptrtoint"(%3) : (!llvm.vec<2 x ptr>) -> vector<2xi16> - "llvm.return"(%4) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "patatino", type = !llvm.func ()>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @patatino() -> vector<2xi16> { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.mlir.undef : vector<2xi16> + %3 = llvm.getelementptr inbounds %0[%1, %2] : (!llvm.ptr, i16, vector<2xi16>) -> !llvm.vec<2 x ptr>, !llvm.array<1 x i16> + %4 = llvm.ptrtoint %3 : !llvm.vec<2 x ptr> to vector<2xi16> + llvm.return %4 : vector<2xi16> + } +} diff --git a/test/LLVMDialect/InstCombine/pr35515.ll.mlir b/test/LLVMDialect/InstCombine/pr35515.ll.mlir new file mode 100644 index 000000000..e702dc4f7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr35515.ll.mlir @@ -0,0 +1,33 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g_40() {addr_space = 0 : i32, alignment = 2 : i64} : i8 + llvm.mlir.global external @g_461() {addr_space = 0 : i32, alignment = 2 : i64} : !llvm.array<6 x i8> + llvm.mlir.global external local_unnamed_addr @g_49() {addr_space = 0 : i32, alignment = 2 : i64} : !llvm.struct<(i8, i8, i8, i8, i8)> + llvm.func @func_24() -> i40 { + %0 = llvm.mlir.addressof @g_49 : !llvm.ptr + %1 = llvm.mlir.constant(-274869518337 : i40) : i40 + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.mlir.addressof @g_461 : !llvm.ptr + %5 = llvm.getelementptr inbounds %4[%3, %2] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<6 x i8> + %6 = llvm.mlir.addressof @g_40 : !llvm.ptr + %7 = llvm.mlir.constant(0 : i32) : i32 + %8 = llvm.mlir.constant(23 : i40) : i40 + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.mlir.constant(23 : i32) : i32 + %11 = llvm.load %0 {alignment = 2 : i64} : !llvm.ptr -> i40 + %12 = llvm.and %11, %1 : i40 + %13 = llvm.icmp "eq" %5, %6 : !llvm.ptr + %14 = llvm.zext %13 : i1 to i32 + %15 = llvm.icmp "sgt" %14, %7 : i32 + %16 = llvm.zext %15 : i1 to i40 + %17 = llvm.shl %16, %8 : i40 + %18 = llvm.or %12, %17 : i40 + %19 = llvm.lshr %18, %8 : i40 + %20 = llvm.trunc %19 : i40 to i32 + %21 = llvm.and %9, %20 : i32 + %22 = llvm.shl %21, %10 overflow : i32 + %23 = llvm.zext %22 : i32 to i40 + %24 = llvm.or %12, %23 : i40 + llvm.return %24 : i40 + } +} diff --git a/test/LLVMDialect/InstCombine/pr36362.ll.mlir b/test/LLVMDialect/InstCombine/pr36362.ll.mlir new file mode 100644 index 000000000..66267a50e --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr36362.ll.mlir @@ -0,0 +1,10 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.select %arg0, %arg1, %0 : i1, i32 + %3 = llvm.srem %arg2, %2 : i32 + %4 = llvm.select %arg0, %3, %1 : i1, i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr38677.ll.mlir b/test/LLVMDialect/InstCombine/pr38677.ll.mlir new file mode 100644 index 000000000..7381bf4bf --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr38677.ll.mlir @@ -0,0 +1,24 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global extern_weak @A() {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.mlir.global extern_weak @B() {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.func @foo(%arg0: i1, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.addressof @A : !llvm.ptr + %3 = llvm.mlir.addressof @B : !llvm.ptr + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.mlir.constant(2147483647 : i32) : i32 + %7 = llvm.mlir.constant(0 : i32) : i32 + llvm.cond_br %1, ^bb2(%0 : i1), ^bb1 + ^bb1: // pred: ^bb0 + %8 = llvm.icmp "eq" %2, %3 : !llvm.ptr + llvm.br ^bb2(%8 : i1) + ^bb2(%9: i1): // 2 preds: ^bb0, ^bb1 + %10 = llvm.select %9, %4, %5 : i1, i32 + %11 = llvm.mul %10, %6 : i32 + %12 = llvm.icmp "ule" %11, %7 : i32 + llvm.store %12, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %10 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr38897.ll.mlir b/test/LLVMDialect/InstCombine/pr38897.ll.mlir new file mode 100644 index 000000000..f22880a24 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr38897.ll.mlir @@ -0,0 +1,17 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @sharpening(%arg0: i32, %arg1: i1, %arg2: i1, %arg3: i32, %arg4: i32, %arg5: i32, %arg6: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.select %arg1, %arg3, %arg4 : i1, i32 + %4 = llvm.select %arg2, %arg5, %arg6 : i1, i32 + %5 = llvm.sub %0, %4 : i32 + %6 = llvm.icmp "sgt" %5, %1 : i32 + %7 = llvm.select %6, %5, %1 : i1, i32 + %8 = llvm.xor %7, %2 : i32 + %9 = llvm.icmp "sgt" %3, %8 : i32 + %10 = llvm.select %9, %3, %8 : i1, i32 + %11 = llvm.xor %10, %2 : i32 + llvm.return %11 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr38915.ll.mlir b/test/LLVMDialect/InstCombine/pr38915.ll.mlir new file mode 100644 index 000000000..eaa476a74 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr38915.ll.mlir @@ -0,0 +1,15 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @PR38915(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.icmp "sgt" %2, %3 : i32 + %5 = llvm.select %4, %2, %3 : i1, i32 + %6 = llvm.xor %5, %1 : i32 + %7 = llvm.icmp "sgt" %6, %arg2 : i32 + %8 = llvm.select %7, %6, %arg2 : i1, i32 + %9 = llvm.xor %8, %1 : i32 + llvm.return %9 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr38984-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/pr38984-inseltpoison.ll.mlir new file mode 100644 index 000000000..f896b2825 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr38984-inseltpoison.ll.mlir @@ -0,0 +1,32 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @a() {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<21 x i16> + llvm.mlir.global external @offsets() {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<4 x i16> + llvm.func @PR38984_1() -> vector<4xi1> { + %0 = llvm.mlir.addressof @offsets : !llvm.ptr + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.load %0 {alignment = 1 : i64} : !llvm.ptr -> i16 + %5 = llvm.insertelement %4, %1[%2 : i32] : vector<4xi16> + %6 = llvm.getelementptr %3[%5] : (!llvm.ptr, vector<4xi16>) -> !llvm.vec<4 x ptr>, i32 + %7 = llvm.getelementptr %3[%5] : (!llvm.ptr, vector<4xi16>) -> !llvm.vec<4 x ptr>, i32 + %8 = llvm.icmp "eq" %6, %7 : !llvm.vec<4 x ptr> + llvm.return %8 : vector<4xi1> + } + llvm.func @PR38984_2() -> vector<4xi1> { + %0 = llvm.mlir.addressof @offsets : !llvm.ptr + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(1 : i64) : i64 + %5 = llvm.mlir.addressof @a : !llvm.ptr + %6 = llvm.getelementptr inbounds %5[%4, %3] : (!llvm.ptr, i64, i32) -> !llvm.ptr, !llvm.array<21 x i16> + %7 = llvm.mlir.zero : !llvm.ptr + %8 = llvm.load %0 {alignment = 2 : i64} : !llvm.ptr -> i16 + %9 = llvm.insertelement %8, %1[%2 : i32] : vector<4xi16> + %10 = llvm.getelementptr %6[%9] : (!llvm.ptr, vector<4xi16>) -> !llvm.vec<4 x ptr>, i16 + %11 = llvm.getelementptr %7[%9] : (!llvm.ptr, vector<4xi16>) -> !llvm.vec<4 x ptr>, i16 + %12 = llvm.icmp "eq" %10, %11 : !llvm.vec<4 x ptr> + llvm.return %12 : vector<4xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/pr38984.ll.mlir b/test/LLVMDialect/InstCombine/pr38984.ll.mlir new file mode 100644 index 000000000..e86268ddd --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr38984.ll.mlir @@ -0,0 +1,32 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @a() {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<21 x i16> + llvm.mlir.global external @offsets() {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<4 x i16> + llvm.func @PR38984_1() -> vector<4xi1> { + %0 = llvm.mlir.addressof @offsets : !llvm.ptr + %1 = llvm.mlir.undef : vector<4xi16> + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.load %0 {alignment = 1 : i64} : !llvm.ptr -> i16 + %5 = llvm.insertelement %4, %1[%2 : i32] : vector<4xi16> + %6 = llvm.getelementptr %3[%5] : (!llvm.ptr, vector<4xi16>) -> !llvm.vec<4 x ptr>, i32 + %7 = llvm.getelementptr %3[%5] : (!llvm.ptr, vector<4xi16>) -> !llvm.vec<4 x ptr>, i32 + %8 = llvm.icmp "eq" %6, %7 : !llvm.vec<4 x ptr> + llvm.return %8 : vector<4xi1> + } + llvm.func @PR38984_2() -> vector<4xi1> { + %0 = llvm.mlir.addressof @offsets : !llvm.ptr + %1 = llvm.mlir.undef : vector<4xi16> + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(1 : i64) : i64 + %5 = llvm.mlir.addressof @a : !llvm.ptr + %6 = llvm.getelementptr inbounds %5[%4, %3] : (!llvm.ptr, i64, i32) -> !llvm.ptr, !llvm.array<21 x i16> + %7 = llvm.mlir.zero : !llvm.ptr + %8 = llvm.load %0 {alignment = 2 : i64} : !llvm.ptr -> i16 + %9 = llvm.insertelement %8, %1[%2 : i32] : vector<4xi16> + %10 = llvm.getelementptr %6[%9] : (!llvm.ptr, vector<4xi16>) -> !llvm.vec<4 x ptr>, i16 + %11 = llvm.getelementptr %7[%9] : (!llvm.ptr, vector<4xi16>) -> !llvm.vec<4 x ptr>, i16 + %12 = llvm.icmp "eq" %10, %11 : !llvm.vec<4 x ptr> + llvm.return %12 : vector<4xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/pr39177.ll.mlir b/test/LLVMDialect/InstCombine/pr39177.ll.mlir new file mode 100644 index 000000000..334e4729a --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr39177.ll.mlir @@ -0,0 +1,30 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @stderr() {addr_space = 0 : i32, alignment = 8 : i64} : !llvm.ptr + llvm.mlir.global private constant @".str"("crash!\0A\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.func @__fwrite_alias(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64, %arg3: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + %3 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %5 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %2 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.store %arg1, %3 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.store %arg2, %4 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.store %arg3, %5 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return %1 : i64 + } + llvm.func @foo() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @stderr : !llvm.ptr + %3 = llvm.mlir.constant("crash!\0A\00") : !llvm.array<8 x i8> + %4 = llvm.mlir.addressof @".str" : !llvm.ptr + %5 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %5 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %7 = llvm.call @fprintf(%6, %4) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @fprintf(!llvm.ptr, !llvm.ptr, ...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/pr39908.ll.mlir b/test/LLVMDialect/InstCombine/pr39908.ll.mlir new file mode 100644 index 000000000..6ad04a097 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr39908.ll.mlir @@ -0,0 +1,29 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: !llvm.ptr, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.getelementptr inbounds %arg0[%0, %arg1, 0, %0] : (!llvm.ptr, i32, i32, i32) -> !llvm.ptr, !llvm.array<0 x struct<"S", (array<2 x i32>)>> + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"S", (array<2 x i32>)> + %4 = llvm.icmp "eq" %3, %arg0 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @test64(%arg0: !llvm.ptr, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i64) : i64 + %3 = llvm.getelementptr inbounds %arg0[%0, %arg1, 0, %0] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<0 x struct<"S", (array<2 x i32>)>> + %4 = llvm.getelementptr inbounds %3[%2] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"S", (array<2 x i32>)> + %5 = llvm.icmp "eq" %4, %arg0 : !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @test64_overflow(%arg0: !llvm.ptr, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8589934592 : i64) : i64 + %3 = llvm.mlir.constant(-1 : i64) : i64 + %4 = llvm.getelementptr inbounds %arg0[%0, %arg1, 0, %2] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<0 x struct<"S", (array<2 x i32>)>> + %5 = llvm.getelementptr inbounds %4[%3] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"S", (array<2 x i32>)> + %6 = llvm.icmp "eq" %5, %arg0 : !llvm.ptr + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/pr41164.ll.mlir b/test/LLVMDialect/InstCombine/pr41164.ll.mlir index 912339170..d848da1dd 100644 --- a/test/LLVMDialect/InstCombine/pr41164.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr41164.ll.mlir @@ -1,27 +1,25 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "wyhash64_x", type = i64, value = 0 : i64} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1946526487930394057 : i128} : () -> i128 - %1 = "llvm.mlir.constant"() {value = 64 : i128} : () -> i128 - %2 = "llvm.mlir.constant"() {value = 11795372955171141389 : i128} : () -> i128 - %3 = "llvm.mlir.addressof"() {global_name = @wyhash64_x} : () -> !llvm.ptr - %4 = "llvm.mlir.constant"() {value = 6971258582664805397 : i64} : () -> i64 - %5 = "llvm.mlir.addressof"() {global_name = @wyhash64_x} : () -> !llvm.ptr - %6 = "llvm.load"(%5) : (!llvm.ptr) -> i64 - %7 = "llvm.add"(%6, %4) : (i64, i64) -> i64 - "llvm.store"(%7, %3) : (i64, !llvm.ptr) -> () - %8 = "llvm.zext"(%7) : (i64) -> i128 - %9 = "llvm.mul"(%8, %2) : (i128, i128) -> i128 - %10 = "llvm.lshr"(%9, %1) : (i128, i128) -> i128 - %11 = "llvm.xor"(%10, %9) : (i128, i128) -> i128 - %12 = "llvm.trunc"(%11) : (i128) -> i64 - %13 = "llvm.zext"(%12) : (i64) -> i128 - %14 = "llvm.mul"(%13, %0) : (i128, i128) -> i128 - %15 = "llvm.lshr"(%14, %1) : (i128, i128) -> i128 - %16 = "llvm.xor"(%15, %14) : (i128, i128) -> i128 - %17 = "llvm.trunc"(%16) : (i128) -> i64 - "llvm.return"(%17) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "_Z8wyhash64v", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @wyhash64_x(0 : i64) {addr_space = 0 : i32, alignment = 8 : i64} : i64 + llvm.func @_Z8wyhash64v() -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.addressof @wyhash64_x : !llvm.ptr + %2 = llvm.mlir.constant(6971258582664805397 : i64) : i64 + %3 = llvm.mlir.constant(11795372955171141389 : i128) : i128 + %4 = llvm.mlir.constant(64 : i128) : i128 + %5 = llvm.mlir.constant(1946526487930394057 : i128) : i128 + %6 = llvm.load %1 {alignment = 8 : i64} : !llvm.ptr -> i64 + %7 = llvm.add %6, %2 : i64 + llvm.store %7, %1 {alignment = 8 : i64} : i64, !llvm.ptr + %8 = llvm.zext %7 : i64 to i128 + %9 = llvm.mul %8, %3 : i128 + %10 = llvm.lshr %9, %4 : i128 + %11 = llvm.xor %10, %9 : i128 + %12 = llvm.trunc %11 : i128 to i64 + %13 = llvm.zext %12 : i64 to i128 + %14 = llvm.mul %13, %5 : i128 + %15 = llvm.lshr %14, %4 : i128 + %16 = llvm.xor %15, %14 : i128 + %17 = llvm.trunc %16 : i128 to i64 + llvm.return %17 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/pr43081.ll.mlir b/test/LLVMDialect/InstCombine/pr43081.ll.mlir index 1bb06589c..3672385d8 100644 --- a/test/LLVMDialect/InstCombine/pr43081.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr43081.ll.mlir @@ -1,15 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strchr", type = !llvm.func (ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr> - "llvm.store"(%arg0, %2) : (!llvm.ptr, !llvm.ptr>) -> () - %3 = "llvm.load"(%2) : (!llvm.ptr>) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "pr43081", type = !llvm.func (ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @strchr(!llvm.ptr, i32) -> !llvm.ptr + llvm.func @pr43081(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %2 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %3 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %4 = llvm.call @strchr(%3, %1) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/pr43376-getFlippedStrictnessPredicateAndConstant-assert.ll.mlir b/test/LLVMDialect/InstCombine/pr43376-getFlippedStrictnessPredicateAndConstant-assert.ll.mlir index 161338dec..802f84c98 100644 --- a/test/LLVMDialect/InstCombine/pr43376-getFlippedStrictnessPredicateAndConstant-assert.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr43376-getFlippedStrictnessPredicateAndConstant-assert.ll.mlir @@ -1,22 +1,20 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i16} : () -> i16 - %1 = "llvm.mlir.constant"() {value = 3 : i16} : () -> i16 - %2 = "llvm.mlir.constant"() {value = false} : () -> i1 - %3 = "llvm.mlir.constant"() {value = 0 : i16} : () -> i16 - %4 = "llvm.load"(%arg0) : (!llvm.ptr) -> i16 - %5 = "llvm.icmp"(%4, %3) {predicate = 1 : i64} : (i16, i16) -> i1 - "llvm.cond_br"(%5, %2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @d(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(3 : i16) : i16 + %3 = llvm.mlir.constant(-1 : i16) : i16 + %4 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i16 + %5 = llvm.icmp "ne" %4, %0 : i16 + llvm.cond_br %5, ^bb1, ^bb2(%1 : i1) ^bb1: // pred: ^bb0 - %6 = "llvm.load"(%arg1) : (!llvm.ptr) -> i16 - %7 = "llvm.icmp"(%6, %3) {predicate = 6 : i64} : (i16, i16) -> i1 - "llvm.br"(%7)[^bb2] : (i1) -> () + %6 = llvm.load %arg1 {alignment = 1 : i64} : !llvm.ptr -> i16 + %7 = llvm.icmp "ult" %6, %0 : i16 + llvm.br ^bb2(%7 : i1) ^bb2(%8: i1): // 2 preds: ^bb0, ^bb1 - %9 = "llvm.zext"(%8) : (i1) -> i16 - %10 = "llvm.mul"(%9, %1) : (i16, i16) -> i16 - %11 = "llvm.xor"(%10, %0) : (i16, i16) -> i16 - "llvm.return"(%11) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "d", type = !llvm.func, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %9 = llvm.zext %8 : i1 to i16 + %10 = llvm.mul %9, %2 overflow : i16 + %11 = llvm.xor %10, %3 : i16 + llvm.return %11 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/pr43893.ll.mlir b/test/LLVMDialect/InstCombine/pr43893.ll.mlir new file mode 100644 index 000000000..5a9c6de1e --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr43893.ll.mlir @@ -0,0 +1,37 @@ +#di_basic_type = #llvm.di_basic_type +#di_basic_type1 = #llvm.di_basic_type +#di_file = #llvm.di_file<"test" in "n"> +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C99, file = #di_file, producer = "clang version 10.0.0", isOptimized = false, emissionKind = Full> +#di_subroutine_type = #llvm.di_subroutine_type +#di_global_variable = #llvm.di_global_variable +#di_global_variable1 = #llvm.di_global_variable +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "main", file = #di_file, line = 2, scopeLine = 2, subprogramFlags = Definition, type = #di_subroutine_type> +#di_global_variable_expression = #llvm.di_global_variable_expression> +#di_global_variable_expression1 = #llvm.di_global_variable_expression> +#di_local_variable = #llvm.di_local_variable +#di_local_variable1 = #llvm.di_local_variable +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @a(0 : i8) {addr_space = 0 : i32, alignment = 1 : i64, dbg_expr = #di_global_variable_expression, dso_local} : i8 + llvm.mlir.global common @b(0 : i8) {addr_space = 0 : i32, alignment = 1 : i64, dbg_expr = #di_global_variable_expression1, dso_local} : i8 + llvm.func @main() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.mlir.addressof @b : !llvm.ptr + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(-8 : i32) : i32 + llvm.intr.dbg.value #di_local_variable = %6 : i32 + %7 = llvm.load %1 {alignment = 1 : i64} : !llvm.ptr -> i8 + %8 = llvm.add %7, %2 : i8 + llvm.store %8, %1 {alignment = 1 : i64} : i8, !llvm.ptr + %9 = llvm.sext %8 : i8 to i32 + %10 = llvm.udiv %9, %3 : i32 + llvm.intr.dbg.value #di_local_variable = %10 : i32 + llvm.intr.dbg.value #di_local_variable1 = %10 : i32 + llvm.store %0, %4 {alignment = 1 : i64} : i8, !llvm.ptr + %11 = llvm.icmp "sgt" %9, %5 : i32 + %12 = llvm.zext %11 : i1 to i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr44242.ll.mlir b/test/LLVMDialect/InstCombine/pr44242.ll.mlir new file mode 100644 index 000000000..036eeb51d --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr44242.ll.mlir @@ -0,0 +1,91 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @global(0 : i32) {addr_space = 0 : i32} : i32 + llvm.func @sitofp(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + llvm.br ^bb1(%0 : i32) + ^bb1(%2: i32): // 2 preds: ^bb0, ^bb2 + %3 = llvm.bitcast %2 : i32 to f32 + %4 = llvm.fcmp "ogt" %3, %arg0 : f32 + llvm.cond_br %4, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + %5 = llvm.fadd %3, %1 : f32 + %6 = llvm.bitcast %5 : f32 to i32 + llvm.br ^bb1(%6 : i32) + ^bb3: // pred: ^bb1 + %7 = llvm.sitofp %2 : i32 to f32 + llvm.return %7 : f32 + } + llvm.func @bitcast(%arg0: f32) -> vector<2xi16> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + llvm.br ^bb1(%0 : i32) + ^bb1(%2: i32): // 2 preds: ^bb0, ^bb2 + %3 = llvm.bitcast %2 : i32 to f32 + %4 = llvm.fcmp "ogt" %3, %arg0 : f32 + llvm.cond_br %4, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + %5 = llvm.fadd %3, %1 : f32 + %6 = llvm.bitcast %5 : f32 to i32 + llvm.br ^bb1(%6 : i32) + ^bb3: // pred: ^bb1 + %7 = llvm.bitcast %2 : i32 to vector<2xi16> + llvm.return %7 : vector<2xi16> + } + llvm.func @store_volatile(%arg0: f32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.mlir.addressof @global : !llvm.ptr + llvm.br ^bb1(%0 : i32) + ^bb1(%3: i32): // 2 preds: ^bb0, ^bb2 + %4 = llvm.bitcast %3 : i32 to f32 + %5 = llvm.fcmp "ogt" %4, %arg0 : f32 + llvm.cond_br %5, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + %6 = llvm.fadd %4, %1 : f32 + %7 = llvm.bitcast %6 : f32 to i32 + llvm.br ^bb1(%7 : i32) + ^bb3: // pred: ^bb1 + llvm.store volatile %3, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @store_address(%arg0: i32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @global : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + llvm.br ^bb1(%1, %0 : !llvm.ptr, i32) + ^bb1(%3: !llvm.ptr, %4: i32): // 2 preds: ^bb0, ^bb2 + %5 = llvm.icmp "sgt" %4, %arg0 : i32 + llvm.cond_br %5, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + %6 = llvm.add %4, %0 : i32 + %7 = llvm.getelementptr %3[%2] : (!llvm.ptr, i32) -> !llvm.ptr, f32 + llvm.br ^bb1(%7, %6 : !llvm.ptr, i32) + ^bb3: // pred: ^bb1 + llvm.store %0, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @multiple_phis(%arg0: f32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.mlir.addressof @global : !llvm.ptr + llvm.br ^bb1(%0 : i32) + ^bb1(%4: i32): // 2 preds: ^bb0, ^bb4 + %5 = llvm.bitcast %4 : i32 to f32 + %6 = llvm.fcmp "ogt" %5, %arg0 : f32 + llvm.cond_br %6, ^bb5, ^bb2 + ^bb2: // pred: ^bb1 + %7 = llvm.fcmp "ogt" %5, %1 : f32 + llvm.cond_br %7, ^bb3, ^bb4(%4 : i32) + ^bb3: // pred: ^bb2 + %8 = llvm.fadd %5, %2 : f32 + %9 = llvm.bitcast %8 : f32 to i32 + llvm.br ^bb4(%9 : i32) + ^bb4(%10: i32): // 2 preds: ^bb2, ^bb3 + llvm.store volatile %10, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb1(%10 : i32) + ^bb5: // pred: ^bb1 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr44245.ll.mlir b/test/LLVMDialect/InstCombine/pr44245.ll.mlir index 694bdd583..b664d74c4 100644 --- a/test/LLVMDialect/InstCombine/pr44245.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr44245.ll.mlir @@ -1,86 +1,75 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.undef"() : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 16 : i64} : () -> i64 - %2 = "llvm.inttoptr"(%1) : (i64) -> !llvm.ptr> - %3 = "llvm.mlir.undef"() : () -> !llvm.ptr> - %4 = "llvm.mlir.undef"() : () -> !llvm.ptr - "llvm.cond_br"(%arg0, %4)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, !llvm.ptr) -> () - ^bb1(%5: !llvm.ptr): // 2 preds: ^bb0, ^bb4 - "llvm.store"(%5, %3) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.return"() : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.undef : !llvm.ptr + %1 = llvm.mlir.constant(16 : i64) : i64 + %2 = llvm.inttoptr %1 : i64 to !llvm.ptr + llvm.cond_br %arg0, ^bb1(%0 : !llvm.ptr), ^bb2 + ^bb1(%3: !llvm.ptr): // 2 preds: ^bb0, ^bb4 + llvm.store %3, %arg1 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return ^bb2: // pred: ^bb0 - "llvm.cond_br"(%arg0)[^bb3, ^bb5] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.cond_br %arg0, ^bb3, ^bb5 ^bb3: // pred: ^bb2 - %6 = "llvm.load"(%2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%6)[^bb4] : (!llvm.ptr) -> () - ^bb4(%7: !llvm.ptr): // 8 preds: ^bb3, ^bb6, ^bb8, ^bb10, ^bb12, ^bb14, ^bb16, ^bb19 - %8 = "llvm.bitcast"(%7) : (!llvm.ptr) -> !llvm.ptr - "llvm.br"(%8)[^bb1] : (!llvm.ptr) -> () + %4 = llvm.load %2 {alignment = 16 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb4(%4 : !llvm.ptr) + ^bb4(%5: !llvm.ptr): // 8 preds: ^bb3, ^bb6, ^bb8, ^bb10, ^bb12, ^bb14, ^bb16, ^bb19 + llvm.br ^bb1(%5 : !llvm.ptr) ^bb5: // pred: ^bb2 - "llvm.cond_br"(%arg0)[^bb6, ^bb7] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.cond_br %arg0, ^bb6, ^bb7 ^bb6: // pred: ^bb5 - %9 = "llvm.load"(%2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%9)[^bb4] : (!llvm.ptr) -> () + %6 = llvm.load %2 {alignment = 16 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb4(%6 : !llvm.ptr) ^bb7: // pred: ^bb5 - "llvm.cond_br"(%arg0)[^bb8, ^bb9] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.cond_br %arg0, ^bb8, ^bb9 ^bb8: // pred: ^bb7 - %10 = "llvm.load"(%2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%10)[^bb4] : (!llvm.ptr) -> () + %7 = llvm.load %2 {alignment = 16 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb4(%7 : !llvm.ptr) ^bb9: // pred: ^bb7 - "llvm.cond_br"(%arg0)[^bb10, ^bb11] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.cond_br %arg0, ^bb10, ^bb11 ^bb10: // pred: ^bb9 - %11 = "llvm.load"(%2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%11)[^bb4] : (!llvm.ptr) -> () + %8 = llvm.load %2 {alignment = 16 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb4(%8 : !llvm.ptr) ^bb11: // pred: ^bb9 - "llvm.cond_br"(%arg0)[^bb12, ^bb13] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.cond_br %arg0, ^bb12, ^bb13 ^bb12: // pred: ^bb11 - %12 = "llvm.load"(%2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%12)[^bb4] : (!llvm.ptr) -> () + %9 = llvm.load %2 {alignment = 16 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb4(%9 : !llvm.ptr) ^bb13: // pred: ^bb11 - "llvm.cond_br"(%arg0)[^bb14, ^bb15] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.cond_br %arg0, ^bb14, ^bb15 ^bb14: // pred: ^bb13 - %13 = "llvm.load"(%2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%13)[^bb4] : (!llvm.ptr) -> () + %10 = llvm.load %2 {alignment = 16 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb4(%10 : !llvm.ptr) ^bb15: // pred: ^bb13 - "llvm.cond_br"(%arg0)[^bb16, ^bb17] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.cond_br %arg0, ^bb16, ^bb17 ^bb16: // pred: ^bb15 - %14 = "llvm.load"(%2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%14)[^bb4] : (!llvm.ptr) -> () + %11 = llvm.load %2 {alignment = 16 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb4(%11 : !llvm.ptr) ^bb17: // pred: ^bb15 - "llvm.cond_br"(%arg0)[^bb18, ^bb20] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.cond_br %arg0, ^bb18, ^bb20 ^bb18: // pred: ^bb17 - %15 = "llvm.load"(%2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.br"(%15)[^bb19] : (!llvm.ptr) -> () - ^bb19(%16: !llvm.ptr): // 2 preds: ^bb18, ^bb20 - "llvm.br"(%16)[^bb4] : (!llvm.ptr) -> () + %12 = llvm.load %2 {alignment = 16 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb19(%12 : !llvm.ptr) + ^bb19(%13: !llvm.ptr): // 2 preds: ^bb18, ^bb20 + llvm.br ^bb4(%13 : !llvm.ptr) ^bb20: // pred: ^bb17 - %17 = "llvm.load"(%2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%0) : (!llvm.ptr>) -> () - "llvm.br"(%17)[^bb19] : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.undef"() : () -> !llvm.ptr>> - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.undef"() : () -> !llvm.ptr> - "llvm.br"(%2)[^bb1] : (!llvm.ptr>) -> () - ^bb1(%3: !llvm.ptr>): // 2 preds: ^bb0, ^bb5 - %4 = "llvm.bitcast"(%3) : (!llvm.ptr>) -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %1) : (!llvm.ptr>, i32) -> !llvm.ptr> - %6 = "llvm.bitcast"(%5) : (!llvm.ptr>) -> !llvm.ptr> - "llvm.br"()[^bb2] : () -> () + %14 = llvm.load %2 {alignment = 16 : i64} : !llvm.ptr -> !llvm.ptr + llvm.call %0() : !llvm.ptr, () -> () + llvm.br ^bb19(%14 : !llvm.ptr) + } + llvm.func local_unnamed_addr @test_2(%arg0: i1) { + %0 = llvm.mlir.undef : !llvm.ptr + llvm.br ^bb1(%0 : !llvm.ptr) + ^bb1(%1: !llvm.ptr): // 2 preds: ^bb0, ^bb5 + llvm.br ^bb2 ^bb2: // pred: ^bb1 - "llvm.cond_br"(%arg0)[^bb3, ^bb4] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + llvm.cond_br %arg0, ^bb3, ^bb4 ^bb3: // pred: ^bb2 - %7 = "llvm.load"(%0) : (!llvm.ptr>>) -> !llvm.ptr> - "llvm.br"(%7)[^bb5] : (!llvm.ptr>) -> () + %2 = llvm.load %0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb5(%2 : !llvm.ptr) ^bb4: // pred: ^bb2 - %8 = "llvm.load"(%0) : (!llvm.ptr>>) -> !llvm.ptr> - "llvm.br"(%8)[^bb5] : (!llvm.ptr>) -> () - ^bb5(%9: !llvm.ptr>): // 2 preds: ^bb3, ^bb4 - "llvm.br"(%9)[^bb1] : (!llvm.ptr>) -> () - }) {linkage = 10 : i64, sym_name = "test_2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %3 = llvm.load %0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.br ^bb5(%3 : !llvm.ptr) + ^bb5(%4: !llvm.ptr): // 2 preds: ^bb3, ^bb4 + llvm.br ^bb1(%4 : !llvm.ptr) + } +} diff --git a/test/LLVMDialect/InstCombine/pr44541.ll.mlir b/test/LLVMDialect/InstCombine/pr44541.ll.mlir new file mode 100644 index 000000000..08bffce8a --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr44541.ll.mlir @@ -0,0 +1,13 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @passthru(%arg0: i16 {llvm.returned}) -> i16 { + llvm.return %arg0 : i16 + } + llvm.func @test(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.call @passthru(%0) : (i16) -> i16 + %2 = llvm.sub %arg0, %1 overflow : i16 + %3 = llvm.icmp "slt" %2, %0 : i16 + %4 = llvm.select %3, %0, %2 : i1, i16 + llvm.return %4 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/pr44552.ll.mlir b/test/LLVMDialect/InstCombine/pr44552.ll.mlir new file mode 100644 index 000000000..c6dda4d35 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr44552.ll.mlir @@ -0,0 +1,64 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @csmith_sink_(0 : i64) {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : i64 + llvm.mlir.global internal constant @g_302_7(0 : i32) {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : i32 + llvm.mlir.global internal @g_313_0(0 : i16) {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : i16 + llvm.mlir.global internal @g_313_1(0 : i32) {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : i32 + llvm.mlir.global internal @g_313_2(0 : i32) {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : i32 + llvm.mlir.global internal @g_313_3(0 : i32) {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : i32 + llvm.mlir.global internal @g_313_4(0 : i16) {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : i16 + llvm.mlir.global internal @g_313_5(0 : i16) {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : i16 + llvm.mlir.global internal @g_313_6(0 : i16) {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : i16 + llvm.mlir.global internal @g_316() {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : !llvm.struct<"struct.S3", (i64)> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.undef : !llvm.struct<"struct.S3", (i64)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<"struct.S3", (i64)> + llvm.return %2 : !llvm.struct<"struct.S3", (i64)> + } + llvm.mlir.global internal @g_316_1_0(0 : i16) {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : i16 + llvm.func @main() -> i16 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.addressof @csmith_sink_ : !llvm.ptr + %2 = llvm.mlir.constant(0 : i16) : i16 + %3 = llvm.mlir.addressof @g_313_0 : !llvm.ptr + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.addressof @g_313_1 : !llvm.ptr + %6 = llvm.mlir.addressof @g_313_2 : !llvm.ptr + %7 = llvm.mlir.addressof @g_313_3 : !llvm.ptr + %8 = llvm.mlir.addressof @g_313_4 : !llvm.ptr + %9 = llvm.mlir.addressof @g_313_5 : !llvm.ptr + %10 = llvm.mlir.addressof @g_313_6 : !llvm.ptr + %11 = llvm.mlir.undef : !llvm.struct<"struct.S3", (i64)> + %12 = llvm.insertvalue %0, %11[0] : !llvm.struct<"struct.S3", (i64)> + %13 = llvm.mlir.addressof @g_316 : !llvm.ptr + %14 = llvm.mlir.addressof @g_316_1_0 : !llvm.ptr + llvm.store %0, %1 {alignment = 1 : i64} : i64, !llvm.ptr + %15 = llvm.load %3 {alignment = 1 : i64} : !llvm.ptr -> i16 + %16 = llvm.sext %15 : i16 to i64 + llvm.store %16, %1 {alignment = 1 : i64} : i64, !llvm.ptr + %17 = llvm.load %5 {alignment = 1 : i64} : !llvm.ptr -> i32 + %18 = llvm.zext %17 : i32 to i64 + llvm.store %18, %1 {alignment = 1 : i64} : i64, !llvm.ptr + %19 = llvm.load %6 {alignment = 1 : i64} : !llvm.ptr -> i32 + %20 = llvm.sext %19 : i32 to i64 + llvm.store %20, %1 {alignment = 1 : i64} : i64, !llvm.ptr + %21 = llvm.load %7 {alignment = 1 : i64} : !llvm.ptr -> i32 + %22 = llvm.zext %21 : i32 to i64 + llvm.store %22, %1 {alignment = 1 : i64} : i64, !llvm.ptr + %23 = llvm.load %8 {alignment = 1 : i64} : !llvm.ptr -> i16 + %24 = llvm.sext %23 : i16 to i64 + llvm.store %24, %1 {alignment = 1 : i64} : i64, !llvm.ptr + %25 = llvm.load %9 {alignment = 1 : i64} : !llvm.ptr -> i16 + %26 = llvm.sext %25 : i16 to i64 + llvm.store %26, %1 {alignment = 1 : i64} : i64, !llvm.ptr + %27 = llvm.load %10 {alignment = 1 : i64} : !llvm.ptr -> i16 + %28 = llvm.sext %27 : i16 to i64 + llvm.store %28, %1 {alignment = 1 : i64} : i64, !llvm.ptr + %29 = llvm.load %13 {alignment = 1 : i64} : !llvm.ptr -> i64 + llvm.store %29, %1 {alignment = 1 : i64} : i64, !llvm.ptr + %30 = llvm.load %14 {alignment = 1 : i64} : !llvm.ptr -> i16 + %31 = llvm.sext %30 : i16 to i64 + llvm.store %31, %1 {alignment = 1 : i64} : i64, !llvm.ptr + llvm.store %0, %1 {alignment = 1 : i64} : i64, !llvm.ptr + llvm.return %2 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/pr44835.ll.mlir b/test/LLVMDialect/InstCombine/pr44835.ll.mlir new file mode 100644 index 000000000..48d700fb7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr44835.ll.mlir @@ -0,0 +1,11 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %2 = llvm.load %arg1 {alignment = 4 : i64} : !llvm.ptr -> i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %arg1, %arg0 : i1, !llvm.ptr + "llvm.intr.memcpy"(%arg0, %4, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/pr46680.ll.mlir b/test/LLVMDialect/InstCombine/pr46680.ll.mlir index 6cfd5b602..b30d139f5 100644 --- a/test/LLVMDialect/InstCombine/pr46680.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr46680.ll.mlir @@ -1,63 +1,49 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "a", type = i64, value = 0 : i64} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "d", type = i64, value = 0 : i64} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "c", type = i8} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @c} : () -> !llvm.ptr - %1 = "llvm.mlir.addressof"() {global_name = @c} : () -> !llvm.ptr - %2 = "llvm.mlir.addressof"() {global_name = @c} : () -> !llvm.ptr - %3 = "llvm.mlir.addressof"() {global_name = @c} : () -> !llvm.ptr - %4 = "llvm.mlir.addressof"() {global_name = @c} : () -> !llvm.ptr - %5 = "llvm.mlir.addressof"() {global_name = @c} : () -> !llvm.ptr - %6 = "llvm.mlir.addressof"() {global_name = @c} : () -> !llvm.ptr - %7 = "llvm.mlir.addressof"() {global_name = @c} : () -> !llvm.ptr - %8 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr - %9 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %10 = "llvm.mlir.addressof"() {global_name = @d} : () -> !llvm.ptr - %11 = "llvm.load"(%10) : (!llvm.ptr) -> i64 - %12 = "llvm.icmp"(%11, %9) {predicate = 0 : i64} : (i64, i64) -> i1 - %13 = "llvm.load"(%8) : (!llvm.ptr) -> i64 - %14 = "llvm.icmp"(%13, %9) {predicate = 1 : i64} : (i64, i64) -> i1 - "llvm.cond_br"(%12)[^bb2, ^bb1] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry, dense<64> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.mlir.global external local_unnamed_addr @a(0 : i64) {addr_space = 0 : i32, alignment = 8 : i64, dso_local} : i64 + llvm.mlir.global external local_unnamed_addr @d(0 : i64) {addr_space = 0 : i32, alignment = 8 : i64, dso_local} : i64 + llvm.mlir.global external local_unnamed_addr @c() {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : i8 + llvm.func local_unnamed_addr @test(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.addressof @d : !llvm.ptr + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @c : !llvm.ptr + %4 = llvm.load %1 {alignment = 8 : i64} : !llvm.ptr -> i64 + %5 = llvm.icmp "eq" %4, %0 : i64 + %6 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> i64 + %7 = llvm.icmp "ne" %6, %0 : i64 + llvm.cond_br %5, ^bb2, ^bb1 ^bb1: // pred: ^bb0 - %15 = "llvm.load"(%arg0) : (!llvm.ptr) -> i16 - %16 = "llvm.trunc"(%15) : (i16) -> i8 - "llvm.store"(%16, %7) : (i8, !llvm.ptr) -> () - "llvm.call"(%14) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %17 = "llvm.load"(%arg0) : (!llvm.ptr) -> i16 - %18 = "llvm.trunc"(%17) : (i16) -> i8 - "llvm.store"(%18, %6) : (i8, !llvm.ptr) -> () - %19 = "llvm.load"(%arg0) : (!llvm.ptr) -> i16 - %20 = "llvm.trunc"(%19) : (i16) -> i8 - "llvm.store"(%20, %5) : (i8, !llvm.ptr) -> () - %21 = "llvm.load"(%arg0) : (!llvm.ptr) -> i16 - %22 = "llvm.trunc"(%21) : (i16) -> i8 - "llvm.store"(%22, %4) : (i8, !llvm.ptr) -> () - "llvm.br"()[^bb3] : () -> () + %8 = llvm.load %arg0 {alignment = 2 : i64} : !llvm.ptr -> i16 + %9 = llvm.trunc %8 : i16 to i8 + llvm.store %9, %3 {alignment = 1 : i64} : i8, !llvm.ptr + "llvm.intr.assume"(%7) : (i1) -> () + %10 = llvm.load %arg0 {alignment = 2 : i64} : !llvm.ptr -> i16 + %11 = llvm.trunc %10 : i16 to i8 + llvm.store %11, %3 {alignment = 1 : i64} : i8, !llvm.ptr + %12 = llvm.load %arg0 {alignment = 2 : i64} : !llvm.ptr -> i16 + %13 = llvm.trunc %12 : i16 to i8 + llvm.store %13, %3 {alignment = 1 : i64} : i8, !llvm.ptr + %14 = llvm.load %arg0 {alignment = 2 : i64} : !llvm.ptr -> i16 + %15 = llvm.trunc %14 : i16 to i8 + llvm.store %15, %3 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.br ^bb3 ^bb2: // pred: ^bb0 - %23 = "llvm.load"(%arg0) : (!llvm.ptr) -> i16 - %24 = "llvm.trunc"(%23) : (i16) -> i8 - "llvm.store"(%24, %3) : (i8, !llvm.ptr) -> () - %25 = "llvm.load"(%arg0) : (!llvm.ptr) -> i16 - %26 = "llvm.trunc"(%25) : (i16) -> i8 - "llvm.store"(%26, %2) : (i8, !llvm.ptr) -> () - %27 = "llvm.load"(%arg0) : (!llvm.ptr) -> i16 - %28 = "llvm.trunc"(%27) : (i16) -> i8 - "llvm.store"(%28, %1) : (i8, !llvm.ptr) -> () - %29 = "llvm.load"(%arg0) : (!llvm.ptr) -> i16 - %30 = "llvm.trunc"(%29) : (i16) -> i8 - "llvm.store"(%30, %0) : (i8, !llvm.ptr) -> () - "llvm.br"()[^bb3] : () -> () + %16 = llvm.load %arg0 {alignment = 2 : i64} : !llvm.ptr -> i16 + %17 = llvm.trunc %16 : i16 to i8 + llvm.store %17, %3 {alignment = 1 : i64} : i8, !llvm.ptr + %18 = llvm.load %arg0 {alignment = 2 : i64} : !llvm.ptr -> i16 + %19 = llvm.trunc %18 : i16 to i8 + llvm.store %19, %3 {alignment = 1 : i64} : i8, !llvm.ptr + %20 = llvm.load %arg0 {alignment = 2 : i64} : !llvm.ptr -> i16 + %21 = llvm.trunc %20 : i16 to i8 + llvm.store %21, %3 {alignment = 1 : i64} : i8, !llvm.ptr + %22 = llvm.load %arg0 {alignment = 2 : i64} : !llvm.ptr -> i16 + %23 = llvm.trunc %22 : i16 to i8 + llvm.store %23, %3 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.br ^bb3 ^bb3: // 2 preds: ^bb1, ^bb2 - "llvm.br"()[^bb4] : () -> () + llvm.br ^bb4 ^bb4: // 2 preds: ^bb3, ^bb4 - "llvm.br"()[^bb4] : () -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.assume", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.br ^bb4 + } +} diff --git a/test/LLVMDialect/InstCombine/pr49688.ll.mlir b/test/LLVMDialect/InstCombine/pr49688.ll.mlir new file mode 100644 index 000000000..cbaf366c9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr49688.ll.mlir @@ -0,0 +1,23 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.ashr %1, %arg0 : i32 + %5 = llvm.icmp "sgt" %arg0, %4 : i32 + %6 = llvm.select %3, %2, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @f2(%arg0: i32 {llvm.signext}, %arg1: i32 {llvm.zeroext}) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.ashr %1, %arg1 : i32 + %5 = llvm.icmp "sgt" %arg0, %4 : i32 + %6 = llvm.select %3, %2, %5 : i1, i1 + %7 = llvm.zext %6 : i1 to i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr51824.ll.mlir b/test/LLVMDialect/InstCombine/pr51824.ll.mlir new file mode 100644 index 000000000..5bca7f3f7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr51824.ll.mlir @@ -0,0 +1,45 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @PR51824(%arg0: vector<4xi16>, %arg1: !llvm.ptr, %arg2: i1, %arg3: !llvm.ptr) { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(-32768 : i16) : i16 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.mlir.constant(dense<0> : vector<4xi16>) : vector<4xi16> + %5 = llvm.mlir.poison : vector<4xi16> + %6 = llvm.mlir.zero : !llvm.ptr + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.mlir.undef : vector<4xi32> + %9 = llvm.mlir.undef : i32 + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.mlir.poison : i1 + %12 = llvm.icmp "sgt" %0, %1 : i1 + %13 = llvm.lshr %2, %3 : i16 + %14 = llvm.icmp "uge" %13, %13 : i16 + %15 = llvm.extractelement %4[%13 : i16] : vector<4xi16> + %16 = llvm.insertelement %15, %5[%3 : i16] : vector<4xi16> + %17 = llvm.sext %16 : vector<4xi16> to vector<4xi32> + %18 = llvm.getelementptr inbounds %6[%17] : (!llvm.ptr, vector<4xi32>) -> !llvm.vec<4 x ptr>, i64 + %19 = llvm.ptrtoint %18 : !llvm.vec<4 x ptr> to vector<4xi32> + %20 = llvm.extractelement %19[%3 : i16] : vector<4xi32> + llvm.br ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb1 + %21 = llvm.alloca %7 x vector<4xi32> {alignment = 16 : i64} : (i32) -> !llvm.ptr + %22 = llvm.load %21 {alignment = 16 : i64} : !llvm.ptr -> vector<4xi32> + %23 = llvm.getelementptr %6[%20] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + %24 = llvm.getelementptr inbounds %23[%arg0] : (!llvm.ptr, vector<4xi16>) -> !llvm.vec<4 x ptr>, i64 + %25 = llvm.ptrtoint %24 : !llvm.vec<4 x ptr> to vector<4xi32> + %26 = llvm.extractelement %22[%0 : i1] : vector<4xi32> + %27 = llvm.extractelement %25[%0 : i1] : vector<4xi32> + %28 = llvm.insertelement %9, %8[%27 : i32] : vector<4xi32> + %29 = llvm.insertelement %26, %28[%3 : i16] : vector<4xi32> + %30 = llvm.shufflevector %29, %22 [-1, -1, -1, -1] : vector<4xi32> + %31 = llvm.insertelement %10, %29[%14 : i1] : vector<4xi32> + %32 = llvm.extractelement %31[%11 : i1] : vector<4xi32> + llvm.store %32, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb2: // pred: ^bb1 + %33 = llvm.shufflevector %28, %30 [-1, -1, -1, -1] : vector<4xi32> + llvm.store %33, %arg3 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/pr53357.ll.mlir b/test/LLVMDialect/InstCombine/pr53357.ll.mlir new file mode 100644 index 000000000..a255e1164 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr53357.ll.mlir @@ -0,0 +1,73 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @src(%arg0: i32 {llvm.noundef}, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.or %arg1, %arg0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.add %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @src_vec(%arg0: vector<2xi32> {llvm.noundef}, %arg1: vector<2xi32> {llvm.noundef}) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg1, %arg0 : vector<2xi32> + %2 = llvm.or %arg1, %arg0 : vector<2xi32> + %3 = llvm.xor %2, %0 : vector<2xi32> + %4 = llvm.add %1, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @src_vec_poison(%arg0: vector<2xi32> {llvm.noundef}, %arg1: vector<2xi32> {llvm.noundef}) -> vector<2xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.and %arg1, %arg0 : vector<2xi32> + %8 = llvm.or %arg1, %arg0 : vector<2xi32> + %9 = llvm.xor %8, %6 : vector<2xi32> + %10 = llvm.add %7, %9 : vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @src2(%arg0: i32 {llvm.noundef}, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.or %arg0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.add %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @src3(%arg0: i32 {llvm.noundef}, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %arg1, %0 : i32 + %4 = llvm.and %2, %3 : i32 + %5 = llvm.add %1, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @src4(%arg0: i32 {llvm.noundef}, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.or %arg1, %arg0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.add %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @src5(%arg0: i32 {llvm.noundef}, %arg1: i32 {llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.and %arg1, %arg0 : i32 + %4 = llvm.add %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @src6(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.or %arg2, %arg3 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.add %1, %3 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr55228.ll.mlir b/test/LLVMDialect/InstCombine/pr55228.ll.mlir new file mode 100644 index 000000000..7082e443a --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr55228.ll.mlir @@ -0,0 +1,22 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g() {addr_space = 0 : i32} : i8 + llvm.mlir.global external constant @c() {addr_space = 0 : i32} : !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.addressof @g : !llvm.ptr + %2 = llvm.getelementptr inbounds %1[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.return %2 : !llvm.ptr + } + llvm.func @test(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.addressof @g : !llvm.ptr + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %4 = llvm.mlir.addressof @c : !llvm.ptr + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.alloca %0 x !llvm.ptr {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%6, %4, %5) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + %7 = llvm.load %6 {alignment = 1 : i64} : !llvm.ptr -> !llvm.ptr + %8 = llvm.icmp "eq" %arg0, %7 : !llvm.ptr + llvm.return %8 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/pr56424.ll.mlir b/test/LLVMDialect/InstCombine/pr56424.ll.mlir index f739dec0a..a8b7c648a 100644 --- a/test/LLVMDialect/InstCombine/pr56424.ll.mlir +++ b/test/LLVMDialect/InstCombine/pr56424.ll.mlir @@ -1,17 +1,15 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -81 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = -2 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - "llvm.cond_br"(%arg0, %2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i64) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @PR56424(%arg0: i1, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.mlir.constant(-81 : i64) : i64 + llvm.cond_br %arg0, ^bb1, ^bb2(%0 : i64) ^bb1: // pred: ^bb0 - %3 = "llvm.ashr"(%arg1, %1) : (i32, i32) -> i32 - %4 = "llvm.sext"(%3) : (i32) -> i64 - "llvm.br"(%4)[^bb2] : (i64) -> () + %3 = llvm.ashr %arg1, %1 : i32 + %4 = llvm.sext %3 : i32 to i64 + llvm.br ^bb2(%4 : i64) ^bb2(%5: i64): // 2 preds: ^bb0, ^bb1 - %6 = "llvm.and"(%0, %5) : (i64, i64) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "PR56424", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %6 = llvm.and %2, %5 : i64 + llvm.return %6 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/pr58901.ll.mlir b/test/LLVMDialect/InstCombine/pr58901.ll.mlir new file mode 100644 index 000000000..170e0ba1f --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr58901.ll.mlir @@ -0,0 +1,15 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f1(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<6 x i32> + %3 = llvm.getelementptr %2[%1, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<6 x i32> + llvm.return %3 : !llvm.ptr + } + llvm.func @f2(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<6 x i32> + %2 = llvm.getelementptr %1[%arg1, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<6 x i32> + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/pr59613.ll.mlir b/test/LLVMDialect/InstCombine/pr59613.ll.mlir new file mode 100644 index 000000000..edb2f621a --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr59613.ll.mlir @@ -0,0 +1,30 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pr59613(%arg0: vector<6xi16>) { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : vector<6xi16>) : vector<6xi16> + %2 = llvm.mlir.undef : i1 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.mlir.undef : vector<6xi1> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %4, %5[%6 : i32] : vector<6xi1> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %3, %7[%8 : i32] : vector<6xi1> + %10 = llvm.mlir.constant(2 : i32) : i32 + %11 = llvm.insertelement %3, %9[%10 : i32] : vector<6xi1> + %12 = llvm.mlir.constant(3 : i32) : i32 + %13 = llvm.insertelement %3, %11[%12 : i32] : vector<6xi1> + %14 = llvm.mlir.constant(4 : i32) : i32 + %15 = llvm.insertelement %2, %13[%14 : i32] : vector<6xi1> + %16 = llvm.mlir.constant(5 : i32) : i32 + %17 = llvm.insertelement %2, %15[%16 : i32] : vector<6xi1> + %18 = llvm.mlir.constant(dense<-1> : vector<6xi16>) : vector<6xi16> + %19 = llvm.mlir.zero : !llvm.ptr + %20 = llvm.icmp "ne" %arg0, %1 : vector<6xi16> + %21 = llvm.or %17, %20 : vector<6xi1> + %22 = llvm.sext %21 : vector<6xi1> to vector<6xi16> + %23 = llvm.xor %22, %18 : vector<6xi16> + llvm.store %23, %19 {alignment = 16 : i64} : vector<6xi16>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/pr63791.ll.mlir b/test/LLVMDialect/InstCombine/pr63791.ll.mlir new file mode 100644 index 000000000..6fc20b0e8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr63791.ll.mlir @@ -0,0 +1,42 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal constant @j(4 : i32) {addr_space = 0 : i32, dso_local} : i32 + llvm.func @y() { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.addressof @j : !llvm.ptr + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(41 : i32) : i32 + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(-1020499714 : i32) : i32 + %7 = llvm.mlir.constant(-1020499638 : i32) : i32 + %8 = llvm.mlir.zero : !llvm.ptr + %9 = llvm.mlir.constant(0 : i64) : i64 + llvm.br ^bb1(%1 : !llvm.ptr) + ^bb1(%10: !llvm.ptr): // 3 preds: ^bb0, ^bb1, ^bb2 + %11 = llvm.load %10 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.cond_br %2, ^bb1(%1 : !llvm.ptr), ^bb3(%11 : i32) + ^bb2: // 2 preds: ^bb3, ^bb4 + %12 = llvm.load %8 {alignment = 4 : i64} : !llvm.ptr -> i32 + %13 = llvm.sext %12 : i32 to i64 + %14 = llvm.icmp "eq" %9, %13 : i64 + llvm.cond_br %14, ^bb1(%8 : !llvm.ptr), ^bb3(%5 : i32) + ^bb3(%15: i32): // 2 preds: ^bb1, ^bb2 + %16 = llvm.or %11, %3 : i32 + %17 = llvm.icmp "sgt" %11, %4 : i32 + %18 = llvm.select %17, %16, %5 : i1, i32 + %19 = llvm.add %18, %3 : i32 + %20 = llvm.icmp "sgt" %18, %5 : i32 + %21 = llvm.select %20, %19, %5 : i1, i32 + %22 = llvm.icmp "eq" %19, %5 : i32 + %23 = llvm.or %19, %16 : i32 + %24 = llvm.icmp "sgt" %23, %5 : i32 + %25 = llvm.select %17, %24, %2 : i1, i1 + %26 = llvm.select %25, %5, %21 : i1, i32 + %27 = llvm.select %22, %5, %26 : i1, i32 + %28 = llvm.or %27, %6 : i32 + %29 = llvm.icmp "sgt" %28, %7 : i32 + llvm.cond_br %29, ^bb4, ^bb2 + ^bb4: // 2 preds: ^bb3, ^bb4 + llvm.cond_br %25, ^bb4, ^bb2 + } +} diff --git a/test/LLVMDialect/InstCombine/pr69059.ll.mlir b/test/LLVMDialect/InstCombine/pr69059.ll.mlir new file mode 100644 index 000000000..803c91b83 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr69059.ll.mlir @@ -0,0 +1,8 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pr69059() -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @labs(%0) : (i32) -> i64 + llvm.return %1 : i64 + } + llvm.func @labs(i32) -> i64 +} diff --git a/test/LLVMDialect/InstCombine/pr71330.ll.mlir b/test/LLVMDialect/InstCombine/pr71330.ll.mlir new file mode 100644 index 000000000..56c273231 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr71330.ll.mlir @@ -0,0 +1,50 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pr71330(%arg0: i32, %arg1: i1, %arg2: i16) { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.mlir.constant(true) : i1 + %6 = llvm.mlir.constant(0 : i64) : i64 + llvm.br ^bb1(%0 : i32) + ^bb1(%7: i32): // 2 preds: ^bb0, ^bb7 + %8 = llvm.and %7, %1 : i32 + %9 = llvm.add %7, %2 : i32 + %10 = llvm.icmp "eq" %8, %3 : i32 + %11 = llvm.icmp "eq" %9, %3 : i32 + %12 = llvm.and %7, %1 : i32 + %13 = llvm.icmp "eq" %12, %3 : i32 + %14 = llvm.icmp "eq" %9, %3 : i32 + %15 = llvm.select %14, %1, %4 : i1, i32 + llvm.cond_br %arg1, ^bb2, ^bb5 + ^bb2: // pred: ^bb1 + llvm.cond_br %10, ^bb3, ^bb4 + ^bb3: // 2 preds: ^bb2, ^bb3 + %16 = llvm.select %13, %1, %15 : i1, i32 + %17 = llvm.select %11, %3, %16 : i1, i32 + %18 = llvm.add %17, %arg0 : i32 + %19 = llvm.sext %18 : i32 to i64 + %20 = llvm.icmp "slt" %19, %6 : i64 + llvm.cond_br %20, ^bb3, ^bb7 + ^bb4: // pred: ^bb2 + llvm.return + ^bb5: // pred: ^bb1 + %21 = llvm.xor %10, %5 : i1 + %22 = llvm.select %21, %5, %11 : i1, i1 + %23 = llvm.select %13, %1, %15 : i1, i32 + %24 = llvm.select %22, %3, %23 : i1, i32 + %25 = llvm.add %24, %arg0 : i32 + %26 = llvm.sext %25 : i32 to i64 + %27 = llvm.icmp "slt" %26, %6 : i64 + llvm.cond_br %27, ^bb6, ^bb7 + ^bb6: // pred: ^bb5 + llvm.return + ^bb7: // 2 preds: ^bb3, ^bb5 + %28 = llvm.zext %arg2 : i16 to i32 + %29 = llvm.icmp "slt" %28, %3 : i32 + llvm.cond_br %29, ^bb1(%3 : i32), ^bb8 + ^bb8: // pred: ^bb7 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/pr72433.ll.mlir b/test/LLVMDialect/InstCombine/pr72433.ll.mlir new file mode 100644 index 000000000..ac363f05f --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr72433.ll.mlir @@ -0,0 +1,17 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @widget(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(20 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %0 : i32 + %5 = llvm.zext %4 : i1 to i32 + %6 = llvm.sub %1, %5 : i32 + %7 = llvm.mul %2, %6 : i32 + %8 = llvm.zext %4 : i1 to i32 + %9 = llvm.xor %8, %3 : i32 + %10 = llvm.add %7, %9 : i32 + %11 = llvm.mul %10, %6 : i32 + llvm.return %11 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr75129.ll.mlir b/test/LLVMDialect/InstCombine/pr75129.ll.mlir new file mode 100644 index 000000000..df65806d4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr75129.ll.mlir @@ -0,0 +1,14 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @or_and_add_and() -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(48 : i16) : i16 + %2 = llvm.mlir.constant(15 : i16) : i16 + %3 = llvm.call @dummy() : () -> i16 + %4 = llvm.add %0, %3 : i16 + %5 = llvm.and %4, %1 : i16 + %6 = llvm.and %3, %2 : i16 + %7 = llvm.or %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @dummy() -> i16 +} diff --git a/test/LLVMDialect/InstCombine/pr75369.ll.mlir b/test/LLVMDialect/InstCombine/pr75369.ll.mlir new file mode 100644 index 000000000..f1d265e39 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr75369.ll.mlir @@ -0,0 +1,28 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @main(%arg0: !llvm.ptr, %arg1: i8, %arg2: i32, %arg3: i8) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.sext %arg3 : i8 to i32 + %5 = llvm.xor %arg2, %0 : i32 + %6 = llvm.or %4, %arg2 : i32 + %7 = llvm.xor %6, %1 : i32 + %8 = llvm.lshr %7, %0 : i32 + %9 = llvm.sub %5, %8 : i32 + %10 = llvm.trunc %9 : i32 to i8 + llvm.store %10, %arg0 {alignment = 1 : i64} : i8, !llvm.ptr + %11 = llvm.shl %arg2, %2 : i32 + %12 = llvm.ashr %11, %2 : i32 + %13 = llvm.trunc %arg2 : i32 to i8 + %14 = llvm.or %13, %3 : i8 + %15 = llvm.xor %14, %3 : i8 + %16 = llvm.xor %arg1, %3 : i8 + %17 = llvm.xor %16, %3 : i8 + %18 = llvm.or %15, %17 : i8 + llvm.store %18, %arg0 {alignment = 1 : i64} : i8, !llvm.ptr + %19 = llvm.icmp "slt" %arg3, %3 : i8 + "llvm.intr.assume"(%19) : (i1) -> () + llvm.return %12 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr77064.ll.mlir b/test/LLVMDialect/InstCombine/pr77064.ll.mlir new file mode 100644 index 000000000..7e23f6ab1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr77064.ll.mlir @@ -0,0 +1,12 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @main(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(596 : i64) : i64 + %2 = llvm.mlir.constant(-1 : i64) : i64 + %3 = llvm.call fastcc @opendir(%arg0) : (!llvm.ptr) -> !llvm.ptr + %4 = llvm.call @__memset_chk(%3, %0, %1, %2) : (!llvm.ptr, i32, i64, i64) -> !llvm.ptr + llvm.return + } + llvm.func @__memset_chk(!llvm.ptr, i32, i64, i64) -> !llvm.ptr + llvm.func fastcc @opendir(!llvm.ptr) -> !llvm.ptr +} diff --git a/test/LLVMDialect/InstCombine/pr80597.ll.mlir b/test/LLVMDialect/InstCombine/pr80597.ll.mlir new file mode 100644 index 000000000..366ebea90 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr80597.ll.mlir @@ -0,0 +1,22 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pr80597(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(4294967293 : i64) : i64 + %2 = llvm.mlir.constant(32 : i64) : i64 + %3 = llvm.mlir.constant(8836839514384105472 : i64) : i64 + %4 = llvm.mlir.constant(-34359738368 : i64) : i64 + %5 = llvm.mlir.constant(8836839522974040064 : i64) : i64 + %6 = llvm.mlir.constant(1 : i64) : i64 + %7 = llvm.select %arg0, %0, %1 : i1, i64 + %8 = llvm.shl %7, %2 : i64 + %9 = llvm.add %8, %3 : i64 + %10 = llvm.icmp "ult" %9, %4 : i64 + llvm.cond_br %10, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + %11 = llvm.or %8, %5 : i64 + %12 = llvm.ashr %11, %6 : i64 + llvm.return %12 : i64 + ^bb2: // pred: ^bb0 + llvm.return %0 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/pr80941.ll.mlir b/test/LLVMDialect/InstCombine/pr80941.ll.mlir new file mode 100644 index 000000000..c38af26c2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr80941.ll.mlir @@ -0,0 +1,14 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pr80941(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = "llvm.intr.is.fpclass"(%arg0) <{bit = 144 : i32}> : (f32) -> i1 + llvm.cond_br %1, ^bb1, ^bb2(%arg0 : f32) + ^bb1: // pred: ^bb0 + %2 = llvm.fpext %arg0 : f32 to f64 + %3 = llvm.intr.copysign(%0, %2) : (f64, f64) -> f64 + %4 = llvm.fptrunc %3 : f64 to f32 + llvm.br ^bb2(%4 : f32) + ^bb2(%5: f32): // 2 preds: ^bb0, ^bb1 + llvm.return %5 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/pr82877.ll.mlir b/test/LLVMDialect/InstCombine/pr82877.ll.mlir new file mode 100644 index 000000000..550ae731c --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr82877.ll.mlir @@ -0,0 +1,19 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @func(%arg0: i32, %arg1: i1) -> i64 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1231558963 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.xor %arg0, %0 : i32 + llvm.br ^bb1(%5 : i32) + ^bb1(%6: i32): // 2 preds: ^bb0, ^bb1 + %7 = llvm.select %arg1, %1, %2 : i1, i32 + %8 = llvm.xor %7, %6 : i32 + %9 = llvm.icmp "ne" %8, %3 : i32 + %10 = llvm.zext %9 : i1 to i32 + llvm.cond_br %9, ^bb1(%10 : i32), ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %4 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/pr83931.ll.mlir b/test/LLVMDialect/InstCombine/pr83931.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/pr83947.ll.mlir b/test/LLVMDialect/InstCombine/pr83947.ll.mlir new file mode 100644 index 000000000..136d835e0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pr83947.ll.mlir @@ -0,0 +1,129 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @c(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.mlir.global external @b(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.func @masked_scatter1() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.vec + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.insertelement %0, %5[%6 : i32] : !llvm.vec + %8 = llvm.mlir.constant(3 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : !llvm.vec + %10 = llvm.mlir.poison : !llvm.vec + %11 = llvm.mlir.constant(0 : i64) : i64 + %12 = llvm.mlir.addressof @c : !llvm.ptr + %13 = llvm.insertelement %12, %10[%11 : i64] : !llvm.vec + %14 = llvm.shufflevector %13, %10 [0, 0, 0, 0] : !llvm.vec + %15 = llvm.mlir.poison : !llvm.vec + %16 = llvm.mlir.addressof @b : !llvm.ptr + %17 = llvm.ptrtoint %16 : !llvm.ptr to i1 + %18 = llvm.insertelement %17, %15[%11 : i64] : !llvm.vec + %19 = llvm.shufflevector %18, %15 [0, 0, 0, 0] : !llvm.vec + %20 = llvm.mlir.constant(4 : i32) : i32 + llvm.intr.masked.scatter %9, %14, %19 {alignment = 4 : i32} : !llvm.vec, vector<[4]xi1> into !llvm.vec + llvm.return + } + llvm.func @masked_scatter2() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.addressof @c : !llvm.ptr + %3 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : !llvm.vec<2 x ptr> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : !llvm.vec<2 x ptr> + %8 = llvm.mlir.constant(true) : i1 + %9 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %10 = llvm.mlir.constant(4 : i32) : i32 + llvm.intr.masked.scatter %1, %7, %9 {alignment = 4 : i32} : vector<2xi32>, vector<2xi1> into !llvm.vec<2 x ptr> + llvm.return + } + llvm.func @masked_scatter3() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.addressof @c : !llvm.ptr + %3 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : !llvm.vec<2 x ptr> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : !llvm.vec<2 x ptr> + %8 = llvm.mlir.undef : vector<2xi1> + %9 = llvm.mlir.constant(4 : i32) : i32 + llvm.intr.masked.scatter %1, %7, %8 {alignment = 4 : i32} : vector<2xi32>, vector<2xi1> into !llvm.vec<2 x ptr> + llvm.return + } + llvm.func @masked_scatter4() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.addressof @c : !llvm.ptr + %3 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : !llvm.vec<2 x ptr> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : !llvm.vec<2 x ptr> + %8 = llvm.mlir.constant(false) : i1 + %9 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %10 = llvm.mlir.constant(4 : i32) : i32 + llvm.intr.masked.scatter %1, %7, %9 {alignment = 4 : i32} : vector<2xi32>, vector<2xi1> into !llvm.vec<2 x ptr> + llvm.return + } + llvm.func @masked_scatter5() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.addressof @c : !llvm.ptr + %3 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : !llvm.vec<2 x ptr> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : !llvm.vec<2 x ptr> + %8 = llvm.mlir.constant(false) : i1 + %9 = llvm.mlir.constant(true) : i1 + %10 = llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : vector<2xi1> + %11 = llvm.mlir.constant(4 : i32) : i32 + llvm.intr.masked.scatter %1, %7, %10 {alignment = 4 : i32} : vector<2xi32>, vector<2xi1> into !llvm.vec<2 x ptr> + llvm.return + } + llvm.func @masked_scatter6() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.addressof @c : !llvm.ptr + %3 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : !llvm.vec<2 x ptr> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : !llvm.vec<2 x ptr> + %8 = llvm.mlir.constant(false) : i1 + %9 = llvm.mlir.undef : i1 + %10 = llvm.mlir.undef : vector<2xi1> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<2xi1> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %8, %12[%13 : i32] : vector<2xi1> + %15 = llvm.mlir.constant(4 : i32) : i32 + llvm.intr.masked.scatter %1, %7, %14 {alignment = 4 : i32} : vector<2xi32>, vector<2xi1> into !llvm.vec<2 x ptr> + llvm.return + } + llvm.func @masked_scatter7() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.addressof @c : !llvm.ptr + %3 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : !llvm.vec<2 x ptr> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : !llvm.vec<2 x ptr> + %8 = llvm.mlir.addressof @b : !llvm.ptr + %9 = llvm.ptrtoint %8 : !llvm.ptr to i1 + %10 = llvm.mlir.undef : vector<2xi1> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<2xi1> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %9, %12[%13 : i32] : vector<2xi1> + %15 = llvm.mlir.constant(4 : i32) : i32 + llvm.intr.masked.scatter %1, %7, %14 {alignment = 4 : i32} : vector<2xi32>, vector<2xi1> into !llvm.vec<2 x ptr> + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/prefetch-load.ll.mlir b/test/LLVMDialect/InstCombine/prefetch-load.ll.mlir index 0d25aadae..4669db585 100644 --- a/test/LLVMDialect/InstCombine/prefetch-load.ll.mlir +++ b/test/LLVMDialect/InstCombine/prefetch-load.ll.mlir @@ -1,24 +1,17 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, i32)>>): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.getelementptr"(%arg0, %2, %2) : (!llvm.ptr>, i32)>>, i32, i32) -> !llvm.ptr>, i32)>>> - %4 = "llvm.load"(%3) : (!llvm.ptr>, i32)>>>) -> !llvm.ptr>, i32)>> - %5 = "llvm.getelementptr"(%4, %2, %2) : (!llvm.ptr>, i32)>>, i32, i32) -> !llvm.ptr>, i32)>>> - %6 = "llvm.load"(%5) : (!llvm.ptr>, i32)>>>) -> !llvm.ptr>, i32)>> - "llvm.store"(%6, %3) : (!llvm.ptr>, i32)>>, !llvm.ptr>, i32)>>>) -> () - %7 = "llvm.getelementptr"(%arg0, %2, %1) : (!llvm.ptr>, i32)>>, i32, i32) -> !llvm.ptr - %8 = "llvm.load"(%7) : (!llvm.ptr) -> i32 - %9 = "llvm.add"(%8, %0) : (i32, i32) -> i32 - "llvm.store"(%9, %7) : (i32, !llvm.ptr) -> () - %10 = "llvm.bitcast"(%6) : (!llvm.ptr>, i32)>>) -> !llvm.ptr - "llvm.call"(%10, %2, %2, %1) {callee = @llvm.prefetch.p0i8, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32, i32, i32) -> () - %11 = "llvm.load"(%7) : (!llvm.ptr) -> i32 - "llvm.return"(%11) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func>, i32)>>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.prefetch.p0i8", type = !llvm.func, i32, i32, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func local_unnamed_addr @foo(%arg0: !llvm.ptr) -> (i32 {llvm.signext}) attributes {passthrough = ["noinline", "nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %4 = llvm.load %3 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.store %4, %arg0 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %5 = llvm.getelementptr inbounds %arg0[%0, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.C", (ptr, i32)> + %6 = llvm.load %5 {alignment = 8 : i64} : !llvm.ptr -> i32 + %7 = llvm.add %6, %2 overflow : i32 + llvm.store %7, %5 {alignment = 8 : i64} : i32, !llvm.ptr + "llvm.intr.prefetch"(%4) <{cache = 1 : i32, hint = 0 : i32, rw = 0 : i32}> : (!llvm.ptr) -> () + %8 = llvm.load %5 {alignment = 8 : i64} : !llvm.ptr -> i32 + llvm.return %8 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/preserve-sminmax.ll.mlir b/test/LLVMDialect/InstCombine/preserve-sminmax.ll.mlir new file mode 100644 index 000000000..a7cb1d91c --- /dev/null +++ b/test/LLVMDialect/InstCombine/preserve-sminmax.ll.mlir @@ -0,0 +1,18 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.sdiv %arg0, %0 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @bar(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.sdiv %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/preserved-analyses.ll.mlir b/test/LLVMDialect/InstCombine/preserved-analyses.ll.mlir index 9cd8d9905..a8b950128 100644 --- a/test/LLVMDialect/InstCombine/preserved-analyses.ll.mlir +++ b/test/LLVMDialect/InstCombine/preserved-analyses.ll.mlir @@ -1,11 +1,9 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -5 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.add"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.add"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(-5 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.add %2, %1 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/prevent-cmp-merge.ll.mlir b/test/LLVMDialect/InstCombine/prevent-cmp-merge.ll.mlir new file mode 100644 index 000000000..1744df503 --- /dev/null +++ b/test/LLVMDialect/InstCombine/prevent-cmp-merge.ll.mlir @@ -0,0 +1,49 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32, %arg1: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.icmp "eq" %2, %arg1 : i32 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @test1_logical(%arg0: i32, %arg1: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.icmp "eq" %3, %arg1 : i32 + %6 = llvm.select %4, %2, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @test2(%arg0: i32, %arg1: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.xor %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.icmp "eq" %2, %1 : i32 + %5 = llvm.xor %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @test3(%arg0: i32, %arg1: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %arg0, %arg1 overflow : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.icmp "eq" %2, %1 : i32 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @test3_logical(%arg0: i32, %arg1: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.sub %arg0, %arg1 overflow : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + %5 = llvm.icmp "eq" %3, %1 : i32 + %6 = llvm.select %4, %2, %5 : i1, i1 + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/printf-1.ll.mlir b/test/LLVMDialect/InstCombine/printf-1.ll.mlir new file mode 100644 index 000000000..b5582063d --- /dev/null +++ b/test/LLVMDialect/InstCombine/printf-1.ll.mlir @@ -0,0 +1,82 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello_world("hello world\0A\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @h("h\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @h2("%%\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent("%\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent_c("%c\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent_d("%d\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent_f("%f\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent_s("%s\0A\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @empty(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.func @printf(!llvm.ptr, ...) -> i32 + llvm.func @test_simplify1() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @empty : !llvm.ptr + %3 = llvm.call @printf(%2) vararg(!llvm.func) : (!llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify2() { + %0 = llvm.mlir.constant("h\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @h : !llvm.ptr + %2 = llvm.call @printf(%1) vararg(!llvm.func) : (!llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify2b() { + %0 = llvm.mlir.constant("%%\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @h2 : !llvm.ptr + %2 = llvm.call @printf(%1) vararg(!llvm.func) : (!llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify3() { + %0 = llvm.mlir.constant("%\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @percent : !llvm.ptr + %2 = llvm.call @printf(%1) vararg(!llvm.func) : (!llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify4() { + %0 = llvm.mlir.constant("hello world\0A\00") : !llvm.array<13 x i8> + %1 = llvm.mlir.addressof @hello_world : !llvm.ptr + %2 = llvm.call @printf(%1) vararg(!llvm.func) : (!llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify5() { + %0 = llvm.mlir.constant("%c\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_c : !llvm.ptr + %2 = llvm.mlir.constant(104 : i8) : i8 + %3 = llvm.call @printf(%1, %2) vararg(!llvm.func) : (!llvm.ptr, i8) -> i32 + llvm.return + } + llvm.func @test_simplify6() { + %0 = llvm.mlir.constant("%s\0A\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @percent_s : !llvm.ptr + %2 = llvm.mlir.constant("hello world\0A\00") : !llvm.array<13 x i8> + %3 = llvm.mlir.addressof @hello_world : !llvm.ptr + %4 = llvm.call @printf(%1, %3) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify7() { + %0 = llvm.mlir.constant("%d\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_d : !llvm.ptr + %2 = llvm.mlir.constant(187 : i32) : i32 + %3 = llvm.call @printf(%1, %2) vararg(!llvm.func) : (!llvm.ptr, i32) -> i32 + llvm.return + } + llvm.func @test_no_simplify1() { + %0 = llvm.mlir.constant("%f\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_f : !llvm.ptr + %2 = llvm.mlir.constant(1.870000e+00 : f64) : f64 + %3 = llvm.call @printf(%1, %2) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.return + } + llvm.func @test_no_simplify2(%arg0: !llvm.ptr, %arg1: f64) { + %0 = llvm.call @printf(%arg0, %arg1) vararg(!llvm.func) : (!llvm.ptr, f64) -> i32 + llvm.return + } + llvm.func @test_no_simplify3() -> i32 { + %0 = llvm.mlir.constant("h\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @h : !llvm.ptr + %2 = llvm.call @printf(%1) vararg(!llvm.func) : (!llvm.ptr) -> i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/printf-2.ll.mlir b/test/LLVMDialect/InstCombine/printf-2.ll.mlir new file mode 100644 index 000000000..aced35403 --- /dev/null +++ b/test/LLVMDialect/InstCombine/printf-2.ll.mlir @@ -0,0 +1,71 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello_world("hello world\0A\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @h("h\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent_s("%s\0A\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @format_str("%s\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @charstr("a\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @empty(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.func @printf(!llvm.ptr, ...) -> i32 + llvm.func @test_simplify1() { + %0 = llvm.mlir.constant("h\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @h : !llvm.ptr + %2 = llvm.call @printf(%1) vararg(!llvm.func) : (!llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify2() { + %0 = llvm.mlir.constant("hello world\0A\00") : !llvm.array<13 x i8> + %1 = llvm.mlir.addressof @hello_world : !llvm.ptr + %2 = llvm.call @printf(%1) vararg(!llvm.func) : (!llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify6() { + %0 = llvm.mlir.constant("%s\0A\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @percent_s : !llvm.ptr + %2 = llvm.mlir.constant("hello world\0A\00") : !llvm.array<13 x i8> + %3 = llvm.mlir.addressof @hello_world : !llvm.ptr + %4 = llvm.call @printf(%1, %3) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify7() { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @format_str : !llvm.ptr + %2 = llvm.mlir.constant("a\00") : !llvm.array<2 x i8> + %3 = llvm.mlir.addressof @charstr : !llvm.ptr + %4 = llvm.call @printf(%1, %3) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify8() { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @format_str : !llvm.ptr + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %4 = llvm.mlir.addressof @empty : !llvm.ptr + %5 = llvm.call @printf(%1, %4) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify9() { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @format_str : !llvm.ptr + %2 = llvm.mlir.constant("hello world\0A\00") : !llvm.array<13 x i8> + %3 = llvm.mlir.addressof @hello_world : !llvm.ptr + %4 = llvm.call @printf(%1, %3) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify10() { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @format_str : !llvm.ptr + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %4 = llvm.mlir.addressof @empty : !llvm.ptr + %5 = llvm.mlir.constant(42 : i32) : i32 + %6 = llvm.mlir.constant(3.1400001049041748 : f64) : f64 + %7 = llvm.mlir.constant("a\00") : !llvm.array<2 x i8> + %8 = llvm.mlir.addressof @charstr : !llvm.ptr + %9 = llvm.mlir.constant("hello world\0A\00") : !llvm.array<13 x i8> + %10 = llvm.mlir.addressof @hello_world : !llvm.ptr + %11 = llvm.call @printf(%1, %4, %5, %6) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, i32, f64) -> i32 + %12 = llvm.call @printf(%1, %8, %5, %6) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, i32, f64) -> i32 + %13 = llvm.call @printf(%1, %10, %5, %6) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, i32, f64) -> i32 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/printf-3.ll.mlir b/test/LLVMDialect/InstCombine/printf-3.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/printf-i16.ll.mlir b/test/LLVMDialect/InstCombine/printf-i16.ll.mlir index 69fdfd985..8917547a4 100644 --- a/test/LLVMDialect/InstCombine/printf-i16.ll.mlir +++ b/test/LLVMDialect/InstCombine/printf-i16.ll.mlir @@ -1,56 +1,44 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "s1", type = !llvm.array<2 x i8>, value = "\01\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "s7f", type = !llvm.array<2 x i8>, value = "\7F\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "s80", type = !llvm.array<2 x i8>, value = "\80\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "sff", type = !llvm.array<2 x i8>, value = "\FF\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "pcnt_c", type = !llvm.array<3 x i8>, value = "%c\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "pcnt_s", type = !llvm.array<3 x i8>, value = "%s\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "putchar", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "puts", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "printf", type = !llvm.func, ...)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 255 : i16} : () -> i16 - %1 = "llvm.mlir.addressof"() {global_name = @sff} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 128 : i16} : () -> i16 - %3 = "llvm.mlir.addressof"() {global_name = @s80} : () -> !llvm.ptr> - %4 = "llvm.mlir.constant"() {value = 127 : i16} : () -> i16 - %5 = "llvm.mlir.addressof"() {global_name = @s7f} : () -> !llvm.ptr> - %6 = "llvm.mlir.constant"() {value = 1 : i16} : () -> i16 - %7 = "llvm.mlir.addressof"() {global_name = @s1} : () -> !llvm.ptr> - %8 = "llvm.mlir.addressof"() {global_name = @pcnt_s} : () -> !llvm.ptr> - %9 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %10 = "llvm.mlir.addressof"() {global_name = @pcnt_c} : () -> !llvm.ptr> - %11 = "llvm.getelementptr"(%10, %9, %9) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %12 = "llvm.getelementptr"(%8, %9, %9) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %13 = "llvm.getelementptr"(%7, %9, %9) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %14 = "llvm.call"(%13) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i16 - %15 = "llvm.call"(%11, %6) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i16) -> i16 - %16 = "llvm.call"(%12, %13) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i16 - %17 = "llvm.getelementptr"(%5, %9, %9) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %18 = "llvm.call"(%17) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i16 - %19 = "llvm.call"(%11, %4) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i16) -> i16 - %20 = "llvm.call"(%12, %17) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i16 - %21 = "llvm.getelementptr"(%3, %9, %9) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %22 = "llvm.call"(%21) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i16 - %23 = "llvm.call"(%11, %2) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i16) -> i16 - %24 = "llvm.call"(%12, %21) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i16 - %25 = "llvm.getelementptr"(%1, %9, %9) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %26 = "llvm.call"(%25) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i16 - %27 = "llvm.call"(%11, %0) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i16) -> i16 - %28 = "llvm.call"(%12, %25) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i16 - %29 = "llvm.call"(%11, %arg0) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i8) -> i16 - %30 = "llvm.call"(%11, %arg1) {callee = @printf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i16) -> i16 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "xform_printf", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @s1("\01\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s7f("\7F\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s80("\80\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @sff("\FF\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @pcnt_c("%c\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @pcnt_s("%s\00") {addr_space = 0 : i32} + llvm.func @putchar(i16) -> i16 + llvm.func @puts(!llvm.ptr) -> i16 + llvm.func @printf(!llvm.ptr, ...) -> i16 + llvm.func @xform_printf(%arg0: i8, %arg1: i16) { + %0 = llvm.mlir.constant("\01\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @s1 : !llvm.ptr + %2 = llvm.mlir.constant("%c\00") : !llvm.array<3 x i8> + %3 = llvm.mlir.addressof @pcnt_c : !llvm.ptr + %4 = llvm.mlir.constant(1 : i16) : i16 + %5 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %6 = llvm.mlir.addressof @pcnt_s : !llvm.ptr + %7 = llvm.mlir.constant("\7F\00") : !llvm.array<2 x i8> + %8 = llvm.mlir.addressof @s7f : !llvm.ptr + %9 = llvm.mlir.constant(127 : i16) : i16 + %10 = llvm.mlir.constant("\80\00") : !llvm.array<2 x i8> + %11 = llvm.mlir.addressof @s80 : !llvm.ptr + %12 = llvm.mlir.constant(128 : i16) : i16 + %13 = llvm.mlir.constant("\FF\00") : !llvm.array<2 x i8> + %14 = llvm.mlir.addressof @sff : !llvm.ptr + %15 = llvm.mlir.constant(255 : i16) : i16 + %16 = llvm.call @printf(%1) vararg(!llvm.func) : (!llvm.ptr) -> i16 + %17 = llvm.call @printf(%3, %4) vararg(!llvm.func) : (!llvm.ptr, i16) -> i16 + %18 = llvm.call @printf(%6, %1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i16 + %19 = llvm.call @printf(%8) vararg(!llvm.func) : (!llvm.ptr) -> i16 + %20 = llvm.call @printf(%3, %9) vararg(!llvm.func) : (!llvm.ptr, i16) -> i16 + %21 = llvm.call @printf(%6, %8) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i16 + %22 = llvm.call @printf(%11) vararg(!llvm.func) : (!llvm.ptr) -> i16 + %23 = llvm.call @printf(%3, %12) vararg(!llvm.func) : (!llvm.ptr, i16) -> i16 + %24 = llvm.call @printf(%6, %11) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i16 + %25 = llvm.call @printf(%14) vararg(!llvm.func) : (!llvm.ptr) -> i16 + %26 = llvm.call @printf(%3, %15) vararg(!llvm.func) : (!llvm.ptr, i16) -> i16 + %27 = llvm.call @printf(%6, %14) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i16 + %28 = llvm.call @printf(%3, %arg0) vararg(!llvm.func) : (!llvm.ptr, i8) -> i16 + %29 = llvm.call @printf(%3, %arg1) vararg(!llvm.func) : (!llvm.ptr, i16) -> i16 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/ptr-int-cast.ll.mlir b/test/LLVMDialect/InstCombine/ptr-int-cast.ll.mlir index e523d912a..dd1bdb478 100644 --- a/test/LLVMDialect/InstCombine/ptr-int-cast.ll.mlir +++ b/test/LLVMDialect/InstCombine/ptr-int-cast.ll.mlir @@ -1,44 +1,35 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.ptrtoint"(%arg0) : (!llvm.ptr) -> i1 - "llvm.return"(%0) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i128): // no predecessors - %0 = "llvm.inttoptr"(%arg0) : (i128) -> !llvm.ptr - "llvm.return"(%0) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func (i128)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.inttoptr"(%arg0) : (i32) -> !llvm.ptr - %1 = "llvm.ptrtoint"(%0) : (!llvm.ptr) -> i64 - "llvm.return"(%1) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "f0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec<4 x ptr>): // no predecessors - %0 = "llvm.ptrtoint"(%arg0) : (!llvm.vec<4 x ptr>) -> vector<4xi32> - "llvm.return"(%0) : (vector<4xi32>) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func (vec<4 x ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec>): // no predecessors - %0 = "llvm.ptrtoint"(%arg0) : (!llvm.vec>) -> !llvm.vec - "llvm.return"(%0) : (!llvm.vec) -> () - }) {linkage = 10 : i64, sym_name = "testvscale4", type = !llvm.func (vec>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec<4 x ptr>): // no predecessors - %0 = "llvm.ptrtoint"(%arg0) : (!llvm.vec<4 x ptr>) -> vector<4xi128> - "llvm.return"(%0) : (vector<4xi128>) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func (vec<4 x ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi32>): // no predecessors - %0 = "llvm.inttoptr"(%arg0) : (vector<4xi32>) -> !llvm.vec<4 x ptr> - "llvm.return"(%0) : (!llvm.vec<4 x ptr>) -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func> (vector<4xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi128>): // no predecessors - %0 = "llvm.inttoptr"(%arg0) : (vector<4xi128>) -> !llvm.vec<4 x ptr> - "llvm.return"(%0) : (!llvm.vec<4 x ptr>) -> () - }) {linkage = 10 : i64, sym_name = "test7", type = !llvm.func> (vector<4xi128>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "big">>} { + llvm.func @test1(%arg0: !llvm.ptr) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.ptrtoint %arg0 : !llvm.ptr to i1 + llvm.return %0 : i1 + } + llvm.func @test2(%arg0: i128) -> !llvm.ptr attributes {passthrough = ["nounwind"]} { + %0 = llvm.inttoptr %arg0 : i128 to !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @f0(%arg0: i32) -> i64 attributes {passthrough = ["nounwind"]} { + %0 = llvm.inttoptr %arg0 : i32 to !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i64 + llvm.return %1 : i64 + } + llvm.func @test4(%arg0: !llvm.vec<4 x ptr>) -> vector<4xi32> attributes {passthrough = ["nounwind"]} { + %0 = llvm.ptrtoint %arg0 : !llvm.vec<4 x ptr> to vector<4xi32> + llvm.return %0 : vector<4xi32> + } + llvm.func @testvscale4(%arg0: !llvm.vec) -> !llvm.vec attributes {passthrough = ["nounwind"]} { + %0 = llvm.ptrtoint %arg0 : !llvm.vec to !llvm.vec + llvm.return %0 : !llvm.vec + } + llvm.func @test5(%arg0: !llvm.vec<4 x ptr>) -> vector<4xi128> attributes {passthrough = ["nounwind"]} { + %0 = llvm.ptrtoint %arg0 : !llvm.vec<4 x ptr> to vector<4xi128> + llvm.return %0 : vector<4xi128> + } + llvm.func @test6(%arg0: vector<4xi32>) -> !llvm.vec<4 x ptr> attributes {passthrough = ["nounwind"]} { + %0 = llvm.inttoptr %arg0 : vector<4xi32> to !llvm.vec<4 x ptr> + llvm.return %0 : !llvm.vec<4 x ptr> + } + llvm.func @test7(%arg0: vector<4xi128>) -> !llvm.vec<4 x ptr> attributes {passthrough = ["nounwind"]} { + %0 = llvm.inttoptr %arg0 : vector<4xi128> to !llvm.vec<4 x ptr> + llvm.return %0 : !llvm.vec<4 x ptr> + } +} diff --git a/test/LLVMDialect/InstCombine/ptr-int-ptr-icmp.ll.mlir b/test/LLVMDialect/InstCombine/ptr-int-ptr-icmp.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/ptr-replace-alloca.ll.mlir b/test/LLVMDialect/InstCombine/ptr-replace-alloca.ll.mlir new file mode 100644 index 000000000..f34ac4eda --- /dev/null +++ b/test/LLVMDialect/InstCombine/ptr-replace-alloca.ll.mlir @@ -0,0 +1,301 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.alloca_memory_space", 5 : ui64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @g1(dense<0> : tensor<32xi8>) {addr_space = 0 : i32} : !llvm.array<32 x i8> + llvm.mlir.global external constant @g2(dense<0> : tensor<32xi8>) {addr_space = 1 : i32} : !llvm.array<32 x i8> + llvm.func @remove_alloca_use_arg(%arg0: i1) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g1 : !llvm.ptr + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 4 : i64} : (i32) -> !llvm.ptr<1> + "llvm.intr.memcpy"(%7, %3, %4) <{isVolatile = false}> : (!llvm.ptr<1>, !llvm.ptr, i64) -> () + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %8 = llvm.getelementptr inbounds %7[%5, %6] : (!llvm.ptr<1>, i32, i32) -> !llvm.ptr<1>, !llvm.array<32 x i8> + llvm.br ^bb3(%8 : !llvm.ptr<1>) + ^bb2: // pred: ^bb0 + %9 = llvm.getelementptr inbounds %7[%5, %0] : (!llvm.ptr<1>, i32, i32) -> !llvm.ptr<1>, !llvm.array<32 x i8> + llvm.br ^bb3(%9 : !llvm.ptr<1>) + ^bb3(%10: !llvm.ptr<1>): // 2 preds: ^bb1, ^bb2 + %11 = llvm.load %10 {alignment = 1 : i64} : !llvm.ptr<1> -> i8 + llvm.return %11 : i8 + } + llvm.func @volatile_load_keep_alloca(%arg0: i1) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g1 : !llvm.ptr + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 4 : i64} : (i32) -> !llvm.ptr<1> + "llvm.intr.memcpy"(%7, %3, %4) <{isVolatile = false}> : (!llvm.ptr<1>, !llvm.ptr, i64) -> () + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %8 = llvm.getelementptr inbounds %7[%5, %0] : (!llvm.ptr<1>, i32, i32) -> !llvm.ptr<1>, !llvm.array<32 x i8> + llvm.br ^bb3(%8 : !llvm.ptr<1>) + ^bb2: // pred: ^bb0 + %9 = llvm.getelementptr inbounds %7[%5, %6] : (!llvm.ptr<1>, i32, i32) -> !llvm.ptr<1>, !llvm.array<32 x i8> + llvm.br ^bb3(%9 : !llvm.ptr<1>) + ^bb3(%10: !llvm.ptr<1>): // 2 preds: ^bb1, ^bb2 + %11 = llvm.load volatile %10 {alignment = 1 : i64} : !llvm.ptr<1> -> i8 + llvm.return %11 : i8 + } + llvm.func @no_memcpy_keep_alloca(%arg0: i1) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 4 : i64} : (i32) -> !llvm.ptr<1> + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.getelementptr inbounds %3[%1, %0] : (!llvm.ptr<1>, i32, i32) -> !llvm.ptr<1>, !llvm.array<32 x i8> + llvm.br ^bb3(%4 : !llvm.ptr<1>) + ^bb2: // pred: ^bb0 + %5 = llvm.getelementptr inbounds %3[%1, %2] : (!llvm.ptr<1>, i32, i32) -> !llvm.ptr<1>, !llvm.array<32 x i8> + llvm.br ^bb3(%5 : !llvm.ptr<1>) + ^bb3(%6: !llvm.ptr<1>): // 2 preds: ^bb1, ^bb2 + %7 = llvm.load volatile %6 {alignment = 1 : i64} : !llvm.ptr<1> -> i8 + llvm.return %7 : i8 + } + llvm.func @loop_phi_remove_alloca(%arg0: i1) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g1 : !llvm.ptr + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 4 : i64} : (i32) -> !llvm.ptr<1> + "llvm.intr.memcpy"(%7, %3, %4) <{isVolatile = false}> : (!llvm.ptr<1>, !llvm.ptr, i64) -> () + %8 = llvm.getelementptr inbounds %7[%5, %0] : (!llvm.ptr<1>, i32, i32) -> !llvm.ptr<1>, !llvm.array<32 x i8> + llvm.br ^bb1(%8 : !llvm.ptr<1>) + ^bb1(%9: !llvm.ptr<1>): // 2 preds: ^bb0, ^bb2 + llvm.cond_br %arg0, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %10 = llvm.getelementptr inbounds %7[%5, %6] : (!llvm.ptr<1>, i32, i32) -> !llvm.ptr<1>, !llvm.array<32 x i8> + llvm.br ^bb1(%10 : !llvm.ptr<1>) + ^bb3: // pred: ^bb1 + %11 = llvm.load %9 {alignment = 1 : i64} : !llvm.ptr<1> -> i8 + llvm.return %11 : i8 + } + llvm.func @remove_alloca_ptr_arg(%arg0: i1, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g1 : !llvm.ptr + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%5, %3, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1 : !llvm.ptr) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%5 : !llvm.ptr) + ^bb2(%6: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %7 : i32 + } + llvm.func @loop_phi_late_memtransfer_remove_alloca(%arg0: i1) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %5 = llvm.mlir.addressof @g1 : !llvm.ptr + %6 = llvm.mlir.constant(32 : i64) : i64 + %7 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 4 : i64} : (i32) -> !llvm.ptr<1> + %8 = llvm.getelementptr inbounds %7[%1, %0] : (!llvm.ptr<1>, i32, i32) -> !llvm.ptr<1>, !llvm.array<32 x i8> + llvm.br ^bb1(%8 : !llvm.ptr<1>) + ^bb1(%9: !llvm.ptr<1>): // 2 preds: ^bb0, ^bb2 + llvm.cond_br %arg0, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %10 = llvm.getelementptr inbounds %7[%1, %2] : (!llvm.ptr<1>, i32, i32) -> !llvm.ptr<1>, !llvm.array<32 x i8> + "llvm.intr.memcpy"(%7, %5, %6) <{isVolatile = false}> : (!llvm.ptr<1>, !llvm.ptr, i64) -> () + llvm.br ^bb1(%10 : !llvm.ptr<1>) + ^bb3: // pred: ^bb1 + %11 = llvm.load %9 {alignment = 1 : i64} : !llvm.ptr<1> -> i8 + llvm.return %11 : i8 + } + llvm.func @test_memcpy_after_phi(%arg0: i1, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g1 : !llvm.ptr + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1 : !llvm.ptr) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%5 : !llvm.ptr) + ^bb2(%6: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + "llvm.intr.memcpy"(%6, %3, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %7 : i32 + } + llvm.func @addrspace_diff_keep_alloca(%arg0: i1, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g2 : !llvm.ptr<1> + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%5, %3, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr<1>, i64) -> () + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1 : !llvm.ptr) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%5 : !llvm.ptr) + ^bb2(%6: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %7 : i32 + } + llvm.func @addrspace_diff_keep_alloca_extra_gep(%arg0: i1, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g2 : !llvm.ptr<1> + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.mlir.constant(4 : i64) : i64 + %6 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%6, %3, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr<1>, i64) -> () + %7 = llvm.getelementptr %6[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.cond_br %arg0, ^bb1, ^bb2(%arg1 : !llvm.ptr) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%7 : !llvm.ptr) + ^bb2(%8: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %9 = llvm.load %8 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %9 : i32 + } + llvm.func @addrspace_diff_remove_alloca(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g2 : !llvm.ptr<1> + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%7, %3, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr<1>, i64) -> () + %8 = llvm.getelementptr inbounds %7[%5, %6] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<32 x i8> + llvm.cond_br %arg0, ^bb1, ^bb2(%8 : !llvm.ptr) + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%7 : !llvm.ptr) + ^bb2(%9: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %10 = llvm.load %9 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %10 : i32 + } + llvm.func @phi_loop(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g1 : !llvm.ptr + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.mlir.constant(4 : i64) : i64 + %6 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%6, %3, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.br ^bb1(%6 : !llvm.ptr) + ^bb1(%7: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %8 = llvm.getelementptr %7[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.cond_br %arg0, ^bb2, ^bb1(%8 : !llvm.ptr) + ^bb2: // pred: ^bb1 + %9 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %9 : i32 + } + llvm.func @phi_loop_different_addrspace(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g2 : !llvm.ptr<1> + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.mlir.constant(4 : i64) : i64 + %6 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%6, %3, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr<1>, i64) -> () + llvm.br ^bb1(%6 : !llvm.ptr) + ^bb1(%7: !llvm.ptr): // 2 preds: ^bb0, ^bb1 + %8 = llvm.getelementptr %7[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.cond_br %arg0, ^bb2, ^bb1(%8 : !llvm.ptr) + ^bb2: // pred: ^bb1 + %9 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %9 : i32 + } + llvm.func @select_same_addrspace_remove_alloca(%arg0: i1, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g1 : !llvm.ptr + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%5, %3, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + %6 = llvm.select %arg0, %5, %arg1 : i1, !llvm.ptr + %7 = llvm.load %6 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %7 : i8 + } + llvm.func @select_after_memcpy_keep_alloca(%arg0: i1, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g1 : !llvm.ptr + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + %6 = llvm.select %arg0, %5, %arg1 : i1, !llvm.ptr + "llvm.intr.memcpy"(%6, %3, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + %7 = llvm.load %6 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %7 : i8 + } + llvm.func @select_diff_addrspace_keep_alloca(%arg0: i1, %arg1: !llvm.ptr<1>) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g1 : !llvm.ptr + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr<1> + "llvm.intr.memcpy"(%5, %3, %4) <{isVolatile = false}> : (!llvm.ptr<1>, !llvm.ptr, i64) -> () + %6 = llvm.select %arg0, %5, %arg1 : i1, !llvm.ptr<1> + %7 = llvm.load %6 {alignment = 1 : i64} : !llvm.ptr<1> -> i8 + llvm.return %7 : i8 + } + llvm.func @select_diff_addrspace_remove_alloca(%arg0: i1, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g2 : !llvm.ptr<1> + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.mlir.constant(4 : i64) : i64 + %8 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%8, %3, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr<1>, i64) -> () + %9 = llvm.getelementptr inbounds %8[%5, %6] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<32 x i8> + %10 = llvm.select %arg0, %8, %9 : i1, !llvm.ptr + %11 = llvm.getelementptr inbounds %10[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %12 = llvm.load %11 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %12 : i8 + } + llvm.func @readonly_callee(!llvm.ptr {llvm.nocapture, llvm.readonly}) -> i8 + llvm.func @call_readonly_remove_alloca() -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g1 : !llvm.ptr + %4 = llvm.mlir.constant(32 : i64) : i64 + %5 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr<1> + "llvm.intr.memcpy"(%5, %3, %4) <{isVolatile = false}> : (!llvm.ptr<1>, !llvm.ptr, i64) -> () + %6 = llvm.addrspacecast %5 : !llvm.ptr<1> to !llvm.ptr + %7 = llvm.call @readonly_callee(%6) : (!llvm.ptr) -> i8 + llvm.return %7 : i8 + } + llvm.func @call_readonly_keep_alloca2() -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @g1 : !llvm.ptr + %4 = llvm.mlir.constant(16 : i64) : i64 + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(16 : i32) : i32 + %7 = llvm.mlir.addressof @g2 : !llvm.ptr<1> + %8 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr<1> + "llvm.intr.memcpy"(%8, %3, %4) <{isVolatile = false}> : (!llvm.ptr<1>, !llvm.ptr, i64) -> () + %9 = llvm.getelementptr inbounds %8[%5, %6] : (!llvm.ptr<1>, i32, i32) -> !llvm.ptr<1>, !llvm.array<32 x i8> + "llvm.intr.memcpy"(%9, %7, %4) <{isVolatile = false}> : (!llvm.ptr<1>, !llvm.ptr<1>, i64) -> () + %10 = llvm.addrspacecast %8 : !llvm.ptr<1> to !llvm.ptr + %11 = llvm.call @readonly_callee(%10) : (!llvm.ptr) -> i8 + llvm.return %11 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/ptrauth-intrinsics.ll.mlir b/test/LLVMDialect/InstCombine/ptrauth-intrinsics.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/ptrmask.ll.mlir b/test/LLVMDialect/InstCombine/ptrmask.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/ptrtoint-nullgep.ll.mlir b/test/LLVMDialect/InstCombine/ptrtoint-nullgep.ll.mlir index a35e7ebce..2a8235d88 100644 --- a/test/LLVMDialect/InstCombine/ptrtoint-nullgep.ll.mlir +++ b/test/LLVMDialect/InstCombine/ptrtoint-nullgep.ll.mlir @@ -1,244 +1,221 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use_i64", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use_ptr", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - "llvm.return"(%0) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_ptrtoint_gep_zero", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1234 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.null"() : () -> !llvm.ptr - %3 = "llvm.getelementptr"(%2, %1) : (!llvm.ptr, i32) -> !llvm.ptr - %4 = "llvm.ptrtoint"(%3) : (!llvm.ptr) -> i64 - %5 = "llvm.mul"(%4, %0) : (i64, i64) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_ptrtoint_gep_nonzero", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - "llvm.return"(%0) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_ptrtoint_gep_zero_inbounds", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1234 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.null"() : () -> !llvm.ptr - %3 = "llvm.getelementptr"(%2, %1) : (!llvm.ptr, i32) -> !llvm.ptr - %4 = "llvm.ptrtoint"(%3) : (!llvm.ptr) -> i64 - %5 = "llvm.mul"(%4, %0) : (i64, i64) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_ptrtoint_gep_nonzero_inbounds", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1234 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.mlir.null"() : () -> !llvm.ptr - %4 = "llvm.getelementptr"(%3, %2) : (!llvm.ptr, i32) -> !llvm.ptr - %5 = "llvm.ptrtoint"(%4) : (!llvm.ptr) -> i64 - %6 = "llvm.mul"(%5, %1) : (i64, i64) -> i64 - "llvm.call"(%6) {callee = @use_i64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%6) {callee = @use_i64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%6) {callee = @use_i64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%6) {callee = @use_i64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%6) {callee = @use_i64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%6) {callee = @use_i64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%6) {callee = @use_i64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%6) {callee = @use_i64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%0) {callee = @use_i64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%0) {callee = @use_i64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%0) {callee = @use_i64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%0) {callee = @use_i64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "constant_fold_ptrtoint_of_gep_of_nullgep", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.add"(%1, %1) : (i64, i64) -> i64 - %3 = "llvm.getelementptr"(%0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - %4 = "llvm.ptrtoint"(%3) : (!llvm.ptr) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nullgep_zero", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.add"(%1, %1) : (i64, i64) -> i64 - %3 = "llvm.getelementptr"(%0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - %4 = "llvm.ptrtoint"(%3) : (!llvm.ptr) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nullgep_zero_inbounds", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1234 : i64} : () -> i64 - %3 = "llvm.add"(%2, %1) : (i64, i64) -> i64 - %4 = "llvm.getelementptr"(%0, %3) : (!llvm.ptr, i64) -> !llvm.ptr - %5 = "llvm.ptrtoint"(%4) : (!llvm.ptr) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nullgep_nonzero", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1234 : i64} : () -> i64 - %3 = "llvm.add"(%2, %1) : (i64, i64) -> i64 - %4 = "llvm.getelementptr"(%0, %3) : (!llvm.ptr, i64) -> !llvm.ptr - %5 = "llvm.ptrtoint"(%4) : (!llvm.ptr) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nullgep_nonzero_inbounds", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.getelementptr"(%0, %arg0) : (!llvm.ptr, i64) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nullgep_variable", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.or"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.getelementptr"(%0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - %4 = "llvm.ptrtoint"(%3) : (!llvm.ptr) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nullgep_variable_known_nonzero", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.getelementptr"(%0, %arg0) : (!llvm.ptr, i64) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nullgep_variable_inbounds", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.or"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.getelementptr"(%0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - %4 = "llvm.ptrtoint"(%3) : (!llvm.ptr) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nullgep_variable_known_nonzero_inbounds", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr, 1> - %2 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %3 = "llvm.or"(%arg0, %2) : (i64, i64) -> i64 - %4 = "llvm.getelementptr"(%1, %3, %0) : (!llvm.ptr, 1>, i64, i32) -> !llvm.ptr - %5 = "llvm.ptrtoint"(%4) : (!llvm.ptr) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nullgep_variable_known_nonzero_inbounds_multiple_indices", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.getelementptr"(%0, %arg0) : (!llvm.ptr, i64) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nullgep_i32_variable", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.getelementptr"(%0, %arg0) : (!llvm.ptr, i64) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nullgep_variable_trunc", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1234 : i64} : () -> i64 - %3 = "llvm.add"(%2, %1) : (i64, i64) -> i64 - %4 = "llvm.sub"(%3, %2) : (i64, i64) -> i64 - %5 = "llvm.getelementptr"(%0, %3) : (!llvm.ptr, i64) -> !llvm.ptr - %6 = "llvm.getelementptr"(%5, %4) : (!llvm.ptr, i64) -> !llvm.ptr - %7 = "llvm.ptrtoint"(%6) : (!llvm.ptr) -> i64 - "llvm.return"(%7) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_zero_nullgep_of_nonzero_inbounds_nullgep", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1234 : i64} : () -> i64 - %3 = "llvm.add"(%2, %1) : (i64, i64) -> i64 - %4 = "llvm.sub"(%3, %2) : (i64, i64) -> i64 - %5 = "llvm.getelementptr"(%0, %4) : (!llvm.ptr, i64) -> !llvm.ptr - %6 = "llvm.getelementptr"(%5, %3) : (!llvm.ptr, i64) -> !llvm.ptr - %7 = "llvm.ptrtoint"(%6) : (!llvm.ptr) -> i64 - "llvm.return"(%7) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nonzero_inbounds_nullgep_of_zero_noninbounds_nullgep", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.null"() : () -> !llvm.ptr)>>)>, 1> - %3 = "llvm.getelementptr"(%2, %1, %0, %1, %0, %arg0) : (!llvm.ptr)>>)>, 1>, i64, i32, i64, i32, i64) -> !llvm.ptr - %4 = "llvm.ptrtoint"(%3) : (!llvm.ptr) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_complex_index_last_nonzero", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.mlir.null"() : () -> !llvm.ptr)>>)>, 1> - %3 = "llvm.getelementptr"(%2, %1, %0, %1, %0, %arg0) : (!llvm.ptr)>>)>, 1>, i64, i32, i64, i32, i64) -> !llvm.ptr - %4 = "llvm.ptrtoint"(%3) : (!llvm.ptr) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_complex_index_multiple_nonzero", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1234 : i64} : () -> i64 - %3 = "llvm.add"(%2, %1) : (i64, i64) -> i64 - %4 = "llvm.sub"(%3, %2) : (i64, i64) -> i64 - %5 = "llvm.getelementptr"(%0, %3) : (!llvm.ptr, i64) -> !llvm.ptr - %6 = "llvm.getelementptr"(%5, %4) : (!llvm.ptr, i64) -> !llvm.ptr - %7 = "llvm.ptrtoint"(%6) : (!llvm.ptr) -> i64 - "llvm.return"(%7) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_inbounds_nullgep_of_nonzero_inbounds_nullgep", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr, 1> - %2 = "llvm.getelementptr"(%1, %arg0, %0) : (!llvm.ptr, 1>, i64, i64) -> !llvm.ptr - %3 = "llvm.ptrtoint"(%2) : (!llvm.ptr) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nullgep_array_one_var_1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr, 1> - %2 = "llvm.getelementptr"(%1, %0, %arg0) : (!llvm.ptr, 1>, i64, i64) -> !llvm.ptr - %3 = "llvm.ptrtoint"(%2) : (!llvm.ptr) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nullgep_array_one_var_2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr, 1> - %1 = "llvm.getelementptr"(%0, %arg0, %arg1) : (!llvm.ptr, 1>, i64, i64) -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nested_array_two_vars", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr>, 1> - %2 = "llvm.getelementptr"(%1, %arg0, %arg1, %0) : (!llvm.ptr>, 1>, i64, i64, i64) -> !llvm.ptr - %3 = "llvm.ptrtoint"(%2) : (!llvm.ptr) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nested_array_two_vars_plus_zero", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr>, 1> - %2 = "llvm.getelementptr"(%1, %arg0, %arg1, %0) : (!llvm.ptr>, 1>, i64, i64, i64) -> !llvm.ptr - %3 = "llvm.ptrtoint"(%2) : (!llvm.ptr) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nested_array_two_vars_plus_const", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr, 1> - %1 = "llvm.getelementptr"(%0, %arg0, %arg1) : (!llvm.ptr, 1>, i64, i64) -> !llvm.ptr - %2 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%2) {callee = @use_ptr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - %3 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_ptrtoint_nested_nullgep_array_variable_multiple_uses", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use_i64(i64) + llvm.func @use_ptr(!llvm.ptr<1>) + llvm.func @constant_fold_ptrtoint_gep_zero() -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + llvm.return %0 : i64 + } + llvm.func @constant_fold_ptrtoint_gep_nonzero() -> i64 { + %0 = llvm.mlir.constant(1234 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr<1> + %2 = llvm.getelementptr %1[%0] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i32 + %3 = llvm.ptrtoint %2 : !llvm.ptr<1> to i64 + llvm.return %3 : i64 + } + llvm.func @constant_fold_ptrtoint_gep_zero_inbounds() -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + llvm.return %0 : i64 + } + llvm.func @constant_fold_ptrtoint_gep_nonzero_inbounds() -> i64 { + %0 = llvm.mlir.constant(1234 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr<1> + %2 = llvm.getelementptr inbounds %1[%0] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i32 + %3 = llvm.ptrtoint %2 : !llvm.ptr<1> to i64 + llvm.return %3 : i64 + } + llvm.func @constant_fold_ptrtoint_of_gep_of_nullgep() { + %0 = llvm.mlir.constant(1234 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr<1> + %2 = llvm.getelementptr inbounds %1[%0] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %3 = llvm.ptrtoint %2 : !llvm.ptr<1> to i64 + %4 = llvm.getelementptr %1[%0] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %5 = llvm.ptrtoint %4 : !llvm.ptr<1> to i64 + %6 = llvm.mlir.constant(0 : i64) : i64 + llvm.call @use_i64(%3) : (i64) -> () + llvm.call @use_i64(%5) : (i64) -> () + llvm.call @use_i64(%3) : (i64) -> () + llvm.call @use_i64(%5) : (i64) -> () + llvm.call @use_i64(%3) : (i64) -> () + llvm.call @use_i64(%3) : (i64) -> () + llvm.call @use_i64(%5) : (i64) -> () + llvm.call @use_i64(%5) : (i64) -> () + llvm.call @use_i64(%6) : (i64) -> () + llvm.call @use_i64(%6) : (i64) -> () + llvm.call @use_i64(%6) : (i64) -> () + llvm.call @use_i64(%6) : (i64) -> () + llvm.return + } + llvm.func @fold_ptrtoint_nullgep_zero() -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr<1> + %2 = llvm.add %0, %0 : i64 + %3 = llvm.getelementptr %1[%2] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %4 = llvm.ptrtoint %3 : !llvm.ptr<1> to i64 + llvm.return %4 : i64 + } + llvm.func @fold_ptrtoint_nullgep_zero_inbounds() -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr<1> + %2 = llvm.add %0, %0 : i64 + %3 = llvm.getelementptr inbounds %1[%2] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %4 = llvm.ptrtoint %3 : !llvm.ptr<1> to i64 + llvm.return %4 : i64 + } + llvm.func @fold_ptrtoint_nullgep_nonzero() -> i64 { + %0 = llvm.mlir.constant(1234 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.zero : !llvm.ptr<1> + %3 = llvm.add %0, %1 : i64 + %4 = llvm.getelementptr %2[%3] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %5 = llvm.ptrtoint %4 : !llvm.ptr<1> to i64 + llvm.return %5 : i64 + } + llvm.func @fold_ptrtoint_nullgep_nonzero_inbounds() -> i64 { + %0 = llvm.mlir.constant(1234 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.zero : !llvm.ptr<1> + %3 = llvm.add %0, %1 : i64 + %4 = llvm.getelementptr inbounds %2[%3] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %5 = llvm.ptrtoint %4 : !llvm.ptr<1> to i64 + llvm.return %5 : i64 + } + llvm.func @fold_ptrtoint_nullgep_variable(%arg0: i64) -> i64 { + %0 = llvm.mlir.zero : !llvm.ptr<1> + %1 = llvm.getelementptr %0[%arg0] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %2 = llvm.ptrtoint %1 : !llvm.ptr<1> to i64 + llvm.return %2 : i64 + } + llvm.func @fold_ptrtoint_nullgep_variable_known_nonzero(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr<1> + %2 = llvm.or %arg0, %0 : i64 + %3 = llvm.getelementptr %1[%2] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %4 = llvm.ptrtoint %3 : !llvm.ptr<1> to i64 + llvm.return %4 : i64 + } + llvm.func @fold_ptrtoint_nullgep_variable_inbounds(%arg0: i64) -> i64 { + %0 = llvm.mlir.zero : !llvm.ptr<1> + %1 = llvm.getelementptr inbounds %0[%arg0] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %2 = llvm.ptrtoint %1 : !llvm.ptr<1> to i64 + llvm.return %2 : i64 + } + llvm.func @fold_ptrtoint_nullgep_variable_known_nonzero_inbounds(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr<1> + %2 = llvm.or %arg0, %0 : i64 + %3 = llvm.getelementptr inbounds %1[%2] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %4 = llvm.ptrtoint %3 : !llvm.ptr<1> to i64 + llvm.return %4 : i64 + } + llvm.func @fold_ptrtoint_nullgep_variable_known_nonzero_inbounds_multiple_indices(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr<1> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.or %arg0, %0 : i64 + %4 = llvm.getelementptr inbounds %1[%3, %2] : (!llvm.ptr<1>, i64, i32) -> !llvm.ptr<1>, !llvm.array<2 x i8> + %5 = llvm.ptrtoint %4 : !llvm.ptr<1> to i64 + llvm.return %5 : i64 + } + llvm.func @fold_ptrtoint_nullgep_i32_variable(%arg0: i64) -> i64 { + %0 = llvm.mlir.zero : !llvm.ptr<1> + %1 = llvm.getelementptr %0[%arg0] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i32 + %2 = llvm.ptrtoint %1 : !llvm.ptr<1> to i64 + llvm.return %2 : i64 + } + llvm.func @fold_ptrtoint_nullgep_variable_trunc(%arg0: i64) -> i32 { + %0 = llvm.mlir.zero : !llvm.ptr<1> + %1 = llvm.getelementptr %0[%arg0] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %2 = llvm.ptrtoint %1 : !llvm.ptr<1> to i32 + llvm.return %2 : i32 + } + llvm.func @fold_ptrtoint_zero_nullgep_of_nonzero_inbounds_nullgep() -> i64 { + %0 = llvm.mlir.constant(1234 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.zero : !llvm.ptr<1> + %3 = llvm.add %0, %1 : i64 + %4 = llvm.sub %3, %0 : i64 + %5 = llvm.getelementptr inbounds %2[%3] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %6 = llvm.getelementptr %5[%4] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %7 = llvm.ptrtoint %6 : !llvm.ptr<1> to i64 + llvm.return %7 : i64 + } + llvm.func @fold_ptrtoint_nonzero_inbounds_nullgep_of_zero_noninbounds_nullgep() -> i64 { + %0 = llvm.mlir.constant(1234 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.zero : !llvm.ptr<1> + %3 = llvm.add %0, %1 : i64 + %4 = llvm.sub %3, %0 : i64 + %5 = llvm.getelementptr %2[%4] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %6 = llvm.getelementptr inbounds %5[%3] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %7 = llvm.ptrtoint %6 : !llvm.ptr<1> to i64 + llvm.return %7 : i64 + } + llvm.func local_unnamed_addr @fold_complex_index_last_nonzero(%arg0: i64) -> i64 { + %0 = llvm.mlir.zero : !llvm.ptr<1> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.getelementptr inbounds %0[%1, 0, %1, 0, %arg0] : (!llvm.ptr<1>, i64, i64, i64) -> !llvm.ptr<1>, !llvm.struct<"struct.S", (array<2 x struct<"struct.K", (array<32 x i8>)>>)> + %4 = llvm.ptrtoint %3 : !llvm.ptr<1> to i64 + llvm.return %4 : i64 + } + llvm.func local_unnamed_addr @fold_complex_index_multiple_nonzero(%arg0: i64) -> i64 { + %0 = llvm.mlir.zero : !llvm.ptr<1> + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.getelementptr inbounds %0[%1, 0, %1, 0, %arg0] : (!llvm.ptr<1>, i64, i64, i64) -> !llvm.ptr<1>, !llvm.struct<"struct.S", (array<2 x struct<"struct.K", (array<32 x i8>)>>)> + %4 = llvm.ptrtoint %3 : !llvm.ptr<1> to i64 + llvm.return %4 : i64 + } + llvm.func @fold_ptrtoint_inbounds_nullgep_of_nonzero_inbounds_nullgep() -> i64 { + %0 = llvm.mlir.constant(1234 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.zero : !llvm.ptr<1> + %3 = llvm.add %0, %1 : i64 + %4 = llvm.sub %3, %0 : i64 + %5 = llvm.getelementptr inbounds %2[%3] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %6 = llvm.getelementptr inbounds %5[%4] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i8 + %7 = llvm.ptrtoint %6 : !llvm.ptr<1> to i64 + llvm.return %7 : i64 + } + llvm.func @fold_ptrtoint_nullgep_array_one_var_1(%arg0: i64) -> i64 { + %0 = llvm.mlir.zero : !llvm.ptr<1> + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.getelementptr %0[%arg0, %1] : (!llvm.ptr<1>, i64, i64) -> !llvm.ptr<1>, !llvm.array<2 x i16> + %3 = llvm.ptrtoint %2 : !llvm.ptr<1> to i64 + llvm.return %3 : i64 + } + llvm.func @fold_ptrtoint_nullgep_array_one_var_2(%arg0: i64) -> i64 { + %0 = llvm.mlir.zero : !llvm.ptr<1> + %1 = llvm.mlir.constant(7 : i64) : i64 + %2 = llvm.getelementptr %0[%1, %arg0] : (!llvm.ptr<1>, i64, i64) -> !llvm.ptr<1>, !llvm.array<2 x i16> + %3 = llvm.ptrtoint %2 : !llvm.ptr<1> to i64 + llvm.return %3 : i64 + } + llvm.func @fold_ptrtoint_nested_array_two_vars(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.zero : !llvm.ptr<1> + %1 = llvm.getelementptr %0[%arg0, %arg1] : (!llvm.ptr<1>, i64, i64) -> !llvm.ptr<1>, !llvm.array<2 x i16> + %2 = llvm.ptrtoint %1 : !llvm.ptr<1> to i64 + llvm.return %2 : i64 + } + llvm.func @fold_ptrtoint_nested_array_two_vars_plus_zero(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.zero : !llvm.ptr<1> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.getelementptr %0[%arg0, %arg1, %1] : (!llvm.ptr<1>, i64, i64, i64) -> !llvm.ptr<1>, !llvm.array<2 x array<2 x i16>> + %3 = llvm.ptrtoint %2 : !llvm.ptr<1> to i64 + llvm.return %3 : i64 + } + llvm.func @fold_ptrtoint_nested_array_two_vars_plus_const(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.zero : !llvm.ptr<1> + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.getelementptr %0[%arg0, %arg1, %1] : (!llvm.ptr<1>, i64, i64, i64) -> !llvm.ptr<1>, !llvm.array<2 x array<2 x i16>> + %3 = llvm.ptrtoint %2 : !llvm.ptr<1> to i64 + llvm.return %3 : i64 + } + llvm.func @fold_ptrtoint_nested_nullgep_array_variable_multiple_uses(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.zero : !llvm.ptr<1> + %1 = llvm.getelementptr %0[%arg0, %arg1] : (!llvm.ptr<1>, i64, i64) -> !llvm.ptr<1>, !llvm.array<2 x i16> + llvm.call @use_ptr(%1) : (!llvm.ptr<1>) -> () + %2 = llvm.ptrtoint %1 : !llvm.ptr<1> to i64 + llvm.return %2 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/pull-binop-through-shift.ll.mlir b/test/LLVMDialect/InstCombine/pull-binop-through-shift.ll.mlir index 89ba709cf..4b1be9498 100644 --- a/test/LLVMDialect/InstCombine/pull-binop-through-shift.ll.mlir +++ b/test/LLVMDialect/InstCombine/pull-binop-through-shift.ll.mlir @@ -1,195 +1,170 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -65536 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "and_signbit_shl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2147418112 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "and_nosignbit_shl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -65536 : i32} : () -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "or_signbit_shl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2147418112 : i32} : () -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "or_nosignbit_shl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -65536 : i32} : () -> i32 - %2 = "llvm.xor"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_signbit_shl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2147418112 : i32} : () -> i32 - %2 = "llvm.xor"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_nosignbit_shl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -65536 : i32} : () -> i32 - %2 = "llvm.add"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "add_signbit_shl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2147418112 : i32} : () -> i32 - %2 = "llvm.add"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "add_nosignbit_shl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -65536 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.lshr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "and_signbit_lshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2147418112 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.lshr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "and_nosignbit_lshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -65536 : i32} : () -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.lshr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "or_signbit_lshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2147418112 : i32} : () -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.lshr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "or_nosignbit_lshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -65536 : i32} : () -> i32 - %2 = "llvm.xor"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.lshr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_signbit_lshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2147418112 : i32} : () -> i32 - %2 = "llvm.xor"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.lshr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_nosignbit_lshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -65536 : i32} : () -> i32 - %2 = "llvm.add"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.lshr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "add_signbit_lshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2147418112 : i32} : () -> i32 - %2 = "llvm.add"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.lshr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "add_nosignbit_lshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -65536 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "and_signbit_ashr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2147418112 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "and_nosignbit_ashr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -65536 : i32} : () -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "or_signbit_ashr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2147418112 : i32} : () -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "or_nosignbit_ashr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -65536 : i32} : () -> i32 - %2 = "llvm.xor"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_signbit_ashr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2147418112 : i32} : () -> i32 - %2 = "llvm.xor"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_nosignbit_ashr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -65536 : i32} : () -> i32 - %2 = "llvm.add"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "add_signbit_ashr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 2147418112 : i32} : () -> i32 - %2 = "llvm.add"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "add_nosignbit_ashr", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @and_signbit_shl(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @and_nosignbit_shl(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @or_signbit_shl(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @or_nosignbit_shl(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @xor_signbit_shl(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @xor_nosignbit_shl(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @add_signbit_shl(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @add_nosignbit_shl(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @and_signbit_lshr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @and_nosignbit_lshr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @or_signbit_lshr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @or_nosignbit_lshr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @xor_signbit_lshr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @xor_nosignbit_lshr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @add_signbit_lshr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @add_nosignbit_lshr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @and_signbit_ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @and_nosignbit_ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @or_signbit_ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @or_nosignbit_ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @xor_signbit_ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @xor_nosignbit_ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @add_signbit_ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @add_nosignbit_ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/pull-conditional-binop-through-shift.ll.mlir b/test/LLVMDialect/InstCombine/pull-conditional-binop-through-shift.ll.mlir new file mode 100644 index 000000000..03f6d0f12 --- /dev/null +++ b/test/LLVMDialect/InstCombine/pull-conditional-binop-through-shift.ll.mlir @@ -0,0 +1,194 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @and_signbit_select_shl(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.shl %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @and_nosignbit_select_shl(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.shl %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @or_signbit_select_shl(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.shl %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @or_nosignbit_select_shl(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.shl %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @xor_signbit_select_shl(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.shl %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @xor_nosignbit_select_shl(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.shl %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @add_signbit_select_shl(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.shl %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @add_nosignbit_select_shl(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.shl %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @and_signbit_select_lshr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.lshr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @and_nosignbit_select_lshr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.lshr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @or_signbit_select_lshr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.lshr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @or_nosignbit_select_lshr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.lshr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @xor_signbit_select_lshr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.lshr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @xor_nosignbit_select_lshr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.lshr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @add_signbit_select_lshr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.lshr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @add_nosignbit_select_lshr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.lshr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @and_signbit_select_ashr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.ashr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @and_nosignbit_select_ashr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.ashr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @or_signbit_select_ashr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.ashr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @or_nosignbit_select_ashr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.ashr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @xor_signbit_select_ashr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.ashr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @xor_nosignbit_select_ashr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.ashr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @add_signbit_select_ashr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-65536 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.ashr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @add_nosignbit_select_ashr(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(2147418112 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.select %arg1, %2, %arg0 : i1, i32 + %4 = llvm.ashr %3, %1 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/puts-1.ll.mlir b/test/LLVMDialect/InstCombine/puts-1.ll.mlir new file mode 100644 index 000000000..9d505bd05 --- /dev/null +++ b/test/LLVMDialect/InstCombine/puts-1.ll.mlir @@ -0,0 +1,18 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @empty(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.func @puts(!llvm.ptr) -> i32 + llvm.func @test_simplify1() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @empty : !llvm.ptr + %3 = llvm.call @puts(%2) : (!llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_no_simplify1() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @empty : !llvm.ptr + %3 = llvm.call @puts(%2) : (!llvm.ptr) -> i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/puts-i16.ll.mlir b/test/LLVMDialect/InstCombine/puts-i16.ll.mlir new file mode 100644 index 000000000..272a18e80 --- /dev/null +++ b/test/LLVMDialect/InstCombine/puts-i16.ll.mlir @@ -0,0 +1,12 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @empty(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.func @putchar(i16) -> i16 + llvm.func @puts(!llvm.ptr) -> i16 + llvm.func @xform_puts(%arg0: i16) { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @empty : !llvm.ptr + %3 = llvm.call @puts(%2) : (!llvm.ptr) -> i16 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/range-check.ll.mlir b/test/LLVMDialect/InstCombine/range-check.ll.mlir new file mode 100644 index 000000000..c940a9f3a --- /dev/null +++ b/test/LLVMDialect/InstCombine/range-check.ll.mlir @@ -0,0 +1,245 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_and1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.icmp "sge" %arg0, %1 : i32 + %4 = llvm.icmp "slt" %arg0, %2 : i32 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @test_and1_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.icmp "sge" %arg0, %1 : i32 + %5 = llvm.icmp "slt" %arg0, %3 : i32 + %6 = llvm.select %4, %5, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @test_and2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.icmp "sle" %arg0, %2 : i32 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @test_and2_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.icmp "sgt" %arg0, %1 : i32 + %5 = llvm.icmp "sle" %arg0, %3 : i32 + %6 = llvm.select %4, %5, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @test_and3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.icmp "sgt" %2, %arg0 : i32 + %4 = llvm.icmp "sge" %arg0, %1 : i32 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @test_and3_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.icmp "sgt" %3, %arg0 : i32 + %5 = llvm.icmp "sge" %arg0, %1 : i32 + %6 = llvm.select %4, %5, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @test_and4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.icmp "sge" %2, %arg0 : i32 + %4 = llvm.icmp "sge" %arg0, %1 : i32 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @test_and4_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.icmp "sge" %3, %arg0 : i32 + %5 = llvm.icmp "sge" %arg0, %1 : i32 + %6 = llvm.select %4, %5, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @test_or1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.icmp "sge" %arg0, %2 : i32 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @test_or1_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.icmp "slt" %arg0, %1 : i32 + %5 = llvm.icmp "sge" %arg0, %3 : i32 + %6 = llvm.select %4, %2, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @test_or2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.icmp "sle" %arg0, %1 : i32 + %4 = llvm.icmp "sgt" %arg0, %2 : i32 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @test_or2_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.icmp "sle" %arg0, %1 : i32 + %5 = llvm.icmp "sgt" %arg0, %3 : i32 + %6 = llvm.select %4, %2, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @test_or3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.icmp "sle" %2, %arg0 : i32 + %4 = llvm.icmp "slt" %arg0, %1 : i32 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @test_or3_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.icmp "sle" %3, %arg0 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.select %4, %2, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @test_or4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.icmp "slt" %2, %arg0 : i32 + %4 = llvm.icmp "slt" %arg0, %1 : i32 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @test_or4_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.icmp "slt" %3, %arg0 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.select %4, %2, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @negative1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %2 : i32 + %4 = llvm.icmp "sgt" %arg0, %1 : i32 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @negative1_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.icmp "slt" %arg0, %3 : i32 + %5 = llvm.icmp "sgt" %arg0, %1 : i32 + %6 = llvm.select %4, %5, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @negative2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %arg1 : i32 + %2 = llvm.icmp "sge" %arg0, %0 : i32 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @negative2_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg0, %arg1 : i32 + %3 = llvm.icmp "sge" %arg0, %0 : i32 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @negative3(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg2, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %2 : i32 + %4 = llvm.icmp "sge" %arg1, %1 : i32 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @negative3_logical(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.and %arg2, %0 : i32 + %4 = llvm.icmp "slt" %arg0, %3 : i32 + %5 = llvm.icmp "sge" %arg1, %1 : i32 + %6 = llvm.select %4, %5, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @negative4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.icmp "ne" %arg0, %2 : i32 + %4 = llvm.icmp "sge" %arg0, %1 : i32 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @negative4_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %3 : i32 + %5 = llvm.icmp "sge" %arg0, %1 : i32 + %6 = llvm.select %4, %5, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @negative5(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %2 : i32 + %4 = llvm.icmp "sge" %arg0, %1 : i32 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @negative5_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.icmp "slt" %arg0, %3 : i32 + %5 = llvm.icmp "sge" %arg0, %1 : i32 + %6 = llvm.select %4, %2, %5 : i1, i1 + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/readnone-maythrow.ll.mlir b/test/LLVMDialect/InstCombine/readnone-maythrow.ll.mlir index 591e8b1c9..02c74e760 100644 --- a/test/LLVMDialect/InstCombine/readnone-maythrow.ll.mlir +++ b/test/LLVMDialect/InstCombine/readnone-maythrow.ll.mlir @@ -1,27 +1,23 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "readnone_but_may_throw", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 20 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - "llvm.store"(%1, %arg0) : (i32, !llvm.ptr) -> () - "llvm.call"() {callee = @readnone_but_may_throw, fastmathFlags = #llvm.fastmath<>} : () -> () - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "f_0", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 20 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - "llvm.store"(%1, %arg1) : (i32, !llvm.ptr) -> () - "llvm.call"() {callee = @readnone_but_may_throw, fastmathFlags = #llvm.fastmath<>} : () -> () - "llvm.cond_br"(%arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @readnone_but_may_throw() attributes {memory = #llvm.memory_effects} + llvm.func @f_0(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(20 : i32) : i32 + llvm.store %0, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.call @readnone_but_may_throw() : () -> () + llvm.store %1, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @f_1(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(20 : i32) : i32 + llvm.store %0, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.call @readnone_but_may_throw() : () -> () + llvm.cond_br %arg0, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.store"(%0, %arg1) : (i32, !llvm.ptr) -> () - "llvm.br"()[^bb2] : () -> () + llvm.store %1, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb2 ^bb2: // 2 preds: ^bb0, ^bb1 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "f_1", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/realloc-free.ll.mlir b/test/LLVMDialect/InstCombine/realloc-free.ll.mlir new file mode 100644 index 000000000..5d2b6ea05 --- /dev/null +++ b/test/LLVMDialect/InstCombine/realloc-free.ll.mlir @@ -0,0 +1,10 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func local_unnamed_addr @_Z3fooPv(%arg0: !llvm.ptr {llvm.nocapture}) attributes {passthrough = ["mustprogress", "nounwind", "willreturn", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(6 : i64) : i64 + %1 = llvm.call @realloc(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr + llvm.call @free(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func local_unnamed_addr @realloc(!llvm.ptr {llvm.allocptr, llvm.nocapture}, i64 {llvm.noundef}) -> (!llvm.ptr {llvm.noalias, llvm.noundef}) attributes {memory = #llvm.memory_effects, passthrough = ["mustprogress", "nounwind", "willreturn", ["allockind", "2"]]} + llvm.func local_unnamed_addr @free(!llvm.ptr {llvm.allocptr, llvm.nocapture, llvm.noundef}) attributes {memory = #llvm.memory_effects, passthrough = ["mustprogress", "nounwind", "willreturn", ["allockind", "4"]]} +} diff --git a/test/LLVMDialect/InstCombine/realloc.ll.mlir b/test/LLVMDialect/InstCombine/realloc.ll.mlir new file mode 100644 index 000000000..bb292f4e2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/realloc.ll.mlir @@ -0,0 +1,15 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @realloc(!llvm.ptr {llvm.allocptr}, i64) -> !llvm.ptr attributes {passthrough = [["allockind", "2"], ["allocsize", "8589934591"]]} + llvm.func @malloc(i64) -> (!llvm.ptr {llvm.noalias}) attributes {passthrough = [["allockind", "9"]]} + llvm.func @realloc_null_ptr() -> !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(100 : i64) : i64 + %2 = llvm.call @realloc(%0, %1) : (!llvm.ptr, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @realloc_unknown_ptr(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(100 : i64) : i64 + %1 = llvm.call @realloc(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/reassociate-nuw.ll.mlir b/test/LLVMDialect/InstCombine/reassociate-nuw.ll.mlir index bf1f2d08f..2c9af06ba 100644 --- a/test/LLVMDialect/InstCombine/reassociate-nuw.ll.mlir +++ b/test/LLVMDialect/InstCombine/reassociate-nuw.ll.mlir @@ -1,126 +1,109 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 64 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.add"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.add"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "reassoc_add_nuw", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 64 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.sub"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.sub"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "reassoc_sub_nuw", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 65 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.mul"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.mul"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "reassoc_mul_nuw", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 64 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.add"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.add"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "no_reassoc_add_nuw_none", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 64 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.add"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.add"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "no_reassoc_add_none_nuw", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.add"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.add"(%arg1, %0) : (i32, i32) -> i32 - %4 = "llvm.add"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "reassoc_x2_add_nuw", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mul"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.mul"(%arg1, %0) : (i32, i32) -> i32 - %4 = "llvm.mul"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "reassoc_x2_mul_nuw", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.sub"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.sub"(%arg1, %0) : (i32, i32) -> i32 - %4 = "llvm.sub"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "reassoc_x2_sub_nuw", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mul"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.add"(%1, %arg0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "tryFactorization_add_nuw_mul_nuw", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2147483647 : i32} : () -> i32 - %1 = "llvm.mul"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.add"(%1, %arg0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "tryFactorization_add_nuw_mul_nuw_int_max", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mul"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.add"(%1, %arg0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "tryFactorization_add_mul_nuw", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mul"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.add"(%1, %arg0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "tryFactorization_add_nuw_mul", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.mul"(%arg0, %arg2) : (i32, i32) -> i32 - %2 = "llvm.add"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "tryFactorization_add_nuw_mul_nuw_mul_nuw_var", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.mul"(%arg0, %arg2) : (i32, i32) -> i32 - %2 = "llvm.add"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "tryFactorization_add_nuw_mul_mul_nuw_var", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.mul"(%arg0, %arg2) : (i32, i32) -> i32 - %2 = "llvm.add"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "tryFactorization_add_nuw_mul_nuw_mul_var", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.mul"(%arg0, %arg2) : (i32, i32) -> i32 - %2 = "llvm.add"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "tryFactorization_add_mul_nuw_mul_var", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @reassoc_add_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(64 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.add %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @reassoc_sub_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(64 : i32) : i32 + %2 = llvm.sub %arg0, %0 overflow : i32 + %3 = llvm.sub %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @reassoc_mul_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(65 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.mul %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @no_reassoc_add_nuw_none(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(64 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.add %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @no_reassoc_add_none_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(64 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.add %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @reassoc_x2_add_nuw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.add %arg1, %1 overflow : i32 + %4 = llvm.add %2, %3 overflow : i32 + llvm.return %4 : i32 + } + llvm.func @reassoc_x2_mul_nuw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mul %arg0, %0 overflow : i32 + %3 = llvm.mul %arg1, %1 overflow : i32 + %4 = llvm.mul %2, %3 overflow : i32 + llvm.return %4 : i32 + } + llvm.func @reassoc_x2_sub_nuw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.sub %arg0, %0 overflow : i32 + %3 = llvm.sub %arg1, %1 overflow : i32 + %4 = llvm.sub %2, %3 overflow : i32 + llvm.return %4 : i32 + } + llvm.func @tryFactorization_add_nuw_mul_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mul %arg0, %0 overflow : i32 + %2 = llvm.add %1, %arg0 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @tryFactorization_add_nuw_mul_nuw_int_max(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mul %arg0, %0 overflow : i32 + %2 = llvm.add %1, %arg0 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @tryFactorization_add_mul_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mul %arg0, %0 : i32 + %2 = llvm.add %1, %arg0 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @tryFactorization_add_nuw_mul(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mul %arg0, %0 overflow : i32 + %2 = llvm.add %1, %arg0 : i32 + llvm.return %2 : i32 + } + llvm.func @tryFactorization_add_nuw_mul_nuw_mul_nuw_var(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mul %arg0, %arg1 overflow : i32 + %1 = llvm.mul %arg0, %arg2 overflow : i32 + %2 = llvm.add %0, %1 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @tryFactorization_add_nuw_mul_mul_nuw_var(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mul %arg0, %arg1 : i32 + %1 = llvm.mul %arg0, %arg2 overflow : i32 + %2 = llvm.add %0, %1 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @tryFactorization_add_nuw_mul_nuw_mul_var(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mul %arg0, %arg1 overflow : i32 + %1 = llvm.mul %arg0, %arg2 : i32 + %2 = llvm.add %0, %1 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @tryFactorization_add_mul_nuw_mul_var(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mul %arg0, %arg1 overflow : i32 + %1 = llvm.mul %arg0, %arg2 overflow : i32 + %2 = llvm.add %0, %1 : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/recurrence.ll.mlir b/test/LLVMDialect/InstCombine/recurrence.ll.mlir index 5c516d7f2..310da272b 100644 --- a/test/LLVMDialect/InstCombine/recurrence.ll.mlir +++ b/test/LLVMDialect/InstCombine/recurrence.ll.mlir @@ -1,73 +1,63 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 15 : i64} : () -> i64 - "llvm.br"(%arg0)[^bb1] : (i64) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_or(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(15 : i64) : i64 + llvm.br ^bb1(%arg0 : i64) ^bb1(%1: i64): // 2 preds: ^bb0, ^bb1 - %2 = "llvm.or"(%1, %0) : (i64, i64) -> i64 - "llvm.call"(%2) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.br"(%2)[^bb1] : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test_or", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - "llvm.br"(%arg0)[^bb1] : (i64) -> () + %2 = llvm.or %1, %0 : i64 + llvm.call @use(%2) : (i64) -> () + llvm.br ^bb1(%2 : i64) + } + llvm.func @test_or2(%arg0: i64, %arg1: i64) -> i64 { + llvm.br ^bb1(%arg0 : i64) ^bb1(%0: i64): // 2 preds: ^bb0, ^bb1 - %1 = "llvm.or"(%0, %arg1) : (i64, i64) -> i64 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.br"(%1)[^bb1] : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test_or2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - "llvm.br"(%arg0)[^bb1] : (i64) -> () + %1 = llvm.or %0, %arg1 : i64 + llvm.call @use(%1) : (i64) -> () + llvm.br ^bb1(%1 : i64) + } + llvm.func @test_or3(%arg0: i64, %arg1: i64) -> i64 { + llvm.br ^bb1(%arg0 : i64) ^bb1(%0: i64): // 2 preds: ^bb0, ^bb1 - %1 = "llvm.or"(%arg1, %0) : (i64, i64) -> i64 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.br"(%1)[^bb1] : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test_or3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: !llvm.ptr): // no predecessors - "llvm.br"(%arg0)[^bb1] : (i64) -> () + %1 = llvm.or %arg1, %0 : i64 + llvm.call @use(%1) : (i64) -> () + llvm.br ^bb1(%1 : i64) + } + llvm.func @test_or4(%arg0: i64, %arg1: !llvm.ptr) -> i64 { + llvm.br ^bb1(%arg0 : i64) ^bb1(%0: i64): // 2 preds: ^bb0, ^bb1 - %1 = "llvm.load"(%arg1) : (!llvm.ptr) -> i64 - %2 = "llvm.or"(%0, %1) : (i64, i64) -> i64 - "llvm.call"(%2) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.br"(%2)[^bb1] : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test_or4", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 15 : i64} : () -> i64 - "llvm.br"(%arg0)[^bb1] : (i64) -> () + %1 = llvm.load volatile %arg1 {alignment = 4 : i64} : !llvm.ptr -> i64 + %2 = llvm.or %0, %1 : i64 + llvm.call @use(%2) : (i64) -> () + llvm.br ^bb1(%2 : i64) + } + llvm.func @test_and(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(15 : i64) : i64 + llvm.br ^bb1(%arg0 : i64) ^bb1(%1: i64): // 2 preds: ^bb0, ^bb1 - %2 = "llvm.and"(%1, %0) : (i64, i64) -> i64 - "llvm.call"(%2) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.br"(%2)[^bb1] : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test_and", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - "llvm.br"(%arg0)[^bb1] : (i64) -> () + %2 = llvm.and %1, %0 : i64 + llvm.call @use(%2) : (i64) -> () + llvm.br ^bb1(%2 : i64) + } + llvm.func @test_and2(%arg0: i64, %arg1: i64) -> i64 { + llvm.br ^bb1(%arg0 : i64) ^bb1(%0: i64): // 2 preds: ^bb0, ^bb1 - %1 = "llvm.and"(%0, %arg1) : (i64, i64) -> i64 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.br"(%1)[^bb1] : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test_and2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - "llvm.br"(%arg0)[^bb1] : (i64) -> () + %1 = llvm.and %0, %arg1 : i64 + llvm.call @use(%1) : (i64) -> () + llvm.br ^bb1(%1 : i64) + } + llvm.func @test_and3(%arg0: i64, %arg1: i64) -> i64 { + llvm.br ^bb1(%arg0 : i64) ^bb1(%0: i64): // 2 preds: ^bb0, ^bb1 - %1 = "llvm.and"(%arg1, %0) : (i64, i64) -> i64 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.br"(%1)[^bb1] : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test_and3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: !llvm.ptr): // no predecessors - "llvm.br"(%arg0)[^bb1] : (i64) -> () + %1 = llvm.and %arg1, %0 : i64 + llvm.call @use(%1) : (i64) -> () + llvm.br ^bb1(%1 : i64) + } + llvm.func @test_and4(%arg0: i64, %arg1: !llvm.ptr) -> i64 { + llvm.br ^bb1(%arg0 : i64) ^bb1(%0: i64): // 2 preds: ^bb0, ^bb1 - %1 = "llvm.load"(%arg1) : (!llvm.ptr) -> i64 - %2 = "llvm.and"(%0, %1) : (i64, i64) -> i64 - "llvm.call"(%2) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.br"(%2)[^bb1] : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test_and4", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %1 = llvm.load volatile %arg1 {alignment = 4 : i64} : !llvm.ptr -> i64 + %2 = llvm.and %0, %1 : i64 + llvm.call @use(%2) : (i64) -> () + llvm.br ^bb1(%2 : i64) + } + llvm.func @use(i64) +} diff --git a/test/LLVMDialect/InstCombine/reduction-add-sext-zext-i1.ll.mlir b/test/LLVMDialect/InstCombine/reduction-add-sext-zext-i1.ll.mlir new file mode 100644 index 000000000..a674610d2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/reduction-add-sext-zext-i1.ll.mlir @@ -0,0 +1,46 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @glob() {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.mlir.global external @glob1() {addr_space = 0 : i32, alignment = 8 : i64} : i64 + llvm.func @reduce_add_self(%arg0: vector<8xi1>) -> i1 { + %0 = "llvm.intr.vector.reduce.add"(%arg0) : (vector<8xi1>) -> i1 + llvm.return %0 : i1 + } + llvm.func @reduce_add_sext(%arg0: vector<4xi1>) -> i32 { + %0 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %1 = "llvm.intr.vector.reduce.add"(%0) : (vector<4xi32>) -> i32 + llvm.return %1 : i32 + } + llvm.func @reduce_add_zext(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %1 = "llvm.intr.vector.reduce.add"(%0) : (vector<8xi64>) -> i64 + llvm.return %1 : i64 + } + llvm.func @reduce_add_sext_same(%arg0: vector<16xi1>) -> i16 { + %0 = llvm.sext %arg0 : vector<16xi1> to vector<16xi16> + %1 = "llvm.intr.vector.reduce.add"(%0) : (vector<16xi16>) -> i16 + llvm.return %1 : i16 + } + llvm.func @reduce_add_zext_long(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %1 = "llvm.intr.vector.reduce.add"(%0) : (vector<128xi8>) -> i8 + llvm.return %1 : i8 + } + llvm.func @reduce_add_zext_long_external_use(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob : !llvm.ptr + %2 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %3 = "llvm.intr.vector.reduce.add"(%2) : (vector<128xi8>) -> i8 + %4 = llvm.extractelement %2[%0 : i32] : vector<128xi8> + llvm.store %4, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return %3 : i8 + } + llvm.func @reduce_add_zext_external_use(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob1 : !llvm.ptr + %2 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %3 = "llvm.intr.vector.reduce.add"(%2) : (vector<8xi64>) -> i64 + %4 = llvm.extractelement %2[%0 : i32] : vector<8xi64> + llvm.store %4, %1 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/reduction-and-sext-zext-i1.ll.mlir b/test/LLVMDialect/InstCombine/reduction-and-sext-zext-i1.ll.mlir new file mode 100644 index 000000000..455b4671b --- /dev/null +++ b/test/LLVMDialect/InstCombine/reduction-and-sext-zext-i1.ll.mlir @@ -0,0 +1,78 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.mlir.global external @glob() {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.mlir.global external @glob1() {addr_space = 0 : i32, alignment = 8 : i64} : i64 + llvm.func @reduce_and_self(%arg0: vector<8xi1>) -> i1 { + %0 = "llvm.intr.vector.reduce.and"(%arg0) : (vector<8xi1>) -> i1 + llvm.return %0 : i1 + } + llvm.func @reduce_and_sext(%arg0: vector<4xi1>) -> i32 { + %0 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %1 = "llvm.intr.vector.reduce.and"(%0) : (vector<4xi32>) -> i32 + llvm.return %1 : i32 + } + llvm.func @reduce_and_zext(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %1 = "llvm.intr.vector.reduce.and"(%0) : (vector<8xi64>) -> i64 + llvm.return %1 : i64 + } + llvm.func @reduce_and_sext_same(%arg0: vector<16xi1>) -> i16 { + %0 = llvm.sext %arg0 : vector<16xi1> to vector<16xi16> + %1 = "llvm.intr.vector.reduce.and"(%0) : (vector<16xi16>) -> i16 + llvm.return %1 : i16 + } + llvm.func @reduce_and_zext_long(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %1 = "llvm.intr.vector.reduce.and"(%0) : (vector<128xi8>) -> i8 + llvm.return %1 : i8 + } + llvm.func @reduce_and_zext_long_external_use(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob : !llvm.ptr + %2 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %3 = "llvm.intr.vector.reduce.and"(%2) : (vector<128xi8>) -> i8 + %4 = llvm.extractelement %2[%0 : i32] : vector<128xi8> + llvm.store %4, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return %3 : i8 + } + llvm.func @reduce_and_zext_external_use(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob1 : !llvm.ptr + %2 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %3 = "llvm.intr.vector.reduce.and"(%2) : (vector<8xi64>) -> i64 + %4 = llvm.extractelement %2[%0 : i32] : vector<8xi64> + llvm.store %4, %1 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %3 : i64 + } + llvm.func @reduce_and_pointer_cast(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> vector<8xi8> + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> vector<8xi8> + %2 = llvm.icmp "eq" %0, %1 : vector<8xi8> + %3 = "llvm.intr.vector.reduce.and"(%2) : (vector<8xi1>) -> i1 + llvm.return %3 : i1 + } + llvm.func @reduce_and_pointer_cast_wide(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.load %arg1 {alignment = 16 : i64} : !llvm.ptr -> vector<8xi16> + %1 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> vector<8xi16> + %2 = llvm.icmp "eq" %0, %1 : vector<8xi16> + %3 = "llvm.intr.vector.reduce.and"(%2) : (vector<8xi1>) -> i1 + llvm.return %3 : i1 + } + llvm.func @reduce_and_pointer_cast_ne(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> vector<8xi8> + %2 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> vector<8xi8> + %3 = llvm.icmp "eq" %1, %2 : vector<8xi8> + %4 = "llvm.intr.vector.reduce.and"(%3) : (vector<8xi1>) -> i1 + %5 = llvm.xor %4, %0 : i1 + llvm.return %5 : i1 + } + llvm.func @reduce_and_pointer_cast_ne_wide(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.load %arg1 {alignment = 16 : i64} : !llvm.ptr -> vector<8xi16> + %2 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> vector<8xi16> + %3 = llvm.icmp "eq" %1, %2 : vector<8xi16> + %4 = "llvm.intr.vector.reduce.and"(%3) : (vector<8xi1>) -> i1 + %5 = llvm.xor %4, %0 : i1 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/reduction-mul-sext-zext-i1.ll.mlir b/test/LLVMDialect/InstCombine/reduction-mul-sext-zext-i1.ll.mlir new file mode 100644 index 000000000..b6e480168 --- /dev/null +++ b/test/LLVMDialect/InstCombine/reduction-mul-sext-zext-i1.ll.mlir @@ -0,0 +1,46 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @glob() {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.mlir.global external @glob1() {addr_space = 0 : i32, alignment = 8 : i64} : i64 + llvm.func @reduce_mul_self(%arg0: vector<8xi1>) -> i1 { + %0 = "llvm.intr.vector.reduce.mul"(%arg0) : (vector<8xi1>) -> i1 + llvm.return %0 : i1 + } + llvm.func @reduce_mul_sext(%arg0: vector<4xi1>) -> i32 { + %0 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %1 = "llvm.intr.vector.reduce.mul"(%0) : (vector<4xi32>) -> i32 + llvm.return %1 : i32 + } + llvm.func @reduce_mul_zext(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %1 = "llvm.intr.vector.reduce.mul"(%0) : (vector<8xi64>) -> i64 + llvm.return %1 : i64 + } + llvm.func @reduce_mul_sext_same(%arg0: vector<16xi1>) -> i16 { + %0 = llvm.sext %arg0 : vector<16xi1> to vector<16xi16> + %1 = "llvm.intr.vector.reduce.mul"(%0) : (vector<16xi16>) -> i16 + llvm.return %1 : i16 + } + llvm.func @reduce_mul_zext_long(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %1 = "llvm.intr.vector.reduce.mul"(%0) : (vector<128xi8>) -> i8 + llvm.return %1 : i8 + } + llvm.func @reduce_mul_zext_long_external_use(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob : !llvm.ptr + %2 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %3 = "llvm.intr.vector.reduce.mul"(%2) : (vector<128xi8>) -> i8 + %4 = llvm.extractelement %2[%0 : i32] : vector<128xi8> + llvm.store %4, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return %3 : i8 + } + llvm.func @reduce_mul_zext_external_use(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob1 : !llvm.ptr + %2 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %3 = "llvm.intr.vector.reduce.mul"(%2) : (vector<8xi64>) -> i64 + %4 = llvm.extractelement %2[%0 : i32] : vector<8xi64> + llvm.store %4, %1 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/reduction-or-sext-zext-i1.ll.mlir b/test/LLVMDialect/InstCombine/reduction-or-sext-zext-i1.ll.mlir new file mode 100644 index 000000000..cff5c3a93 --- /dev/null +++ b/test/LLVMDialect/InstCombine/reduction-or-sext-zext-i1.ll.mlir @@ -0,0 +1,78 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @glob() {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.mlir.global external @glob1() {addr_space = 0 : i32, alignment = 8 : i64} : i64 + llvm.func @reduce_or_self(%arg0: vector<8xi1>) -> i1 { + %0 = "llvm.intr.vector.reduce.or"(%arg0) : (vector<8xi1>) -> i1 + llvm.return %0 : i1 + } + llvm.func @reduce_or_sext(%arg0: vector<4xi1>) -> i32 { + %0 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %1 = "llvm.intr.vector.reduce.or"(%0) : (vector<4xi32>) -> i32 + llvm.return %1 : i32 + } + llvm.func @reduce_or_zext(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %1 = "llvm.intr.vector.reduce.or"(%0) : (vector<8xi64>) -> i64 + llvm.return %1 : i64 + } + llvm.func @reduce_or_sext_same(%arg0: vector<16xi1>) -> i16 { + %0 = llvm.sext %arg0 : vector<16xi1> to vector<16xi16> + %1 = "llvm.intr.vector.reduce.or"(%0) : (vector<16xi16>) -> i16 + llvm.return %1 : i16 + } + llvm.func @reduce_or_zext_long(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %1 = "llvm.intr.vector.reduce.or"(%0) : (vector<128xi8>) -> i8 + llvm.return %1 : i8 + } + llvm.func @reduce_or_zext_long_external_use(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob : !llvm.ptr + %2 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %3 = "llvm.intr.vector.reduce.or"(%2) : (vector<128xi8>) -> i8 + %4 = llvm.extractelement %2[%0 : i32] : vector<128xi8> + llvm.store %4, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return %3 : i8 + } + llvm.func @reduce_or_zext_external_use(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob1 : !llvm.ptr + %2 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %3 = "llvm.intr.vector.reduce.or"(%2) : (vector<8xi64>) -> i64 + %4 = llvm.extractelement %2[%0 : i32] : vector<8xi64> + llvm.store %4, %1 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %3 : i64 + } + llvm.func @reduce_or_pointer_cast(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> vector<8xi8> + %2 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> vector<8xi8> + %3 = llvm.icmp "ne" %1, %2 : vector<8xi8> + %4 = "llvm.intr.vector.reduce.or"(%3) : (vector<8xi1>) -> i1 + %5 = llvm.xor %4, %0 : i1 + llvm.return %5 : i1 + } + llvm.func @reduce_or_pointer_cast_wide(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.load %arg1 {alignment = 16 : i64} : !llvm.ptr -> vector<8xi16> + %2 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> vector<8xi16> + %3 = llvm.icmp "ne" %1, %2 : vector<8xi16> + %4 = "llvm.intr.vector.reduce.or"(%3) : (vector<8xi1>) -> i1 + %5 = llvm.xor %4, %0 : i1 + llvm.return %5 : i1 + } + llvm.func @reduce_or_pointer_cast_ne(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> vector<8xi8> + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> vector<8xi8> + %2 = llvm.icmp "ne" %0, %1 : vector<8xi8> + %3 = "llvm.intr.vector.reduce.or"(%2) : (vector<8xi1>) -> i1 + llvm.return %3 : i1 + } + llvm.func @reduce_or_pointer_cast_ne_wide(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.load %arg1 {alignment = 16 : i64} : !llvm.ptr -> vector<8xi16> + %1 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> vector<8xi16> + %2 = llvm.icmp "ne" %0, %1 : vector<8xi16> + %3 = "llvm.intr.vector.reduce.or"(%2) : (vector<8xi1>) -> i1 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/reduction-shufflevector.ll.mlir b/test/LLVMDialect/InstCombine/reduction-shufflevector.ll.mlir new file mode 100644 index 000000000..0b365d3bc --- /dev/null +++ b/test/LLVMDialect/InstCombine/reduction-shufflevector.ll.mlir @@ -0,0 +1,144 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @reduce_add(%arg0: vector<4xi32>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3] : vector<4xi32> + %2 = "llvm.intr.vector.reduce.add"(%1) : (vector<4xi32>) -> i32 + llvm.return %2 : i32 + } + llvm.func @reduce_or(%arg0: vector<4xi32>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %0, %arg0 [7, 6, 5, 4] : vector<4xi32> + %2 = "llvm.intr.vector.reduce.or"(%1) : (vector<4xi32>) -> i32 + llvm.return %2 : i32 + } + llvm.func @reduce_and(%arg0: vector<4xi32>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [0, 2, 1, 3] : vector<4xi32> + %2 = "llvm.intr.vector.reduce.and"(%1) : (vector<4xi32>) -> i32 + llvm.return %2 : i32 + } + llvm.func @reduce_xor(%arg0: vector<4xi32>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %0, %arg0 [5, 6, 7, 4] : vector<4xi32> + %2 = "llvm.intr.vector.reduce.xor"(%1) : (vector<4xi32>) -> i32 + llvm.return %2 : i32 + } + llvm.func @reduce_umax(%arg0: vector<4xi32>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [2, 1, 3, 0] : vector<4xi32> + %2 = "llvm.intr.vector.reduce.umax"(%1) : (vector<4xi32>) -> i32 + llvm.return %2 : i32 + } + llvm.func @reduce_umin(%arg0: vector<4xi32>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [2, 3, 0, 1] : vector<4xi32> + %2 = "llvm.intr.vector.reduce.umin"(%1) : (vector<4xi32>) -> i32 + llvm.return %2 : i32 + } + llvm.func @reduce_smax(%arg0: vector<4xi32>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [2, 0, 3, 1] : vector<4xi32> + %2 = "llvm.intr.vector.reduce.smax"(%1) : (vector<4xi32>) -> i32 + llvm.return %2 : i32 + } + llvm.func @reduce_smin(%arg0: vector<4xi32>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [0, 3, 1, 2] : vector<4xi32> + %2 = "llvm.intr.vector.reduce.smin"(%1) : (vector<4xi32>) -> i32 + llvm.return %2 : i32 + } + llvm.func @reduce_fmax(%arg0: vector<4xf32>) -> f32 { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.shufflevector %arg0, %0 [2, 0, 3, 1] : vector<4xf32> + %2 = llvm.intr.vector.reduce.fmax(%1) {fastmathFlags = #llvm.fastmath} : (vector<4xf32>) -> f32 + llvm.return %2 : f32 + } + llvm.func @reduce_fmin(%arg0: vector<4xf32>) -> f32 { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.shufflevector %arg0, %0 [0, 3, 1, 2] : vector<4xf32> + %2 = llvm.intr.vector.reduce.fmin(%1) : (vector<4xf32>) -> f32 + llvm.return %2 : f32 + } + llvm.func @reduce_fadd(%arg0: f32, %arg1: vector<4xf32>) -> f32 { + %0 = llvm.shufflevector %arg1, %arg1 [0, 3, 1, 2] : vector<4xf32> + %1 = "llvm.intr.vector.reduce.fadd"(%arg0, %0) <{fastmathFlags = #llvm.fastmath}> : (f32, vector<4xf32>) -> f32 + llvm.return %1 : f32 + } + llvm.func @reduce_fmul(%arg0: f32, %arg1: vector<4xf32>) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.shufflevector %arg1, %1 [0, 3, 1, 2] : vector<4xf32> + %3 = "llvm.intr.vector.reduce.fmul"(%arg0, %2) <{fastmathFlags = #llvm.fastmath}> : (f32, vector<4xf32>) -> f32 + llvm.return %3 : f32 + } + llvm.func @reduce_add_failed(%arg0: vector<4xi32>) -> i32 { + %0 = llvm.shufflevector %arg0, %arg0 [0, 1, 2, 4] : vector<4xi32> + %1 = "llvm.intr.vector.reduce.add"(%0) : (vector<4xi32>) -> i32 + llvm.return %1 : i32 + } + llvm.func @reduce_or_failed(%arg0: vector<4xi32>) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [3, 2, 1, 4] : vector<4xi32> + %3 = "llvm.intr.vector.reduce.or"(%2) : (vector<4xi32>) -> i32 + llvm.return %3 : i32 + } + llvm.func @reduce_and_failed(%arg0: vector<4xi32>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [0, 2, 1, 0] : vector<4xi32> + %2 = "llvm.intr.vector.reduce.and"(%1) : (vector<4xi32>) -> i32 + llvm.return %2 : i32 + } + llvm.func @reduce_xor_failed(%arg0: vector<4xi32>) -> i32 { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [1, 2, 3, -1] : vector<4xi32> + %2 = "llvm.intr.vector.reduce.xor"(%1) : (vector<4xi32>) -> i32 + llvm.return %2 : i32 + } + llvm.func @reduce_umax_failed(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> i32 { + %0 = llvm.shufflevector %arg0, %arg1 [2, 1, 3, 0] : vector<2xi32> + %1 = "llvm.intr.vector.reduce.umax"(%0) : (vector<4xi32>) -> i32 + llvm.return %1 : i32 + } + llvm.func @reduce_umin_failed(%arg0: vector<2xi32>) -> i32 { + %0 = llvm.mlir.poison : vector<2xi32> + %1 = llvm.shufflevector %arg0, %0 [2, 3, 0, 1] : vector<2xi32> + %2 = "llvm.intr.vector.reduce.umin"(%1) : (vector<4xi32>) -> i32 + llvm.return %2 : i32 + } + llvm.func @reduce_smax_failed(%arg0: vector<8xi32>) -> i32 { + %0 = llvm.mlir.poison : vector<8xi32> + %1 = llvm.shufflevector %arg0, %0 [2, 0, 3, 1] : vector<8xi32> + %2 = "llvm.intr.vector.reduce.smax"(%1) : (vector<4xi32>) -> i32 + llvm.return %2 : i32 + } + llvm.func @reduce_smin_failed(%arg0: vector<8xi32>) -> i32 { + %0 = llvm.shufflevector %arg0, %arg0 [0, 3, 1, 2] : vector<8xi32> + %1 = "llvm.intr.vector.reduce.smin"(%0) : (vector<4xi32>) -> i32 + llvm.return %1 : i32 + } + llvm.func @reduce_fmax_failed(%arg0: vector<4xf32>) -> f32 { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.shufflevector %arg0, %0 [2, 2, 3, 1] : vector<4xf32> + %2 = llvm.intr.vector.reduce.fmax(%1) : (vector<4xf32>) -> f32 + llvm.return %2 : f32 + } + llvm.func @reduce_fmin_failed(%arg0: vector<4xf32>) -> f32 { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.shufflevector %arg0, %0 [-1, 3, 1, 2] : vector<4xf32> + %2 = llvm.intr.vector.reduce.fmin(%1) : (vector<4xf32>) -> f32 + llvm.return %2 : f32 + } + llvm.func @reduce_fadd_failed(%arg0: f32, %arg1: vector<4xf32>) -> f32 { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.shufflevector %arg1, %0 [0, 3, 1, 2] : vector<4xf32> + %2 = "llvm.intr.vector.reduce.fadd"(%arg0, %1) <{fastmathFlags = #llvm.fastmath}> : (f32, vector<4xf32>) -> f32 + llvm.return %2 : f32 + } + llvm.func @reduce_fmul_failed(%arg0: f32, %arg1: vector<2xf32>) -> f32 { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.shufflevector %arg1, %0 [0, 3, 1, 2] : vector<2xf32> + %2 = "llvm.intr.vector.reduce.fmul"(%arg0, %1) <{fastmathFlags = #llvm.fastmath}> : (f32, vector<4xf32>) -> f32 + llvm.return %2 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/reduction-smax-sext-zext-i1.ll.mlir b/test/LLVMDialect/InstCombine/reduction-smax-sext-zext-i1.ll.mlir new file mode 100644 index 000000000..9a6fbb47b --- /dev/null +++ b/test/LLVMDialect/InstCombine/reduction-smax-sext-zext-i1.ll.mlir @@ -0,0 +1,46 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @glob() {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.mlir.global external @glob1() {addr_space = 0 : i32, alignment = 8 : i64} : i64 + llvm.func @reduce_smax_self(%arg0: vector<8xi1>) -> i1 { + %0 = "llvm.intr.vector.reduce.smax"(%arg0) : (vector<8xi1>) -> i1 + llvm.return %0 : i1 + } + llvm.func @reduce_smax_sext(%arg0: vector<4xi1>) -> i32 { + %0 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %1 = "llvm.intr.vector.reduce.smax"(%0) : (vector<4xi32>) -> i32 + llvm.return %1 : i32 + } + llvm.func @reduce_smax_zext(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %1 = "llvm.intr.vector.reduce.smax"(%0) : (vector<8xi64>) -> i64 + llvm.return %1 : i64 + } + llvm.func @reduce_smax_sext_same(%arg0: vector<16xi1>) -> i16 { + %0 = llvm.sext %arg0 : vector<16xi1> to vector<16xi16> + %1 = "llvm.intr.vector.reduce.smax"(%0) : (vector<16xi16>) -> i16 + llvm.return %1 : i16 + } + llvm.func @reduce_smax_zext_long(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %1 = "llvm.intr.vector.reduce.smax"(%0) : (vector<128xi8>) -> i8 + llvm.return %1 : i8 + } + llvm.func @reduce_smax_zext_long_external_use(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob : !llvm.ptr + %2 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %3 = "llvm.intr.vector.reduce.smax"(%2) : (vector<128xi8>) -> i8 + %4 = llvm.extractelement %2[%0 : i32] : vector<128xi8> + llvm.store %4, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return %3 : i8 + } + llvm.func @reduce_smax_zext_external_use(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob1 : !llvm.ptr + %2 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %3 = "llvm.intr.vector.reduce.smax"(%2) : (vector<8xi64>) -> i64 + %4 = llvm.extractelement %2[%0 : i32] : vector<8xi64> + llvm.store %4, %1 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/reduction-smin-sext-zext-i1.ll.mlir b/test/LLVMDialect/InstCombine/reduction-smin-sext-zext-i1.ll.mlir new file mode 100644 index 000000000..664e51e9d --- /dev/null +++ b/test/LLVMDialect/InstCombine/reduction-smin-sext-zext-i1.ll.mlir @@ -0,0 +1,46 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @glob() {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.mlir.global external @glob1() {addr_space = 0 : i32, alignment = 8 : i64} : i64 + llvm.func @reduce_smin_self(%arg0: vector<8xi1>) -> i1 { + %0 = "llvm.intr.vector.reduce.smin"(%arg0) : (vector<8xi1>) -> i1 + llvm.return %0 : i1 + } + llvm.func @reduce_smin_sext(%arg0: vector<4xi1>) -> i32 { + %0 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %1 = "llvm.intr.vector.reduce.smin"(%0) : (vector<4xi32>) -> i32 + llvm.return %1 : i32 + } + llvm.func @reduce_smin_zext(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %1 = "llvm.intr.vector.reduce.smin"(%0) : (vector<8xi64>) -> i64 + llvm.return %1 : i64 + } + llvm.func @reduce_smin_sext_same(%arg0: vector<16xi1>) -> i16 { + %0 = llvm.sext %arg0 : vector<16xi1> to vector<16xi16> + %1 = "llvm.intr.vector.reduce.smin"(%0) : (vector<16xi16>) -> i16 + llvm.return %1 : i16 + } + llvm.func @reduce_smin_zext_long(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %1 = "llvm.intr.vector.reduce.smin"(%0) : (vector<128xi8>) -> i8 + llvm.return %1 : i8 + } + llvm.func @reduce_smin_zext_long_external_use(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob : !llvm.ptr + %2 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %3 = "llvm.intr.vector.reduce.smin"(%2) : (vector<128xi8>) -> i8 + %4 = llvm.extractelement %2[%0 : i32] : vector<128xi8> + llvm.store %4, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return %3 : i8 + } + llvm.func @reduce_smin_zext_external_use(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob1 : !llvm.ptr + %2 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %3 = "llvm.intr.vector.reduce.smin"(%2) : (vector<8xi64>) -> i64 + %4 = llvm.extractelement %2[%0 : i32] : vector<8xi64> + llvm.store %4, %1 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/reduction-umax-sext-zext-i1.ll.mlir b/test/LLVMDialect/InstCombine/reduction-umax-sext-zext-i1.ll.mlir new file mode 100644 index 000000000..97f8da0fd --- /dev/null +++ b/test/LLVMDialect/InstCombine/reduction-umax-sext-zext-i1.ll.mlir @@ -0,0 +1,46 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @glob() {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.mlir.global external @glob1() {addr_space = 0 : i32, alignment = 8 : i64} : i64 + llvm.func @reduce_umax_self(%arg0: vector<8xi1>) -> i1 { + %0 = "llvm.intr.vector.reduce.umax"(%arg0) : (vector<8xi1>) -> i1 + llvm.return %0 : i1 + } + llvm.func @reduce_umax_sext(%arg0: vector<4xi1>) -> i32 { + %0 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %1 = "llvm.intr.vector.reduce.umax"(%0) : (vector<4xi32>) -> i32 + llvm.return %1 : i32 + } + llvm.func @reduce_umax_zext(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %1 = "llvm.intr.vector.reduce.umax"(%0) : (vector<8xi64>) -> i64 + llvm.return %1 : i64 + } + llvm.func @reduce_umax_sext_same(%arg0: vector<16xi1>) -> i16 { + %0 = llvm.sext %arg0 : vector<16xi1> to vector<16xi16> + %1 = "llvm.intr.vector.reduce.umax"(%0) : (vector<16xi16>) -> i16 + llvm.return %1 : i16 + } + llvm.func @reduce_umax_zext_long(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %1 = "llvm.intr.vector.reduce.umax"(%0) : (vector<128xi8>) -> i8 + llvm.return %1 : i8 + } + llvm.func @reduce_umax_zext_long_external_use(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob : !llvm.ptr + %2 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %3 = "llvm.intr.vector.reduce.umax"(%2) : (vector<128xi8>) -> i8 + %4 = llvm.extractelement %2[%0 : i32] : vector<128xi8> + llvm.store %4, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return %3 : i8 + } + llvm.func @reduce_umax_zext_external_use(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob1 : !llvm.ptr + %2 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %3 = "llvm.intr.vector.reduce.umax"(%2) : (vector<8xi64>) -> i64 + %4 = llvm.extractelement %2[%0 : i32] : vector<8xi64> + llvm.store %4, %1 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/reduction-umin-sext-zext-i1.ll.mlir b/test/LLVMDialect/InstCombine/reduction-umin-sext-zext-i1.ll.mlir new file mode 100644 index 000000000..95ddf2447 --- /dev/null +++ b/test/LLVMDialect/InstCombine/reduction-umin-sext-zext-i1.ll.mlir @@ -0,0 +1,46 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @glob() {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.mlir.global external @glob1() {addr_space = 0 : i32, alignment = 8 : i64} : i64 + llvm.func @reduce_umin_self(%arg0: vector<8xi1>) -> i1 { + %0 = "llvm.intr.vector.reduce.umin"(%arg0) : (vector<8xi1>) -> i1 + llvm.return %0 : i1 + } + llvm.func @reduce_umin_sext(%arg0: vector<4xi1>) -> i32 { + %0 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %1 = "llvm.intr.vector.reduce.umin"(%0) : (vector<4xi32>) -> i32 + llvm.return %1 : i32 + } + llvm.func @reduce_umin_zext(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %1 = "llvm.intr.vector.reduce.umin"(%0) : (vector<8xi64>) -> i64 + llvm.return %1 : i64 + } + llvm.func @reduce_umin_sext_same(%arg0: vector<16xi1>) -> i16 { + %0 = llvm.sext %arg0 : vector<16xi1> to vector<16xi16> + %1 = "llvm.intr.vector.reduce.umin"(%0) : (vector<16xi16>) -> i16 + llvm.return %1 : i16 + } + llvm.func @reduce_umin_zext_long(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %1 = "llvm.intr.vector.reduce.umin"(%0) : (vector<128xi8>) -> i8 + llvm.return %1 : i8 + } + llvm.func @reduce_umin_zext_long_external_use(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob : !llvm.ptr + %2 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %3 = "llvm.intr.vector.reduce.umin"(%2) : (vector<128xi8>) -> i8 + %4 = llvm.extractelement %2[%0 : i32] : vector<128xi8> + llvm.store %4, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return %3 : i8 + } + llvm.func @reduce_umin_zext_external_use(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob1 : !llvm.ptr + %2 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %3 = "llvm.intr.vector.reduce.umin"(%2) : (vector<8xi64>) -> i64 + %4 = llvm.extractelement %2[%0 : i32] : vector<8xi64> + llvm.store %4, %1 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/reduction-xor-sext-zext-i1.ll.mlir b/test/LLVMDialect/InstCombine/reduction-xor-sext-zext-i1.ll.mlir new file mode 100644 index 000000000..30cff4506 --- /dev/null +++ b/test/LLVMDialect/InstCombine/reduction-xor-sext-zext-i1.ll.mlir @@ -0,0 +1,46 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @glob() {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.mlir.global external @glob1() {addr_space = 0 : i32, alignment = 8 : i64} : i64 + llvm.func @reduce_xor_self(%arg0: vector<8xi1>) -> i1 { + %0 = "llvm.intr.vector.reduce.xor"(%arg0) : (vector<8xi1>) -> i1 + llvm.return %0 : i1 + } + llvm.func @reduce_xor_sext(%arg0: vector<4xi1>) -> i32 { + %0 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %1 = "llvm.intr.vector.reduce.xor"(%0) : (vector<4xi32>) -> i32 + llvm.return %1 : i32 + } + llvm.func @reduce_xor_zext(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %1 = "llvm.intr.vector.reduce.xor"(%0) : (vector<8xi64>) -> i64 + llvm.return %1 : i64 + } + llvm.func @reduce_xor_sext_same(%arg0: vector<16xi1>) -> i16 { + %0 = llvm.sext %arg0 : vector<16xi1> to vector<16xi16> + %1 = "llvm.intr.vector.reduce.xor"(%0) : (vector<16xi16>) -> i16 + llvm.return %1 : i16 + } + llvm.func @reduce_xor_zext_long(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %1 = "llvm.intr.vector.reduce.xor"(%0) : (vector<128xi8>) -> i8 + llvm.return %1 : i8 + } + llvm.func @reduce_xor_zext_long_external_use(%arg0: vector<128xi1>) -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob : !llvm.ptr + %2 = llvm.sext %arg0 : vector<128xi1> to vector<128xi8> + %3 = "llvm.intr.vector.reduce.xor"(%2) : (vector<128xi8>) -> i8 + %4 = llvm.extractelement %2[%0 : i32] : vector<128xi8> + llvm.store %4, %1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return %3 : i8 + } + llvm.func @reduce_xor_zext_external_use(%arg0: vector<8xi1>) -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @glob1 : !llvm.ptr + %2 = llvm.zext %arg0 : vector<8xi1> to vector<8xi64> + %3 = "llvm.intr.vector.reduce.xor"(%2) : (vector<8xi64>) -> i64 + %4 = llvm.extractelement %2[%0 : i32] : vector<8xi64> + llvm.store %4, %1 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-a.ll.mlir b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-a.ll.mlir new file mode 100644 index 000000000..7acc483cb --- /dev/null +++ b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-a.ll.mlir @@ -0,0 +1,155 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @t0_basic(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.zext %arg1 : i32 to i64 + %4 = llvm.shl %0, %3 : i64 + %5 = llvm.add %4, %1 : i64 + %6 = llvm.sub %2, %arg1 : i32 + %7 = llvm.and %5, %arg0 : i64 + llvm.call @use32(%arg1) : (i32) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use64(%7) : (i64) -> () + %8 = llvm.trunc %7 : i64 to i32 + %9 = llvm.shl %8, %6 : i32 + llvm.return %9 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @use8xi64(vector<8xi64>) + llvm.func @t1_vec_splat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<8xi64>) : vector<8xi64> + %1 = llvm.mlir.constant(dense<-1> : vector<8xi64>) : vector<8xi64> + %2 = llvm.mlir.constant(dense<32> : vector<8xi32>) : vector<8xi32> + %3 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %4 = llvm.shl %0, %3 : vector<8xi64> + %5 = llvm.add %4, %1 : vector<8xi64> + %6 = llvm.sub %2, %arg1 : vector<8xi32> + %7 = llvm.and %5, %arg0 : vector<8xi64> + llvm.call @use8xi32(%arg1) : (vector<8xi32>) -> () + llvm.call @use8xi64(%3) : (vector<8xi64>) -> () + llvm.call @use8xi64(%4) : (vector<8xi64>) -> () + llvm.call @use8xi64(%5) : (vector<8xi64>) -> () + llvm.call @use8xi32(%6) : (vector<8xi32>) -> () + llvm.call @use8xi64(%7) : (vector<8xi64>) -> () + %8 = llvm.trunc %7 : vector<8xi64> to vector<8xi32> + %9 = llvm.shl %8, %6 : vector<8xi32> + llvm.return %9 : vector<8xi32> + } + llvm.func @t2_vec_splat_poison(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<8xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi64> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi64> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi64> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi64> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi64> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi64> + %19 = llvm.mlir.constant(-1 : i64) : i64 + %20 = llvm.mlir.undef : vector<8xi64> + %21 = llvm.mlir.constant(0 : i32) : i32 + %22 = llvm.insertelement %19, %20[%21 : i32] : vector<8xi64> + %23 = llvm.mlir.constant(1 : i32) : i32 + %24 = llvm.insertelement %19, %22[%23 : i32] : vector<8xi64> + %25 = llvm.mlir.constant(2 : i32) : i32 + %26 = llvm.insertelement %19, %24[%25 : i32] : vector<8xi64> + %27 = llvm.mlir.constant(3 : i32) : i32 + %28 = llvm.insertelement %19, %26[%27 : i32] : vector<8xi64> + %29 = llvm.mlir.constant(4 : i32) : i32 + %30 = llvm.insertelement %19, %28[%29 : i32] : vector<8xi64> + %31 = llvm.mlir.constant(5 : i32) : i32 + %32 = llvm.insertelement %19, %30[%31 : i32] : vector<8xi64> + %33 = llvm.mlir.constant(6 : i32) : i32 + %34 = llvm.insertelement %1, %32[%33 : i32] : vector<8xi64> + %35 = llvm.mlir.constant(7 : i32) : i32 + %36 = llvm.insertelement %19, %34[%35 : i32] : vector<8xi64> + %37 = llvm.mlir.constant(32 : i32) : i32 + %38 = llvm.mlir.poison : i32 + %39 = llvm.mlir.undef : vector<8xi32> + %40 = llvm.mlir.constant(0 : i32) : i32 + %41 = llvm.insertelement %37, %39[%40 : i32] : vector<8xi32> + %42 = llvm.mlir.constant(1 : i32) : i32 + %43 = llvm.insertelement %37, %41[%42 : i32] : vector<8xi32> + %44 = llvm.mlir.constant(2 : i32) : i32 + %45 = llvm.insertelement %37, %43[%44 : i32] : vector<8xi32> + %46 = llvm.mlir.constant(3 : i32) : i32 + %47 = llvm.insertelement %37, %45[%46 : i32] : vector<8xi32> + %48 = llvm.mlir.constant(4 : i32) : i32 + %49 = llvm.insertelement %37, %47[%48 : i32] : vector<8xi32> + %50 = llvm.mlir.constant(5 : i32) : i32 + %51 = llvm.insertelement %37, %49[%50 : i32] : vector<8xi32> + %52 = llvm.mlir.constant(6 : i32) : i32 + %53 = llvm.insertelement %38, %51[%52 : i32] : vector<8xi32> + %54 = llvm.mlir.constant(7 : i32) : i32 + %55 = llvm.insertelement %37, %53[%54 : i32] : vector<8xi32> + %56 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %57 = llvm.shl %18, %56 : vector<8xi64> + %58 = llvm.add %57, %36 : vector<8xi64> + %59 = llvm.sub %55, %arg1 : vector<8xi32> + %60 = llvm.and %58, %arg0 : vector<8xi64> + llvm.call @use8xi32(%arg1) : (vector<8xi32>) -> () + llvm.call @use8xi64(%56) : (vector<8xi64>) -> () + llvm.call @use8xi64(%57) : (vector<8xi64>) -> () + llvm.call @use8xi64(%58) : (vector<8xi64>) -> () + llvm.call @use8xi32(%59) : (vector<8xi32>) -> () + llvm.call @use8xi64(%60) : (vector<8xi64>) -> () + %61 = llvm.trunc %60 : vector<8xi64> to vector<8xi32> + %62 = llvm.shl %61, %59 : vector<8xi32> + llvm.return %62 : vector<8xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<8xi64>) : vector<8xi64> + %1 = llvm.mlir.constant(dense<-1> : vector<8xi64>) : vector<8xi64> + %2 = llvm.mlir.constant(dense<32> : vector<8xi32>) : vector<8xi32> + %3 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %4 = llvm.shl %0, %3 : vector<8xi64> + %5 = llvm.add %4, %1 : vector<8xi64> + %6 = llvm.sub %2, %arg1 : vector<8xi32> + %7 = llvm.and %5, %arg0 : vector<8xi64> + llvm.call @use8xi32(%arg1) : (vector<8xi32>) -> () + llvm.call @use8xi64(%3) : (vector<8xi64>) -> () + llvm.call @use8xi64(%4) : (vector<8xi64>) -> () + llvm.call @use8xi64(%5) : (vector<8xi64>) -> () + llvm.call @use8xi32(%6) : (vector<8xi32>) -> () + llvm.call @use8xi64(%7) : (vector<8xi64>) -> () + %8 = llvm.trunc %7 : vector<8xi64> to vector<8xi32> + %9 = llvm.shl %8, %6 : vector<8xi32> + llvm.return %9 : vector<8xi32> + } + llvm.func @n4_extrause(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.zext %arg1 : i32 to i64 + %4 = llvm.shl %0, %3 : i64 + %5 = llvm.add %4, %1 : i64 + %6 = llvm.sub %2, %arg1 : i32 + %7 = llvm.and %5, %arg0 : i64 + llvm.call @use32(%arg1) : (i32) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use64(%7) : (i64) -> () + %8 = llvm.trunc %7 : i64 to i32 + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.shl %8, %6 : i32 + llvm.return %9 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-b.ll.mlir b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-b.ll.mlir new file mode 100644 index 000000000..877b1276e --- /dev/null +++ b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-b.ll.mlir @@ -0,0 +1,154 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @t0_basic(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.shl %0, %2 : i64 + %4 = llvm.xor %3, %0 : i64 + %5 = llvm.sub %1, %arg1 : i32 + %6 = llvm.and %4, %arg0 : i64 + llvm.call @use32(%arg1) : (i32) -> () + llvm.call @use64(%2) : (i64) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use64(%6) : (i64) -> () + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.shl %7, %5 : i32 + llvm.return %8 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @use8xi64(vector<8xi64>) + llvm.func @t1_vec_splat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi64>) : vector<8xi64> + %1 = llvm.mlir.constant(dense<32> : vector<8xi32>) : vector<8xi32> + %2 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %3 = llvm.shl %0, %2 : vector<8xi64> + %4 = llvm.xor %3, %0 : vector<8xi64> + %5 = llvm.sub %1, %arg1 : vector<8xi32> + %6 = llvm.and %4, %arg0 : vector<8xi64> + llvm.call @use8xi32(%arg1) : (vector<8xi32>) -> () + llvm.call @use8xi64(%2) : (vector<8xi64>) -> () + llvm.call @use8xi64(%3) : (vector<8xi64>) -> () + llvm.call @use8xi64(%4) : (vector<8xi64>) -> () + llvm.call @use8xi32(%5) : (vector<8xi32>) -> () + llvm.call @use8xi64(%6) : (vector<8xi64>) -> () + %7 = llvm.trunc %6 : vector<8xi64> to vector<8xi32> + %8 = llvm.shl %7, %5 : vector<8xi32> + llvm.return %8 : vector<8xi32> + } + llvm.func @t2_vec_splat_poison(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<8xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi64> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi64> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi64> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi64> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi64> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi64> + %19 = llvm.mlir.constant(32 : i32) : i32 + %20 = llvm.mlir.poison : i32 + %21 = llvm.mlir.undef : vector<8xi32> + %22 = llvm.mlir.constant(0 : i32) : i32 + %23 = llvm.insertelement %19, %21[%22 : i32] : vector<8xi32> + %24 = llvm.mlir.constant(1 : i32) : i32 + %25 = llvm.insertelement %19, %23[%24 : i32] : vector<8xi32> + %26 = llvm.mlir.constant(2 : i32) : i32 + %27 = llvm.insertelement %19, %25[%26 : i32] : vector<8xi32> + %28 = llvm.mlir.constant(3 : i32) : i32 + %29 = llvm.insertelement %19, %27[%28 : i32] : vector<8xi32> + %30 = llvm.mlir.constant(4 : i32) : i32 + %31 = llvm.insertelement %19, %29[%30 : i32] : vector<8xi32> + %32 = llvm.mlir.constant(5 : i32) : i32 + %33 = llvm.insertelement %19, %31[%32 : i32] : vector<8xi32> + %34 = llvm.mlir.constant(6 : i32) : i32 + %35 = llvm.insertelement %20, %33[%34 : i32] : vector<8xi32> + %36 = llvm.mlir.constant(7 : i32) : i32 + %37 = llvm.insertelement %19, %35[%36 : i32] : vector<8xi32> + %38 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %39 = llvm.shl %18, %38 : vector<8xi64> + %40 = llvm.xor %39, %18 : vector<8xi64> + %41 = llvm.sub %37, %arg1 : vector<8xi32> + %42 = llvm.and %40, %arg0 : vector<8xi64> + llvm.call @use8xi32(%arg1) : (vector<8xi32>) -> () + llvm.call @use8xi64(%38) : (vector<8xi64>) -> () + llvm.call @use8xi64(%39) : (vector<8xi64>) -> () + llvm.call @use8xi64(%40) : (vector<8xi64>) -> () + llvm.call @use8xi32(%41) : (vector<8xi32>) -> () + llvm.call @use8xi64(%42) : (vector<8xi64>) -> () + %43 = llvm.trunc %42 : vector<8xi64> to vector<8xi32> + %44 = llvm.shl %43, %41 : vector<8xi32> + llvm.return %44 : vector<8xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<[-1, 0, 0, 1, 0, 0, 0, 0]> : vector<8xi32>) : vector<8xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<8xi64>) : vector<8xi64> + %2 = llvm.mlir.constant(dense<[33, 32, 33, 32, 32, 32, 32, 32]> : vector<8xi32>) : vector<8xi32> + %3 = llvm.add %arg1, %0 : vector<8xi32> + %4 = llvm.zext %3 : vector<8xi32> to vector<8xi64> + %5 = llvm.shl %1, %4 : vector<8xi64> + %6 = llvm.xor %5, %1 : vector<8xi64> + %7 = llvm.sub %2, %arg1 : vector<8xi32> + %8 = llvm.and %6, %arg0 : vector<8xi64> + llvm.call @use8xi32(%3) : (vector<8xi32>) -> () + llvm.call @use8xi64(%4) : (vector<8xi64>) -> () + llvm.call @use8xi64(%5) : (vector<8xi64>) -> () + llvm.call @use8xi64(%6) : (vector<8xi64>) -> () + llvm.call @use8xi32(%7) : (vector<8xi32>) -> () + llvm.call @use8xi64(%8) : (vector<8xi64>) -> () + %9 = llvm.trunc %8 : vector<8xi64> to vector<8xi32> + %10 = llvm.shl %9, %7 : vector<8xi32> + llvm.return %10 : vector<8xi32> + } + llvm.func @t4_allones_trunc(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(4294967295 : i64) : i64 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.zext %arg1 : i32 to i64 + %4 = llvm.shl %0, %3 : i64 + %5 = llvm.xor %4, %1 : i64 + %6 = llvm.sub %2, %arg1 : i32 + %7 = llvm.and %5, %arg0 : i64 + llvm.call @use32(%arg1) : (i32) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use64(%7) : (i64) -> () + %8 = llvm.trunc %7 : i64 to i32 + %9 = llvm.shl %8, %6 : i32 + llvm.return %9 : i32 + } + llvm.func @n5_extrause(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.shl %0, %2 : i64 + %4 = llvm.xor %3, %0 : i64 + %5 = llvm.sub %1, %arg1 : i32 + %6 = llvm.and %4, %arg0 : i64 + llvm.call @use32(%arg1) : (i32) -> () + llvm.call @use64(%2) : (i64) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use64(%6) : (i64) -> () + %7 = llvm.trunc %6 : i64 to i32 + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.shl %7, %5 : i32 + llvm.return %8 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-c.ll.mlir b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-c.ll.mlir new file mode 100644 index 000000000..8dfdc4c60 --- /dev/null +++ b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-c.ll.mlir @@ -0,0 +1,160 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @t0_basic(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(-32 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.lshr %0, %2 : i64 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.and %3, %arg0 : i64 + llvm.call @use64(%2) : (i64) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use64(%5) : (i64) -> () + %6 = llvm.trunc %5 : i64 to i32 + %7 = llvm.shl %6, %4 : i32 + llvm.return %7 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @use8xi64(vector<8xi64>) + llvm.func @t1_vec_splat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi64>) : vector<8xi64> + %1 = llvm.mlir.constant(dense<-32> : vector<8xi32>) : vector<8xi32> + %2 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %3 = llvm.lshr %0, %2 : vector<8xi64> + %4 = llvm.add %arg1, %1 : vector<8xi32> + %5 = llvm.and %3, %arg0 : vector<8xi64> + llvm.call @use8xi64(%2) : (vector<8xi64>) -> () + llvm.call @use8xi64(%3) : (vector<8xi64>) -> () + llvm.call @use8xi32(%4) : (vector<8xi32>) -> () + llvm.call @use8xi64(%5) : (vector<8xi64>) -> () + %6 = llvm.trunc %5 : vector<8xi64> to vector<8xi32> + %7 = llvm.shl %6, %4 : vector<8xi32> + llvm.return %7 : vector<8xi32> + } + llvm.func @t2_vec_splat_poison(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<8xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi64> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi64> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi64> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi64> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi64> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi64> + %19 = llvm.mlir.constant(-32 : i32) : i32 + %20 = llvm.mlir.poison : i32 + %21 = llvm.mlir.undef : vector<8xi32> + %22 = llvm.mlir.constant(0 : i32) : i32 + %23 = llvm.insertelement %19, %21[%22 : i32] : vector<8xi32> + %24 = llvm.mlir.constant(1 : i32) : i32 + %25 = llvm.insertelement %19, %23[%24 : i32] : vector<8xi32> + %26 = llvm.mlir.constant(2 : i32) : i32 + %27 = llvm.insertelement %19, %25[%26 : i32] : vector<8xi32> + %28 = llvm.mlir.constant(3 : i32) : i32 + %29 = llvm.insertelement %19, %27[%28 : i32] : vector<8xi32> + %30 = llvm.mlir.constant(4 : i32) : i32 + %31 = llvm.insertelement %19, %29[%30 : i32] : vector<8xi32> + %32 = llvm.mlir.constant(5 : i32) : i32 + %33 = llvm.insertelement %19, %31[%32 : i32] : vector<8xi32> + %34 = llvm.mlir.constant(6 : i32) : i32 + %35 = llvm.insertelement %20, %33[%34 : i32] : vector<8xi32> + %36 = llvm.mlir.constant(7 : i32) : i32 + %37 = llvm.insertelement %19, %35[%36 : i32] : vector<8xi32> + %38 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %39 = llvm.lshr %18, %38 : vector<8xi64> + %40 = llvm.add %arg1, %37 : vector<8xi32> + %41 = llvm.and %39, %arg0 : vector<8xi64> + llvm.call @use8xi64(%38) : (vector<8xi64>) -> () + llvm.call @use8xi64(%39) : (vector<8xi64>) -> () + llvm.call @use8xi32(%40) : (vector<8xi32>) -> () + llvm.call @use8xi64(%41) : (vector<8xi64>) -> () + %42 = llvm.trunc %41 : vector<8xi64> to vector<8xi32> + %43 = llvm.shl %42, %40 : vector<8xi32> + llvm.return %43 : vector<8xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<8xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi64> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi64> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi64> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi64> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi64> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi64> + %19 = llvm.mlir.constant(64 : i32) : i32 + %20 = llvm.mlir.poison : i32 + %21 = llvm.mlir.constant(32 : i32) : i32 + %22 = llvm.mlir.constant(31 : i32) : i32 + %23 = llvm.mlir.constant(1 : i32) : i32 + %24 = llvm.mlir.constant(0 : i32) : i32 + %25 = llvm.mlir.constant(-1 : i32) : i32 + %26 = llvm.mlir.constant(-32 : i32) : i32 + %27 = llvm.mlir.undef : vector<8xi32> + %28 = llvm.mlir.constant(0 : i32) : i32 + %29 = llvm.insertelement %26, %27[%28 : i32] : vector<8xi32> + %30 = llvm.mlir.constant(1 : i32) : i32 + %31 = llvm.insertelement %25, %29[%30 : i32] : vector<8xi32> + %32 = llvm.mlir.constant(2 : i32) : i32 + %33 = llvm.insertelement %24, %31[%32 : i32] : vector<8xi32> + %34 = llvm.mlir.constant(3 : i32) : i32 + %35 = llvm.insertelement %23, %33[%34 : i32] : vector<8xi32> + %36 = llvm.mlir.constant(4 : i32) : i32 + %37 = llvm.insertelement %22, %35[%36 : i32] : vector<8xi32> + %38 = llvm.mlir.constant(5 : i32) : i32 + %39 = llvm.insertelement %21, %37[%38 : i32] : vector<8xi32> + %40 = llvm.mlir.constant(6 : i32) : i32 + %41 = llvm.insertelement %20, %39[%40 : i32] : vector<8xi32> + %42 = llvm.mlir.constant(7 : i32) : i32 + %43 = llvm.insertelement %19, %41[%42 : i32] : vector<8xi32> + %44 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %45 = llvm.lshr %18, %44 : vector<8xi64> + %46 = llvm.add %arg1, %43 : vector<8xi32> + %47 = llvm.and %45, %arg0 : vector<8xi64> + llvm.call @use8xi64(%44) : (vector<8xi64>) -> () + llvm.call @use8xi64(%45) : (vector<8xi64>) -> () + llvm.call @use8xi32(%46) : (vector<8xi32>) -> () + llvm.call @use8xi64(%47) : (vector<8xi64>) -> () + %48 = llvm.trunc %47 : vector<8xi64> to vector<8xi32> + %49 = llvm.shl %48, %46 : vector<8xi32> + llvm.return %49 : vector<8xi32> + } + llvm.func @n4_extrause(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(-32 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.lshr %0, %2 : i64 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.and %3, %arg0 : i64 + llvm.call @use64(%2) : (i64) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use64(%5) : (i64) -> () + %6 = llvm.trunc %5 : i64 to i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %6, %4 : i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-d.ll.mlir b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-d.ll.mlir new file mode 100644 index 000000000..1b7732da7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-d.ll.mlir @@ -0,0 +1,170 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @t0_basic(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(-32 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.shl %0, %2 : i64 + %4 = llvm.lshr %3, %2 : i64 + %5 = llvm.add %arg1, %1 : i32 + %6 = llvm.and %4, %arg0 : i64 + llvm.call @use64(%2) : (i64) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use64(%6) : (i64) -> () + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.shl %7, %5 : i32 + llvm.return %8 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @use8xi64(vector<8xi64>) + llvm.func @t1_vec_splat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<8xi64>) : vector<8xi64> + %1 = llvm.mlir.constant(dense<-32> : vector<8xi32>) : vector<8xi32> + %2 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %3 = llvm.shl %0, %2 : vector<8xi64> + %4 = llvm.lshr %3, %2 : vector<8xi64> + %5 = llvm.add %arg1, %1 : vector<8xi32> + %6 = llvm.and %4, %arg0 : vector<8xi64> + llvm.call @use8xi64(%2) : (vector<8xi64>) -> () + llvm.call @use8xi64(%3) : (vector<8xi64>) -> () + llvm.call @use8xi64(%4) : (vector<8xi64>) -> () + llvm.call @use8xi32(%5) : (vector<8xi32>) -> () + llvm.call @use8xi64(%6) : (vector<8xi64>) -> () + %7 = llvm.trunc %6 : vector<8xi64> to vector<8xi32> + %8 = llvm.shl %7, %5 : vector<8xi32> + llvm.return %8 : vector<8xi32> + } + llvm.func @t2_vec_splat_poison(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<8xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi64> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi64> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi64> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi64> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi64> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi64> + %19 = llvm.mlir.constant(-32 : i32) : i32 + %20 = llvm.mlir.poison : i32 + %21 = llvm.mlir.undef : vector<8xi32> + %22 = llvm.mlir.constant(0 : i32) : i32 + %23 = llvm.insertelement %19, %21[%22 : i32] : vector<8xi32> + %24 = llvm.mlir.constant(1 : i32) : i32 + %25 = llvm.insertelement %19, %23[%24 : i32] : vector<8xi32> + %26 = llvm.mlir.constant(2 : i32) : i32 + %27 = llvm.insertelement %19, %25[%26 : i32] : vector<8xi32> + %28 = llvm.mlir.constant(3 : i32) : i32 + %29 = llvm.insertelement %19, %27[%28 : i32] : vector<8xi32> + %30 = llvm.mlir.constant(4 : i32) : i32 + %31 = llvm.insertelement %19, %29[%30 : i32] : vector<8xi32> + %32 = llvm.mlir.constant(5 : i32) : i32 + %33 = llvm.insertelement %19, %31[%32 : i32] : vector<8xi32> + %34 = llvm.mlir.constant(6 : i32) : i32 + %35 = llvm.insertelement %20, %33[%34 : i32] : vector<8xi32> + %36 = llvm.mlir.constant(7 : i32) : i32 + %37 = llvm.insertelement %19, %35[%36 : i32] : vector<8xi32> + %38 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %39 = llvm.shl %18, %38 : vector<8xi64> + %40 = llvm.lshr %39, %38 : vector<8xi64> + %41 = llvm.add %arg1, %37 : vector<8xi32> + %42 = llvm.and %40, %arg0 : vector<8xi64> + llvm.call @use8xi64(%38) : (vector<8xi64>) -> () + llvm.call @use8xi64(%39) : (vector<8xi64>) -> () + llvm.call @use8xi64(%40) : (vector<8xi64>) -> () + llvm.call @use8xi32(%41) : (vector<8xi32>) -> () + llvm.call @use8xi64(%42) : (vector<8xi64>) -> () + %43 = llvm.trunc %42 : vector<8xi64> to vector<8xi32> + %44 = llvm.shl %43, %41 : vector<8xi32> + llvm.return %44 : vector<8xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<8xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi64> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi64> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi64> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi64> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi64> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi64> + %19 = llvm.mlir.constant(64 : i32) : i32 + %20 = llvm.mlir.poison : i32 + %21 = llvm.mlir.constant(32 : i32) : i32 + %22 = llvm.mlir.constant(31 : i32) : i32 + %23 = llvm.mlir.constant(1 : i32) : i32 + %24 = llvm.mlir.constant(0 : i32) : i32 + %25 = llvm.mlir.constant(-1 : i32) : i32 + %26 = llvm.mlir.constant(-32 : i32) : i32 + %27 = llvm.mlir.undef : vector<8xi32> + %28 = llvm.mlir.constant(0 : i32) : i32 + %29 = llvm.insertelement %26, %27[%28 : i32] : vector<8xi32> + %30 = llvm.mlir.constant(1 : i32) : i32 + %31 = llvm.insertelement %25, %29[%30 : i32] : vector<8xi32> + %32 = llvm.mlir.constant(2 : i32) : i32 + %33 = llvm.insertelement %24, %31[%32 : i32] : vector<8xi32> + %34 = llvm.mlir.constant(3 : i32) : i32 + %35 = llvm.insertelement %23, %33[%34 : i32] : vector<8xi32> + %36 = llvm.mlir.constant(4 : i32) : i32 + %37 = llvm.insertelement %22, %35[%36 : i32] : vector<8xi32> + %38 = llvm.mlir.constant(5 : i32) : i32 + %39 = llvm.insertelement %21, %37[%38 : i32] : vector<8xi32> + %40 = llvm.mlir.constant(6 : i32) : i32 + %41 = llvm.insertelement %20, %39[%40 : i32] : vector<8xi32> + %42 = llvm.mlir.constant(7 : i32) : i32 + %43 = llvm.insertelement %19, %41[%42 : i32] : vector<8xi32> + %44 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %45 = llvm.shl %18, %44 : vector<8xi64> + %46 = llvm.lshr %45, %44 : vector<8xi64> + %47 = llvm.add %arg1, %43 : vector<8xi32> + %48 = llvm.and %46, %arg0 : vector<8xi64> + llvm.call @use8xi64(%44) : (vector<8xi64>) -> () + llvm.call @use8xi64(%45) : (vector<8xi64>) -> () + llvm.call @use8xi64(%46) : (vector<8xi64>) -> () + llvm.call @use8xi32(%47) : (vector<8xi32>) -> () + llvm.call @use8xi64(%48) : (vector<8xi64>) -> () + %49 = llvm.trunc %48 : vector<8xi64> to vector<8xi32> + %50 = llvm.shl %49, %47 : vector<8xi32> + llvm.return %50 : vector<8xi32> + } + llvm.func @n4_extrause(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(-32 : i32) : i32 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.shl %0, %2 : i64 + %4 = llvm.lshr %3, %2 : i64 + %5 = llvm.add %arg1, %1 : i32 + %6 = llvm.and %4, %arg0 : i64 + llvm.call @use64(%2) : (i64) -> () + llvm.call @use64(%3) : (i64) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use64(%6) : (i64) -> () + %7 = llvm.trunc %6 : i64 to i32 + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.shl %7, %5 : i32 + llvm.return %8 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-e.ll.mlir b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-e.ll.mlir new file mode 100644 index 000000000..9a42e1d25 --- /dev/null +++ b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-e.ll.mlir @@ -0,0 +1,119 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @t0_basic(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-32 : i32) : i32 + %1 = llvm.zext %arg1 : i32 to i64 + %2 = llvm.shl %arg0, %1 : i64 + %3 = llvm.add %arg1, %0 : i32 + %4 = llvm.lshr %2, %1 : i64 + llvm.call @use64(%1) : (i64) -> () + llvm.call @use64(%2) : (i64) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.shl %5, %3 : i32 + llvm.return %6 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @use8xi64(vector<8xi64>) + llvm.func @t1_vec_splat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-32> : vector<8xi32>) : vector<8xi32> + %1 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %2 = llvm.shl %arg0, %1 : vector<8xi64> + %3 = llvm.add %arg1, %0 : vector<8xi32> + %4 = llvm.lshr %2, %1 : vector<8xi64> + llvm.call @use8xi64(%1) : (vector<8xi64>) -> () + llvm.call @use8xi64(%2) : (vector<8xi64>) -> () + llvm.call @use8xi32(%3) : (vector<8xi32>) -> () + llvm.call @use8xi64(%4) : (vector<8xi64>) -> () + %5 = llvm.trunc %4 : vector<8xi64> to vector<8xi32> + %6 = llvm.shl %5, %3 : vector<8xi32> + llvm.return %6 : vector<8xi32> + } + llvm.func @t2_vec_splat_undef(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-32 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<8xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi32> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi32> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi32> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi32> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi32> + %19 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %20 = llvm.shl %arg0, %19 : vector<8xi64> + %21 = llvm.add %arg1, %18 : vector<8xi32> + %22 = llvm.lshr %20, %19 : vector<8xi64> + llvm.call @use8xi64(%19) : (vector<8xi64>) -> () + llvm.call @use8xi64(%20) : (vector<8xi64>) -> () + llvm.call @use8xi32(%21) : (vector<8xi32>) -> () + llvm.call @use8xi64(%22) : (vector<8xi64>) -> () + %23 = llvm.trunc %22 : vector<8xi64> to vector<8xi32> + %24 = llvm.shl %23, %21 : vector<8xi32> + llvm.return %24 : vector<8xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.mlir.constant(31 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(-1 : i32) : i32 + %7 = llvm.mlir.constant(-32 : i32) : i32 + %8 = llvm.mlir.undef : vector<8xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<8xi32> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %6, %10[%11 : i32] : vector<8xi32> + %13 = llvm.mlir.constant(2 : i32) : i32 + %14 = llvm.insertelement %5, %12[%13 : i32] : vector<8xi32> + %15 = llvm.mlir.constant(3 : i32) : i32 + %16 = llvm.insertelement %4, %14[%15 : i32] : vector<8xi32> + %17 = llvm.mlir.constant(4 : i32) : i32 + %18 = llvm.insertelement %3, %16[%17 : i32] : vector<8xi32> + %19 = llvm.mlir.constant(5 : i32) : i32 + %20 = llvm.insertelement %2, %18[%19 : i32] : vector<8xi32> + %21 = llvm.mlir.constant(6 : i32) : i32 + %22 = llvm.insertelement %1, %20[%21 : i32] : vector<8xi32> + %23 = llvm.mlir.constant(7 : i32) : i32 + %24 = llvm.insertelement %0, %22[%23 : i32] : vector<8xi32> + %25 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %26 = llvm.shl %arg0, %25 : vector<8xi64> + %27 = llvm.add %arg1, %24 : vector<8xi32> + %28 = llvm.lshr %26, %25 : vector<8xi64> + llvm.call @use8xi64(%25) : (vector<8xi64>) -> () + llvm.call @use8xi64(%26) : (vector<8xi64>) -> () + llvm.call @use8xi32(%27) : (vector<8xi32>) -> () + llvm.call @use8xi64(%28) : (vector<8xi64>) -> () + %29 = llvm.trunc %28 : vector<8xi64> to vector<8xi32> + %30 = llvm.shl %29, %27 : vector<8xi32> + llvm.return %30 : vector<8xi32> + } + llvm.func @n4_extrause(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-32 : i32) : i32 + %1 = llvm.zext %arg1 : i32 to i64 + %2 = llvm.shl %arg0, %1 : i64 + %3 = llvm.add %arg1, %0 : i32 + %4 = llvm.lshr %2, %1 : i64 + llvm.call @use64(%1) : (i64) -> () + llvm.call @use64(%2) : (i64) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.shl %5, %3 : i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-f.ll.mlir b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-f.ll.mlir new file mode 100644 index 000000000..58e2d50b3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-f.ll.mlir @@ -0,0 +1,132 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @t0_basic(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-32 : i32) : i32 + %1 = llvm.zext %arg1 : i32 to i64 + %2 = llvm.shl %arg0, %1 : i64 + %3 = llvm.add %arg1, %0 : i32 + %4 = llvm.ashr %2, %1 : i64 + llvm.call @use64(%1) : (i64) -> () + llvm.call @use64(%2) : (i64) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.shl %5, %3 : i32 + llvm.return %6 : i32 + } + llvm.func @use8xi32(vector<8xi32>) + llvm.func @use8xi64(vector<8xi64>) + llvm.func @t1_vec_splat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(dense<-32> : vector<8xi32>) : vector<8xi32> + %1 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %2 = llvm.shl %arg0, %1 : vector<8xi64> + %3 = llvm.add %arg1, %0 : vector<8xi32> + %4 = llvm.ashr %2, %1 : vector<8xi64> + llvm.call @use8xi64(%1) : (vector<8xi64>) -> () + llvm.call @use8xi64(%2) : (vector<8xi64>) -> () + llvm.call @use8xi32(%3) : (vector<8xi32>) -> () + llvm.call @use8xi64(%4) : (vector<8xi64>) -> () + %5 = llvm.trunc %4 : vector<8xi64> to vector<8xi32> + %6 = llvm.shl %5, %3 : vector<8xi32> + llvm.return %6 : vector<8xi32> + } + llvm.func @t2_vec_splat_undef(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(-32 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<8xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<8xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<8xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<8xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<8xi32> + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<8xi32> + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %0, %12[%13 : i32] : vector<8xi32> + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<8xi32> + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<8xi32> + %19 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %20 = llvm.shl %arg0, %19 : vector<8xi64> + %21 = llvm.add %arg1, %18 : vector<8xi32> + %22 = llvm.ashr %20, %19 : vector<8xi64> + llvm.call @use8xi64(%19) : (vector<8xi64>) -> () + llvm.call @use8xi64(%20) : (vector<8xi64>) -> () + llvm.call @use8xi32(%21) : (vector<8xi32>) -> () + llvm.call @use8xi64(%22) : (vector<8xi64>) -> () + %23 = llvm.trunc %22 : vector<8xi64> to vector<8xi32> + %24 = llvm.shl %23, %21 : vector<8xi32> + llvm.return %24 : vector<8xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<8xi64>, %arg1: vector<8xi32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.mlir.constant(31 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(-1 : i32) : i32 + %7 = llvm.mlir.constant(-32 : i32) : i32 + %8 = llvm.mlir.undef : vector<8xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<8xi32> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %6, %10[%11 : i32] : vector<8xi32> + %13 = llvm.mlir.constant(2 : i32) : i32 + %14 = llvm.insertelement %5, %12[%13 : i32] : vector<8xi32> + %15 = llvm.mlir.constant(3 : i32) : i32 + %16 = llvm.insertelement %4, %14[%15 : i32] : vector<8xi32> + %17 = llvm.mlir.constant(4 : i32) : i32 + %18 = llvm.insertelement %3, %16[%17 : i32] : vector<8xi32> + %19 = llvm.mlir.constant(5 : i32) : i32 + %20 = llvm.insertelement %2, %18[%19 : i32] : vector<8xi32> + %21 = llvm.mlir.constant(6 : i32) : i32 + %22 = llvm.insertelement %1, %20[%21 : i32] : vector<8xi32> + %23 = llvm.mlir.constant(7 : i32) : i32 + %24 = llvm.insertelement %0, %22[%23 : i32] : vector<8xi32> + %25 = llvm.zext %arg1 : vector<8xi32> to vector<8xi64> + %26 = llvm.shl %arg0, %25 : vector<8xi64> + %27 = llvm.add %arg1, %24 : vector<8xi32> + %28 = llvm.ashr %26, %25 : vector<8xi64> + llvm.call @use8xi64(%25) : (vector<8xi64>) -> () + llvm.call @use8xi64(%26) : (vector<8xi64>) -> () + llvm.call @use8xi32(%27) : (vector<8xi32>) -> () + llvm.call @use8xi64(%28) : (vector<8xi64>) -> () + %29 = llvm.trunc %28 : vector<8xi64> to vector<8xi32> + %30 = llvm.shl %29, %27 : vector<8xi32> + llvm.return %30 : vector<8xi32> + } + llvm.func @n4_extrause(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-32 : i32) : i32 + %1 = llvm.zext %arg1 : i32 to i64 + %2 = llvm.shl %arg0, %1 : i64 + %3 = llvm.add %arg1, %0 : i32 + %4 = llvm.ashr %2, %1 : i64 + llvm.call @use64(%1) : (i64) -> () + llvm.call @use64(%2) : (i64) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.shl %5, %3 : i32 + llvm.return %6 : i32 + } + llvm.func @n5_mask(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.zext %arg1 : i32 to i64 + %2 = llvm.shl %arg0, %1 : i64 + %3 = llvm.add %arg1, %0 : i32 + llvm.call @use64(%1) : (i64) -> () + llvm.call @use64(%2) : (i64) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.ashr %2, %1 : i64 + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.shl %5, %3 : i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-pr49778.ll.mlir b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-pr49778.ll.mlir index cee091f2c..5beb9e414 100644 --- a/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-pr49778.ll.mlir +++ b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-pr49778.ll.mlir @@ -1,13 +1,11 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i1) -> i32 - %2 = "llvm.shl"(%0, %1) : (i32, i32) -> i32 - %3 = "llvm.xor"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.and"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.shl"(%4, %1) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "src", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @src(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.shl %0, %1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.shl %4, %1 : i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-a.ll.mlir b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-a.ll.mlir new file mode 100644 index 000000000..4d1756e18 --- /dev/null +++ b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-a.ll.mlir @@ -0,0 +1,265 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @t0_basic(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.add %3, %1 overflow : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @t1_bigger_shift(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(33 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.add %3, %1 overflow : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @t2_bigger_mask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.add %arg1, %0 : i32 + %4 = llvm.shl %0, %3 : i32 + %5 = llvm.add %4, %1 overflow : i32 + %6 = llvm.and %5, %arg0 : i32 + %7 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.shl %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @use3xi32(vector<3xi32>) + llvm.func @t3_vec_splat(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<3xi32>) : vector<3xi32> + %2 = llvm.mlir.constant(dense<1> : vector<3xi32>) : vector<3xi32> + %3 = llvm.mlir.constant(dense<-1> : vector<3xi32>) : vector<3xi32> + %4 = llvm.mlir.constant(dense<32> : vector<3xi32>) : vector<3xi32> + %5 = llvm.add %arg1, %1 : vector<3xi32> + %6 = llvm.shl %2, %5 : vector<3xi32> + %7 = llvm.add %6, %3 overflow : vector<3xi32> + %8 = llvm.and %7, %arg0 : vector<3xi32> + %9 = llvm.sub %4, %arg1 : vector<3xi32> + llvm.call @use3xi32(%5) : (vector<3xi32>) -> () + llvm.call @use3xi32(%6) : (vector<3xi32>) -> () + llvm.call @use3xi32(%7) : (vector<3xi32>) -> () + llvm.call @use3xi32(%8) : (vector<3xi32>) -> () + llvm.call @use3xi32(%9) : (vector<3xi32>) -> () + %10 = llvm.shl %8, %9 : vector<3xi32> + llvm.return %10 : vector<3xi32> + } + llvm.func @t4_vec_nonsplat(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<[-1, 0, 1]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<1> : vector<3xi32>) : vector<3xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<3xi32>) : vector<3xi32> + %3 = llvm.mlir.constant(dense<[33, 32, 32]> : vector<3xi32>) : vector<3xi32> + %4 = llvm.add %arg1, %0 : vector<3xi32> + %5 = llvm.shl %1, %4 : vector<3xi32> + %6 = llvm.add %5, %2 overflow : vector<3xi32> + %7 = llvm.and %6, %arg0 : vector<3xi32> + %8 = llvm.sub %3, %arg1 : vector<3xi32> + llvm.call @use3xi32(%4) : (vector<3xi32>) -> () + llvm.call @use3xi32(%5) : (vector<3xi32>) -> () + llvm.call @use3xi32(%6) : (vector<3xi32>) -> () + llvm.call @use3xi32(%7) : (vector<3xi32>) -> () + llvm.call @use3xi32(%8) : (vector<3xi32>) -> () + %9 = llvm.shl %7, %8 : vector<3xi32> + llvm.return %9 : vector<3xi32> + } + llvm.func @t5_vec_poison(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.mlir.constant(-1 : i32) : i32 + %18 = llvm.mlir.undef : vector<3xi32> + %19 = llvm.mlir.constant(0 : i32) : i32 + %20 = llvm.insertelement %17, %18[%19 : i32] : vector<3xi32> + %21 = llvm.mlir.constant(1 : i32) : i32 + %22 = llvm.insertelement %1, %20[%21 : i32] : vector<3xi32> + %23 = llvm.mlir.constant(2 : i32) : i32 + %24 = llvm.insertelement %17, %22[%23 : i32] : vector<3xi32> + %25 = llvm.mlir.constant(32 : i32) : i32 + %26 = llvm.mlir.undef : vector<3xi32> + %27 = llvm.mlir.constant(0 : i32) : i32 + %28 = llvm.insertelement %25, %26[%27 : i32] : vector<3xi32> + %29 = llvm.mlir.constant(1 : i32) : i32 + %30 = llvm.insertelement %1, %28[%29 : i32] : vector<3xi32> + %31 = llvm.mlir.constant(2 : i32) : i32 + %32 = llvm.insertelement %25, %30[%31 : i32] : vector<3xi32> + %33 = llvm.add %arg1, %8 : vector<3xi32> + %34 = llvm.shl %16, %33 : vector<3xi32> + %35 = llvm.add %34, %24 overflow : vector<3xi32> + %36 = llvm.and %35, %arg0 : vector<3xi32> + %37 = llvm.sub %32, %arg1 : vector<3xi32> + llvm.call @use3xi32(%33) : (vector<3xi32>) -> () + llvm.call @use3xi32(%34) : (vector<3xi32>) -> () + llvm.call @use3xi32(%35) : (vector<3xi32>) -> () + llvm.call @use3xi32(%36) : (vector<3xi32>) -> () + llvm.call @use3xi32(%37) : (vector<3xi32>) -> () + %38 = llvm.shl %36, %37 : vector<3xi32> + llvm.return %38 : vector<3xi32> + } + llvm.func @gen32() -> i32 + llvm.func @t6_commutativity0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.call @gen32() : () -> i32 + %4 = llvm.shl %0, %arg0 : i32 + %5 = llvm.add %4, %1 overflow : i32 + %6 = llvm.and %3, %5 : i32 + %7 = llvm.sub %2, %arg0 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.shl %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @t7_commutativity1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.add %3, %1 overflow : i32 + %5 = llvm.shl %0, %arg1 : i32 + %6 = llvm.add %5, %1 overflow : i32 + %7 = llvm.and %6, %4 : i32 + %8 = llvm.sub %2, %arg0 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.shl %7, %8 : i32 + llvm.return %9 : i32 + } + llvm.func @t8_commutativity2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.add %3, %1 overflow : i32 + %5 = llvm.shl %0, %arg1 : i32 + %6 = llvm.add %5, %1 overflow : i32 + %7 = llvm.and %6, %4 : i32 + %8 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.shl %7, %8 : i32 + llvm.return %9 : i32 + } + llvm.func @t9_nuw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.add %3, %1 overflow : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 overflow : i32 + llvm.return %7 : i32 + } + llvm.func @t10_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.add %3, %1 overflow : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 overflow : i32 + llvm.return %7 : i32 + } + llvm.func @t11_nuw_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.add %3, %1 overflow : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 overflow : i32 + llvm.return %7 : i32 + } + llvm.func @n12_not_minus_one(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.add %3, %1 overflow : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @n13_not_minus_one(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.add %3, %1 overflow : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-b.ll.mlir b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-b.ll.mlir new file mode 100644 index 000000000..cd25695d9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-b.ll.mlir @@ -0,0 +1,232 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @t0_basic(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.and %3, %arg0 : i32 + %5 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.shl %4, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @t1_bigger_shift(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(33 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.and %3, %arg0 : i32 + %5 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.shl %4, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @t2_bigger_mask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.add %arg1, %0 : i32 + %4 = llvm.shl %1, %3 : i32 + %5 = llvm.xor %4, %1 : i32 + %6 = llvm.and %5, %arg0 : i32 + %7 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.shl %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @use3xi32(vector<3xi32>) + llvm.func @t3_vec_splat(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<3xi32>) : vector<3xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<3xi32>) : vector<3xi32> + %3 = llvm.mlir.constant(dense<32> : vector<3xi32>) : vector<3xi32> + %4 = llvm.add %arg1, %1 : vector<3xi32> + %5 = llvm.shl %2, %4 : vector<3xi32> + %6 = llvm.xor %5, %2 : vector<3xi32> + %7 = llvm.and %6, %arg0 : vector<3xi32> + %8 = llvm.sub %3, %arg1 : vector<3xi32> + llvm.call @use3xi32(%4) : (vector<3xi32>) -> () + llvm.call @use3xi32(%5) : (vector<3xi32>) -> () + llvm.call @use3xi32(%6) : (vector<3xi32>) -> () + llvm.call @use3xi32(%7) : (vector<3xi32>) -> () + llvm.call @use3xi32(%8) : (vector<3xi32>) -> () + %9 = llvm.shl %7, %8 : vector<3xi32> + llvm.return %9 : vector<3xi32> + } + llvm.func @t4_vec_nonsplat(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<[-1, 0, 1]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<3xi32>) : vector<3xi32> + %2 = llvm.mlir.constant(dense<[33, 32, 32]> : vector<3xi32>) : vector<3xi32> + %3 = llvm.add %arg1, %0 : vector<3xi32> + %4 = llvm.shl %1, %3 : vector<3xi32> + %5 = llvm.xor %4, %1 : vector<3xi32> + %6 = llvm.and %5, %arg0 : vector<3xi32> + %7 = llvm.sub %2, %arg1 : vector<3xi32> + llvm.call @use3xi32(%3) : (vector<3xi32>) -> () + llvm.call @use3xi32(%4) : (vector<3xi32>) -> () + llvm.call @use3xi32(%5) : (vector<3xi32>) -> () + llvm.call @use3xi32(%6) : (vector<3xi32>) -> () + llvm.call @use3xi32(%7) : (vector<3xi32>) -> () + %8 = llvm.shl %6, %7 : vector<3xi32> + llvm.return %8 : vector<3xi32> + } + llvm.func @t5_vec_poison(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(-1 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.mlir.constant(32 : i32) : i32 + %18 = llvm.mlir.undef : vector<3xi32> + %19 = llvm.mlir.constant(0 : i32) : i32 + %20 = llvm.insertelement %17, %18[%19 : i32] : vector<3xi32> + %21 = llvm.mlir.constant(1 : i32) : i32 + %22 = llvm.insertelement %1, %20[%21 : i32] : vector<3xi32> + %23 = llvm.mlir.constant(2 : i32) : i32 + %24 = llvm.insertelement %17, %22[%23 : i32] : vector<3xi32> + %25 = llvm.add %arg1, %8 : vector<3xi32> + %26 = llvm.shl %16, %25 : vector<3xi32> + %27 = llvm.xor %26, %16 : vector<3xi32> + %28 = llvm.and %27, %arg0 : vector<3xi32> + %29 = llvm.sub %24, %arg1 : vector<3xi32> + llvm.call @use3xi32(%25) : (vector<3xi32>) -> () + llvm.call @use3xi32(%26) : (vector<3xi32>) -> () + llvm.call @use3xi32(%27) : (vector<3xi32>) -> () + llvm.call @use3xi32(%28) : (vector<3xi32>) -> () + llvm.call @use3xi32(%29) : (vector<3xi32>) -> () + %30 = llvm.shl %28, %29 : vector<3xi32> + llvm.return %30 : vector<3xi32> + } + llvm.func @gen32() -> i32 + llvm.func @t6_commutativity0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.call @gen32() : () -> i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.and %2, %4 : i32 + %6 = llvm.sub %1, %arg0 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @t7_commutativity1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.shl %0, %arg1 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %5, %3 : i32 + %7 = llvm.sub %1, %arg0 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.shl %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @t8_commutativity2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.shl %0, %arg1 : i32 + %5 = llvm.xor %4, %0 : i32 + %6 = llvm.and %5, %3 : i32 + %7 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.shl %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @t9_nuw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.and %3, %arg0 : i32 + %5 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.shl %4, %5 overflow : i32 + llvm.return %6 : i32 + } + llvm.func @t10_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.and %3, %arg0 : i32 + %5 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.shl %4, %5 overflow : i32 + llvm.return %6 : i32 + } + llvm.func @t11_nuw_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.and %3, %arg0 : i32 + %5 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.shl %4, %5 overflow : i32 + llvm.return %6 : i32 + } + llvm.func @n12_not_minus_one(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.and %4, %arg0 : i32 + %6 = llvm.sub %2, %arg1 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-c.ll.mlir b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-c.ll.mlir new file mode 100644 index 000000000..918f84644 --- /dev/null +++ b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-c.ll.mlir @@ -0,0 +1,156 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @t0_basic(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.lshr %0, %arg1 : i32 + %2 = llvm.and %1, %arg0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @t1_bigger_shift(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.lshr %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.add %arg1, %1 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.shl %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @use3xi32(vector<3xi32>) + llvm.func @t2_vec_splat(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<1> : vector<3xi32>) : vector<3xi32> + %2 = llvm.lshr %0, %arg1 : vector<3xi32> + %3 = llvm.and %2, %arg0 : vector<3xi32> + %4 = llvm.add %arg1, %1 : vector<3xi32> + llvm.call @use3xi32(%2) : (vector<3xi32>) -> () + llvm.call @use3xi32(%3) : (vector<3xi32>) -> () + llvm.call @use3xi32(%4) : (vector<3xi32>) -> () + %5 = llvm.shl %3, %4 : vector<3xi32> + llvm.return %5 : vector<3xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<[1, 0, 2]> : vector<3xi32>) : vector<3xi32> + %2 = llvm.lshr %0, %arg1 : vector<3xi32> + %3 = llvm.and %2, %arg0 : vector<3xi32> + %4 = llvm.add %arg1, %1 : vector<3xi32> + llvm.call @use3xi32(%2) : (vector<3xi32>) -> () + llvm.call @use3xi32(%3) : (vector<3xi32>) -> () + llvm.call @use3xi32(%4) : (vector<3xi32>) -> () + %5 = llvm.shl %3, %4 : vector<3xi32> + llvm.return %5 : vector<3xi32> + } + llvm.func @t4_vec_poison(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.lshr %8, %arg1 : vector<3xi32> + %18 = llvm.and %17, %arg0 : vector<3xi32> + %19 = llvm.add %arg1, %16 : vector<3xi32> + llvm.call @use3xi32(%17) : (vector<3xi32>) -> () + llvm.call @use3xi32(%18) : (vector<3xi32>) -> () + llvm.call @use3xi32(%19) : (vector<3xi32>) -> () + %20 = llvm.shl %18, %19 : vector<3xi32> + llvm.return %20 : vector<3xi32> + } + llvm.func @gen32() -> i32 + llvm.func @t5_commutativity0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.lshr %0, %arg0 : i32 + %3 = llvm.and %1, %2 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %3, %arg0 : i32 + llvm.return %4 : i32 + } + llvm.func @t6_commutativity1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.lshr %0, %arg0 : i32 + %2 = llvm.lshr %0, %arg1 : i32 + %3 = llvm.and %1, %2 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %3, %arg0 : i32 + llvm.return %4 : i32 + } + llvm.func @t7_commutativity2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.lshr %0, %arg0 : i32 + %2 = llvm.lshr %0, %arg1 : i32 + %3 = llvm.and %1, %2 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %3, %arg1 : i32 + llvm.return %4 : i32 + } + llvm.func @t8_nuw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.lshr %0, %arg1 : i32 + %2 = llvm.and %1, %arg0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %2, %arg1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @t9_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.lshr %0, %arg1 : i32 + %2 = llvm.and %1, %arg0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %2, %arg1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @t10_nuw_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.lshr %0, %arg1 : i32 + %2 = llvm.and %1, %arg0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %2, %arg1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @t11_assume_uge(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "uge" %arg2, %arg1 : i32 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.lshr %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %3, %arg2 : i32 + llvm.return %4 : i32 + } + llvm.func @n12_not_minus_one(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.lshr %0, %arg1 : i32 + %2 = llvm.and %1, %arg0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %2, %arg1 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-d.ll.mlir b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-d.ll.mlir new file mode 100644 index 000000000..ce8582ebc --- /dev/null +++ b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-d.ll.mlir @@ -0,0 +1,195 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @t0_basic(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %3, %arg1 : i32 + llvm.return %4 : i32 + } + llvm.func @t1_bigger_shift(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.lshr %2, %arg1 : i32 + %4 = llvm.and %3, %arg0 : i32 + %5 = llvm.add %arg1, %1 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.shl %4, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @use3xi32(vector<3xi32>) + llvm.func @t2_vec_splat(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<1> : vector<3xi32>) : vector<3xi32> + %2 = llvm.shl %0, %arg1 : vector<3xi32> + %3 = llvm.lshr %2, %arg1 : vector<3xi32> + %4 = llvm.and %3, %arg0 : vector<3xi32> + %5 = llvm.add %arg1, %1 : vector<3xi32> + llvm.call @use3xi32(%2) : (vector<3xi32>) -> () + llvm.call @use3xi32(%3) : (vector<3xi32>) -> () + llvm.call @use3xi32(%4) : (vector<3xi32>) -> () + llvm.call @use3xi32(%5) : (vector<3xi32>) -> () + %6 = llvm.shl %4, %5 : vector<3xi32> + llvm.return %6 : vector<3xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<[1, 0, 2]> : vector<3xi32>) : vector<3xi32> + %2 = llvm.shl %0, %arg1 : vector<3xi32> + %3 = llvm.lshr %2, %arg1 : vector<3xi32> + %4 = llvm.and %3, %arg0 : vector<3xi32> + %5 = llvm.add %arg1, %1 : vector<3xi32> + llvm.call @use3xi32(%2) : (vector<3xi32>) -> () + llvm.call @use3xi32(%3) : (vector<3xi32>) -> () + llvm.call @use3xi32(%4) : (vector<3xi32>) -> () + llvm.call @use3xi32(%5) : (vector<3xi32>) -> () + %6 = llvm.shl %4, %5 : vector<3xi32> + llvm.return %6 : vector<3xi32> + } + llvm.func @t4_vec_poison(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.shl %8, %arg1 : vector<3xi32> + %18 = llvm.lshr %17, %arg1 : vector<3xi32> + %19 = llvm.and %18, %arg0 : vector<3xi32> + %20 = llvm.add %arg1, %16 : vector<3xi32> + llvm.call @use3xi32(%17) : (vector<3xi32>) -> () + llvm.call @use3xi32(%18) : (vector<3xi32>) -> () + llvm.call @use3xi32(%19) : (vector<3xi32>) -> () + llvm.call @use3xi32(%20) : (vector<3xi32>) -> () + %21 = llvm.shl %19, %20 : vector<3xi32> + llvm.return %21 : vector<3xi32> + } + llvm.func @gen32() -> i32 + llvm.func @t5_commutativity0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.lshr %2, %arg0 : i32 + %4 = llvm.and %1, %3 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.shl %4, %arg0 : i32 + llvm.return %5 : i32 + } + llvm.func @t6_commutativity1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %0, %arg0 : i32 + %2 = llvm.lshr %1, %arg0 : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.lshr %1, %arg1 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.shl %5, %arg0 : i32 + llvm.return %6 : i32 + } + llvm.func @t7_commutativity2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %0, %arg0 : i32 + %2 = llvm.lshr %1, %arg0 : i32 + %3 = llvm.shl %0, %arg1 : i32 + %4 = llvm.lshr %1, %arg1 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.shl %5, %arg1 : i32 + llvm.return %6 : i32 + } + llvm.func @t8_nuw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %3, %arg1 overflow : i32 + llvm.return %4 : i32 + } + llvm.func @t9_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %3, %arg1 overflow : i32 + llvm.return %4 : i32 + } + llvm.func @t10_nuw_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %3, %arg1 overflow : i32 + llvm.return %4 : i32 + } + llvm.func @t11_assume_uge(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "uge" %arg2, %arg1 : i32 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.lshr %2, %arg1 : i32 + %4 = llvm.and %3, %arg0 : i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.shl %4, %arg2 : i32 + llvm.return %5 : i32 + } + llvm.func @n12_different_shamts0(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.lshr %0, %arg2 : i32 + %2 = llvm.and %1, %arg0 : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @n13_different_shamts1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.lshr %0, %arg2 : i32 + %2 = llvm.and %1, %arg0 : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %2, %arg2 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-e.ll.mlir b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-e.ll.mlir new file mode 100644 index 000000000..8caca5b94 --- /dev/null +++ b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-e.ll.mlir @@ -0,0 +1,114 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @t0_basic(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.lshr %0, %arg1 : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @t1_bigger_shift(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + %3 = llvm.add %arg1, %0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @use3xi32(vector<3xi32>) + llvm.func @t2_vec_splat(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<3xi32>) : vector<3xi32> + %1 = llvm.shl %arg0, %arg1 : vector<3xi32> + %2 = llvm.lshr %1, %arg1 : vector<3xi32> + %3 = llvm.add %arg1, %0 : vector<3xi32> + llvm.call @use3xi32(%1) : (vector<3xi32>) -> () + llvm.call @use3xi32(%2) : (vector<3xi32>) -> () + llvm.call @use3xi32(%3) : (vector<3xi32>) -> () + %4 = llvm.shl %2, %3 : vector<3xi32> + llvm.return %4 : vector<3xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<[1, 0, 2]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.shl %arg0, %arg1 : vector<3xi32> + %2 = llvm.lshr %1, %arg1 : vector<3xi32> + %3 = llvm.add %arg1, %0 : vector<3xi32> + llvm.call @use3xi32(%1) : (vector<3xi32>) -> () + llvm.call @use3xi32(%2) : (vector<3xi32>) -> () + llvm.call @use3xi32(%3) : (vector<3xi32>) -> () + %4 = llvm.shl %2, %3 : vector<3xi32> + llvm.return %4 : vector<3xi32> + } + llvm.func @t4_vec_undef(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.shl %arg0, %arg1 : vector<3xi32> + %10 = llvm.lshr %9, %arg1 : vector<3xi32> + %11 = llvm.add %arg1, %8 : vector<3xi32> + llvm.call @use3xi32(%9) : (vector<3xi32>) -> () + llvm.call @use3xi32(%10) : (vector<3xi32>) -> () + llvm.call @use3xi32(%11) : (vector<3xi32>) -> () + %12 = llvm.shl %10, %11 : vector<3xi32> + llvm.return %12 : vector<3xi32> + } + llvm.func @t5_nuw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.lshr %0, %arg1 : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %1, %arg1 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @t6_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.lshr %0, %arg1 : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %1, %arg1 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @t7_nuw_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.lshr %0, %arg1 : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %1, %arg1 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @t8_assume_uge(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.icmp "uge" %arg2, %arg1 : i32 + "llvm.intr.assume"(%0) : (i1) -> () + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.lshr %1, %arg1 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %2, %arg2 : i32 + llvm.return %3 : i32 + } + llvm.func @n9_different_shamts0(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.lshr %0, %arg2 : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @n10_different_shamts1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.lshr %0, %arg2 : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %1, %arg2 : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-f.ll.mlir b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-f.ll.mlir new file mode 100644 index 000000000..1b0fbc1b5 --- /dev/null +++ b/test/LLVMDialect/InstCombine/redundant-left-shift-input-masking-variant-f.ll.mlir @@ -0,0 +1,124 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @t0_basic(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.ashr %0, %arg1 : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @t1_bigger_shift(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.ashr %1, %arg1 : i32 + %3 = llvm.add %arg1, %0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @use3xi32(vector<3xi32>) + llvm.func @t2_vec_splat(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<3xi32>) : vector<3xi32> + %1 = llvm.shl %arg0, %arg1 : vector<3xi32> + %2 = llvm.ashr %1, %arg1 : vector<3xi32> + %3 = llvm.add %arg1, %0 : vector<3xi32> + llvm.call @use3xi32(%1) : (vector<3xi32>) -> () + llvm.call @use3xi32(%2) : (vector<3xi32>) -> () + llvm.call @use3xi32(%3) : (vector<3xi32>) -> () + %4 = llvm.shl %2, %3 : vector<3xi32> + llvm.return %4 : vector<3xi32> + } + llvm.func @t3_vec_nonsplat(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<[1, 0, 2]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.shl %arg0, %arg1 : vector<3xi32> + %2 = llvm.ashr %1, %arg1 : vector<3xi32> + %3 = llvm.add %arg1, %0 : vector<3xi32> + llvm.call @use3xi32(%1) : (vector<3xi32>) -> () + llvm.call @use3xi32(%2) : (vector<3xi32>) -> () + llvm.call @use3xi32(%3) : (vector<3xi32>) -> () + %4 = llvm.shl %2, %3 : vector<3xi32> + llvm.return %4 : vector<3xi32> + } + llvm.func @t4_vec_undef(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.shl %arg0, %arg1 : vector<3xi32> + %10 = llvm.ashr %9, %arg1 : vector<3xi32> + %11 = llvm.add %arg1, %8 : vector<3xi32> + llvm.call @use3xi32(%9) : (vector<3xi32>) -> () + llvm.call @use3xi32(%10) : (vector<3xi32>) -> () + llvm.call @use3xi32(%11) : (vector<3xi32>) -> () + %12 = llvm.shl %10, %11 : vector<3xi32> + llvm.return %12 : vector<3xi32> + } + llvm.func @t5_nuw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.ashr %0, %arg1 : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %1, %arg1 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @t6_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.ashr %0, %arg1 : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %1, %arg1 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @t7_nuw_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.ashr %0, %arg1 : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %1, %arg1 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @t8_assume_uge(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.icmp "uge" %arg2, %arg1 : i32 + "llvm.intr.assume"(%0) : (i1) -> () + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.ashr %1, %arg1 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %2, %arg2 : i32 + llvm.return %3 : i32 + } + llvm.func @n9_different_shamts0(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.ashr %0, %arg2 : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @n10_different_shamts1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.shl %arg0, %arg1 : i32 + %1 = llvm.ashr %0, %arg2 : i32 + llvm.call @use32(%0) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %1, %arg2 : i32 + llvm.return %2 : i32 + } + llvm.func @n11_shamt_is_smaller(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.ashr %1, %arg1 : i32 + %3 = llvm.add %arg1, %0 : i32 + llvm.call @use32(%1) : (i32) -> () + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %2, %3 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/redundant-right-shift-input-masking.ll.mlir b/test/LLVMDialect/InstCombine/redundant-right-shift-input-masking.ll.mlir new file mode 100644 index 000000000..1cd75f0fe --- /dev/null +++ b/test/LLVMDialect/InstCombine/redundant-right-shift-input-masking.ll.mlir @@ -0,0 +1,129 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_lshr(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.lshr %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @t1_sshr(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.ashr %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @t2_vec(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shl %0, %arg1 : vector<4xi32> + %2 = llvm.and %1, %arg0 : vector<4xi32> + %3 = llvm.lshr %2, %arg1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @t3_vec_undef(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.shl %10, %arg1 : vector<4xi32> + %12 = llvm.and %11, %arg0 : vector<4xi32> + %13 = llvm.lshr %12, %arg1 : vector<4xi32> + llvm.return %13 : vector<4xi32> + } + llvm.func @use32(i32) + llvm.func @t4_extrause0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.lshr %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @t5_extrause1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.and %1, %arg0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.lshr %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @t6_extrause2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.and %1, %arg0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.lshr %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @t7_noncanonical_lshr_lshr_extrauses(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.lshr %arg0, %arg1 : i32 + llvm.call @use32(%0) : (i32) -> () + %1 = llvm.shl %0, %arg1 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @t8_noncanonical_lshr_ashr_extrauses(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.lshr %arg0, %arg1 : i32 + llvm.call @use32(%0) : (i32) -> () + %1 = llvm.shl %0, %arg1 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.ashr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @t9_noncanonical_ashr_lshr_extrauses(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.ashr %arg0, %arg1 : i32 + llvm.call @use32(%0) : (i32) -> () + %1 = llvm.shl %0, %arg1 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.lshr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @t10_noncanonical_ashr_ashr_extrauses(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.ashr %arg0, %arg1 : i32 + llvm.call @use32(%0) : (i32) -> () + %1 = llvm.shl %0, %arg1 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.ashr %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @gen32() -> i32 + llvm.func @t11_commutative(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.and %1, %2 : i32 + %4 = llvm.lshr %3, %arg0 : i32 + llvm.return %4 : i32 + } + llvm.func @n12(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.lshr %2, %arg1 : i32 + llvm.return %3 : i32 + } + llvm.func @n13(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.lshr %2, %arg2 : i32 + llvm.return %3 : i32 + } + llvm.func @n14(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.lshr %arg0, %arg1 : i32 + llvm.call @use32(%0) : (i32) -> () + %1 = llvm.shl %0, %arg2 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.lshr %1, %arg3 : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/rem-mul-shl.ll.mlir b/test/LLVMDialect/InstCombine/rem-mul-shl.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/rem.ll.mlir b/test/LLVMDialect/InstCombine/rem.ll.mlir new file mode 100644 index 000000000..054a2ebda --- /dev/null +++ b/test/LLVMDialect/InstCombine/rem.ll.mlir @@ -0,0 +1,611 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @a(dense<0> : tensor<5xi16>) {addr_space = 0 : i32, alignment = 2 : i64} : !llvm.array<5 x i16> + llvm.mlir.global common @b(0 : i16) {addr_space = 0 : i32, alignment = 2 : i64} : i16 + llvm.func @use(i32) + llvm.func @rem_signed(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.sdiv %arg0, %arg1 : i64 + %1 = llvm.mul %0, %arg1 : i64 + %2 = llvm.sub %arg0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @rem_signed_vec(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.sdiv %arg0, %arg1 : vector<4xi32> + %1 = llvm.mul %0, %arg1 : vector<4xi32> + %2 = llvm.sub %arg0, %1 : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @rem_unsigned(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.udiv %arg0, %arg1 : i64 + %1 = llvm.mul %0, %arg1 : i64 + %2 = llvm.sub %arg0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @big_divisor(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-127 : i8) : i8 + %1 = llvm.urem %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @biggest_divisor(%arg0: i5) -> i5 { + %0 = llvm.mlir.constant(-1 : i5) : i5 + %1 = llvm.urem %arg0, %0 : i5 + llvm.return %1 : i5 + } + llvm.func @urem_with_sext_bool_divisor(%arg0: i1, %arg1: i8) -> i8 { + %0 = llvm.sext %arg0 : i1 to i8 + %1 = llvm.urem %arg1, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @urem_with_sext_bool_divisor_vec(%arg0: vector<2xi1>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.sext %arg0 : vector<2xi1> to vector<2xi8> + %1 = llvm.urem %arg1, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @big_divisor_vec(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-3 : i4) : i4 + %1 = llvm.mlir.constant(dense<-3> : vector<2xi4>) : vector<2xi4> + %2 = llvm.urem %arg0, %1 : vector<2xi4> + llvm.return %2 : vector<2xi4> + } + llvm.func @urem1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.udiv %arg0, %arg1 : i8 + %1 = llvm.mul %0, %arg1 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @srem1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.sdiv %arg0, %arg1 : i8 + %1 = llvm.mul %0, %arg1 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @urem2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.udiv %arg0, %arg1 : i8 + %1 = llvm.mul %0, %arg1 : i8 + %2 = llvm.sub %1, %arg0 : i8 + llvm.return %2 : i8 + } + llvm.func @urem3(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(-3 : i8) : i8 + %2 = llvm.udiv %arg0, %0 : i8 + %3 = llvm.mul %2, %1 : i8 + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @sdiv_mul_sdiv(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.sdiv %arg0, %arg1 : i32 + %1 = llvm.mul %0, %arg1 : i32 + %2 = llvm.sdiv %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @udiv_mul_udiv(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.udiv %arg0, %arg1 : i32 + %1 = llvm.mul %0, %arg1 : i32 + %2 = llvm.udiv %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @test1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.srem %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @test3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.urem %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @vec_power_of_2_constant_splat_divisor(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.urem %arg0, %0 : vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @weird_vec_power_of_2_constant_splat_divisor(%arg0: vector<2xi19>) -> vector<2xi19> { + %0 = llvm.mlir.constant(8 : i19) : i19 + %1 = llvm.mlir.constant(dense<8> : vector<2xi19>) : vector<2xi19> + %2 = llvm.urem %arg0, %1 : vector<2xi19> + llvm.return %2 : vector<2xi19> + } + llvm.func @test3a(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test3a_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.srem %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @test4(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.select %arg1, %0, %1 : i1, i32 + %3 = llvm.urem %arg0, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test5(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.shl %0, %1 : i32 + %3 = llvm.urem %arg0, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test6(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.srem %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @test7(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.srem %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test8(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.srem %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test9(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mul %arg0, %0 : i32 + %3 = llvm.urem %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test10(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(4 : i64) : i64 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.mul %2, %0 : i32 + %4 = llvm.sext %3 : i32 to i64 + %5 = llvm.urem %4, %1 : i64 + %6 = llvm.trunc %5 : i64 to i32 + llvm.return %6 : i32 + } + llvm.func @test11(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.mul %3, %1 : i32 + %5 = llvm.urem %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test12(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-4 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.srem %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test13(%arg0: i32) -> i32 { + %0 = llvm.srem %arg0, %arg0 : i32 + llvm.return %0 : i32 + } + llvm.func @test14(%arg0: i64, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.zext %1 : i32 to i64 + %3 = llvm.urem %arg0, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @test15(%arg0: i32, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.zext %1 : i32 to i64 + %3 = llvm.zext %arg0 : i32 to i64 + %4 = llvm.urem %3, %2 : i64 + llvm.return %4 : i64 + } + llvm.func @test16(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(11 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.lshr %arg1, %0 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.urem %arg0, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test17(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.urem %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @test18(%arg0: i16, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.mlir.constant(64 : i32) : i32 + %4 = llvm.and %arg0, %0 : i16 + %5 = llvm.icmp "ne" %4, %1 : i16 + %6 = llvm.select %5, %2, %3 : i1, i32 + %7 = llvm.urem %arg1, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @test19(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %0, %arg0 : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %1, %2 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.urem %arg1, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test19_commutative0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %0, %arg0 : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.urem %arg1, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test19_commutative1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %0, %arg0 : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %1, %2 : i32 + %4 = llvm.add %1, %3 : i32 + %5 = llvm.urem %arg1, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test19_commutative2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %0, %arg0 : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.add %1, %3 : i32 + %5 = llvm.urem %arg1, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test20(%arg0: vector<2xi64>, %arg1: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<[8, 9]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.constant(dense<[2, 3]> : vector<2xi64>) : vector<2xi64> + %3 = llvm.select %arg1, %0, %1 : vector<2xi1>, vector<2xi64> + %4 = llvm.urem %3, %2 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @test21(%arg0: i1, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %1 = llvm.load volatile %arg1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb2(%1 : i32) + ^bb2(%2: i32): // 2 preds: ^bb0, ^bb1 + %3 = llvm.srem %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @pr27968_0(%arg0: i1, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(4 : i64) : i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.mlir.constant(dense<0> : tensor<5xi16>) : !llvm.array<5 x i16> + %5 = llvm.mlir.addressof @a : !llvm.ptr + %6 = llvm.getelementptr inbounds %5[%2, %1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<5 x i16> + %7 = llvm.mlir.addressof @b : !llvm.ptr + %8 = llvm.mlir.constant(0 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %9 = llvm.load volatile %arg1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb2(%9 : i32) + ^bb2(%10: i32): // 2 preds: ^bb0, ^bb1 + %11 = llvm.icmp "eq" %6, %7 : !llvm.ptr + llvm.cond_br %11, ^bb3, ^bb4 + ^bb3: // pred: ^bb2 + %12 = llvm.zext %11 : i1 to i32 + %13 = llvm.srem %10, %12 : i32 + llvm.return %13 : i32 + ^bb4: // pred: ^bb2 + llvm.return %8 : i32 + } + llvm.func @pr27968_1(%arg0: i1, %arg1: i1, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-2147483648 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %3 = llvm.load volatile %arg2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb2(%3 : i32) + ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.cond_br %arg1, ^bb3, ^bb4 + ^bb3: // pred: ^bb2 + %5 = llvm.srem %4, %2 : i32 + llvm.return %5 : i32 + ^bb4: // pred: ^bb2 + llvm.return %1 : i32 + } + llvm.func @pr27968_2(%arg0: i1, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(4 : i64) : i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.mlir.constant(dense<0> : tensor<5xi16>) : !llvm.array<5 x i16> + %5 = llvm.mlir.addressof @a : !llvm.ptr + %6 = llvm.getelementptr inbounds %5[%2, %1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<5 x i16> + %7 = llvm.mlir.addressof @b : !llvm.ptr + %8 = llvm.mlir.constant(0 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %9 = llvm.load volatile %arg1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb2(%9 : i32) + ^bb2(%10: i32): // 2 preds: ^bb0, ^bb1 + %11 = llvm.icmp "eq" %6, %7 : !llvm.ptr + llvm.cond_br %11, ^bb3, ^bb4 + ^bb3: // pred: ^bb2 + %12 = llvm.zext %11 : i1 to i32 + %13 = llvm.urem %10, %12 : i32 + llvm.return %13 : i32 + ^bb4: // pred: ^bb2 + llvm.return %8 : i32 + } + llvm.func @pr27968_3(%arg0: i1, %arg1: i1, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-2147483648 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %3 = llvm.load volatile %arg2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.br ^bb2(%3 : i32) + ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.cond_br %arg1, ^bb3, ^bb4 + ^bb3: // pred: ^bb2 + %5 = llvm.urem %4, %2 : i32 + llvm.return %5 : i32 + ^bb4: // pred: ^bb2 + llvm.return %1 : i32 + } + llvm.func @test22(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.srem %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @test23(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<2147483647> : vector<2xi32>) : vector<2xi32> + %1 = llvm.and %arg0, %0 : vector<2xi32> + %2 = llvm.srem %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @test24(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.urem %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test24_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.urem %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @test25(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test25_vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.srem %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi1> + } + llvm.func @test26(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.srem %arg0, %2 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @test27(%arg0: i32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + llvm.store %2, %arg1 {alignment = 1 : i64} : i32, !llvm.ptr + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test28(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @positive_and_odd_eq(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @negative_and_odd_eq(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @positive_and_odd_ne(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @negative_and_odd_ne(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @PR34870(%arg0: i1, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.select %arg0, %arg2, %0 : i1, f64 + %2 = llvm.frem %arg1, %1 : f64 + llvm.return %2 : f64 + } + llvm.func @srem_constant_dividend_select_of_constants_divisor(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(-3 : i32) : i32 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.srem %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @srem_constant_dividend_select_of_constants_divisor_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(-3 : i32) : i32 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.srem %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @srem_constant_dividend_select_of_constants_divisor_0_arm(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.srem %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @srem_constant_dividend_select_divisor1(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.select %arg0, %arg1, %0 : i1, i32 + %3 = llvm.srem %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @srem_constant_dividend_select_divisor2(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.select %arg0, %0, %arg1 : i1, i32 + %3 = llvm.srem %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @srem_constant_dividend_select_of_constants_divisor_vec(%arg0: i1) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[12, -5]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-4, 4]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.select %arg0, %0, %1 : i1, vector<2xi8> + %4 = llvm.srem %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @srem_constant_dividend_select_of_constants_divisor_vec_ub1(%arg0: i1) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[0, -5]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-4, 4]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.select %arg0, %0, %1 : i1, vector<2xi8> + %4 = llvm.srem %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @srem_constant_dividend_select_of_constants_divisor_vec_ub2(%arg0: i1) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[12, -5]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-4, -1]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<[42, -128]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.select %arg0, %0, %1 : i1, vector<2xi8> + %4 = llvm.srem %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @srem_select_of_constants_divisor(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(-3 : i32) : i32 + %2 = llvm.select %arg0, %0, %1 : i1, i32 + %3 = llvm.srem %arg1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @urem_constant_dividend_select_of_constants_divisor(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(-3 : i32) : i32 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.urem %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @urem_constant_dividend_select_of_constants_divisor_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(-3 : i32) : i32 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.urem %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @urem_constant_dividend_select_of_constants_divisor_0_arm(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.urem %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @urem_constant_dividend_select_divisor1(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.select %arg0, %arg1, %0 : i1, i32 + %3 = llvm.urem %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @urem_constant_dividend_select_divisor2(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.select %arg0, %0, %arg1 : i1, i32 + %3 = llvm.urem %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @urem_constant_dividend_select_of_constants_divisor_vec(%arg0: i1) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[12, -5]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-4, 4]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.select %arg0, %0, %1 : i1, vector<2xi8> + %4 = llvm.urem %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @urem_constant_dividend_select_of_constants_divisor_vec_ub1(%arg0: i1) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[0, -5]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-4, 4]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.select %arg0, %0, %1 : i1, vector<2xi8> + %4 = llvm.urem %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @urem_constant_dividend_select_of_constants_divisor_vec_ub2(%arg0: i1) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[12, -5]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-4, -1]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<[42, -128]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.select %arg0, %0, %1 : i1, vector<2xi8> + %4 = llvm.urem %2, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @urem_select_of_constants_divisor(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(-3 : i32) : i32 + %2 = llvm.select %arg0, %0, %1 : i1, i32 + %3 = llvm.urem %arg1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @PR62401(%arg0: vector<2xi1>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.sext %arg0 : vector<2xi1> to vector<2xi32> + %1 = llvm.urem %arg1, %0 : vector<2xi32> + llvm.return %1 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/remove-loop-phi-multiply-by-zero.ll.mlir b/test/LLVMDialect/InstCombine/remove-loop-phi-multiply-by-zero.ll.mlir new file mode 100644 index 000000000..504eb21a4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/remove-loop-phi-multiply-by-zero.ll.mlir @@ -0,0 +1,204 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_mul_fast_flags(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(1000 : i64) : i64 + llvm.br ^bb1(%0, %1 : i64, f64) + ^bb1(%4: i64, %5: f64): // 2 preds: ^bb0, ^bb1 + %6 = llvm.getelementptr inbounds %arg0[%0, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<1000 x f64> + %7 = llvm.load %6 {alignment = 8 : i64} : !llvm.ptr -> f64 + %8 = llvm.fmul %5, %7 {fastmathFlags = #llvm.fastmath} : f64 + %9 = llvm.add %4, %2 : i64 + %10 = llvm.icmp "ult" %9, %3 : i64 + llvm.cond_br %10, ^bb1(%9, %8 : i64, f64), ^bb2(%8 : f64) + ^bb2(%11: f64): // pred: ^bb1 + llvm.return %11 : f64 + } + llvm.func @test_nsz_nnan_flags_enabled(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(1000 : i64) : i64 + llvm.br ^bb1(%0, %1 : i64, f64) + ^bb1(%4: i64, %5: f64): // 2 preds: ^bb0, ^bb1 + %6 = llvm.getelementptr inbounds %arg0[%0, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<1000 x f64> + %7 = llvm.load %6 {alignment = 8 : i64} : !llvm.ptr -> f64 + %8 = llvm.fmul %5, %7 {fastmathFlags = #llvm.fastmath} : f64 + %9 = llvm.add %4, %2 : i64 + %10 = llvm.icmp "ult" %9, %3 : i64 + llvm.cond_br %10, ^bb1(%9, %8 : i64, f64), ^bb2(%8 : f64) + ^bb2(%11: f64): // pred: ^bb1 + llvm.return %11 : f64 + } + llvm.func @test_nnan_flag_enabled(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(1000 : i64) : i64 + llvm.br ^bb1(%0, %1 : i64, f64) + ^bb1(%4: i64, %5: f64): // 2 preds: ^bb0, ^bb1 + %6 = llvm.getelementptr inbounds %arg0[%0, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<1000 x f64> + %7 = llvm.load %6 {alignment = 8 : i64} : !llvm.ptr -> f64 + %8 = llvm.fmul %5, %7 {fastmathFlags = #llvm.fastmath} : f64 + %9 = llvm.add %4, %2 : i64 + %10 = llvm.icmp "ult" %9, %3 : i64 + llvm.cond_br %10, ^bb1(%9, %8 : i64, f64), ^bb2(%8 : f64) + ^bb2(%11: f64): // pred: ^bb1 + llvm.return %11 : f64 + } + llvm.func @test_ninf_flag_enabled(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(1000 : i64) : i64 + llvm.br ^bb1(%0, %1 : i64, f64) + ^bb1(%4: i64, %5: f64): // 2 preds: ^bb0, ^bb1 + %6 = llvm.getelementptr inbounds %arg0[%0, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<1000 x f64> + %7 = llvm.load %6 {alignment = 8 : i64} : !llvm.ptr -> f64 + %8 = llvm.fmul %5, %7 {fastmathFlags = #llvm.fastmath} : f64 + %9 = llvm.add %4, %2 : i64 + %10 = llvm.icmp "ult" %9, %3 : i64 + llvm.cond_br %10, ^bb1(%9, %8 : i64, f64), ^bb2(%8 : f64) + ^bb2(%11: f64): // pred: ^bb1 + llvm.return %11 : f64 + } + llvm.func @test_nsz_flag_enabled(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(1000 : i64) : i64 + llvm.br ^bb1(%0, %1 : i64, f64) + ^bb1(%4: i64, %5: f64): // 2 preds: ^bb0, ^bb1 + %6 = llvm.getelementptr inbounds %arg0[%0, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<1000 x f64> + %7 = llvm.load %6 {alignment = 8 : i64} : !llvm.ptr -> f64 + %8 = llvm.fmul %5, %7 {fastmathFlags = #llvm.fastmath} : f64 + %9 = llvm.add %4, %2 : i64 + %10 = llvm.icmp "ult" %9, %3 : i64 + llvm.cond_br %10, ^bb1(%9, %8 : i64, f64), ^bb2(%8 : f64) + ^bb2(%11: f64): // pred: ^bb1 + llvm.return %11 : f64 + } + llvm.func @test_phi_initalise_to_non_zero(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(1000 : i64) : i64 + llvm.br ^bb1(%0, %1 : i64, f64) + ^bb1(%4: i64, %5: f64): // 2 preds: ^bb0, ^bb1 + %6 = llvm.getelementptr inbounds %arg0[%0, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<1000 x f64> + %7 = llvm.load %6 {alignment = 8 : i64} : !llvm.ptr -> f64 + %8 = llvm.fmul %5, %7 {fastmathFlags = #llvm.fastmath} : f64 + %9 = llvm.add %4, %2 : i64 + %10 = llvm.icmp "ult" %9, %3 : i64 + llvm.cond_br %10, ^bb1(%9, %8 : i64, f64), ^bb2(%8 : f64) + ^bb2(%11: f64): // pred: ^bb1 + llvm.return %11 : f64 + } + llvm.func @test_multiple_phi_operands(%arg0: !llvm.ptr, %arg1: i1) -> f64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(1000 : i64) : i64 + llvm.cond_br %arg1, ^bb2(%0, %1 : i64, f64), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%0, %1 : i64, f64) + ^bb2(%4: i64, %5: f64): // 3 preds: ^bb0, ^bb1, ^bb2 + %6 = llvm.getelementptr inbounds %arg0[%0, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<1000 x f64> + %7 = llvm.load %6 {alignment = 8 : i64} : !llvm.ptr -> f64 + %8 = llvm.fmul %5, %7 {fastmathFlags = #llvm.fastmath} : f64 + %9 = llvm.add %4, %2 : i64 + %10 = llvm.icmp "ult" %9, %3 : i64 + llvm.cond_br %10, ^bb2(%9, %8 : i64, f64), ^bb3(%8 : f64) + ^bb3(%11: f64): // pred: ^bb2 + llvm.return %11 : f64 + } + llvm.func @test_multiple_phi_operands_with_non_zero(%arg0: !llvm.ptr, %arg1: i1) -> f64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(1000 : i64) : i64 + llvm.cond_br %arg1, ^bb2(%0, %1 : i64, f64), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%0, %2 : i64, f64) + ^bb2(%5: i64, %6: f64): // 3 preds: ^bb0, ^bb1, ^bb2 + %7 = llvm.getelementptr inbounds %arg0[%0, %5] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<1000 x f64> + %8 = llvm.load %7 {alignment = 8 : i64} : !llvm.ptr -> f64 + %9 = llvm.fmul %6, %8 {fastmathFlags = #llvm.fastmath} : f64 + %10 = llvm.add %5, %3 : i64 + %11 = llvm.icmp "ult" %10, %4 : i64 + llvm.cond_br %11, ^bb2(%10, %9 : i64, f64), ^bb3(%9 : f64) + ^bb3(%12: f64): // pred: ^bb2 + llvm.return %12 : f64 + } + llvm.func @test_int_phi_operands(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(1000 : i64) : i64 + llvm.br ^bb1(%0, %1 : i64, i32) + ^bb1(%4: i64, %5: i32): // 2 preds: ^bb0, ^bb1 + %6 = llvm.getelementptr inbounds %arg0[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + %8 = llvm.mul %5, %7 overflow : i32 + %9 = llvm.add %4, %2 : i64 + %10 = llvm.icmp "ult" %9, %3 : i64 + llvm.cond_br %10, ^bb1(%9, %8 : i64, i32), ^bb2(%8 : i32) + ^bb2(%11: i32): // pred: ^bb1 + llvm.return %11 : i32 + } + llvm.func @test_int_phi_operands_initalise_to_non_zero(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(1000 : i64) : i64 + llvm.br ^bb1(%0, %1 : i64, i32) + ^bb1(%4: i64, %5: i32): // 2 preds: ^bb0, ^bb1 + %6 = llvm.getelementptr inbounds %arg0[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + %8 = llvm.mul %5, %7 : i32 + %9 = llvm.add %4, %2 : i64 + %10 = llvm.icmp "ult" %9, %3 : i64 + llvm.cond_br %10, ^bb1(%9, %8 : i64, i32), ^bb2(%8 : i32) + ^bb2(%11: i32): // pred: ^bb1 + llvm.return %11 : i32 + } + llvm.func @test_multiple_int_phi_operands(%arg0: !llvm.ptr, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(1000 : i64) : i64 + llvm.cond_br %arg1, ^bb2(%0, %1 : i64, i32), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%0, %1 : i64, i32) + ^bb2(%4: i64, %5: i32): // 3 preds: ^bb0, ^bb1, ^bb2 + %6 = llvm.getelementptr inbounds %arg0[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %7 = llvm.load %6 {alignment = 4 : i64} : !llvm.ptr -> i32 + %8 = llvm.mul %5, %7 : i32 + %9 = llvm.add %4, %2 : i64 + %10 = llvm.icmp "ult" %9, %3 : i64 + llvm.cond_br %10, ^bb2(%9, %8 : i64, i32), ^bb3(%8 : i32) + ^bb3(%11: i32): // pred: ^bb2 + llvm.return %11 : i32 + } + llvm.func @test_multiple_int_phi_operands_initalise_to_non_zero(%arg0: !llvm.ptr, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(1000 : i64) : i64 + llvm.cond_br %arg1, ^bb2(%0, %1 : i64, i32), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%0, %2 : i64, i32) + ^bb2(%5: i64, %6: i32): // 3 preds: ^bb0, ^bb1, ^bb2 + %7 = llvm.getelementptr inbounds %arg0[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %8 = llvm.load %7 {alignment = 4 : i64} : !llvm.ptr -> i32 + %9 = llvm.mul %6, %8 : i32 + %10 = llvm.add %5, %3 : i64 + %11 = llvm.icmp "ult" %10, %4 : i64 + llvm.cond_br %11, ^bb2(%10, %9 : i64, i32), ^bb3(%9 : i32) + ^bb3(%12: i32): // pred: ^bb2 + llvm.return %12 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/result-of-add-of-negative-is-non-zero-and-no-underflow.ll.mlir b/test/LLVMDialect/InstCombine/result-of-add-of-negative-is-non-zero-and-no-underflow.ll.mlir new file mode 100644 index 000000000..b56772a8f --- /dev/null +++ b/test/LLVMDialect/InstCombine/result-of-add-of-negative-is-non-zero-and-no-underflow.ll.mlir @@ -0,0 +1,261 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use1(i1) + llvm.func @t0_bad(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %0 : i8 + %3 = llvm.icmp "ult" %1, %arg0 : i8 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @t0_bad_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "ult" %2, %arg0 : i8 + %5 = llvm.select %3, %4, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "ult" %2, %arg0 : i8 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @t1_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.icmp "ult" %3, %arg0 : i8 + %6 = llvm.select %4, %5, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg1, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "ult" %2, %arg0 : i8 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @t2_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg1, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.icmp "ult" %3, %arg0 : i8 + %6 = llvm.select %4, %5, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t3_oneuse0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "ult" %2, %arg0 : i8 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @t3_oneuse0_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.icmp "ult" %3, %arg0 : i8 + %6 = llvm.select %4, %5, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t4_oneuse1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "ult" %2, %arg0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @t4_oneuse1_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.icmp "ult" %3, %arg0 : i8 + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.select %4, %5, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t5_oneuse2_bad(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "ult" %2, %arg0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @t5_oneuse2_bad_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.icmp "ult" %3, %arg0 : i8 + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.select %4, %5, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t6_commutativity0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "ult" %2, %arg0 : i8 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @t6_commutativity0_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.icmp "ult" %3, %arg0 : i8 + %6 = llvm.select %5, %4, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t7_commutativity1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "ugt" %arg0, %2 : i8 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @t7_commutativity1_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.icmp "ugt" %arg0, %3 : i8 + %6 = llvm.select %4, %5, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t7_commutativity3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "ugt" %arg0, %2 : i8 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @t7_commutativity3_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.icmp "ugt" %arg0, %3 : i8 + %6 = llvm.select %5, %4, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t8(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %0 : i8 + %4 = llvm.icmp "uge" %2, %arg0 : i8 + %5 = llvm.or %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @t8_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "eq" %3, %0 : i8 + %5 = llvm.icmp "uge" %3, %arg0 : i8 + %6 = llvm.select %4, %1, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t9(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "ult" %2, %arg1 : i8 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @t9_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ne" %3, %0 : i8 + %5 = llvm.icmp "ult" %3, %arg1 : i8 + %6 = llvm.select %4, %5, %1 : i1, i1 + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/result-of-add-of-negative-or-zero-is-non-zero-and-no-underflow.ll.mlir b/test/LLVMDialect/InstCombine/result-of-add-of-negative-or-zero-is-non-zero-and-no-underflow.ll.mlir new file mode 100644 index 000000000..43b495767 --- /dev/null +++ b/test/LLVMDialect/InstCombine/result-of-add-of-negative-or-zero-is-non-zero-and-no-underflow.ll.mlir @@ -0,0 +1,183 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use1(i1) + llvm.func @t0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %0 : i8 + %3 = llvm.icmp "ule" %1, %arg0 : i8 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @t0_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "ule" %2, %arg0 : i8 + %5 = llvm.select %3, %4, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t1_oneuse0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "ule" %1, %arg0 : i8 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @t1_oneuse0_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "ule" %2, %arg0 : i8 + %5 = llvm.select %3, %4, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t2_oneuse1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %0 : i8 + %3 = llvm.icmp "ule" %1, %arg0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @t2_oneuse1_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "ule" %2, %arg0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %3, %4, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @n3_oneuse2_bad(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "ule" %1, %arg0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @n3_oneuse2_bad_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "ule" %2, %arg0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %3, %4, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t4_commutativity0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %0 : i8 + %3 = llvm.icmp "ule" %1, %arg0 : i8 + %4 = llvm.and %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @t4_commutativity0_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "ule" %2, %arg0 : i8 + %5 = llvm.select %4, %3, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t5_commutativity1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %0 : i8 + %3 = llvm.icmp "uge" %arg0, %1 : i8 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @t5_commutativity1_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "uge" %arg0, %2 : i8 + %5 = llvm.select %3, %4, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t6_commutativity3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %0 : i8 + %3 = llvm.icmp "uge" %arg0, %1 : i8 + %4 = llvm.and %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @t6_commutativity3_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "uge" %arg0, %2 : i8 + %5 = llvm.select %4, %3, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t7(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "eq" %1, %0 : i8 + %3 = llvm.icmp "ugt" %1, %arg0 : i8 + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @t7_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %0 : i8 + %4 = llvm.icmp "ugt" %2, %arg0 : i8 + %5 = llvm.select %3, %1, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t8(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %0 : i8 + %3 = llvm.icmp "ule" %1, %arg1 : i8 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @t8_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "ule" %2, %arg1 : i8 + %5 = llvm.select %3, %4, %1 : i1, i1 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/result-of-usub-is-non-zero-and-no-overflow.ll.mlir b/test/LLVMDialect/InstCombine/result-of-usub-is-non-zero-and-no-overflow.ll.mlir new file mode 100644 index 000000000..974da4c8c --- /dev/null +++ b/test/LLVMDialect/InstCombine/result-of-usub-is-non-zero-and-no-overflow.ll.mlir @@ -0,0 +1,461 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use64(i64) + llvm.func @use1(i1) + llvm.func @useagg(!llvm.struct<(i8, i1)>) + llvm.func @t0_noncanonical_ignoreme(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ule" %1, %arg0 : i8 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "ne" %1, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.and %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @t0_noncanonical_ignoreme_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ule" %2, %arg0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "ne" %2, %0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %4, %3, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "uge" %arg0, %arg1 : i8 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "ne" %1, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.and %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @t1_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "uge" %arg0, %arg1 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "ne" %2, %0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %4, %3, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t1_strict(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ugt" %arg0, %arg1 : i8 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "ne" %1, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.and %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @t1_strict_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ugt" %arg0, %arg1 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "ne" %2, %0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %4, %3, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.call @useagg(%2) : (!llvm.struct<(i8, i1)>) -> () + %3 = llvm.extractvalue %2[0] : !llvm.struct<(i8, i1)> + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.extractvalue %2[1] : !llvm.struct<(i8, i1)> + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.xor %4, %0 : i1 + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.icmp "ne" %3, %1 : i8 + %7 = llvm.and %6, %5 : i1 + llvm.return %7 : i1 + } + llvm.func @t2_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(false) : i1 + %3 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.call @useagg(%3) : (!llvm.struct<(i8, i1)>) -> () + %4 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.xor %5, %0 : i1 + llvm.call @use1(%6) : (i1) -> () + %7 = llvm.icmp "ne" %4, %1 : i8 + %8 = llvm.select %7, %6, %2 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @t3_commutability0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ule" %arg1, %arg0 : i8 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "ne" %1, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.and %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @t3_commutability0_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ule" %arg1, %arg0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "ne" %2, %0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %4, %3, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t4_commutability1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "uge" %arg0, %arg1 : i8 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "ne" %1, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @t4_commutability1_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "uge" %arg0, %arg1 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "ne" %2, %0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %3, %4, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t5_commutability2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ule" %arg1, %arg0 : i8 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "ne" %1, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @t5_commutability2_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ule" %arg1, %arg0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "ne" %2, %0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %3, %4, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t6_commutability(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.call @useagg(%2) : (!llvm.struct<(i8, i1)>) -> () + %3 = llvm.extractvalue %2[0] : !llvm.struct<(i8, i1)> + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.extractvalue %2[1] : !llvm.struct<(i8, i1)> + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.xor %4, %0 : i1 + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.icmp "ne" %3, %1 : i8 + %7 = llvm.and %5, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @t6_commutability_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(false) : i1 + %3 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.call @useagg(%3) : (!llvm.struct<(i8, i1)>) -> () + %4 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.xor %5, %0 : i1 + llvm.call @use1(%6) : (i1) -> () + %7 = llvm.icmp "ne" %4, %1 : i8 + %8 = llvm.select %6, %7, %2 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @t7(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ult" %arg0, %arg1 : i8 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "eq" %1, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.or %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @t7_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ult" %arg0, %arg1 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "eq" %2, %0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %4, %1, %3 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t7_nonstrict(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ule" %arg0, %arg1 : i8 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "eq" %1, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.or %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @t7_nonstrict_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ule" %arg0, %arg1 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "eq" %2, %0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %4, %1, %3 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t8(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.call @useagg(%1) : (!llvm.struct<(i8, i1)>) -> () + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "eq" %2, %0 : i8 + %5 = llvm.or %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @t8_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.call @useagg(%2) : (!llvm.struct<(i8, i1)>) -> () + %3 = llvm.extractvalue %2[0] : !llvm.struct<(i8, i1)> + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.extractvalue %2[1] : !llvm.struct<(i8, i1)> + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.icmp "eq" %3, %0 : i8 + %6 = llvm.select %5, %1, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t9_commutative(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ult" %arg0, %1 : i8 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "eq" %1, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.or %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @t9_commutative_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ult" %arg0, %2 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "eq" %2, %0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %4, %1, %3 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @t10(%arg0: i64, %arg1: !llvm.ptr {llvm.nonnull}) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.ptrtoint %arg1 : !llvm.ptr to i64 + %2 = llvm.sub %arg0, %1 : i64 + llvm.call @use64(%2) : (i64) -> () + %3 = llvm.icmp "ult" %2, %arg0 : i64 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "ne" %2, %0 : i64 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @t10_logical(%arg0: i64, %arg1: !llvm.ptr {llvm.nonnull}) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.ptrtoint %arg1 : !llvm.ptr to i64 + %3 = llvm.sub %arg0, %2 : i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.icmp "ult" %3, %arg0 : i64 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.icmp "ne" %3, %0 : i64 + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.select %5, %4, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t11_commutative(%arg0: i64, %arg1: !llvm.ptr {llvm.nonnull}) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.ptrtoint %arg1 : !llvm.ptr to i64 + %2 = llvm.sub %arg0, %1 : i64 + llvm.call @use64(%2) : (i64) -> () + %3 = llvm.icmp "ugt" %arg0, %2 : i64 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "ne" %2, %0 : i64 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @t11_commutative_logical(%arg0: i64, %arg1: !llvm.ptr {llvm.nonnull}) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.ptrtoint %arg1 : !llvm.ptr to i64 + %3 = llvm.sub %arg0, %2 : i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.icmp "ugt" %arg0, %3 : i64 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.icmp "ne" %3, %0 : i64 + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.select %5, %4, %1 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t12(%arg0: i64, %arg1: !llvm.ptr {llvm.nonnull}) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.ptrtoint %arg1 : !llvm.ptr to i64 + %2 = llvm.sub %arg0, %1 : i64 + llvm.call @use64(%2) : (i64) -> () + %3 = llvm.icmp "uge" %2, %arg0 : i64 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "eq" %2, %0 : i64 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.or %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @t12_logical(%arg0: i64, %arg1: !llvm.ptr {llvm.nonnull}) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.ptrtoint %arg1 : !llvm.ptr to i64 + %3 = llvm.sub %arg0, %2 : i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.icmp "uge" %3, %arg0 : i64 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.icmp "eq" %3, %0 : i64 + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.select %5, %1, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t13(%arg0: i64, %arg1: !llvm.ptr {llvm.nonnull}) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.ptrtoint %arg1 : !llvm.ptr to i64 + %2 = llvm.sub %arg0, %1 : i64 + llvm.call @use64(%2) : (i64) -> () + %3 = llvm.icmp "ule" %arg0, %2 : i64 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "eq" %2, %0 : i64 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.or %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @t13_logical(%arg0: i64, %arg1: !llvm.ptr {llvm.nonnull}) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.ptrtoint %arg1 : !llvm.ptr to i64 + %3 = llvm.sub %arg0, %2 : i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.icmp "ule" %arg0, %3 : i64 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.icmp "eq" %3, %0 : i64 + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.select %5, %1, %4 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @t14_bad(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sub %arg0, %arg1 : i64 + llvm.call @use64(%1) : (i64) -> () + %2 = llvm.icmp "ult" %1, %arg0 : i64 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "ne" %1, %0 : i64 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.and %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @t14_bad_logical(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.sub %arg0, %arg1 : i64 + llvm.call @use64(%2) : (i64) -> () + %3 = llvm.icmp "ult" %2, %arg0 : i64 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "ne" %2, %0 : i64 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %4, %3, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @base_ult_offset(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %0 : i8 + %3 = llvm.icmp "ule" %arg0, %arg1 : i8 + %4 = llvm.and %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @base_ult_offset_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ne" %2, %0 : i8 + %4 = llvm.icmp "ule" %arg0, %arg1 : i8 + %5 = llvm.select %4, %3, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @base_uge_offset(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "eq" %1, %0 : i8 + %3 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %4 = llvm.or %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @base_uge_offset_logical(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "eq" %2, %0 : i8 + %4 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %5 = llvm.select %4, %1, %3 : i1, i1 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/reuse-constant-from-select-in-icmp.ll.mlir b/test/LLVMDialect/InstCombine/reuse-constant-from-select-in-icmp.ll.mlir new file mode 100644 index 000000000..714cde93c --- /dev/null +++ b/test/LLVMDialect/InstCombine/reuse-constant-from-select-in-icmp.ll.mlir @@ -0,0 +1,237 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @p0_ult_65536(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @p1_ugt(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65534 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @p2_slt_65536(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @p3_sgt(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65534 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @p4_vec_splat_ult_65536(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<65536> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<65535> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %arg1, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @p5_vec_splat_ugt(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<65534> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<65535> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "ugt" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %arg1, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @p6_vec_splat_slt_65536(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<65536> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<65535> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "slt" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %arg1, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @p7_vec_splat_sgt(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<65534> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<65535> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %arg1, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @p8_vec_nonsplat_poison0(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<65535> : vector<2xi32>) : vector<2xi32> + %8 = llvm.icmp "ult" %arg0, %6 : vector<2xi32> + %9 = llvm.select %8, %arg1, %7 : vector<2xi1>, vector<2xi32> + llvm.return %9 : vector<2xi32> + } + llvm.func @p9_vec_nonsplat_poison1(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<65536> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.constant(65535 : i32) : i32 + %3 = llvm.mlir.undef : vector<2xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi32> + %8 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %9 = llvm.select %8, %arg1, %7 : vector<2xi1>, vector<2xi32> + llvm.return %9 : vector<2xi32> + } + llvm.func @p10_vec_nonsplat_poison2(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(65535 : i32) : i32 + %8 = llvm.mlir.undef : vector<2xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi32> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi32> + %13 = llvm.icmp "ult" %arg0, %6 : vector<2xi32> + %14 = llvm.select %13, %arg1, %12 : vector<2xi1>, vector<2xi32> + llvm.return %14 : vector<2xi32> + } + llvm.func @p11_vec_nonsplat(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[65536, 32768]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[65535, 32767]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %arg1, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @use1(i1) + llvm.func @n12_extrause(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.select %2, %arg1, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @p13_commutativity0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @p14_commutativity1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.select %3, %1, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @p15_commutativity2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.mlir.constant(65535 : i32) : i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.select %3, %1, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @n17_ult_zero(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[65536, 0]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[65535, -1]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %arg1, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @n18_ugt_allones(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[65534, -1]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[65535, 0]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "ugt" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %arg1, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @n19_slt_int_min(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[65536, -2147483648]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[65535, 2147483647]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "slt" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %arg1, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @n20_sgt_int_max(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[65534, 2147483647]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[65535, -2147483648]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %arg1, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @n21_equality(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @t22_sign_check(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @t22_sign_check2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @n23_type_mismatch(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65536 : i64) : i64 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i64 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @n24_ult_65534(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65534 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @n25_all_good0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.select %2, %1, %0 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @n26_all_good1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.select %2, %0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @ult_inf_loop(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(-3 : i32) : i32 + %4 = llvm.add %arg0, %0 : i32 + %5 = llvm.icmp "ult" %4, %1 : i32 + %6 = llvm.select %5, %2, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @ult_inf_loop_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-5> : vector<2xi32>) : vector<2xi32> + %3 = llvm.add %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "ugt" %3, %1 : vector<2xi32> + %5 = llvm.select %4, %2, %1 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/rotate.ll.mlir b/test/LLVMDialect/InstCombine/rotate.ll.mlir new file mode 100644 index 000000000..ebcc7e89a --- /dev/null +++ b/test/LLVMDialect/InstCombine/rotate.ll.mlir @@ -0,0 +1,712 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @external_global() {addr_space = 0 : i32} : i8 + llvm.func @rotl_i32_constant(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(11 : i32) : i32 + %1 = llvm.mlir.constant(21 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.lshr %arg0, %1 : i32 + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @rotr_i42_constant(%arg0: i42) -> i42 { + %0 = llvm.mlir.constant(31 : i42) : i42 + %1 = llvm.mlir.constant(11 : i42) : i42 + %2 = llvm.shl %arg0, %0 : i42 + %3 = llvm.lshr %arg0, %1 : i42 + %4 = llvm.or %3, %2 : i42 + llvm.return %4 : i42 + } + llvm.func @rotr_i8_constant_commute(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.lshr %arg0, %1 : i8 + %4 = llvm.or %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @rotl_i88_constant_commute(%arg0: i88) -> i88 { + %0 = llvm.mlir.constant(44 : i88) : i88 + %1 = llvm.shl %arg0, %0 : i88 + %2 = llvm.lshr %arg0, %0 : i88 + %3 = llvm.or %1, %2 : i88 + llvm.return %3 : i88 + } + llvm.func @rotl_v2i16_constant_splat(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<15> : vector<2xi16>) : vector<2xi16> + %2 = llvm.shl %arg0, %0 : vector<2xi16> + %3 = llvm.lshr %arg0, %1 : vector<2xi16> + %4 = llvm.or %2, %3 : vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @rotl_v2i16_constant_splat_poison0(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<2xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi16> + %7 = llvm.mlir.constant(dense<15> : vector<2xi16>) : vector<2xi16> + %8 = llvm.shl %arg0, %6 : vector<2xi16> + %9 = llvm.lshr %arg0, %7 : vector<2xi16> + %10 = llvm.or %8, %9 : vector<2xi16> + llvm.return %10 : vector<2xi16> + } + llvm.func @rotl_v2i16_constant_splat_poison1(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.constant(15 : i16) : i16 + %3 = llvm.mlir.undef : vector<2xi16> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi16> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi16> + %8 = llvm.shl %arg0, %0 : vector<2xi16> + %9 = llvm.lshr %arg0, %7 : vector<2xi16> + %10 = llvm.or %8, %9 : vector<2xi16> + llvm.return %10 : vector<2xi16> + } + llvm.func @rotr_v2i17_constant_splat(%arg0: vector<2xi17>) -> vector<2xi17> { + %0 = llvm.mlir.constant(12 : i17) : i17 + %1 = llvm.mlir.constant(dense<12> : vector<2xi17>) : vector<2xi17> + %2 = llvm.mlir.constant(5 : i17) : i17 + %3 = llvm.mlir.constant(dense<5> : vector<2xi17>) : vector<2xi17> + %4 = llvm.shl %arg0, %1 : vector<2xi17> + %5 = llvm.lshr %arg0, %3 : vector<2xi17> + %6 = llvm.or %5, %4 : vector<2xi17> + llvm.return %6 : vector<2xi17> + } + llvm.func @rotr_v2i17_constant_splat_poison0(%arg0: vector<2xi17>) -> vector<2xi17> { + %0 = llvm.mlir.poison : i17 + %1 = llvm.mlir.constant(12 : i17) : i17 + %2 = llvm.mlir.undef : vector<2xi17> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi17> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi17> + %7 = llvm.mlir.constant(5 : i17) : i17 + %8 = llvm.mlir.undef : vector<2xi17> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<2xi17> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %7, %10[%11 : i32] : vector<2xi17> + %13 = llvm.shl %arg0, %6 : vector<2xi17> + %14 = llvm.lshr %arg0, %12 : vector<2xi17> + %15 = llvm.or %14, %13 : vector<2xi17> + llvm.return %15 : vector<2xi17> + } + llvm.func @rotr_v2i17_constant_splat_poison1(%arg0: vector<2xi17>) -> vector<2xi17> { + %0 = llvm.mlir.poison : i17 + %1 = llvm.mlir.constant(12 : i17) : i17 + %2 = llvm.mlir.undef : vector<2xi17> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi17> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi17> + %7 = llvm.mlir.constant(5 : i17) : i17 + %8 = llvm.mlir.undef : vector<2xi17> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi17> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi17> + %13 = llvm.shl %arg0, %6 : vector<2xi17> + %14 = llvm.lshr %arg0, %12 : vector<2xi17> + %15 = llvm.or %14, %13 : vector<2xi17> + llvm.return %15 : vector<2xi17> + } + llvm.func @rotr_v2i32_constant_nonsplat(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[17, 19]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[15, 13]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.shl %arg0, %0 : vector<2xi32> + %3 = llvm.lshr %arg0, %1 : vector<2xi32> + %4 = llvm.or %2, %3 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @rotr_v2i32_constant_nonsplat_poison0(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(19 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<[15, 13]> : vector<2xi32>) : vector<2xi32> + %8 = llvm.shl %arg0, %6 : vector<2xi32> + %9 = llvm.lshr %arg0, %7 : vector<2xi32> + %10 = llvm.or %8, %9 : vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @rotr_v2i32_constant_nonsplat_poison1(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[17, 19]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.undef : vector<2xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi32> + %8 = llvm.shl %arg0, %0 : vector<2xi32> + %9 = llvm.lshr %arg0, %7 : vector<2xi32> + %10 = llvm.or %8, %9 : vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @rotl_v2i36_constant_nonsplat(%arg0: vector<2xi36>) -> vector<2xi36> { + %0 = llvm.mlir.constant(11 : i36) : i36 + %1 = llvm.mlir.constant(21 : i36) : i36 + %2 = llvm.mlir.constant(dense<[21, 11]> : vector<2xi36>) : vector<2xi36> + %3 = llvm.mlir.constant(25 : i36) : i36 + %4 = llvm.mlir.constant(15 : i36) : i36 + %5 = llvm.mlir.constant(dense<[15, 25]> : vector<2xi36>) : vector<2xi36> + %6 = llvm.shl %arg0, %2 : vector<2xi36> + %7 = llvm.lshr %arg0, %5 : vector<2xi36> + %8 = llvm.or %6, %7 : vector<2xi36> + llvm.return %8 : vector<2xi36> + } + llvm.func @rotl_v3i36_constant_nonsplat_poison0(%arg0: vector<3xi36>) -> vector<3xi36> { + %0 = llvm.mlir.poison : i36 + %1 = llvm.mlir.constant(11 : i36) : i36 + %2 = llvm.mlir.constant(21 : i36) : i36 + %3 = llvm.mlir.undef : vector<3xi36> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi36> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi36> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi36> + %10 = llvm.mlir.constant(25 : i36) : i36 + %11 = llvm.mlir.constant(15 : i36) : i36 + %12 = llvm.mlir.undef : vector<3xi36> + %13 = llvm.mlir.constant(0 : i32) : i32 + %14 = llvm.insertelement %11, %12[%13 : i32] : vector<3xi36> + %15 = llvm.mlir.constant(1 : i32) : i32 + %16 = llvm.insertelement %10, %14[%15 : i32] : vector<3xi36> + %17 = llvm.mlir.constant(2 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<3xi36> + %19 = llvm.shl %arg0, %9 : vector<3xi36> + %20 = llvm.lshr %arg0, %18 : vector<3xi36> + %21 = llvm.or %19, %20 : vector<3xi36> + llvm.return %21 : vector<3xi36> + } + llvm.func @rotl_i32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.lshr %arg0, %1 : i32 + %4 = llvm.or %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @rotr_i37(%arg0: i37, %arg1: i37) -> i37 { + %0 = llvm.mlir.constant(37 : i37) : i37 + %1 = llvm.sub %0, %arg1 : i37 + %2 = llvm.shl %arg0, %1 : i37 + %3 = llvm.lshr %arg0, %arg1 : i37 + %4 = llvm.or %3, %2 : i37 + llvm.return %4 : i37 + } + llvm.func @rotr_i8_commute(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(8 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + %2 = llvm.shl %arg0, %1 : i8 + %3 = llvm.lshr %arg0, %arg1 : i8 + %4 = llvm.or %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @rotl_v4i32(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<32> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sub %0, %arg1 : vector<4xi32> + %2 = llvm.shl %arg0, %arg1 : vector<4xi32> + %3 = llvm.lshr %arg0, %1 : vector<4xi32> + %4 = llvm.or %2, %3 : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @rotr_v3i42(%arg0: vector<3xi42>, %arg1: vector<3xi42>) -> vector<3xi42> { + %0 = llvm.mlir.constant(42 : i42) : i42 + %1 = llvm.mlir.constant(dense<42> : vector<3xi42>) : vector<3xi42> + %2 = llvm.sub %1, %arg1 : vector<3xi42> + %3 = llvm.shl %arg0, %2 : vector<3xi42> + %4 = llvm.lshr %arg0, %arg1 : vector<3xi42> + %5 = llvm.or %4, %3 : vector<3xi42> + llvm.return %5 : vector<3xi42> + } + llvm.func @rotl_safe_i32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.and %2, %1 : i32 + %5 = llvm.shl %arg0, %3 : i32 + %6 = llvm.lshr %arg0, %4 : i32 + %7 = llvm.or %6, %5 : i32 + llvm.return %7 : i32 + } + llvm.func @rotl_safe_i16_commute_extra_use(%arg0: i16, %arg1: i16, %arg2: !llvm.ptr) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(15 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.and %arg1, %1 : i16 + %4 = llvm.and %2, %1 : i16 + llvm.store %4, %arg2 {alignment = 2 : i64} : i16, !llvm.ptr + %5 = llvm.shl %arg0, %3 : i16 + %6 = llvm.lshr %arg0, %4 : i16 + %7 = llvm.or %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @rotr_safe_i64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(63 : i64) : i64 + %2 = llvm.sub %0, %arg1 : i64 + %3 = llvm.and %arg1, %1 : i64 + %4 = llvm.and %2, %1 : i64 + %5 = llvm.shl %arg0, %4 : i64 + %6 = llvm.lshr %arg0, %3 : i64 + %7 = llvm.or %6, %5 : i64 + llvm.return %7 : i64 + } + llvm.func @rotr_safe_i8_commute_extra_use(%arg0: i8, %arg1: i8, %arg2: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.sub %0, %arg1 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.and %2, %1 : i8 + %5 = llvm.shl %arg0, %4 : i8 + %6 = llvm.lshr %arg0, %3 : i8 + llvm.store %6, %arg2 {alignment = 1 : i64} : i8, !llvm.ptr + %7 = llvm.or %5, %6 : i8 + llvm.return %7 : i8 + } + llvm.func @rotl_safe_v2i32(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %3 = llvm.sub %1, %arg1 : vector<2xi32> + %4 = llvm.and %arg1, %2 : vector<2xi32> + %5 = llvm.and %3, %2 : vector<2xi32> + %6 = llvm.shl %arg0, %4 : vector<2xi32> + %7 = llvm.lshr %arg0, %5 : vector<2xi32> + %8 = llvm.or %7, %6 : vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @rotr_safe_v3i16(%arg0: vector<3xi16>, %arg1: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : vector<3xi16>) : vector<3xi16> + %2 = llvm.mlir.constant(dense<15> : vector<3xi16>) : vector<3xi16> + %3 = llvm.sub %1, %arg1 : vector<3xi16> + %4 = llvm.and %arg1, %2 : vector<3xi16> + %5 = llvm.and %3, %2 : vector<3xi16> + %6 = llvm.shl %arg0, %5 : vector<3xi16> + %7 = llvm.lshr %arg0, %4 : vector<3xi16> + %8 = llvm.or %7, %6 : vector<3xi16> + llvm.return %8 : vector<3xi16> + } + llvm.func @rotate_left_16bit(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.zext %arg0 : i16 to i32 + %4 = llvm.shl %3, %2 : i32 + %5 = llvm.sub %1, %2 : i32 + %6 = llvm.lshr %3, %5 : i32 + %7 = llvm.or %6, %4 : i32 + %8 = llvm.trunc %7 : i32 to i16 + llvm.return %8 : i16 + } + llvm.func @rotate_left_commute_16bit_vec(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg1, %0 : vector<2xi32> + %3 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %4 = llvm.shl %3, %2 : vector<2xi32> + %5 = llvm.sub %1, %2 : vector<2xi32> + %6 = llvm.lshr %3, %5 : vector<2xi32> + %7 = llvm.or %4, %6 : vector<2xi32> + %8 = llvm.trunc %7 : vector<2xi32> to vector<2xi16> + llvm.return %8 : vector<2xi16> + } + llvm.func @rotate_right_8bit(%arg0: i8, %arg1: i3) -> i8 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.zext %arg1 : i3 to i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.lshr %2, %1 : i32 + %4 = llvm.sub %0, %1 : i32 + %5 = llvm.shl %2, %4 : i32 + %6 = llvm.or %5, %3 : i32 + %7 = llvm.trunc %6 : i32 to i8 + llvm.return %7 : i8 + } + llvm.func @rotate_right_commute_8bit_unmasked_shl(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.lshr %4, %3 : i32 + %6 = llvm.sub %2, %3 : i32 + %7 = llvm.shl %4, %6 : i32 + %8 = llvm.or %5, %7 : i32 + %9 = llvm.trunc %8 : i32 to i8 + llvm.return %9 : i8 + } + llvm.func @rotate_right_commute_8bit(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.lshr %4, %3 : i32 + %6 = llvm.sub %2, %3 : i32 + %7 = llvm.shl %arg0, %6 : i32 + %8 = llvm.or %5, %7 : i32 + %9 = llvm.trunc %8 : i32 to i8 + llvm.return %9 : i8 + } + llvm.func @rotate8_not_safe(%arg0: i8, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.lshr %1, %2 : i32 + %4 = llvm.shl %1, %arg1 : i32 + %5 = llvm.or %3, %4 : i32 + %6 = llvm.trunc %5 : i32 to i8 + llvm.return %6 : i8 + } + llvm.func @rotate9_not_safe(%arg0: i9, %arg1: i32) -> i9 { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.zext %arg0 : i9 to i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.lshr %1, %2 : i32 + %4 = llvm.shl %1, %arg1 : i32 + %5 = llvm.or %3, %4 : i32 + %6 = llvm.trunc %5 : i32 to i9 + llvm.return %6 : i9 + } + llvm.func @rotateleft_16_neg_mask(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(15 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.and %arg1, %1 : i16 + %4 = llvm.zext %3 : i16 to i32 + %5 = llvm.and %2, %1 : i16 + %6 = llvm.zext %5 : i16 to i32 + %7 = llvm.zext %arg0 : i16 to i32 + %8 = llvm.shl %7, %4 : i32 + %9 = llvm.lshr %7, %6 : i32 + %10 = llvm.or %9, %8 : i32 + %11 = llvm.trunc %10 : i32 to i16 + llvm.return %11 : i16 + } + llvm.func @rotateleft_16_neg_mask_commute(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(15 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.and %arg1, %1 : i16 + %4 = llvm.zext %3 : i16 to i32 + %5 = llvm.and %2, %1 : i16 + %6 = llvm.zext %5 : i16 to i32 + %7 = llvm.zext %arg0 : i16 to i32 + %8 = llvm.shl %7, %4 : i32 + %9 = llvm.lshr %7, %6 : i32 + %10 = llvm.or %8, %9 : i32 + %11 = llvm.trunc %10 : i32 to i16 + llvm.return %11 : i16 + } + llvm.func @rotateright_8_neg_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.sub %0, %arg1 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.zext %3 : i8 to i32 + %5 = llvm.and %2, %1 : i8 + %6 = llvm.zext %5 : i8 to i32 + %7 = llvm.zext %arg0 : i8 to i32 + %8 = llvm.shl %7, %6 : i32 + %9 = llvm.lshr %7, %4 : i32 + %10 = llvm.or %9, %8 : i32 + %11 = llvm.trunc %10 : i32 to i8 + llvm.return %11 : i8 + } + llvm.func @rotateright_8_neg_mask_commute(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.sub %0, %arg1 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.zext %3 : i8 to i32 + %5 = llvm.and %2, %1 : i8 + %6 = llvm.zext %5 : i8 to i32 + %7 = llvm.zext %arg0 : i8 to i32 + %8 = llvm.shl %7, %6 : i32 + %9 = llvm.lshr %7, %4 : i32 + %10 = llvm.or %8, %9 : i32 + %11 = llvm.trunc %10 : i32 to i8 + llvm.return %11 : i8 + } + llvm.func @rotateright_16_neg_mask_wide_amount(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.and %2, %1 : i32 + %5 = llvm.zext %arg0 : i16 to i32 + %6 = llvm.shl %5, %4 : i32 + %7 = llvm.lshr %5, %3 : i32 + %8 = llvm.or %7, %6 : i32 + %9 = llvm.trunc %8 : i32 to i16 + llvm.return %9 : i16 + } + llvm.func @rotateright_16_neg_mask_wide_amount_commute(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.and %2, %1 : i32 + %5 = llvm.zext %arg0 : i16 to i32 + %6 = llvm.shl %5, %4 : i32 + %7 = llvm.lshr %5, %3 : i32 + %8 = llvm.or %6, %7 : i32 + %9 = llvm.trunc %8 : i32 to i16 + llvm.return %9 : i16 + } + llvm.func @rotateright_64_zext_neg_mask_amount(%arg0: i64, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(63 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + %4 = llvm.lshr %arg0, %3 : i64 + %5 = llvm.sub %1, %arg1 overflow : i32 + %6 = llvm.and %5, %0 : i32 + %7 = llvm.zext %6 : i32 to i64 + %8 = llvm.shl %arg0, %7 : i64 + %9 = llvm.or %4, %8 : i64 + llvm.return %9 : i64 + } + llvm.func @rotateleft_8_neg_mask_wide_amount(%arg0: i8, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.and %2, %1 : i32 + %5 = llvm.zext %arg0 : i8 to i32 + %6 = llvm.shl %5, %3 : i32 + %7 = llvm.lshr %5, %4 : i32 + %8 = llvm.or %7, %6 : i32 + %9 = llvm.trunc %8 : i32 to i8 + llvm.return %9 : i8 + } + llvm.func @rotateleft_8_neg_mask_wide_amount_commute(%arg0: i8, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.and %2, %1 : i32 + %5 = llvm.zext %arg0 : i8 to i32 + %6 = llvm.shl %5, %3 : i32 + %7 = llvm.lshr %5, %4 : i32 + %8 = llvm.or %6, %7 : i32 + %9 = llvm.trunc %8 : i32 to i8 + llvm.return %9 : i8 + } + llvm.func @rotateleft_64_zext_neg_mask_amount(%arg0: i64, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(63 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + %4 = llvm.shl %arg0, %3 : i64 + %5 = llvm.sub %1, %arg1 overflow : i32 + %6 = llvm.and %5, %0 : i32 + %7 = llvm.zext %6 : i32 to i64 + %8 = llvm.lshr %arg0, %7 : i64 + %9 = llvm.or %4, %8 : i64 + llvm.return %9 : i64 + } + llvm.func @rotateleft_9_neg_mask_wide_amount_commute(%arg0: i9, %arg1: i33) -> i9 { + %0 = llvm.mlir.constant(0 : i33) : i33 + %1 = llvm.mlir.constant(8 : i33) : i33 + %2 = llvm.sub %0, %arg1 : i33 + %3 = llvm.and %arg1, %1 : i33 + %4 = llvm.and %2, %1 : i33 + %5 = llvm.zext %arg0 : i9 to i33 + %6 = llvm.shl %5, %3 : i33 + %7 = llvm.lshr %5, %4 : i33 + %8 = llvm.or %6, %7 : i33 + %9 = llvm.trunc %8 : i33 to i9 + llvm.return %9 : i9 + } + llvm.func @rotl_sub_mask(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(64 : i64) : i64 + %2 = llvm.and %arg1, %0 : i64 + %3 = llvm.shl %arg0, %2 : i64 + %4 = llvm.sub %1, %2 overflow : i64 + %5 = llvm.lshr %arg0, %4 : i64 + %6 = llvm.or %5, %3 : i64 + llvm.return %6 : i64 + } + llvm.func @rotr_sub_mask(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(64 : i64) : i64 + %2 = llvm.and %arg1, %0 : i64 + %3 = llvm.lshr %arg0, %2 : i64 + %4 = llvm.sub %1, %2 overflow : i64 + %5 = llvm.shl %arg0, %4 : i64 + %6 = llvm.or %5, %3 : i64 + llvm.return %6 : i64 + } + llvm.func @rotr_sub_mask_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<63> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<64> : vector<2xi64>) : vector<2xi64> + %2 = llvm.and %arg1, %0 : vector<2xi64> + %3 = llvm.lshr %arg0, %2 : vector<2xi64> + %4 = llvm.sub %1, %2 overflow : vector<2xi64> + %5 = llvm.shl %arg0, %4 : vector<2xi64> + %6 = llvm.or %5, %3 : vector<2xi64> + llvm.return %6 : vector<2xi64> + } + llvm.func @rotr_select(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.icmp "eq" %arg1, %0 : i32 + %3 = llvm.sub %1, %arg1 : i32 + %4 = llvm.lshr %arg0, %arg1 : i32 + %5 = llvm.shl %arg0, %3 : i32 + %6 = llvm.or %4, %5 : i32 + %7 = llvm.select %2, %arg0, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @rotr_select_commute(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(8 : i8) : i8 + %2 = llvm.icmp "eq" %arg1, %0 : i8 + %3 = llvm.sub %1, %arg1 : i8 + %4 = llvm.lshr %arg0, %arg1 : i8 + %5 = llvm.shl %arg0, %3 : i8 + %6 = llvm.or %5, %4 : i8 + %7 = llvm.select %2, %arg0, %6 : i1, i8 + llvm.return %7 : i8 + } + llvm.func @rotl_select(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(16 : i16) : i16 + %2 = llvm.icmp "eq" %arg1, %0 : i16 + %3 = llvm.sub %1, %arg1 : i16 + %4 = llvm.lshr %arg0, %3 : i16 + %5 = llvm.shl %arg0, %arg1 : i16 + %6 = llvm.or %4, %5 : i16 + %7 = llvm.select %2, %arg0, %6 : i1, i16 + llvm.return %7 : i16 + } + llvm.func @rotl_select_commute(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.constant(dense<64> : vector<2xi64>) : vector<2xi64> + %3 = llvm.icmp "eq" %arg1, %1 : vector<2xi64> + %4 = llvm.sub %2, %arg1 : vector<2xi64> + %5 = llvm.lshr %arg0, %4 : vector<2xi64> + %6 = llvm.shl %arg0, %arg1 : vector<2xi64> + %7 = llvm.or %6, %5 : vector<2xi64> + %8 = llvm.select %3, %arg0, %7 : vector<2xi1>, vector<2xi64> + llvm.return %8 : vector<2xi64> + } + llvm.func @rotl_select_weird_type(%arg0: i24, %arg1: i24) -> i24 { + %0 = llvm.mlir.constant(0 : i24) : i24 + %1 = llvm.mlir.constant(24 : i24) : i24 + %2 = llvm.icmp "eq" %arg1, %0 : i24 + %3 = llvm.sub %1, %arg1 : i24 + %4 = llvm.lshr %arg0, %3 : i24 + %5 = llvm.shl %arg0, %arg1 : i24 + %6 = llvm.or %5, %4 : i24 + %7 = llvm.select %2, %arg0, %6 : i1, i24 + llvm.return %7 : i24 + } + llvm.func @rotl_select_zext_shamt(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(31 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(32 : i8) : i8 + %3 = llvm.and %arg1, %0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + %5 = llvm.zext %3 : i8 to i32 + %6 = llvm.sub %2, %3 overflow : i8 + %7 = llvm.zext %6 : i8 to i32 + %8 = llvm.lshr %arg0, %7 : i32 + %9 = llvm.shl %arg0, %5 : i32 + %10 = llvm.or %9, %8 : i32 + %11 = llvm.select %4, %arg0, %10 : i1, i32 + llvm.return %11 : i32 + } + llvm.func @rotr_select_zext_shamt(%arg0: i64, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(63 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(64 : i32) : i32 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.zext %3 : i32 to i64 + %6 = llvm.lshr %arg0, %5 : i64 + %7 = llvm.sub %2, %3 overflow : i32 + %8 = llvm.zext %7 : i32 to i64 + %9 = llvm.shl %arg0, %8 : i64 + %10 = llvm.or %9, %6 : i64 + %11 = llvm.select %4, %arg0, %10 : i1, i64 + llvm.return %11 : i64 + } + llvm.func @rotl_constant_expr(%arg0: i32) -> i32 { + %0 = llvm.mlir.addressof @external_global : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i32 + %2 = llvm.mlir.constant(11 : i32) : i32 + %3 = llvm.lshr %1, %arg0 : i32 + %4 = llvm.shl %1, %2 : i32 + %5 = llvm.or %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @rotateleft32_doubleand1(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(31 : i8) : i8 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(31 : i32) : i32 + %3 = llvm.and %arg1, %0 : i8 + %4 = llvm.zext %3 : i8 to i32 + %5 = llvm.sub %1, %4 overflow : i32 + %6 = llvm.and %5, %2 : i32 + %7 = llvm.shl %arg0, %4 : i32 + %8 = llvm.lshr %arg0, %6 : i32 + %9 = llvm.or %8, %7 : i32 + llvm.return %9 : i32 + } + llvm.func @rotateright32_doubleand1(%arg0: i32, %arg1: i16) -> i32 { + %0 = llvm.mlir.constant(31 : i16) : i16 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(31 : i32) : i32 + %3 = llvm.and %arg1, %0 : i16 + %4 = llvm.zext %3 : i16 to i32 + %5 = llvm.sub %1, %4 overflow : i32 + %6 = llvm.and %5, %2 : i32 + %7 = llvm.shl %arg0, %6 : i32 + %8 = llvm.lshr %arg0, %4 : i32 + %9 = llvm.or %8, %7 : i32 + llvm.return %9 : i32 + } + llvm.func @unmasked_shlop_unmasked_shift_amount(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.sub %1, %arg1 : i32 + %4 = llvm.shl %arg0, %3 : i32 + %5 = llvm.lshr %2, %arg1 : i32 + %6 = llvm.or %4, %5 : i32 + %7 = llvm.trunc %6 : i32 to i8 + llvm.return %7 : i8 + } + llvm.func @check_rotate_masked_16bit(%arg0: i8, %arg1: i32) -> i16 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.and %arg0, %1 : i8 + %5 = llvm.zext %4 : i8 to i32 + %6 = llvm.lshr %3, %5 : i32 + %7 = llvm.sub %2, %arg0 : i8 + %8 = llvm.and %7, %1 : i8 + %9 = llvm.zext %8 : i8 to i32 + %10 = llvm.shl %3, %9 overflow : i32 + %11 = llvm.or %6, %10 : i32 + %12 = llvm.trunc %11 : i32 to i16 + llvm.return %12 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/sadd-with-overflow.ll.mlir b/test/LLVMDialect/InstCombine/sadd-with-overflow.ll.mlir new file mode 100644 index 000000000..dee97ba3b --- /dev/null +++ b/test/LLVMDialect/InstCombine/sadd-with-overflow.ll.mlir @@ -0,0 +1,105 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @simple_fold(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(13 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = "llvm.intr.sadd.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @fold_mixed_signs(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(13 : i32) : i32 + %1 = llvm.mlir.constant(-7 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = "llvm.intr.sadd.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @fold_on_constant_add_no_overflow(%arg0: i8) -> !llvm.struct<(i8, i1)> { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(27 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = "llvm.intr.sadd.with.overflow"(%2, %1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.return %3 : !llvm.struct<(i8, i1)> + } + llvm.func @no_fold_on_constant_add_overflow(%arg0: i8) -> !llvm.struct<(i8, i1)> { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(28 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = "llvm.intr.sadd.with.overflow"(%2, %1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.return %3 : !llvm.struct<(i8, i1)> + } + llvm.func @fold_simple_splat_constant(%arg0: vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> { + %0 = llvm.mlir.constant(dense<12> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<30> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %arg0, %0 overflow : vector<2xi32> + %3 = "llvm.intr.sadd.with.overflow"(%2, %1) : (vector<2xi32>, vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> + llvm.return %3 : !llvm.struct<(vector<2xi32>, vector<2xi1>)> + } + llvm.func @no_fold_splat_undef_constant(%arg0: vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<30> : vector<2xi32>) : vector<2xi32> + %8 = llvm.add %arg0, %6 overflow : vector<2xi32> + %9 = "llvm.intr.sadd.with.overflow"(%8, %7) : (vector<2xi32>, vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> + llvm.return %9 : !llvm.struct<(vector<2xi32>, vector<2xi1>)> + } + llvm.func @no_fold_splat_not_constant(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> { + %0 = llvm.mlir.constant(dense<30> : vector<2xi32>) : vector<2xi32> + %1 = llvm.add %arg0, %arg1 overflow : vector<2xi32> + %2 = "llvm.intr.sadd.with.overflow"(%1, %0) : (vector<2xi32>, vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> + llvm.return %2 : !llvm.struct<(vector<2xi32>, vector<2xi1>)> + } + llvm.func @fold_nuwnsw(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = "llvm.intr.sadd.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @no_fold_nuw(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = "llvm.intr.sadd.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @no_fold_wrapped_add(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = "llvm.intr.sadd.with.overflow"(%1, %2) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @fold_sub_simple(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(-12 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.sub %arg0, %0 overflow : i32 + %3 = "llvm.intr.sadd.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @fold_with_distjoin_or(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(13 : i32) : i32 + %1 = llvm.mlir.constant(-7 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = "llvm.intr.sadd.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @fold_with_disjoint_or2(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(27 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = "llvm.intr.sadd.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @fold_with_or_fail(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(100 : i32) : i32 + %1 = llvm.mlir.constant(27 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = "llvm.intr.sadd.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } +} diff --git a/test/LLVMDialect/InstCombine/sadd_sat.ll.mlir b/test/LLVMDialect/InstCombine/sadd_sat.ll.mlir new file mode 100644 index 000000000..afa6fe94b --- /dev/null +++ b/test/LLVMDialect/InstCombine/sadd_sat.ll.mlir @@ -0,0 +1,555 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 64 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @sadd_sat32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.add %3, %2 : i64 + %5 = llvm.icmp "slt" %4, %0 : i64 + %6 = llvm.select %5, %4, %0 : i1, i64 + %7 = llvm.icmp "sgt" %6, %1 : i64 + %8 = llvm.select %7, %6, %1 : i1, i64 + %9 = llvm.trunc %8 : i64 to i32 + llvm.return %9 : i32 + } + llvm.func @sadd_sat32_mm(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.add %3, %2 : i64 + %5 = llvm.intr.smin(%4, %0) : (i64, i64) -> i64 + %6 = llvm.intr.smax(%5, %1) : (i64, i64) -> i64 + %7 = llvm.trunc %6 : i64 to i32 + llvm.return %7 : i32 + } + llvm.func @ssub_sat32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.sub %2, %3 : i64 + %5 = llvm.icmp "slt" %4, %0 : i64 + %6 = llvm.select %5, %4, %0 : i1, i64 + %7 = llvm.icmp "sgt" %6, %1 : i64 + %8 = llvm.select %7, %6, %1 : i1, i64 + %9 = llvm.trunc %8 : i64 to i32 + llvm.return %9 : i32 + } + llvm.func @ssub_sat32_mm(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.sub %2, %3 : i64 + %5 = llvm.intr.smin(%4, %0) : (i64, i64) -> i64 + %6 = llvm.intr.smax(%5, %1) : (i64, i64) -> i64 + %7 = llvm.trunc %6 : i64 to i32 + llvm.return %7 : i32 + } + llvm.func @smul_sat32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.mul %3, %2 : i64 + %5 = llvm.icmp "slt" %4, %0 : i64 + %6 = llvm.select %5, %4, %0 : i1, i64 + %7 = llvm.icmp "sgt" %6, %1 : i64 + %8 = llvm.select %7, %6, %1 : i1, i64 + %9 = llvm.trunc %8 : i64 to i32 + llvm.return %9 : i32 + } + llvm.func @smul_sat32_mm(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.mul %3, %2 : i64 + %5 = llvm.intr.smin(%4, %0) : (i64, i64) -> i64 + %6 = llvm.intr.smax(%5, %1) : (i64, i64) -> i64 + %7 = llvm.trunc %6 : i64 to i32 + llvm.return %7 : i32 + } + llvm.func @sadd_sat16(%arg0: i16 {llvm.signext}, %arg1: i16 {llvm.signext}) -> (i16 {llvm.signext}) { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.sext %arg0 : i16 to i32 + %3 = llvm.sext %arg1 : i16 to i32 + %4 = llvm.add %3, %2 : i32 + %5 = llvm.icmp "slt" %4, %0 : i32 + %6 = llvm.select %5, %4, %0 : i1, i32 + %7 = llvm.icmp "sgt" %6, %1 : i32 + %8 = llvm.select %7, %6, %1 : i1, i32 + %9 = llvm.trunc %8 : i32 to i16 + llvm.return %9 : i16 + } + llvm.func @sadd_sat16_mm(%arg0: i16 {llvm.signext}, %arg1: i16 {llvm.signext}) -> (i16 {llvm.signext}) { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.sext %arg0 : i16 to i32 + %3 = llvm.sext %arg1 : i16 to i32 + %4 = llvm.add %3, %2 : i32 + %5 = llvm.intr.smin(%4, %0) : (i32, i32) -> i32 + %6 = llvm.intr.smax(%5, %1) : (i32, i32) -> i32 + %7 = llvm.trunc %6 : i32 to i16 + llvm.return %7 : i16 + } + llvm.func @ssub_sat16(%arg0: i16 {llvm.signext}, %arg1: i16 {llvm.signext}) -> (i16 {llvm.signext}) { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.sext %arg0 : i16 to i32 + %3 = llvm.sext %arg1 : i16 to i32 + %4 = llvm.sub %2, %3 : i32 + %5 = llvm.icmp "slt" %4, %0 : i32 + %6 = llvm.select %5, %4, %0 : i1, i32 + %7 = llvm.icmp "sgt" %6, %1 : i32 + %8 = llvm.select %7, %6, %1 : i1, i32 + %9 = llvm.trunc %8 : i32 to i16 + llvm.return %9 : i16 + } + llvm.func @ssub_sat16_mm(%arg0: i16 {llvm.signext}, %arg1: i16 {llvm.signext}) -> (i16 {llvm.signext}) { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.sext %arg0 : i16 to i32 + %3 = llvm.sext %arg1 : i16 to i32 + %4 = llvm.sub %2, %3 : i32 + %5 = llvm.intr.smin(%4, %0) : (i32, i32) -> i32 + %6 = llvm.intr.smax(%5, %1) : (i32, i32) -> i32 + %7 = llvm.trunc %6 : i32 to i16 + llvm.return %7 : i16 + } + llvm.func @sadd_sat8(%arg0: i8 {llvm.signext}, %arg1: i8 {llvm.signext}) -> (i8 {llvm.signext}) { + %0 = llvm.mlir.constant(127 : i32) : i32 + %1 = llvm.mlir.constant(-128 : i32) : i32 + %2 = llvm.sext %arg0 : i8 to i32 + %3 = llvm.sext %arg1 : i8 to i32 + %4 = llvm.add %3, %2 : i32 + %5 = llvm.icmp "slt" %4, %0 : i32 + %6 = llvm.select %5, %4, %0 : i1, i32 + %7 = llvm.icmp "sgt" %6, %1 : i32 + %8 = llvm.select %7, %6, %1 : i1, i32 + %9 = llvm.trunc %8 : i32 to i8 + llvm.return %9 : i8 + } + llvm.func @sadd_sat8_mm(%arg0: i8 {llvm.signext}, %arg1: i8 {llvm.signext}) -> (i8 {llvm.signext}) { + %0 = llvm.mlir.constant(127 : i32) : i32 + %1 = llvm.mlir.constant(-128 : i32) : i32 + %2 = llvm.sext %arg0 : i8 to i32 + %3 = llvm.sext %arg1 : i8 to i32 + %4 = llvm.add %3, %2 : i32 + %5 = llvm.intr.smin(%4, %0) : (i32, i32) -> i32 + %6 = llvm.intr.smax(%5, %1) : (i32, i32) -> i32 + %7 = llvm.trunc %6 : i32 to i8 + llvm.return %7 : i8 + } + llvm.func @ssub_sat8(%arg0: i8 {llvm.signext}, %arg1: i8 {llvm.signext}) -> (i8 {llvm.signext}) { + %0 = llvm.mlir.constant(127 : i32) : i32 + %1 = llvm.mlir.constant(-128 : i32) : i32 + %2 = llvm.sext %arg0 : i8 to i32 + %3 = llvm.sext %arg1 : i8 to i32 + %4 = llvm.sub %2, %3 : i32 + %5 = llvm.icmp "slt" %4, %0 : i32 + %6 = llvm.select %5, %4, %0 : i1, i32 + %7 = llvm.icmp "sgt" %6, %1 : i32 + %8 = llvm.select %7, %6, %1 : i1, i32 + %9 = llvm.trunc %8 : i32 to i8 + llvm.return %9 : i8 + } + llvm.func @ssub_sat8_mm(%arg0: i8 {llvm.signext}, %arg1: i8 {llvm.signext}) -> (i8 {llvm.signext}) { + %0 = llvm.mlir.constant(127 : i32) : i32 + %1 = llvm.mlir.constant(-128 : i32) : i32 + %2 = llvm.sext %arg0 : i8 to i32 + %3 = llvm.sext %arg1 : i8 to i32 + %4 = llvm.sub %2, %3 : i32 + %5 = llvm.intr.smin(%4, %0) : (i32, i32) -> i32 + %6 = llvm.intr.smax(%5, %1) : (i32, i32) -> i32 + %7 = llvm.trunc %6 : i32 to i8 + llvm.return %7 : i8 + } + llvm.func @sadd_sat64(%arg0: i64 {llvm.signext}, %arg1: i64 {llvm.signext}) -> (i64 {llvm.signext}) { + %0 = llvm.mlir.constant(9223372036854775807 : i65) : i65 + %1 = llvm.mlir.constant(-9223372036854775808 : i65) : i65 + %2 = llvm.sext %arg0 : i64 to i65 + %3 = llvm.sext %arg1 : i64 to i65 + %4 = llvm.add %3, %2 : i65 + %5 = llvm.icmp "slt" %4, %0 : i65 + %6 = llvm.select %5, %4, %0 : i1, i65 + %7 = llvm.icmp "sgt" %6, %1 : i65 + %8 = llvm.select %7, %6, %1 : i1, i65 + %9 = llvm.trunc %8 : i65 to i64 + llvm.return %9 : i64 + } + llvm.func @ssub_sat64(%arg0: i64 {llvm.signext}, %arg1: i64 {llvm.signext}) -> (i64 {llvm.signext}) { + %0 = llvm.mlir.constant(9223372036854775807 : i65) : i65 + %1 = llvm.mlir.constant(-9223372036854775808 : i65) : i65 + %2 = llvm.sext %arg0 : i64 to i65 + %3 = llvm.sext %arg1 : i64 to i65 + %4 = llvm.sub %2, %3 : i65 + %5 = llvm.icmp "slt" %4, %0 : i65 + %6 = llvm.select %5, %4, %0 : i1, i65 + %7 = llvm.icmp "sgt" %6, %1 : i65 + %8 = llvm.select %7, %6, %1 : i1, i65 + %9 = llvm.trunc %8 : i65 to i64 + llvm.return %9 : i64 + } + llvm.func @sadd_sat4(%arg0: i4 {llvm.signext}, %arg1: i4 {llvm.signext}) -> (i4 {llvm.signext}) { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(-8 : i32) : i32 + %2 = llvm.sext %arg0 : i4 to i32 + %3 = llvm.sext %arg1 : i4 to i32 + %4 = llvm.add %3, %2 : i32 + %5 = llvm.icmp "slt" %4, %0 : i32 + %6 = llvm.select %5, %4, %0 : i1, i32 + %7 = llvm.icmp "sgt" %6, %1 : i32 + %8 = llvm.select %7, %6, %1 : i1, i32 + %9 = llvm.trunc %8 : i32 to i4 + llvm.return %9 : i4 + } + llvm.func @ssub_sat4(%arg0: i4 {llvm.signext}, %arg1: i4 {llvm.signext}) -> (i4 {llvm.signext}) { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(-8 : i32) : i32 + %2 = llvm.sext %arg0 : i4 to i32 + %3 = llvm.sext %arg1 : i4 to i32 + %4 = llvm.sub %2, %3 : i32 + %5 = llvm.icmp "slt" %4, %0 : i32 + %6 = llvm.select %5, %4, %0 : i1, i32 + %7 = llvm.icmp "sgt" %6, %1 : i32 + %8 = llvm.select %7, %6, %1 : i1, i32 + %9 = llvm.trunc %8 : i32 to i4 + llvm.return %9 : i4 + } + llvm.func @sadd_satv4i32(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<2147483647> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mlir.constant(dense<-2147483648> : vector<4xi64>) : vector<4xi64> + %2 = llvm.sext %arg0 : vector<4xi32> to vector<4xi64> + %3 = llvm.sext %arg1 : vector<4xi32> to vector<4xi64> + %4 = llvm.add %3, %2 : vector<4xi64> + %5 = llvm.icmp "slt" %4, %0 : vector<4xi64> + %6 = llvm.select %5, %4, %0 : vector<4xi1>, vector<4xi64> + %7 = llvm.icmp "sgt" %6, %1 : vector<4xi64> + %8 = llvm.select %7, %6, %1 : vector<4xi1>, vector<4xi64> + %9 = llvm.trunc %8 : vector<4xi64> to vector<4xi32> + llvm.return %9 : vector<4xi32> + } + llvm.func @sadd_satv4i32_mm(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<2147483647> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mlir.constant(dense<-2147483648> : vector<4xi64>) : vector<4xi64> + %2 = llvm.sext %arg0 : vector<4xi32> to vector<4xi64> + %3 = llvm.sext %arg1 : vector<4xi32> to vector<4xi64> + %4 = llvm.add %3, %2 : vector<4xi64> + %5 = llvm.intr.smin(%4, %0) : (vector<4xi64>, vector<4xi64>) -> vector<4xi64> + %6 = llvm.intr.smax(%5, %1) : (vector<4xi64>, vector<4xi64>) -> vector<4xi64> + %7 = llvm.trunc %6 : vector<4xi64> to vector<4xi32> + llvm.return %7 : vector<4xi32> + } + llvm.func @ssub_satv4i32(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<2147483647> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mlir.constant(dense<-2147483648> : vector<4xi64>) : vector<4xi64> + %2 = llvm.sext %arg0 : vector<4xi32> to vector<4xi64> + %3 = llvm.sext %arg1 : vector<4xi32> to vector<4xi64> + %4 = llvm.sub %3, %2 : vector<4xi64> + %5 = llvm.icmp "slt" %4, %0 : vector<4xi64> + %6 = llvm.select %5, %4, %0 : vector<4xi1>, vector<4xi64> + %7 = llvm.icmp "sgt" %6, %1 : vector<4xi64> + %8 = llvm.select %7, %6, %1 : vector<4xi1>, vector<4xi64> + %9 = llvm.trunc %8 : vector<4xi64> to vector<4xi32> + llvm.return %9 : vector<4xi32> + } + llvm.func @ssub_satv4i32_mm(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<2147483647> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mlir.constant(dense<-2147483648> : vector<4xi64>) : vector<4xi64> + %2 = llvm.sext %arg0 : vector<4xi32> to vector<4xi64> + %3 = llvm.sext %arg1 : vector<4xi32> to vector<4xi64> + %4 = llvm.sub %3, %2 : vector<4xi64> + %5 = llvm.intr.smin(%4, %0) : (vector<4xi64>, vector<4xi64>) -> vector<4xi64> + %6 = llvm.intr.smax(%5, %1) : (vector<4xi64>, vector<4xi64>) -> vector<4xi64> + %7 = llvm.trunc %6 : vector<4xi64> to vector<4xi32> + llvm.return %7 : vector<4xi32> + } + llvm.func @sadd_satv4i4(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<15> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-16> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %arg1 : vector<4xi32> + %3 = llvm.icmp "slt" %2, %0 : vector<4xi32> + %4 = llvm.select %3, %2, %0 : vector<4xi1>, vector<4xi32> + %5 = llvm.icmp "sgt" %4, %1 : vector<4xi32> + %6 = llvm.select %5, %4, %1 : vector<4xi1>, vector<4xi32> + llvm.return %6 : vector<4xi32> + } + llvm.func @ssub_satv4i4(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<15> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-16> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %arg0, %arg1 : vector<4xi32> + %3 = llvm.icmp "slt" %2, %0 : vector<4xi32> + %4 = llvm.select %3, %2, %0 : vector<4xi1>, vector<4xi32> + %5 = llvm.icmp "sgt" %4, %1 : vector<4xi32> + %6 = llvm.select %5, %4, %1 : vector<4xi1>, vector<4xi32> + llvm.return %6 : vector<4xi32> + } + llvm.func @sadd_sat32_extrause_1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.add %3, %2 : i64 + %5 = llvm.icmp "slt" %4, %0 : i64 + %6 = llvm.select %5, %4, %0 : i1, i64 + %7 = llvm.icmp "sgt" %6, %1 : i64 + %8 = llvm.select %7, %6, %1 : i1, i64 + %9 = llvm.trunc %8 : i64 to i32 + llvm.call @use64(%8) : (i64) -> () + llvm.return %9 : i32 + } + llvm.func @sadd_sat32_extrause_2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.add %3, %2 : i64 + %5 = llvm.icmp "slt" %4, %0 : i64 + %6 = llvm.select %5, %4, %0 : i1, i64 + %7 = llvm.icmp "sgt" %6, %1 : i64 + %8 = llvm.select %7, %6, %1 : i1, i64 + %9 = llvm.trunc %8 : i64 to i32 + llvm.call @use64(%6) : (i64) -> () + llvm.return %9 : i32 + } + llvm.func @sadd_sat32_extrause_2_mm(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.add %3, %2 : i64 + %5 = llvm.intr.smin(%4, %0) : (i64, i64) -> i64 + %6 = llvm.intr.smax(%5, %1) : (i64, i64) -> i64 + %7 = llvm.trunc %6 : i64 to i32 + llvm.call @use64(%5) : (i64) -> () + llvm.return %7 : i32 + } + llvm.func @sadd_sat32_extrause_3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.add %3, %2 : i64 + %5 = llvm.icmp "slt" %4, %0 : i64 + %6 = llvm.select %5, %4, %0 : i1, i64 + %7 = llvm.icmp "sgt" %6, %1 : i64 + %8 = llvm.select %7, %6, %1 : i1, i64 + %9 = llvm.trunc %8 : i64 to i32 + llvm.call @use64(%4) : (i64) -> () + llvm.return %9 : i32 + } + llvm.func @sadd_sat32_extrause_3_mm(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.add %3, %2 : i64 + %5 = llvm.intr.smin(%4, %0) : (i64, i64) -> i64 + %6 = llvm.intr.smax(%5, %1) : (i64, i64) -> i64 + %7 = llvm.trunc %6 : i64 to i32 + llvm.call @use64(%4) : (i64) -> () + llvm.return %7 : i32 + } + llvm.func @sadd_sat32_trunc(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32767 : i64) : i64 + %1 = llvm.mlir.constant(-32768 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.add %3, %2 : i64 + %5 = llvm.icmp "slt" %4, %0 : i64 + %6 = llvm.select %5, %4, %0 : i1, i64 + %7 = llvm.icmp "sgt" %6, %1 : i64 + %8 = llvm.select %7, %6, %1 : i1, i64 + %9 = llvm.trunc %8 : i64 to i32 + llvm.return %9 : i32 + } + llvm.func @sadd_sat32_ext16(%arg0: i32, %arg1: i16) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i16 to i64 + %4 = llvm.add %3, %2 : i64 + %5 = llvm.icmp "slt" %4, %0 : i64 + %6 = llvm.select %5, %4, %0 : i1, i64 + %7 = llvm.icmp "sgt" %6, %1 : i64 + %8 = llvm.select %7, %6, %1 : i1, i64 + %9 = llvm.trunc %8 : i64 to i32 + llvm.return %9 : i32 + } + llvm.func @sadd_sat8_ext8(%arg0: i8, %arg1: i16) -> i8 { + %0 = llvm.mlir.constant(127 : i32) : i32 + %1 = llvm.mlir.constant(-128 : i32) : i32 + %2 = llvm.sext %arg0 : i8 to i32 + %3 = llvm.sext %arg1 : i16 to i32 + %4 = llvm.add %3, %2 : i32 + %5 = llvm.icmp "slt" %4, %0 : i32 + %6 = llvm.select %5, %4, %0 : i1, i32 + %7 = llvm.icmp "sgt" %6, %1 : i32 + %8 = llvm.select %7, %6, %1 : i1, i32 + %9 = llvm.trunc %8 : i32 to i8 + llvm.return %9 : i8 + } + llvm.func @sadd_sat32_zext(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.zext %arg0 : i32 to i64 + %3 = llvm.zext %arg1 : i32 to i64 + %4 = llvm.add %3, %2 : i64 + %5 = llvm.icmp "slt" %4, %0 : i64 + %6 = llvm.select %5, %4, %0 : i1, i64 + %7 = llvm.icmp "sgt" %6, %1 : i64 + %8 = llvm.select %7, %6, %1 : i1, i64 + %9 = llvm.trunc %8 : i64 to i32 + llvm.return %9 : i32 + } + llvm.func @sadd_sat32_maxmin(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i64) : i64 + %1 = llvm.mlir.constant(2147483647 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.add %3, %2 : i64 + %5 = llvm.icmp "sgt" %4, %0 : i64 + %6 = llvm.select %5, %4, %0 : i1, i64 + %7 = llvm.icmp "slt" %6, %1 : i64 + %8 = llvm.select %7, %6, %1 : i1, i64 + %9 = llvm.trunc %8 : i64 to i32 + llvm.return %9 : i32 + } + llvm.func @sadd_sat32_notrunc(%arg0: i32, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(-2147483648 : i64) : i64 + %1 = llvm.mlir.constant(2147483647 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.sext %arg1 : i32 to i64 + %4 = llvm.add %3, %2 : i64 + %5 = llvm.icmp "sgt" %4, %0 : i64 + %6 = llvm.select %5, %4, %0 : i1, i64 + %7 = llvm.icmp "slt" %6, %1 : i64 + %8 = llvm.select %7, %6, %1 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @ashrA(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(2147483647 : i64) : i64 + %2 = llvm.mlir.constant(-2147483648 : i64) : i64 + %3 = llvm.ashr %arg0, %0 : i64 + %4 = llvm.sext %arg1 : i32 to i64 + %5 = llvm.add %4, %3 : i64 + %6 = llvm.intr.smin(%5, %1) : (i64, i64) -> i64 + %7 = llvm.intr.smax(%6, %2) : (i64, i64) -> i64 + %8 = llvm.trunc %7 : i64 to i32 + llvm.return %8 : i32 + } + llvm.func @ashrB(%arg0: i32, %arg1: i64) -> i32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.mlir.constant(2147483647 : i64) : i64 + %3 = llvm.sext %arg0 : i32 to i64 + %4 = llvm.ashr %arg1, %0 : i64 + %5 = llvm.add %4, %3 : i64 + %6 = llvm.icmp "sgt" %5, %1 : i64 + %7 = llvm.select %6, %5, %1 : i1, i64 + %8 = llvm.icmp "slt" %7, %2 : i64 + %9 = llvm.select %8, %7, %2 : i1, i64 + %10 = llvm.trunc %9 : i64 to i32 + llvm.return %10 : i32 + } + llvm.func @ashrAB(%arg0: i64, %arg1: i64) -> i32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.mlir.constant(2147483647 : i64) : i64 + %3 = llvm.ashr %arg0, %0 : i64 + %4 = llvm.ashr %arg1, %0 : i64 + %5 = llvm.add %4, %3 : i64 + %6 = llvm.icmp "sgt" %5, %1 : i64 + %7 = llvm.select %6, %5, %1 : i1, i64 + %8 = llvm.icmp "slt" %7, %2 : i64 + %9 = llvm.select %8, %7, %2 : i1, i64 + %10 = llvm.trunc %9 : i64 to i32 + llvm.return %10 : i32 + } + llvm.func @ashrA31(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.mlir.constant(2147483647 : i64) : i64 + %3 = llvm.ashr %arg0, %0 : i64 + %4 = llvm.sext %arg1 : i32 to i64 + %5 = llvm.add %4, %3 : i64 + %6 = llvm.icmp "sgt" %5, %1 : i64 + %7 = llvm.select %6, %5, %1 : i1, i64 + %8 = llvm.icmp "slt" %7, %2 : i64 + %9 = llvm.select %8, %7, %2 : i1, i64 + %10 = llvm.trunc %9 : i64 to i32 + llvm.return %10 : i32 + } + llvm.func @ashrA33(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(33 : i64) : i64 + %1 = llvm.mlir.constant(-2147483648 : i64) : i64 + %2 = llvm.mlir.constant(2147483647 : i64) : i64 + %3 = llvm.ashr %arg0, %0 : i64 + %4 = llvm.sext %arg1 : i32 to i64 + %5 = llvm.add %4, %3 : i64 + %6 = llvm.icmp "sgt" %5, %1 : i64 + %7 = llvm.select %6, %5, %1 : i1, i64 + %8 = llvm.icmp "slt" %7, %2 : i64 + %9 = llvm.select %8, %7, %2 : i1, i64 + %10 = llvm.trunc %9 : i64 to i32 + llvm.return %10 : i32 + } + llvm.func @ashrv2i8(%arg0: vector<2xi16>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[8, 12]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<-128> : vector<2xi16>) : vector<2xi16> + %2 = llvm.mlir.constant(dense<127> : vector<2xi16>) : vector<2xi16> + %3 = llvm.ashr %arg0, %0 : vector<2xi16> + %4 = llvm.sext %arg1 : vector<2xi8> to vector<2xi16> + %5 = llvm.add %4, %3 : vector<2xi16> + %6 = llvm.icmp "sgt" %5, %1 : vector<2xi16> + %7 = llvm.select %6, %5, %1 : vector<2xi1>, vector<2xi16> + %8 = llvm.icmp "slt" %7, %2 : vector<2xi16> + %9 = llvm.select %8, %7, %2 : vector<2xi1>, vector<2xi16> + %10 = llvm.trunc %9 : vector<2xi16> to vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @ashrv2i8_s(%arg0: vector<2xi16>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<-128> : vector<2xi16>) : vector<2xi16> + %2 = llvm.mlir.constant(dense<127> : vector<2xi16>) : vector<2xi16> + %3 = llvm.ashr %arg0, %0 : vector<2xi16> + %4 = llvm.sext %arg1 : vector<2xi8> to vector<2xi16> + %5 = llvm.add %4, %3 : vector<2xi16> + %6 = llvm.icmp "sgt" %5, %1 : vector<2xi16> + %7 = llvm.select %6, %5, %1 : vector<2xi1>, vector<2xi16> + %8 = llvm.icmp "slt" %7, %2 : vector<2xi16> + %9 = llvm.select %8, %7, %2 : vector<2xi1>, vector<2xi16> + %10 = llvm.trunc %9 : vector<2xi16> to vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @or(%arg0: i8, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(-16 : i16) : i16 + %1 = llvm.mlir.constant(-128 : i16) : i16 + %2 = llvm.mlir.constant(127 : i16) : i16 + %3 = llvm.sext %arg0 : i8 to i16 + %4 = llvm.or %arg1, %0 : i16 + %5 = llvm.sub %3, %4 overflow : i16 + %6 = llvm.icmp "sgt" %5, %1 : i16 + %7 = llvm.select %6, %5, %1 : i1, i16 + %8 = llvm.icmp "slt" %7, %2 : i16 + %9 = llvm.select %8, %7, %2 : i1, i16 + llvm.return %9 : i16 + } + llvm.func @const(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(10 : i16) : i16 + %1 = llvm.mlir.constant(-128 : i16) : i16 + %2 = llvm.mlir.constant(127 : i16) : i16 + %3 = llvm.sext %arg0 : i8 to i16 + %4 = llvm.add %3, %0 : i16 + %5 = llvm.icmp "sgt" %4, %1 : i16 + %6 = llvm.select %5, %4, %1 : i1, i16 + %7 = llvm.icmp "slt" %6, %2 : i16 + %8 = llvm.select %7, %6, %2 : i1, i16 + llvm.return %8 : i16 + } + llvm.func @use64(i64) +} diff --git a/test/LLVMDialect/InstCombine/saddo.ll.mlir b/test/LLVMDialect/InstCombine/saddo.ll.mlir new file mode 100644 index 000000000..b48a882e2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/saddo.ll.mlir @@ -0,0 +1,55 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_generic(%arg0: i64, %arg1: i64) -> i1 { + %0 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i64, i1)> + llvm.return %1 : i1 + } + llvm.func @test_constant0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.sadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = "llvm.intr.sadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = "llvm.intr.sadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = "llvm.intr.sadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = "llvm.intr.sadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant127(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = "llvm.intr.sadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant128(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = "llvm.intr.sadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant255(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = "llvm.intr.sadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/salvage-dbg-declare.ll.mlir b/test/LLVMDialect/InstCombine/salvage-dbg-declare.ll.mlir new file mode 100644 index 000000000..50889687f --- /dev/null +++ b/test/LLVMDialect/InstCombine/salvage-dbg-declare.ll.mlir @@ -0,0 +1,19 @@ +#di_basic_type = #llvm.di_basic_type +#di_file = #llvm.di_file<"b" in "c"> +#di_subroutine_type = #llvm.di_subroutine_type<> +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C99, file = #di_file, producer = "clang version", isOptimized = true, emissionKind = Full> +#di_composite_type = #llvm.di_composite_type +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "a", file = #di_file, line = 232, scopeLine = 234, subprogramFlags = "LocalToUnit|Definition|Optimized", type = #di_subroutine_type> +#di_lexical_block = #llvm.di_lexical_block +#di_lexical_block1 = #llvm.di_lexical_block +#di_local_variable = #llvm.di_local_variable +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bar(!llvm.ptr) -> i32 + llvm.func internal @foo() -> i32 attributes {dso_local, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i64) -> !llvm.ptr + llvm.intr.dbg.declare #di_local_variable = %1 : !llvm.ptr + %2 = llvm.call @bar(%1) : (!llvm.ptr) -> i32 + llvm.unreachable + } +} diff --git a/test/LLVMDialect/InstCombine/saturating-add-sub.ll.mlir b/test/LLVMDialect/InstCombine/saturating-add-sub.ll.mlir new file mode 100644 index 000000000..91cfa39ff --- /dev/null +++ b/test/LLVMDialect/InstCombine/saturating-add-sub.ll.mlir @@ -0,0 +1,1324 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_scalar_uadd_canonical(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.intr.uadd.sat(%0, %arg0) : (i8, i8) -> i8 + llvm.return %1 : i8 + } + llvm.func @test_vector_uadd_canonical(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[10, 20]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.intr.uadd.sat(%0, %arg0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @test_scalar_sadd_canonical(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-10 : i8) : i8 + %1 = llvm.intr.sadd.sat(%0, %arg0) : (i8, i8) -> i8 + llvm.return %1 : i8 + } + llvm.func @test_vector_sadd_canonical(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[10, -20]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.intr.sadd.sat(%0, %arg0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @test_scalar_uadd_combine(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.intr.uadd.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.uadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_uadd_combine(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<20> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.uadd.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.intr.uadd.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_vector_uadd_combine_non_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[10, 20]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[30, 40]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.uadd.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.intr.uadd.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_uadd_overflow(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(-56 : i8) : i8 + %2 = llvm.intr.uadd.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.uadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_uadd_overflow(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<100> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-56> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.uadd.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.intr.uadd.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_sadd_both_positive(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.intr.sadd.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.sadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_sadd_both_positive(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<20> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.sadd.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.intr.sadd.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_sadd_both_negative(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-10 : i8) : i8 + %1 = llvm.mlir.constant(-20 : i8) : i8 + %2 = llvm.intr.sadd.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.sadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_sadd_both_negative(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-20> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.sadd.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.intr.sadd.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_sadd_different_sign(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(-20 : i8) : i8 + %2 = llvm.intr.sadd.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.sadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_scalar_sadd_overflow(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.intr.sadd.sat(%arg0, %0) : (i8, i8) -> i8 + %2 = llvm.intr.sadd.sat(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @test_scalar_uadd_neg_neg(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(-10 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.intr.uadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_uadd_neg_neg(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-10, -20]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.or %arg0, %0 : vector<2xi8> + %3 = llvm.intr.uadd.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_uadd_nneg_nneg(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.intr.uadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_uadd_nneg_nneg(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[10, 20]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.and %arg0, %0 : vector<2xi8> + %3 = llvm.intr.uadd.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_uadd_neg_nneg(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.intr.uadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_uadd_neg_nneg(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[10, 20]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.or %arg0, %0 : vector<2xi8> + %3 = llvm.intr.uadd.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_uadd_never_overflows(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-127 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.intr.uadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_uadd_never_overflows(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.and %arg0, %0 : vector<2xi8> + %3 = llvm.intr.uadd.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_uadd_always_overflows(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.intr.uadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_uadd_always_overflows(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-64> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<64> : vector<2xi8>) : vector<2xi8> + %2 = llvm.or %arg0, %0 : vector<2xi8> + %3 = llvm.intr.uadd.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_sadd_neg_nneg(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.intr.sadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_sadd_neg_nneg(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[10, 20]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.or %arg0, %0 : vector<2xi8> + %3 = llvm.intr.sadd.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_sadd_nneg_neg(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-10 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.intr.sadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_sadd_nneg_neg(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-10, -20]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.and %arg0, %0 : vector<2xi8> + %3 = llvm.intr.sadd.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_sadd_neg_neg(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(-10 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.intr.sadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_sadd_neg_neg(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-10, -20]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.or %arg0, %0 : vector<2xi8> + %3 = llvm.intr.sadd.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_sadd_always_overflows_low(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-120 : i8) : i8 + %1 = llvm.mlir.constant(-10 : i8) : i8 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.intr.sadd.sat(%3, %1) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @test_scalar_sadd_always_overflows_high(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(120 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.icmp "sgt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.intr.sadd.sat(%3, %1) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @test_scalar_uadd_sub_nuw_lost_no_ov(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(9 : i8) : i8 + %2 = llvm.sub %arg0, %0 overflow : i8 + %3 = llvm.intr.uadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_scalar_uadd_urem_no_ov(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(-100 : i8) : i8 + %2 = llvm.urem %arg0, %0 : i8 + %3 = llvm.intr.uadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_scalar_uadd_urem_may_ov(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(-99 : i8) : i8 + %2 = llvm.urem %arg0, %0 : i8 + %3 = llvm.intr.uadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_scalar_uadd_udiv_known_bits(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-66 : i8) : i8 + %1 = llvm.mlir.constant(63 : i8) : i8 + %2 = llvm.udiv %0, %arg0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.intr.uadd.sat(%2, %3) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @test_scalar_sadd_srem_no_ov(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(28 : i8) : i8 + %2 = llvm.srem %arg0, %0 : i8 + %3 = llvm.intr.sadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_scalar_sadd_srem_may_ov(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(29 : i8) : i8 + %2 = llvm.srem %arg0, %0 : i8 + %3 = llvm.intr.sadd.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_scalar_sadd_srem_and_no_ov(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.srem %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.intr.sadd.sat(%2, %3) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @test_scalar_usub_canonical(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.intr.usub.sat(%arg0, %0) : (i8, i8) -> i8 + llvm.return %1 : i8 + } + llvm.func @test_scalar_ssub_canonical(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.intr.ssub.sat(%arg0, %0) : (i8, i8) -> i8 + llvm.return %1 : i8 + } + llvm.func @test_vector_ssub_canonical(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.intr.ssub.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @test_vector_ssub_canonical_min_non_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[10, -10]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.intr.ssub.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @test_scalar_ssub_canonical_min(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.intr.ssub.sat(%arg0, %0) : (i8, i8) -> i8 + llvm.return %1 : i8 + } + llvm.func @test_vector_ssub_canonical_min(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[-128, -10]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.intr.ssub.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @test_scalar_usub_combine(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.usub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_simplify_decrement(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.sub %arg0, %1 : i8 + %4 = llvm.select %2, %0, %3 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @use.i1(i1) + llvm.func @test_simplify_decrement_ne(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + llvm.call @use.i1(%2) : (i1) -> () + %3 = llvm.add %arg0, %1 : i8 + %4 = llvm.select %2, %3, %0 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @test_simplify_decrement_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %3 = llvm.icmp "eq" %arg0, %1 : vector<2xi8> + %4 = llvm.sub %arg0, %2 : vector<2xi8> + %5 = llvm.select %3, %1, %4 : vector<2xi1>, vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @test_simplify_decrement_vec_poison(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.poison : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %3, %6[%7 : i32] : vector<2xi8> + %9 = llvm.icmp "eq" %arg0, %1 : vector<2xi8> + %10 = llvm.sub %arg0, %2 : vector<2xi8> + %11 = llvm.select %9, %8, %10 : vector<2xi1>, vector<2xi8> + llvm.return %11 : vector<2xi8> + } + llvm.func @test_simplify_decrement_invalid_ne(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.sub %arg0, %1 : i8 + %4 = llvm.select %2, %0, %3 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @test_invalid_simplify_sub2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.sub %arg0, %1 : i8 + %4 = llvm.select %2, %0, %3 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @test_invalid_simplify_eq2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "eq" %arg0, %0 : i8 + %4 = llvm.sub %arg0, %1 : i8 + %5 = llvm.select %3, %2, %4 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @test_invalid_simplify_select_1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.sub %arg0, %1 : i8 + %4 = llvm.select %2, %1, %3 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @test_invalid_simplify_other(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.sub %arg1, %1 : i8 + %4 = llvm.select %2, %0, %3 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @test_vector_usub_combine(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<20> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_vector_usub_combine_non_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[10, 20]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[30, 40]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_usub_overflow(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(-56 : i8) : i8 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.usub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_usub_overflow(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<100> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-56> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.usub.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_ssub_both_positive(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.intr.ssub.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.ssub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_ssub_both_positive(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<20> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.ssub.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.intr.ssub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_ssub_both_negative(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-10 : i8) : i8 + %1 = llvm.mlir.constant(-20 : i8) : i8 + %2 = llvm.intr.ssub.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.ssub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_ssub_both_negative(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-20> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.ssub.sat(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.intr.ssub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_ssub_different_sign(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(-20 : i8) : i8 + %2 = llvm.intr.ssub.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.intr.ssub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_scalar_sadd_ssub(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(-20 : i8) : i8 + %2 = llvm.intr.sadd.sat(%0, %arg0) : (i8, i8) -> i8 + %3 = llvm.intr.ssub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_sadd_ssub(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<20> : vector<2xi8>) : vector<2xi8> + %2 = llvm.intr.sadd.sat(%0, %arg0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %3 = llvm.intr.ssub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_ssub_overflow(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.intr.ssub.sat(%arg0, %0) : (i8, i8) -> i8 + %2 = llvm.intr.ssub.sat(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @test_scalar_usub_nneg_neg(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(-10 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.intr.usub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_usub_nneg_neg(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-10, -20]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.and %arg0, %0 : vector<2xi8> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_usub_neg_nneg(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.intr.usub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_usub_neg_nneg(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[10, 20]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.or %arg0, %0 : vector<2xi8> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_usub_nneg_nneg(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.intr.usub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_usub_nneg_nneg(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[10, 20]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.and %arg0, %0 : vector<2xi8> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_usub_never_overflows(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(64 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.intr.usub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_usub_never_overflows(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<64> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<10> : vector<2xi8>) : vector<2xi8> + %2 = llvm.or %arg0, %0 : vector<2xi8> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_usub_always_overflows(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(64 : i8) : i8 + %1 = llvm.mlir.constant(100 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.intr.usub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_usub_always_overflows(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<64> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<100> : vector<2xi8>) : vector<2xi8> + %2 = llvm.and %arg0, %0 : vector<2xi8> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_ssub_neg_neg(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(-10 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.intr.ssub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_ssub_neg_neg(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-10, -20]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.or %arg0, %0 : vector<2xi8> + %3 = llvm.intr.ssub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_ssub_nneg_nneg(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.intr.ssub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_ssub_nneg_nneg(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<127> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[10, 20]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.and %arg0, %0 : vector<2xi8> + %3 = llvm.intr.ssub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_ssub_neg_nneg(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.intr.ssub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_ssub_neg_nneg(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-128> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[10, 20]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.or %arg0, %0 : vector<2xi8> + %3 = llvm.intr.ssub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_ssub_always_overflows_low(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(120 : i8) : i8 + %1 = llvm.mlir.constant(-10 : i8) : i8 + %2 = llvm.icmp "sgt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.intr.ssub.sat(%1, %3) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @test_scalar_ssub_always_overflows_high(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-120 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = llvm.intr.ssub.sat(%1, %3) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @test_scalar_usub_add_nuw_no_ov(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(9 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.intr.usub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_scalar_usub_add_nuw_nsw_no_ov(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(9 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.intr.usub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_scalar_usub_add_nuw_eq(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.add %arg0, %0 overflow : i8 + %2 = llvm.intr.usub.sat(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @test_scalar_usub_add_nuw_may_ov(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.intr.usub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_scalar_usub_urem_must_ov(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.urem %arg0, %0 : i8 + %2 = llvm.intr.usub.sat(%1, %0) : (i8, i8) -> i8 + llvm.return %2 : i8 + } + llvm.func @test_scalar_usub_urem_must_zero(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(9 : i8) : i8 + %2 = llvm.urem %arg0, %0 : i8 + %3 = llvm.intr.usub.sat(%2, %1) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_scalar_usub_add_nuw_known_bits(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.intr.usub.sat(%2, %3) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @test_scalar_usub_add_nuw_inferred(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(9 : i8) : i8 + %2 = llvm.intr.usub.sat(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.add %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @test_vector_usub_add_nuw_no_ov(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<9> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_vector_usub_add_nuw_no_ov_nonsplat1(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[10, 9]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_vector_usub_add_nuw_no_ov_nonsplat1_poison(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<10> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(9 : i8) : i8 + %3 = llvm.mlir.constant(10 : i8) : i8 + %4 = llvm.mlir.undef : vector<3xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<3xi8> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<3xi8> + %11 = llvm.add %arg0, %0 overflow : vector<3xi8> + %12 = llvm.intr.usub.sat(%11, %10) : (vector<3xi8>, vector<3xi8>) -> vector<3xi8> + llvm.return %12 : vector<3xi8> + } + llvm.func @test_vector_usub_add_nuw_no_ov_nonsplat2(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[10, 9]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<9> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_vector_usub_add_nuw_no_ov_nonsplat3(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[10, 9]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.add %arg0, %0 overflow : vector<2xi8> + %2 = llvm.intr.usub.sat(%1, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @test_scalar_ssub_add_nsw_no_ov(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.add %arg0, %0 overflow : i8 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.intr.ssub.sat(%1, %2) : (i8, i8) -> i8 + llvm.return %3 : i8 + } + llvm.func @test_scalar_ssub_add_nsw_may_ov(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.intr.ssub.sat(%2, %3) : (i8, i8) -> i8 + llvm.return %4 : i8 + } + llvm.func @test_vector_ssub_add_nsw_no_ov_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %1 = llvm.add %arg0, %0 overflow : vector<2xi8> + %2 = llvm.and %arg1, %0 : vector<2xi8> + %3 = llvm.intr.ssub.sat(%1, %2) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_vector_ssub_add_nsw_no_ov_nonsplat1(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[7, 6]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = llvm.and %arg1, %1 : vector<2xi8> + %4 = llvm.intr.ssub.sat(%2, %3) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @test_vector_ssub_add_nsw_no_ov_nonsplat2(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[7, 8]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = llvm.and %arg1, %1 : vector<2xi8> + %4 = llvm.intr.ssub.sat(%2, %3) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @test_vector_ssub_add_nsw_no_ov_nonsplat3(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[7, 6]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.add %arg0, %0 overflow : vector<2xi8> + %2 = llvm.and %arg1, %0 : vector<2xi8> + %3 = llvm.intr.ssub.sat(%1, %2) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @test_scalar_usub_add(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.usub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.add %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @test_scalar_usub_add_extra_use(%arg0: i8, %arg1: i8, %arg2: !llvm.ptr) -> i8 { + %0 = llvm.intr.usub.sat(%arg0, %arg1) : (i8, i8) -> i8 + llvm.store %0, %arg2 {alignment = 1 : i64} : i8, !llvm.ptr + %1 = llvm.add %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @test_scalar_usub_add_commuted(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.usub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.add %arg1, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @test_scalar_usub_add_commuted_wrong(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.usub.sat(%arg1, %arg0) : (i8, i8) -> i8 + %1 = llvm.add %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @test_scalar_usub_add_const(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.intr.usub.sat(%arg0, %0) : (i8, i8) -> i8 + %2 = llvm.add %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @test_scalar_usub_sub(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.usub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @test_scalar_usub_sub_extra_use(%arg0: i8, %arg1: i8, %arg2: !llvm.ptr) -> i8 { + %0 = llvm.intr.usub.sat(%arg0, %arg1) : (i8, i8) -> i8 + llvm.store %0, %arg2 {alignment = 1 : i64} : i8, !llvm.ptr + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @test_vector_usub_sub(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.intr.usub.sat(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %1 = llvm.sub %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @test_scalar_usub_sub_wrong(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.usub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.sub %arg1, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @test_scalar_usub_sub_wrong2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.usub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @test_scalar_uadd_sub(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.uadd.sat(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @test_scalar_uadd_sub_extra_use(%arg0: i8, %arg1: i8, %arg2: !llvm.ptr) -> i8 { + %0 = llvm.intr.uadd.sat(%arg0, %arg1) : (i8, i8) -> i8 + llvm.store %0, %arg2 {alignment = 1 : i64} : i8, !llvm.ptr + %1 = llvm.sub %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @test_scalar_uadd_sub_commuted(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.uadd.sat(%arg1, %arg0) : (i8, i8) -> i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @test_scalar_uadd_sub_commuted_wrong(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.uadd.sat(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.sub %arg1, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @test_scalar_uadd_sub_const(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.intr.uadd.sat(%arg0, %0) : (i8, i8) -> i8 + %2 = llvm.sub %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @scalar_uadd_eq_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.uadd.sat(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @scalar_uadd_ne_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.uadd.sat(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @scalar_usub_eq_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.usub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @scalar_usub_ne_zero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.intr.usub.sat(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @uadd_sat(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.add %arg1, %arg0 : i32 + %3 = llvm.icmp "ult" %1, %arg1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uadd_sat_nonstrict(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.add %arg1, %arg0 : i32 + %3 = llvm.icmp "ule" %1, %arg1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uadd_sat_commute_add(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.urem %0, %arg0 : i32 + %3 = llvm.xor %2, %1 : i32 + %4 = llvm.add %2, %arg1 : i32 + %5 = llvm.icmp "ult" %3, %arg1 : i32 + %6 = llvm.select %5, %1, %4 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @uadd_sat_ugt(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2442 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %arg1, %0 : i32 + %3 = llvm.xor %arg0, %1 : i32 + %4 = llvm.add %2, %arg0 : i32 + %5 = llvm.icmp "ugt" %2, %3 : i32 + %6 = llvm.select %5, %1, %4 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @uadd_sat_uge(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2442 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %arg1, %0 : i32 + %3 = llvm.xor %arg0, %1 : i32 + %4 = llvm.add %2, %arg0 : i32 + %5 = llvm.icmp "uge" %2, %3 : i32 + %6 = llvm.select %5, %1, %4 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @uadd_sat_ugt_commute_add(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[2442, 4242]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[42, 43]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.sdiv %arg1, %0 : vector<2xi32> + %4 = llvm.srem %1, %arg0 : vector<2xi32> + %5 = llvm.xor %4, %2 : vector<2xi32> + %6 = llvm.add %4, %3 : vector<2xi32> + %7 = llvm.icmp "ugt" %3, %5 : vector<2xi32> + %8 = llvm.select %7, %2, %6 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @uadd_sat_commute_select(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2442 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %arg1, %0 : i32 + %3 = llvm.xor %arg0, %1 : i32 + %4 = llvm.add %2, %arg0 : i32 + %5 = llvm.icmp "ult" %2, %3 : i32 + %6 = llvm.select %5, %4, %1 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @uadd_sat_commute_select_nonstrict(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2442 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %arg1, %0 : i32 + %3 = llvm.xor %arg0, %1 : i32 + %4 = llvm.add %2, %arg0 : i32 + %5 = llvm.icmp "ule" %2, %3 : i32 + %6 = llvm.select %5, %4, %1 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @uadd_sat_commute_select_commute_add(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(2442 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.urem %0, %arg0 : i32 + %4 = llvm.sdiv %arg1, %1 : i32 + %5 = llvm.xor %3, %2 : i32 + %6 = llvm.add %3, %4 : i32 + %7 = llvm.icmp "ult" %4, %5 : i32 + %8 = llvm.select %7, %6, %2 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @uadd_sat_commute_select_ugt(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.xor %arg0, %0 : vector<2xi32> + %2 = llvm.add %arg1, %arg0 : vector<2xi32> + %3 = llvm.icmp "ugt" %1, %arg1 : vector<2xi32> + %4 = llvm.select %3, %2, %0 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @uadd_sat_commute_select_ugt_commute_add(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.srem %0, %arg0 : i32 + %3 = llvm.xor %2, %1 : i32 + %4 = llvm.add %2, %arg1 : i32 + %5 = llvm.icmp "ugt" %3, %arg1 : i32 + %6 = llvm.select %5, %4, %1 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @not_uadd_sat(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.icmp "ugt" %arg0, %1 : i32 + %4 = llvm.select %3, %2, %arg1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @not_uadd_sat2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = llvm.icmp "ugt" %arg0, %1 : i32 + %5 = llvm.select %4, %3, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @uadd_sat_not(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.add %1, %arg1 : i32 + %3 = llvm.icmp "ult" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uadd_sat_not_nonstrict(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.add %1, %arg1 : i32 + %3 = llvm.icmp "ule" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uadd_sat_not_commute_add(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.srem %0, %arg0 : i32 + %3 = llvm.urem %0, %arg1 : i32 + %4 = llvm.xor %2, %1 : i32 + %5 = llvm.add %3, %4 : i32 + %6 = llvm.icmp "ult" %2, %3 : i32 + %7 = llvm.select %6, %1, %5 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @uadd_sat_not_ugt(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.add %1, %arg1 : i32 + %3 = llvm.icmp "ugt" %arg1, %arg0 : i32 + %4 = llvm.select %3, %0, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uadd_sat_not_uge(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.add %1, %arg1 : i32 + %3 = llvm.icmp "uge" %arg1, %arg0 : i32 + %4 = llvm.select %3, %0, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uadd_sat_not_ugt_commute_add(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[2442, 4242]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sdiv %arg1, %0 : vector<2xi32> + %3 = llvm.xor %arg0, %1 : vector<2xi32> + %4 = llvm.add %2, %3 : vector<2xi32> + %5 = llvm.icmp "ugt" %2, %arg0 : vector<2xi32> + %6 = llvm.select %5, %1, %4 : vector<2xi1>, vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @uadd_sat_not_commute_select(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.add %1, %arg1 : i32 + %3 = llvm.icmp "ult" %arg1, %arg0 : i32 + %4 = llvm.select %3, %2, %0 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uadd_sat_not_commute_select_nonstrict(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.add %1, %arg1 : i32 + %3 = llvm.icmp "ule" %arg1, %arg0 : i32 + %4 = llvm.select %3, %2, %0 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uadd_sat_not_commute_select_commute_add(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sdiv %0, %arg1 : i32 + %3 = llvm.xor %arg0, %1 : i32 + %4 = llvm.add %2, %3 : i32 + %5 = llvm.icmp "ult" %2, %arg0 : i32 + %6 = llvm.select %5, %4, %1 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @uadd_sat_not_commute_select_ugt(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, -42]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[12, 412]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.urem %0, %arg0 : vector<2xi32> + %4 = llvm.srem %1, %arg1 : vector<2xi32> + %5 = llvm.xor %3, %2 : vector<2xi32> + %6 = llvm.add %4, %5 : vector<2xi32> + %7 = llvm.icmp "ugt" %3, %4 : vector<2xi32> + %8 = llvm.select %7, %6, %2 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @uadd_sat_not_commute_select_ugt_commute_add(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.add %1, %arg1 : i32 + %3 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %4 = llvm.select %3, %2, %0 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uadd_sat_not_commute_select_uge_commute_add(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.add %1, %arg1 : i32 + %3 = llvm.icmp "uge" %arg0, %arg1 : i32 + %4 = llvm.select %3, %2, %0 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uadd_sat_constant(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-43 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = llvm.icmp "ugt" %arg0, %1 : i32 + %5 = llvm.select %4, %2, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @uadd_sat_constant_commute(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-43 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = llvm.icmp "ult" %arg0, %1 : i32 + %5 = llvm.select %4, %3, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @uadd_sat_canon(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.icmp "ult" %1, %arg0 : i32 + %3 = llvm.select %2, %0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @uadd_sat_canon_y(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.icmp "ult" %1, %arg1 : i32 + %3 = llvm.select %2, %0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @uadd_sat_canon_nuw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 overflow : i32 + %2 = llvm.icmp "ult" %1, %arg0 : i32 + %3 = llvm.select %2, %0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @uadd_sat_canon_y_nuw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 overflow : i32 + %2 = llvm.icmp "ult" %1, %arg1 : i32 + %3 = llvm.select %2, %0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @uadd_sat_constant_vec(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<42> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-43> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %3 = llvm.add %arg0, %0 : vector<4xi32> + %4 = llvm.icmp "ugt" %arg0, %1 : vector<4xi32> + %5 = llvm.select %4, %2, %3 : vector<4xi1>, vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @uadd_sat_constant_vec_commute(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<42> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-43> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %3 = llvm.add %arg0, %0 : vector<4xi32> + %4 = llvm.icmp "ult" %arg0, %1 : vector<4xi32> + %5 = llvm.select %4, %3, %2 : vector<4xi1>, vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @uadd_sat_constant_vec_commute_undefs(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(-43 : i32) : i32 + %12 = llvm.mlir.undef : vector<4xi32> + %13 = llvm.mlir.constant(0 : i32) : i32 + %14 = llvm.insertelement %11, %12[%13 : i32] : vector<4xi32> + %15 = llvm.mlir.constant(1 : i32) : i32 + %16 = llvm.insertelement %11, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(2 : i32) : i32 + %18 = llvm.insertelement %0, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(3 : i32) : i32 + %20 = llvm.insertelement %11, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(-1 : i32) : i32 + %22 = llvm.mlir.undef : vector<4xi32> + %23 = llvm.mlir.constant(0 : i32) : i32 + %24 = llvm.insertelement %21, %22[%23 : i32] : vector<4xi32> + %25 = llvm.mlir.constant(1 : i32) : i32 + %26 = llvm.insertelement %0, %24[%25 : i32] : vector<4xi32> + %27 = llvm.mlir.constant(2 : i32) : i32 + %28 = llvm.insertelement %21, %26[%27 : i32] : vector<4xi32> + %29 = llvm.mlir.constant(3 : i32) : i32 + %30 = llvm.insertelement %21, %28[%29 : i32] : vector<4xi32> + %31 = llvm.add %arg0, %10 : vector<4xi32> + %32 = llvm.icmp "ult" %arg0, %20 : vector<4xi32> + %33 = llvm.select %32, %31, %30 : vector<4xi1>, vector<4xi32> + llvm.return %33 : vector<4xi32> + } + llvm.func @get_i32() -> i32 + llvm.func @get_v2i8() -> vector<2xi8> + llvm.func @unsigned_sat_variable_using_min_add(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @get_i32() : () -> i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.icmp "ult" %arg0, %2 : i32 + %4 = llvm.select %3, %arg0, %2 : i1, i32 + %5 = llvm.add %4, %1 : i32 + llvm.return %5 : i32 + } + llvm.func @unsigned_sat_variable_using_min_commute_add(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @get_i32() : () -> i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.icmp "ult" %arg0, %2 : i32 + %4 = llvm.select %3, %arg0, %2 : i1, i32 + %5 = llvm.add %1, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @unsigned_sat_variable_using_min_commute_select(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @get_v2i8() : () -> vector<2xi8> + %2 = llvm.xor %1, %0 : vector<2xi8> + %3 = llvm.icmp "ult" %2, %arg0 : vector<2xi8> + %4 = llvm.select %3, %2, %arg0 : vector<2xi1>, vector<2xi8> + %5 = llvm.add %4, %1 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @unsigned_sat_variable_using_min_commute_add_select(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.call @get_v2i8() : () -> vector<2xi8> + %2 = llvm.xor %1, %0 : vector<2xi8> + %3 = llvm.icmp "ult" %2, %arg0 : vector<2xi8> + %4 = llvm.select %3, %2, %arg0 : vector<2xi1>, vector<2xi8> + %5 = llvm.add %1, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @unsigned_sat_variable_using_wrong_min(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @get_i32() : () -> i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %2 : i32 + %4 = llvm.select %3, %arg0, %2 : i1, i32 + %5 = llvm.add %1, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @unsigned_sat_variable_using_wrong_value(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @get_i32() : () -> i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.icmp "ult" %arg0, %2 : i32 + %4 = llvm.select %3, %arg0, %2 : i1, i32 + %5 = llvm.add %arg1, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @unsigned_sat_constant_using_min(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-43 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @unsigned_sat_constant_using_min_splat(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<14> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-15> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "ult" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %arg0, %0 : vector<2xi1>, vector<2xi32> + %4 = llvm.add %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @unsigned_sat_constant_using_min_wrong_constant(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-42 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i32 + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @uadd_sat_via_add(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.icmp "ult" %1, %arg1 : i32 + %3 = llvm.select %2, %0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @uadd_sat_via_add_nonstrict(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.icmp "ule" %1, %arg1 : i32 + %3 = llvm.select %2, %0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @uadd_sat_via_add_swapped_select(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.icmp "uge" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %0 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @uadd_sat_via_add_swapped_select_strict(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.icmp "ugt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %0 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @uadd_sat_via_add_swapped_cmp(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.icmp "ugt" %arg1, %1 : i32 + %3 = llvm.select %2, %0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @uadd_sat_via_add_swapped_cmp_nonstrict(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.icmp "uge" %arg1, %1 : i32 + %3 = llvm.select %2, %0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @uadd_sat_via_add_swapped_cmp_nonstric(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.icmp "ule" %arg1, %1 : i32 + %3 = llvm.select %2, %1, %0 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @uadd_sat_via_add_swapped_cmp_select_nonstrict(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.add %arg0, %arg1 : i32 + %2 = llvm.icmp "ult" %arg1, %1 : i32 + %3 = llvm.select %2, %1, %0 : i1, i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/scalable-bitcast-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/scalable-bitcast-inseltpoison.ll.mlir new file mode 100644 index 000000000..f4a9c6688 --- /dev/null +++ b/test/LLVMDialect/InstCombine/scalable-bitcast-inseltpoison.ll.mlir @@ -0,0 +1,9 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bitcast_of_insert_i8_i16(%arg0: i16) -> !llvm.vec { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec + %3 = llvm.bitcast %2 : !llvm.vec to !llvm.vec + llvm.return %3 : !llvm.vec + } +} diff --git a/test/LLVMDialect/InstCombine/scalable-bitcast.ll.mlir b/test/LLVMDialect/InstCombine/scalable-bitcast.ll.mlir new file mode 100644 index 000000000..be2fe77a2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/scalable-bitcast.ll.mlir @@ -0,0 +1,9 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bitcast_of_insert_i8_i16(%arg0: i16) -> !llvm.vec { + %0 = llvm.mlir.undef : !llvm.vec + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec + %3 = llvm.bitcast %2 : !llvm.vec to !llvm.vec + llvm.return %3 : !llvm.vec + } +} diff --git a/test/LLVMDialect/InstCombine/scalable-cast-of-alloc.ll.mlir b/test/LLVMDialect/InstCombine/scalable-cast-of-alloc.ll.mlir new file mode 100644 index 000000000..a3b6cbfc8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/scalable-cast-of-alloc.ll.mlir @@ -0,0 +1,186 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fixed_array16i32_to_scalable4i32(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.vec + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : !llvm.vec + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : !llvm.vec + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : !llvm.vec + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : !llvm.vec + %11 = llvm.alloca %0 x !llvm.array<16 x i32> {alignment = 16 : i64} : (i32) -> !llvm.ptr + llvm.store volatile %10, %11 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + %12 = llvm.load volatile %11 {alignment = 16 : i64} : !llvm.ptr -> !llvm.vec + llvm.store %12, %arg0 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + llvm.return + } + llvm.func @scalable4i32_to_fixed16i32(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<16xi32>) : vector<16xi32> + %3 = llvm.alloca %0 x !llvm.vec {alignment = 16 : i64} : (i32) -> !llvm.ptr + llvm.store %2, %3 {alignment = 16 : i64} : vector<16xi32>, !llvm.ptr + %4 = llvm.load volatile %3 {alignment = 16 : i64} : !llvm.ptr -> vector<16xi32> + llvm.store %4, %arg0 {alignment = 16 : i64} : vector<16xi32>, !llvm.ptr + llvm.return + } + llvm.func @fixed16i32_to_scalable4i32(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.vec + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : !llvm.vec + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : !llvm.vec + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : !llvm.vec + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : !llvm.vec + %11 = llvm.alloca %0 x vector<16xi32> {alignment = 16 : i64} : (i32) -> !llvm.ptr + llvm.store volatile %10, %11 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + %12 = llvm.load volatile %11 {alignment = 16 : i64} : !llvm.ptr -> !llvm.vec + llvm.store %12, %arg0 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + llvm.return + } + llvm.func @scalable16i32_to_fixed16i32(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<16xi32>) : vector<16xi32> + %3 = llvm.alloca %0 x !llvm.vec {alignment = 16 : i64} : (i32) -> !llvm.ptr + llvm.store volatile %2, %3 {alignment = 16 : i64} : vector<16xi32>, !llvm.ptr + %4 = llvm.load volatile %3 {alignment = 16 : i64} : !llvm.ptr -> vector<16xi32> + llvm.store %4, %arg0 {alignment = 16 : i64} : vector<16xi32>, !llvm.ptr + llvm.return + } + llvm.func @scalable32i32_to_scalable16i32(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.vec + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : !llvm.vec + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : !llvm.vec + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : !llvm.vec + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : !llvm.vec + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %1, %10[%11 : i32] : !llvm.vec + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : !llvm.vec + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : !llvm.vec + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %1, %16[%17 : i32] : !llvm.vec + %19 = llvm.mlir.constant(8 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : !llvm.vec + %21 = llvm.mlir.constant(9 : i32) : i32 + %22 = llvm.insertelement %1, %20[%21 : i32] : !llvm.vec + %23 = llvm.mlir.constant(10 : i32) : i32 + %24 = llvm.insertelement %1, %22[%23 : i32] : !llvm.vec + %25 = llvm.mlir.constant(11 : i32) : i32 + %26 = llvm.insertelement %1, %24[%25 : i32] : !llvm.vec + %27 = llvm.mlir.constant(12 : i32) : i32 + %28 = llvm.insertelement %1, %26[%27 : i32] : !llvm.vec + %29 = llvm.mlir.constant(13 : i32) : i32 + %30 = llvm.insertelement %1, %28[%29 : i32] : !llvm.vec + %31 = llvm.mlir.constant(14 : i32) : i32 + %32 = llvm.insertelement %1, %30[%31 : i32] : !llvm.vec + %33 = llvm.mlir.constant(15 : i32) : i32 + %34 = llvm.insertelement %1, %32[%33 : i32] : !llvm.vec + %35 = llvm.alloca %0 x !llvm.vec {alignment = 16 : i64} : (i32) -> !llvm.ptr + llvm.store volatile %34, %35 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + %36 = llvm.load volatile %35 {alignment = 16 : i64} : !llvm.ptr -> !llvm.vec + llvm.store %36, %arg0 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + llvm.return + } + llvm.func @scalable32i16_to_scalable16i32(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.vec + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : !llvm.vec + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : !llvm.vec + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : !llvm.vec + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : !llvm.vec + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %1, %10[%11 : i32] : !llvm.vec + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : !llvm.vec + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : !llvm.vec + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %1, %16[%17 : i32] : !llvm.vec + %19 = llvm.mlir.constant(8 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : !llvm.vec + %21 = llvm.mlir.constant(9 : i32) : i32 + %22 = llvm.insertelement %1, %20[%21 : i32] : !llvm.vec + %23 = llvm.mlir.constant(10 : i32) : i32 + %24 = llvm.insertelement %1, %22[%23 : i32] : !llvm.vec + %25 = llvm.mlir.constant(11 : i32) : i32 + %26 = llvm.insertelement %1, %24[%25 : i32] : !llvm.vec + %27 = llvm.mlir.constant(12 : i32) : i32 + %28 = llvm.insertelement %1, %26[%27 : i32] : !llvm.vec + %29 = llvm.mlir.constant(13 : i32) : i32 + %30 = llvm.insertelement %1, %28[%29 : i32] : !llvm.vec + %31 = llvm.mlir.constant(14 : i32) : i32 + %32 = llvm.insertelement %1, %30[%31 : i32] : !llvm.vec + %33 = llvm.mlir.constant(15 : i32) : i32 + %34 = llvm.insertelement %1, %32[%33 : i32] : !llvm.vec + %35 = llvm.alloca %0 x !llvm.vec {alignment = 16 : i64} : (i32) -> !llvm.ptr + llvm.store volatile %34, %35 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + %36 = llvm.load volatile %35 {alignment = 16 : i64} : !llvm.ptr -> !llvm.vec + llvm.store %36, %arg0 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + llvm.return + } + llvm.func @scalable32i16_to_scalable16i32_multiuse(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : !llvm.vec + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : !llvm.vec + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : !llvm.vec + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : !llvm.vec + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : !llvm.vec + %11 = llvm.mlir.constant(4 : i32) : i32 + %12 = llvm.insertelement %1, %10[%11 : i32] : !llvm.vec + %13 = llvm.mlir.constant(5 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : !llvm.vec + %15 = llvm.mlir.constant(6 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : !llvm.vec + %17 = llvm.mlir.constant(7 : i32) : i32 + %18 = llvm.insertelement %1, %16[%17 : i32] : !llvm.vec + %19 = llvm.mlir.constant(8 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : !llvm.vec + %21 = llvm.mlir.constant(9 : i32) : i32 + %22 = llvm.insertelement %1, %20[%21 : i32] : !llvm.vec + %23 = llvm.mlir.constant(10 : i32) : i32 + %24 = llvm.insertelement %1, %22[%23 : i32] : !llvm.vec + %25 = llvm.mlir.constant(11 : i32) : i32 + %26 = llvm.insertelement %1, %24[%25 : i32] : !llvm.vec + %27 = llvm.mlir.constant(12 : i32) : i32 + %28 = llvm.insertelement %1, %26[%27 : i32] : !llvm.vec + %29 = llvm.mlir.constant(13 : i32) : i32 + %30 = llvm.insertelement %1, %28[%29 : i32] : !llvm.vec + %31 = llvm.mlir.constant(14 : i32) : i32 + %32 = llvm.insertelement %1, %30[%31 : i32] : !llvm.vec + %33 = llvm.mlir.constant(15 : i32) : i32 + %34 = llvm.insertelement %1, %32[%33 : i32] : !llvm.vec + %35 = llvm.alloca %0 x !llvm.vec {alignment = 16 : i64} : (i32) -> !llvm.ptr + llvm.store volatile %34, %35 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + %36 = llvm.load volatile %35 {alignment = 16 : i64} : !llvm.ptr -> !llvm.vec + llvm.store %36, %arg0 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + %37 = llvm.load volatile %35 {alignment = 16 : i64} : !llvm.ptr -> !llvm.vec + llvm.store %37, %arg1 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/scalable-const-fp-splat.ll.mlir b/test/LLVMDialect/InstCombine/scalable-const-fp-splat.ll.mlir new file mode 100644 index 000000000..34c0c53af --- /dev/null +++ b/test/LLVMDialect/InstCombine/scalable-const-fp-splat.ll.mlir @@ -0,0 +1,14 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @shrink_splat_scalable_extend(%arg0: !llvm.vec) -> !llvm.vec { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %2 = llvm.mlir.undef : !llvm.vec + %3 = llvm.insertelement %1, %2[%0 : i32] : !llvm.vec + %4 = llvm.shufflevector %3, %2 [0, 0] : !llvm.vec + %5 = llvm.fpext %arg0 : !llvm.vec to !llvm.vec + %6 = llvm.fpext %4 : vector<[2]xf32> to !llvm.vec + %7 = llvm.fadd %5, %6 : !llvm.vec + %8 = llvm.fptrunc %7 : !llvm.vec to !llvm.vec + llvm.return %8 : !llvm.vec + } +} diff --git a/test/LLVMDialect/InstCombine/scalable-select.ll.mlir b/test/LLVMDialect/InstCombine/scalable-select.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/scalable-trunc.ll.mlir b/test/LLVMDialect/InstCombine/scalable-trunc.ll.mlir index dd0eba9f1..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/scalable-trunc.ll.mlir +++ b/test/LLVMDialect/InstCombine/scalable-trunc.ll.mlir @@ -1,19 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.vec): // no predecessors - %0 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @llvm.aarch64.sve.ptrue.nxv16i1, fastmathFlags = #llvm.fastmath<>} : (i32) -> !llvm.vec - %2 = "llvm.bitcast"(%arg1) : (!llvm.vec) -> !llvm.vec - %3 = "llvm.call"(%1) {callee = @llvm.aarch64.sve.convert.from.svbool.nxv2i1, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec) -> !llvm.vec - %4 = "llvm.trunc"(%2) : (!llvm.vec) -> !llvm.vec - "llvm.call"(%4, %3, %arg0) {callee = @llvm.aarch64.sve.st1.nxv2i32, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec, !llvm.vec, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "trunc_nxv2i64_to_nxv2i32", type = !llvm.func, vec)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.aarch64.sve.st1.nxv2i32", type = !llvm.func, vec, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.aarch64.sve.convert.from.svbool.nxv2i1", type = !llvm.func (vec)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.aarch64.sve.ptrue.nxv16i1", type = !llvm.func (i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/scalable-vector-array.ll.mlir b/test/LLVMDialect/InstCombine/scalable-vector-array.ll.mlir new file mode 100644 index 000000000..77794be35 --- /dev/null +++ b/test/LLVMDialect/InstCombine/scalable-vector-array.ll.mlir @@ -0,0 +1,14 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @load(%arg0: !llvm.ptr) -> !llvm.vec { + %0 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> !llvm.array<2 x vec> + %1 = llvm.extractvalue %0[1] : !llvm.array<2 x vec> + llvm.return %1 : !llvm.vec + } + llvm.func @store(%arg0: !llvm.ptr, %arg1: !llvm.vec, %arg2: !llvm.vec) { + %0 = llvm.mlir.poison : !llvm.array<2 x vec> + %1 = llvm.insertvalue %arg1, %0[0] : !llvm.array<2 x vec> + %2 = llvm.insertvalue %arg2, %1[1] : !llvm.array<2 x vec> + llvm.store %2, %arg0 {alignment = 16 : i64} : !llvm.array<2 x vec>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/scalable-vector-struct.ll.mlir b/test/LLVMDialect/InstCombine/scalable-vector-struct.ll.mlir new file mode 100644 index 000000000..b2ccb0615 --- /dev/null +++ b/test/LLVMDialect/InstCombine/scalable-vector-struct.ll.mlir @@ -0,0 +1,14 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @load(%arg0: !llvm.ptr) -> !llvm.vec { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> !llvm.struct<"struct.test", (vec, vec)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<"struct.test", (vec, vec)> + llvm.return %1 : !llvm.vec + } + llvm.func @store(%arg0: !llvm.ptr, %arg1: !llvm.vec, %arg2: !llvm.vec) { + %0 = llvm.mlir.undef : !llvm.struct<"struct.test", (vec, vec)> + %1 = llvm.insertvalue %arg1, %0[0] : !llvm.struct<"struct.test", (vec, vec)> + %2 = llvm.insertvalue %arg2, %1[1] : !llvm.struct<"struct.test", (vec, vec)> + llvm.store %2, %arg0 {alignment = 4 : i64} : !llvm.struct<"struct.test", (vec, vec)>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/scalarization-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/scalarization-inseltpoison.ll.mlir new file mode 100644 index 000000000..0c9813105 --- /dev/null +++ b/test/LLVMDialect/InstCombine/scalarization-inseltpoison.ll.mlir @@ -0,0 +1,220 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @extract_load(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> vector<4xi32> + %2 = llvm.extractelement %1[%0 : i32] : vector<4xi32> + llvm.return %2 : i32 + } + llvm.func @extract_load_fp(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 32 : i64} : !llvm.ptr -> vector<4xf64> + %2 = llvm.extractelement %1[%0 : i32] : vector<4xf64> + llvm.return %2 : f64 + } + llvm.func @extract_load_volatile(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.load volatile %arg0 {alignment = 32 : i64} : !llvm.ptr -> vector<4xf64> + %2 = llvm.extractelement %1[%0 : i32] : vector<4xf64> + llvm.return %2 : f64 + } + llvm.func @extract_load_extra_use(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> vector<4xf64> + %2 = llvm.extractelement %1[%0 : i32] : vector<4xf64> + llvm.store %1, %arg1 {alignment = 32 : i64} : vector<4xf64>, !llvm.ptr + llvm.return %2 : f64 + } + llvm.func @extract_load_variable_index(%arg0: !llvm.ptr, %arg1: i32) -> f64 { + %0 = llvm.load %arg0 {alignment = 32 : i64} : !llvm.ptr -> vector<4xf64> + %1 = llvm.extractelement %0[%arg1 : i32] : vector<4xf64> + llvm.return %1 : f64 + } + llvm.func @scalarize_phi(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(dense<2.330000e+00> : vector<4xf32>) : vector<4xf32> + %5 = llvm.load volatile %arg1 {alignment = 4 : i64} : !llvm.ptr -> f32 + %6 = llvm.insertelement %5, %0[%1 : i32] : vector<4xf32> + %7 = llvm.shufflevector %6, %0 [0, 0, 0, 0] : vector<4xf32> + %8 = llvm.insertelement %2, %0[%1 : i32] : vector<4xf32> + llvm.br ^bb1(%7, %1 : vector<4xf32>, i32) + ^bb1(%9: vector<4xf32>, %10: i32): // 2 preds: ^bb0, ^bb2 + %11 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %12 = llvm.icmp "ne" %10, %11 : i32 + llvm.cond_br %12, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %13 = llvm.extractelement %9[%3 : i32] : vector<4xf32> + llvm.store volatile %13, %arg1 {alignment = 4 : i64} : f32, !llvm.ptr + %14 = llvm.fmul %9, %4 : vector<4xf32> + %15 = llvm.add %10, %3 overflow : i32 + llvm.br ^bb1(%14, %15 : vector<4xf32>, i32) + ^bb3: // pred: ^bb1 + llvm.return + } + llvm.func @extract_element_binop_splat_constant_index(%arg0: vector<4xf32>) -> f32 { + %0 = llvm.mlir.constant(dense<2.330000e+00> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.fadd %arg0, %0 : vector<4xf32> + %3 = llvm.extractelement %2[%1 : i32] : vector<4xf32> + llvm.return %3 : f32 + } + llvm.func @extract_element_binop_splat_with_undef_constant_index(%arg0: vector<2xf64>) -> f64 { + %0 = llvm.mlir.undef : f64 + %1 = llvm.mlir.constant(4.200000e+01 : f64) : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.mlir.constant(0 : i32) : i32 + %8 = llvm.fdiv %6, %arg0 : vector<2xf64> + %9 = llvm.extractelement %8[%7 : i32] : vector<2xf64> + llvm.return %9 : f64 + } + llvm.func @extract_element_binop_nonsplat_constant_index(%arg0: vector<2xf32>) -> f32 { + %0 = llvm.mlir.constant(dense<[4.200000e+01, 4.300000e+01]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.fmul %arg0, %0 : vector<2xf32> + %3 = llvm.extractelement %2[%1 : i32] : vector<2xf32> + llvm.return %3 : f32 + } + llvm.func @extract_element_binop_splat_variable_index(%arg0: vector<4xi8>, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(dense<42> : vector<4xi8>) : vector<4xi8> + %1 = llvm.sdiv %arg0, %0 : vector<4xi8> + %2 = llvm.extractelement %1[%arg1 : i32] : vector<4xi8> + llvm.return %2 : i8 + } + llvm.func @extract_element_binop_splat_with_undef_variable_index(%arg0: vector<4xi8>, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<4xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi8> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi8> + %11 = llvm.mul %arg0, %10 : vector<4xi8> + %12 = llvm.extractelement %11[%arg1 : i32] : vector<4xi8> + llvm.return %12 : i8 + } + llvm.func @extract_element_binop_nonsplat_variable_index(%arg0: vector<4xi8>, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.mlir.constant(4 : i8) : i8 + %4 = llvm.mlir.undef : vector<4xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xi8> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xi8> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xi8> + %13 = llvm.lshr %arg0, %12 : vector<4xi8> + %14 = llvm.extractelement %13[%arg1 : i32] : vector<4xi8> + llvm.return %14 : i8 + } + llvm.func @extract_element_load(%arg0: vector<4xf32>, %arg1: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.load %arg1 {alignment = 16 : i64} : !llvm.ptr -> vector<4xf32> + %2 = llvm.fadd %arg0, %1 : vector<4xf32> + %3 = llvm.extractelement %2[%0 : i32] : vector<4xf32> + llvm.return %3 : f32 + } + llvm.func @extract_element_multi_Use_load(%arg0: vector<4xf32>, %arg1: !llvm.ptr, %arg2: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.load %arg1 {alignment = 16 : i64} : !llvm.ptr -> vector<4xf32> + llvm.store %1, %arg2 {alignment = 16 : i64} : vector<4xf32>, !llvm.ptr + %2 = llvm.fadd %arg0, %1 : vector<4xf32> + %3 = llvm.extractelement %2[%0 : i32] : vector<4xf32> + llvm.return %3 : f32 + } + llvm.func @extract_element_variable_index(%arg0: vector<4xf32>, %arg1: i32) -> f32 { + %0 = llvm.mlir.constant(dense<1.000000e+00> : vector<4xf32>) : vector<4xf32> + %1 = llvm.fadd %arg0, %0 : vector<4xf32> + %2 = llvm.extractelement %1[%arg1 : i32] : vector<4xf32> + llvm.return %2 : f32 + } + llvm.func @extelt_binop_insertelt(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.insertelement %arg2, %arg0[%0 : i32] : vector<4xf32> + %2 = llvm.fmul %1, %arg1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.extractelement %2[%0 : i32] : vector<4xf32> + llvm.return %3 : f32 + } + llvm.func @extelt_binop_binop_insertelt(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.insertelement %arg2, %arg0[%0 : i32] : vector<4xi32> + %2 = llvm.add %1, %arg1 : vector<4xi32> + %3 = llvm.mul %2, %arg1 overflow : vector<4xi32> + %4 = llvm.extractelement %3[%0 : i32] : vector<4xi32> + llvm.return %4 : i32 + } + llvm.func @extract_element_constant_vector_variable_index(%arg0: i32) -> f32 { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.extractelement %0[%arg0 : i32] : vector<4xf32> + llvm.return %1 : f32 + } + llvm.func @cheap_to_extract_icmp(%arg0: vector<4xi32>, %arg1: vector<4xi1>) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %1 : vector<4xi32> + %4 = llvm.and %3, %arg1 : vector<4xi1> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xi1> + llvm.return %5 : i1 + } + llvm.func @cheap_to_extract_fcmp(%arg0: vector<4xf32>, %arg1: vector<4xi1>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.fcmp "oeq" %arg0, %1 : vector<4xf32> + %4 = llvm.and %3, %arg1 : vector<4xi1> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xi1> + llvm.return %5 : i1 + } + llvm.func @extractelt_vector_icmp_constrhs(%arg0: vector<2xi32>) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "eq" %arg0, %1 : vector<2xi32> + %3 = llvm.extractelement %2[%0 : i32] : vector<2xi1> + llvm.return %3 : i1 + } + llvm.func @extractelt_vector_fcmp_constrhs(%arg0: vector<2xf32>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.fcmp "oeq" %arg0, %1 : vector<2xf32> + %4 = llvm.extractelement %3[%2 : i32] : vector<2xi1> + llvm.return %4 : i1 + } + llvm.func @extractelt_vector_icmp_constrhs_dynidx(%arg0: vector<2xi32>, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "eq" %arg0, %1 : vector<2xi32> + %3 = llvm.extractelement %2[%arg1 : i32] : vector<2xi1> + llvm.return %3 : i1 + } + llvm.func @extractelt_vector_fcmp_constrhs_dynidx(%arg0: vector<2xf32>, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.fcmp "oeq" %arg0, %1 : vector<2xf32> + %3 = llvm.extractelement %2[%arg1 : i32] : vector<2xi1> + llvm.return %3 : i1 + } + llvm.func @extractelt_vector_fcmp_not_cheap_to_scalarize_multi_use(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>, %arg3: i32) -> i1 { + %0 = llvm.mlir.undef : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.fadd %arg1, %arg2 : vector<2xf32> + llvm.store volatile %2, %0 {alignment = 8 : i64} : vector<2xf32>, !llvm.ptr + %3 = llvm.fcmp "oeq" %arg0, %2 : vector<2xf32> + %4 = llvm.extractelement %3[%1 : i32] : vector<2xi1> + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/scalarization.ll.mlir b/test/LLVMDialect/InstCombine/scalarization.ll.mlir new file mode 100644 index 000000000..2b81365c0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/scalarization.ll.mlir @@ -0,0 +1,241 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @extract_load(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> vector<4xi32> + %2 = llvm.extractelement %1[%0 : i32] : vector<4xi32> + llvm.return %2 : i32 + } + llvm.func @extract_load_fp(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 32 : i64} : !llvm.ptr -> vector<4xf64> + %2 = llvm.extractelement %1[%0 : i32] : vector<4xf64> + llvm.return %2 : f64 + } + llvm.func @extract_load_volatile(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.load volatile %arg0 {alignment = 32 : i64} : !llvm.ptr -> vector<4xf64> + %2 = llvm.extractelement %1[%0 : i32] : vector<4xf64> + llvm.return %2 : f64 + } + llvm.func @extract_load_extra_use(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> vector<4xf64> + %2 = llvm.extractelement %1[%0 : i32] : vector<4xf64> + llvm.store %1, %arg1 {alignment = 32 : i64} : vector<4xf64>, !llvm.ptr + llvm.return %2 : f64 + } + llvm.func @extract_load_variable_index(%arg0: !llvm.ptr, %arg1: i32) -> f64 { + %0 = llvm.load %arg0 {alignment = 32 : i64} : !llvm.ptr -> vector<4xf64> + %1 = llvm.extractelement %0[%arg1 : i32] : vector<4xf64> + llvm.return %1 : f64 + } + llvm.func @scalarize_phi(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(dense<2.330000e+00> : vector<4xf32>) : vector<4xf32> + %5 = llvm.load volatile %arg1 {alignment = 4 : i64} : !llvm.ptr -> f32 + %6 = llvm.insertelement %5, %0[%1 : i32] : vector<4xf32> + %7 = llvm.shufflevector %6, %0 [0, 0, 0, 0] : vector<4xf32> + %8 = llvm.insertelement %2, %0[%1 : i32] : vector<4xf32> + llvm.br ^bb1(%7, %1 : vector<4xf32>, i32) + ^bb1(%9: vector<4xf32>, %10: i32): // 2 preds: ^bb0, ^bb2 + %11 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %12 = llvm.icmp "ne" %10, %11 : i32 + llvm.cond_br %12, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %13 = llvm.extractelement %9[%3 : i32] : vector<4xf32> + llvm.store volatile %13, %arg1 {alignment = 4 : i64} : f32, !llvm.ptr + %14 = llvm.fmul %9, %4 : vector<4xf32> + %15 = llvm.add %10, %3 overflow : i32 + llvm.br ^bb1(%14, %15 : vector<4xf32>, i32) + ^bb3: // pred: ^bb1 + llvm.return + } + llvm.func @extract_element_binop_splat_constant_index(%arg0: vector<4xf32>) -> f32 { + %0 = llvm.mlir.constant(dense<2.330000e+00> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.fadd %arg0, %0 : vector<4xf32> + %3 = llvm.extractelement %2[%1 : i32] : vector<4xf32> + llvm.return %3 : f32 + } + llvm.func @extract_element_binop_splat_with_undef_constant_index(%arg0: vector<2xf64>) -> f64 { + %0 = llvm.mlir.undef : f64 + %1 = llvm.mlir.constant(4.200000e+01 : f64) : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.mlir.constant(0 : i32) : i32 + %8 = llvm.fdiv %6, %arg0 : vector<2xf64> + %9 = llvm.extractelement %8[%7 : i32] : vector<2xf64> + llvm.return %9 : f64 + } + llvm.func @extract_element_binop_nonsplat_constant_index(%arg0: vector<2xf32>) -> f32 { + %0 = llvm.mlir.constant(dense<[4.200000e+01, 4.300000e+01]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.fmul %arg0, %0 : vector<2xf32> + %3 = llvm.extractelement %2[%1 : i32] : vector<2xf32> + llvm.return %3 : f32 + } + llvm.func @extract_element_binop_splat_variable_index(%arg0: vector<4xi8>, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(dense<42> : vector<4xi8>) : vector<4xi8> + %1 = llvm.sdiv %arg0, %0 : vector<4xi8> + %2 = llvm.extractelement %1[%arg1 : i32] : vector<4xi8> + llvm.return %2 : i8 + } + llvm.func @extract_element_binop_splat_variable_index_may_trap(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: i32) -> i8 { + %0 = llvm.mlir.constant(dense<42> : vector<4xi8>) : vector<4xi8> + %1 = llvm.sdiv %0, %arg1 : vector<4xi8> + %2 = llvm.extractelement %1[%arg2 : i32] : vector<4xi8> + llvm.return %2 : i8 + } + llvm.func @extract_element_binop_constant_index_may_trap(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: i32) -> i8 { + %0 = llvm.mlir.constant(dense<42> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.sdiv %0, %arg1 : vector<4xi8> + %3 = llvm.extractelement %2[%1 : i32] : vector<4xi8> + llvm.return %3 : i8 + } + llvm.func @extract_element_binop_splat_with_undef_variable_index(%arg0: vector<4xi8>, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<4xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi8> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi8> + %11 = llvm.mul %arg0, %10 : vector<4xi8> + %12 = llvm.extractelement %11[%arg1 : i32] : vector<4xi8> + llvm.return %12 : i8 + } + llvm.func @extract_element_binop_nonsplat_variable_index(%arg0: vector<4xi8>, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.mlir.constant(4 : i8) : i8 + %4 = llvm.mlir.undef : vector<4xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xi8> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xi8> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xi8> + %13 = llvm.lshr %arg0, %12 : vector<4xi8> + %14 = llvm.extractelement %13[%arg1 : i32] : vector<4xi8> + llvm.return %14 : i8 + } + llvm.func @extract_element_load(%arg0: vector<4xf32>, %arg1: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.load %arg1 {alignment = 16 : i64} : !llvm.ptr -> vector<4xf32> + %2 = llvm.fadd %arg0, %1 : vector<4xf32> + %3 = llvm.extractelement %2[%0 : i32] : vector<4xf32> + llvm.return %3 : f32 + } + llvm.func @extract_element_multi_Use_load(%arg0: vector<4xf32>, %arg1: !llvm.ptr, %arg2: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.load %arg1 {alignment = 16 : i64} : !llvm.ptr -> vector<4xf32> + llvm.store %1, %arg2 {alignment = 16 : i64} : vector<4xf32>, !llvm.ptr + %2 = llvm.fadd %arg0, %1 : vector<4xf32> + %3 = llvm.extractelement %2[%0 : i32] : vector<4xf32> + llvm.return %3 : f32 + } + llvm.func @extract_element_variable_index(%arg0: vector<4xf32>, %arg1: i32) -> f32 { + %0 = llvm.mlir.constant(dense<1.000000e+00> : vector<4xf32>) : vector<4xf32> + %1 = llvm.fadd %arg0, %0 : vector<4xf32> + %2 = llvm.extractelement %1[%arg1 : i32] : vector<4xf32> + llvm.return %2 : f32 + } + llvm.func @extelt_binop_insertelt(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.insertelement %arg2, %arg0[%0 : i32] : vector<4xf32> + %2 = llvm.fmul %1, %arg1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.extractelement %2[%0 : i32] : vector<4xf32> + llvm.return %3 : f32 + } + llvm.func @extelt_binop_binop_insertelt(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.insertelement %arg2, %arg0[%0 : i32] : vector<4xi32> + %2 = llvm.add %1, %arg1 : vector<4xi32> + %3 = llvm.mul %2, %arg1 overflow : vector<4xi32> + %4 = llvm.extractelement %3[%0 : i32] : vector<4xi32> + llvm.return %4 : i32 + } + llvm.func @extract_element_constant_vector_variable_index(%arg0: i32) -> f32 { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.extractelement %0[%arg0 : i32] : vector<4xf32> + llvm.return %1 : f32 + } + llvm.func @cheap_to_extract_icmp(%arg0: vector<4xi32>, %arg1: vector<4xi1>) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %1 : vector<4xi32> + %4 = llvm.and %3, %arg1 : vector<4xi1> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xi1> + llvm.return %5 : i1 + } + llvm.func @cheap_to_extract_fcmp(%arg0: vector<4xf32>, %arg1: vector<4xi1>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.fcmp "oeq" %arg0, %1 : vector<4xf32> + %4 = llvm.and %3, %arg1 : vector<4xi1> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xi1> + llvm.return %5 : i1 + } + llvm.func @extractelt_vector_icmp_constrhs(%arg0: vector<2xi32>) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "eq" %arg0, %1 : vector<2xi32> + %3 = llvm.extractelement %2[%0 : i32] : vector<2xi1> + llvm.return %3 : i1 + } + llvm.func @extractelt_vector_fcmp_constrhs(%arg0: vector<2xf32>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.fcmp "oeq" %arg0, %1 : vector<2xf32> + %4 = llvm.extractelement %3[%2 : i32] : vector<2xi1> + llvm.return %4 : i1 + } + llvm.func @extractelt_vector_icmp_constrhs_dynidx(%arg0: vector<2xi32>, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "eq" %arg0, %1 : vector<2xi32> + %3 = llvm.extractelement %2[%arg1 : i32] : vector<2xi1> + llvm.return %3 : i1 + } + llvm.func @extractelt_vector_fcmp_constrhs_dynidx(%arg0: vector<2xf32>, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.fcmp "oeq" %arg0, %1 : vector<2xf32> + %3 = llvm.extractelement %2[%arg1 : i32] : vector<2xi1> + llvm.return %3 : i1 + } + llvm.func @extractelt_vector_fcmp_copy_flags(%arg0: vector<4xf32>) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.fcmp "oeq" %arg0, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %4 = llvm.extractelement %3[%2 : i32] : vector<4xi1> + llvm.return %4 : i1 + } + llvm.func @extractelt_vector_fcmp_not_cheap_to_scalarize_multi_use(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>, %arg3: i32) -> i1 { + %0 = llvm.mlir.undef : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.fadd %arg1, %arg2 : vector<2xf32> + llvm.store volatile %2, %0 {alignment = 8 : i64} : vector<2xf32>, !llvm.ptr + %3 = llvm.fcmp "oeq" %arg0, %2 : vector<2xf32> + %4 = llvm.extractelement %3[%1 : i32] : vector<2xi1> + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/scmp.ll.mlir b/test/LLVMDialect/InstCombine/scmp.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/sdiv-1.ll.mlir b/test/LLVMDialect/InstCombine/sdiv-1.ll.mlir index 11ed47518..2002b9feb 100644 --- a/test/LLVMDialect/InstCombine/sdiv-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/sdiv-1.ll.mlir @@ -1,26 +1,22 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.sub"(%1, %arg0) : (i32, i32) -> i32 - %3 = "llvm.sdiv"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "a", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2147483648 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @a, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "b", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -3 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -2147483648 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.sub"(%2, %1) : (i32, i32) -> i32 - %4 = "llvm.sdiv"(%3, %0) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "c", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-3 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.sdiv %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @b(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.call @a(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @c(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(-3 : i32) : i32 + %3 = llvm.sub %0, %1 : i32 + %4 = llvm.sdiv %3, %2 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sdiv-2.ll.mlir b/test/LLVMDialect/InstCombine/sdiv-2.ll.mlir new file mode 100644 index 000000000..3d97fe4b4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sdiv-2.ll.mlir @@ -0,0 +1,26 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func fastcc @func(%arg0: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i128) : i128 + %2 = llvm.mlir.constant(200000000 : i128) : i128 + %3 = llvm.mlir.constant(10 : i128) : i128 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.icmp "ne" %arg0, %0 : i32 + %6 = llvm.select %5, %1, %2 : i1, i128 + %7 = llvm.sdiv %6, %3 : i128 + llvm.br ^bb1(%1 : i128) + ^bb1(%8: i128): // 2 preds: ^bb0, ^bb3 + %9 = llvm.icmp "sgt" %8, %7 : i128 + llvm.cond_br %9, ^bb4, ^bb2 + ^bb2: // pred: ^bb1 + %10 = llvm.mul %8, %3 : i128 + %11 = llvm.sub %6, %1 : i128 + %12 = llvm.icmp "slt" %11, %10 : i128 + llvm.cond_br %12, ^bb4, ^bb3 + ^bb3: // pred: ^bb2 + %13 = llvm.add %1, %10 : i128 + llvm.br ^bb1(%13 : i128) + ^bb4: // 2 preds: ^bb1, ^bb2 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sdiv-canonicalize.ll.mlir b/test/LLVMDialect/InstCombine/sdiv-canonicalize.ll.mlir new file mode 100644 index 000000000..2582687eb --- /dev/null +++ b/test/LLVMDialect/InstCombine/sdiv-canonicalize.ll.mlir @@ -0,0 +1,74 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @X(5 : i32) {addr_space = 0 : i32} : i32 + llvm.func @use(i32) + llvm.func @test_sdiv_canonicalize_op0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 overflow : i32 + %2 = llvm.sdiv %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_sdiv_canonicalize_op0_exact(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 overflow : i32 + %2 = llvm.sdiv %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_sdiv_canonicalize_op1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.sdiv %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test_sdiv_canonicalize_nonsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.sdiv %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_sdiv_canonicalize_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %1, %arg0 overflow : vector<2xi32> + %3 = llvm.sdiv %2, %arg1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @test_sdiv_canonicalize_multiple_uses(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 overflow : i32 + %2 = llvm.sdiv %1, %arg1 : i32 + %3 = llvm.sdiv %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test_sdiv_canonicalize_constexpr(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.addressof @X : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.sub %2, %3 overflow : i64 + %5 = llvm.sdiv %arg0, %4 : i64 + llvm.return %5 : i64 + } + llvm.func @sdiv_abs_nsw(%arg0: i32) -> i32 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i32) -> i32 + %1 = llvm.sdiv %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @sdiv_abs_nsw_vec(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (vector<4xi32>) -> vector<4xi32> + %1 = llvm.sdiv %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @sdiv_abs(%arg0: i32) -> i32 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = false}> : (i32) -> i32 + %1 = llvm.sdiv %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @sdiv_abs_extra_use(%arg0: i32) -> i32 { + %0 = "llvm.intr.abs"(%arg0) <{is_int_min_poison = true}> : (i32) -> i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.sdiv %0, %arg0 : i32 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sdiv-exact-by-negative-power-of-two.ll.mlir b/test/LLVMDialect/InstCombine/sdiv-exact-by-negative-power-of-two.ll.mlir new file mode 100644 index 000000000..e97d41d16 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sdiv-exact-by-negative-power-of-two.ll.mlir @@ -0,0 +1,72 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-32 : i8) : i8 + %1 = llvm.sdiv %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @n1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-32 : i8) : i8 + %1 = llvm.sdiv %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @t2_vec_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-32> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sdiv %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @t3_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[-32, -16]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sdiv %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @n4_vec_mixed(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[-32, 16]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sdiv %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @n4_vec_undef(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.undef : i8 + %1 = llvm.mlir.constant(-32 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.sdiv %arg0, %6 : vector<2xi8> + llvm.return %7 : vector<2xi8> + } + llvm.func @prove_exact_with_high_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-32 : i8) : i8 + %1 = llvm.mlir.constant(-4 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.sdiv %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @prove_exact_with_high_mask_limit(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-32 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.sdiv %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @not_prove_exact_with_high_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-32 : i8) : i8 + %1 = llvm.mlir.constant(-64 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.sdiv %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @prove_exact_with_high_mask_splat_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-16> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.sdiv %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @prove_exact_with_high_mask_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[3, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[-8, -4]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.sdiv %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/sdiv-exact-by-power-of-two.ll.mlir b/test/LLVMDialect/InstCombine/sdiv-exact-by-power-of-two.ll.mlir new file mode 100644 index 000000000..84b49beca --- /dev/null +++ b/test/LLVMDialect/InstCombine/sdiv-exact-by-power-of-two.ll.mlir @@ -0,0 +1,96 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(32 : i8) : i8 + %1 = llvm.sdiv %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @n1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(32 : i8) : i8 + %1 = llvm.sdiv %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @n2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.sdiv %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @t3_vec_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sdiv %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @t4_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[32, 16]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sdiv %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @n5_vec_undef(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.undef : i8 + %1 = llvm.mlir.constant(32 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.sdiv %arg0, %6 : vector<2xi8> + llvm.return %7 : vector<2xi8> + } + llvm.func @n6_vec_negative(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[32, -128]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.sdiv %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @shl1_nsw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + %2 = llvm.sdiv %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @shl1_nuw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + %2 = llvm.sdiv %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @shl1_nsw_not_exact(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %0, %arg1 overflow : i8 + %2 = llvm.sdiv %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @prove_exact_with_high_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-8 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.sdiv %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @prove_exact_with_high_mask_limit(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-8 : i8) : i8 + %1 = llvm.mlir.constant(8 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.sdiv %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_prove_exact_with_high_mask(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-8 : i8) : i8 + %1 = llvm.mlir.constant(16 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.sdiv %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @prove_exact_with_high_mask_splat_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<8> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.sdiv %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @prove_exact_with_high_mask_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[3, 2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[8, 4]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.sdiv %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/sdiv-guard.ll.mlir b/test/LLVMDialect/InstCombine/sdiv-guard.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/sdiv-icmp.ll.mlir b/test/LLVMDialect/InstCombine/sdiv-icmp.ll.mlir new file mode 100644 index 000000000..523d0bd0a --- /dev/null +++ b/test/LLVMDialect/InstCombine/sdiv-icmp.ll.mlir @@ -0,0 +1,66 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use.i8(i8) + llvm.func @sdiv_exact_eq_0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sdiv %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @udiv_exact_ne_0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.udiv %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @sdiv_exact_ne_1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sdiv %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @udiv_exact_eq_1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.udiv %arg0, %arg1 : i8 + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @sdiv_exact_eq_9_no_of(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(9 : i8) : i8 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.sdiv %arg0, %2 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @sdiv_exact_eq_9_may_of(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(9 : i8) : i8 + %1 = llvm.sdiv %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @sdiv_exact_eq_9_no_of_fail_multiuse(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(9 : i8) : i8 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.sdiv %arg0, %2 : i8 + llvm.call @use.i8(%3) : (i8) -> () + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @sdiv_exact_eq_9_must_of_todo_is_false(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(55 : i8) : i8 + %1 = llvm.mlir.constant(9 : i8) : i8 + %2 = llvm.or %arg1, %0 : i8 + %3 = llvm.sdiv %arg0, %2 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @udiv_exact_ne_30_no_of(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(30 : i8) : i8 + %2 = llvm.and %arg1, %0 : i8 + %3 = llvm.udiv %arg0, %2 : i8 + %4 = llvm.icmp "ne" %3, %1 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/sdiv-of-non-negative-by-negative-power-of-two.ll.mlir b/test/LLVMDialect/InstCombine/sdiv-of-non-negative-by-negative-power-of-two.ll.mlir index 8342572cf..11c20a288 100644 --- a/test/LLVMDialect/InstCombine/sdiv-of-non-negative-by-negative-power-of-two.ll.mlir +++ b/test/LLVMDialect/InstCombine/sdiv-of-non-negative-by-negative-power-of-two.ll.mlir @@ -1,32 +1,26 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.assume", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -32 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %2 = "llvm.icmp"(%arg0, %1) {predicate = 5 : i64} : (i8, i8) -> i1 - "llvm.call"(%2) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %3 = "llvm.sdiv"(%arg0, %0) : (i8, i8) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -32 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %2 = "llvm.icmp"(%arg0, %1) {predicate = 5 : i64} : (i8, i8) -> i1 - "llvm.call"(%2) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %3 = "llvm.sdiv"(%arg0, %0) : (i8, i8) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "n1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -31 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %2 = "llvm.icmp"(%arg0, %1) {predicate = 5 : i64} : (i8, i8) -> i1 - "llvm.call"(%2) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %3 = "llvm.sdiv"(%arg0, %0) : (i8, i8) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "n2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-32 : i8) : i8 + %2 = llvm.icmp "sge" %arg0, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.sdiv %arg0, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @n1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(-32 : i8) : i8 + %2 = llvm.icmp "sge" %arg0, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.sdiv %arg0, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @n2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-31 : i8) : i8 + %2 = llvm.icmp "sge" %arg0, %0 : i8 + "llvm.intr.assume"(%2) : (i1) -> () + %3 = llvm.sdiv %arg0, %1 : i8 + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/select-2.ll.mlir b/test/LLVMDialect/InstCombine/select-2.ll.mlir new file mode 100644 index 000000000..934763c9e --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-2.ll.mlir @@ -0,0 +1,67 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(18 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.lshr %arg1, %1 : i32 + %4 = llvm.select %2, %3, %arg1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @t2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(18 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.select %2, %3, %arg1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @t3(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ogt" %arg0, %arg1 : f32 + %2 = llvm.select %1, %arg0, %0 : i1, f32 + %3 = llvm.fadd %2, %0 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %3 : f32 + } + llvm.func @ashr_exact_poison_constant_fold(%arg0: i1, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.select %arg0, %arg1, %0 : i1, i8 + %3 = llvm.ashr %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @ashr_exact(%arg0: i1, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.select %arg0, %arg1, %0 : i1, i8 + %3 = llvm.ashr %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @shl_nsw_nuw_poison_constant_fold(%arg0: i1, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(16 : i8) : i8 + %2 = llvm.select %arg0, %0, %arg1 : i1, i8 + %3 = llvm.shl %1, %2 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @shl_nsw_nuw(%arg0: i1, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.select %arg0, %0, %arg1 : i1, i8 + %3 = llvm.shl %1, %2 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @add_nsw_poison_constant_fold(%arg0: i1, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(65 : i8) : i8 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.select %arg0, %arg1, %0 : i1, i8 + %3 = llvm.add %2, %1 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @add_nsw(%arg0: i1, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.select %arg0, %arg1, %0 : i1, i8 + %3 = llvm.add %2, %1 overflow : i8 + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/select-and-or.ll.mlir b/test/LLVMDialect/InstCombine/select-and-or.ll.mlir new file mode 100644 index 000000000..2dbaf5a94 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-and-or.ll.mlir @@ -0,0 +1,739 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g1() {addr_space = 0 : i32} : i16 + llvm.mlir.global external @g2() {addr_space = 0 : i32} : i16 + llvm.func @use(i1) + llvm.func @gen_i1() -> i1 + llvm.func @gen_v2i1() -> vector<2xi1> + llvm.func @logical_and(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + llvm.return %1 : i1 + } + llvm.func @logical_or(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + llvm.return %1 : i1 + } + llvm.func @logical_and_not(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + llvm.return %1 : i1 + } + llvm.func @logical_or_not(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + llvm.return %1 : i1 + } + llvm.func @logical_and_cond_reuse(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.select %arg0, %arg1, %arg0 : i1, i1 + llvm.return %0 : i1 + } + llvm.func @logical_or_cond_reuse(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.select %arg0, %arg0, %arg1 : i1, i1 + llvm.return %0 : i1 + } + llvm.func @logical_and_not_cond_reuse(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.select %arg0, %arg1, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @logical_or_not_cond_reuse(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.select %arg0, %1, %arg1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @logical_or_implies(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @logical_or_implies_folds(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.icmp "sge" %arg0, %0 : i32 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logical_and_implies(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "ne" %arg0, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @logical_and_implies_folds(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.icmp "ne" %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @logical_or_noundef_a(%arg0: i1 {llvm.noundef}, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + llvm.return %1 : i1 + } + llvm.func @logical_or_noundef_b(%arg0: i1, %arg1: i1 {llvm.noundef}) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + llvm.return %1 : i1 + } + llvm.func @logical_and_noundef_a(%arg0: i1 {llvm.noundef}, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + llvm.return %1 : i1 + } + llvm.func @logical_and_noundef_b(%arg0: i1, %arg1: i1 {llvm.noundef}) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + llvm.return %1 : i1 + } + llvm.func @not_not_true(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.xor %arg1, %0 : i1 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @not_not_false(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.xor %arg1, %0 : i1 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @not_true_not(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.xor %arg1, %0 : i1 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @not_false_not(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.xor %arg1, %0 : i1 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @not_not_true_use1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.xor %arg1, %0 : i1 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @not_not_false_use1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.xor %arg1, %0 : i1 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @not_true_not_use1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.xor %arg1, %0 : i1 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @not_false_not_use1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.xor %arg1, %0 : i1 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @not_not_true_use2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.xor %arg1, %0 : i1 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @not_not_false_use2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.xor %arg1, %0 : i1 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @not_true_not_use2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.xor %arg1, %0 : i1 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @not_false_not_use2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.xor %arg1, %0 : i1 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @not_not_true_use3(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.xor %arg1, %0 : i1 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @not_not_false_use3(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.xor %arg1, %0 : i1 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @not_true_not_use3(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.xor %arg1, %0 : i1 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @not_false_not_use3(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg0, %0 : i1 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.xor %arg1, %0 : i1 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @demorgan_select_infloop1(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.addressof @g2 : !llvm.ptr + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i16 + %4 = llvm.mlir.addressof @g1 : !llvm.ptr + %5 = llvm.mlir.constant(false) : i1 + %6 = llvm.xor %arg0, %0 : i1 + %7 = llvm.icmp "eq" %3, %4 : !llvm.ptr + %8 = llvm.add %7, %7 : i1 + %9 = llvm.xor %8, %0 : i1 + %10 = llvm.select %6, %9, %5 : i1, i1 + llvm.return %10 : i1 + } + llvm.func @demorgan_select_infloop2(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.addressof @g1 : !llvm.ptr + %3 = llvm.getelementptr inbounds %2[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i16 + %4 = llvm.mlir.addressof @g2 : !llvm.ptr + %5 = llvm.getelementptr inbounds %4[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i16 + %6 = llvm.mlir.constant(false) : i1 + %7 = llvm.xor %arg0, %0 : i1 + %8 = llvm.icmp "eq" %3, %2 : !llvm.ptr + %9 = llvm.icmp "eq" %5, %2 : !llvm.ptr + %10 = llvm.add %8, %9 : i1 + %11 = llvm.xor %10, %0 : i1 + %12 = llvm.select %7, %11, %6 : i1, i1 + llvm.return %12 : i1 + } + llvm.func @and_or1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.or %1, %arg2 : i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @and_or2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg2, %0 : i1 + %2 = llvm.and %1, %arg1 : i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @and_or1_commuted(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.or %arg2, %1 : i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @and_or2_commuted(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg2, %0 : i1 + %2 = llvm.and %arg1, %1 : i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @and_or1_multiuse(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.or %1, %arg2 : i1 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.select %2, %arg0, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @and_or2_multiuse(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg2, %0 : i1 + %2 = llvm.and %1, %arg1 : i1 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.select %2, %arg0, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @and_or1_vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.call @gen_v2i1() : () -> vector<2xi1> + %3 = llvm.xor %arg0, %1 : vector<2xi1> + %4 = llvm.or %3, %2 : vector<2xi1> + %5 = llvm.select %4, %arg0, %arg1 : vector<2xi1>, vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @and_or2_vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.call @gen_v2i1() : () -> vector<2xi1> + %3 = llvm.xor %2, %1 : vector<2xi1> + %4 = llvm.and %3, %arg1 : vector<2xi1> + %5 = llvm.select %4, %arg0, %arg1 : vector<2xi1>, vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @and_or1_vec_commuted(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.call @gen_v2i1() : () -> vector<2xi1> + %3 = llvm.xor %arg0, %1 : vector<2xi1> + %4 = llvm.or %2, %3 : vector<2xi1> + %5 = llvm.select %4, %arg0, %arg1 : vector<2xi1>, vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @and_or2_vec_commuted(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.call @gen_v2i1() : () -> vector<2xi1> + %3 = llvm.xor %2, %1 : vector<2xi1> + %4 = llvm.and %arg1, %3 : vector<2xi1> + %5 = llvm.select %4, %arg0, %arg1 : vector<2xi1>, vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @and_or1_wrong_operand(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.or %1, %arg2 : i1 + %3 = llvm.select %2, %arg3, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @and_or2_wrong_operand(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg2, %0 : i1 + %2 = llvm.and %1, %arg1 : i1 + %3 = llvm.select %2, %arg0, %arg3 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @and_or3(%arg0: i1, %arg1: i1, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.icmp "eq" %arg2, %arg3 : i32 + %1 = llvm.and %arg1, %0 : i1 + %2 = llvm.select %1, %arg0, %arg1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @and_or3_commuted(%arg0: i1, %arg1: i1, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.icmp "eq" %arg2, %arg3 : i32 + %1 = llvm.and %0, %arg1 : i1 + %2 = llvm.select %1, %arg0, %arg1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @and_or3_not_free_to_invert(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.and %arg1, %arg2 : i1 + %1 = llvm.select %0, %arg0, %arg1 : i1, i1 + llvm.return %1 : i1 + } + llvm.func @and_or3_multiuse(%arg0: i1, %arg1: i1, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.icmp "eq" %arg2, %arg3 : i32 + %1 = llvm.and %arg1, %0 : i1 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.select %1, %arg0, %arg1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @and_or3_vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>, %arg2: vector<2xi32>, %arg3: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.icmp "eq" %arg2, %arg3 : vector<2xi32> + %1 = llvm.and %arg1, %0 : vector<2xi1> + %2 = llvm.select %1, %arg0, %arg1 : vector<2xi1>, vector<2xi1> + llvm.return %2 : vector<2xi1> + } + llvm.func @and_or3_vec_commuted(%arg0: vector<2xi1>, %arg1: vector<2xi1>, %arg2: vector<2xi32>, %arg3: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.icmp "eq" %arg2, %arg3 : vector<2xi32> + %1 = llvm.and %0, %arg1 : vector<2xi1> + %2 = llvm.select %1, %arg0, %arg1 : vector<2xi1>, vector<2xi1> + llvm.return %2 : vector<2xi1> + } + llvm.func @and_or3_wrong_operand(%arg0: i1, %arg1: i1, %arg2: i32, %arg3: i32, %arg4: i1) -> i1 { + %0 = llvm.icmp "eq" %arg2, %arg3 : i32 + %1 = llvm.and %arg1, %0 : i1 + %2 = llvm.select %1, %arg0, %arg4 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @or_and1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg1, %0 : i1 + %2 = llvm.and %1, %arg2 : i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @or_and2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg2, %0 : i1 + %2 = llvm.or %1, %arg0 : i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @or_and1_commuted(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg1, %0 : i1 + %2 = llvm.and %arg2, %1 : i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @or_and2_commuted(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg2, %0 : i1 + %2 = llvm.or %arg0, %1 : i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @or_and1_multiuse(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg1, %0 : i1 + %2 = llvm.and %1, %arg2 : i1 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.select %2, %arg0, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @or_and2_multiuse(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg2, %0 : i1 + %2 = llvm.or %1, %arg0 : i1 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.select %2, %arg0, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @or_and1_vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.call @gen_v2i1() : () -> vector<2xi1> + %3 = llvm.xor %arg1, %1 : vector<2xi1> + %4 = llvm.and %2, %3 : vector<2xi1> + %5 = llvm.select %4, %arg0, %arg1 : vector<2xi1>, vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @or_and2_vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.call @gen_v2i1() : () -> vector<2xi1> + %3 = llvm.xor %2, %1 : vector<2xi1> + %4 = llvm.or %arg0, %3 : vector<2xi1> + %5 = llvm.select %4, %arg0, %arg1 : vector<2xi1>, vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @or_and1_vec_commuted(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.call @gen_v2i1() : () -> vector<2xi1> + %3 = llvm.xor %arg1, %1 : vector<2xi1> + %4 = llvm.and %3, %2 : vector<2xi1> + %5 = llvm.select %4, %arg0, %arg1 : vector<2xi1>, vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @or_and2_vec_commuted(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.call @gen_v2i1() : () -> vector<2xi1> + %3 = llvm.xor %2, %1 : vector<2xi1> + %4 = llvm.or %3, %arg0 : vector<2xi1> + %5 = llvm.select %4, %arg0, %arg1 : vector<2xi1>, vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @or_and1_wrong_operand(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg1, %0 : i1 + %2 = llvm.and %arg2, %1 : i1 + %3 = llvm.select %2, %arg0, %arg3 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @or_and2_wrong_operand(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg2, %0 : i1 + %2 = llvm.or %arg0, %1 : i1 + %3 = llvm.select %2, %arg3, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @pr64558(%arg0: i1 {llvm.noundef}, %arg1: i1 {llvm.noundef}) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg1, %0 : i1 + %2 = llvm.and %1, %arg0 : i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @or_and3(%arg0: i1, %arg1: i1, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.icmp "eq" %arg2, %arg3 : i32 + %1 = llvm.or %arg0, %0 : i1 + %2 = llvm.select %1, %arg0, %arg1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @or_and3_commuted(%arg0: i1, %arg1: i1, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.icmp "eq" %arg2, %arg3 : i32 + %1 = llvm.or %0, %arg0 : i1 + %2 = llvm.select %1, %arg0, %arg1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @or_and3_not_free_to_invert(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.or %arg0, %arg2 : i1 + %1 = llvm.select %0, %arg0, %arg1 : i1, i1 + llvm.return %1 : i1 + } + llvm.func @or_and3_multiuse(%arg0: i1, %arg1: i1, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.icmp "eq" %arg2, %arg3 : i32 + %1 = llvm.or %arg0, %0 : i1 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.select %1, %arg0, %arg1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @or_and3_vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>, %arg2: vector<2xi32>, %arg3: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.icmp "eq" %arg2, %arg3 : vector<2xi32> + %1 = llvm.or %arg0, %0 : vector<2xi1> + %2 = llvm.select %1, %arg0, %arg1 : vector<2xi1>, vector<2xi1> + llvm.return %2 : vector<2xi1> + } + llvm.func @or_and3_vec_commuted(%arg0: vector<2xi1>, %arg1: vector<2xi1>, %arg2: vector<2xi32>, %arg3: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.icmp "eq" %arg2, %arg3 : vector<2xi32> + %1 = llvm.or %0, %arg0 : vector<2xi1> + %2 = llvm.select %1, %arg0, %arg1 : vector<2xi1>, vector<2xi1> + llvm.return %2 : vector<2xi1> + } + llvm.func @or_and3_wrong_operand(%arg0: i1, %arg1: i1, %arg2: i32, %arg3: i32, %arg4: i1) -> i1 { + %0 = llvm.icmp "eq" %arg2, %arg3 : i32 + %1 = llvm.or %arg0, %0 : i1 + %2 = llvm.select %1, %arg4, %arg1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @test_or_umax(%arg0: i8, %arg1: i8, %arg2: i1) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %2 = llvm.select %arg2, %0, %1 : i1, i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @test_or_umin(%arg0: i8, %arg1: i8, %arg2: i1) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %2 = llvm.select %arg2, %0, %1 : i1, i1 + %3 = llvm.select %2, %arg1, %arg0 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @test_and_umax(%arg0: i8, %arg1: i8, %arg2: i1) -> i8 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %2 = llvm.select %arg2, %1, %0 : i1, i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @test_and_umin(%arg0: i8, %arg1: i8, %arg2: i1) -> i8 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %2 = llvm.select %arg2, %1, %0 : i1, i1 + %3 = llvm.select %2, %arg1, %arg0 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @test_or_umax_bitwise1(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg2, %0 : i8 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %3 = llvm.or %1, %2 : i1 + %4 = llvm.select %3, %arg0, %arg1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @test_or_umax_bitwise2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg2, %0 : i8 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %3 = llvm.or %2, %1 : i1 + %4 = llvm.select %3, %arg0, %arg1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @test_and_umax_bitwise1(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg2, %0 : i8 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %3 = llvm.and %1, %2 : i1 + %4 = llvm.select %3, %arg0, %arg1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @test_and_umax_bitwise2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg2, %0 : i8 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %3 = llvm.and %2, %1 : i1 + %4 = llvm.select %3, %arg0, %arg1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @test_or_smax(%arg0: i8, %arg1: i8, %arg2: i1) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %2 = llvm.select %arg2, %0, %1 : i1, i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @test_or_abs(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "sgt" %arg0, %0 : i8 + %4 = llvm.sub %1, %arg0 overflow : i8 + %5 = llvm.select %arg1, %2, %3 : i1, i1 + %6 = llvm.select %5, %arg0, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @test_or_fmaxnum(%arg0: f32, %arg1: f32, %arg2: i1) -> f32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.fcmp "ogt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %2 = llvm.select %arg2, %0, %1 : i1, i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @test_or_umax_invalid_logical(%arg0: i8, %arg1: i8, %arg2: i1) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %2 = llvm.select %1, %0, %arg2 : i1, i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @test_and_umax_invalid_logical(%arg0: i8, %arg1: i8, %arg2: i1) -> i8 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %2 = llvm.select %1, %arg2, %0 : i1, i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @test_or_umax_multiuse_cond(%arg0: i8, %arg1: i8, %arg2: i1) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %2 = llvm.select %arg2, %0, %1 : i1, i1 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.select %2, %arg0, %arg1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @test_or_eq_a_b(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.icmp "eq" %arg1, %arg2 : i8 + %1 = llvm.or %arg0, %0 : i1 + %2 = llvm.select %1, %arg1, %arg2 : i1, i8 + llvm.return %2 : i8 + } + llvm.func @test_and_ne_a_b(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.icmp "ne" %arg1, %arg2 : i8 + %1 = llvm.and %arg0, %0 : i1 + %2 = llvm.select %1, %arg1, %arg2 : i1, i8 + llvm.return %2 : i8 + } + llvm.func @test_or_eq_a_b_commuted(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.icmp "eq" %arg1, %arg2 : i8 + %1 = llvm.or %arg0, %0 : i1 + %2 = llvm.select %1, %arg2, %arg1 : i1, i8 + llvm.return %2 : i8 + } + llvm.func @test_and_ne_a_b_commuted(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.icmp "ne" %arg1, %arg2 : i8 + %1 = llvm.and %arg0, %0 : i1 + %2 = llvm.select %1, %arg2, %arg1 : i1, i8 + llvm.return %2 : i8 + } + llvm.func @test_or_eq_different_operands(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.icmp "eq" %arg0, %arg2 : i8 + %1 = llvm.icmp "eq" %arg1, %arg0 : i8 + %2 = llvm.or %0, %1 : i1 + %3 = llvm.select %2, %arg0, %arg1 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @test_or_eq_a_b_multi_use(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.icmp "eq" %arg1, %arg2 : i8 + %1 = llvm.or %arg0, %0 : i1 + llvm.call @use(%0) : (i1) -> () + llvm.call @use(%1) : (i1) -> () + %2 = llvm.select %1, %arg1, %arg2 : i1, i8 + llvm.return %2 : i8 + } + llvm.func @test_or_eq_a_b_vec(%arg0: vector<2xi1>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.icmp "eq" %arg1, %arg2 : vector<2xi8> + %1 = llvm.or %arg0, %0 : vector<2xi1> + %2 = llvm.select %1, %arg1, %arg2 : vector<2xi1>, vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @test_or_ne_a_b(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.icmp "ne" %arg1, %arg2 : i8 + %1 = llvm.or %arg0, %0 : i1 + %2 = llvm.select %1, %arg1, %arg2 : i1, i8 + llvm.return %2 : i8 + } + llvm.func @test_and_ne_different_operands_fail(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.icmp "ne" %arg0, %arg2 : i8 + %1 = llvm.icmp "ne" %arg1, %arg2 : i8 + %2 = llvm.and %0, %1 : i1 + %3 = llvm.select %2, %arg1, %arg0 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @test_logical_or_eq_a_b(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + %3 = llvm.select %2, %arg1, %arg2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @test_logical_commuted_or_eq_a_b(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.select %1, %0, %arg0 : i1, i1 + %3 = llvm.select %2, %arg1, %arg2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @test_logical_and_ne_a_b(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.icmp "ne" %arg1, %arg2 : i8 + %2 = llvm.select %arg0, %1, %0 : i1, i1 + %3 = llvm.select %2, %arg1, %arg2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @test_logical_commuted_and_ne_a_b(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.icmp "ne" %arg1, %arg2 : i8 + %2 = llvm.select %1, %arg0, %0 : i1, i1 + %3 = llvm.select %2, %arg1, %arg2 : i1, i8 + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/select-binop-cmp.ll.mlir b/test/LLVMDialect/InstCombine/select-binop-cmp.ll.mlir new file mode 100644 index 000000000..b8612e810 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-binop-cmp.ll.mlir @@ -0,0 +1,795 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g(0 : i32) {addr_space = 0 : i32} : i32 + llvm.func @use(vector<2xi1>) + llvm.func @use2(i1) + llvm.func @use.i32(i32) + llvm.func @select_xor_icmp(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.xor %arg0, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_xor_icmp2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %0 : i32 + %2 = llvm.xor %arg0, %arg2 : i32 + %3 = llvm.select %1, %arg1, %2 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_xor_icmp_meta(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.xor %arg0, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_mul_icmp(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.mul %arg0, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_add_icmp(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.add %arg0, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_or_icmp(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.or %arg0, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_and_icmp(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.and %arg0, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_xor_icmp_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.icmp "eq" %arg0, %1 : vector<2xi8> + %3 = llvm.xor %arg0, %arg2 : vector<2xi8> + %4 = llvm.select %2, %3, %arg1 : vector<2xi1>, vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @select_xor_icmp_vec_use(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.icmp "ne" %arg0, %1 : vector<2xi8> + llvm.call @use(%2) : (vector<2xi1>) -> () + %3 = llvm.xor %arg0, %arg2 : vector<2xi8> + %4 = llvm.select %2, %arg1, %3 : vector<2xi1>, vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @select_xor_inv_icmp(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.xor %arg2, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_xor_inv_icmp2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %0 : i32 + llvm.call @use2(%1) : (i1) -> () + %2 = llvm.xor %arg0, %arg2 : i32 + %3 = llvm.select %1, %arg1, %2 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_fadd_fcmp(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fadd %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fadd_fcmp_poszero(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fadd %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fadd_fcmp_2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "une" %arg0, %0 : f32 + %3 = llvm.fadd %arg2, %1 : f32 + %4 = llvm.fadd %3, %arg0 : f32 + %5 = llvm.select %2, %arg1, %4 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @select_fadd_fcmp_2_poszero(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "une" %arg0, %0 : f32 + %2 = llvm.fadd %arg2, %0 : f32 + %3 = llvm.fadd %2, %arg0 : f32 + %4 = llvm.select %1, %arg1, %3 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @select_fadd_fcmp_3(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(6.000000e+00 : f32) : f32 + %2 = llvm.fcmp "une" %arg0, %0 : f32 + %3 = llvm.fadd %1, %arg0 : f32 + %4 = llvm.select %2, %arg1, %3 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @select_fadd_fcmp_3_poszero(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(6.000000e+00 : f32) : f32 + %2 = llvm.fcmp "une" %arg0, %0 : f32 + %3 = llvm.fadd %1, %arg0 : f32 + %4 = llvm.select %2, %arg1, %3 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @select_fadd_fcmp_4(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "une" %arg0, %0 : f32 + %2 = llvm.fadd %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %arg1, %2 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fadd_fcmp_4_poszero(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "une" %arg0, %0 : f32 + %2 = llvm.fadd %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %arg1, %2 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fadd_fcmp_5(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "oeq" %arg0, %0 : f32 + %3 = llvm.fadd %arg2, %1 : f32 + %4 = llvm.fadd %3, %arg0 : f32 + %5 = llvm.select %2, %4, %arg1 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @select_fadd_fcmp_5_poszero(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fadd %arg2, %0 : f32 + %3 = llvm.fadd %2, %arg0 : f32 + %4 = llvm.select %1, %3, %arg1 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @select_fadd_fcmp_6(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(6.000000e+00 : f32) : f32 + %2 = llvm.fcmp "oeq" %arg0, %0 : f32 + %3 = llvm.fadd %arg0, %1 : f32 + %4 = llvm.select %2, %3, %arg1 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @select_fadd_fcmp_6_poszero(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(6.000000e+00 : f32) : f32 + %2 = llvm.fcmp "oeq" %arg0, %0 : f32 + %3 = llvm.fadd %arg0, %1 : f32 + %4 = llvm.select %2, %3, %arg1 : i1, f32 + llvm.return %4 : f32 + } + llvm.func @select_fmul_fcmp(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fmul %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fsub_fcmp(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fsub %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fsub_fcmp_negzero(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fsub %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fdiv_fcmp(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fdiv %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_sub_icmp(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.sub %arg2, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_sub_icmp_2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + llvm.call @use2(%1) : (i1) -> () + %2 = llvm.sub %arg2, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_sub_icmp_3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %0 : i32 + llvm.call @use2(%1) : (i1) -> () + %2 = llvm.sub %arg2, %arg0 : i32 + %3 = llvm.select %1, %arg1, %2 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_sub_icmp_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.icmp "eq" %arg0, %1 : vector<2xi8> + %3 = llvm.sub %arg2, %arg0 : vector<2xi8> + %4 = llvm.select %2, %3, %arg1 : vector<2xi1>, vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @select_shl_icmp(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %0 : i32 + llvm.call @use2(%1) : (i1) -> () + %2 = llvm.shl %arg2, %arg0 : i32 + %3 = llvm.select %1, %arg1, %2 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_lshr_icmp(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.lshr %arg2, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_ashr_icmp(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %0 : i32 + llvm.call @use2(%1) : (i1) -> () + %2 = llvm.ashr %arg2, %arg0 : i32 + %3 = llvm.select %1, %arg1, %2 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_udiv_icmp(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.udiv %arg2, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_sdiv_icmp(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %0 : i32 + llvm.call @use2(%1) : (i1) -> () + %2 = llvm.sdiv %arg2, %arg0 : i32 + %3 = llvm.select %1, %arg1, %2 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_xor_icmp_bad_1(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.icmp "eq" %arg0, %arg3 : i32 + %1 = llvm.xor %arg0, %arg2 : i32 + %2 = llvm.select %0, %1, %arg1 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @select_xor_icmp_bad_2(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.xor %arg3, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_xor_icmp_bad_3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.xor %arg0, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_xor_fcmp_bad_4(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: f32) -> i32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg3, %0 : f32 + %2 = llvm.xor %arg0, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_xor_icmp_bad_5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %0 : i32 + %2 = llvm.xor %arg0, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_xor_icmp_bad_6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %0 : i32 + %2 = llvm.xor %arg0, %arg2 : i32 + %3 = llvm.select %1, %arg1, %2 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_xor_icmp_vec_bad(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[5, 3]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.icmp "eq" %arg0, %0 : vector<2xi8> + %2 = llvm.xor %arg0, %arg2 : vector<2xi8> + %3 = llvm.select %1, %2, %arg1 : vector<2xi1>, vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @vec_select_no_equivalence(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.undef : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.shufflevector %arg0, %0 [1, 0] : vector<2xi32> + %4 = llvm.icmp "eq" %arg0, %2 : vector<2xi32> + %5 = llvm.select %4, %3, %arg0 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @select_xor_icmp_vec_undef(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.undef : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.icmp "eq" %arg0, %6 : vector<2xi8> + %8 = llvm.xor %arg0, %arg2 : vector<2xi8> + %9 = llvm.select %7, %8, %arg1 : vector<2xi1>, vector<2xi8> + llvm.return %9 : vector<2xi8> + } + llvm.func @select_mul_icmp_bad(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.mul %arg0, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_add_icmp_bad(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.add %arg0, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_and_icmp_zero(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.and %arg0, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_or_icmp_bad(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.or %arg0, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_lshr_icmp_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @select_lshr_icmp_const_reordered(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @select_exact_lshr_icmp_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @select_lshr_icmp_const_large_exact_range(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(63 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @select_lshr_icmp_const_different_values(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.lshr %arg1, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @select_fadd_fcmp_bad(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fadd %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fadd_fcmp_bad_2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %1 = llvm.fcmp "ueq" %arg0, %0 : f32 + %2 = llvm.fadd %arg0, %arg2 : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fadd_fcmp_bad_3(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: f32) -> f32 { + %0 = llvm.fcmp "one" %arg0, %arg3 : f32 + %1 = llvm.fadd %arg0, %arg2 : f32 + %2 = llvm.select %0, %arg1, %1 : i1, f32 + llvm.return %2 : f32 + } + llvm.func @select_fadd_fcmp_bad_4(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "une" %arg0, %0 : f32 + %2 = llvm.fadd %arg0, %arg2 : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fadd_fcmp_bad_5(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "one" %arg0, %0 : f32 + %2 = llvm.fadd %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %arg1, %2 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fadd_fcmp_bad_6(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fadd %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %arg1, %2 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fadd_fcmp_bad_7(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fadd %arg0, %arg2 : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fadd_fcmp_bad_8(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "one" %arg0, %0 : f32 + %3 = llvm.fadd %arg2, %1 : f32 + %4 = llvm.fadd %3, %arg0 : f32 + %5 = llvm.select %2, %arg1, %4 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @select_fadd_fcmp_bad_9(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "one" %arg0, %0 : f32 + %2 = llvm.fadd %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %arg1, %2 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fadd_fcmp_bad_10(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %2 = llvm.fcmp "one" %arg0, %0 : f32 + %3 = llvm.fadd %arg2, %1 : f32 + %4 = llvm.fadd %3, %arg0 : f32 + %5 = llvm.select %2, %arg1, %4 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @select_fadd_fcmp_bad_11(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "une" %arg0, %0 : f32 + %3 = llvm.fadd %arg2, %1 : f32 + %4 = llvm.fadd %3, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %5 = llvm.select %2, %arg1, %4 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @select_fadd_fcmp_bad_12(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "une" %arg0, %0 : f32 + %2 = llvm.fadd %arg2, %arg0 : f32 + %3 = llvm.select %1, %arg1, %2 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fadd_fcmp_bad_13(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fadd %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %arg1, %2 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fadd_fcmp_bad_14(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(-1.000000e+00 : f32) : f32 + %1 = llvm.fcmp "une" %arg0, %0 : f32 + %2 = llvm.fadd %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %arg1, %2 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fmul_fcmp_bad(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fmul %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fmul_fcmp_bad_2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fmul %arg0, %arg2 : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fmul_icmp_bad(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: i32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg3, %0 : i32 + %2 = llvm.fmul %arg0, %arg2 : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fmul_icmp_bad_2(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: i32) -> f32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg3, %0 : i32 + %2 = llvm.fmul %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fdiv_fcmp_bad(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fdiv %arg0, %arg2 : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fdiv_fcmp_bad_2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fdiv %arg0, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fsub_fcmp_bad(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fsub %arg2, %arg0 : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_fsub_fcmp_bad_2(%arg0: f32, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.fcmp "oeq" %arg0, %0 : f32 + %2 = llvm.fsub %arg2, %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %3 = llvm.select %1, %2, %arg1 : i1, f32 + llvm.return %3 : f32 + } + llvm.func @select_sub_icmp_bad(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.sub %arg0, %arg2 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_sub_icmp_bad_2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.sub %arg2, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_sub_icmp_bad_3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %0 : i32 + llvm.call @use2(%1) : (i1) -> () + %2 = llvm.sub %arg2, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_sub_icmp_4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %0 : i32 + llvm.call @use2(%1) : (i1) -> () + %2 = llvm.sub %arg2, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_sub_icmp_bad_4(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.sub %arg2, %arg3 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_sub_icmp_bad_5(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.icmp "eq" %arg0, %arg3 : i32 + %1 = llvm.sub %arg2, %arg0 : i32 + %2 = llvm.select %0, %1, %arg1 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @select_shl_icmp_bad(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.shl %arg2, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_lshr_icmp_bad(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.lshr %arg2, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_ashr_icmp_bad(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.ashr %arg2, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_udiv_icmp_bad(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.udiv %arg2, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_sdiv_icmp_bad(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.sdiv %arg2, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_replace_one_use(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.sub %arg0, %arg1 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_replace_multi_use(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.sub %arg0, %arg1 : i32 + llvm.call @use_i32(%2) : (i32) -> () + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_replace_fold(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.intr.fshr(%arg1, %arg2, %arg0) : (i32, i32, i32) -> i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_replace_nested(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.sub %arg1, %arg0 : i32 + %3 = llvm.add %2, %arg2 : i32 + %4 = llvm.select %1, %3, %arg1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @select_replace_nested_extra_use(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.sub %arg1, %arg0 : i32 + llvm.call @use.i32(%2) : (i32) -> () + %3 = llvm.add %2, %arg2 : i32 + %4 = llvm.select %1, %3, %arg1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @select_replace_nested_no_simplify(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.sub %arg1, %arg0 : i32 + %3 = llvm.add %2, %arg2 : i32 + %4 = llvm.select %1, %3, %arg1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @select_replace_deeply_nested(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : i32 + %3 = llvm.sub %arg1, %arg0 : i32 + %4 = llvm.add %3, %arg2 : i32 + %5 = llvm.shl %4, %1 : i32 + %6 = llvm.select %2, %5, %arg1 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_replace_constexpr(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @g : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.icmp "eq" %arg0, %2 : i32 + %4 = llvm.add %arg0, %arg1 : i32 + %5 = llvm.select %3, %4, %arg2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @select_replace_undef(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.icmp "eq" %arg0, %6 : vector<2xi32> + %8 = llvm.sub %arg0, %arg1 : vector<2xi32> + %9 = llvm.select %7, %8, %arg1 : vector<2xi1>, vector<2xi32> + llvm.return %9 : vector<2xi32> + } + llvm.func @select_replace_call_speculatable(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.call @call_speculatable(%arg0, %arg0) : (i32, i32) -> i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_replace_call_non_speculatable(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.call @call_non_speculatable(%arg0, %arg0) : (i32, i32) -> i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_replace_sdiv_speculatable(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.sdiv %arg1, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_replace_sdiv_non_speculatable(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.sdiv %arg1, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_replace_udiv_speculatable(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.udiv %arg1, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_replace_udiv_non_speculatable(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %0 : i32 + %2 = llvm.udiv %arg1, %arg0 : i32 + %3 = llvm.select %1, %2, %arg1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @select_replace_phi(%arg0: i32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + llvm.br ^bb1(%0, %1 : i32, i32) + ^bb1(%4: i32, %5: i32): // 2 preds: ^bb0, ^bb1 + %6 = llvm.add %4, %2 : i32 + %7 = llvm.icmp "eq" %4, %0 : i32 + %8 = llvm.select %7, %5, %3 : i1, i32 + llvm.call @use_i32(%8) : (i32) -> () + llvm.br ^bb1(%6, %4 : i32, i32) + } + llvm.func @call_speculatable(i32, i32) -> i32 attributes {passthrough = ["speculatable"]} + llvm.func @call_non_speculatable(i32, i32) -> i32 + llvm.func @use_i32(i32) +} diff --git a/test/LLVMDialect/InstCombine/select-binop-foldable-floating-point.ll.mlir b/test/LLVMDialect/InstCombine/select-binop-foldable-floating-point.ll.mlir new file mode 100644 index 000000000..4ff0c648b --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-binop-foldable-floating-point.ll.mlir @@ -0,0 +1,127 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @select_maybe_nan_fadd(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fadd %arg1, %arg2 : f32 + %1 = llvm.select %arg0, %0, %arg1 : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_fpclass_fadd(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fadd %arg1, %arg2 : f32 + %1 = llvm.select %arg0, %0, %arg1 : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fadd(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fadd %arg1, %arg2 : f32 + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fadd_swapped(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fadd %arg1, %arg2 : f32 + %1 = llvm.select %arg0, %arg1, %0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fadd_fast_math(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fadd %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fadd_swapped_fast_math(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fadd %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %arg0, %arg1, %0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_nsz_fadd_v4f32(%arg0: vector<4xi1>, %arg1: vector<4xf32>, %arg2: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.fadd %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<4xi1>, vector<4xf32> + llvm.return %1 : vector<4xf32> + } + llvm.func @select_nnan_nsz_fadd_nxv4f32(%arg0: !llvm.vec, %arg1: !llvm.vec, %arg2: !llvm.vec) -> !llvm.vec { + %0 = llvm.fadd %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : !llvm.vec + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : !llvm.vec, !llvm.vec + llvm.return %1 : !llvm.vec + } + llvm.func @select_nnan_nsz_fadd_nxv4f32_swapops(%arg0: !llvm.vec, %arg1: !llvm.vec, %arg2: !llvm.vec) -> !llvm.vec { + %0 = llvm.fadd %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : !llvm.vec + %1 = llvm.select %arg0, %arg1, %0 {fastmathFlags = #llvm.fastmath} : !llvm.vec, !llvm.vec + llvm.return %1 : !llvm.vec + } + llvm.func @select_nnan_fmul(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fmul %arg1, %arg2 : f32 + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fmul_swapped(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fmul %arg1, %arg2 : f32 + %1 = llvm.select %arg0, %arg1, %0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fmul_fast_math(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fmul %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fmul_swapped_fast_math(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fmul %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %arg0, %arg1, %0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fsub(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fsub %arg1, %arg2 : f32 + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fsub_swapped(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fsub %arg1, %arg2 : f32 + %1 = llvm.select %arg0, %arg1, %0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fsub_fast_math(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fsub %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fsub_swapped_fast_math(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fsub %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %arg0, %arg1, %0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_nsz_fsub_v4f32(%arg0: vector<4xi1>, %arg1: vector<4xf32>, %arg2: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.fsub %arg1, %arg2 : vector<4xf32> + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : vector<4xi1>, vector<4xf32> + llvm.return %1 : vector<4xf32> + } + llvm.func @select_nnan_nsz_fsub_nxv4f32(%arg0: !llvm.vec, %arg1: !llvm.vec, %arg2: !llvm.vec) -> !llvm.vec { + %0 = llvm.fsub %arg1, %arg2 : !llvm.vec + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : !llvm.vec, !llvm.vec + llvm.return %1 : !llvm.vec + } + llvm.func @select_nnan_fsub_invalid(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fsub %arg2, %arg1 : f32 + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fdiv(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fdiv %arg1, %arg2 : f32 + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fdiv_swapped(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fdiv %arg1, %arg2 : f32 + %1 = llvm.select %arg0, %arg1, %0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fdiv_fast_math(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fdiv_swapped_fast_math(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fdiv %arg1, %arg2 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %arg0, %arg1, %0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_nnan_fdiv_invalid(%arg0: i1, %arg1: f32, %arg2: f32) -> f32 { + %0 = llvm.fdiv %arg2, %arg1 : f32 + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/select-bitext-bitwise-ops.ll.mlir b/test/LLVMDialect/InstCombine/select-bitext-bitwise-ops.ll.mlir new file mode 100644 index 000000000..b0840ee36 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-bitext-bitwise-ops.ll.mlir @@ -0,0 +1,74 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @sel_false_val_is_a_masked_shl_of_true_val1(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %1 overflow : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @sel_false_val_is_a_masked_shl_of_true_val2(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %1 overflow : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %4, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @sel_false_val_is_a_masked_lshr_of_true_val1(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(60 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @sel_false_val_is_a_masked_lshr_of_true_val2(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(60 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %4, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @sel_false_val_is_a_masked_ashr_of_true_val1(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-2147483588 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.ashr %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @sel_false_val_is_a_masked_ashr_of_true_val2(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-2147483588 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.ashr %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %4, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/select-bitext.ll.mlir b/test/LLVMDialect/InstCombine/select-bitext.ll.mlir new file mode 100644 index 000000000..393697acd --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-bitext.ll.mlir @@ -0,0 +1,362 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @sel_sext_constants(%arg0: i1) -> i16 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(42 : i8) : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i8 + %3 = llvm.sext %2 : i8 to i16 + llvm.return %3 : i16 + } + llvm.func @sel_zext_constants(%arg0: i1) -> i16 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(42 : i8) : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i8 + %3 = llvm.zext %2 : i8 to i16 + llvm.return %3 : i16 + } + llvm.func @sel_fpext_constants(%arg0: i1) -> f64 { + %0 = llvm.mlir.constant(-2.550000e+02 : f32) : f32 + %1 = llvm.mlir.constant(4.200000e+01 : f32) : f32 + %2 = llvm.select %arg0, %0, %1 : i1, f32 + %3 = llvm.fpext %2 : f32 to f64 + llvm.return %3 : f64 + } + llvm.func @sel_sext(%arg0: i32, %arg1: i1) -> i64 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.select %arg1, %arg0, %0 : i1, i32 + %2 = llvm.sext %1 : i32 to i64 + llvm.return %2 : i64 + } + llvm.func @sel_sext_vec(%arg0: vector<4xi32>, %arg1: vector<4xi1>) -> vector<4xi64> { + %0 = llvm.mlir.constant(dense<42> : vector<4xi32>) : vector<4xi32> + %1 = llvm.select %arg1, %arg0, %0 : vector<4xi1>, vector<4xi32> + %2 = llvm.sext %1 : vector<4xi32> to vector<4xi64> + llvm.return %2 : vector<4xi64> + } + llvm.func @sel_zext(%arg0: i32, %arg1: i1) -> i64 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.select %arg1, %arg0, %0 : i1, i32 + %2 = llvm.zext %1 : i32 to i64 + llvm.return %2 : i64 + } + llvm.func @sel_zext_vec(%arg0: vector<4xi32>, %arg1: vector<4xi1>) -> vector<4xi64> { + %0 = llvm.mlir.constant(dense<42> : vector<4xi32>) : vector<4xi32> + %1 = llvm.select %arg1, %arg0, %0 : vector<4xi1>, vector<4xi32> + %2 = llvm.zext %1 : vector<4xi32> to vector<4xi64> + llvm.return %2 : vector<4xi64> + } + llvm.func @trunc_sel_larger_sext(%arg0: i32, %arg1: i1) -> i64 { + %0 = llvm.mlir.constant(42 : i16) : i16 + %1 = llvm.trunc %arg0 : i32 to i16 + %2 = llvm.select %arg1, %1, %0 : i1, i16 + %3 = llvm.sext %2 : i16 to i64 + llvm.return %3 : i64 + } + llvm.func @trunc_sel_larger_sext_vec(%arg0: vector<2xi32>, %arg1: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[42, 43]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.trunc %arg0 : vector<2xi32> to vector<2xi16> + %2 = llvm.select %arg1, %1, %0 : vector<2xi1>, vector<2xi16> + %3 = llvm.sext %2 : vector<2xi16> to vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @trunc_sel_smaller_sext(%arg0: i64, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(42 : i16) : i16 + %1 = llvm.trunc %arg0 : i64 to i16 + %2 = llvm.select %arg1, %1, %0 : i1, i16 + %3 = llvm.sext %2 : i16 to i32 + llvm.return %3 : i32 + } + llvm.func @trunc_sel_smaller_sext_vec(%arg0: vector<2xi64>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 43]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi16> + %2 = llvm.select %arg1, %1, %0 : vector<2xi1>, vector<2xi16> + %3 = llvm.sext %2 : vector<2xi16> to vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @trunc_sel_equal_sext(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(42 : i16) : i16 + %1 = llvm.trunc %arg0 : i32 to i16 + %2 = llvm.select %arg1, %1, %0 : i1, i16 + %3 = llvm.sext %2 : i16 to i32 + llvm.return %3 : i32 + } + llvm.func @trunc_sel_equal_sext_vec(%arg0: vector<2xi32>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 43]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.trunc %arg0 : vector<2xi32> to vector<2xi16> + %2 = llvm.select %arg1, %1, %0 : vector<2xi1>, vector<2xi16> + %3 = llvm.sext %2 : vector<2xi16> to vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @trunc_sel_larger_zext(%arg0: i32, %arg1: i1) -> i64 { + %0 = llvm.mlir.constant(42 : i16) : i16 + %1 = llvm.trunc %arg0 : i32 to i16 + %2 = llvm.select %arg1, %1, %0 : i1, i16 + %3 = llvm.zext %2 : i16 to i64 + llvm.return %3 : i64 + } + llvm.func @trunc_sel_larger_zext_vec(%arg0: vector<2xi32>, %arg1: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[42, 43]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.trunc %arg0 : vector<2xi32> to vector<2xi16> + %2 = llvm.select %arg1, %1, %0 : vector<2xi1>, vector<2xi16> + %3 = llvm.zext %2 : vector<2xi16> to vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @trunc_sel_smaller_zext(%arg0: i64, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(42 : i16) : i16 + %1 = llvm.trunc %arg0 : i64 to i16 + %2 = llvm.select %arg1, %1, %0 : i1, i16 + %3 = llvm.zext %2 : i16 to i32 + llvm.return %3 : i32 + } + llvm.func @trunc_sel_smaller_zext_vec(%arg0: vector<2xi64>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 43]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi16> + %2 = llvm.select %arg1, %1, %0 : vector<2xi1>, vector<2xi16> + %3 = llvm.zext %2 : vector<2xi16> to vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @trunc_sel_equal_zext(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(42 : i16) : i16 + %1 = llvm.trunc %arg0 : i32 to i16 + %2 = llvm.select %arg1, %1, %0 : i1, i16 + %3 = llvm.zext %2 : i16 to i32 + llvm.return %3 : i32 + } + llvm.func @trunc_sel_equal_zext_vec(%arg0: vector<2xi32>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 43]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.trunc %arg0 : vector<2xi32> to vector<2xi16> + %2 = llvm.select %arg1, %1, %0 : vector<2xi1>, vector<2xi16> + %3 = llvm.zext %2 : vector<2xi16> to vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @trunc_sel_larger_fpext(%arg0: f32, %arg1: i1) -> f64 { + %0 = llvm.mlir.constant(4.200000e+01 : f16) : f16 + %1 = llvm.fptrunc %arg0 : f32 to f16 + %2 = llvm.select %arg1, %1, %0 : i1, f16 + %3 = llvm.fpext %2 : f16 to f64 + llvm.return %3 : f64 + } + llvm.func @trunc_sel_larger_fpext_vec(%arg0: vector<2xf32>, %arg1: vector<2xi1>) -> vector<2xf64> { + %0 = llvm.mlir.constant(dense<[4.200000e+01, 4.300000e+01]> : vector<2xf16>) : vector<2xf16> + %1 = llvm.fptrunc %arg0 : vector<2xf32> to vector<2xf16> + %2 = llvm.select %arg1, %1, %0 : vector<2xi1>, vector<2xf16> + %3 = llvm.fpext %2 : vector<2xf16> to vector<2xf64> + llvm.return %3 : vector<2xf64> + } + llvm.func @trunc_sel_smaller_fpext(%arg0: f64, %arg1: i1) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f16) : f16 + %1 = llvm.fptrunc %arg0 : f64 to f16 + %2 = llvm.select %arg1, %1, %0 : i1, f16 + %3 = llvm.fpext %2 : f16 to f32 + llvm.return %3 : f32 + } + llvm.func @trunc_sel_smaller_fpext_vec(%arg0: vector<2xf64>, %arg1: vector<2xi1>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[4.200000e+01, 4.300000e+01]> : vector<2xf16>) : vector<2xf16> + %1 = llvm.fptrunc %arg0 : vector<2xf64> to vector<2xf16> + %2 = llvm.select %arg1, %1, %0 : vector<2xi1>, vector<2xf16> + %3 = llvm.fpext %2 : vector<2xf16> to vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @trunc_sel_equal_fpext(%arg0: f32, %arg1: i1) -> f32 { + %0 = llvm.mlir.constant(4.200000e+01 : f16) : f16 + %1 = llvm.fptrunc %arg0 : f32 to f16 + %2 = llvm.select %arg1, %1, %0 : i1, f16 + %3 = llvm.fpext %2 : f16 to f32 + llvm.return %3 : f32 + } + llvm.func @trunc_sel_equal_fpext_vec(%arg0: vector<2xf32>, %arg1: vector<2xi1>) -> vector<2xf32> { + %0 = llvm.mlir.constant(dense<[4.200000e+01, 4.300000e+01]> : vector<2xf16>) : vector<2xf16> + %1 = llvm.fptrunc %arg0 : vector<2xf32> to vector<2xf16> + %2 = llvm.select %arg1, %1, %0 : vector<2xi1>, vector<2xf16> + %3 = llvm.fpext %2 : vector<2xf16> to vector<2xf32> + llvm.return %3 : vector<2xf32> + } + llvm.func @test_sext1(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.select %arg1, %1, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @test_sext2(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.select %arg1, %0, %1 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @test_sext3(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.select %arg1, %0, %1 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @test_sext4(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.select %arg1, %1, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @test_zext1(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.select %arg1, %1, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @test_zext2(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.select %arg1, %0, %1 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @test_zext3(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.select %arg1, %0, %1 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @test_zext4(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.select %arg1, %1, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @test_negative_sext(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.select %arg1, %1, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @test_negative_zext(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.select %arg1, %1, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @test_bits_sext(%arg0: i8, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(-128 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.select %arg1, %1, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @test_bits_zext(%arg0: i8, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.select %arg1, %1, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @sel_sext_const_uses(%arg0: i8, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(127 : i32) : i32 + %2 = llvm.icmp "ugt" %arg1, %0 : i8 + %3 = llvm.sext %arg0 : i8 to i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.select %2, %3, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @sel_zext_const_uses(%arg0: i8, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(15 : i8) : i8 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.icmp "sgt" %arg1, %0 : i8 + %3 = llvm.zext %arg0 : i8 to i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.select %2, %1, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @test_op_op(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.sext %1 : i1 to i32 + %3 = llvm.icmp "sgt" %arg1, %0 : i32 + %4 = llvm.sext %3 : i1 to i32 + %5 = llvm.icmp "sgt" %arg2, %0 : i32 + %6 = llvm.select %5, %2, %4 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_vectors_sext(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sext %arg0 : vector<2xi1> to vector<2xi32> + %3 = llvm.select %arg1, %2, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @test_vectors_sext_nonsplat(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[0, -1]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.select %arg1, %1, %0 : vector<2xi1>, vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @test_vectors_zext(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi1> to vector<2xi32> + %3 = llvm.select %arg1, %2, %1 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @test_vectors_zext_nonsplat(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[1, 0]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.select %arg1, %1, %0 : vector<2xi1>, vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @scalar_select_of_vectors_sext(%arg0: vector<2xi1>, %arg1: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sext %arg0 : vector<2xi1> to vector<2xi32> + %3 = llvm.select %arg1, %2, %1 : i1, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @scalar_select_of_vectors_zext(%arg0: vector<2xi1>, %arg1: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi1> to vector<2xi32> + %3 = llvm.select %arg1, %2, %1 : i1, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @sext_true_val_must_be_all_ones(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.select %arg0, %1, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @sext_true_val_must_be_all_ones_vec(%arg0: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 12]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.select %arg0, %1, %0 : vector<2xi1>, vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @zext_true_val_must_be_one(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.select %arg0, %1, %0 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @zext_true_val_must_be_one_vec(%arg0: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 12]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.select %arg0, %1, %0 : vector<2xi1>, vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @sext_false_val_must_be_zero(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.select %arg0, %0, %1 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @sext_false_val_must_be_zero_vec(%arg0: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 12]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.select %arg0, %0, %1 : vector<2xi1>, vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @zext_false_val_must_be_zero(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.select %arg0, %0, %1 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @zext_false_val_must_be_zero_vec(%arg0: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 12]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.select %arg0, %0, %1 : vector<2xi1>, vector<2xi32> + llvm.return %2 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/select-cmp-br.ll.mlir b/test/LLVMDialect/InstCombine/select-cmp-br.ll.mlir new file mode 100644 index 000000000..f1e282359 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-cmp-br.ll.mlir @@ -0,0 +1,118 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @bar(!llvm.ptr) + llvm.func @foobar() + llvm.func @test1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(9 : i64) : i64 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.getelementptr inbounds %arg0[%0, 0, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"C", packed (struct<"struct.S", (ptr, i32, i32)>)> + %6 = llvm.load %5 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %7 = llvm.getelementptr inbounds %4[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + %8 = llvm.load %7 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %9 = llvm.icmp "eq" %4, %6 : !llvm.ptr + %10 = llvm.select %9, %arg0, %3 : i1, !llvm.ptr + %11 = llvm.icmp "eq" %10, %3 : !llvm.ptr + llvm.cond_br %11, ^bb3, ^bb2 + ^bb1: // 2 preds: ^bb2, ^bb3 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @bar(%10) : (!llvm.ptr) -> () + llvm.br ^bb1 + ^bb3: // pred: ^bb0 + %12 = llvm.call %8(%arg0) : !llvm.ptr, (!llvm.ptr) -> i64 + llvm.br ^bb1 + } + llvm.func @test2(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(9 : i64) : i64 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.getelementptr inbounds %arg0[%0, 0, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"C", packed (struct<"struct.S", (ptr, i32, i32)>)> + %6 = llvm.load %5 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %7 = llvm.getelementptr inbounds %4[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + %8 = llvm.load %7 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %9 = llvm.icmp "eq" %4, %6 : !llvm.ptr + %10 = llvm.select %9, %3, %arg0 : i1, !llvm.ptr + %11 = llvm.icmp "eq" %10, %3 : !llvm.ptr + llvm.cond_br %11, ^bb3, ^bb2 + ^bb1: // 2 preds: ^bb2, ^bb3 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @bar(%10) : (!llvm.ptr) -> () + llvm.br ^bb1 + ^bb3: // pred: ^bb0 + %12 = llvm.call %8(%arg0) : !llvm.ptr, (!llvm.ptr) -> i64 + llvm.br ^bb1 + } + llvm.func @test3(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(9 : i64) : i64 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.getelementptr inbounds %arg0[%0, 0, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"C", packed (struct<"struct.S", (ptr, i32, i32)>)> + %6 = llvm.load %5 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %7 = llvm.getelementptr inbounds %4[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + %8 = llvm.load %7 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %9 = llvm.icmp "eq" %4, %6 : !llvm.ptr + %10 = llvm.select %9, %arg0, %3 : i1, !llvm.ptr + %11 = llvm.icmp "ne" %10, %3 : !llvm.ptr + llvm.cond_br %11, ^bb2, ^bb3 + ^bb1: // 2 preds: ^bb2, ^bb3 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @bar(%10) : (!llvm.ptr) -> () + llvm.br ^bb1 + ^bb3: // pred: ^bb0 + %12 = llvm.call %8(%arg0) : !llvm.ptr, (!llvm.ptr) -> i64 + llvm.br ^bb1 + } + llvm.func @test4(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(9 : i64) : i64 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %5 = llvm.getelementptr inbounds %arg0[%0, 0, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<"C", packed (struct<"struct.S", (ptr, i32, i32)>)> + %6 = llvm.load %5 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %7 = llvm.getelementptr inbounds %4[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + %8 = llvm.load %7 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %9 = llvm.icmp "eq" %4, %6 : !llvm.ptr + %10 = llvm.select %9, %3, %arg0 : i1, !llvm.ptr + %11 = llvm.icmp "ne" %10, %3 : !llvm.ptr + llvm.cond_br %11, ^bb2, ^bb3 + ^bb1: // 2 preds: ^bb2, ^bb3 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @bar(%10) : (!llvm.ptr) -> () + llvm.br ^bb1 + ^bb3: // pred: ^bb0 + %12 = llvm.call %8(%arg0) : !llvm.ptr, (!llvm.ptr) -> i64 + llvm.br ^bb1 + } + llvm.func @test5(%arg0: !llvm.ptr, %arg1: i1) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.select %arg1, %0, %arg0 : i1, !llvm.ptr + %2 = llvm.icmp "ne" %1, %0 : !llvm.ptr + llvm.cond_br %2, ^bb2, ^bb3 + ^bb1: // 2 preds: ^bb2, ^bb3 + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @bar(%1) : (!llvm.ptr) -> () + llvm.br ^bb1 + ^bb3: // pred: ^bb0 + llvm.call @foobar() : () -> () + llvm.br ^bb1 + } + llvm.func @test6(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.select %arg1, %arg0, %0 : i1, i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.cond_br %2, ^bb1, ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb0 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/select-cmp-cttz-ctlz.ll.mlir b/test/LLVMDialect/InstCombine/select-cmp-cttz-ctlz.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/select-cmp-eq-op-fold.ll.mlir b/test/LLVMDialect/InstCombine/select-cmp-eq-op-fold.ll.mlir new file mode 100644 index 000000000..5148f3750 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-cmp-eq-op-fold.ll.mlir @@ -0,0 +1,95 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use.i1(i1) + llvm.func @use.i8(i8) + llvm.func @replace_with_y_noundef(%arg0: i8, %arg1: i8 {llvm.noundef}, %arg2: i8) -> i8 { + %0 = llvm.icmp "eq" %arg0, %arg1 : i8 + %1 = llvm.and %arg0, %arg1 : i8 + %2 = llvm.select %0, %1, %arg2 : i1, i8 + llvm.return %2 : i8 + } + llvm.func @replace_with_x_noundef(%arg0: i8 {llvm.noundef}, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.icmp "ne" %arg0, %arg1 : i8 + llvm.call @use.i1(%0) : (i1) -> () + %1 = llvm.or %arg0, %arg1 : i8 + %2 = llvm.select %0, %arg2, %1 : i1, i8 + llvm.return %2 : i8 + } + llvm.func @replace_with_x_maybe_undef_fail(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.icmp "ne" %arg0, %arg1 : i8 + llvm.call @use.i1(%0) : (i1) -> () + %1 = llvm.or %arg0, %arg1 : i8 + %2 = llvm.select %0, %arg2, %1 : i1, i8 + llvm.return %2 : i8 + } + llvm.func @replace_with_y_for_new_oneuse(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(13 : i8) : i8 + %1 = llvm.mul %arg0, %0 : i8 + %2 = llvm.icmp "eq" %1, %arg1 : i8 + %3 = llvm.add %1, %arg1 overflow : i8 + %4 = llvm.select %2, %3, %arg2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @replace_with_y_for_new_oneuse2(%arg0: i8, %arg1: i8 {llvm.noundef}, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(13 : i8) : i8 + %1 = llvm.mul %arg0, %0 : i8 + %2 = llvm.icmp "eq" %1, %arg1 : i8 + %3 = llvm.add %1, %arg3 overflow : i8 + %4 = llvm.select %2, %3, %arg2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @replace_with_x_for_new_oneuse(%arg0: i8 {llvm.noundef}, %arg1: i8 {llvm.noundef}, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(13 : i8) : i8 + %1 = llvm.mul %arg0, %0 : i8 + %2 = llvm.add %arg1, %arg3 : i8 + %3 = llvm.icmp "eq" %1, %2 : i8 + %4 = llvm.mul %1, %2 : i8 + %5 = llvm.select %3, %4, %arg2 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @replace_with_x_for_new_oneuse2(%arg0: i8 {llvm.noundef}, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(13 : i8) : i8 + %1 = llvm.mul %arg0, %0 : i8 + %2 = llvm.add %arg1, %arg3 : i8 + %3 = llvm.icmp "eq" %1, %2 : i8 + %4 = llvm.mul %arg4, %2 : i8 + %5 = llvm.select %3, %4, %arg2 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @replace_with_x_for_simple_binop(%arg0: i8 {llvm.noundef}, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(13 : i8) : i8 + %1 = llvm.mul %arg0, %0 : i8 + %2 = llvm.add %arg1, %arg3 : i8 + %3 = llvm.icmp "eq" %1, %2 : i8 + %4 = llvm.mul %1, %2 : i8 + llvm.call @use.i8(%2) : (i8) -> () + %5 = llvm.select %3, %4, %arg2 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @replace_with_none_for_new_oneuse_fail_maybe_undef(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(13 : i8) : i8 + %1 = llvm.mul %arg0, %0 : i8 + %2 = llvm.icmp "eq" %1, %arg1 : i8 + %3 = llvm.mul %1, %arg1 : i8 + %4 = llvm.select %2, %3, %arg2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @replace_with_y_for_simple_binop(%arg0: i8, %arg1: i8 {llvm.noundef}, %arg2: i8) -> i8 { + %0 = llvm.icmp "eq" %arg0, %arg1 : i8 + %1 = llvm.mul %arg0, %arg1 overflow : i8 + %2 = llvm.select %0, %1, %arg2 : i1, i8 + llvm.return %2 : i8 + } + llvm.func @replace_with_y_for_simple_binop_fail_multiuse(%arg0: i8, %arg1: i8 {llvm.noundef}, %arg2: i8) -> i8 { + %0 = llvm.icmp "eq" %arg0, %arg1 : i8 + %1 = llvm.mul %arg0, %arg1 overflow : i8 + %2 = llvm.select %0, %1, %arg2 : i1, i8 + llvm.call @use.i8(%1) : (i8) -> () + llvm.return %2 : i8 + } + llvm.func @replace_with_y_for_simple_binop_fail(%arg0: i8, %arg1: i8 {llvm.noundef}, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.icmp "eq" %arg0, %arg1 : i8 + %1 = llvm.mul %arg0, %arg3 overflow : i8 + %2 = llvm.select %0, %1, %arg2 : i1, i8 + llvm.return %2 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/select-cmp.ll.mlir b/test/LLVMDialect/InstCombine/select-cmp.ll.mlir new file mode 100644 index 000000000..f2bfea5f4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-cmp.ll.mlir @@ -0,0 +1,246 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f(%arg0: i1, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.poison : i32 + %1 = llvm.select %arg0, %0, %arg1 : i1, i32 + %2 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.return %2 : i1 + } + llvm.func @icmp_ne_common_op00(%arg0: i1, %arg1: i6, %arg2: i6, %arg3: i6) -> i1 { + %0 = llvm.icmp "ne" %arg1, %arg2 : i6 + %1 = llvm.icmp "ne" %arg1, %arg3 : i6 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_ne_common_op01(%arg0: i1, %arg1: i3, %arg2: i3, %arg3: i3) -> i1 { + %0 = llvm.icmp "ne" %arg1, %arg2 : i3 + %1 = llvm.icmp "ne" %arg3, %arg1 : i3 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_ne_common_op10(%arg0: i1, %arg1: i4, %arg2: i4, %arg3: i4) -> i1 { + %0 = llvm.icmp "ne" %arg2, %arg1 : i4 + %1 = llvm.icmp "ne" %arg1, %arg3 : i4 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_ne_common_op11(%arg0: vector<3xi1>, %arg1: vector<3xi17>, %arg2: vector<3xi17>, %arg3: vector<3xi17>) -> vector<3xi1> { + %0 = llvm.icmp "ne" %arg2, %arg1 : vector<3xi17> + %1 = llvm.icmp "ne" %arg3, %arg1 : vector<3xi17> + %2 = llvm.select %arg0, %0, %1 : vector<3xi1>, vector<3xi1> + llvm.return %2 : vector<3xi1> + } + llvm.func @icmp_eq_common_op00(%arg0: i1, %arg1: i5, %arg2: i5, %arg3: i5) -> i1 { + %0 = llvm.icmp "eq" %arg1, %arg2 : i5 + %1 = llvm.icmp "eq" %arg1, %arg3 : i5 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_eq_common_op01(%arg0: vector<5xi1>, %arg1: vector<5xi7>, %arg2: vector<5xi7>, %arg3: vector<5xi7>) -> vector<5xi1> { + %0 = llvm.icmp "eq" %arg1, %arg2 : vector<5xi7> + %1 = llvm.icmp "eq" %arg3, %arg1 : vector<5xi7> + %2 = llvm.select %arg0, %0, %1 : vector<5xi1>, vector<5xi1> + llvm.return %2 : vector<5xi1> + } + llvm.func @icmp_eq_common_op10(%arg0: i1, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.icmp "eq" %arg2, %arg1 : i32 + %1 = llvm.icmp "eq" %arg1, %arg3 : i32 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_eq_common_op11(%arg0: i1, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 { + %0 = llvm.icmp "eq" %arg2, %arg1 : i64 + %1 = llvm.icmp "eq" %arg3, %arg1 : i64 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_common_one_use_1(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8) -> i1 { + %0 = llvm.icmp "eq" %arg2, %arg1 : i8 + llvm.call @use(%0) : (i1) -> () + %1 = llvm.icmp "eq" %arg3, %arg1 : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_slt_common(%arg0: i1, %arg1: i6, %arg2: i6, %arg3: i6) -> i1 { + %0 = llvm.icmp "slt" %arg1, %arg2 : i6 + %1 = llvm.icmp "slt" %arg1, %arg3 : i6 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_sgt_common(%arg0: i1, %arg1: i6, %arg2: i6, %arg3: i6) -> i1 { + %0 = llvm.icmp "sgt" %arg1, %arg2 : i6 + %1 = llvm.icmp "sgt" %arg1, %arg3 : i6 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_sle_common(%arg0: i1, %arg1: i6, %arg2: i6, %arg3: i6) -> i1 { + %0 = llvm.icmp "sle" %arg2, %arg1 : i6 + %1 = llvm.icmp "sle" %arg3, %arg1 : i6 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_sge_common(%arg0: i1, %arg1: i6, %arg2: i6, %arg3: i6) -> i1 { + %0 = llvm.icmp "sge" %arg2, %arg1 : i6 + %1 = llvm.icmp "sge" %arg3, %arg1 : i6 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_slt_sgt_common(%arg0: i1, %arg1: i6, %arg2: i6, %arg3: i6) -> i1 { + %0 = llvm.icmp "slt" %arg1, %arg2 : i6 + %1 = llvm.icmp "sgt" %arg3, %arg1 : i6 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_sle_sge_common(%arg0: i1, %arg1: i6, %arg2: i6, %arg3: i6) -> i1 { + %0 = llvm.icmp "sle" %arg2, %arg1 : i6 + %1 = llvm.icmp "sge" %arg1, %arg3 : i6 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_ult_common(%arg0: i1, %arg1: i6, %arg2: i6, %arg3: i6) -> i1 { + %0 = llvm.icmp "ult" %arg1, %arg2 : i6 + %1 = llvm.icmp "ult" %arg1, %arg3 : i6 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_ule_common(%arg0: i1, %arg1: i6, %arg2: i6, %arg3: i6) -> i1 { + %0 = llvm.icmp "ule" %arg2, %arg1 : i6 + %1 = llvm.icmp "ule" %arg3, %arg1 : i6 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_ugt_common(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8) -> i1 { + %0 = llvm.icmp "ugt" %arg2, %arg1 : i8 + %1 = llvm.icmp "ugt" %arg3, %arg1 : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_uge_common(%arg0: i1, %arg1: i6, %arg2: i6, %arg3: i6) -> i1 { + %0 = llvm.icmp "uge" %arg2, %arg1 : i6 + %1 = llvm.icmp "uge" %arg3, %arg1 : i6 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_ult_ugt_common(%arg0: i1, %arg1: i6, %arg2: i6, %arg3: i6) -> i1 { + %0 = llvm.icmp "ult" %arg1, %arg2 : i6 + %1 = llvm.icmp "ugt" %arg3, %arg1 : i6 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_ule_uge_common(%arg0: i1, %arg1: i6, %arg2: i6, %arg3: i6) -> i1 { + %0 = llvm.icmp "ule" %arg2, %arg1 : i6 + %1 = llvm.icmp "uge" %arg1, %arg3 : i6 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_common_pred_different(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8) -> i1 { + %0 = llvm.icmp "eq" %arg2, %arg1 : i8 + %1 = llvm.icmp "ne" %arg3, %arg1 : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_common_pred_not_swap(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8) -> i1 { + %0 = llvm.icmp "slt" %arg2, %arg1 : i8 + %1 = llvm.icmp "sle" %arg3, %arg1 : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_common_pred_not_commute_pred(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8) -> i1 { + %0 = llvm.icmp "slt" %arg2, %arg1 : i8 + %1 = llvm.icmp "sgt" %arg3, %arg1 : i8 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_common_one_use_0(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8) -> i1 { + %0 = llvm.icmp "eq" %arg2, %arg1 : i8 + llvm.call @use(%0) : (i1) -> () + %1 = llvm.icmp "eq" %arg3, %arg1 : i8 + llvm.call @use(%1) : (i1) -> () + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @icmp_no_common(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "eq" %arg2, %0 : i8 + %2 = llvm.icmp "eq" %arg3, %arg1 : i8 + %3 = llvm.select %arg0, %1, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @test_select_inverse_eq(%arg0: i64, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "ne" %arg0, %0 : i64 + %2 = llvm.icmp "eq" %arg0, %0 : i64 + %3 = llvm.select %arg1, %1, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @test_select_inverse_signed(%arg0: i64, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + %3 = llvm.icmp "slt" %arg0, %1 : i64 + %4 = llvm.select %arg1, %2, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @test_select_inverse_unsigned(%arg0: i64, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(11 : i64) : i64 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.icmp "ult" %arg0, %0 : i64 + %3 = llvm.icmp "ugt" %arg0, %1 : i64 + %4 = llvm.select %arg1, %2, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @test_select_inverse_eq_ptr(%arg0: !llvm.ptr, %arg1: i1) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + %3 = llvm.select %arg1, %1, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @test_select_inverse_fail(%arg0: i64, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "sgt" %arg0, %0 : i64 + %2 = llvm.icmp "slt" %arg0, %0 : i64 + %3 = llvm.select %arg1, %1, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @test_select_inverse_vec(%arg0: vector<2xi64>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.icmp "ne" %arg0, %1 : vector<2xi64> + %3 = llvm.icmp "eq" %arg0, %1 : vector<2xi64> + %4 = llvm.select %arg1, %2, %3 : vector<2xi1>, vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @test_select_inverse_vec_fail(%arg0: vector<2xi64>, %arg1: i1) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.icmp "ne" %arg0, %1 : vector<2xi64> + %3 = llvm.icmp "eq" %arg0, %1 : vector<2xi64> + %4 = llvm.select %arg1, %2, %3 : i1, vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @test_select_inverse_nonconst1(%arg0: i64, %arg1: i64, %arg2: i1) -> i1 { + %0 = llvm.icmp "ne" %arg0, %arg1 : i64 + %1 = llvm.icmp "eq" %arg0, %arg1 : i64 + %2 = llvm.select %arg2, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @test_select_inverse_nonconst2(%arg0: i64, %arg1: i64, %arg2: i1) -> i1 { + %0 = llvm.icmp "ne" %arg0, %arg1 : i64 + %1 = llvm.icmp "eq" %arg1, %arg0 : i64 + %2 = llvm.select %arg2, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @test_select_inverse_nonconst3(%arg0: i64, %arg1: i64, %arg2: i1) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i64 + %1 = llvm.icmp "uge" %arg0, %arg1 : i64 + %2 = llvm.select %arg2, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @test_select_inverse_nonconst4(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i1) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i64 + %1 = llvm.icmp "uge" %arg2, %arg1 : i64 + %2 = llvm.select %arg3, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @use(i1) +} diff --git a/test/LLVMDialect/InstCombine/select-cmpxchg.ll.mlir b/test/LLVMDialect/InstCombine/select-cmpxchg.ll.mlir new file mode 100644 index 000000000..2b8eec9b1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-cmpxchg.ll.mlir @@ -0,0 +1,24 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @cmpxchg_0(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.cmpxchg %arg0, %arg1, %arg2 seq_cst seq_cst {alignment = 8 : i64} : !llvm.ptr, i64 + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i64, i1)> + %2 = llvm.extractvalue %0[0] : !llvm.struct<(i64, i1)> + %3 = llvm.select %1, %arg1, %2 : i1, i64 + llvm.return %3 : i64 + } + llvm.func @cmpxchg_1(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.cmpxchg %arg0, %arg1, %arg2 seq_cst seq_cst {alignment = 8 : i64} : !llvm.ptr, i64 + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i64, i1)> + %2 = llvm.extractvalue %0[0] : !llvm.struct<(i64, i1)> + %3 = llvm.select %1, %2, %arg1 : i1, i64 + llvm.return %3 : i64 + } + llvm.func @cmpxchg_2(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.cmpxchg %arg0, %arg1, %arg2 acq_rel monotonic {alignment = 8 : i64} : !llvm.ptr, i64 + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i64, i1)> + %2 = llvm.extractvalue %0[0] : !llvm.struct<(i64, i1)> + %3 = llvm.select %1, %arg1, %2 : i1, i64 + %4 = llvm.select %1, %3, %arg1 : i1, i64 + llvm.return %4 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/select-crash.ll.mlir b/test/LLVMDialect/InstCombine/select-crash.ll.mlir new file mode 100644 index 000000000..1284507e1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-crash.ll.mlir @@ -0,0 +1,26 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func fastcc @gimp_operation_color_balance_map(%arg0: f32, %arg1: f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["inlinehint", "nounwind"]} { + %0 = llvm.mlir.constant(1.600000e+01 : f64) : f64 + %1 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %2 = llvm.mlir.constant(1.075000e+00 : f64) : f64 + %3 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %4 = llvm.fpext %arg0 : f32 to f64 + %5 = llvm.fdiv %4, %0 : f64 + %6 = llvm.fadd %5, %1 : f64 + %7 = llvm.fdiv %1, %6 : f64 + %8 = llvm.fsub %2, %7 : f64 + %9 = llvm.fsub %1, %8 : f64 + %10 = llvm.fadd %8, %1 : f64 + %11 = llvm.fcmp "ogt" %arg1, %3 : f64 + %12 = llvm.select %11, %9, %10 : i1, f64 + %13 = llvm.fmul %arg1, %12 : f64 + %14 = llvm.fadd %13, %13 : f64 + llvm.return %14 : f64 + } + llvm.func @foo(%arg0: i1, %arg1: vector<4xf32>, %arg2: vector<4xf32>, %arg3: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.fadd %arg1, %arg2 : vector<4xf32> + %1 = llvm.fsub %arg1, %arg3 : vector<4xf32> + %2 = llvm.select %arg0, %0, %1 : i1, vector<4xf32> + llvm.return %2 : vector<4xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/select-ctlz-to-cttz.ll.mlir b/test/LLVMDialect/InstCombine/select-ctlz-to-cttz.ll.mlir new file mode 100644 index 000000000..fa3a819a4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-ctlz-to-cttz.ll.mlir @@ -0,0 +1,222 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @use2(i1) + llvm.func @select_clz_to_ctz(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = true}> : (i32) -> i32 + %5 = llvm.icmp "eq" %arg0, %0 : i32 + %6 = llvm.xor %4, %1 : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @select_clz_to_ctz_preserve_flag(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + %5 = llvm.icmp "eq" %arg0, %0 : i32 + %6 = llvm.xor %4, %1 : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @select_clz_to_ctz_constant_for_zero(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.sub %0, %arg0 : i32 + %4 = llvm.and %3, %arg0 : i32 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = false}> : (i32) -> i32 + %6 = llvm.icmp "eq" %arg0, %0 : i32 + %7 = llvm.xor %5, %1 : i32 + %8 = llvm.select %6, %2, %7 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @select_clz_to_ctz_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %3 = llvm.sub %1, %arg0 : vector<2xi32> + %4 = llvm.and %3, %arg0 : vector<2xi32> + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = true}> : (vector<2xi32>) -> vector<2xi32> + %6 = llvm.icmp "eq" %arg0, %1 : vector<2xi32> + %7 = llvm.xor %5, %2 : vector<2xi32> + %8 = llvm.select %6, %5, %7 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @select_clz_to_ctz_extra_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = true}> : (i32) -> i32 + %5 = llvm.icmp "eq" %arg0, %0 : i32 + %6 = llvm.xor %4, %1 : i32 + llvm.call @use(%6) : (i32) -> () + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @select_clz_to_ctz_and_commuted(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %arg0, %2 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = true}> : (i32) -> i32 + %5 = llvm.icmp "eq" %arg0, %0 : i32 + %6 = llvm.xor %4, %1 : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @select_clz_to_ctz_icmp_ne(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = true}> : (i32) -> i32 + %5 = llvm.icmp "ne" %arg0, %0 : i32 + llvm.call @use2(%5) : (i1) -> () + %6 = llvm.xor %4, %1 : i32 + %7 = llvm.select %5, %6, %4 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @select_clz_to_ctz_i64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(63 : i64) : i64 + %2 = llvm.sub %0, %arg0 : i64 + %3 = llvm.and %2, %arg0 : i64 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = true}> : (i64) -> i64 + %5 = llvm.icmp "eq" %arg0, %0 : i64 + %6 = llvm.xor %4, %1 : i64 + %7 = llvm.select %5, %4, %6 : i1, i64 + llvm.return %7 : i64 + } + llvm.func @select_clz_to_ctz_wrong_sub(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(31 : i32) : i32 + %3 = llvm.sub %0, %arg0 : i32 + %4 = llvm.and %3, %arg0 : i32 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = true}> : (i32) -> i32 + %6 = llvm.icmp "eq" %arg0, %1 : i32 + %7 = llvm.xor %5, %2 : i32 + %8 = llvm.select %6, %5, %7 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @select_clz_to_ctz_i64_wrong_xor(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(64 : i64) : i64 + %2 = llvm.sub %0, %arg0 : i64 + %3 = llvm.and %2, %arg0 : i64 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = true}> : (i64) -> i64 + %5 = llvm.icmp "eq" %arg0, %0 : i64 + %6 = llvm.xor %4, %1 : i64 + %7 = llvm.select %5, %4, %6 : i1, i64 + llvm.return %7 : i64 + } + llvm.func @select_clz_to_ctz_i64_wrong_icmp_cst(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(63 : i64) : i64 + %3 = llvm.sub %0, %arg0 : i64 + %4 = llvm.and %3, %arg0 : i64 + %5 = "llvm.intr.ctlz"(%4) <{is_zero_poison = true}> : (i64) -> i64 + %6 = llvm.icmp "eq" %arg0, %1 : i64 + %7 = llvm.xor %5, %2 : i64 + %8 = llvm.select %6, %5, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @select_clz_to_ctz_i64_wrong_icmp_pred(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(63 : i64) : i64 + %2 = llvm.sub %0, %arg0 : i64 + %3 = llvm.and %2, %arg0 : i64 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = true}> : (i64) -> i64 + %5 = llvm.icmp "slt" %arg0, %0 : i64 + %6 = llvm.xor %4, %1 : i64 + %7 = llvm.select %5, %4, %6 : i1, i64 + llvm.return %7 : i64 + } + llvm.func @select_clz_to_ctz_vec_with_undef(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.undef : i32 + %3 = llvm.mlir.constant(31 : i32) : i32 + %4 = llvm.mlir.undef : vector<2xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi32> + %9 = llvm.sub %1, %arg0 : vector<2xi32> + %10 = llvm.and %9, %arg0 : vector<2xi32> + %11 = "llvm.intr.ctlz"(%10) <{is_zero_poison = true}> : (vector<2xi32>) -> vector<2xi32> + %12 = llvm.icmp "eq" %arg0, %1 : vector<2xi32> + %13 = llvm.xor %11, %8 : vector<2xi32> + %14 = llvm.select %12, %11, %13 : vector<2xi1>, vector<2xi32> + llvm.return %14 : vector<2xi32> + } + llvm.func @select_clz_to_ctz_wrong_constant_for_zero(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + %5 = llvm.icmp "eq" %arg0, %0 : i32 + %6 = llvm.xor %4, %1 : i32 + %7 = llvm.select %5, %1, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @PR45762(%arg0: i3) -> i4 { + %0 = llvm.mlir.constant(0 : i3) : i3 + %1 = llvm.mlir.constant(3 : i3) : i3 + %2 = llvm.mlir.constant(1 : i4) : i4 + %3 = llvm.mlir.constant(0 : i4) : i4 + %4 = llvm.mlir.constant(2 : i4) : i4 + %5 = llvm.mlir.constant(false) : i1 + %6 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i3) -> i3 + %7 = llvm.icmp "eq" %arg0, %0 : i3 + %8 = llvm.select %7, %1, %6 : i1, i3 + %9 = llvm.zext %8 : i3 to i4 + %10 = llvm.shl %2, %9 : i4 + %11 = llvm.lshr %10, %3 : i4 + %12 = llvm.trunc %11 : i4 to i1 + %13 = llvm.lshr %10, %2 : i4 + %14 = llvm.trunc %13 : i4 to i1 + %15 = llvm.lshr %10, %4 : i4 + %16 = llvm.trunc %15 : i4 to i1 + %17 = llvm.or %12, %14 : i1 + %18 = llvm.or %17, %16 : i1 + %19 = llvm.mul %10, %10 : i4 + %20 = llvm.icmp "eq" %18, %5 : i1 + %21 = llvm.select %20, %10, %19 : i1, i4 + llvm.return %21 : i4 + } + llvm.func @PR45762_logical(%arg0: i3) -> i4 { + %0 = llvm.mlir.constant(0 : i3) : i3 + %1 = llvm.mlir.constant(3 : i3) : i3 + %2 = llvm.mlir.constant(1 : i4) : i4 + %3 = llvm.mlir.constant(0 : i4) : i4 + %4 = llvm.mlir.constant(2 : i4) : i4 + %5 = llvm.mlir.constant(true) : i1 + %6 = llvm.mlir.constant(false) : i1 + %7 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = false}> : (i3) -> i3 + %8 = llvm.icmp "eq" %arg0, %0 : i3 + %9 = llvm.select %8, %1, %7 : i1, i3 + %10 = llvm.zext %9 : i3 to i4 + %11 = llvm.shl %2, %10 : i4 + %12 = llvm.lshr %11, %3 : i4 + %13 = llvm.trunc %12 : i4 to i1 + %14 = llvm.lshr %11, %2 : i4 + %15 = llvm.trunc %14 : i4 to i1 + %16 = llvm.lshr %11, %4 : i4 + %17 = llvm.trunc %16 : i4 to i1 + %18 = llvm.select %13, %5, %15 : i1, i1 + %19 = llvm.select %18, %5, %17 : i1, i1 + %20 = llvm.mul %11, %11 : i4 + %21 = llvm.icmp "eq" %19, %6 : i1 + %22 = llvm.select %21, %11, %20 : i1, i4 + llvm.return %22 : i4 + } +} diff --git a/test/LLVMDialect/InstCombine/select-divrem.ll.mlir b/test/LLVMDialect/InstCombine/select-divrem.ll.mlir new file mode 100644 index 000000000..eba098f6d --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-divrem.ll.mlir @@ -0,0 +1,201 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @sdiv_common_divisor(%arg0: i1, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.sdiv %arg2, %arg1 : i5 + %1 = llvm.sdiv %arg3, %arg1 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @srem_common_divisor(%arg0: i1, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.srem %arg2, %arg1 : i5 + %1 = llvm.srem %arg3, %arg1 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @udiv_common_divisor(%arg0: i1, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.udiv %arg2, %arg1 : i5 + %1 = llvm.udiv %arg3, %arg1 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @urem_common_divisor(%arg0: i1, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.urem %arg2, %arg1 : i5 + %1 = llvm.urem %arg3, %arg1 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @sdiv_common_dividend(%arg0: i1, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.sdiv %arg1, %arg2 : i5 + %1 = llvm.sdiv %arg1, %arg3 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @srem_common_dividend(%arg0: i1, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.srem %arg1, %arg2 : i5 + %1 = llvm.srem %arg1, %arg3 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @udiv_common_dividend(%arg0: i1, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.udiv %arg1, %arg2 : i5 + %1 = llvm.udiv %arg1, %arg3 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @urem_common_dividend(%arg0: i1, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.urem %arg1, %arg2 : i5 + %1 = llvm.urem %arg1, %arg3 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @sdiv_common_divisor_defined_cond(%arg0: i1 {llvm.noundef}, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.sdiv %arg2, %arg1 : i5 + %1 = llvm.sdiv %arg3, %arg1 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @srem_common_divisor_defined_cond(%arg0: i1 {llvm.noundef}, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.srem %arg2, %arg1 : i5 + %1 = llvm.srem %arg3, %arg1 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @udiv_common_divisor_defined_cond(%arg0: i1 {llvm.noundef}, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.udiv %arg2, %arg1 : i5 + %1 = llvm.udiv %arg3, %arg1 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @urem_common_divisor_defined_cond(%arg0: i1 {llvm.noundef}, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.urem %arg2, %arg1 : i5 + %1 = llvm.urem %arg3, %arg1 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @sdiv_common_dividend_defined_cond(%arg0: i1 {llvm.noundef}, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.sdiv %arg1, %arg2 : i5 + %1 = llvm.sdiv %arg1, %arg3 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @srem_common_dividend_defined_cond(%arg0: i1 {llvm.noundef}, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.srem %arg1, %arg2 : i5 + %1 = llvm.srem %arg1, %arg3 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @udiv_common_dividend_defined_cond(%arg0: i1 {llvm.noundef}, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.udiv %arg1, %arg2 : i5 + %1 = llvm.udiv %arg1, %arg3 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @urem_common_dividend_defined_cond(%arg0: i1 {llvm.noundef}, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.urem %arg1, %arg2 : i5 + %1 = llvm.urem %arg1, %arg3 : i5 + %2 = llvm.select %arg0, %1, %0 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @rem_euclid_1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.add %2, %0 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @rem_euclid_2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + %4 = llvm.add %2, %0 : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @rem_euclid_wrong_sign_test(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + %4 = llvm.add %2, %0 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @rem_euclid_add_different_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.srem %arg0, %0 : i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + %5 = llvm.add %3, %2 : i32 + %6 = llvm.select %4, %5, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @rem_euclid_wrong_operands_select(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.srem %arg0, %0 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.add %2, %0 : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @rem_euclid_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.srem %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "slt" %3, %2 : vector<2xi32> + %5 = llvm.add %3, %0 : vector<2xi32> + %6 = llvm.select %4, %5, %3 : vector<2xi1>, vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @rem_euclid_i128(%arg0: i128) -> i128 { + %0 = llvm.mlir.constant(8 : i128) : i128 + %1 = llvm.mlir.constant(0 : i128) : i128 + %2 = llvm.srem %arg0, %0 : i128 + %3 = llvm.icmp "slt" %2, %1 : i128 + %4 = llvm.add %2, %0 : i128 + %5 = llvm.select %3, %4, %2 : i1, i128 + llvm.return %5 : i128 + } + llvm.func @rem_euclid_non_const_pow2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %0, %arg0 : i8 + %3 = llvm.srem %arg1, %2 : i8 + %4 = llvm.icmp "slt" %3, %1 : i8 + %5 = llvm.add %3, %2 : i8 + %6 = llvm.select %4, %5, %3 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @rem_euclid_pow2_true_arm_folded(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.srem %arg0, %0 : i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + %5 = llvm.select %4, %2, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @rem_euclid_pow2_false_arm_folded(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.srem %arg0, %0 : i32 + %4 = llvm.icmp "sge" %3, %1 : i32 + %5 = llvm.select %4, %3, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @pr89516(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.icmp "slt" %arg1, %0 : i8 + %3 = llvm.shl %1, %arg0 overflow : i8 + %4 = llvm.srem %1, %3 : i8 + %5 = llvm.add %4, %3 overflow : i8 + %6 = llvm.select %2, %5, %4 : i1, i8 + llvm.return %6 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/select-extractelement-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/select-extractelement-inseltpoison.ll.mlir new file mode 100644 index 000000000..898fcd06c --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-extractelement-inseltpoison.ll.mlir @@ -0,0 +1,124 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @v4float_user(vector<4xf32>) attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} + llvm.func @extract_one_select(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: i32) -> f32 attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.icmp "ne" %arg2, %0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, vector<4xf32> + %4 = llvm.extractelement %3[%1 : i32] : vector<4xf32> + llvm.return %4 : f32 + } + llvm.func @extract_two_select(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: i32) -> vector<2xf32> attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.poison : vector<2xf32> + %4 = llvm.icmp "ne" %arg2, %0 : i32 + %5 = llvm.select %4, %arg0, %arg1 : i1, vector<4xf32> + %6 = llvm.extractelement %5[%1 : i32] : vector<4xf32> + %7 = llvm.extractelement %5[%2 : i32] : vector<4xf32> + %8 = llvm.insertelement %6, %3[%0 : i32] : vector<2xf32> + %9 = llvm.insertelement %7, %8[%1 : i32] : vector<2xf32> + llvm.return %9 : vector<2xf32> + } + llvm.func @extract_one_select_user(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: i32) -> f32 attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.icmp "ne" %arg2, %0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, vector<4xf32> + %4 = llvm.extractelement %3[%1 : i32] : vector<4xf32> + llvm.call @v4float_user(%3) : (vector<4xf32>) -> () + llvm.return %4 : f32 + } + llvm.func @extract_one_vselect_user(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: vector<4xi32>) -> f32 attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.icmp "ne" %arg2, %1 : vector<4xi32> + %4 = llvm.select %3, %arg0, %arg1 : vector<4xi1>, vector<4xf32> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xf32> + llvm.call @v4float_user(%4) : (vector<4xf32>) -> () + llvm.return %5 : f32 + } + llvm.func @extract_one_vselect(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: vector<4xi32>) -> f32 attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.icmp "ne" %arg2, %1 : vector<4xi32> + %3 = llvm.select %2, %arg0, %arg1 : vector<4xi1>, vector<4xf32> + %4 = llvm.extractelement %3[%0 : i32] : vector<4xf32> + llvm.return %4 : f32 + } + llvm.func @extract_two_vselect(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: vector<4xi32>) -> vector<2xf32> attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.poison : vector<2xf32> + %5 = llvm.icmp "ne" %arg2, %1 : vector<4xi32> + %6 = llvm.select %5, %arg0, %arg1 : vector<4xi1>, vector<4xf32> + %7 = llvm.extractelement %6[%2 : i32] : vector<4xf32> + %8 = llvm.extractelement %6[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %7, %4[%0 : i32] : vector<2xf32> + %10 = llvm.insertelement %8, %9[%2 : i32] : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @simple_vector_select(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: vector<4xi32>) -> vector<4xf32> attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : vector<4xf32> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.extractelement %arg2[%0 : i32] : vector<4xi32> + %6 = llvm.icmp "ne" %5, %0 : i32 + %7 = llvm.select %6, %arg0, %arg1 : i1, vector<4xf32> + %8 = llvm.extractelement %7[%0 : i32] : vector<4xf32> + %9 = llvm.insertelement %8, %1[%0 : i32] : vector<4xf32> + %10 = llvm.extractelement %arg2[%2 : i32] : vector<4xi32> + %11 = llvm.icmp "ne" %10, %0 : i32 + %12 = llvm.select %11, %arg0, %arg1 : i1, vector<4xf32> + %13 = llvm.extractelement %12[%2 : i32] : vector<4xf32> + %14 = llvm.insertelement %13, %9[%2 : i32] : vector<4xf32> + %15 = llvm.extractelement %arg2[%3 : i32] : vector<4xi32> + %16 = llvm.icmp "ne" %15, %0 : i32 + %17 = llvm.select %16, %arg0, %arg1 : i1, vector<4xf32> + %18 = llvm.extractelement %17[%3 : i32] : vector<4xf32> + %19 = llvm.insertelement %18, %14[%3 : i32] : vector<4xf32> + %20 = llvm.extractelement %arg2[%4 : i32] : vector<4xi32> + %21 = llvm.icmp "ne" %20, %0 : i32 + %22 = llvm.select %21, %arg0, %arg1 : i1, vector<4xf32> + %23 = llvm.extractelement %22[%4 : i32] : vector<4xf32> + %24 = llvm.insertelement %23, %19[%4 : i32] : vector<4xf32> + llvm.return %24 : vector<4xf32> + } + llvm.func @extract_cond(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi1>) -> vector<4xi32> { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.extractelement %arg2[%0 : i32] : vector<4xi1> + %2 = llvm.select %1, %arg0, %arg1 : i1, vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @splat_cond(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi1>) -> vector<4xi32> { + %0 = llvm.mlir.poison : vector<4xi1> + %1 = llvm.shufflevector %arg2, %0 [3, 3, 3, 3] : vector<4xi1> + %2 = llvm.select %1, %arg0, %arg1 : vector<4xi1>, vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @extra_use(i1) + llvm.func @extract_cond_extra_use(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi1>) -> vector<4xi32> { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.extractelement %arg2[%0 : i32] : vector<4xi1> + llvm.call @extra_use(%1) : (i1) -> () + %2 = llvm.select %1, %arg0, %arg1 : i1, vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @extract_cond_variable_index(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi1>, %arg3: i32) -> vector<4xi32> { + %0 = llvm.extractelement %arg2[%arg3 : i32] : vector<4xi1> + %1 = llvm.select %0, %arg0, %arg1 : i1, vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @extract_cond_type_mismatch(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<5xi1>) -> vector<4xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.extractelement %arg2[%0 : i32] : vector<5xi1> + %2 = llvm.select %1, %arg0, %arg1 : i1, vector<4xi32> + llvm.return %2 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/select-extractelement.ll.mlir b/test/LLVMDialect/InstCombine/select-extractelement.ll.mlir new file mode 100644 index 000000000..118e7c8d4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-extractelement.ll.mlir @@ -0,0 +1,150 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @v4float_user(vector<4xf32>) attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} + llvm.func @extract_one_select(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: i32) -> f32 attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.icmp "ne" %arg2, %0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, vector<4xf32> + %4 = llvm.extractelement %3[%1 : i32] : vector<4xf32> + llvm.return %4 : f32 + } + llvm.func @extract_two_select(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: i32) -> vector<2xf32> attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.undef : vector<2xf32> + %4 = llvm.icmp "ne" %arg2, %0 : i32 + %5 = llvm.select %4, %arg0, %arg1 : i1, vector<4xf32> + %6 = llvm.extractelement %5[%1 : i32] : vector<4xf32> + %7 = llvm.extractelement %5[%2 : i32] : vector<4xf32> + %8 = llvm.insertelement %6, %3[%0 : i32] : vector<2xf32> + %9 = llvm.insertelement %7, %8[%1 : i32] : vector<2xf32> + llvm.return %9 : vector<2xf32> + } + llvm.func @extract_one_select_user(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: i32) -> f32 attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.icmp "ne" %arg2, %0 : i32 + %3 = llvm.select %2, %arg0, %arg1 : i1, vector<4xf32> + %4 = llvm.extractelement %3[%1 : i32] : vector<4xf32> + llvm.call @v4float_user(%3) : (vector<4xf32>) -> () + llvm.return %4 : f32 + } + llvm.func @extract_one_vselect_user(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: vector<4xi32>) -> f32 attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.icmp "ne" %arg2, %1 : vector<4xi32> + %4 = llvm.select %3, %arg0, %arg1 : vector<4xi1>, vector<4xf32> + %5 = llvm.extractelement %4[%2 : i32] : vector<4xf32> + llvm.call @v4float_user(%4) : (vector<4xf32>) -> () + llvm.return %5 : f32 + } + llvm.func @extract_one_vselect(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: vector<4xi32>) -> f32 attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.icmp "ne" %arg2, %1 : vector<4xi32> + %3 = llvm.select %2, %arg0, %arg1 : vector<4xi1>, vector<4xf32> + %4 = llvm.extractelement %3[%0 : i32] : vector<4xf32> + llvm.return %4 : f32 + } + llvm.func @extract_two_vselect(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: vector<4xi32>) -> vector<2xf32> attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.icmp "ne" %arg2, %1 : vector<4xi32> + %6 = llvm.select %5, %arg0, %arg1 : vector<4xi1>, vector<4xf32> + %7 = llvm.extractelement %6[%2 : i32] : vector<4xf32> + %8 = llvm.extractelement %6[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %7, %4[%0 : i32] : vector<2xf32> + %10 = llvm.insertelement %8, %9[%2 : i32] : vector<2xf32> + llvm.return %10 : vector<2xf32> + } + llvm.func @simple_vector_select(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: vector<4xi32>) -> vector<4xf32> attributes {frame_pointer = #llvm.framePointerKind, passthrough = ["nounwind", "ssp", ["uwtable", "2"], ["less-precise-fpmad", "false"], ["no-infs-fp-math", "false"], ["no-nans-fp-math", "false"], ["stack-protector-buffer-size", "8"], ["unsafe-fp-math", "false"], ["use-soft-float", "false"]]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xf32> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.extractelement %arg2[%0 : i32] : vector<4xi32> + %6 = llvm.icmp "ne" %5, %0 : i32 + %7 = llvm.select %6, %arg0, %arg1 : i1, vector<4xf32> + %8 = llvm.extractelement %7[%0 : i32] : vector<4xf32> + %9 = llvm.insertelement %8, %1[%0 : i32] : vector<4xf32> + %10 = llvm.extractelement %arg2[%2 : i32] : vector<4xi32> + %11 = llvm.icmp "ne" %10, %0 : i32 + %12 = llvm.select %11, %arg0, %arg1 : i1, vector<4xf32> + %13 = llvm.extractelement %12[%2 : i32] : vector<4xf32> + %14 = llvm.insertelement %13, %9[%2 : i32] : vector<4xf32> + %15 = llvm.extractelement %arg2[%3 : i32] : vector<4xi32> + %16 = llvm.icmp "ne" %15, %0 : i32 + %17 = llvm.select %16, %arg0, %arg1 : i1, vector<4xf32> + %18 = llvm.extractelement %17[%3 : i32] : vector<4xf32> + %19 = llvm.insertelement %18, %14[%3 : i32] : vector<4xf32> + %20 = llvm.extractelement %arg2[%4 : i32] : vector<4xi32> + %21 = llvm.icmp "ne" %20, %0 : i32 + %22 = llvm.select %21, %arg0, %arg1 : i1, vector<4xf32> + %23 = llvm.extractelement %22[%4 : i32] : vector<4xf32> + %24 = llvm.insertelement %23, %19[%4 : i32] : vector<4xf32> + llvm.return %24 : vector<4xf32> + } + llvm.func @extract_cond(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi1>) -> vector<4xi32> { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.extractelement %arg2[%0 : i32] : vector<4xi1> + %2 = llvm.select %1, %arg0, %arg1 : i1, vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @splat_cond(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi1>) -> vector<4xi32> { + %0 = llvm.mlir.undef : vector<4xi1> + %1 = llvm.shufflevector %arg2, %0 [3, 3, 3, 3] : vector<4xi1> + %2 = llvm.select %1, %arg0, %arg1 : vector<4xi1>, vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @extra_use(i1) + llvm.func @extract_cond_extra_use(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi1>) -> vector<4xi32> { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.extractelement %arg2[%0 : i32] : vector<4xi1> + llvm.call @extra_use(%1) : (i1) -> () + %2 = llvm.select %1, %arg0, %arg1 : i1, vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @extract_cond_variable_index(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi1>, %arg3: i32) -> vector<4xi32> { + %0 = llvm.extractelement %arg2[%arg3 : i32] : vector<4xi1> + %1 = llvm.select %0, %arg0, %arg1 : i1, vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @extract_cond_type_mismatch(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<5xi1>) -> vector<4xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.extractelement %arg2[%0 : i32] : vector<5xi1> + %2 = llvm.select %1, %arg0, %arg1 : i1, vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @inf_loop_partial_undef(%arg0: vector<2xi1>, %arg1: vector<2xi1>, %arg2: vector<2xi32>, %arg3: vector<2xi32>) -> i32 { + %0 = llvm.mlir.constant(dense<2147483647> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.poison : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.undef : vector<2xi1> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi1> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi1> + %8 = llvm.mlir.constant(true) : i1 + %9 = llvm.mlir.undef : vector<2xi1> + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.insertelement %8, %9[%10 : i32] : vector<2xi1> + %12 = llvm.mlir.constant(1 : i32) : i32 + %13 = llvm.insertelement %1, %11[%12 : i32] : vector<2xi1> + %14 = llvm.mlir.constant(0 : i32) : i32 + %15 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %16 = llvm.add %arg3, %0 overflow : vector<2xi32> + %17 = llvm.icmp "slt" %16, %arg2 : vector<2xi32> + %18 = llvm.and %arg0, %arg1 : vector<2xi1> + %19 = llvm.select %18, %17, %7 : vector<2xi1>, vector<2xi1> + %20 = llvm.xor %19, %13 : vector<2xi1> + %21 = llvm.select %20, %15, %arg3 : vector<2xi1>, vector<2xi32> + %22 = llvm.extractelement %21[%14 : i32] : vector<2xi32> + llvm.return %22 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/select-factorize.ll.mlir b/test/LLVMDialect/InstCombine/select-factorize.ll.mlir new file mode 100644 index 000000000..a35b9c4cb --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-factorize.ll.mlir @@ -0,0 +1,605 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i1) + llvm.func @logic_and_logic_or_1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %arg1, %0 : i1, i1 + %3 = llvm.select %arg0, %arg2, %0 : i1, i1 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_and_logic_or_2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg1, %arg0, %0 : i1, i1 + %3 = llvm.select %arg0, %arg2, %0 : i1, i1 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_and_logic_or_3(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg1, %arg0, %0 : i1, i1 + %3 = llvm.select %arg2, %arg0, %0 : i1, i1 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_and_logic_or_4(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %arg1, %0 : i1, i1 + %3 = llvm.select %arg2, %arg0, %0 : i1, i1 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_and_logic_or_5(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %arg1, %0 : i1, i1 + %3 = llvm.select %arg0, %arg2, %0 : i1, i1 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_and_logic_or_6(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg1, %arg0, %0 : i1, i1 + %3 = llvm.select %arg0, %arg2, %0 : i1, i1 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_and_logic_or_7(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg1, %arg0, %0 : i1, i1 + %3 = llvm.select %arg2, %arg0, %0 : i1, i1 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_and_logic_or_8(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %arg1, %0 : i1, i1 + %3 = llvm.select %arg2, %arg0, %0 : i1, i1 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_and_logic_or_vector(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %4 = llvm.select %arg0, %arg1, %1 : vector<3xi1>, vector<3xi1> + %5 = llvm.select %arg0, %arg2, %1 : vector<3xi1>, vector<3xi1> + %6 = llvm.select %4, %3, %5 : vector<3xi1>, vector<3xi1> + llvm.return %6 : vector<3xi1> + } + llvm.func @logic_and_logic_or_vector_poison1(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.mlir.poison : i1 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.mlir.undef : vector<3xi1> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<3xi1> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %3, %6[%7 : i32] : vector<3xi1> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %2, %8[%9 : i32] : vector<3xi1> + %11 = llvm.select %arg0, %arg1, %1 : vector<3xi1>, vector<3xi1> + %12 = llvm.select %arg0, %arg2, %1 : vector<3xi1>, vector<3xi1> + %13 = llvm.select %11, %10, %12 : vector<3xi1>, vector<3xi1> + llvm.return %13 : vector<3xi1> + } + llvm.func @logic_and_logic_or_vector_poison2(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.poison : i1 + %2 = llvm.mlir.undef : vector<3xi1> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi1> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi1> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi1> + %9 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %10 = llvm.mlir.constant(true) : i1 + %11 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %12 = llvm.select %arg0, %arg1, %8 : vector<3xi1>, vector<3xi1> + %13 = llvm.select %arg0, %arg2, %9 : vector<3xi1>, vector<3xi1> + %14 = llvm.select %12, %11, %13 : vector<3xi1>, vector<3xi1> + llvm.return %14 : vector<3xi1> + } + llvm.func @logic_and_logic_or_vector_poison3(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.mlir.poison : i1 + %3 = llvm.mlir.undef : vector<3xi1> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi1> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %0, %5[%6 : i32] : vector<3xi1> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi1> + %10 = llvm.mlir.constant(true) : i1 + %11 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %12 = llvm.select %arg0, %arg1, %1 : vector<3xi1>, vector<3xi1> + %13 = llvm.select %arg0, %arg2, %9 : vector<3xi1>, vector<3xi1> + %14 = llvm.select %12, %11, %13 : vector<3xi1>, vector<3xi1> + llvm.return %14 : vector<3xi1> + } + llvm.func @logic_and_logic_or_not_one_use(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %arg1, %0 : i1, i1 + %3 = llvm.select %arg0, %arg2, %0 : i1, i1 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.call @use(%2) : (i1) -> () + llvm.call @use(%3) : (i1) -> () + llvm.return %4 : i1 + } + llvm.func @and_logic_and_logic_or_1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.and %arg0, %arg1 : i1 + %3 = llvm.select %arg0, %arg2, %0 : i1, i1 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @and_logic_and_logic_or_2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.and %arg0, %arg1 : i1 + %3 = llvm.select %arg2, %arg0, %0 : i1, i1 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @and_logic_and_logic_or_3(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.and %arg1, %arg0 : i1 + %3 = llvm.select %arg0, %arg2, %0 : i1, i1 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @and_logic_and_logic_or_4(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.and %arg1, %arg0 : i1 + %3 = llvm.select %arg2, %arg0, %0 : i1, i1 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @and_logic_and_logic_or_5(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.and %arg0, %arg1 : i1 + %3 = llvm.select %arg0, %arg2, %0 : i1, i1 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @and_logic_and_logic_or_6(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.and %arg0, %arg1 : i1 + %3 = llvm.select %arg2, %arg0, %0 : i1, i1 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @and_logic_and_logic_or_7(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.and %arg1, %arg0 : i1 + %3 = llvm.select %arg0, %arg2, %0 : i1, i1 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @and_logic_and_logic_or_8(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.and %arg1, %arg0 : i1 + %3 = llvm.select %arg2, %arg0, %0 : i1, i1 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @and_logic_and_logic_or_vector(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %4 = llvm.and %arg0, %arg1 : vector<3xi1> + %5 = llvm.select %arg0, %arg2, %1 : vector<3xi1>, vector<3xi1> + %6 = llvm.select %4, %3, %5 : vector<3xi1>, vector<3xi1> + llvm.return %6 : vector<3xi1> + } + llvm.func @and_logic_and_logic_or_vector_poison1(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.poison : i1 + %2 = llvm.mlir.undef : vector<3xi1> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi1> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi1> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi1> + %9 = llvm.mlir.constant(true) : i1 + %10 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %11 = llvm.and %arg0, %arg1 : vector<3xi1> + %12 = llvm.select %arg0, %arg2, %8 : vector<3xi1>, vector<3xi1> + %13 = llvm.select %11, %10, %12 : vector<3xi1>, vector<3xi1> + llvm.return %13 : vector<3xi1> + } + llvm.func @and_logic_and_logic_or_vector_poison2(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.poison : i1 + %4 = llvm.mlir.undef : vector<3xi1> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<3xi1> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<3xi1> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %2, %8[%9 : i32] : vector<3xi1> + %11 = llvm.and %arg0, %arg1 : vector<3xi1> + %12 = llvm.select %arg0, %arg2, %1 : vector<3xi1>, vector<3xi1> + %13 = llvm.select %11, %10, %12 : vector<3xi1>, vector<3xi1> + llvm.return %13 : vector<3xi1> + } + llvm.func @and_logic_and_logic_or_not_one_use(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.and %arg1, %arg0 : i1 + %3 = llvm.select %arg2, %arg0, %0 : i1, i1 + %4 = llvm.select %3, %1, %2 : i1, i1 + llvm.call @use(%2) : (i1) -> () + llvm.call @use(%3) : (i1) -> () + llvm.return %4 : i1 + } + llvm.func @and_and_logic_or_1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.and %arg0, %arg1 : i1 + %2 = llvm.and %arg0, %arg2 : i1 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @and_and_logic_or_2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.and %arg1, %arg0 : i1 + %2 = llvm.and %arg0, %arg2 : i1 + %3 = llvm.select %2, %0, %1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @and_and_logic_or_vector(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.and %arg0, %arg1 : vector<3xi1> + %3 = llvm.and %arg0, %arg2 : vector<3xi1> + %4 = llvm.select %2, %1, %3 : vector<3xi1>, vector<3xi1> + llvm.return %4 : vector<3xi1> + } + llvm.func @and_and_logic_or_vector_poison(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.poison : i1 + %2 = llvm.mlir.undef : vector<3xi1> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi1> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi1> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi1> + %9 = llvm.and %arg0, %arg1 : vector<3xi1> + %10 = llvm.and %arg0, %arg2 : vector<3xi1> + %11 = llvm.select %9, %8, %10 : vector<3xi1>, vector<3xi1> + llvm.return %11 : vector<3xi1> + } + llvm.func @and_and_logic_or_not_one_use(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.and %arg1, %arg0 : i1 + %2 = llvm.and %arg0, %arg2 : i1 + %3 = llvm.select %2, %0, %1 : i1, i1 + llvm.call @use(%1) : (i1) -> () + llvm.call @use(%2) : (i1) -> () + llvm.return %3 : i1 + } + llvm.func @logic_or_logic_and_1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg0, %0, %arg1 : i1, i1 + %3 = llvm.select %arg0, %0, %arg2 : i1, i1 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_or_logic_and_2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg1, %0, %arg0 : i1, i1 + %3 = llvm.select %arg0, %0, %arg2 : i1, i1 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_or_logic_and_3(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg1, %0, %arg0 : i1, i1 + %3 = llvm.select %arg2, %0, %arg0 : i1, i1 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_or_logic_and_4(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg0, %0, %arg1 : i1, i1 + %3 = llvm.select %arg2, %0, %arg0 : i1, i1 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_or_logic_and_5(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg0, %0, %arg1 : i1, i1 + %3 = llvm.select %arg0, %0, %arg2 : i1, i1 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_or_logic_and_6(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg1, %0, %arg0 : i1, i1 + %3 = llvm.select %arg0, %0, %arg2 : i1, i1 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_or_logic_and_7(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg1, %0, %arg0 : i1, i1 + %3 = llvm.select %arg2, %0, %arg0 : i1, i1 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_or_logic_and_8(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg0, %0, %arg1 : i1, i1 + %3 = llvm.select %arg2, %0, %arg0 : i1, i1 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @logic_or_logic_and_vector(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %4 = llvm.select %arg0, %1, %arg1 : vector<3xi1>, vector<3xi1> + %5 = llvm.select %arg0, %1, %arg2 : vector<3xi1>, vector<3xi1> + %6 = llvm.select %4, %5, %3 : vector<3xi1>, vector<3xi1> + llvm.return %6 : vector<3xi1> + } + llvm.func @logic_or_logic_and_vector_poison1(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.poison : i1 + %2 = llvm.mlir.undef : vector<3xi1> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<3xi1> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<3xi1> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi1> + %9 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %10 = llvm.mlir.constant(false) : i1 + %11 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %12 = llvm.select %arg0, %8, %arg1 : vector<3xi1>, vector<3xi1> + %13 = llvm.select %arg0, %9, %arg2 : vector<3xi1>, vector<3xi1> + %14 = llvm.select %12, %13, %11 : vector<3xi1>, vector<3xi1> + llvm.return %14 : vector<3xi1> + } + llvm.func @logic_or_logic_and_vector_poison2(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.mlir.poison : i1 + %3 = llvm.mlir.undef : vector<3xi1> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : vector<3xi1> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi1> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi1> + %10 = llvm.mlir.constant(false) : i1 + %11 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %12 = llvm.select %arg0, %1, %arg1 : vector<3xi1>, vector<3xi1> + %13 = llvm.select %arg0, %9, %arg2 : vector<3xi1>, vector<3xi1> + %14 = llvm.select %12, %13, %11 : vector<3xi1>, vector<3xi1> + llvm.return %14 : vector<3xi1> + } + llvm.func @logic_or_logic_and_vector_poison3(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.mlir.poison : i1 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.undef : vector<3xi1> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<3xi1> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %3, %6[%7 : i32] : vector<3xi1> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %2, %8[%9 : i32] : vector<3xi1> + %11 = llvm.select %arg0, %1, %arg1 : vector<3xi1>, vector<3xi1> + %12 = llvm.select %arg0, %1, %arg2 : vector<3xi1>, vector<3xi1> + %13 = llvm.select %11, %12, %10 : vector<3xi1>, vector<3xi1> + llvm.return %13 : vector<3xi1> + } + llvm.func @logic_or_logic_and_not_one_use(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg0, %0, %arg1 : i1, i1 + %3 = llvm.select %arg2, %0, %arg0 : i1, i1 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.call @use(%2) : (i1) -> () + llvm.call @use(%3) : (i1) -> () + llvm.return %4 : i1 + } + llvm.func @or_logic_or_logic_and_1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.or %arg0, %arg1 : i1 + %3 = llvm.select %arg0, %0, %arg2 : i1, i1 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @or_logic_or_logic_and_2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.or %arg0, %arg1 : i1 + %3 = llvm.select %arg2, %0, %arg0 : i1, i1 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @or_logic_or_logic_and_3(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.or %arg0, %arg1 : i1 + %3 = llvm.select %arg0, %0, %arg2 : i1, i1 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @or_logic_or_logic_and_4(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.or %arg0, %arg1 : i1 + %3 = llvm.select %arg2, %0, %arg0 : i1, i1 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @or_logic_or_logic_and_5(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.or %arg1, %arg0 : i1 + %3 = llvm.select %arg0, %0, %arg2 : i1, i1 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @or_logic_or_logic_and_6(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.or %arg1, %arg0 : i1 + %3 = llvm.select %arg2, %0, %arg0 : i1, i1 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @or_logic_or_logic_and_7(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.or %arg1, %arg0 : i1 + %3 = llvm.select %arg0, %0, %arg2 : i1, i1 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @or_logic_or_logic_and_8(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.or %arg1, %arg0 : i1 + %3 = llvm.select %arg2, %0, %arg0 : i1, i1 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @or_logic_or_logic_and_vector(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %4 = llvm.or %arg0, %arg1 : vector<3xi1> + %5 = llvm.select %arg0, %1, %arg2 : vector<3xi1>, vector<3xi1> + %6 = llvm.select %4, %5, %3 : vector<3xi1>, vector<3xi1> + llvm.return %6 : vector<3xi1> + } + llvm.func @or_logic_or_logic_and_vector_poison1(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.poison : i1 + %2 = llvm.mlir.undef : vector<3xi1> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi1> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi1> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi1> + %9 = llvm.mlir.constant(false) : i1 + %10 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %11 = llvm.or %arg0, %arg1 : vector<3xi1> + %12 = llvm.select %arg0, %8, %arg2 : vector<3xi1>, vector<3xi1> + %13 = llvm.select %11, %12, %10 : vector<3xi1>, vector<3xi1> + llvm.return %13 : vector<3xi1> + } + llvm.func @or_logic_or_logic_and_vector_poison2(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.mlir.poison : i1 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.mlir.undef : vector<3xi1> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<3xi1> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %3, %6[%7 : i32] : vector<3xi1> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %2, %8[%9 : i32] : vector<3xi1> + %11 = llvm.or %arg0, %arg1 : vector<3xi1> + %12 = llvm.select %arg0, %1, %arg2 : vector<3xi1>, vector<3xi1> + %13 = llvm.select %11, %12, %10 : vector<3xi1>, vector<3xi1> + llvm.return %13 : vector<3xi1> + } + llvm.func @or_logic_or_logic_and_not_one_use(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.or %arg0, %arg1 : i1 + %3 = llvm.select %arg2, %0, %arg0 : i1, i1 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.call @use(%2) : (i1) -> () + llvm.call @use(%3) : (i1) -> () + llvm.return %4 : i1 + } + llvm.func @or_or_logic_and_1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.or %arg0, %arg1 : i1 + %2 = llvm.or %arg2, %arg0 : i1 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @or_or_logic_and_2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.or %arg0, %arg1 : i1 + %2 = llvm.or %arg2, %arg0 : i1 + %3 = llvm.select %2, %1, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @or_or_logic_and_vector(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.or %arg0, %arg1 : vector<3xi1> + %3 = llvm.or %arg2, %arg0 : vector<3xi1> + %4 = llvm.select %2, %3, %1 : vector<3xi1>, vector<3xi1> + llvm.return %4 : vector<3xi1> + } + llvm.func @or_or_logic_and_vector_poison(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.poison : i1 + %2 = llvm.mlir.undef : vector<3xi1> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<3xi1> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<3xi1> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi1> + %9 = llvm.or %arg0, %arg1 : vector<3xi1> + %10 = llvm.or %arg2, %arg0 : vector<3xi1> + %11 = llvm.select %9, %10, %8 : vector<3xi1>, vector<3xi1> + llvm.return %11 : vector<3xi1> + } + llvm.func @or_or_logic_and_not_one_use(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.or %arg0, %arg1 : i1 + %2 = llvm.or %arg2, %arg0 : i1 + %3 = llvm.select %2, %1, %0 : i1, i1 + llvm.call @use(%1) : (i1) -> () + llvm.call @use(%2) : (i1) -> () + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/select-gep.ll.mlir b/test/LLVMDialect/InstCombine/select-gep.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/select-icmp-and-zero-shl.ll.mlir b/test/LLVMDialect/InstCombine/select-icmp-and-zero-shl.ll.mlir new file mode 100644 index 000000000..b7e541778 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-icmp-and-zero-shl.ll.mlir @@ -0,0 +1,129 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_eq(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.shl %arg0, %2 : i32 + %6 = llvm.select %4, %1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_eq_vect(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1073741823> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi32> + %6 = llvm.shl %arg0, %3 : vector<2xi32> + %7 = llvm.select %5, %2, %6 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @test_ne(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.shl %arg0, %2 : i32 + %6 = llvm.select %4, %5, %1 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_ne_vect(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1073741823> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.icmp "ne" %4, %2 : vector<2xi32> + %6 = llvm.shl %arg0, %3 : vector<2xi32> + %7 = llvm.select %5, %6, %2 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @test_nuw_dropped(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.shl %arg0, %2 overflow : i32 + %6 = llvm.select %4, %1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_nsw_dropped(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.shl %arg0, %2 overflow : i32 + %6 = llvm.select %4, %1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @use_multi(i32, i1, i32) + llvm.func @test_multi_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.shl %arg0, %2 : i32 + %6 = llvm.select %4, %5, %1 : i1, i32 + llvm.call @use_multi(%3, %4, %5) : (i32, i1, i32) -> () + llvm.return %6 : i32 + } + llvm.func @test_multi_use_nuw_dropped(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.shl %arg0, %2 overflow : i32 + %6 = llvm.select %4, %1, %5 : i1, i32 + llvm.call @use_multi(%3, %4, %5) : (i32, i1, i32) -> () + llvm.return %6 : i32 + } + llvm.func @neg_test_bits_not_match(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.shl %arg0, %2 : i32 + %6 = llvm.select %4, %1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @neg_test_icmp_non_equality(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + %5 = llvm.shl %arg0, %2 : i32 + %6 = llvm.select %4, %1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @neg_test_select_non_zero_constant(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.shl %arg0, %2 : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @neg_test_icmp_non_zero_constant(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.shl %arg0, %2 : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/select-icmp-and.ll.mlir b/test/LLVMDialect/InstCombine/select-icmp-and.ll.mlir new file mode 100644 index 000000000..5390e686f --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-icmp-and.ll.mlir @@ -0,0 +1,435 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test5(%arg0: i41) -> i41 { + %0 = llvm.mlir.constant(32 : i41) : i41 + %1 = llvm.mlir.constant(0 : i41) : i41 + %2 = llvm.and %arg0, %0 : i41 + %3 = llvm.icmp "ne" %2, %1 : i41 + %4 = llvm.select %3, %0, %1 : i1, i41 + llvm.return %4 : i41 + } + llvm.func @test6(%arg0: i1023) -> i1023 { + %0 = llvm.mlir.constant(64 : i1023) : i1023 + %1 = llvm.mlir.constant(0 : i1023) : i1023 + %2 = llvm.and %arg0, %0 : i1023 + %3 = llvm.icmp "ne" %2, %1 : i1023 + %4 = llvm.select %3, %0, %1 : i1, i1023 + llvm.return %4 : i1023 + } + llvm.func @test35(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(60 : i32) : i32 + %2 = llvm.mlir.constant(100 : i32) : i32 + %3 = llvm.icmp "sge" %arg0, %0 : i32 + %4 = llvm.select %3, %1, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @test35vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<60> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<100> : vector<2xi32>) : vector<2xi32> + %4 = llvm.icmp "sge" %arg0, %1 : vector<2xi32> + %5 = llvm.select %4, %2, %3 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test35_with_trunc(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(60 : i32) : i32 + %2 = llvm.mlir.constant(100 : i32) : i32 + %3 = llvm.trunc %arg0 : i64 to i32 + %4 = llvm.icmp "sge" %3, %0 : i32 + %5 = llvm.select %4, %1, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test36(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(60 : i32) : i32 + %2 = llvm.mlir.constant(100 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %3, %1, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @test36vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<60> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<100> : vector<2xi32>) : vector<2xi32> + %4 = llvm.icmp "slt" %arg0, %1 : vector<2xi32> + %5 = llvm.select %4, %2, %3 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test37(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %1, %0 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @test37vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %3 = llvm.select %2, %1, %0 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @test65(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(40 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.and %arg0, %0 : i64 + %5 = llvm.icmp "ne" %4, %1 : i64 + %6 = llvm.select %5, %2, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test65vec(%arg0: vector<2xi64>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mlir.constant(dense<40> : vector<2xi32>) : vector<2xi32> + %4 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %5 = llvm.and %arg0, %0 : vector<2xi64> + %6 = llvm.icmp "ne" %5, %2 : vector<2xi64> + %7 = llvm.select %6, %3, %4 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @test66(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(4294967296 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(40 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.and %arg0, %0 : i64 + %5 = llvm.icmp "ne" %4, %1 : i64 + %6 = llvm.select %5, %2, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test66vec(%arg0: vector<2xi64>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4294967296> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mlir.constant(dense<40> : vector<2xi32>) : vector<2xi32> + %4 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %5 = llvm.and %arg0, %0 : vector<2xi64> + %6 = llvm.icmp "ne" %5, %2 : vector<2xi64> + %7 = llvm.select %6, %3, %4 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @test66vec_scalar_and(%arg0: i64) -> vector<2xi32> { + %0 = llvm.mlir.constant(4294967296 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<40> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : i64 + %5 = llvm.icmp "ne" %4, %1 : i64 + %6 = llvm.select %5, %2, %3 : i1, vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @test67(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.mlir.constant(40 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.and %arg0, %0 : i16 + %5 = llvm.icmp "ne" %4, %1 : i16 + %6 = llvm.select %5, %2, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test67vec(%arg0: vector<2xi16>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.mlir.constant(dense<0> : vector<2xi16>) : vector<2xi16> + %3 = llvm.mlir.constant(dense<40> : vector<2xi32>) : vector<2xi32> + %4 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %5 = llvm.and %arg0, %0 : vector<2xi16> + %6 = llvm.icmp "ne" %5, %2 : vector<2xi16> + %7 = llvm.select %6, %3, %4 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @test71(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(40 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.select %5, %2, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test71vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<128> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<40> : vector<2xi32>) : vector<2xi32> + %4 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %5 = llvm.and %arg0, %0 : vector<2xi32> + %6 = llvm.icmp "ne" %5, %2 : vector<2xi32> + %7 = llvm.select %6, %3, %4 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @test72(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(40 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.select %5, %2, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test72vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<128> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<40> : vector<2xi32>) : vector<2xi32> + %4 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %5 = llvm.and %arg0, %0 : vector<2xi32> + %6 = llvm.icmp "eq" %5, %2 : vector<2xi32> + %7 = llvm.select %6, %3, %4 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @test73(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(40 : i32) : i32 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.trunc %arg0 : i32 to i8 + %4 = llvm.icmp "sgt" %3, %0 : i8 + %5 = llvm.select %4, %1, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test73vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<40> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %3 = llvm.trunc %arg0 : vector<2xi32> to vector<2xi8> + %4 = llvm.icmp "sgt" %3, %0 : vector<2xi8> + %5 = llvm.select %4, %1, %2 : vector<2xi1>, vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test74(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(40 : i32) : i32 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.select %3, %1, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @test74vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<40> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %3 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %4 = llvm.select %3, %1, %2 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test75(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(8 : i64) : i64 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %3, %1, %2 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @test15a(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.select %3, %1, %0 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @test15b(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @test15c(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.select %3, %0, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @test15d(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @test15e(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.select %4, %2, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test15f(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.select %4, %1, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test15g(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(-9 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.select %5, %2, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test15h(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-9 : i32) : i32 + %3 = llvm.mlir.constant(-1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.select %5, %2, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test15i(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(577 : i32) : i32 + %3 = llvm.mlir.constant(1089 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.select %5, %2, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test15j(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1089 : i32) : i32 + %3 = llvm.mlir.constant(577 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.select %5, %2, %3 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @use1(i1) + llvm.func @clear_to_set(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-3 : i32) : i32 + %3 = llvm.mlir.constant(-11 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.select %5, %2, %3 : i1, i32 + llvm.call @use1(%5) : (i1) -> () + llvm.return %6 : i32 + } + llvm.func @clear_to_clear(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-11 : i32) : i32 + %3 = llvm.mlir.constant(-3 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.select %5, %2, %3 : i1, i32 + llvm.call @use1(%5) : (i1) -> () + llvm.return %6 : i32 + } + llvm.func @set_to_set(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-3 : i32) : i32 + %3 = llvm.mlir.constant(-11 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.select %5, %2, %3 : i1, i32 + llvm.call @use1(%5) : (i1) -> () + llvm.return %6 : i32 + } + llvm.func @set_to_clear(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-11 : i32) : i32 + %3 = llvm.mlir.constant(-3 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.select %5, %2, %3 : i1, i32 + llvm.call @use1(%5) : (i1) -> () + llvm.return %6 : i32 + } + llvm.func @clear_to_set_decomposebittest(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(-125 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.icmp "sgt" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @clear_to_clear_decomposebittest(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(-125 : i8) : i8 + %3 = llvm.icmp "sgt" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @set_to_set_decomposebittest(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-125 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.icmp "slt" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @set_to_clear_decomposebittest(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(-125 : i8) : i8 + %3 = llvm.icmp "slt" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @clear_to_set_decomposebittest_extra_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(-125 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.icmp "sgt" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i8 + llvm.call @use1(%3) : (i1) -> () + llvm.return %4 : i8 + } + llvm.func @clear_to_clear_decomposebittest_extra_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(-125 : i8) : i8 + %3 = llvm.icmp "sgt" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i8 + llvm.call @use1(%3) : (i1) -> () + llvm.return %4 : i8 + } + llvm.func @set_to_set_decomposebittest_extra_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-125 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.icmp "slt" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i8 + llvm.call @use1(%3) : (i1) -> () + llvm.return %4 : i8 + } + llvm.func @set_to_clear_decomposebittest_extra_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(-125 : i8) : i8 + %3 = llvm.icmp "slt" %arg0, %0 : i8 + %4 = llvm.select %3, %1, %2 : i1, i8 + llvm.call @use1(%3) : (i1) -> () + llvm.return %4 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/select-imm-canon.ll.mlir b/test/LLVMDialect/InstCombine/select-imm-canon.ll.mlir new file mode 100644 index 000000000..048c1529a --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-imm-canon.ll.mlir @@ -0,0 +1,79 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @single(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(-128 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %1, %arg0 : i1, i32 + %4 = llvm.trunc %3 : i32 to i8 + llvm.return %4 : i8 + } + llvm.func @double(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(-128 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(127 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %3, %1, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %arg0, %2 : i32 + %6 = llvm.select %5, %2, %4 : i1, i32 + %7 = llvm.trunc %6 : i32 to i8 + llvm.return %7 : i8 + } + llvm.func @thisdoesnotloop(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(-128 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.trunc %3 : i32 to i8 + llvm.return %4 : i8 + } + llvm.func @original(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(127 : i32) : i32 + %1 = llvm.mlir.constant(-128 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "slt" %0, %arg0 : i32 + %4 = llvm.icmp "sle" %1, %arg0 : i32 + %5 = llvm.select %3, %0, %1 : i1, i32 + %6 = llvm.xor %3, %2 : i1 + %7 = llvm.and %4, %6 : i1 + %8 = llvm.select %7, %arg0, %5 : i1, i32 + %9 = llvm.trunc %8 : i32 to i8 + llvm.return %9 : i8 + } + llvm.func @original_logical(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(127 : i32) : i32 + %1 = llvm.mlir.constant(-128 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "slt" %0, %arg0 : i32 + %5 = llvm.icmp "sle" %1, %arg0 : i32 + %6 = llvm.select %4, %0, %1 : i1, i32 + %7 = llvm.xor %4, %2 : i1 + %8 = llvm.select %5, %7, %3 : i1, i1 + %9 = llvm.select %8, %arg0, %6 : i1, i32 + %10 = llvm.trunc %9 : i32 to i8 + llvm.return %10 : i8 + } + llvm.func @PR49205(%arg0: i32, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.undef : i32 + llvm.br ^bb1(%0 : i32) + ^bb1(%4: i32): // 2 preds: ^bb0, ^bb2 + llvm.cond_br %arg1, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %5 = llvm.add %arg0, %3 : i32 + %6 = llvm.add %5, %2 overflow : i32 + llvm.br ^bb1(%6 : i32) + ^bb3: // pred: ^bb1 + %7 = llvm.icmp "ne" %4, %1 : i32 + %8 = llvm.zext %7 : i1 to i32 + %9 = llvm.and %4, %8 : i32 + %10 = llvm.sub %4, %9 : i32 + %11 = llvm.icmp "ne" %10, %1 : i32 + %12 = llvm.zext %11 : i1 to i32 + %13 = llvm.sub %12, %10 : i32 + %14 = llvm.and %13, %2 : i32 + llvm.return %14 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/select-load-call.ll.mlir b/test/LLVMDialect/InstCombine/select-load-call.ll.mlir new file mode 100644 index 000000000..99807d48c --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-load-call.ll.mlir @@ -0,0 +1,13 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test2() + llvm.func @test(%arg0: i1, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %0, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.call @test2() : () -> () + %2 = llvm.select %arg0, %arg1, %1 : i1, !llvm.ptr + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/select-masked_gather.ll.mlir b/test/LLVMDialect/InstCombine/select-masked_gather.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/select-masked_load.ll.mlir b/test/LLVMDialect/InstCombine/select-masked_load.ll.mlir new file mode 100644 index 000000000..2668c4be5 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-masked_load.ll.mlir @@ -0,0 +1,91 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @masked_load_and_zero_inactive_1(%arg0: !llvm.ptr, %arg1: vector<4xi1>) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %4 = llvm.intr.masked.load %arg0, %arg1, %0 {alignment = 4 : i32} : (!llvm.ptr, vector<4xi1>, vector<4xf32>) -> vector<4xf32> + %5 = llvm.select %arg1, %4, %3 : vector<4xi1>, vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @masked_load_and_zero_inactive_2(%arg0: !llvm.ptr, %arg1: vector<4xi1>) -> vector<4xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.intr.masked.load %arg0, %arg1, %1 {alignment = 4 : i32} : (!llvm.ptr, vector<4xi1>, vector<4xi32>) -> vector<4xi32> + %4 = llvm.select %arg1, %3, %1 : vector<4xi1>, vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @masked_load_and_zero_inactive_3(%arg0: !llvm.ptr, %arg1: vector<4xi1>, %arg2: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %3 = llvm.intr.masked.load %arg0, %arg1, %arg2 {alignment = 4 : i32} : (!llvm.ptr, vector<4xi1>, vector<4xi32>) -> vector<4xi32> + %4 = llvm.select %arg1, %3, %2 : vector<4xi1>, vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @masked_load_and_zero_inactive_4(%arg0: !llvm.ptr, %arg1: vector<4xi1>) -> vector<4xi32> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %6 = llvm.xor %arg1, %1 : vector<4xi1> + %7 = llvm.intr.masked.load %arg0, %6, %2 {alignment = 4 : i32} : (!llvm.ptr, vector<4xi1>, vector<4xi32>) -> vector<4xi32> + %8 = llvm.select %arg1, %5, %7 : vector<4xi1>, vector<4xi32> + llvm.return %8 : vector<4xi32> + } + llvm.func @masked_load_and_zero_inactive_5(%arg0: !llvm.ptr, %arg1: vector<4xi1>) -> vector<4xi32> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %4 = llvm.mlir.constant(4 : i32) : i32 + %5 = llvm.xor %arg1, %1 : vector<4xi1> + %6 = llvm.intr.masked.load %arg0, %5, %3 {alignment = 4 : i32} : (!llvm.ptr, vector<4xi1>, vector<4xi32>) -> vector<4xi32> + %7 = llvm.select %arg1, %3, %6 : vector<4xi1>, vector<4xi32> + llvm.return %7 : vector<4xi32> + } + llvm.func @masked_load_and_zero_inactive_6(%arg0: !llvm.ptr, %arg1: vector<4xi1>, %arg2: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %5 = llvm.xor %arg1, %1 : vector<4xi1> + %6 = llvm.intr.masked.load %arg0, %5, %arg2 {alignment = 4 : i32} : (!llvm.ptr, vector<4xi1>, vector<4xi32>) -> vector<4xi32> + %7 = llvm.select %arg1, %4, %6 : vector<4xi1>, vector<4xi32> + llvm.return %7 : vector<4xi32> + } + llvm.func @masked_load_and_zero_inactive_7(%arg0: !llvm.ptr, %arg1: vector<4xi1>, %arg2: vector<4xi1>) -> vector<4xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.intr.masked.load %arg0, %arg1, %1 {alignment = 4 : i32} : (!llvm.ptr, vector<4xi1>, vector<4xi32>) -> vector<4xi32> + %4 = llvm.select %arg2, %1, %3 : vector<4xi1>, vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @masked_load_and_zero_inactive_8(%arg0: !llvm.ptr, %arg1: vector<4xi1>, %arg2: vector<4xi1>) -> vector<4xf32> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> + %2 = llvm.mlir.undef : vector<4xf32> + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %5 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %6 = llvm.xor %arg1, %1 : vector<4xi1> + %7 = llvm.and %6, %arg2 : vector<4xi1> + %8 = llvm.intr.masked.load %arg0, %7, %2 {alignment = 4 : i32} : (!llvm.ptr, vector<4xi1>, vector<4xf32>) -> vector<4xf32> + %9 = llvm.select %arg1, %5, %8 : vector<4xi1>, vector<4xf32> + llvm.return %9 : vector<4xf32> + } + llvm.func @masked_load_and_scalar_select_cond(%arg0: !llvm.ptr, %arg1: vector<8xi1>, %arg2: i1) -> vector<8xf32> { + %0 = llvm.mlir.undef : vector<8xf32> + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %4 = llvm.intr.masked.load %arg0, %arg1, %0 {alignment = 32 : i32} : (!llvm.ptr, vector<8xi1>, vector<8xf32>) -> vector<8xf32> + %5 = llvm.select %arg2, %3, %4 : i1, vector<8xf32> + llvm.return %5 : vector<8xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/select-min-max.ll.mlir b/test/LLVMDialect/InstCombine/select-min-max.ll.mlir new file mode 100644 index 000000000..89c35c9cc --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-min-max.ll.mlir @@ -0,0 +1,182 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @smin_smin_common_op_00(%arg0: i1, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.intr.smin(%arg3, %arg1) : (i5, i5) -> i5 + %1 = llvm.intr.smin(%arg3, %arg2) : (i5, i5) -> i5 + %2 = llvm.select %arg0, %0, %1 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @smax_smax_common_op_01(%arg0: vector<2xi1>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.intr.smax(%arg3, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %1 = llvm.intr.smax(%arg2, %arg3) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %2 = llvm.select %arg0, %0, %1 : vector<2xi1>, vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @umin_umin_common_op_10(%arg0: i1, %arg1: i5, %arg2: i5, %arg3: i5, %arg4: !llvm.ptr) -> i5 { + %0 = llvm.intr.umin(%arg1, %arg3) : (i5, i5) -> i5 + llvm.store %0, %arg4 {alignment = 1 : i64} : i5, !llvm.ptr + %1 = llvm.intr.umin(%arg3, %arg2) : (i5, i5) -> i5 + %2 = llvm.select %arg0, %0, %1 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @umax_umax_common_op_11(%arg0: i1, %arg1: vector<3xi5>, %arg2: vector<3xi5>, %arg3: vector<3xi5>, %arg4: !llvm.ptr) -> vector<3xi5> { + %0 = llvm.intr.umax(%arg1, %arg3) : (vector<3xi5>, vector<3xi5>) -> vector<3xi5> + %1 = llvm.intr.umax(%arg2, %arg3) : (vector<3xi5>, vector<3xi5>) -> vector<3xi5> + llvm.store %1, %arg4 {alignment = 2 : i64} : vector<3xi5>, !llvm.ptr + %2 = llvm.select %arg0, %0, %1 : i1, vector<3xi5> + llvm.return %2 : vector<3xi5> + } + llvm.func @smin_umin_common_op_11(%arg0: i1, %arg1: i5, %arg2: i5, %arg3: i5) -> i5 { + %0 = llvm.intr.smin(%arg1, %arg3) : (i5, i5) -> i5 + %1 = llvm.intr.umin(%arg2, %arg3) : (i5, i5) -> i5 + %2 = llvm.select %arg0, %0, %1 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @smin_smin_no_common_op(%arg0: i1, %arg1: i5, %arg2: i5, %arg3: i5, %arg4: i5) -> i5 { + %0 = llvm.intr.smin(%arg3, %arg1) : (i5, i5) -> i5 + %1 = llvm.intr.smin(%arg4, %arg2) : (i5, i5) -> i5 + %2 = llvm.select %arg0, %0, %1 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @umin_umin_common_op_10_uses(%arg0: i1, %arg1: i5, %arg2: i5, %arg3: i5, %arg4: !llvm.ptr, %arg5: !llvm.ptr) -> i5 { + %0 = llvm.intr.umin(%arg1, %arg3) : (i5, i5) -> i5 + llvm.store %0, %arg4 {alignment = 1 : i64} : i5, !llvm.ptr + %1 = llvm.intr.umin(%arg3, %arg2) : (i5, i5) -> i5 + llvm.store %1, %arg5 {alignment = 1 : i64} : i5, !llvm.ptr + %2 = llvm.select %arg0, %0, %1 : i1, i5 + llvm.return %2 : i5 + } + llvm.func @smin_select_const_const(%arg0: i1) -> i5 { + %0 = llvm.mlir.constant(-3 : i5) : i5 + %1 = llvm.mlir.constant(8 : i5) : i5 + %2 = llvm.mlir.constant(5 : i5) : i5 + %3 = llvm.select %arg0, %0, %1 : i1, i5 + %4 = llvm.intr.smin(%3, %2) : (i5, i5) -> i5 + llvm.return %4 : i5 + } + llvm.func @smax_select_const_const(%arg0: vector<2xi1>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[1, 3]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[5, 43]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<[0, 42]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.select %arg0, %0, %1 : vector<2xi1>, vector<2xi8> + %4 = llvm.intr.smax(%3, %2) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @umin_select_const_const(%arg0: i1) -> i5 { + %0 = llvm.mlir.constant(8 : i5) : i5 + %1 = llvm.mlir.constant(3 : i5) : i5 + %2 = llvm.mlir.constant(4 : i5) : i5 + %3 = llvm.select %arg0, %0, %1 : i1, i5 + %4 = llvm.intr.umin(%2, %3) : (i5, i5) -> i5 + llvm.return %4 : i5 + } + llvm.func @umax_select_const_const(%arg0: vector<3xi1>) -> vector<3xi5> { + %0 = llvm.mlir.constant(4 : i5) : i5 + %1 = llvm.mlir.constant(3 : i5) : i5 + %2 = llvm.mlir.constant(2 : i5) : i5 + %3 = llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi5>) : vector<3xi5> + %4 = llvm.mlir.constant(9 : i5) : i5 + %5 = llvm.mlir.constant(8 : i5) : i5 + %6 = llvm.mlir.constant(7 : i5) : i5 + %7 = llvm.mlir.constant(dense<[7, 8, 9]> : vector<3xi5>) : vector<3xi5> + %8 = llvm.mlir.constant(-16 : i5) : i5 + %9 = llvm.mlir.constant(5 : i5) : i5 + %10 = llvm.mlir.constant(dense<[5, 8, -16]> : vector<3xi5>) : vector<3xi5> + %11 = llvm.select %arg0, %3, %7 : vector<3xi1>, vector<3xi5> + %12 = llvm.intr.umax(%10, %11) : (vector<3xi5>, vector<3xi5>) -> vector<3xi5> + llvm.return %12 : vector<3xi5> + } + llvm.func @smin_select_const(%arg0: i1, %arg1: i5) -> i5 { + %0 = llvm.mlir.constant(-3 : i5) : i5 + %1 = llvm.mlir.constant(5 : i5) : i5 + %2 = llvm.select %arg0, %0, %arg1 : i1, i5 + %3 = llvm.intr.smin(%2, %1) : (i5, i5) -> i5 + llvm.return %3 : i5 + } + llvm.func @smax_select_const(%arg0: vector<2xi1>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[5, 43]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[0, 42]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.select %arg0, %arg1, %0 : vector<2xi1>, vector<2xi8> + %3 = llvm.intr.smax(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @umin_select_const(%arg0: i1, %arg1: i5) -> i5 { + %0 = llvm.mlir.constant(3 : i5) : i5 + %1 = llvm.mlir.constant(4 : i5) : i5 + %2 = llvm.select %arg0, %arg1, %0 : i1, i5 + %3 = llvm.intr.umin(%1, %2) : (i5, i5) -> i5 + llvm.return %3 : i5 + } + llvm.func @umax_select_const(%arg0: vector<3xi1>, %arg1: vector<3xi5>) -> vector<3xi5> { + %0 = llvm.mlir.constant(4 : i5) : i5 + %1 = llvm.mlir.constant(3 : i5) : i5 + %2 = llvm.mlir.constant(2 : i5) : i5 + %3 = llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi5>) : vector<3xi5> + %4 = llvm.mlir.constant(1 : i5) : i5 + %5 = llvm.mlir.constant(8 : i5) : i5 + %6 = llvm.mlir.constant(5 : i5) : i5 + %7 = llvm.mlir.constant(dense<[5, 8, 1]> : vector<3xi5>) : vector<3xi5> + %8 = llvm.select %arg0, %3, %arg1 : vector<3xi1>, vector<3xi5> + %9 = llvm.intr.umax(%7, %8) : (vector<3xi5>, vector<3xi5>) -> vector<3xi5> + llvm.return %9 : vector<3xi5> + } + llvm.func @smax_smin(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.intr.smax(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @smin_smax(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.intr.smin(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @umax_umin(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(-127 : i8) : i8 + %2 = llvm.intr.umax(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.icmp "ult" %arg0, %1 : i8 + %4 = llvm.select %3, %2, %1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @umin_umax(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(126 : i8) : i8 + %2 = llvm.intr.umin(%arg0, %0) : (i8, i8) -> i8 + %3 = llvm.icmp "ugt" %arg0, %1 : i8 + %4 = llvm.select %3, %2, %1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @not_smax(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %arg1 : i8 + %2 = llvm.sub %arg0, %arg1 overflow : i8 + %3 = llvm.select %1, %0, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @not_smax_swap(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %2 = llvm.sub %arg0, %arg1 overflow : i8 + %3 = llvm.select %1, %2, %0 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @not_smin(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i8 + %2 = llvm.sub %arg0, %arg1 overflow : i8 + %3 = llvm.select %1, %0, %2 : i1, i8 + llvm.return %3 : i8 + } + llvm.func @not_smin_swap(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %arg1 : i8 + %2 = llvm.sub %arg0, %arg1 overflow : i8 + %3 = llvm.select %1, %2, %0 : i1, i8 + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/select-obo-peo-ops.ll.mlir b/test/LLVMDialect/InstCombine/select-obo-peo-ops.ll.mlir new file mode 100644 index 000000000..636903179 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-obo-peo-ops.ll.mlir @@ -0,0 +1,786 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_shl_nuw_nsw__all_are_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %1 overflow : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_shl_nuw__all_are_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %1 overflow : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_shl_nsw__all_are_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %1 overflow : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_shl__all_are_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_shl_nuw_nsw__nuw_is_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(1073741822 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %1 overflow : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_shl_nuw__nuw_is_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(1073741822 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %1 overflow : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_shl_nsw__nuw_is_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(1073741822 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %1 overflow : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_shl__nuw_is_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(1073741822 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_shl_nuw_nsw__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-83886080 : i32) : i32 + %1 = llvm.mlir.constant(-83886079 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(-335544316 : i32) : i32 + %4 = llvm.or %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.shl %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + %8 = llvm.mul %7, %4 : i32 + %9 = llvm.mul %8, %6 : i32 + llvm.return %9 : i32 + } + llvm.func @test_shl_nuw__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-83886080 : i32) : i32 + %1 = llvm.mlir.constant(-83886079 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(-335544316 : i32) : i32 + %4 = llvm.or %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.shl %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + %8 = llvm.mul %7, %4 : i32 + %9 = llvm.mul %8, %6 : i32 + llvm.return %9 : i32 + } + llvm.func @test_shl_nsw__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-83886080 : i32) : i32 + %1 = llvm.mlir.constant(-83886079 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(-335544316 : i32) : i32 + %4 = llvm.or %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.shl %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + %8 = llvm.mul %7, %4 : i32 + %9 = llvm.mul %8, %6 : i32 + llvm.return %9 : i32 + } + llvm.func @test_shl__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-83886080 : i32) : i32 + %1 = llvm.mlir.constant(-83886079 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(-335544316 : i32) : i32 + %4 = llvm.or %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.shl %4, %2 : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + %8 = llvm.mul %7, %4 : i32 + %9 = llvm.mul %8, %6 : i32 + llvm.return %9 : i32 + } + llvm.func @test_shl_nuw_nsw__none_are_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %1 overflow : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_shl_nuw__none_are_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %1 overflow : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_shl_nsw__none_are_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %1 overflow : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_shl__none_are_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.shl %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_lshr_exact__exact_is_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(60 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_lshr__exact_is_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(60 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_lshr_exact__exact_is_unsafe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_lshr__exact_is_unsafe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_ashr_exact__exact_is_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-2147483588 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.ashr %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_ashr__exact_is_safe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-2147483588 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.ashr %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_ashr_exact__exact_is_unsafe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-2147483585 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.ashr %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_ashr__exact_is_unsafe(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(-2147483585 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.ashr %3, %1 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.icmp "eq" %3, %2 : i32 + %7 = llvm.ashr %arg1, %5 : i64 + %8 = llvm.select %6, %arg1, %7 : i1, i64 + llvm.return %8 : i64 + } + llvm.func @test_add_nuw_nsw__all_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.add %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_add_nuw__all_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.add %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_add_nsw__all_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.add %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_add__all_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.add %4, %2 : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_add_nuw_nsw__nuw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-2147483648 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + %5 = llvm.add %3, %1 overflow : i32 + %6 = llvm.select %4, %2, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_add_nuw__nuw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-2147483648 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + %5 = llvm.add %3, %1 overflow : i32 + %6 = llvm.select %4, %2, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_add_nsw__nuw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-2147483648 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + %5 = llvm.add %3, %1 overflow : i32 + %6 = llvm.select %4, %2, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_add__nuw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-2147483648 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + %5 = llvm.add %3, %1 : i32 + %6 = llvm.select %4, %2, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_add_nuw_nsw__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.or %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.add %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_add_nuw__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.or %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.add %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_add_nsw__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.or %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.add %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_add__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.or %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.add %4, %2 : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_add_nuw_nsw__none_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 overflow : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test_add_nuw__none_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 overflow : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test_add_nsw__none_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 overflow : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test_add__none_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test_sub_nuw_nsw__all_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.mlir.constant(-254 : i32) : i32 + %3 = llvm.mlir.constant(-260 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.sub %2, %4 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_sub_nuw__all_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.mlir.constant(-254 : i32) : i32 + %3 = llvm.mlir.constant(-260 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.sub %2, %4 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_sub_nsw__all_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.mlir.constant(-254 : i32) : i32 + %3 = llvm.mlir.constant(-260 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.sub %2, %4 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_sub__all_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.mlir.constant(-254 : i32) : i32 + %3 = llvm.mlir.constant(-260 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.sub %2, %4 : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_sub_nuw_nsw__nuw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(1073741824 : i32) : i32 + %2 = llvm.mlir.constant(-2147483648 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.sub %2, %3 overflow : i32 + %6 = llvm.select %4, %1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_sub_nuw__nuw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(1073741824 : i32) : i32 + %2 = llvm.mlir.constant(-2147483648 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.sub %2, %3 overflow : i32 + %6 = llvm.select %4, %1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_sub_nsw__nuw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(1073741824 : i32) : i32 + %2 = llvm.mlir.constant(-2147483648 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.sub %2, %3 overflow : i32 + %6 = llvm.select %4, %1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_sub__nuw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(1073741824 : i32) : i32 + %2 = llvm.mlir.constant(-2147483648 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.sub %2, %3 : i32 + %6 = llvm.select %4, %1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_sub_nuw_nsw__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(-2147483647 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.or %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %2, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_sub_nuw__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(-2147483647 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.or %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %2, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_sub_nsw__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(-2147483647 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.or %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.sub %0, %3 overflow : i32 + %6 = llvm.select %4, %2, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_sub__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(-2147483647 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.or %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.sub %0, %3 : i32 + %6 = llvm.select %4, %2, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test_sub_nuw_nsw__none_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(2147483647 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.sub %1, %arg0 overflow : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test_sub_nuw__none_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(2147483647 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.sub %1, %arg0 overflow : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test_sub_nsw__none_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(2147483647 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.sub %1, %arg0 overflow : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test_sub__none_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(2147483647 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.sub %1, %arg0 : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test_mul_nuw_nsw__all_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.mlir.constant(153 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.mul %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_mul_nuw__all_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.mlir.constant(153 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.mul %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_mul_nsw__all_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.mlir.constant(153 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.mul %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_mul__all_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.mlir.constant(153 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.mul %4, %2 : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_mul_nuw_nsw__nuw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(268435457 : i32) : i32 + %1 = llvm.mlir.constant(268435456 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.mlir.constant(-1879048192 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.mul %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_mul_nuw__nuw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(268435457 : i32) : i32 + %1 = llvm.mlir.constant(268435456 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.mlir.constant(-1879048192 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.mul %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_mul_nsw__nuw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(268435457 : i32) : i32 + %1 = llvm.mlir.constant(268435456 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.mlir.constant(-1879048192 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.mul %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_mul__nuw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(268435457 : i32) : i32 + %1 = llvm.mlir.constant(268435456 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.mlir.constant(-1879048192 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.mul %4, %2 : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_mul_nuw_nsw__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-83886080 : i32) : i32 + %1 = llvm.mlir.constant(-83886079 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.mlir.constant(-754974711 : i32) : i32 + %4 = llvm.or %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.mul %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_mul_nuw__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-83886080 : i32) : i32 + %1 = llvm.mlir.constant(-83886079 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.mlir.constant(-754974711 : i32) : i32 + %4 = llvm.or %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.mul %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_mul_nsw__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-83886080 : i32) : i32 + %1 = llvm.mlir.constant(-83886079 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.mlir.constant(-754974711 : i32) : i32 + %4 = llvm.or %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.mul %4, %2 overflow : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_mul__nsw_is_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-83886080 : i32) : i32 + %1 = llvm.mlir.constant(-83886079 : i32) : i32 + %2 = llvm.mlir.constant(9 : i32) : i32 + %3 = llvm.mlir.constant(-754974711 : i32) : i32 + %4 = llvm.or %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.mul %4, %2 : i32 + %7 = llvm.select %5, %3, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test_mul_nuw_nsw__none_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(805306368 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(-1342177280 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.mul %arg0, %1 overflow : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test_mul_nuw__none_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(805306368 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(-1342177280 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.mul %arg0, %1 overflow : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test_mul_nsw__none_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(805306368 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(-1342177280 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.mul %arg0, %1 overflow : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test_mul__none_are_safe(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(805306368 : i32) : i32 + %1 = llvm.mlir.constant(9 : i32) : i32 + %2 = llvm.mlir.constant(-1342177280 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.mul %arg0, %1 : i32 + %5 = llvm.select %3, %2, %4 : i1, i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/select-of-bittest.ll.mlir b/test/LLVMDialect/InstCombine/select-of-bittest.ll.mlir new file mode 100644 index 000000000..4e54dff1a --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-of-bittest.ll.mlir @@ -0,0 +1,504 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @and_lshr_and(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.lshr %arg0, %0 : i32 + %5 = llvm.and %4, %0 : i32 + %6 = llvm.select %3, %5, %0 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @and_lshr_and_splatvec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "eq" %3, %2 : vector<2xi32> + %5 = llvm.lshr %arg0, %0 : vector<2xi32> + %6 = llvm.and %5, %0 : vector<2xi32> + %7 = llvm.select %4, %6, %0 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @and_lshr_and_vec_v0(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[1, 4]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi32> + %6 = llvm.lshr %arg0, %3 : vector<2xi32> + %7 = llvm.and %6, %3 : vector<2xi32> + %8 = llvm.select %5, %7, %3 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @and_lshr_and_vec_v1(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi32> + %6 = llvm.lshr %arg0, %3 : vector<2xi32> + %7 = llvm.and %6, %0 : vector<2xi32> + %8 = llvm.select %5, %7, %0 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @and_lshr_and_vec_v2(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[8, 1]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<[2, 1]> : vector<2xi32>) : vector<2xi32> + %4 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %5 = llvm.and %arg0, %0 : vector<2xi32> + %6 = llvm.icmp "eq" %5, %2 : vector<2xi32> + %7 = llvm.lshr %arg0, %3 : vector<2xi32> + %8 = llvm.and %7, %4 : vector<2xi32> + %9 = llvm.select %6, %8, %4 : vector<2xi1>, vector<2xi32> + llvm.return %9 : vector<2xi32> + } + llvm.func @and_lshr_and_vec_poison(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.and %arg0, %8 : vector<3xi32> + %18 = llvm.icmp "eq" %17, %16 : vector<3xi32> + %19 = llvm.lshr %arg0, %8 : vector<3xi32> + %20 = llvm.and %19, %8 : vector<3xi32> + %21 = llvm.select %18, %20, %8 : vector<3xi1>, vector<3xi32> + llvm.return %21 : vector<3xi32> + } + llvm.func @and_and(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.select %4, %5, %2 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @and_and_splatvec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi32> + %6 = llvm.and %arg0, %3 : vector<2xi32> + %7 = llvm.select %5, %6, %3 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @and_and_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[6, 2]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi32> + %6 = llvm.and %arg0, %3 : vector<2xi32> + %7 = llvm.select %5, %6, %3 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @and_and_vec_poison(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.mlir.undef : vector<3xi32> + %19 = llvm.mlir.constant(0 : i32) : i32 + %20 = llvm.insertelement %17, %18[%19 : i32] : vector<3xi32> + %21 = llvm.mlir.constant(1 : i32) : i32 + %22 = llvm.insertelement %1, %20[%21 : i32] : vector<3xi32> + %23 = llvm.mlir.constant(2 : i32) : i32 + %24 = llvm.insertelement %17, %22[%23 : i32] : vector<3xi32> + %25 = llvm.and %arg0, %8 : vector<3xi32> + %26 = llvm.icmp "eq" %25, %16 : vector<3xi32> + %27 = llvm.and %arg0, %24 : vector<3xi32> + %28 = llvm.select %26, %27, %24 : vector<3xi1>, vector<3xi32> + llvm.return %28 : vector<3xi32> + } + llvm.func @f_var0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %4, %1 : i32 + %6 = llvm.select %3, %5, %1 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @f_var0_commutative_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg1, %arg0 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %4, %1 : i32 + %6 = llvm.select %3, %5, %1 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @f_var0_splatvec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %arg1 : vector<2xi32> + %4 = llvm.icmp "eq" %3, %1 : vector<2xi32> + %5 = llvm.lshr %arg0, %2 : vector<2xi32> + %6 = llvm.and %5, %2 : vector<2xi32> + %7 = llvm.select %4, %6, %2 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @f_var0_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %arg1 : vector<2xi32> + %5 = llvm.icmp "eq" %4, %1 : vector<2xi32> + %6 = llvm.lshr %arg0, %2 : vector<2xi32> + %7 = llvm.and %6, %3 : vector<2xi32> + %8 = llvm.select %5, %7, %3 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @f_var0_vec_poison(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.and %arg0, %arg1 : vector<3xi32> + %18 = llvm.icmp "eq" %17, %8 : vector<3xi32> + %19 = llvm.lshr %arg0, %16 : vector<3xi32> + %20 = llvm.and %19, %16 : vector<3xi32> + %21 = llvm.select %18, %20, %16 : vector<3xi1>, vector<3xi32> + llvm.return %21 : vector<3xi32> + } + llvm.func @f_var1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.select %3, %4, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @f_var1_commutative_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg1, %arg0 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.select %3, %4, %1 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @f_var1_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %arg1 : vector<2xi32> + %4 = llvm.icmp "eq" %3, %1 : vector<2xi32> + %5 = llvm.and %arg0, %2 : vector<2xi32> + %6 = llvm.select %4, %5, %2 : vector<2xi1>, vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @f_var1_vec_poison(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.and %arg0, %arg1 : vector<3xi32> + %18 = llvm.icmp "eq" %17, %8 : vector<3xi32> + %19 = llvm.and %arg0, %16 : vector<3xi32> + %20 = llvm.select %18, %19, %16 : vector<3xi1>, vector<3xi32> + llvm.return %20 : vector<3xi32> + } + llvm.func @f_var2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.lshr %arg0, %arg1 : i32 + %5 = llvm.and %4, %0 : i32 + %6 = llvm.select %3, %5, %0 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @f_var2_splatvec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "eq" %3, %2 : vector<2xi32> + %5 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %6 = llvm.and %5, %0 : vector<2xi32> + %7 = llvm.select %4, %6, %0 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @f_var2_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[2, 1]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi32> + %6 = llvm.lshr %arg0, %arg1 : vector<2xi32> + %7 = llvm.and %6, %3 : vector<2xi32> + %8 = llvm.select %5, %7, %3 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @f_var2_vec_poison(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.and %arg0, %8 : vector<3xi32> + %18 = llvm.icmp "eq" %17, %16 : vector<3xi32> + %19 = llvm.lshr %arg0, %arg1 : vector<3xi32> + %20 = llvm.and %19, %8 : vector<3xi32> + %21 = llvm.select %18, %20, %8 : vector<3xi1>, vector<3xi32> + llvm.return %21 : vector<3xi32> + } + llvm.func @f_var3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.lshr %arg0, %arg2 : i32 + %5 = llvm.and %4, %1 : i32 + %6 = llvm.select %3, %5, %1 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @f_var3_commutative_and(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg1, %arg0 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.lshr %arg0, %arg2 : i32 + %5 = llvm.and %4, %1 : i32 + %6 = llvm.select %3, %5, %1 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @f_var3_splatvec(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %arg1 : vector<2xi32> + %4 = llvm.icmp "eq" %3, %1 : vector<2xi32> + %5 = llvm.lshr %arg0, %arg2 : vector<2xi32> + %6 = llvm.and %5, %2 : vector<2xi32> + %7 = llvm.select %4, %6, %2 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @f_var3_vec_poison(%arg0: vector<3xi32>, %arg1: vector<3xi32>, %arg2: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.and %arg0, %arg1 : vector<3xi32> + %18 = llvm.icmp "eq" %17, %8 : vector<3xi32> + %19 = llvm.lshr %arg0, %arg2 : vector<3xi32> + %20 = llvm.and %19, %16 : vector<3xi32> + %21 = llvm.select %18, %20, %16 : vector<3xi1>, vector<3xi32> + llvm.return %21 : vector<3xi32> + } + llvm.func @use32(i32) + llvm.func @use1(i1) + llvm.func @n_var0_oneuse(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.lshr %arg0, %arg2 : i32 + %5 = llvm.and %4, %1 : i32 + %6 = llvm.select %3, %5, %1 : i1, i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use1(%3) : (i1) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.return %6 : i32 + } + llvm.func @n_var1_oneuse(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.and %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.select %3, %4, %1 : i1, i32 + llvm.call @use32(%2) : (i32) -> () + llvm.call @use1(%3) : (i1) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @n0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.lshr %arg1, %0 : i32 + %5 = llvm.and %4, %0 : i32 + %6 = llvm.select %3, %5, %0 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @n1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %5, %2 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @n2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.lshr %arg0, %2 : i32 + %6 = llvm.and %5, %0 : i32 + %7 = llvm.select %4, %6, %1 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @n3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.select %4, %5, %1 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @n4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.lshr %arg0, %2 : i32 + %6 = llvm.and %5, %2 : i32 + %7 = llvm.select %4, %6, %0 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @n5(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.select %4, %5, %2 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @n6(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.lshr %arg0, %2 : i32 + %6 = llvm.and %5, %0 : i32 + %7 = llvm.select %4, %6, %0 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @n7(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %arg0, %2 : i32 + %6 = llvm.select %4, %5, %2 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @n8(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.lshr %arg0, %1 : i32 + %5 = llvm.and %4, %0 : i32 + %6 = llvm.select %3, %5, %0 : i1, i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/select-pr39595.ll.mlir b/test/LLVMDialect/InstCombine/select-pr39595.ll.mlir new file mode 100644 index 000000000..876121059 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-pr39595.ll.mlir @@ -0,0 +1,10 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.icmp "ugt" %1, %2 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/select-safe-bool-transforms.ll.mlir b/test/LLVMDialect/InstCombine/select-safe-bool-transforms.ll.mlir new file mode 100644 index 000000000..fb721d505 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-safe-bool-transforms.ll.mlir @@ -0,0 +1,328 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @land_land_left1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + %2 = llvm.select %1, %arg0, %0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @land_land_left2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg1, %arg0, %0 : i1, i1 + %2 = llvm.select %1, %arg0, %0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @land_band_left1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + %2 = llvm.and %1, %arg0 : i1 + llvm.return %2 : i1 + } + llvm.func @land_band_left2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg1, %arg0, %0 : i1, i1 + %2 = llvm.and %1, %arg0 : i1 + llvm.return %2 : i1 + } + llvm.func @land_lor_left1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %arg1, %0 : i1, i1 + %3 = llvm.select %2, %1, %arg0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @land_lor_left2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg1, %arg0, %0 : i1, i1 + %3 = llvm.select %2, %1, %arg0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @land_bor_left1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + %2 = llvm.or %1, %arg0 : i1 + llvm.return %2 : i1 + } + llvm.func @land_bor_left2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg1, %arg0, %0 : i1, i1 + %2 = llvm.or %1, %arg0 : i1 + llvm.return %2 : i1 + } + llvm.func @band_land_left1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.and %arg0, %arg1 : i1 + %2 = llvm.select %1, %arg0, %0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @band_land_left2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.and %arg1, %arg0 : i1 + %2 = llvm.select %1, %arg0, %0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @band_lor_left1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.and %arg0, %arg1 : i1 + %2 = llvm.select %1, %0, %arg0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @band_lor_left2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.and %arg1, %arg0 : i1 + %2 = llvm.select %1, %0, %arg0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @lor_land_left1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg0, %0, %arg1 : i1, i1 + %3 = llvm.select %2, %arg0, %1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @lor_land_left2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg1, %0, %arg0 : i1, i1 + %3 = llvm.select %2, %arg0, %1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @lor_band_left1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + %2 = llvm.and %1, %arg0 : i1 + llvm.return %2 : i1 + } + llvm.func @lor_band_left2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg1, %0, %arg0 : i1, i1 + %2 = llvm.and %1, %arg0 : i1 + llvm.return %2 : i1 + } + llvm.func @lor_lor_left1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + %2 = llvm.select %1, %0, %arg0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @lor_lor_left2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg1, %0, %arg0 : i1, i1 + %2 = llvm.select %1, %0, %arg0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @lor_bor_left1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + %2 = llvm.or %1, %arg0 : i1 + llvm.return %2 : i1 + } + llvm.func @lor_bor_left2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg1, %0, %arg0 : i1, i1 + %2 = llvm.or %1, %arg0 : i1 + llvm.return %2 : i1 + } + llvm.func @bor_land_left1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.or %arg0, %arg1 : i1 + %2 = llvm.select %1, %arg0, %0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @bor_land_left2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.or %arg1, %arg0 : i1 + %2 = llvm.select %1, %arg0, %0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @bor_lor_left1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.or %arg0, %arg1 : i1 + %2 = llvm.select %1, %0, %arg0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @bor_lor_left2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.or %arg1, %arg0 : i1 + %2 = llvm.select %1, %0, %arg0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @land_land_right1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + %2 = llvm.select %arg0, %1, %0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @land_land_right2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg1, %arg0, %0 : i1, i1 + %2 = llvm.select %arg0, %1, %0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @land_band_right1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + %2 = llvm.and %arg0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @land_band_right2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg1, %arg0, %0 : i1, i1 + %2 = llvm.and %arg0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @land_lor_right1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg0, %arg1, %0 : i1, i1 + %3 = llvm.select %arg0, %1, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @land_lor_right2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg1, %arg0, %0 : i1, i1 + %3 = llvm.select %arg0, %1, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @land_lor_right1_vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.select %arg0, %arg1, %1 : vector<2xi1>, vector<2xi1> + %5 = llvm.select %arg0, %3, %4 : vector<2xi1>, vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @land_lor_right2_vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.select %arg1, %arg0, %1 : vector<2xi1>, vector<2xi1> + %5 = llvm.select %arg0, %3, %4 : vector<2xi1>, vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @land_bor_right1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg0, %arg1, %0 : i1, i1 + %2 = llvm.or %arg0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @land_bor_right2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.select %arg1, %arg0, %0 : i1, i1 + %2 = llvm.or %arg0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @band_land_right1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.and %arg0, %arg1 : i1 + %2 = llvm.select %arg0, %1, %0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @band_land_right2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.and %arg1, %arg0 : i1 + %2 = llvm.select %arg0, %1, %0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @band_lor_right1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.and %arg0, %arg1 : i1 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @band_lor_right2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.and %arg1, %arg0 : i1 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @lor_land_right1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg0, %0, %arg1 : i1, i1 + %3 = llvm.select %arg0, %2, %1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @lor_land_right2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg1, %0, %arg0 : i1, i1 + %3 = llvm.select %arg0, %2, %1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @lor_band_right1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + %2 = llvm.and %arg0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @lor_band_right2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg1, %0, %arg0 : i1, i1 + %2 = llvm.and %arg0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @lor_lor_right1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @lor_lor_right2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg1, %0, %arg0 : i1, i1 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @lor_bor_right1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg1 : i1, i1 + %2 = llvm.or %arg0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @lor_bor_right2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg1, %0, %arg0 : i1, i1 + %2 = llvm.or %arg0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @bor_land_right1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.or %arg0, %arg1 : i1 + %2 = llvm.select %arg0, %1, %0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @bor_land_right2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.or %arg1, %arg0 : i1 + %2 = llvm.select %arg0, %1, %0 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @bor_lor_right1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.or %arg0, %arg1 : i1 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @bor_lor_right2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.or %arg1, %arg0 : i1 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + llvm.return %2 : i1 + } + llvm.func @PR50500_trueval(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.poison : vector<2xi1> + %1 = llvm.shufflevector %arg0, %0 [1, 0] : vector<2xi1> + %2 = llvm.select %arg0, %1, %arg1 : vector<2xi1>, vector<2xi1> + llvm.return %2 : vector<2xi1> + } + llvm.func @PR50500_falseval(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.poison : vector<2xi1> + %1 = llvm.shufflevector %arg0, %0 [1, 0] : vector<2xi1> + %2 = llvm.select %arg0, %arg1, %1 : vector<2xi1>, vector<2xi1> + llvm.return %2 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/select-safe-impliedcond-transforms.ll.mlir b/test/LLVMDialect/InstCombine/select-safe-impliedcond-transforms.ll.mlir new file mode 100644 index 000000000..d4036afd6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-safe-impliedcond-transforms.ll.mlir @@ -0,0 +1,129 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a_true_implies_b_true(%arg0: i8, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(20 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "ugt" %arg0, %0 : i8 + %4 = llvm.icmp "ugt" %arg0, %1 : i8 + %5 = llvm.select %4, %arg1, %arg2 : i1, i1 + %6 = llvm.select %3, %5, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @a_true_implies_b_true_vec(%arg0: i8, %arg1: vector<2xi1>, %arg2: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<[20, 19]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(10 : i8) : i8 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %6 = llvm.insertelement %arg0, %0[%1 : i8] : vector<2xi8> + %7 = llvm.shufflevector %6, %0 [0, 0] : vector<2xi8> + %8 = llvm.icmp "ugt" %7, %2 : vector<2xi8> + %9 = llvm.icmp "ugt" %arg0, %3 : i8 + %10 = llvm.select %9, %arg1, %arg2 : i1, vector<2xi1> + %11 = llvm.select %8, %10, %5 : vector<2xi1>, vector<2xi1> + llvm.return %11 : vector<2xi1> + } + llvm.func @a_true_implies_b_true2(%arg0: i8, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(20 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.icmp "ugt" %arg0, %1 : i8 + %4 = llvm.select %3, %arg1, %arg2 : i1, i1 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @a_true_implies_b_true2_comm(%arg0: i8, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(20 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.icmp "ugt" %arg0, %1 : i8 + %4 = llvm.select %3, %arg1, %arg2 : i1, i1 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @a_true_implies_b_false(%arg0: i8, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(20 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "ugt" %arg0, %0 : i8 + %4 = llvm.icmp "ult" %arg0, %1 : i8 + %5 = llvm.select %4, %arg1, %arg2 : i1, i1 + %6 = llvm.select %3, %5, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @a_true_implies_b_false2(%arg0: i8, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(20 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.icmp "eq" %arg0, %1 : i8 + %4 = llvm.select %3, %arg1, %arg2 : i1, i1 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @a_true_implies_b_false2_comm(%arg0: i8, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(20 : i8) : i8 + %1 = llvm.mlir.constant(10 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.icmp "eq" %arg0, %1 : i8 + %4 = llvm.select %3, %arg1, %arg2 : i1, i1 + %5 = llvm.and %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @a_false_implies_b_true(%arg0: i8, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "ugt" %arg0, %0 : i8 + %4 = llvm.icmp "ult" %arg0, %1 : i8 + %5 = llvm.select %4, %arg1, %arg2 : i1, i1 + %6 = llvm.select %3, %2, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @a_false_implies_b_true2(%arg0: i8, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.icmp "ult" %arg0, %1 : i8 + %4 = llvm.select %3, %arg1, %arg2 : i1, i1 + %5 = llvm.or %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @a_false_implies_b_true2_comm(%arg0: i8, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.icmp "ult" %arg0, %1 : i8 + %4 = llvm.select %3, %arg1, %arg2 : i1, i1 + %5 = llvm.or %4, %2 : i1 + llvm.return %5 : i1 + } + llvm.func @a_false_implies_b_false(%arg0: i8, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "ugt" %arg0, %0 : i8 + %4 = llvm.icmp "ugt" %arg0, %1 : i8 + %5 = llvm.select %4, %arg1, %arg2 : i1, i1 + %6 = llvm.select %3, %2, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @a_false_implies_b_false2(%arg0: i8, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.icmp "ugt" %arg0, %1 : i8 + %4 = llvm.select %3, %arg1, %arg2 : i1, i1 + %5 = llvm.or %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @a_false_implies_b_false2_comm(%arg0: i8, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(20 : i8) : i8 + %2 = llvm.icmp "ugt" %arg0, %0 : i8 + %3 = llvm.icmp "ugt" %arg0, %1 : i8 + %4 = llvm.select %3, %arg1, %arg2 : i1, i1 + %5 = llvm.or %4, %2 : i1 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/select-safe-transforms.ll.mlir b/test/LLVMDialect/InstCombine/select-safe-transforms.ll.mlir new file mode 100644 index 000000000..31b014233 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-safe-transforms.ll.mlir @@ -0,0 +1,563 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @glb(0 : i8) {addr_space = 0 : i32} : i8 + llvm.func @gen1() -> i1 + llvm.func @cond_eq_and(%arg0: i8, %arg1: i8, %arg2: i8 {llvm.noundef}) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.icmp "eq" %arg0, %arg2 : i8 + %2 = llvm.icmp "ult" %arg0, %arg1 : i8 + %3 = llvm.select %1, %2, %0 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @cond_eq_and_const(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.icmp "ult" %arg0, %arg1 : i8 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @cond_eq_or(%arg0: i8, %arg1: i8, %arg2: i8 {llvm.noundef}) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "ne" %arg0, %arg2 : i8 + %2 = llvm.icmp "ult" %arg0, %arg1 : i8 + %3 = llvm.select %1, %0, %2 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @cond_eq_or_const(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ne" %arg0, %0 : i8 + %3 = llvm.icmp "ult" %arg0, %arg1 : i8 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @xor_and(%arg0: i1, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "ult" %arg1, %arg2 : i32 + %3 = llvm.select %arg0, %2, %0 : i1, i1 + %4 = llvm.xor %3, %1 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_and2(%arg0: vector<2xi1>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : vector<2xi1> + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.icmp "ult" %arg1, %arg2 : vector<2xi32> + %5 = llvm.select %arg0, %4, %2 : vector<2xi1>, vector<2xi1> + %6 = llvm.xor %5, %3 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @xor_and3(%arg0: vector<2xi1>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.addressof @glb : !llvm.ptr + %3 = llvm.ptrtoint %2 : !llvm.ptr to i1 + %4 = llvm.mlir.undef : vector<2xi1> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi1> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<2xi1> + %9 = llvm.mlir.constant(true) : i1 + %10 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %11 = llvm.icmp "ult" %arg1, %arg2 : vector<2xi32> + %12 = llvm.select %arg0, %11, %8 : vector<2xi1>, vector<2xi1> + %13 = llvm.xor %12, %10 : vector<2xi1> + llvm.return %13 : vector<2xi1> + } + llvm.func @xor_or(%arg0: i1, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "ult" %arg1, %arg2 : i32 + %2 = llvm.select %arg0, %0, %1 : i1, i1 + %3 = llvm.xor %2, %0 : i1 + llvm.return %3 : i1 + } + llvm.func @xor_or2(%arg0: vector<2xi1>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : vector<2xi1> + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.icmp "ult" %arg1, %arg2 : vector<2xi32> + %5 = llvm.select %arg0, %2, %4 : vector<2xi1>, vector<2xi1> + %6 = llvm.xor %5, %3 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @xor_or3(%arg0: vector<2xi1>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.addressof @glb : !llvm.ptr + %3 = llvm.ptrtoint %2 : !llvm.ptr to i1 + %4 = llvm.mlir.undef : vector<2xi1> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi1> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<2xi1> + %9 = llvm.mlir.constant(true) : i1 + %10 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %11 = llvm.icmp "ult" %arg1, %arg2 : vector<2xi32> + %12 = llvm.select %arg0, %8, %11 : vector<2xi1>, vector<2xi1> + %13 = llvm.xor %12, %10 : vector<2xi1> + llvm.return %13 : vector<2xi1> + } + llvm.func @and_orn_cmp_1_logical(%arg0: i32, %arg1: i32, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %3 = llvm.icmp "sle" %arg0, %arg1 : i32 + %4 = llvm.select %arg2, %0, %3 : i1, i1 + %5 = llvm.select %2, %4, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @and_orn_cmp_1_partial_logical(%arg0: i32, %arg1: i32, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %2 = llvm.icmp "sle" %arg0, %arg1 : i32 + %3 = llvm.or %2, %arg2 : i1 + %4 = llvm.select %1, %3, %0 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @and_orn_cmp_1_partial_logical_commute(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.call @gen1() : () -> i1 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %3 = llvm.icmp "sle" %arg0, %arg1 : i32 + %4 = llvm.or %1, %3 : i1 + %5 = llvm.select %2, %4, %0 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @andn_or_cmp_2_logical(%arg0: i16, %arg1: i16, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sge" %arg0, %arg1 : i16 + %3 = llvm.icmp "slt" %arg0, %arg1 : i16 + %4 = llvm.select %arg2, %0, %2 : i1, i1 + %5 = llvm.select %4, %3, %1 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @andn_or_cmp_2_partial_logical(%arg0: i16, %arg1: i16, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.icmp "sge" %arg0, %arg1 : i16 + %2 = llvm.icmp "slt" %arg0, %arg1 : i16 + %3 = llvm.or %1, %arg2 : i1 + %4 = llvm.select %3, %2, %0 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @andn_or_cmp_2_partial_logical_commute(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.call @gen1() : () -> i1 + %2 = llvm.icmp "sge" %arg0, %arg1 : i16 + %3 = llvm.icmp "slt" %arg0, %arg1 : i16 + %4 = llvm.or %1, %2 : i1 + %5 = llvm.select %4, %3, %0 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @not_logical_or(%arg0: i1, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %6 = llvm.icmp "ult" %arg1, %0 : vector<2xi32> + %7 = llvm.icmp "slt" %arg1, %1 : vector<2xi32> + %8 = llvm.select %arg0, %3, %7 : i1, vector<2xi1> + %9 = llvm.select %6, %8, %5 : vector<2xi1>, vector<2xi1> + llvm.return %9 : vector<2xi1> + } + llvm.func @not_logical_or2(%arg0: i1, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %6 = llvm.icmp "ult" %arg1, %0 : vector<2xi32> + %7 = llvm.icmp "slt" %arg1, %1 : vector<2xi32> + %8 = llvm.select %arg0, %3, %7 : i1, vector<2xi1> + %9 = llvm.select %8, %6, %5 : vector<2xi1>, vector<2xi1> + llvm.return %9 : vector<2xi1> + } + llvm.func @bools_logical_commute0(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %2, %arg0, %1 : i1, i1 + %4 = llvm.select %arg2, %arg1, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools_logical_commute0_and1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.and %2, %arg0 : i1 + %4 = llvm.select %arg2, %arg1, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools_logical_commute0_and2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %2, %arg0, %1 : i1, i1 + %4 = llvm.and %arg2, %arg1 : i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools_logical_commute0_and1_and2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg2, %0 : i1 + %2 = llvm.and %1, %arg0 : i1 + %3 = llvm.and %arg2, %arg1 : i1 + %4 = llvm.select %2, %0, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @bools_logical_commute1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %arg0, %2, %1 : i1, i1 + %4 = llvm.select %arg2, %arg1, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools_logical_commute1_and1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.call @gen1() : () -> i1 + %3 = llvm.xor %arg1, %0 : i1 + %4 = llvm.and %2, %3 : i1 + %5 = llvm.select %arg1, %arg0, %1 : i1, i1 + %6 = llvm.select %4, %0, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @bools_logical_commute1_and2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %arg0, %2, %1 : i1, i1 + %4 = llvm.and %arg2, %arg1 : i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools_logical_commute1_and1_and2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.call @gen1() : () -> i1 + %2 = llvm.xor %arg1, %0 : i1 + %3 = llvm.and %1, %2 : i1 + %4 = llvm.and %arg1, %arg0 : i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools_logical_commute2(%arg0: vector<2xi1>, %arg1: vector<2xi1>, %arg2: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.xor %arg2, %1 : vector<2xi1> + %5 = llvm.select %4, %arg0, %3 : vector<2xi1>, vector<2xi1> + %6 = llvm.select %arg1, %arg2, %3 : vector<2xi1>, vector<2xi1> + %7 = llvm.select %5, %1, %6 : vector<2xi1>, vector<2xi1> + llvm.return %7 : vector<2xi1> + } + llvm.func @bools_logical_commute2_and1(%arg0: vector<2xi1>, %arg1: vector<2xi1>, %arg2: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.xor %arg2, %1 : vector<2xi1> + %5 = llvm.and %4, %arg0 : vector<2xi1> + %6 = llvm.select %arg1, %arg2, %3 : vector<2xi1>, vector<2xi1> + %7 = llvm.select %5, %1, %6 : vector<2xi1>, vector<2xi1> + llvm.return %7 : vector<2xi1> + } + llvm.func @bools_logical_commute2_and2(%arg0: vector<2xi1>, %arg1: vector<2xi1>, %arg2: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.xor %arg2, %1 : vector<2xi1> + %5 = llvm.select %4, %arg0, %3 : vector<2xi1>, vector<2xi1> + %6 = llvm.and %arg1, %arg2 : vector<2xi1> + %7 = llvm.select %5, %1, %6 : vector<2xi1>, vector<2xi1> + llvm.return %7 : vector<2xi1> + } + llvm.func @bools_logical_commute2_and1_and2(%arg0: vector<2xi1>, %arg1: vector<2xi1>, %arg2: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.xor %arg2, %1 : vector<2xi1> + %3 = llvm.and %2, %arg0 : vector<2xi1> + %4 = llvm.and %arg1, %arg2 : vector<2xi1> + %5 = llvm.select %3, %1, %4 : vector<2xi1>, vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @bools_logical_commute3(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %arg0, %2, %1 : i1, i1 + %4 = llvm.select %arg1, %arg2, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools_logical_commute3_and1(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.call @gen1() : () -> i1 + %3 = llvm.xor %arg1, %0 : i1 + %4 = llvm.and %2, %3 : i1 + %5 = llvm.select %arg0, %arg1, %1 : i1, i1 + %6 = llvm.select %4, %0, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @bools_logical_commute3_and2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %arg0, %2, %1 : i1, i1 + %4 = llvm.and %arg1, %arg2 : i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools_logical_commute3_and1_and2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.call @gen1() : () -> i1 + %2 = llvm.xor %arg1, %0 : i1 + %3 = llvm.and %1, %2 : i1 + %4 = llvm.and %arg0, %arg1 : i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools2_logical_commute0(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %arg2, %arg0, %1 : i1, i1 + %4 = llvm.select %2, %arg1, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools2_logical_commute0_and1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.and %arg2, %arg0 : i1 + %4 = llvm.select %2, %arg1, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools2_logical_commute0_and2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %arg2, %arg0, %1 : i1, i1 + %4 = llvm.and %2, %arg1 : i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools2_logical_commute0_and1_and2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg2, %0 : i1 + %2 = llvm.and %arg2, %arg0 : i1 + %3 = llvm.and %1, %arg1 : i1 + %4 = llvm.select %2, %0, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @bools2_logical_commute1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %arg0, %arg2, %1 : i1, i1 + %4 = llvm.select %2, %arg1, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools2_logical_commute1_and1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.and %arg0, %arg2 : i1 + %4 = llvm.select %2, %arg1, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools2_logical_commute1_and2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %arg0, %arg2, %1 : i1, i1 + %4 = llvm.and %2, %arg1 : i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools2_logical_commute1_and1_and2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg2, %0 : i1 + %2 = llvm.and %arg0, %arg2 : i1 + %3 = llvm.and %1, %arg1 : i1 + %4 = llvm.select %2, %0, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @bools2_logical_commute2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %arg2, %arg0, %1 : i1, i1 + %4 = llvm.select %arg1, %2, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools2_logical_commute2_and1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.and %arg2, %arg0 : i1 + %4 = llvm.select %arg1, %2, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools2_logical_commute2_and2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.call @gen1() : () -> i1 + %3 = llvm.xor %arg1, %0 : i1 + %4 = llvm.select %arg1, %arg0, %1 : i1, i1 + %5 = llvm.and %2, %3 : i1 + %6 = llvm.select %4, %0, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @bools2_logical_commute2_and1_and2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.call @gen1() : () -> i1 + %2 = llvm.xor %arg1, %0 : i1 + %3 = llvm.and %arg1, %arg0 : i1 + %4 = llvm.and %1, %2 : i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools2_logical_commute3(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %arg0, %arg2, %1 : i1, i1 + %4 = llvm.select %arg1, %2, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools2_logical_commute3_nopoison(%arg0: i1, %arg1: i1, %arg2: i1 {llvm.noundef}) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.select %arg0, %arg2, %1 : i1, i1 + %4 = llvm.select %arg1, %2, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools2_logical_commute3_and1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.xor %arg2, %0 : i1 + %3 = llvm.and %arg0, %arg2 : i1 + %4 = llvm.select %arg1, %2, %1 : i1, i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @bools2_logical_commute3_and2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.call @gen1() : () -> i1 + %3 = llvm.xor %arg1, %0 : i1 + %4 = llvm.select %arg0, %arg1, %1 : i1, i1 + %5 = llvm.and %2, %3 : i1 + %6 = llvm.select %4, %0, %5 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @bools2_logical_commute3_and1_and2(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.call @gen1() : () -> i1 + %2 = llvm.xor %arg1, %0 : i1 + %3 = llvm.and %arg0, %arg1 : i1 + %4 = llvm.and %1, %2 : i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @orn_and_cmp_1_logical(%arg0: i37, %arg1: i37, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i37 + %3 = llvm.icmp "sle" %arg0, %arg1 : i37 + %4 = llvm.select %arg2, %2, %0 : i1, i1 + %5 = llvm.select %3, %1, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @orn_and_cmp_1_partial_logical(%arg0: i37, %arg1: i37, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i37 + %2 = llvm.icmp "sle" %arg0, %arg1 : i37 + %3 = llvm.and %1, %arg2 : i1 + %4 = llvm.select %2, %0, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @orn_and_cmp_1_partial_logical_commute(%arg0: i37, %arg1: i37) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.call @gen1() : () -> i1 + %2 = llvm.icmp "sgt" %arg0, %arg1 : i37 + %3 = llvm.icmp "sle" %arg0, %arg1 : i37 + %4 = llvm.and %1, %2 : i1 + %5 = llvm.select %3, %0, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @orn_and_cmp_2_logical(%arg0: i16, %arg1: i16, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sge" %arg0, %arg1 : i16 + %3 = llvm.icmp "slt" %arg0, %arg1 : i16 + %4 = llvm.select %arg2, %2, %0 : i1, i1 + %5 = llvm.select %4, %1, %3 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @orn_and_cmp_2_partial_logical(%arg0: i16, %arg1: i16, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "sge" %arg0, %arg1 : i16 + %2 = llvm.icmp "slt" %arg0, %arg1 : i16 + %3 = llvm.and %1, %arg2 : i1 + %4 = llvm.select %3, %0, %2 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @orn_and_cmp_2_partial_logical_commute(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.call @gen1() : () -> i1 + %2 = llvm.icmp "sge" %arg0, %arg1 : i16 + %3 = llvm.icmp "slt" %arg0, %arg1 : i16 + %4 = llvm.and %1, %2 : i1 + %5 = llvm.select %4, %0, %3 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @not_logical_and(%arg0: i1, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %6 = llvm.icmp "ult" %arg1, %0 : vector<2xi32> + %7 = llvm.icmp "ugt" %arg1, %1 : vector<2xi32> + %8 = llvm.select %arg0, %6, %3 : i1, vector<2xi1> + %9 = llvm.select %7, %5, %8 : vector<2xi1>, vector<2xi1> + llvm.return %9 : vector<2xi1> + } + llvm.func @not_logical_and2(%arg0: i1, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %6 = llvm.icmp "ult" %arg1, %0 : vector<2xi32> + %7 = llvm.icmp "ugt" %arg1, %1 : vector<2xi32> + %8 = llvm.select %arg0, %6, %3 : i1, vector<2xi1> + %9 = llvm.select %8, %5, %7 : vector<2xi1>, vector<2xi1> + llvm.return %9 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/select-select.ll.mlir b/test/LLVMDialect/InstCombine/select-select.ll.mlir new file mode 100644 index 000000000..d9fca0b5f --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-select.ll.mlir @@ -0,0 +1,367 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo1(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ogt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "olt" %3, %1 : f32 + %5 = llvm.select %4, %3, %1 : i1, f32 + llvm.return %5 : f32 + } + llvm.func @foo2(%arg0: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = llvm.fcmp "ogt" %arg0, %0 : f32 + %3 = llvm.select %2, %arg0, %0 : i1, f32 + %4 = llvm.fcmp "olt" %3, %1 : f32 + %5 = llvm.select %2, %arg0, %0 : i1, f32 + %6 = llvm.select %4, %5, %1 : i1, f32 + llvm.return %6 : f32 + } + llvm.func @foo3(%arg0: vector<2xi1>, %arg1: i1, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.select %arg0, %1, %arg2 : vector<2xi1>, vector<2xi32> + %3 = llvm.select %arg1, %2, %arg2 : i1, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @sel_shuf_commute0(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi1>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 5, 2, 7] : vector<4xi8> + %1 = llvm.select %arg2, %0, %arg0 : vector<4xi1>, vector<4xi8> + llvm.return %1 : vector<4xi8> + } + llvm.func @sel_shuf_commute1(%arg0: vector<5xi9>, %arg1: vector<5xi9>, %arg2: vector<5xi1>) -> vector<5xi9> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 6, 2, 8, 9] : vector<5xi9> + %1 = llvm.select %arg2, %0, %arg1 : vector<5xi1>, vector<5xi9> + llvm.return %1 : vector<5xi9> + } + llvm.func @sel_shuf_commute2(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: vector<4xi1>) -> vector<4xf32> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 7] : vector<4xf32> + %1 = llvm.select %arg2, %arg0, %0 : vector<4xi1>, vector<4xf32> + llvm.return %1 : vector<4xf32> + } + llvm.func @sel_shuf_commute3(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: i1) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 5, 2, 3] : vector<4xi8> + %1 = llvm.select %arg2, %arg1, %0 : i1, vector<4xi8> + llvm.return %1 : vector<4xi8> + } + llvm.func @use(vector<4xi8>) + llvm.func @sel_shuf_use(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi1>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 5, 2, 7] : vector<4xi8> + llvm.call @use(%0) : (vector<4xi8>) -> () + %1 = llvm.select %arg2, %0, %arg0 : vector<4xi1>, vector<4xi8> + llvm.return %1 : vector<4xi8> + } + llvm.func @sel_shuf_undef(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi1>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 5, 2, -1] : vector<4xi8> + %1 = llvm.select %arg2, %0, %arg1 : vector<4xi1>, vector<4xi8> + llvm.return %1 : vector<4xi8> + } + llvm.func @sel_shuf_not(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi1>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 5, 2, 6] : vector<4xi8> + %1 = llvm.select %arg2, %0, %arg1 : vector<4xi1>, vector<4xi8> + llvm.return %1 : vector<4xi8> + } + llvm.func @sel_shuf_no_common_operand(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi1>, %arg3: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 5, 2, 3] : vector<4xi8> + %1 = llvm.select %arg2, %arg3, %0 : vector<4xi1>, vector<4xi8> + llvm.return %1 : vector<4xi8> + } + llvm.func @sel_shuf_narrowing_commute1(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi1>) -> vector<2xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 5] : vector<4xi8> + %1 = llvm.select %arg3, %0, %arg2 : vector<2xi1>, vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @sel_shuf_narrowing_commute2(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi1>) -> vector<2xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 5] : vector<4xi8> + %1 = llvm.select %arg3, %arg2, %0 : vector<2xi1>, vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @strong_order_cmp_slt_eq(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "slt" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i8 + %5 = llvm.icmp "eq" %arg0, %arg1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @strong_order_cmp_ult_eq(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "ult" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i8 + %5 = llvm.icmp "eq" %arg0, %arg1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @strong_order_cmp_slt_eq_wrong_const(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "slt" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i8 + %5 = llvm.icmp "eq" %arg0, %arg1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @strong_order_cmp_ult_eq_wrong_const(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "ult" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i8 + %5 = llvm.icmp "eq" %arg0, %arg1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @strong_order_cmp_slt_ult_wrong_pred(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "slt" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i8 + %5 = llvm.icmp "ult" %arg0, %arg1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @strong_order_cmp_sgt_eq(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i8 + %5 = llvm.icmp "eq" %arg0, %arg1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @strong_order_cmp_ugt_eq(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i8 + %5 = llvm.icmp "eq" %arg0, %arg1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @strong_order_cmp_eq_slt(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.icmp "eq" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i8 + %5 = llvm.icmp "slt" %arg0, %arg1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @strong_order_cmp_eq_sgt(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.icmp "eq" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i8 + %5 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @strong_order_cmp_eq_ult(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.icmp "eq" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i8 + %5 = llvm.icmp "ult" %arg0, %arg1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @strong_order_cmp_eq_ugt(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.icmp "eq" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i8 + %5 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @strong_order_cmp_slt_sgt(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %arg1 : i32 + %2 = llvm.sext %1 : i1 to i8 + %3 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @strong_order_cmp_ult_ugt(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.icmp "ult" %arg0, %arg1 : i32 + %2 = llvm.sext %1 : i1 to i8 + %3 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @strong_order_cmp_sgt_slt(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %2 = llvm.zext %1 : i1 to i8 + %3 = llvm.icmp "slt" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @strong_order_cmp_ugt_ult(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %2 = llvm.zext %1 : i1 to i8 + %3 = llvm.icmp "ult" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @strong_order_cmp_ne_ugt_ne_not_one_use(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.icmp "ne" %arg0, %arg1 : i32 + llvm.call @use1(%1) : (i1) -> () + %2 = llvm.sext %1 : i1 to i8 + %3 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @strong_order_cmp_slt_eq_slt_not_oneuse(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "slt" %arg0, %arg1 : i32 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.select %3, %0, %1 : i1, i8 + %5 = llvm.icmp "eq" %arg0, %arg1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @strong_order_cmp_sgt_eq_eq_not_oneuse(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %1 : i1, i8 + %5 = llvm.icmp "eq" %arg0, %arg1 : i32 + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.select %5, %2, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @strong_order_cmp_eq_ugt_eq_not_oneuse(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.icmp "eq" %arg0, %arg1 : i32 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.select %3, %0, %1 : i1, i8 + %5 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %6 = llvm.select %5, %2, %4 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @strong_order_cmp_ugt_ult_zext_not_oneuse(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %2 = llvm.zext %1 : i1 to i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ult" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @strong_order_cmp_slt_sgt_sext_not_oneuse(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %arg1 : i32 + %2 = llvm.sext %1 : i1 to i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @strong_order_cmp_ugt_ult_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.icmp "ugt" %arg0, %arg1 : vector<2xi32> + %2 = llvm.zext %1 : vector<2xi1> to vector<2xi8> + %3 = llvm.icmp "ult" %arg0, %arg1 : vector<2xi32> + %4 = llvm.select %3, %0, %2 : vector<2xi1>, vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @strong_order_cmp_ugt_ult_vector_poison(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi8> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.icmp "ugt" %arg0, %arg1 : vector<2xi32> + %8 = llvm.zext %7 : vector<2xi1> to vector<2xi8> + %9 = llvm.icmp "ult" %arg0, %arg1 : vector<2xi32> + %10 = llvm.select %9, %6, %8 : vector<2xi1>, vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @strong_order_cmp_eq_ugt_vector(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %4 = llvm.icmp "eq" %arg0, %arg1 : vector<2xi32> + %5 = llvm.select %4, %1, %2 : vector<2xi1>, vector<2xi8> + %6 = llvm.icmp "ugt" %arg0, %arg1 : vector<2xi32> + %7 = llvm.select %6, %3, %5 : vector<2xi1>, vector<2xi8> + llvm.return %7 : vector<2xi8> + } + llvm.func @strong_order_cmp_eq_ugt_vector_poison1(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %8 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %9 = llvm.icmp "eq" %arg0, %arg1 : vector<2xi32> + %10 = llvm.select %9, %6, %7 : vector<2xi1>, vector<2xi8> + %11 = llvm.icmp "ugt" %arg0, %arg1 : vector<2xi32> + %12 = llvm.select %11, %8, %10 : vector<2xi1>, vector<2xi8> + llvm.return %12 : vector<2xi8> + } + llvm.func @strong_order_cmp_eq_ugt_vector_poison2(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.mlir.poison : i8 + %4 = llvm.mlir.undef : vector<2xi8> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi8> + %9 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %10 = llvm.icmp "eq" %arg0, %arg1 : vector<2xi32> + %11 = llvm.select %10, %1, %8 : vector<2xi1>, vector<2xi8> + %12 = llvm.icmp "ugt" %arg0, %arg1 : vector<2xi32> + %13 = llvm.select %12, %9, %11 : vector<2xi1>, vector<2xi8> + llvm.return %13 : vector<2xi8> + } + llvm.func @strong_order_cmp_eq_ugt_vector_poison3(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.poison : i8 + %4 = llvm.mlir.constant(1 : i8) : i8 + %5 = llvm.mlir.undef : vector<2xi8> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %4, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %3, %7[%8 : i32] : vector<2xi8> + %10 = llvm.icmp "eq" %arg0, %arg1 : vector<2xi32> + %11 = llvm.select %10, %1, %2 : vector<2xi1>, vector<2xi8> + %12 = llvm.icmp "ugt" %arg0, %arg1 : vector<2xi32> + %13 = llvm.select %12, %9, %11 : vector<2xi1>, vector<2xi8> + llvm.return %13 : vector<2xi8> + } + llvm.func @use1(i1) + llvm.func @use8(i8) +} diff --git a/test/LLVMDialect/InstCombine/select-with-bitwise-ops.ll.mlir b/test/LLVMDialect/InstCombine/select-with-bitwise-ops.ll.mlir new file mode 100644 index 000000000..010d58b93 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select-with-bitwise-ops.ll.mlir @@ -0,0 +1,1143 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @use_vec(vector<2xi8>) + llvm.func @select_icmp_eq_and_1_0_or_2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.or %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_eq_and_1_0_or_2_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi32> + %6 = llvm.or %arg1, %3 : vector<2xi32> + %7 = llvm.select %5, %arg1, %6 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @select_icmp_eq_and_1_0_or_2_vec_poison1(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(0 : i32) : i32 + %8 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %9 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %10 = llvm.and %arg0, %6 : vector<2xi32> + %11 = llvm.icmp "eq" %10, %8 : vector<2xi32> + %12 = llvm.or %arg1, %9 : vector<2xi32> + %13 = llvm.select %11, %arg1, %12 : vector<2xi1>, vector<2xi32> + llvm.return %13 : vector<2xi32> + } + llvm.func @select_icmp_eq_and_1_0_or_2_vec_poison2(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.undef : vector<2xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi32> + %8 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %9 = llvm.and %arg0, %0 : vector<2xi32> + %10 = llvm.icmp "eq" %9, %7 : vector<2xi32> + %11 = llvm.or %arg1, %8 : vector<2xi32> + %12 = llvm.select %10, %arg1, %11 : vector<2xi1>, vector<2xi32> + llvm.return %12 : vector<2xi32> + } + llvm.func @select_icmp_eq_and_1_0_or_2_vec_poison3(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.poison : i32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.undef : vector<2xi32> + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.insertelement %4, %5[%6 : i32] : vector<2xi32> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.insertelement %3, %7[%8 : i32] : vector<2xi32> + %10 = llvm.and %arg0, %0 : vector<2xi32> + %11 = llvm.icmp "eq" %10, %2 : vector<2xi32> + %12 = llvm.or %arg1, %9 : vector<2xi32> + %13 = llvm.select %11, %arg1, %12 : vector<2xi1>, vector<2xi32> + llvm.return %13 : vector<2xi32> + } + llvm.func @select_icmp_eq_and_1_0_xor_2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.xor %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_eq_and_1_0_and_not_2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-3 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_eq_and_32_0_or_8(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.or %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_eq_and_32_0_or_8_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi32> + %6 = llvm.or %arg1, %3 : vector<2xi32> + %7 = llvm.select %5, %arg1, %6 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @select_icmp_eq_and_32_0_xor_8(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.xor %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_eq_and_32_0_and_not_8(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-9 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_ne_0_and_4096_or_4096(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %1, %2 : i32 + %4 = llvm.or %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @select_icmp_ne_0_and_4096_or_4096_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4096> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "ne" %2, %3 : vector<2xi32> + %5 = llvm.or %arg1, %0 : vector<2xi32> + %6 = llvm.select %4, %arg1, %5 : vector<2xi1>, vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @select_icmp_ne_0_and_4096_xor_4096(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %1, %2 : i32 + %4 = llvm.xor %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @select_icmp_ne_0_and_4096_and_not_4096(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-4097 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_eq_and_4096_0_or_4096(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.or %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @select_icmp_eq_and_4096_0_or_4096_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4096> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "eq" %3, %2 : vector<2xi32> + %5 = llvm.or %arg1, %0 : vector<2xi32> + %6 = llvm.select %4, %arg1, %5 : vector<2xi1>, vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @select_icmp_eq_and_4096_0_xor_4096(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.xor %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @select_icmp_eq_and_4096_0_and_not_4096(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-4097 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_eq_0_and_1_or_1(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i64 + %4 = llvm.icmp "eq" %3, %1 : i64 + %5 = llvm.or %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_eq_0_and_1_or_1_vec(%arg0: vector<2xi64>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi64> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi64> + %6 = llvm.or %arg1, %3 : vector<2xi32> + %7 = llvm.select %5, %arg1, %6 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @select_icmp_eq_0_and_1_xor_1(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i64 + %4 = llvm.icmp "eq" %3, %1 : i64 + %5 = llvm.xor %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_eq_0_and_1_and_not_1(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(-2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i64 + %4 = llvm.icmp "eq" %3, %1 : i64 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_ne_0_and_4096_or_32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.or %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_ne_0_and_4096_xor_32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.xor %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_ne_0_and_4096_and_not_32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-33 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_ne_0_and_32_or_4096(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(4096 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.or %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_ne_0_and_32_or_4096_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<4096> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.icmp "ne" %2, %4 : vector<2xi32> + %6 = llvm.or %arg1, %3 : vector<2xi32> + %7 = llvm.select %5, %arg1, %6 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @select_icmp_ne_0_and_32_xor_4096(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(4096 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.xor %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_ne_0_and_32_and_not_4096(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-4097 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_ne_0_and_1073741824_or_8(%arg0: i32, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1073741824 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i8) : i8 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.or %arg1, %2 : i8 + %6 = llvm.select %4, %arg1, %5 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @select_icmp_ne_0_and_1073741824_xor_8(%arg0: i32, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1073741824 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i8) : i8 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.xor %arg1, %2 : i8 + %6 = llvm.select %4, %arg1, %5 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @select_icmp_ne_0_and_1073741824_and_not_8(%arg0: i32, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1073741824 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-9 : i8) : i8 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.and %arg1, %2 : i8 + %6 = llvm.select %4, %arg1, %5 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @select_icmp_ne_0_and_8_or_1073741824(%arg0: i8, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(1073741824 : i32) : i32 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.icmp "ne" %1, %3 : i8 + %5 = llvm.or %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_ne_0_and_8_xor_1073741824(%arg0: i8, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(1073741824 : i32) : i32 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.icmp "ne" %1, %3 : i8 + %5 = llvm.xor %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_ne_0_and_8_and_not_1073741824(%arg0: i8, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(-1073741825 : i32) : i32 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.icmp "ne" %1, %3 : i8 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_eq_and_1_0_or_vector_of_2s(%arg0: i32, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.or %arg1, %2 : vector<2xi32> + %6 = llvm.select %4, %arg1, %5 : i1, vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @select_icmp_and_8_ne_0_xor_8(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.select %3, %arg0, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @select_icmp_and_8_eq_0_xor_8(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.select %3, %4, %arg0 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @select_icmp_x_and_8_eq_0_y_xor_8(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i64) : i64 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.xor %arg1, %2 : i64 + %6 = llvm.select %4, %arg1, %5 : i1, i64 + llvm.return %6 : i64 + } + llvm.func @select_icmp_x_and_8_ne_0_y_xor_8(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i64) : i64 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.xor %arg1, %2 : i64 + %6 = llvm.select %4, %5, %arg1 : i1, i64 + llvm.return %6 : i64 + } + llvm.func @select_icmp_x_and_8_ne_0_y_or_8(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(8 : i64) : i64 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.or %arg1, %2 : i64 + %6 = llvm.select %4, %5, %arg1 : i1, i64 + llvm.return %6 : i64 + } + llvm.func @select_icmp_x_and_8_ne_0_y_or_8_vec(%arg0: vector<2xi32>, %arg1: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<8> : vector<2xi64>) : vector<2xi64> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi32> + %6 = llvm.or %arg1, %3 : vector<2xi64> + %7 = llvm.select %5, %6, %arg1 : vector<2xi1>, vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @select_icmp_x_and_8_ne_0_y_and_not_8(%arg0: i32, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-9 : i64) : i64 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg1, %2 : i64 + %6 = llvm.select %4, %5, %arg1 : i1, i64 + llvm.return %6 : i64 + } + llvm.func @select_icmp_and_2147483648_ne_0_xor_2147483648(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.select %3, %arg0, %4 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @select_icmp_and_2147483648_eq_0_xor_2147483648(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.xor %arg0, %0 : i32 + %5 = llvm.select %3, %4, %arg0 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @select_icmp_x_and_2147483648_ne_0_or_2147483648(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.or %arg0, %0 : i32 + %5 = llvm.select %3, %4, %arg0 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test68(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.or %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test68vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<128> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi32> + %6 = llvm.or %arg1, %3 : vector<2xi32> + %7 = llvm.select %5, %arg1, %6 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @test68_xor(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.xor %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test68_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-3 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test69(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.or %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test69vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<128> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.icmp "ne" %4, %2 : vector<2xi32> + %6 = llvm.or %arg1, %3 : vector<2xi32> + %7 = llvm.select %5, %arg1, %6 : vector<2xi1>, vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @test69_xor(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.xor %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test69_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @test70(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + %3 = llvm.or %arg1, %1 : i8 + %4 = llvm.select %2, %3, %arg1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @test70_multiuse(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.icmp "slt" %arg0, %0 : i8 + %3 = llvm.or %arg1, %1 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.select %2, %3, %arg1 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @shift_no_xor_multiuse_or(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.or %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.mul %6, %5 : i32 + llvm.return %7 : i32 + } + llvm.func @shift_no_xor_multiuse_xor(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.xor %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.mul %6, %5 : i32 + llvm.return %7 : i32 + } + llvm.func @shift_no_xor_multiuse_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-3 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.mul %6, %5 : i32 + llvm.return %7 : i32 + } + llvm.func @no_shift_no_xor_multiuse_or(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.or %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + %6 = llvm.mul %5, %4 : i32 + llvm.return %6 : i32 + } + llvm.func @no_shift_no_xor_multiuse_xor(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.xor %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + %6 = llvm.mul %5, %4 : i32 + llvm.return %6 : i32 + } + llvm.func @no_shift_no_xor_multiuse_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-4097 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.add %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.mul %6, %5 : i32 + llvm.return %7 : i32 + } + llvm.func @no_shift_xor_multiuse_or(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %1, %2 : i32 + %4 = llvm.or %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + %6 = llvm.mul %5, %4 : i32 + llvm.return %6 : i32 + } + llvm.func @no_shift_xor_multiuse_xor(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %1, %2 : i32 + %4 = llvm.xor %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + %6 = llvm.mul %5, %4 : i32 + llvm.return %6 : i32 + } + llvm.func @no_shift_xor_multiuse_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-4097 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.mul %6, %5 : i32 + llvm.return %7 : i32 + } + llvm.func @shift_xor_multiuse_or(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2048 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.or %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.mul %6, %5 : i32 + llvm.return %7 : i32 + } + llvm.func @shift_xor_multiuse_xor(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2048 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.xor %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.mul %6, %5 : i32 + llvm.return %7 : i32 + } + llvm.func @shift_xor_multiuse_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-2049 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.mul %6, %5 : i32 + llvm.return %7 : i32 + } + llvm.func @shift_no_xor_multiuse_cmp(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.or %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @shift_no_xor_multiuse_cmp_with_xor(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.xor %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @shift_no_xor_multiuse_cmp_with_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-3 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @no_shift_no_xor_multiuse_cmp(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.or %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + %6 = llvm.select %3, %arg2, %arg3 : i1, i32 + %7 = llvm.mul %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @no_shift_no_xor_multiuse_cmp_with_xor(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.xor %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + %6 = llvm.select %3, %arg2, %arg3 : i1, i32 + %7 = llvm.mul %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @no_shift_no_xor_multiuse_cmp_with_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-4097 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @no_shift_xor_multiuse_cmp(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %1, %2 : i32 + %4 = llvm.or %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + %6 = llvm.select %3, %arg2, %arg3 : i1, i32 + %7 = llvm.mul %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @no_shift_xor_multiuse_cmp_with_xor(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %1, %2 : i32 + %4 = llvm.xor %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + %6 = llvm.select %3, %arg2, %arg3 : i1, i32 + %7 = llvm.mul %5, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @no_shift_xor_multiuse_cmp_with_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-4097 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @shift_xor_multiuse_cmp(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2048 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.or %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @shift_xor_multiuse_cmp_with_xor(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2048 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.xor %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @shift_xor_multiuse_cmp_with_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-2049 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + llvm.return %8 : i32 + } + llvm.func @shift_no_xor_multiuse_cmp_or(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.or %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + %9 = llvm.mul %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @shift_no_xor_multiuse_cmp_xor(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.xor %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + %9 = llvm.mul %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @shift_no_xor_multiuse_cmp_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-3 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + %9 = llvm.mul %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @no_shift_no_xor_multiuse_cmp_or(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.or %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + %6 = llvm.select %3, %arg2, %arg3 : i1, i32 + %7 = llvm.mul %5, %6 : i32 + %8 = llvm.mul %7, %4 : i32 + llvm.return %8 : i32 + } + llvm.func @no_shift_no_xor_multiuse_cmp_xor(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.xor %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + %6 = llvm.select %3, %arg2, %arg3 : i1, i32 + %7 = llvm.mul %5, %6 : i32 + %8 = llvm.mul %7, %4 : i32 + llvm.return %8 : i32 + } + llvm.func @no_shift_no_xor_multiuse_cmp_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-4097 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + %9 = llvm.mul %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @no_shift_xor_multiuse_cmp_or(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %1, %2 : i32 + %4 = llvm.or %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + %6 = llvm.select %3, %arg2, %arg3 : i1, i32 + %7 = llvm.mul %5, %6 : i32 + %8 = llvm.mul %7, %4 : i32 + llvm.return %8 : i32 + } + llvm.func @no_shift_xor_multiuse_cmp_xor(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %1, %2 : i32 + %4 = llvm.xor %arg1, %0 : i32 + %5 = llvm.select %3, %arg1, %4 : i1, i32 + %6 = llvm.select %3, %arg2, %arg3 : i1, i32 + %7 = llvm.mul %5, %6 : i32 + %8 = llvm.mul %7, %4 : i32 + llvm.return %8 : i32 + } + llvm.func @no_shift_xor_multiuse_cmp_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-4097 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + %9 = llvm.mul %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @shift_xor_multiuse_cmp_or(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2048 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.or %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + %9 = llvm.mul %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @shift_xor_multiuse_cmp_xor(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2048 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.xor %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + %9 = llvm.mul %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @shift_xor_multiuse_cmp_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i32 { + %0 = llvm.mlir.constant(4096 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2048 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + %5 = llvm.and %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + %7 = llvm.select %4, %arg2, %arg3 : i1, i32 + %8 = llvm.mul %6, %7 : i32 + %9 = llvm.mul %8, %5 : i32 + llvm.return %9 : i32 + } + llvm.func @set_bits(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(-6 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.or %arg0, %1 : i8 + %4 = llvm.select %arg1, %3, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @set_bits_not_inverse_constant(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(-6 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.or %arg0, %1 : i8 + %4 = llvm.select %arg1, %3, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @set_bits_extra_use1(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(-6 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.or %arg0, %1 : i8 + %4 = llvm.select %arg1, %3, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @set_bits_extra_use2(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(-6 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.or %arg0, %1 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.select %arg1, %3, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @clear_bits(%arg0: vector<2xi8>, %arg1: vector<2xi1>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<37> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-38> : vector<2xi8>) : vector<2xi8> + %2 = llvm.and %arg0, %0 : vector<2xi8> + %3 = llvm.or %arg0, %1 : vector<2xi8> + %4 = llvm.select %arg1, %2, %3 : vector<2xi1>, vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @clear_bits_not_inverse_constant(%arg0: vector<2xi8>, %arg1: vector<2xi1>) -> vector<2xi8> { + %0 = llvm.mlir.constant(37 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(dense<-38> : vector<2xi8>) : vector<2xi8> + %8 = llvm.and %arg0, %6 : vector<2xi8> + %9 = llvm.or %arg0, %7 : vector<2xi8> + %10 = llvm.select %arg1, %8, %9 : vector<2xi1>, vector<2xi8> + llvm.return %10 : vector<2xi8> + } + llvm.func @clear_bits_extra_use1(%arg0: vector<2xi8>, %arg1: i1) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<37> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-38> : vector<2xi8>) : vector<2xi8> + %2 = llvm.and %arg0, %0 : vector<2xi8> + llvm.call @use_vec(%2) : (vector<2xi8>) -> () + %3 = llvm.or %arg0, %1 : vector<2xi8> + %4 = llvm.select %arg1, %2, %3 : i1, vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @clear_bits_extra_use2(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(-6 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.or %arg0, %1 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.select %arg1, %2, %3 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @xor_i8_to_i64_shl_save_and_eq(%arg0: i8, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + %5 = llvm.xor %arg1, %2 : i64 + %6 = llvm.select %4, %5, %arg1 : i1, i64 + llvm.return %6 : i64 + } + llvm.func @xor_i8_to_i64_shl_save_and_ne(%arg0: i8, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.icmp "ne" %3, %1 : i8 + %5 = llvm.xor %arg1, %2 : i64 + %6 = llvm.select %4, %5, %arg1 : i1, i64 + llvm.return %6 : i64 + } + llvm.func @select_icmp_eq_and_1_0_srem_2_fail_null_identity(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.srem %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_eq_and_1_0_sdiv_2_fail_null_1_identity(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.sdiv %arg1, %2 : i32 + %6 = llvm.select %4, %arg1, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @select_icmp_eq_and_1_0_lshr_fv(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + %5 = llvm.lshr %arg1, %2 : i8 + %6 = llvm.select %4, %arg1, %5 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @select_icmp_eq_and_1_0_lshr_tv(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.icmp "ne" %3, %1 : i8 + %5 = llvm.lshr %arg1, %2 : i8 + %6 = llvm.select %4, %5, %arg1 : i1, i8 + llvm.return %6 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/select.ll.mlir b/test/LLVMDialect/InstCombine/select.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/select_arithmetic.ll.mlir b/test/LLVMDialect/InstCombine/select_arithmetic.ll.mlir new file mode 100644 index 000000000..def30fc96 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select_arithmetic.ll.mlir @@ -0,0 +1,97 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1a(%arg0: i1 {llvm.zeroext}) -> f32 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(6.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(9.000000e+00 : f32) : f32 + %4 = llvm.select %arg0, %0, %1 : i1, f32 + %5 = llvm.select %arg0, %2, %3 : i1, f32 + %6 = llvm.fadd %4, %5 : f32 + llvm.return %6 : f32 + } + llvm.func @test1b(%arg0: i1 {llvm.zeroext}) -> f32 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(6.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(9.000000e+00 : f32) : f32 + %4 = llvm.mlir.constant(2.500000e-01 : f32) : f32 + %5 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %6 = llvm.select %arg0, %0, %1 : i1, f32 + %7 = llvm.select %arg0, %2, %3 : i1, f32 + %8 = llvm.select %arg0, %4, %5 : i1, f32 + %9 = llvm.fadd %6, %7 : f32 + %10 = llvm.fadd %8, %7 : f32 + %11 = llvm.fadd %10, %9 : f32 + llvm.return %11 : f32 + } + llvm.func @test2(%arg0: i1 {llvm.zeroext}) -> f32 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(6.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(9.000000e+00 : f32) : f32 + %4 = llvm.select %arg0, %0, %1 : i1, f32 + %5 = llvm.select %arg0, %2, %3 : i1, f32 + %6 = llvm.fsub %4, %5 : f32 + llvm.return %6 : f32 + } + llvm.func @test3(%arg0: i1 {llvm.zeroext}) -> f32 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(6.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(9.000000e+00 : f32) : f32 + %4 = llvm.select %arg0, %0, %1 : i1, f32 + %5 = llvm.select %arg0, %2, %3 : i1, f32 + %6 = llvm.fmul %4, %5 : f32 + llvm.return %6 : f32 + } + llvm.func @use_float(f32) + llvm.func @test4(%arg0: i1 {llvm.zeroext}) -> f32 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(6.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(9.000000e+00 : f32) : f32 + %4 = llvm.select %arg0, %0, %1 : i1, f32 + %5 = llvm.select %arg0, %2, %3 : i1, f32 + %6 = llvm.fmul %4, %5 : f32 + llvm.call @use_float(%4) : (f32) -> () + llvm.return %6 : f32 + } + llvm.func @test5(%arg0: i1 {llvm.zeroext}, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %1 = llvm.select %arg0, %arg1, %0 : i1, f32 + %2 = llvm.fmul %1, %1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @use_float(%1) : (f32) -> () + llvm.return %2 : f32 + } + llvm.func @fmul_nnan_nsz(%arg0: i1, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(-0.000000e+00 : f32) : f32 + %2 = llvm.select %arg0, %arg1, %0 : i1, f32 + %3 = llvm.select %arg0, %1, %arg1 : i1, f32 + %4 = llvm.fmul %2, %3 {fastmathFlags = #llvm.fastmath} : f32 + llvm.return %4 : f32 + } + llvm.func @fadd_nsz(%arg0: vector<2xi1>, %arg1: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf32>) : vector<2xf32> + %2 = llvm.select %arg0, %arg1, %1 : vector<2xi1>, vector<2xf32> + %3 = llvm.select %arg0, %1, %arg1 : vector<2xi1>, vector<2xf32> + %4 = llvm.fadd %2, %3 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + llvm.return %4 : vector<2xf32> + } + llvm.func @fsub_nnan(%arg0: i1, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.mlir.constant(7.000000e+00 : f64) : f64 + %1 = llvm.select %arg0, %arg1, %arg2 : i1, f64 + %2 = llvm.select %arg0, %arg1, %0 : i1, f64 + %3 = llvm.fsub %1, %2 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %3 : f64 + } + llvm.func @fdiv_nnan_nsz(%arg0: i1, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(4.200000e+01 : f64) : f64 + %2 = llvm.select %arg0, %arg2, %0 : i1, f64 + %3 = llvm.select %arg0, %1, %arg1 : i1, f64 + %4 = llvm.fdiv %2, %3 {fastmathFlags = #llvm.fastmath} : f64 + llvm.return %4 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/select_meta.ll.mlir b/test/LLVMDialect/InstCombine/select_meta.ll.mlir new file mode 100644 index 000000000..ff024c5c1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/select_meta.ll.mlir @@ -0,0 +1,231 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func local_unnamed_addr @foo(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(20 : i32) : i32 + %2 = llvm.mlir.constant(-20 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 overflow : i32 + %5 = llvm.add %arg0, %2 : i32 + %6 = llvm.select %3, %4, %5 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @shrink_select(%arg0: i1, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.select %arg0, %arg1, %0 : i1, i32 + %2 = llvm.trunc %1 : i32 to i8 + llvm.return %2 : i8 + } + llvm.func @min_max_bitcast(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: !llvm.ptr, %arg3: !llvm.ptr) { + %0 = llvm.fcmp "olt" %arg0, %arg1 : vector<4xf32> + %1 = llvm.bitcast %arg0 : vector<4xf32> to vector<4xi32> + %2 = llvm.bitcast %arg1 : vector<4xf32> to vector<4xi32> + %3 = llvm.select %0, %1, %2 : vector<4xi1>, vector<4xi32> + %4 = llvm.select %0, %2, %1 : vector<4xi1>, vector<4xi32> + llvm.store %3, %arg2 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.store %4, %arg3 {alignment = 16 : i64} : vector<4xi32>, !llvm.ptr + llvm.return + } + llvm.func local_unnamed_addr @foo2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.add %arg0, %arg1 overflow : i32 + %3 = llvm.sub %arg0, %arg1 overflow : i32 + %4 = llvm.select %1, %2, %3 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @test43(%arg0: i32) -> i64 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.sext %arg0 : i32 to i64 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.select %3, %2, %1 : i1, i64 + llvm.return %4 : i64 + } + llvm.func @scalar_select_of_vectors_sext(%arg0: vector<2xi1>, %arg1: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sext %arg0 : vector<2xi1> to vector<2xi32> + %3 = llvm.select %arg1, %2, %1 : i1, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @t7(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(-32768 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i16) : i16 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.trunc %arg0 : i32 to i16 + %4 = llvm.select %2, %3, %1 : i1, i16 + llvm.return %4 : i16 + } + llvm.func @abs_nabs_x01(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.select %2, %3, %arg0 : i1, i32 + %5 = llvm.icmp "sgt" %4, %0 : i32 + %6 = llvm.sub %1, %4 overflow : i32 + %7 = llvm.select %5, %4, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @abs_nabs_x01_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %4 = llvm.sub %2, %arg0 overflow : vector<2xi32> + %5 = llvm.select %3, %4, %arg0 : vector<2xi1>, vector<2xi32> + %6 = llvm.icmp "sgt" %5, %0 : vector<2xi32> + %7 = llvm.sub %2, %5 overflow : vector<2xi32> + %8 = llvm.select %6, %5, %7 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @test30(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "sgt" %1, %arg0 : i32 + %3 = llvm.select %2, %1, %arg0 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @test70(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(75 : i32) : i32 + %1 = llvm.mlir.constant(36 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test72(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(92 : i32) : i32 + %1 = llvm.mlir.constant(11 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.icmp "sgt" %3, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @test74(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(36 : i32) : i32 + %1 = llvm.mlir.constant(75 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %0, %arg0 : i1, i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @smin1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.select %3, %2, %0 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @smin2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @smax1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.select %3, %2, %0 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @smax2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.select %3, %0, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @umin1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @umin2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %1, %arg0 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @umax1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.select %2, %arg0, %1 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @umax2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.select %2, %1, %arg0 : i1, i32 + llvm.return %3 : i32 + } + llvm.func @not_cond(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.xor %arg0, %0 : i1 + %2 = llvm.select %1, %arg1, %arg2 : i1, i32 + llvm.return %2 : i32 + } + llvm.func @not_cond_vec(%arg0: vector<2xi1>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.xor %arg0, %1 : vector<2xi1> + %3 = llvm.select %2, %arg1, %arg2 : vector<2xi1>, vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @not_cond_vec_poison(%arg0: vector<2xi1>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.poison : i1 + %2 = llvm.mlir.undef : vector<2xi1> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi1> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi1> + %7 = llvm.xor %arg0, %6 : vector<2xi1> + %8 = llvm.select %7, %arg1, %arg2 : vector<2xi1>, vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @select_add(%arg0: i1, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.add %arg1, %arg2 : i64 + %1 = llvm.select %arg0, %0, %arg1 : i1, i64 + llvm.return %1 : i64 + } + llvm.func @select_or(%arg0: vector<2xi1>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.or %arg1, %arg2 : vector<2xi32> + %1 = llvm.select %arg0, %0, %arg1 : vector<2xi1>, vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @select_sub(%arg0: i1, %arg1: i17, %arg2: i17) -> i17 { + %0 = llvm.sub %arg1, %arg2 : i17 + %1 = llvm.select %arg0, %0, %arg1 : i1, i17 + llvm.return %1 : i17 + } + llvm.func @select_ashr(%arg0: i1, %arg1: i128, %arg2: i128) -> i128 { + %0 = llvm.ashr %arg1, %arg2 : i128 + %1 = llvm.select %arg0, %0, %arg1 : i1, i128 + llvm.return %1 : i128 + } + llvm.func @select_fmul(%arg0: i1, %arg1: f64, %arg2: f64) -> f64 { + %0 = llvm.fmul %arg1, %arg2 : f64 + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f64 + llvm.return %1 : f64 + } + llvm.func @select_fdiv(%arg0: i1, %arg1: vector<2xf32>, %arg2: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.fdiv %arg1, %arg2 : vector<2xf32> + %1 = llvm.select %arg0, %0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, vector<2xf32> + llvm.return %1 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/set-lowbits-mask-canonicalize.ll.mlir b/test/LLVMDialect/InstCombine/set-lowbits-mask-canonicalize.ll.mlir new file mode 100644 index 000000000..f092b200f --- /dev/null +++ b/test/LLVMDialect/InstCombine/set-lowbits-mask-canonicalize.ll.mlir @@ -0,0 +1,207 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @shl_add(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.add %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_add_nsw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.add %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_add_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.add %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_add_nsw_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.add %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nsw_add(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 overflow : i32 + %3 = llvm.add %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nsw_add_nsw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 overflow : i32 + %3 = llvm.add %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nsw_add_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 overflow : i32 + %3 = llvm.add %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nsw_add_nsw_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 overflow : i32 + %3 = llvm.add %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nuw_add(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 overflow : i32 + %3 = llvm.add %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nuw_add_nsw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 overflow : i32 + %3 = llvm.add %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nuw_add_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 overflow : i32 + %3 = llvm.add %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nuw_add_nsw_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 overflow : i32 + %3 = llvm.add %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nsw_nuw_add(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 overflow : i32 + %3 = llvm.add %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nsw_nuw_add_nsw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 overflow : i32 + %3 = llvm.add %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nsw_nuw_add_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 overflow : i32 + %3 = llvm.add %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nsw_nuw_add_nsw_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 overflow : i32 + %3 = llvm.add %2, %1 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_add_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.shl %0, %arg0 : vector<2xi32> + %3 = llvm.add %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @shl_add_vec_poison0(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(dense<-1> : vector<3xi32>) : vector<3xi32> + %10 = llvm.shl %8, %arg0 : vector<3xi32> + %11 = llvm.add %10, %9 : vector<3xi32> + llvm.return %11 : vector<3xi32> + } + llvm.func @shl_add_vec_poison1(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.undef : vector<3xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi32> + %10 = llvm.shl %0, %arg0 : vector<3xi32> + %11 = llvm.add %10, %9 : vector<3xi32> + llvm.return %11 : vector<3xi32> + } + llvm.func @shl_add_vec_poison2(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(-1 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.shl %8, %arg0 : vector<3xi32> + %18 = llvm.add %17, %16 : vector<3xi32> + llvm.return %18 : vector<3xi32> + } + llvm.func @use32(i32) + llvm.func @bad_oneuse0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.add %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @bad_shl(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.add %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @bad_add0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %0, %arg0 : i32 + %2 = llvm.add %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @bad_add1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %0, %arg0 : i32 + %2 = llvm.add %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @bad_add2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.add %2, %1 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/set.ll.mlir b/test/LLVMDialect/InstCombine/set.ll.mlir new file mode 100644 index 000000000..e2e46d52d --- /dev/null +++ b/test/LLVMDialect/InstCombine/set.ll.mlir @@ -0,0 +1,358 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @X() {addr_space = 0 : i32} : i32 + llvm.func @use(i1) + llvm.func @test1(%arg0: i32) -> i1 { + %0 = llvm.mlir.addressof @X : !llvm.ptr + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %arg0 : i32 + %3 = llvm.icmp "eq" %0, %1 : !llvm.ptr + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test1_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.addressof @X : !llvm.ptr + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "eq" %arg0, %arg0 : i32 + %4 = llvm.icmp "eq" %0, %1 : !llvm.ptr + %5 = llvm.select %3, %4, %2 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @test2(%arg0: i32) -> i1 { + %0 = llvm.mlir.addressof @X : !llvm.ptr + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.icmp "ne" %arg0, %arg0 : i32 + %3 = llvm.icmp "ne" %0, %1 : !llvm.ptr + %4 = llvm.or %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test2_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.addressof @X : !llvm.ptr + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "ne" %arg0, %arg0 : i32 + %4 = llvm.icmp "ne" %0, %1 : !llvm.ptr + %5 = llvm.select %3, %2, %4 : i1, i1 + llvm.return %5 : i1 + } + llvm.func @test3(%arg0: i32) -> i1 { + %0 = llvm.icmp "slt" %arg0, %arg0 : i32 + llvm.return %0 : i1 + } + llvm.func @test4(%arg0: i32) -> i1 { + %0 = llvm.icmp "sgt" %arg0, %arg0 : i32 + llvm.return %0 : i1 + } + llvm.func @test5(%arg0: i32) -> i1 { + %0 = llvm.icmp "sle" %arg0, %arg0 : i32 + llvm.return %0 : i1 + } + llvm.func @test6(%arg0: i32) -> i1 { + %0 = llvm.icmp "sge" %arg0, %arg0 : i32 + llvm.return %0 : i1 + } + llvm.func @test7(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "uge" %arg0, %0 : i32 + llvm.return %1 : i1 + } + llvm.func @test8(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ult" %arg0, %0 : i32 + llvm.return %1 : i1 + } + llvm.func @test9(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.icmp "ult" %arg0, %0 : i1 + llvm.return %1 : i1 + } + llvm.func @test10(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "ugt" %arg0, %0 : i1 + llvm.return %1 : i1 + } + llvm.func @test11(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "ule" %arg0, %0 : i1 + llvm.return %1 : i1 + } + llvm.func @test12(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.icmp "uge" %arg0, %0 : i1 + llvm.return %1 : i1 + } + llvm.func @test13(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.icmp "uge" %arg0, %arg1 : i1 + llvm.return %0 : i1 + } + llvm.func @test13vec(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.icmp "uge" %arg0, %arg1 : vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @test14(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.icmp "eq" %arg0, %arg1 : i1 + llvm.return %0 : i1 + } + llvm.func @test14vec(%arg0: vector<3xi1>, %arg1: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.icmp "eq" %arg0, %arg1 : vector<3xi1> + llvm.return %0 : vector<3xi1> + } + llvm.func @bool_eq0(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "sgt" %arg0, %0 : i64 + %4 = llvm.icmp "eq" %arg0, %1 : i64 + %5 = llvm.icmp "eq" %4, %2 : i1 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @bool_eq0_logical(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "sgt" %arg0, %0 : i64 + %4 = llvm.icmp "eq" %arg0, %1 : i64 + %5 = llvm.icmp "eq" %4, %2 : i1 + %6 = llvm.select %3, %5, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @xor_of_icmps(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + %3 = llvm.icmp "eq" %arg0, %1 : i64 + %4 = llvm.xor %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_of_icmps_commute(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + %3 = llvm.icmp "eq" %arg0, %1 : i64 + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_of_icmps_to_ne(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(6 : i64) : i64 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + %3 = llvm.icmp "slt" %arg0, %1 : i64 + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_of_icmps_to_ne_commute(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(6 : i64) : i64 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + %3 = llvm.icmp "slt" %arg0, %1 : i64 + %4 = llvm.xor %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_of_icmps_neg_to_ne(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(-6 : i64) : i64 + %1 = llvm.mlir.constant(-4 : i64) : i64 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + %3 = llvm.icmp "slt" %arg0, %1 : i64 + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_of_icmps_to_ne_vector(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<6> : vector<2xi64>) : vector<2xi64> + %2 = llvm.icmp "sgt" %arg0, %0 : vector<2xi64> + %3 = llvm.icmp "slt" %arg0, %1 : vector<2xi64> + %4 = llvm.xor %2, %3 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @xor_of_icmps_to_ne_no_common_operand(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(6 : i64) : i64 + %2 = llvm.icmp "sgt" %arg1, %0 : i64 + %3 = llvm.icmp "slt" %arg0, %1 : i64 + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_of_icmps_to_ne_extra_use_one(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(6 : i64) : i64 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + %3 = llvm.icmp "slt" %arg0, %1 : i64 + llvm.call @use(%2) : (i1) -> () + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_of_icmps_to_ne_extra_use_two(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.mlir.constant(6 : i64) : i64 + %2 = llvm.icmp "sgt" %arg0, %0 : i64 + %3 = llvm.icmp "slt" %arg0, %1 : i64 + llvm.call @use(%2) : (i1) -> () + llvm.call @use(%3) : (i1) -> () + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_of_icmps_to_eq(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(126 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.icmp "sgt" %arg0, %0 : i8 + %3 = llvm.icmp "slt" %arg0, %1 : i8 + %4 = llvm.xor %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @PR2844(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-638208501 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.icmp "eq" %arg0, %0 : i32 + %4 = llvm.icmp "slt" %arg0, %1 : i32 + %5 = llvm.or %3, %4 : i1 + %6 = llvm.select %5, %0, %2 : i1, i32 + llvm.return %6 : i32 + } + llvm.func @PR2844_logical(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-638208501 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %0 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.select %4, %2, %5 : i1, i1 + %7 = llvm.select %6, %0, %3 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @test16(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test17(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @test18(%arg0: i1, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(123 : i32) : i32 + llvm.cond_br %arg0, ^bb2(%0 : i32), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : i32) + ^bb2(%3: i32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.icmp "slt" %3, %2 : i32 + llvm.return %4 : i1 + } + llvm.func @test19(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.zext %arg0 : i1 to i32 + %1 = llvm.zext %arg1 : i1 to i32 + %2 = llvm.icmp "eq" %0, %1 : i32 + llvm.return %2 : i1 + } + llvm.func @test20(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + %4 = llvm.zext %3 : i1 to i32 + llvm.return %4 : i32 + } + llvm.func @test20vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi32> + %5 = llvm.zext %4 : vector<2xi1> to vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test21(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + %4 = llvm.zext %3 : i1 to i32 + llvm.return %4 : i32 + } + llvm.func @test21vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi32> + %5 = llvm.zext %4 : vector<2xi1> to vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test22(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(100663295 : i32) : i32 + %1 = llvm.mlir.constant(268435456 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(-1 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ult" %4, %1 : i32 + %6 = llvm.and %arg1, %2 : i32 + %7 = llvm.icmp "sgt" %6, %3 : i32 + %8 = llvm.or %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @test22_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(100663295 : i32) : i32 + %1 = llvm.mlir.constant(268435456 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.constant(-1 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "ult" %5, %1 : i32 + %7 = llvm.and %arg1, %2 : i32 + %8 = llvm.icmp "sgt" %7, %3 : i32 + %9 = llvm.select %6, %4, %8 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @test23(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.zext %3 : i1 to i32 + llvm.return %4 : i32 + } + llvm.func @test23vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %0 : vector<2xi32> + %4 = llvm.icmp "eq" %3, %2 : vector<2xi32> + %5 = llvm.zext %4 : vector<2xi1> to vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test24(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.lshr %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @test24vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.and %arg0, %0 : vector<2xi32> + %5 = llvm.lshr %4, %1 : vector<2xi32> + %6 = llvm.icmp "eq" %5, %3 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi1> to vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @test25(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.icmp "ugt" %1, %0 : i32 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/setcc-strength-reduce.ll.mlir b/test/LLVMDialect/InstCombine/setcc-strength-reduce.ll.mlir index b457be758..4fbe0a323 100644 --- a/test/LLVMDialect/InstCombine/setcc-strength-reduce.ll.mlir +++ b/test/LLVMDialect/InstCombine/setcc-strength-reduce.ll.mlir @@ -1,33 +1,27 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 9 : i64} : (i32, i32) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 8 : i64} : (i32, i32) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -127 : i8} : () -> i8 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 5 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 126 : i8} : () -> i8 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 3 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 127 : i8} : () -> i8 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.icmp "uge" %arg0, %0 : i32 + llvm.return %1 : i1 + } + llvm.func @test2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ugt" %arg0, %0 : i32 + llvm.return %1 : i1 + } + llvm.func @test3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-127 : i8) : i8 + %1 = llvm.icmp "sge" %arg0, %0 : i8 + llvm.return %1 : i1 + } + llvm.func @test4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(126 : i8) : i8 + %1 = llvm.icmp "sle" %arg0, %0 : i8 + llvm.return %1 : i1 + } + llvm.func @test5(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/sext-of-trunc-nsw.ll.mlir b/test/LLVMDialect/InstCombine/sext-of-trunc-nsw.ll.mlir index 188edea9c..7d1f53ee8 100644 --- a/test/LLVMDialect/InstCombine/sext-of-trunc-nsw.ll.mlir +++ b/test/LLVMDialect/InstCombine/sext-of-trunc-nsw.ll.mlir @@ -1,146 +1,128 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use4", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "usevec", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i8} : () -> i8 - %1 = "llvm.ashr"(%arg0, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.trunc"(%1) : (i8) -> i4 - %3 = "llvm.sext"(%2) : (i4) -> i16 - "llvm.return"(%3) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "t0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i8} : () -> i8 - %1 = "llvm.ashr"(%arg0, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.trunc"(%1) : (i8) -> i4 - %3 = "llvm.sext"(%2) : (i4) -> i16 - "llvm.return"(%3) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "t1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i8} : () -> i8 - %1 = "llvm.ashr"(%arg0, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.trunc"(%1) : (i8) -> i4 - %3 = "llvm.sext"(%2) : (i4) -> i16 - "llvm.return"(%3) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "n2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<4> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.ashr"(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.call"(%1) {callee = @usevec, fastmathFlags = #llvm.fastmath<>} : (vector<2xi8>) -> () - %2 = "llvm.trunc"(%1) : (vector<2xi8>) -> vector<2xi4> - %3 = "llvm.sext"(%2) : (vector<2xi4>) -> vector<2xi16> - "llvm.return"(%3) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "t3_vec", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[4, 3]> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.ashr"(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.call"(%1) {callee = @usevec, fastmathFlags = #llvm.fastmath<>} : (vector<2xi8>) -> () - %2 = "llvm.trunc"(%1) : (vector<2xi8>) -> vector<2xi4> - %3 = "llvm.sext"(%2) : (vector<2xi4>) -> vector<2xi16> - "llvm.return"(%3) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "t4_vec_nonsplat", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i8} : () -> i8 - %1 = "llvm.ashr"(%arg0, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.trunc"(%1) : (i8) -> i4 - "llvm.call"(%2) {callee = @use4, fastmathFlags = #llvm.fastmath<>} : (i4) -> () - %3 = "llvm.sext"(%2) : (i4) -> i16 - "llvm.return"(%3) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "t5_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%0, %2) : (i32, i32) -> i32 - %4 = "llvm.trunc"(%3) : (i32) -> i8 - %5 = "llvm.sext"(%4) : (i8) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "narrow_source_matching_signbits", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%0, %2) : (i32, i32) -> i32 - %4 = "llvm.trunc"(%3) : (i32) -> i8 - %5 = "llvm.sext"(%4) : (i8) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "narrow_source_not_matching_signbits", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%0, %2) : (i32, i32) -> i32 - %4 = "llvm.trunc"(%3) : (i32) -> i8 - %5 = "llvm.sext"(%4) : (i8) -> i24 - "llvm.return"(%5) : (i24) -> () - }) {linkage = 10 : i64, sym_name = "wide_source_matching_signbits", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%0, %2) : (i32, i32) -> i32 - %4 = "llvm.trunc"(%3) : (i32) -> i8 - %5 = "llvm.sext"(%4) : (i8) -> i24 - "llvm.return"(%5) : (i24) -> () - }) {linkage = 10 : i64, sym_name = "wide_source_not_matching_signbits", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%0, %2) : (i32, i32) -> i32 - %4 = "llvm.trunc"(%3) : (i32) -> i8 - %5 = "llvm.sext"(%4) : (i8) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "same_source_matching_signbits", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%0, %2) : (i32, i32) -> i32 - %4 = "llvm.trunc"(%3) : (i32) -> i8 - %5 = "llvm.sext"(%4) : (i8) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "same_source_not_matching_signbits", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%0, %2) : (i32, i32) -> i32 - %4 = "llvm.trunc"(%3) : (i32) -> i8 - "llvm.call"(%4) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %5 = "llvm.sext"(%4) : (i8) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "same_source_matching_signbits_extra_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%0, %2) : (i32, i32) -> i32 - %4 = "llvm.trunc"(%3) : (i32) -> i8 - "llvm.call"(%4) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %5 = "llvm.sext"(%4) : (i8) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "same_source_not_matching_signbits_extra_use", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use4(i4) + llvm.func @usevec(vector<2xi8>) + llvm.func @t0(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.trunc %1 : i8 to i4 + %3 = llvm.sext %2 : i4 to i16 + llvm.return %3 : i16 + } + llvm.func @t1(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.trunc %1 : i8 to i4 + %3 = llvm.sext %2 : i4 to i16 + llvm.return %3 : i16 + } + llvm.func @n2(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.trunc %1 : i8 to i4 + %3 = llvm.sext %2 : i4 to i16 + llvm.return %3 : i16 + } + llvm.func @t3_vec(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi8>) : vector<2xi8> + %1 = llvm.ashr %arg0, %0 : vector<2xi8> + llvm.call @usevec(%1) : (vector<2xi8>) -> () + %2 = llvm.trunc %1 : vector<2xi8> to vector<2xi4> + %3 = llvm.sext %2 : vector<2xi4> to vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @t4_vec_nonsplat(%arg0: vector<2xi8>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[4, 3]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.ashr %arg0, %0 : vector<2xi8> + llvm.call @usevec(%1) : (vector<2xi8>) -> () + %2 = llvm.trunc %1 : vector<2xi8> to vector<2xi4> + %3 = llvm.sext %2 : vector<2xi4> to vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @t5_extrause(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.ashr %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.trunc %1 : i8 to i4 + llvm.call @use4(%2) : (i4) -> () + %3 = llvm.sext %2 : i4 to i16 + llvm.return %3 : i16 + } + llvm.func @narrow_source_matching_signbits(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %1, %2 overflow : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.sext %4 : i8 to i64 + llvm.return %5 : i64 + } + llvm.func @narrow_source_not_matching_signbits(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %1, %2 overflow : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.sext %4 : i8 to i64 + llvm.return %5 : i64 + } + llvm.func @wide_source_matching_signbits(%arg0: i32) -> i24 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %1, %2 overflow : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.sext %4 : i8 to i24 + llvm.return %5 : i24 + } + llvm.func @wide_source_not_matching_signbits(%arg0: i32) -> i24 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %1, %2 overflow : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.sext %4 : i8 to i24 + llvm.return %5 : i24 + } + llvm.func @same_source_matching_signbits(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %1, %2 overflow : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.sext %4 : i8 to i32 + llvm.return %5 : i32 + } + llvm.func @same_source_not_matching_signbits(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %1, %2 overflow : i32 + %4 = llvm.trunc %3 : i32 to i8 + %5 = llvm.sext %4 : i8 to i32 + llvm.return %5 : i32 + } + llvm.func @same_source_matching_signbits_extra_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %1, %2 overflow : i32 + %4 = llvm.trunc %3 : i32 to i8 + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.sext %4 : i8 to i32 + llvm.return %5 : i32 + } + llvm.func @same_source_not_matching_signbits_extra_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.shl %1, %2 overflow : i32 + %4 = llvm.trunc %3 : i32 to i8 + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.sext %4 : i8 to i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sext.ll.mlir b/test/LLVMDialect/InstCombine/sext.ll.mlir new file mode 100644 index 000000000..87deaef1d --- /dev/null +++ b/test/LLVMDialect/InstCombine/sext.ll.mlir @@ -0,0 +1,253 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @use_vec(vector<2xi5>) + llvm.func @test1(%arg0: i32) -> i64 { + %0 = llvm.intr.ctpop(%arg0) : (i32) -> i32 + %1 = llvm.sext %0 : i32 to i64 + llvm.return %1 : i64 + } + llvm.func @test2(%arg0: i32) -> i64 { + %0 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %1 = llvm.sext %0 : i32 to i64 + llvm.return %1 : i64 + } + llvm.func @test3(%arg0: i32) -> i64 { + %0 = "llvm.intr.cttz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %1 = llvm.sext %0 : i32 to i64 + llvm.return %1 : i64 + } + llvm.func @test4(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.udiv %arg0, %0 : i32 + %2 = llvm.sext %1 : i32 to i64 + llvm.return %2 : i64 + } + llvm.func @test5(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(30000 : i32) : i32 + %1 = llvm.urem %arg0, %0 : i32 + %2 = llvm.sext %1 : i32 to i64 + llvm.return %2 : i64 + } + llvm.func @test6(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.lshr %arg0, %0 : i32 + %2 = llvm.mul %1, %0 : i32 + %3 = llvm.sext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @test7(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(511 : i32) : i32 + %1 = llvm.mlir.constant(20000 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.sub %1, %2 : i32 + %4 = llvm.sext %3 : i32 to i64 + llvm.return %4 : i64 + } + llvm.func @test8(%arg0: i8, %arg1: i32, %arg2: i1, %arg3: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg1, %0 : i32 + %3 = llvm.select %arg2, %2, %1 : i1, i32 + %4 = llvm.trunc %3 : i32 to i16 + %5 = llvm.sext %4 : i16 to i32 + llvm.return %5 : i32 + } + llvm.func @test9(%arg0: i16, %arg1: i1) -> i16 { + %0 = llvm.mlir.constant(42 : i32) : i32 + llvm.cond_br %arg1, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %1 = llvm.sext %arg0 : i16 to i32 + llvm.br ^bb2(%1 : i32) + ^bb2(%2: i32): // 2 preds: ^bb0, ^bb1 + %3 = llvm.trunc %2 : i32 to i16 + llvm.return %3 : i16 + } + llvm.func @test10(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.trunc %arg0 : i32 to i8 + %2 = llvm.shl %1, %0 : i8 + %3 = llvm.ashr %2, %0 : i8 + %4 = llvm.sext %3 : i8 to i32 + llvm.return %4 : i32 + } + llvm.func @test10_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %1 = llvm.trunc %arg0 : vector<2xi32> to vector<2xi8> + %2 = llvm.shl %1, %0 : vector<2xi8> + %3 = llvm.ashr %2, %0 : vector<2xi8> + %4 = llvm.sext %3 : vector<2xi8> to vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test10_vec_nonuniform(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[6, 3]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.trunc %arg0 : vector<2xi32> to vector<2xi8> + %2 = llvm.shl %1, %0 : vector<2xi8> + %3 = llvm.ashr %2, %0 : vector<2xi8> + %4 = llvm.sext %3 : vector<2xi8> to vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test10_vec_poison0(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[6, 0]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.constant(6 : i8) : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.trunc %arg0 : vector<2xi32> to vector<2xi8> + %9 = llvm.shl %8, %0 : vector<2xi8> + %10 = llvm.ashr %9, %7 : vector<2xi8> + %11 = llvm.sext %10 : vector<2xi8> to vector<2xi32> + llvm.return %11 : vector<2xi32> + } + llvm.func @test10_vec_poison1(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(dense<[6, 0]> : vector<2xi8>) : vector<2xi8> + %8 = llvm.trunc %arg0 : vector<2xi32> to vector<2xi8> + %9 = llvm.shl %8, %6 : vector<2xi8> + %10 = llvm.ashr %9, %7 : vector<2xi8> + %11 = llvm.sext %10 : vector<2xi8> to vector<2xi32> + llvm.return %11 : vector<2xi32> + } + llvm.func @test10_vec_poison2(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.trunc %arg0 : vector<2xi32> to vector<2xi8> + %8 = llvm.shl %7, %6 : vector<2xi8> + %9 = llvm.ashr %8, %6 : vector<2xi8> + %10 = llvm.sext %9 : vector<2xi8> to vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @test11(%arg0: vector<2xi16>, %arg1: vector<2xi16>, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(dense<15> : vector<2xi16>) : vector<2xi16> + %1 = llvm.icmp "eq" %arg1, %arg0 : vector<2xi16> + %2 = llvm.sext %1 : vector<2xi1> to vector<2xi16> + %3 = llvm.ashr %2, %0 : vector<2xi16> + llvm.store %3, %arg2 {alignment = 4 : i64} : vector<2xi16>, !llvm.ptr + llvm.return + } + llvm.func @test12(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.sub %1, %2 overflow : i32 + %4 = llvm.sext %3 : i32 to i64 + llvm.return %4 : i64 + } + llvm.func @test13(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.sext %3 : i1 to i32 + llvm.return %4 : i32 + } + llvm.func @test14(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(16 : i16) : i16 + %1 = llvm.and %arg0, %0 : i16 + %2 = llvm.icmp "ne" %1, %0 : i16 + %3 = llvm.sext %2 : i1 to i32 + llvm.return %3 : i32 + } + llvm.func @test15(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + %4 = llvm.sext %3 : i1 to i32 + llvm.return %4 : i32 + } + llvm.func @test16(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.and %arg0, %0 : i16 + %2 = llvm.icmp "eq" %1, %0 : i16 + %3 = llvm.sext %2 : i1 to i32 + llvm.return %3 : i32 + } + llvm.func @test17(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i1 to i32 + %2 = llvm.sub %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test18(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.icmp "slt" %arg0, %0 : i16 + %2 = llvm.select %1, %0, %arg0 : i1, i16 + %3 = llvm.sext %2 : i16 to i32 + llvm.return %3 : i32 + } + llvm.func @test19(%arg0: i10) -> i10 { + %0 = llvm.mlir.constant(2 : i3) : i3 + %1 = llvm.trunc %arg0 : i10 to i3 + %2 = llvm.shl %1, %0 : i3 + %3 = llvm.ashr %2, %0 : i3 + %4 = llvm.sext %3 : i3 to i10 + llvm.return %4 : i10 + } + llvm.func @smear_set_bit(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.trunc %arg0 : i32 to i8 + %2 = llvm.ashr %1, %0 : i8 + %3 = llvm.sext %2 : i8 to i32 + llvm.return %3 : i32 + } + llvm.func @smear_set_bit_vec_use1(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(4 : i5) : i5 + %1 = llvm.mlir.constant(dense<4> : vector<2xi5>) : vector<2xi5> + %2 = llvm.trunc %arg0 : vector<2xi32> to vector<2xi5> + llvm.call @use_vec(%2) : (vector<2xi5>) -> () + %3 = llvm.ashr %2, %1 : vector<2xi5> + %4 = llvm.sext %3 : vector<2xi5> to vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @smear_set_bit_use2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.trunc %arg0 : i32 to i8 + %2 = llvm.ashr %1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.sext %2 : i8 to i32 + llvm.return %3 : i32 + } + llvm.func @smear_set_bit_wrong_shift_amount(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.trunc %arg0 : i32 to i8 + %2 = llvm.ashr %1, %0 : i8 + %3 = llvm.sext %2 : i8 to i32 + llvm.return %3 : i32 + } + llvm.func @smear_set_bit_different_dest_type(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.trunc %arg0 : i32 to i8 + %2 = llvm.ashr %1, %0 : i8 + %3 = llvm.sext %2 : i8 to i16 + llvm.return %3 : i16 + } + llvm.func @smear_set_bit_different_dest_type_extra_use(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.trunc %arg0 : i32 to i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.ashr %1, %0 : i8 + %3 = llvm.sext %2 : i8 to i16 + llvm.return %3 : i16 + } + llvm.func @smear_set_bit_different_dest_type_wider_dst(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.trunc %arg0 : i32 to i8 + %2 = llvm.ashr %1, %0 : i8 + %3 = llvm.sext %2 : i8 to i64 + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/shift-add-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/shift-add-inseltpoison.ll.mlir new file mode 100644 index 000000000..2733931f7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shift-add-inseltpoison.ll.mlir @@ -0,0 +1,90 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @shl_C1_add_A_C2_i32(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.zext %arg0 : i16 to i32 + %3 = llvm.add %2, %0 : i32 + %4 = llvm.shl %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @ashr_C1_add_A_C2_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(6 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.ashr %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @lshr_C1_add_A_C2_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(6 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.shl %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @shl_C1_add_A_C2_v4i32(%arg0: vector<4xi16>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[0, 1, 50, 16]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[6, 2, 1, -7]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.zext %arg0 : vector<4xi16> to vector<4xi32> + %3 = llvm.add %2, %0 : vector<4xi32> + %4 = llvm.shl %1, %3 : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @ashr_C1_add_A_C2_v4i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[0, 15, 255, 65535]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[0, 1, 50, 16]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<[6, 2, 1, -7]> : vector<4xi32>) : vector<4xi32> + %3 = llvm.and %arg0, %0 : vector<4xi32> + %4 = llvm.add %3, %1 : vector<4xi32> + %5 = llvm.ashr %2, %4 : vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @lshr_C1_add_A_C2_v4i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[0, 15, 255, 65535]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[0, 1, 50, 16]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<[6, 2, 1, -7]> : vector<4xi32>) : vector<4xi32> + %3 = llvm.and %arg0, %0 : vector<4xi32> + %4 = llvm.add %3, %1 : vector<4xi32> + %5 = llvm.lshr %2, %4 : vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @shl_C1_add_A_C2_v4i32_splat(%arg0: i16) -> vector<4xi32> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1, 50, 16]> : vector<4xi32>) : vector<4xi32> + %3 = llvm.mlir.constant(dense<[6, 2, 1, -7]> : vector<4xi32>) : vector<4xi32> + %4 = llvm.zext %arg0 : i16 to i32 + %5 = llvm.insertelement %4, %0[%1 : i32] : vector<4xi32> + %6 = llvm.shufflevector %5, %0 [0, 0, 0, 0] : vector<4xi32> + %7 = llvm.add %6, %2 : vector<4xi32> + %8 = llvm.shl %3, %7 : vector<4xi32> + llvm.return %8 : vector<4xi32> + } + llvm.func @ashr_C1_add_A_C2_v4i32_splat(%arg0: i16) -> vector<4xi32> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1, 50, 16]> : vector<4xi32>) : vector<4xi32> + %3 = llvm.mlir.constant(dense<[6, 2, 1, -7]> : vector<4xi32>) : vector<4xi32> + %4 = llvm.zext %arg0 : i16 to i32 + %5 = llvm.insertelement %4, %0[%1 : i32] : vector<4xi32> + %6 = llvm.shufflevector %5, %0 [0, 0, 0, 0] : vector<4xi32> + %7 = llvm.add %6, %2 : vector<4xi32> + %8 = llvm.ashr %3, %7 : vector<4xi32> + llvm.return %8 : vector<4xi32> + } + llvm.func @lshr_C1_add_A_C2_v4i32_splat(%arg0: i16) -> vector<4xi32> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1, 50, 16]> : vector<4xi32>) : vector<4xi32> + %3 = llvm.mlir.constant(dense<[6, 2, 1, -7]> : vector<4xi32>) : vector<4xi32> + %4 = llvm.zext %arg0 : i16 to i32 + %5 = llvm.insertelement %4, %0[%1 : i32] : vector<4xi32> + %6 = llvm.shufflevector %5, %0 [0, 0, 0, 0] : vector<4xi32> + %7 = llvm.add %6, %2 : vector<4xi32> + %8 = llvm.lshr %3, %7 : vector<4xi32> + llvm.return %8 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/shift-add.ll.mlir b/test/LLVMDialect/InstCombine/shift-add.ll.mlir new file mode 100644 index 000000000..56c7aa6a3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shift-add.ll.mlir @@ -0,0 +1,511 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @shl_C1_add_A_C2_i32(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.zext %arg0 : i16 to i32 + %3 = llvm.add %2, %0 : i32 + %4 = llvm.shl %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @ashr_C1_add_A_C2_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(6 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.ashr %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @lshr_C1_add_A_C2_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(6 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.shl %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @shl_C1_add_A_C2_v4i32(%arg0: vector<4xi16>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[0, 1, 50, 16]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[6, 2, 1, -7]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.zext %arg0 : vector<4xi16> to vector<4xi32> + %3 = llvm.add %2, %0 : vector<4xi32> + %4 = llvm.shl %1, %3 : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @ashr_C1_add_A_C2_v4i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[0, 15, 255, 65535]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[0, 1, 50, 16]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<[6, 2, 1, -7]> : vector<4xi32>) : vector<4xi32> + %3 = llvm.and %arg0, %0 : vector<4xi32> + %4 = llvm.add %3, %1 : vector<4xi32> + %5 = llvm.ashr %2, %4 : vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @lshr_C1_add_A_C2_v4i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[0, 15, 255, 65535]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[0, 1, 50, 16]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<[6, 2, 1, -7]> : vector<4xi32>) : vector<4xi32> + %3 = llvm.and %arg0, %0 : vector<4xi32> + %4 = llvm.add %3, %1 : vector<4xi32> + %5 = llvm.lshr %2, %4 : vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @shl_C1_add_A_C2_v4i32_splat(%arg0: i16) -> vector<4xi32> { + %0 = llvm.mlir.undef : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1, 50, 16]> : vector<4xi32>) : vector<4xi32> + %3 = llvm.mlir.constant(dense<[6, 2, 1, -7]> : vector<4xi32>) : vector<4xi32> + %4 = llvm.zext %arg0 : i16 to i32 + %5 = llvm.insertelement %4, %0[%1 : i32] : vector<4xi32> + %6 = llvm.shufflevector %5, %0 [0, 0, 0, 0] : vector<4xi32> + %7 = llvm.add %6, %2 : vector<4xi32> + %8 = llvm.shl %3, %7 : vector<4xi32> + llvm.return %8 : vector<4xi32> + } + llvm.func @ashr_C1_add_A_C2_v4i32_splat(%arg0: i16) -> vector<4xi32> { + %0 = llvm.mlir.undef : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1, 50, 16]> : vector<4xi32>) : vector<4xi32> + %3 = llvm.mlir.constant(dense<[6, 2, 1, -7]> : vector<4xi32>) : vector<4xi32> + %4 = llvm.zext %arg0 : i16 to i32 + %5 = llvm.insertelement %4, %0[%1 : i32] : vector<4xi32> + %6 = llvm.shufflevector %5, %0 [0, 0, 0, 0] : vector<4xi32> + %7 = llvm.add %6, %2 : vector<4xi32> + %8 = llvm.ashr %3, %7 : vector<4xi32> + llvm.return %8 : vector<4xi32> + } + llvm.func @lshr_C1_add_A_C2_v4i32_splat(%arg0: i16) -> vector<4xi32> { + %0 = llvm.mlir.undef : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1, 50, 16]> : vector<4xi32>) : vector<4xi32> + %3 = llvm.mlir.constant(dense<[6, 2, 1, -7]> : vector<4xi32>) : vector<4xi32> + %4 = llvm.zext %arg0 : i16 to i32 + %5 = llvm.insertelement %4, %0[%1 : i32] : vector<4xi32> + %6 = llvm.shufflevector %5, %0 [0, 0, 0, 0] : vector<4xi32> + %7 = llvm.add %6, %2 : vector<4xi32> + %8 = llvm.lshr %3, %7 : vector<4xi32> + llvm.return %8 : vector<4xi32> + } + llvm.func @shl_add_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.shl %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_add_nuw(%arg0: vector<2xi12>) -> vector<2xi12> { + %0 = llvm.mlir.constant(1 : i12) : i12 + %1 = llvm.mlir.constant(5 : i12) : i12 + %2 = llvm.mlir.constant(dense<[5, 1]> : vector<2xi12>) : vector<2xi12> + %3 = llvm.mlir.constant(42 : i12) : i12 + %4 = llvm.mlir.constant(6 : i12) : i12 + %5 = llvm.mlir.constant(dense<[6, 42]> : vector<2xi12>) : vector<2xi12> + %6 = llvm.add %arg0, %2 overflow : vector<2xi12> + %7 = llvm.lshr %5, %6 : vector<2xi12> + llvm.return %7 : vector<2xi12> + } + llvm.func @ashr_add_nuw(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(-6 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + llvm.store %2, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.ashr %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nuw_add_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.add %arg0, %0 overflow : i32 + %2 = llvm.shl %0, %1 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @shl_nsw_add_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.shl %1, %2 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_exact_add_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.lshr %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_exact_add_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-4 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.ashr %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_add_nsw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = llvm.shl %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_exact_add_positive_shift_positive(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.lshr %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_exact_add_big_negative_offset(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.lshr %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_exact_add_negative_shift_negative(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.lshr %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_add_negative_shift_no_exact(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.lshr %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_exact_add_negative_shift_positive(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.lshr %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_exact_add_negative_shift_positive_extra_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.lshr %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @lshr_exact_add_negative_shift_positive_vec(%arg0: vector<2xi9>) -> vector<2xi9> { + %0 = llvm.mlir.constant(-7 : i9) : i9 + %1 = llvm.mlir.constant(dense<-7> : vector<2xi9>) : vector<2xi9> + %2 = llvm.mlir.constant(2 : i9) : i9 + %3 = llvm.mlir.constant(dense<2> : vector<2xi9>) : vector<2xi9> + %4 = llvm.add %arg0, %1 : vector<2xi9> + %5 = llvm.lshr %3, %4 : vector<2xi9> + llvm.return %5 : vector<2xi9> + } + llvm.func @lshr_exact_add_negative_shift_lzcnt(%arg0: vector<2xi9>) -> vector<2xi9> { + %0 = llvm.mlir.constant(-7 : i9) : i9 + %1 = llvm.mlir.constant(dense<-7> : vector<2xi9>) : vector<2xi9> + %2 = llvm.mlir.constant(4 : i9) : i9 + %3 = llvm.mlir.constant(dense<4> : vector<2xi9>) : vector<2xi9> + %4 = llvm.add %arg0, %1 : vector<2xi9> + %5 = llvm.lshr %3, %4 : vector<2xi9> + llvm.return %5 : vector<2xi9> + } + llvm.func @ashr_exact_add_negative_shift_no_trailing_zeros(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-4 : i8) : i8 + %1 = llvm.mlir.constant(-112 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.ashr %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @ashr_exact_add_big_negative_offset(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.ashr %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_add_negative_shift_no_exact(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.ashr %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_exact_add_negative_shift_negative(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.ashr %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_exact_add_negative_shift_negative_extra_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(-32 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.ashr %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @ashr_exact_add_negative_shift_negative_vec(%arg0: vector<2xi7>) -> vector<2xi7> { + %0 = llvm.mlir.constant(-5 : i7) : i7 + %1 = llvm.mlir.constant(dense<-5> : vector<2xi7>) : vector<2xi7> + %2 = llvm.mlir.constant(-2 : i7) : i7 + %3 = llvm.mlir.constant(dense<-2> : vector<2xi7>) : vector<2xi7> + %4 = llvm.add %arg0, %1 : vector<2xi7> + %5 = llvm.ashr %3, %4 : vector<2xi7> + llvm.return %5 : vector<2xi7> + } + llvm.func @ashr_exact_add_negative_leading_ones_vec(%arg0: vector<2xi7>) -> vector<2xi7> { + %0 = llvm.mlir.constant(-5 : i7) : i7 + %1 = llvm.mlir.constant(dense<-5> : vector<2xi7>) : vector<2xi7> + %2 = llvm.mlir.constant(-4 : i7) : i7 + %3 = llvm.mlir.constant(dense<-4> : vector<2xi7>) : vector<2xi7> + %4 = llvm.add %arg0, %1 : vector<2xi7> + %5 = llvm.ashr %3, %4 : vector<2xi7> + llvm.return %5 : vector<2xi7> + } + llvm.func @shl_nsw_add_negative(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.shl %1, %2 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nuw_add_negative_splat_uses(%arg0: vector<2xi8>, %arg1: !llvm.ptr) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-2> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<12> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 : vector<2xi8> + llvm.store %2, %arg1 {alignment = 2 : i64} : vector<2xi8>, !llvm.ptr + %3 = llvm.shl %1, %2 overflow : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @shl_nsw_add_negative_invalid_constant(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.shl %1, %2 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nsw_add_positive_invalid_constant(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.shl %1, %2 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nsw_add_negative_invalid_constant2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.shl %1, %2 overflow : i32 + llvm.return %3 : i32 + } + llvm.func @shl_nsw_add_negative_invalid_constant3(%arg0: i4) -> i4 { + %0 = llvm.mlir.constant(-8 : i4) : i4 + %1 = llvm.mlir.constant(2 : i4) : i4 + %2 = llvm.add %arg0, %0 : i4 + %3 = llvm.shl %1, %2 overflow : i4 + llvm.return %3 : i4 + } + llvm.func @lshr_2_add_zext_basic(%arg0: i1, %arg1: i1) -> i2 { + %0 = llvm.mlir.constant(1 : i2) : i2 + %1 = llvm.zext %arg0 : i1 to i2 + %2 = llvm.zext %arg1 : i1 to i2 + %3 = llvm.add %1, %2 : i2 + %4 = llvm.lshr %3, %0 : i2 + llvm.return %4 : i2 + } + llvm.func @ashr_2_add_zext_basic(%arg0: i1, %arg1: i1) -> i2 { + %0 = llvm.mlir.constant(1 : i2) : i2 + %1 = llvm.zext %arg0 : i1 to i2 + %2 = llvm.zext %arg1 : i1 to i2 + %3 = llvm.add %1, %2 : i2 + %4 = llvm.ashr %3, %0 : i2 + llvm.return %4 : i2 + } + llvm.func @lshr_16_add_zext_basic(%arg0: i16, %arg1: i16) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.zext %arg1 : i16 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.lshr %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @lshr_16_add_zext_basic_multiuse(%arg0: i16, %arg1: i16) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.zext %arg1 : i16 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.lshr %3, %0 : i32 + %5 = llvm.or %4, %1 : i32 + llvm.return %5 : i32 + } + llvm.func @lshr_16_add_known_16_leading_zeroes(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %0 : i32 + %4 = llvm.add %2, %3 : i32 + %5 = llvm.lshr %4, %1 : i32 + llvm.return %5 : i32 + } + llvm.func @lshr_16_add_not_known_16_leading_zeroes(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(131071 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.mlir.constant(16 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.and %arg1, %1 : i32 + %5 = llvm.add %3, %4 : i32 + %6 = llvm.lshr %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @lshr_32_add_zext_basic(%arg0: i32, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.zext %arg0 : i32 to i64 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.add %1, %2 : i64 + %4 = llvm.lshr %3, %0 : i64 + llvm.return %4 : i64 + } + llvm.func @lshr_32_add_zext_basic_multiuse(%arg0: i32, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.zext %arg0 : i32 to i64 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.add %1, %2 : i64 + %4 = llvm.lshr %3, %0 : i64 + %5 = llvm.or %4, %2 : i64 + llvm.return %5 : i64 + } + llvm.func @lshr_31_i32_add_zext_basic(%arg0: i32, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(31 : i64) : i64 + %1 = llvm.zext %arg0 : i32 to i64 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.add %1, %2 : i64 + %4 = llvm.lshr %3, %0 : i64 + llvm.return %4 : i64 + } + llvm.func @lshr_33_i32_add_zext_basic(%arg0: i32, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(33 : i64) : i64 + %1 = llvm.zext %arg0 : i32 to i64 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.add %1, %2 : i64 + %4 = llvm.lshr %3, %0 : i64 + llvm.return %4 : i64 + } + llvm.func @lshr_16_to_64_add_zext_basic(%arg0: i16, %arg1: i16) -> i64 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.zext %arg0 : i16 to i64 + %2 = llvm.zext %arg1 : i16 to i64 + %3 = llvm.add %1, %2 : i64 + %4 = llvm.lshr %3, %0 : i64 + llvm.return %4 : i64 + } + llvm.func @lshr_32_add_known_32_leading_zeroes(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(4294967295 : i64) : i64 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.and %arg1, %0 : i64 + %4 = llvm.add %2, %3 : i64 + %5 = llvm.lshr %4, %1 : i64 + llvm.return %5 : i64 + } + llvm.func @lshr_32_add_not_known_32_leading_zeroes(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(8589934591 : i64) : i64 + %1 = llvm.mlir.constant(4294967295 : i64) : i64 + %2 = llvm.mlir.constant(32 : i64) : i64 + %3 = llvm.and %arg0, %0 : i64 + %4 = llvm.and %arg1, %1 : i64 + %5 = llvm.add %3, %4 : i64 + %6 = llvm.lshr %5, %2 : i64 + llvm.return %6 : i64 + } + llvm.func @ashr_16_add_zext_basic(%arg0: i16, %arg1: i16) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.zext %arg1 : i16 to i32 + %3 = llvm.add %1, %2 : i32 + %4 = llvm.lshr %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @ashr_32_add_zext_basic(%arg0: i32, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.zext %arg0 : i32 to i64 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.add %1, %2 : i64 + %4 = llvm.ashr %3, %0 : i64 + llvm.return %4 : i64 + } + llvm.func @ashr_16_to_64_add_zext_basic(%arg0: i16, %arg1: i16) -> i64 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.zext %arg0 : i16 to i64 + %2 = llvm.zext %arg1 : i16 to i64 + %3 = llvm.add %1, %2 : i64 + %4 = llvm.ashr %3, %0 : i64 + llvm.return %4 : i64 + } + llvm.func @lshr_32_add_zext_trunc(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.zext %arg0 : i32 to i64 + %2 = llvm.zext %arg1 : i32 to i64 + %3 = llvm.add %1, %2 : i64 + %4 = llvm.trunc %3 : i64 to i32 + %5 = llvm.lshr %3, %0 : i64 + %6 = llvm.trunc %5 : i64 to i32 + %7 = llvm.add %4, %6 : i32 + llvm.return %7 : i32 + } + llvm.func @add3_i96(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(32 : i64) : i64 + %3 = llvm.mlir.constant(2 : i64) : i64 + %4 = llvm.mlir.undef : vector<3xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.extractelement %arg0[%0 : i64] : vector<3xi32> + %9 = llvm.zext %8 : i32 to i64 + %10 = llvm.extractelement %arg1[%0 : i64] : vector<3xi32> + %11 = llvm.zext %10 : i32 to i64 + %12 = llvm.add %11, %9 overflow : i64 + %13 = llvm.extractelement %arg0[%1 : i64] : vector<3xi32> + %14 = llvm.zext %13 : i32 to i64 + %15 = llvm.extractelement %arg1[%1 : i64] : vector<3xi32> + %16 = llvm.zext %15 : i32 to i64 + %17 = llvm.add %16, %14 overflow : i64 + %18 = llvm.lshr %12, %2 : i64 + %19 = llvm.add %17, %18 overflow : i64 + %20 = llvm.extractelement %arg0[%3 : i64] : vector<3xi32> + %21 = llvm.extractelement %arg1[%3 : i64] : vector<3xi32> + %22 = llvm.add %21, %20 : i32 + %23 = llvm.lshr %19, %2 : i64 + %24 = llvm.trunc %23 : i64 to i32 + %25 = llvm.add %22, %24 : i32 + %26 = llvm.trunc %12 : i64 to i32 + %27 = llvm.insertelement %26, %4[%5 : i32] : vector<3xi32> + %28 = llvm.trunc %19 : i64 to i32 + %29 = llvm.insertelement %28, %27[%6 : i32] : vector<3xi32> + %30 = llvm.insertelement %25, %29[%7 : i32] : vector<3xi32> + llvm.return %30 : vector<3xi32> + } + llvm.func @shl_fold_or_disjoint_cnt(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.shl %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @ashr_fold_or_disjoint_cnt(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[3, 1]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[2, 3]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.or %arg0, %0 : vector<2xi8> + %3 = llvm.ashr %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @lshr_fold_or_disjoint_cnt_out_of_bounds(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[3, 8]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[2, 3]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.or %arg0, %0 : vector<2xi8> + %3 = llvm.lshr %1, %2 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/shift-amount-reassociation-in-bittest-with-truncation-lshr.ll.mlir b/test/LLVMDialect/InstCombine/shift-amount-reassociation-in-bittest-with-truncation-lshr.ll.mlir new file mode 100644 index 000000000..f87ad476b --- /dev/null +++ b/test/LLVMDialect/InstCombine/shift-amount-reassociation-in-bittest-with-truncation-lshr.ll.mlir @@ -0,0 +1,333 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @n0(%arg0: i32, %arg1: i64, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-16 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + %4 = llvm.shl %arg0, %3 : i32 + %5 = llvm.add %arg2, %1 : i32 + %6 = llvm.zext %5 : i32 to i64 + %7 = llvm.lshr %arg1, %6 : i64 + %8 = llvm.trunc %7 : i64 to i32 + %9 = llvm.and %4, %8 : i32 + %10 = llvm.icmp "ne" %9, %2 : i32 + llvm.return %10 : i1 + } + llvm.func @t1(%arg0: i64, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(65535 : i32) : i32 + %2 = llvm.mlir.constant(-16 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.shl %1, %4 : i32 + %6 = llvm.add %arg1, %2 : i32 + %7 = llvm.zext %6 : i32 to i64 + %8 = llvm.lshr %arg0, %7 : i64 + %9 = llvm.trunc %8 : i64 to i32 + %10 = llvm.and %5, %9 : i32 + %11 = llvm.icmp "ne" %10, %3 : i32 + llvm.return %11 : i1 + } + llvm.func @t1_single_bit(%arg0: i64, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(32768 : i32) : i32 + %2 = llvm.mlir.constant(-16 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.shl %1, %4 : i32 + %6 = llvm.add %arg1, %2 : i32 + %7 = llvm.zext %6 : i32 to i64 + %8 = llvm.lshr %arg0, %7 : i64 + %9 = llvm.trunc %8 : i64 to i32 + %10 = llvm.and %5, %9 : i32 + %11 = llvm.icmp "ne" %10, %3 : i32 + llvm.return %11 : i1 + } + llvm.func @n2(%arg0: i64, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(131071 : i32) : i32 + %2 = llvm.mlir.constant(-16 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.shl %1, %4 : i32 + %6 = llvm.add %arg1, %2 : i32 + %7 = llvm.zext %6 : i32 to i64 + %8 = llvm.lshr %arg0, %7 : i64 + %9 = llvm.trunc %8 : i64 to i32 + %10 = llvm.and %5, %9 : i32 + %11 = llvm.icmp "ne" %10, %3 : i32 + llvm.return %11 : i1 + } + llvm.func @t3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-16 : i32) : i32 + %2 = llvm.mlir.constant(131071 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.shl %arg0, %4 : i32 + %6 = llvm.add %arg1, %1 : i32 + %7 = llvm.zext %6 : i32 to i64 + %8 = llvm.lshr %2, %7 : i64 + %9 = llvm.trunc %8 : i64 to i32 + %10 = llvm.and %5, %9 : i32 + %11 = llvm.icmp "ne" %10, %3 : i32 + llvm.return %11 : i1 + } + llvm.func @t3_singlebit(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-16 : i32) : i32 + %2 = llvm.mlir.constant(65536 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.shl %arg0, %4 : i32 + %6 = llvm.add %arg1, %1 : i32 + %7 = llvm.zext %6 : i32 to i64 + %8 = llvm.lshr %2, %7 : i64 + %9 = llvm.trunc %8 : i64 to i32 + %10 = llvm.and %5, %9 : i32 + %11 = llvm.icmp "ne" %10, %3 : i32 + llvm.return %11 : i1 + } + llvm.func @n4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-16 : i32) : i32 + %2 = llvm.mlir.constant(262143 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.shl %arg0, %4 : i32 + %6 = llvm.add %arg1, %1 : i32 + %7 = llvm.zext %6 : i32 to i64 + %8 = llvm.lshr %2, %7 : i64 + %9 = llvm.trunc %8 : i64 to i32 + %10 = llvm.and %5, %9 : i32 + %11 = llvm.icmp "ne" %10, %3 : i32 + llvm.return %11 : i1 + } + llvm.func @t5_vec(%arg0: vector<2xi64>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[65535, 32767]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-16> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %5 = llvm.sub %0, %arg1 : vector<2xi32> + %6 = llvm.shl %1, %5 : vector<2xi32> + %7 = llvm.add %arg1, %2 : vector<2xi32> + %8 = llvm.zext %7 : vector<2xi32> to vector<2xi64> + %9 = llvm.lshr %arg0, %8 : vector<2xi64> + %10 = llvm.trunc %9 : vector<2xi64> to vector<2xi32> + %11 = llvm.and %6, %10 : vector<2xi32> + %12 = llvm.icmp "ne" %11, %4 : vector<2xi32> + llvm.return %12 : vector<2xi1> + } + llvm.func @n6_vec(%arg0: vector<2xi64>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[65535, 131071]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-16> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %5 = llvm.sub %0, %arg1 : vector<2xi32> + %6 = llvm.shl %1, %5 : vector<2xi32> + %7 = llvm.add %arg1, %2 : vector<2xi32> + %8 = llvm.zext %7 : vector<2xi32> to vector<2xi64> + %9 = llvm.lshr %arg0, %8 : vector<2xi64> + %10 = llvm.trunc %9 : vector<2xi64> to vector<2xi32> + %11 = llvm.and %6, %10 : vector<2xi32> + %12 = llvm.icmp "ne" %11, %4 : vector<2xi32> + llvm.return %12 : vector<2xi1> + } + llvm.func @t7_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-16> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[131071, 65535]> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %5 = llvm.sub %0, %arg1 : vector<2xi32> + %6 = llvm.shl %arg0, %5 : vector<2xi32> + %7 = llvm.add %arg1, %1 : vector<2xi32> + %8 = llvm.zext %7 : vector<2xi32> to vector<2xi64> + %9 = llvm.lshr %2, %8 : vector<2xi64> + %10 = llvm.trunc %9 : vector<2xi64> to vector<2xi32> + %11 = llvm.and %6, %10 : vector<2xi32> + %12 = llvm.icmp "ne" %11, %4 : vector<2xi32> + llvm.return %12 : vector<2xi1> + } + llvm.func @n8_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-16> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[131071, 262143]> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %5 = llvm.sub %0, %arg1 : vector<2xi32> + %6 = llvm.shl %arg0, %5 : vector<2xi32> + %7 = llvm.add %arg1, %1 : vector<2xi32> + %8 = llvm.zext %7 : vector<2xi32> to vector<2xi64> + %9 = llvm.lshr %2, %8 : vector<2xi64> + %10 = llvm.trunc %9 : vector<2xi64> to vector<2xi32> + %11 = llvm.and %6, %10 : vector<2xi32> + %12 = llvm.icmp "ne" %11, %4 : vector<2xi32> + llvm.return %12 : vector<2xi1> + } + llvm.func @t9_highest_bit(%arg0: i32, %arg1: i64, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + %4 = llvm.shl %arg0, %3 : i32 + %5 = llvm.add %arg2, %1 : i32 + %6 = llvm.zext %5 : i32 to i64 + %7 = llvm.lshr %arg1, %6 : i64 + %8 = llvm.trunc %7 : i64 to i32 + %9 = llvm.and %4, %8 : i32 + %10 = llvm.icmp "ne" %9, %2 : i32 + llvm.return %10 : i1 + } + llvm.func @t10_almost_highest_bit(%arg0: i32, %arg1: i64, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + %4 = llvm.shl %arg0, %3 : i32 + %5 = llvm.add %arg2, %1 : i32 + %6 = llvm.zext %5 : i32 to i64 + %7 = llvm.lshr %arg1, %6 : i64 + %8 = llvm.trunc %7 : i64 to i32 + %9 = llvm.and %4, %8 : i32 + %10 = llvm.icmp "ne" %9, %2 : i32 + llvm.return %10 : i1 + } + llvm.func @t11_no_shift(%arg0: i32, %arg1: i64, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(-64 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + %4 = llvm.shl %arg0, %3 : i32 + %5 = llvm.add %arg2, %1 : i32 + %6 = llvm.zext %5 : i32 to i64 + %7 = llvm.lshr %arg1, %6 : i64 + %8 = llvm.trunc %7 : i64 to i32 + %9 = llvm.and %4, %8 : i32 + %10 = llvm.icmp "ne" %9, %2 : i32 + llvm.return %10 : i1 + } + llvm.func @t10_shift_by_one(%arg0: i32, %arg1: i64, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(-63 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + %4 = llvm.shl %arg0, %3 : i32 + %5 = llvm.add %arg2, %1 : i32 + %6 = llvm.zext %5 : i32 to i64 + %7 = llvm.lshr %arg1, %6 : i64 + %8 = llvm.trunc %7 : i64 to i32 + %9 = llvm.and %4, %8 : i32 + %10 = llvm.icmp "ne" %9, %2 : i32 + llvm.return %10 : i1 + } + llvm.func @t11_zero_and_almost_bitwidth(%arg0: vector<2xi32>, %arg1: vector<2xi64>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<64> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-1, -64]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.sub %0, %arg2 : vector<2xi32> + %5 = llvm.shl %arg0, %4 : vector<2xi32> + %6 = llvm.add %arg2, %1 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi32> to vector<2xi64> + %8 = llvm.lshr %arg1, %7 : vector<2xi64> + %9 = llvm.trunc %8 : vector<2xi64> to vector<2xi32> + %10 = llvm.and %5, %9 : vector<2xi32> + %11 = llvm.icmp "ne" %10, %3 : vector<2xi32> + llvm.return %11 : vector<2xi1> + } + llvm.func @n12_bad(%arg0: vector<2xi32>, %arg1: vector<2xi64>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<64> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-2, -64]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.sub %0, %arg2 : vector<2xi32> + %5 = llvm.shl %arg0, %4 : vector<2xi32> + %6 = llvm.add %arg2, %1 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi32> to vector<2xi64> + %8 = llvm.lshr %arg1, %7 : vector<2xi64> + %9 = llvm.trunc %8 : vector<2xi64> to vector<2xi32> + %10 = llvm.and %5, %9 : vector<2xi32> + %11 = llvm.icmp "ne" %10, %3 : vector<2xi32> + llvm.return %11 : vector<2xi1> + } + llvm.func @t13_x_is_one(%arg0: i64, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-16 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.shl %1, %4 : i32 + %6 = llvm.add %arg1, %2 : i32 + %7 = llvm.zext %6 : i32 to i64 + %8 = llvm.lshr %arg0, %7 : i64 + %9 = llvm.trunc %8 : i64 to i32 + %10 = llvm.and %5, %9 : i32 + %11 = llvm.icmp "ne" %10, %3 : i32 + llvm.return %11 : i1 + } + llvm.func @t14_x_is_one(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-16 : i32) : i32 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 : i32 + %5 = llvm.shl %arg0, %4 : i32 + %6 = llvm.add %arg1, %1 : i32 + %7 = llvm.zext %6 : i32 to i64 + %8 = llvm.lshr %2, %7 : i64 + %9 = llvm.trunc %8 : i64 to i32 + %10 = llvm.and %5, %9 : i32 + %11 = llvm.icmp "ne" %10, %3 : i32 + llvm.return %11 : i1 + } + llvm.func @t15_vec_x_is_one_or_zero(%arg0: vector<2xi64>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<64> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[1, 0]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-16> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %5 = llvm.sub %0, %arg1 : vector<2xi32> + %6 = llvm.shl %1, %5 : vector<2xi32> + %7 = llvm.add %arg1, %2 : vector<2xi32> + %8 = llvm.zext %7 : vector<2xi32> to vector<2xi64> + %9 = llvm.lshr %arg0, %8 : vector<2xi64> + %10 = llvm.trunc %9 : vector<2xi64> to vector<2xi32> + %11 = llvm.and %6, %10 : vector<2xi32> + %12 = llvm.icmp "ne" %11, %4 : vector<2xi32> + llvm.return %12 : vector<2xi1> + } + llvm.func @t16_vec_y_is_one_or_zero(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<64> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-16> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[1, 0]> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %5 = llvm.sub %0, %arg1 : vector<2xi32> + %6 = llvm.shl %arg0, %5 : vector<2xi32> + %7 = llvm.add %arg1, %1 : vector<2xi32> + %8 = llvm.zext %7 : vector<2xi32> to vector<2xi64> + %9 = llvm.lshr %2, %8 : vector<2xi64> + %10 = llvm.trunc %9 : vector<2xi64> to vector<2xi32> + %11 = llvm.and %6, %10 : vector<2xi32> + %12 = llvm.icmp "ne" %11, %4 : vector<2xi32> + llvm.return %12 : vector<2xi1> + } + llvm.func @rawspeed_signbit(%arg0: i64, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg1 overflow : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.lshr %arg0, %5 : i64 + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.add %arg1, %1 overflow : i32 + %9 = llvm.shl %2, %8 : i32 + %10 = llvm.and %9, %7 : i32 + %11 = llvm.icmp "eq" %10, %3 : i32 + llvm.return %11 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/shift-amount-reassociation-in-bittest-with-truncation-shl.ll.mlir b/test/LLVMDialect/InstCombine/shift-amount-reassociation-in-bittest-with-truncation-shl.ll.mlir new file mode 100644 index 000000000..ee71db763 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shift-amount-reassociation-in-bittest-with-truncation-shl.ll.mlir @@ -0,0 +1,259 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_const_after_fold_lshr_shl_ne(%arg0: i32, %arg1: i64, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.add %arg2, %1 : i32 + %6 = llvm.zext %5 : i32 to i64 + %7 = llvm.shl %arg1, %6 : i64 + %8 = llvm.trunc %7 : i64 to i32 + %9 = llvm.and %4, %8 : i32 + %10 = llvm.icmp "ne" %9, %2 : i32 + llvm.return %10 : i1 + } + llvm.func @t1_vec_splat(%arg0: vector<2xi32>, %arg1: vector<2xi64>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.sub %0, %arg2 : vector<2xi32> + %5 = llvm.lshr %arg0, %4 : vector<2xi32> + %6 = llvm.add %arg2, %1 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi32> to vector<2xi64> + %8 = llvm.shl %arg1, %7 : vector<2xi64> + %9 = llvm.trunc %8 : vector<2xi64> to vector<2xi32> + %10 = llvm.and %5, %9 : vector<2xi32> + %11 = llvm.icmp "ne" %10, %3 : vector<2xi32> + llvm.return %11 : vector<2xi1> + } + llvm.func @t2_vec_nonsplat(%arg0: vector<2xi32>, %arg1: vector<2xi64>, %arg2: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[30, 32]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[1, -2]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.sub %0, %arg2 : vector<2xi32> + %5 = llvm.lshr %arg0, %4 : vector<2xi32> + %6 = llvm.add %arg2, %1 : vector<2xi32> + %7 = llvm.zext %6 : vector<2xi32> to vector<2xi64> + %8 = llvm.shl %arg1, %7 : vector<2xi64> + %9 = llvm.trunc %8 : vector<2xi64> to vector<2xi32> + %10 = llvm.and %5, %9 : vector<2xi32> + %11 = llvm.icmp "ne" %10, %3 : vector<2xi32> + llvm.return %11 : vector<2xi1> + } + llvm.func @gen32() -> i32 + llvm.func @gen64() -> i64 + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @t3_oneuse0(%arg0: i32, %arg1: i64, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.lshr %arg0, %3 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.add %arg2, %1 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.zext %5 : i32 to i64 + llvm.call @use64(%6) : (i64) -> () + %7 = llvm.shl %arg1, %6 : i64 + llvm.call @use64(%7) : (i64) -> () + %8 = llvm.trunc %7 : i64 to i32 + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.and %4, %8 : i32 + llvm.call @use32(%9) : (i32) -> () + %10 = llvm.icmp "ne" %9, %2 : i32 + llvm.return %10 : i1 + } + llvm.func @t4_oneuse1(%arg0: i32, %arg1: i64, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.lshr %arg0, %3 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.add %arg2, %1 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.zext %5 : i32 to i64 + llvm.call @use64(%6) : (i64) -> () + %7 = llvm.shl %arg1, %6 : i64 + llvm.call @use64(%7) : (i64) -> () + %8 = llvm.trunc %7 : i64 to i32 + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.and %4, %8 : i32 + %10 = llvm.icmp "ne" %9, %2 : i32 + llvm.return %10 : i1 + } + llvm.func @t5_oneuse2(%arg0: i32, %arg1: i64, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.add %arg2, %1 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.zext %5 : i32 to i64 + llvm.call @use64(%6) : (i64) -> () + %7 = llvm.shl %arg1, %6 : i64 + llvm.call @use64(%7) : (i64) -> () + %8 = llvm.trunc %7 : i64 to i32 + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.and %4, %8 : i32 + %10 = llvm.icmp "ne" %9, %2 : i32 + llvm.return %10 : i1 + } + llvm.func @t6_oneuse3(%arg0: i32, %arg1: i64, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.add %arg2, %1 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.zext %5 : i32 to i64 + llvm.call @use64(%6) : (i64) -> () + %7 = llvm.shl %arg1, %6 : i64 + llvm.call @use64(%7) : (i64) -> () + %8 = llvm.trunc %7 : i64 to i32 + %9 = llvm.and %4, %8 : i32 + %10 = llvm.icmp "ne" %9, %2 : i32 + llvm.return %10 : i1 + } + llvm.func @t7_oneuse4(%arg0: i32, %arg1: i64, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.add %arg2, %1 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.zext %5 : i32 to i64 + llvm.call @use64(%6) : (i64) -> () + %7 = llvm.shl %arg1, %6 : i64 + llvm.call @use64(%7) : (i64) -> () + %8 = llvm.trunc %7 : i64 to i32 + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.and %4, %8 : i32 + %10 = llvm.icmp "ne" %9, %2 : i32 + llvm.return %10 : i1 + } + llvm.func @t8_oneuse5(%arg0: i32, %arg1: i64, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-52543054 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg2 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.lshr %1, %4 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.add %arg2, %2 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.zext %6 : i32 to i64 + llvm.call @use64(%7) : (i64) -> () + %8 = llvm.shl %arg1, %7 : i64 + llvm.call @use64(%8) : (i64) -> () + %9 = llvm.trunc %8 : i64 to i32 + llvm.call @use32(%9) : (i32) -> () + %10 = llvm.and %5, %9 : i32 + %11 = llvm.icmp "ne" %10, %3 : i32 + llvm.return %11 : i1 + } + llvm.func @t9_oneuse5(%arg0: i32, %arg1: i64, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(4242424242 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg2 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.lshr %arg0, %4 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.add %arg2, %1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.zext %6 : i32 to i64 + llvm.call @use64(%7) : (i64) -> () + %8 = llvm.shl %2, %7 : i64 + llvm.call @use64(%8) : (i64) -> () + %9 = llvm.trunc %8 : i64 to i32 + llvm.call @use32(%9) : (i32) -> () + %10 = llvm.and %5, %9 : i32 + %11 = llvm.icmp "ne" %10, %3 : i32 + llvm.return %11 : i1 + } + llvm.func @t10_constants(%arg0: i32, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(14 : i64) : i64 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.shl %arg1, %1 : i64 + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.and %3, %5 : i32 + %7 = llvm.icmp "ne" %6, %2 : i32 + llvm.return %7 : i1 + } + llvm.func @t11_constants_vec_splat(%arg0: vector<2xi32>, %arg1: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<12> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<14> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.lshr %arg0, %0 : vector<2xi32> + %5 = llvm.shl %arg1, %1 : vector<2xi64> + %6 = llvm.trunc %5 : vector<2xi64> to vector<2xi32> + %7 = llvm.and %4, %6 : vector<2xi32> + %8 = llvm.icmp "ne" %7, %3 : vector<2xi32> + llvm.return %8 : vector<2xi1> + } + llvm.func @t12_constants_vec_nonsplat(%arg0: vector<2xi32>, %arg1: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[12, 14]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[16, 14]> : vector<2xi64>) : vector<2xi64> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.lshr %arg0, %0 : vector<2xi32> + %5 = llvm.shl %arg1, %1 : vector<2xi64> + %6 = llvm.trunc %5 : vector<2xi64> to vector<2xi32> + %7 = llvm.and %4, %6 : vector<2xi32> + %8 = llvm.icmp "ne" %7, %3 : vector<2xi32> + llvm.return %8 : vector<2xi1> + } + llvm.func @n13_overshift(%arg0: i32, %arg1: i64, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.sub %0, %arg2 : i32 + %3 = llvm.lshr %arg0, %2 : i32 + %4 = llvm.add %arg2, %0 : i32 + %5 = llvm.zext %4 : i32 to i64 + %6 = llvm.shl %arg1, %5 : i64 + %7 = llvm.trunc %6 : i64 to i32 + %8 = llvm.and %3, %7 : i32 + %9 = llvm.icmp "ne" %8, %1 : i32 + llvm.return %9 : i1 + } + llvm.func @n14_trunc_of_lshr(%arg0: i64, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + %4 = llvm.zext %3 : i32 to i64 + %5 = llvm.lshr %arg0, %4 : i64 + %6 = llvm.trunc %5 : i64 to i32 + %7 = llvm.add %arg2, %1 : i32 + %8 = llvm.shl %arg1, %7 : i32 + %9 = llvm.and %6, %8 : i32 + %10 = llvm.icmp "ne" %9, %2 : i32 + llvm.return %10 : i1 + } + llvm.func @n15_variable_shamts(%arg0: i32, %arg1: i64, %arg2: i32, %arg3: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.lshr %arg0, %arg2 : i32 + %2 = llvm.shl %arg1, %arg3 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "ne" %4, %0 : i32 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/shift-amount-reassociation-in-bittest.ll.mlir b/test/LLVMDialect/InstCombine/shift-amount-reassociation-in-bittest.ll.mlir new file mode 100644 index 000000000..a44da2115 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shift-amount-reassociation-in-bittest.ll.mlir @@ -0,0 +1,516 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal @f.a(0 : i16) {addr_space = 0 : i32, dso_local} : i16 + llvm.func @t0_const_lshr_shl_ne(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.shl %arg1, %0 : i32 + %4 = llvm.and %3, %2 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @t1_const_shl_lshr_ne(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.lshr %arg1, %0 : i32 + %4 = llvm.and %3, %2 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @t2_const_lshr_shl_eq(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.shl %arg1, %0 : i32 + %4 = llvm.and %3, %2 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @t3_const_after_fold_lshr_shl_ne(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.add %arg2, %1 : i32 + %6 = llvm.shl %arg1, %5 : i32 + %7 = llvm.and %4, %6 : i32 + %8 = llvm.icmp "ne" %7, %2 : i32 + llvm.return %8 : i1 + } + llvm.func @t4_const_after_fold_lshr_shl_ne(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg2 : i32 + %4 = llvm.shl %arg0, %3 : i32 + %5 = llvm.add %arg2, %1 : i32 + %6 = llvm.lshr %arg1, %5 : i32 + %7 = llvm.and %4, %6 : i32 + %8 = llvm.icmp "ne" %7, %2 : i32 + llvm.return %8 : i1 + } + llvm.func @t5_const_lshr_shl_ne(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.lshr %arg0, %arg2 : i32 + %2 = llvm.shl %arg1, %arg3 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @t6_const_shl_lshr_ne(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.shl %arg0, %arg2 : i32 + %2 = llvm.lshr %arg1, %arg3 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @t7_const_lshr_shl_ne_vec_splat(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.lshr %arg0, %0 : vector<2xi32> + %4 = llvm.shl %arg1, %0 : vector<2xi32> + %5 = llvm.and %4, %3 : vector<2xi32> + %6 = llvm.icmp "ne" %5, %2 : vector<2xi32> + llvm.return %6 : vector<2xi1> + } + llvm.func @t8_const_lshr_shl_ne_vec_nonsplat(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[3, 4]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.lshr %arg0, %0 : vector<2xi32> + %5 = llvm.shl %arg1, %1 : vector<2xi32> + %6 = llvm.and %5, %4 : vector<2xi32> + %7 = llvm.icmp "ne" %6, %3 : vector<2xi32> + llvm.return %7 : vector<2xi1> + } + llvm.func @t9_const_lshr_shl_ne_vec_poison0(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(dense<1> : vector<3xi32>) : vector<3xi32> + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.mlir.constant(dense<0> : vector<3xi32>) : vector<3xi32> + %12 = llvm.lshr %arg0, %8 : vector<3xi32> + %13 = llvm.shl %arg1, %9 : vector<3xi32> + %14 = llvm.and %13, %12 : vector<3xi32> + %15 = llvm.icmp "ne" %14, %11 : vector<3xi32> + llvm.return %15 : vector<3xi1> + } + llvm.func @t10_const_lshr_shl_ne_vec_poison1(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.undef : vector<3xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi32> + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.mlir.constant(dense<0> : vector<3xi32>) : vector<3xi32> + %12 = llvm.lshr %arg0, %0 : vector<3xi32> + %13 = llvm.shl %arg1, %9 : vector<3xi32> + %14 = llvm.and %13, %12 : vector<3xi32> + %15 = llvm.icmp "ne" %14, %11 : vector<3xi32> + llvm.return %15 : vector<3xi1> + } + llvm.func @t11_const_lshr_shl_ne_vec_poison2(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.undef : vector<3xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi32> + %10 = llvm.lshr %arg0, %0 : vector<3xi32> + %11 = llvm.shl %arg1, %0 : vector<3xi32> + %12 = llvm.and %11, %10 : vector<3xi32> + %13 = llvm.icmp "ne" %12, %9 : vector<3xi32> + llvm.return %13 : vector<3xi1> + } + llvm.func @t12_const_lshr_shl_ne_vec_poison3(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.mlir.constant(dense<0> : vector<3xi32>) : vector<3xi32> + %11 = llvm.lshr %arg0, %8 : vector<3xi32> + %12 = llvm.shl %arg1, %8 : vector<3xi32> + %13 = llvm.and %12, %11 : vector<3xi32> + %14 = llvm.icmp "ne" %13, %10 : vector<3xi32> + llvm.return %14 : vector<3xi1> + } + llvm.func @t13_const_lshr_shl_ne_vec_poison4(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.undef : vector<3xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi32> + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.mlir.undef : vector<3xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.insertelement %10, %11[%12 : i32] : vector<3xi32> + %14 = llvm.mlir.constant(1 : i32) : i32 + %15 = llvm.insertelement %2, %13[%14 : i32] : vector<3xi32> + %16 = llvm.mlir.constant(2 : i32) : i32 + %17 = llvm.insertelement %10, %15[%16 : i32] : vector<3xi32> + %18 = llvm.lshr %arg0, %0 : vector<3xi32> + %19 = llvm.shl %arg1, %9 : vector<3xi32> + %20 = llvm.and %19, %18 : vector<3xi32> + %21 = llvm.icmp "ne" %20, %17 : vector<3xi32> + llvm.return %21 : vector<3xi1> + } + llvm.func @t14_const_lshr_shl_ne_vec_poison5(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(dense<1> : vector<3xi32>) : vector<3xi32> + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.mlir.undef : vector<3xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.insertelement %10, %11[%12 : i32] : vector<3xi32> + %14 = llvm.mlir.constant(1 : i32) : i32 + %15 = llvm.insertelement %1, %13[%14 : i32] : vector<3xi32> + %16 = llvm.mlir.constant(2 : i32) : i32 + %17 = llvm.insertelement %10, %15[%16 : i32] : vector<3xi32> + %18 = llvm.lshr %arg0, %8 : vector<3xi32> + %19 = llvm.shl %arg1, %9 : vector<3xi32> + %20 = llvm.and %19, %18 : vector<3xi32> + %21 = llvm.icmp "ne" %20, %17 : vector<3xi32> + llvm.return %21 : vector<3xi1> + } + llvm.func @t15_const_lshr_shl_ne_vec_poison6(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.lshr %arg0, %8 : vector<3xi32> + %18 = llvm.shl %arg1, %8 : vector<3xi32> + %19 = llvm.and %18, %17 : vector<3xi32> + %20 = llvm.icmp "ne" %19, %16 : vector<3xi32> + llvm.return %20 : vector<3xi1> + } + llvm.func @gen32() -> i32 + llvm.func @t16_commutativity0(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.call @gen32() : () -> i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.shl %2, %0 : i32 + %5 = llvm.and %4, %3 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + llvm.return %6 : i1 + } + llvm.func @t17_commutativity1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.call @gen32() : () -> i32 + %3 = llvm.lshr %2, %0 : i32 + %4 = llvm.shl %arg0, %0 : i32 + %5 = llvm.and %3, %4 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + llvm.return %6 : i1 + } + llvm.func @use32(i32) + llvm.func @t18_const_oneuse0(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %arg1, %0 : i32 + %4 = llvm.and %3, %2 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @t19_const_oneuse1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.shl %arg1, %0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.and %3, %2 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @t20_const_oneuse2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.shl %arg1, %0 : i32 + %4 = llvm.and %3, %2 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.icmp "ne" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @t21_const_oneuse3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %arg1, %0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.and %3, %2 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @t22_const_oneuse4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %arg1, %0 : i32 + %4 = llvm.and %3, %2 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.icmp "ne" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @t23_const_oneuse5(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.shl %arg1, %0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.and %3, %2 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.icmp "ne" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @t24_const_oneuse6(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %arg1, %0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.and %3, %2 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.icmp "ne" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @t25_var_oneuse0(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.lshr %arg0, %arg2 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %arg1, %arg3 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @t26_var_oneuse1(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.lshr %arg0, %arg2 : i32 + %2 = llvm.shl %arg1, %arg3 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.and %2, %1 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @t27_var_oneuse2(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.lshr %arg0, %arg2 : i32 + %2 = llvm.shl %arg1, %arg3 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @t28_var_oneuse3(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.lshr %arg0, %arg2 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %arg1, %arg3 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.and %2, %1 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @t29_var_oneuse4(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.lshr %arg0, %arg2 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %arg1, %arg3 : i32 + %3 = llvm.and %2, %1 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @t30_var_oneuse5(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.lshr %arg0, %arg2 : i32 + %2 = llvm.shl %arg1, %arg3 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.and %2, %1 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @t31_var_oneuse6(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.lshr %arg0, %arg2 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.shl %arg1, %arg3 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.and %2, %1 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.icmp "ne" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @t32_shift_of_const_oneuse0(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-52543054 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg2 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.lshr %1, %4 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.add %arg2, %2 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %arg1, %6 : i32 + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.and %5, %7 : i32 + %9 = llvm.icmp "ne" %8, %3 : i32 + llvm.return %9 : i1 + } + llvm.func @t33_shift_of_const_oneuse1(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(-52543054 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.sub %0, %arg2 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.lshr %arg0, %4 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.add %arg2, %1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %2, %6 : i32 + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.and %5, %7 : i32 + %9 = llvm.icmp "ne" %8, %3 : i32 + llvm.return %9 : i1 + } + llvm.func @t34_commutativity0_oneuse0(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.call @gen32() : () -> i32 + %3 = llvm.lshr %arg0, %0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %2, %0 : i32 + %5 = llvm.and %4, %3 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + llvm.return %6 : i1 + } + llvm.func @t35_commutativity0_oneuse1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.call @gen32() : () -> i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.shl %2, %0 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.and %4, %3 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + llvm.return %6 : i1 + } + llvm.func @t36_commutativity1_oneuse0(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.call @gen32() : () -> i32 + %3 = llvm.lshr %2, %0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.shl %arg0, %0 : i32 + %5 = llvm.and %3, %4 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + llvm.return %6 : i1 + } + llvm.func @t37_commutativity1_oneuse1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.call @gen32() : () -> i32 + %3 = llvm.lshr %2, %0 : i32 + %4 = llvm.shl %arg0, %0 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.and %3, %4 : i32 + %6 = llvm.icmp "ne" %5, %1 : i32 + llvm.return %6 : i1 + } + llvm.func @n38_overshift(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[15, 1]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[17, 1]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.lshr %arg0, %0 : vector<2xi32> + %5 = llvm.shl %arg1, %1 : vector<2xi32> + %6 = llvm.and %5, %4 : vector<2xi32> + %7 = llvm.icmp "ne" %6, %3 : vector<2xi32> + llvm.return %7 : vector<2xi1> + } + llvm.func @constantexpr() -> i1 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.addressof @f.a : !llvm.ptr + %2 = llvm.mlir.constant(1 : i16) : i16 + %3 = llvm.ptrtoint %1 : !llvm.ptr to i16 + %4 = llvm.load %1 {alignment = 2 : i64} : !llvm.ptr -> i16 + %5 = llvm.ashr %4, %2 : i16 + %6 = llvm.icmp "ne" %3, %2 : i16 + %7 = llvm.zext %6 : i1 to i16 + %8 = llvm.ashr %5, %7 : i16 + %9 = llvm.and %8, %2 : i16 + %10 = llvm.icmp "ne" %9, %0 : i16 + llvm.return %10 : i1 + } + llvm.func @pr44802(%arg0: i3, %arg1: i3, %arg2: i3) -> i1 { + %0 = llvm.mlir.constant(0 : i3) : i3 + %1 = llvm.icmp "ne" %arg0, %0 : i3 + %2 = llvm.zext %1 : i1 to i3 + %3 = llvm.lshr %arg1, %2 : i3 + %4 = llvm.shl %arg2, %2 : i3 + %5 = llvm.and %3, %4 : i3 + %6 = llvm.icmp "ne" %5, %0 : i3 + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/shift-amount-reassociation-with-truncation-ashr.ll.mlir b/test/LLVMDialect/InstCombine/shift-amount-reassociation-with-truncation-ashr.ll.mlir new file mode 100644 index 000000000..960589c88 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shift-amount-reassociation-with-truncation-ashr.ll.mlir @@ -0,0 +1,149 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.ashr %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + %7 = llvm.ashr %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @t1_vec_splat(%arg0: vector<2xi32>, %arg1: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi16>) : vector<2xi16> + %2 = llvm.sub %0, %arg1 : vector<2xi16> + %3 = llvm.zext %2 : vector<2xi16> to vector<2xi32> + %4 = llvm.ashr %arg0, %3 : vector<2xi32> + %5 = llvm.trunc %4 : vector<2xi32> to vector<2xi16> + %6 = llvm.add %arg1, %1 : vector<2xi16> + %7 = llvm.ashr %5, %6 : vector<2xi16> + llvm.return %7 : vector<2xi16> + } + llvm.func @t3_vec_nonsplat_poison0(%arg0: vector<3xi32>, %arg1: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<3xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi16> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi16> + %9 = llvm.mlir.constant(dense<-1> : vector<3xi16>) : vector<3xi16> + %10 = llvm.sub %8, %arg1 : vector<3xi16> + %11 = llvm.zext %10 : vector<3xi16> to vector<3xi32> + %12 = llvm.ashr %arg0, %11 : vector<3xi32> + %13 = llvm.trunc %12 : vector<3xi32> to vector<3xi16> + %14 = llvm.add %arg1, %9 : vector<3xi16> + %15 = llvm.ashr %13, %14 : vector<3xi16> + llvm.return %15 : vector<3xi16> + } + llvm.func @t4_vec_nonsplat_poison1(%arg0: vector<3xi32>, %arg1: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<32> : vector<3xi16>) : vector<3xi16> + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.mlir.poison : i16 + %3 = llvm.mlir.undef : vector<3xi16> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi16> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi16> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi16> + %10 = llvm.sub %0, %arg1 : vector<3xi16> + %11 = llvm.zext %10 : vector<3xi16> to vector<3xi32> + %12 = llvm.ashr %arg0, %11 : vector<3xi32> + %13 = llvm.trunc %12 : vector<3xi32> to vector<3xi16> + %14 = llvm.add %arg1, %9 : vector<3xi16> + %15 = llvm.ashr %13, %14 : vector<3xi16> + llvm.return %15 : vector<3xi16> + } + llvm.func @t5_vec_nonsplat_poison1(%arg0: vector<3xi32>, %arg1: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<3xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi16> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi16> + %9 = llvm.mlir.constant(-1 : i16) : i16 + %10 = llvm.mlir.undef : vector<3xi16> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi16> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi16> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi16> + %17 = llvm.sub %8, %arg1 : vector<3xi16> + %18 = llvm.zext %17 : vector<3xi16> to vector<3xi32> + %19 = llvm.ashr %arg0, %18 : vector<3xi32> + %20 = llvm.trunc %19 : vector<3xi32> to vector<3xi16> + %21 = llvm.add %arg1, %16 : vector<3xi16> + %22 = llvm.ashr %20, %21 : vector<3xi16> + llvm.return %22 : vector<3xi16> + } + llvm.func @use16(i16) + llvm.func @use32(i32) + llvm.func @t6_extrause0(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.ashr %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + llvm.call @use16(%5) : (i16) -> () + %7 = llvm.ashr %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @t7_extrause1(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.ashr %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + llvm.call @use16(%6) : (i16) -> () + %7 = llvm.ashr %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @t8_extrause2(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.ashr %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + llvm.call @use16(%5) : (i16) -> () + llvm.call @use16(%6) : (i16) -> () + %7 = llvm.ashr %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @t9_ashr(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-2 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.ashr %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + %7 = llvm.ashr %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @n10_lshr_ashr(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + %7 = llvm.ashr %5, %6 : i16 + llvm.return %7 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/shift-amount-reassociation-with-truncation-lshr.ll.mlir b/test/LLVMDialect/InstCombine/shift-amount-reassociation-with-truncation-lshr.ll.mlir new file mode 100644 index 000000000..63db8eef9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shift-amount-reassociation-with-truncation-lshr.ll.mlir @@ -0,0 +1,149 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + %7 = llvm.lshr %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @t1_vec_splat(%arg0: vector<2xi32>, %arg1: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi16>) : vector<2xi16> + %2 = llvm.sub %0, %arg1 : vector<2xi16> + %3 = llvm.zext %2 : vector<2xi16> to vector<2xi32> + %4 = llvm.lshr %arg0, %3 : vector<2xi32> + %5 = llvm.trunc %4 : vector<2xi32> to vector<2xi16> + %6 = llvm.add %arg1, %1 : vector<2xi16> + %7 = llvm.lshr %5, %6 : vector<2xi16> + llvm.return %7 : vector<2xi16> + } + llvm.func @t3_vec_nonsplat_poison0(%arg0: vector<3xi32>, %arg1: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<3xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi16> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi16> + %9 = llvm.mlir.constant(dense<-1> : vector<3xi16>) : vector<3xi16> + %10 = llvm.sub %8, %arg1 : vector<3xi16> + %11 = llvm.zext %10 : vector<3xi16> to vector<3xi32> + %12 = llvm.lshr %arg0, %11 : vector<3xi32> + %13 = llvm.trunc %12 : vector<3xi32> to vector<3xi16> + %14 = llvm.add %arg1, %9 : vector<3xi16> + %15 = llvm.lshr %13, %14 : vector<3xi16> + llvm.return %15 : vector<3xi16> + } + llvm.func @t4_vec_nonsplat_poison1(%arg0: vector<3xi32>, %arg1: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<32> : vector<3xi16>) : vector<3xi16> + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.mlir.poison : i16 + %3 = llvm.mlir.undef : vector<3xi16> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi16> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi16> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi16> + %10 = llvm.sub %0, %arg1 : vector<3xi16> + %11 = llvm.zext %10 : vector<3xi16> to vector<3xi32> + %12 = llvm.lshr %arg0, %11 : vector<3xi32> + %13 = llvm.trunc %12 : vector<3xi32> to vector<3xi16> + %14 = llvm.add %arg1, %9 : vector<3xi16> + %15 = llvm.lshr %13, %14 : vector<3xi16> + llvm.return %15 : vector<3xi16> + } + llvm.func @t5_vec_nonsplat_poison1(%arg0: vector<3xi32>, %arg1: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<3xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi16> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi16> + %9 = llvm.mlir.constant(-1 : i16) : i16 + %10 = llvm.mlir.undef : vector<3xi16> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi16> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi16> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi16> + %17 = llvm.sub %8, %arg1 : vector<3xi16> + %18 = llvm.zext %17 : vector<3xi16> to vector<3xi32> + %19 = llvm.lshr %arg0, %18 : vector<3xi32> + %20 = llvm.trunc %19 : vector<3xi32> to vector<3xi16> + %21 = llvm.add %arg1, %16 : vector<3xi16> + %22 = llvm.lshr %20, %21 : vector<3xi16> + llvm.return %22 : vector<3xi16> + } + llvm.func @use16(i16) + llvm.func @use32(i32) + llvm.func @t6_extrause0(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + llvm.call @use16(%5) : (i16) -> () + %7 = llvm.lshr %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @t7_extrause1(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + llvm.call @use16(%6) : (i16) -> () + %7 = llvm.lshr %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @t8_extrause2(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + llvm.call @use16(%5) : (i16) -> () + llvm.call @use16(%6) : (i16) -> () + %7 = llvm.lshr %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @t9_lshr(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-2 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + %7 = llvm.lshr %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @n10_ashr_lshr(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.ashr %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + %7 = llvm.lshr %5, %6 : i16 + llvm.return %7 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/shift-amount-reassociation-with-truncation-shl.ll.mlir b/test/LLVMDialect/InstCombine/shift-amount-reassociation-with-truncation-shl.ll.mlir new file mode 100644 index 000000000..17298c6e6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shift-amount-reassociation-with-truncation-shl.ll.mlir @@ -0,0 +1,197 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @Y32(42 : i32) {addr_space = 0 : i32} : i32 + llvm.mlir.global external @Y16(42 : i16) {addr_space = 0 : i32} : i16 + llvm.func @t0(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-24 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.shl %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + %7 = llvm.shl %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @t1_vec_splat(%arg0: vector<2xi32>, %arg1: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<-24> : vector<2xi16>) : vector<2xi16> + %2 = llvm.sub %0, %arg1 : vector<2xi16> + %3 = llvm.zext %2 : vector<2xi16> to vector<2xi32> + %4 = llvm.shl %arg0, %3 : vector<2xi32> + %5 = llvm.trunc %4 : vector<2xi32> to vector<2xi16> + %6 = llvm.add %arg1, %1 : vector<2xi16> + %7 = llvm.shl %5, %6 : vector<2xi16> + llvm.return %7 : vector<2xi16> + } + llvm.func @t2_vec_nonsplat(%arg0: vector<2xi32>, %arg1: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[32, 30]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<[-24, 0]> : vector<2xi16>) : vector<2xi16> + %2 = llvm.sub %0, %arg1 : vector<2xi16> + %3 = llvm.zext %2 : vector<2xi16> to vector<2xi32> + %4 = llvm.shl %arg0, %3 : vector<2xi32> + %5 = llvm.trunc %4 : vector<2xi32> to vector<2xi16> + %6 = llvm.add %arg1, %1 : vector<2xi16> + %7 = llvm.shl %5, %6 : vector<2xi16> + llvm.return %7 : vector<2xi16> + } + llvm.func @t3_vec_nonsplat_poison0(%arg0: vector<3xi32>, %arg1: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<3xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi16> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi16> + %9 = llvm.mlir.constant(dense<-24> : vector<3xi16>) : vector<3xi16> + %10 = llvm.sub %8, %arg1 : vector<3xi16> + %11 = llvm.zext %10 : vector<3xi16> to vector<3xi32> + %12 = llvm.shl %arg0, %11 : vector<3xi32> + %13 = llvm.trunc %12 : vector<3xi32> to vector<3xi16> + %14 = llvm.add %arg1, %9 : vector<3xi16> + %15 = llvm.shl %13, %14 : vector<3xi16> + llvm.return %15 : vector<3xi16> + } + llvm.func @t4_vec_nonsplat_poison1(%arg0: vector<3xi32>, %arg1: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<32> : vector<3xi16>) : vector<3xi16> + %1 = llvm.mlir.constant(-24 : i16) : i16 + %2 = llvm.mlir.poison : i16 + %3 = llvm.mlir.undef : vector<3xi16> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi16> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi16> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi16> + %10 = llvm.sub %0, %arg1 : vector<3xi16> + %11 = llvm.zext %10 : vector<3xi16> to vector<3xi32> + %12 = llvm.shl %arg0, %11 : vector<3xi32> + %13 = llvm.trunc %12 : vector<3xi32> to vector<3xi16> + %14 = llvm.add %arg1, %9 : vector<3xi16> + %15 = llvm.shl %13, %14 : vector<3xi16> + llvm.return %15 : vector<3xi16> + } + llvm.func @t5_vec_nonsplat_poison1(%arg0: vector<3xi32>, %arg1: vector<3xi16>) -> vector<3xi16> { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<3xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi16> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi16> + %9 = llvm.mlir.constant(-24 : i16) : i16 + %10 = llvm.mlir.undef : vector<3xi16> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi16> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi16> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi16> + %17 = llvm.sub %8, %arg1 : vector<3xi16> + %18 = llvm.zext %17 : vector<3xi16> to vector<3xi32> + %19 = llvm.shl %arg0, %18 : vector<3xi32> + %20 = llvm.trunc %19 : vector<3xi32> to vector<3xi16> + %21 = llvm.add %arg1, %16 : vector<3xi16> + %22 = llvm.shl %20, %21 : vector<3xi16> + llvm.return %22 : vector<3xi16> + } + llvm.func @use16(i16) + llvm.func @use32(i32) + llvm.func @t6_extrause0(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-24 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.shl %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + llvm.call @use16(%5) : (i16) -> () + %7 = llvm.shl %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @t7_extrause1(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-24 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.shl %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + llvm.call @use16(%6) : (i16) -> () + %7 = llvm.shl %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @t8_extrause2(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(32 : i16) : i16 + %1 = llvm.mlir.constant(-24 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.shl %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + llvm.call @use16(%5) : (i16) -> () + llvm.call @use16(%6) : (i16) -> () + %7 = llvm.shl %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @n11(%arg0: i32, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(30 : i16) : i16 + %1 = llvm.mlir.constant(-31 : i16) : i16 + %2 = llvm.sub %0, %arg1 : i16 + %3 = llvm.zext %2 : i16 to i32 + %4 = llvm.shl %arg0, %3 : i32 + %5 = llvm.trunc %4 : i32 to i16 + %6 = llvm.add %arg1, %1 : i16 + %7 = llvm.shl %5, %6 : i16 + llvm.return %7 : i16 + } + llvm.func @t01(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.addressof @Y32 : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.mlir.constant(42 : i16) : i16 + %4 = llvm.mlir.addressof @Y16 : !llvm.ptr + %5 = llvm.ptrtoint %4 : !llvm.ptr to i16 + %6 = llvm.shl %arg0, %2 : i32 + %7 = llvm.trunc %6 : i32 to i16 + %8 = llvm.shl %7, %5 : i16 + llvm.return %8 : i16 + } + llvm.func @shl_tr_shl_constant_shift_amount_uses(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(4 : i16) : i16 + %2 = llvm.shl %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i16 + llvm.call @use16(%3) : (i16) -> () + %4 = llvm.shl %3, %1 : i16 + llvm.return %4 : i16 + } + llvm.func @PR51657(%arg0: i64, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(64 : i64) : i64 + llvm.cond_br %arg1, ^bb1, ^bb2(%0, %1 : i32, i8) + ^bb1: // pred: ^bb0 + %3 = llvm.shl %arg0, %2 : i64 + %4 = llvm.trunc %3 : i64 to i32 + %5 = llvm.trunc %3 : i64 to i8 + llvm.br ^bb2(%4, %5 : i32, i8) + ^bb2(%6: i32, %7: i8): // 2 preds: ^bb0, ^bb1 + %8 = llvm.sext %7 : i8 to i32 + %9 = llvm.icmp "eq" %6, %8 : i32 + llvm.return %9 : i1 + } + llvm.func @extra_use_on_first_shift(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(6 : i16) : i16 + %2 = llvm.ashr %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i16 + %4 = llvm.lshr %3, %1 : i16 + llvm.return %4 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/shift-amount-reassociation.ll.mlir b/test/LLVMDialect/InstCombine/shift-amount-reassociation.ll.mlir new file mode 100644 index 000000000..b5a332b06 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shift-amount-reassociation.ll.mlir @@ -0,0 +1,255 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @X() {addr_space = 0 : i32} : i32 + llvm.func @t0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.lshr %arg0, %2 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.lshr %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @t1_vec_splat(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-2> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %0, %arg1 : vector<2xi32> + %3 = llvm.lshr %arg0, %2 : vector<2xi32> + %4 = llvm.add %arg1, %1 : vector<2xi32> + %5 = llvm.lshr %3, %4 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @t2_vec_nonsplat(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[32, 30]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-2, 0]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %0, %arg1 : vector<2xi32> + %3 = llvm.lshr %arg0, %2 : vector<2xi32> + %4 = llvm.add %arg1, %1 : vector<2xi32> + %5 = llvm.lshr %3, %4 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @t3_vec_nonsplat_poison0(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(dense<-2> : vector<3xi32>) : vector<3xi32> + %10 = llvm.sub %8, %arg1 : vector<3xi32> + %11 = llvm.lshr %arg0, %10 : vector<3xi32> + %12 = llvm.add %arg1, %9 : vector<3xi32> + %13 = llvm.lshr %11, %12 : vector<3xi32> + llvm.return %13 : vector<3xi32> + } + llvm.func @t4_vec_nonsplat_poison1(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<32> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.undef : vector<3xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi32> + %10 = llvm.sub %0, %arg1 : vector<3xi32> + %11 = llvm.lshr %arg0, %10 : vector<3xi32> + %12 = llvm.add %arg1, %9 : vector<3xi32> + %13 = llvm.lshr %11, %12 : vector<3xi32> + llvm.return %13 : vector<3xi32> + } + llvm.func @t5_vec_nonsplat_poison1(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(-2 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.sub %8, %arg1 : vector<3xi32> + %18 = llvm.lshr %arg0, %17 : vector<3xi32> + %19 = llvm.add %arg1, %16 : vector<3xi32> + %20 = llvm.lshr %18, %19 : vector<3xi32> + llvm.return %20 : vector<3xi32> + } + llvm.func @t6_shl(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.shl %arg0, %2 overflow : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.shl %3, %4 overflow : i32 + llvm.return %5 : i32 + } + llvm.func @t7_ashr(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.ashr %arg0, %2 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.ashr %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @t8_lshr_exact_flag_preservation(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.lshr %arg0, %2 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.lshr %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @t9_ashr_exact_flag_preservation(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.ashr %arg0, %2 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.ashr %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @t10_shl_nuw_flag_preservation(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.shl %arg0, %2 overflow : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.shl %3, %4 overflow : i32 + llvm.return %5 : i32 + } + llvm.func @t11_shl_nsw_flag_preservation(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.shl %arg0, %2 overflow : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.shl %3, %4 overflow : i32 + llvm.return %5 : i32 + } + llvm.func @constantexpr() -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.addressof @X : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.mlir.undef : i64 + %5 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %6 = llvm.load %5 {alignment = 4 : i64} : !llvm.ptr -> i64 + %7 = llvm.add %2, %3 : i64 + %8 = llvm.shl %7, %3 : i64 + %9 = llvm.ashr %8, %6 : i64 + %10 = llvm.and %4, %9 : i64 + llvm.return %10 : i64 + } + llvm.func @n12(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(30 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.lshr %arg0, %2 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.lshr %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @t13_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[32, 30]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[-2, 2]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %0, %arg1 : vector<2xi32> + %3 = llvm.lshr %arg0, %2 : vector<2xi32> + %4 = llvm.add %arg1, %1 : vector<2xi32> + %5 = llvm.lshr %3, %4 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @n13(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.lshr %arg0, %2 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.ashr %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @n14(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.lshr %arg0, %2 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.ashr %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @n15(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.ashr %arg0, %2 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.lshr %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @n16(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.ashr %arg0, %2 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.lshr %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @n17(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.shl %arg0, %2 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.lshr %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @n18(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.shl %arg0, %2 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.ashr %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @n19(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.lshr %arg0, %2 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.shl %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @n20(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + %3 = llvm.ashr %arg0, %2 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.shl %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @pr44802(%arg0: i3) -> i3 { + %0 = llvm.mlir.constant(0 : i3) : i3 + %1 = llvm.sub %0, %arg0 : i3 + %2 = llvm.icmp "ne" %arg0, %0 : i3 + %3 = llvm.zext %2 : i1 to i3 + %4 = llvm.lshr %1, %3 : i3 + %5 = llvm.lshr %4, %3 : i3 + llvm.return %5 : i3 + } +} diff --git a/test/LLVMDialect/InstCombine/shift-by-signext.ll.mlir b/test/LLVMDialect/InstCombine/shift-by-signext.ll.mlir index e5496e23d..031e3bf3d 100644 --- a/test/LLVMDialect/InstCombine/shift-by-signext.ll.mlir +++ b/test/LLVMDialect/InstCombine/shift-by-signext.ll.mlir @@ -1,103 +1,80 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg1) : (i8) -> i32 - %1 = "llvm.shl"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "t0_shl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg1) : (i8) -> i32 - %1 = "llvm.lshr"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "t1_lshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg1) : (i8) -> i32 - %1 = "llvm.ashr"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "t2_ashr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.sext"(%arg1) : (vector<2xi8>) -> vector<2xi32> - %1 = "llvm.shl"(%arg0, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%1) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "t3_vec_shl", type = !llvm.func (vector<2xi32>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.sext"(%arg1) : (vector<2xi8>) -> vector<2xi32> - %1 = "llvm.lshr"(%arg0, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%1) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "t4_vec_lshr", type = !llvm.func (vector<2xi32>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.sext"(%arg1) : (vector<2xi8>) -> vector<2xi32> - %1 = "llvm.ashr"(%arg0, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%1) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "t5_vec_ashr", type = !llvm.func (vector<2xi32>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg1) : (i8) -> i32 - "llvm.br"()[^bb1] : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_shl(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.sext %arg1 : i8 to i32 + %1 = llvm.shl %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @t1_lshr(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.sext %arg1 : i8 to i32 + %1 = llvm.lshr %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @t2_ashr(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.sext %arg1 : i8 to i32 + %1 = llvm.ashr %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @t3_vec_shl(%arg0: vector<2xi32>, %arg1: vector<2xi8>) -> vector<2xi32> { + %0 = llvm.sext %arg1 : vector<2xi8> to vector<2xi32> + %1 = llvm.shl %arg0, %0 : vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @t4_vec_lshr(%arg0: vector<2xi32>, %arg1: vector<2xi8>) -> vector<2xi32> { + %0 = llvm.sext %arg1 : vector<2xi8> to vector<2xi32> + %1 = llvm.lshr %arg0, %0 : vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @t5_vec_ashr(%arg0: vector<2xi32>, %arg1: vector<2xi8>) -> vector<2xi32> { + %0 = llvm.sext %arg1 : vector<2xi8> to vector<2xi32> + %1 = llvm.ashr %arg0, %0 : vector<2xi32> + llvm.return %1 : vector<2xi32> + } + llvm.func @t6_twoshifts(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.sext %arg1 : i8 to i32 + llvm.br ^bb1 ^bb1: // pred: ^bb0 - %1 = "llvm.shl"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.ashr"(%1, %0) : (i32, i32) -> i32 - "llvm.br"()[^bb2] : () -> () + %1 = llvm.shl %arg0, %0 : i32 + %2 = llvm.ashr %1, %0 : i32 + llvm.br ^bb2 ^bb2: // pred: ^bb1 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "t6_twoshifts", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.fshl.i7", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.fshr.i7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i7, %arg1: i7, %arg2: i6): // no predecessors - %0 = "llvm.sext"(%arg2) : (i6) -> i7 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.fshl.i7, fastmathFlags = #llvm.fastmath<>} : (i7, i7, i7) -> i7 - "llvm.return"(%1) : (i7) -> () - }) {linkage = 10 : i64, sym_name = "n7_fshl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i7, %arg1: i7, %arg2: i6): // no predecessors - %0 = "llvm.sext"(%arg2) : (i6) -> i7 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.fshr.i7, fastmathFlags = #llvm.fastmath<>} : (i7, i7, i7) -> i7 - "llvm.return"(%1) : (i7) -> () - }) {linkage = 10 : i64, sym_name = "n8_fshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.fshl.i8", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.fshr.i8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i6): // no predecessors - %0 = "llvm.sext"(%arg2) : (i6) -> i8 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.fshl.i8, fastmathFlags = #llvm.fastmath<>} : (i8, i8, i8) -> i8 - "llvm.return"(%1) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t9_fshl", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i6): // no predecessors - %0 = "llvm.sext"(%arg2) : (i6) -> i8 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @llvm.fshr.i8, fastmathFlags = #llvm.fastmath<>} : (i8, i8, i8) -> i8 - "llvm.return"(%1) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t10_fshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg1) : (i8) -> i32 - "llvm.call"(%0) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %1 = "llvm.shl"(%arg0, %0) : (i32, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "n11_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i8): // no predecessors - %0 = "llvm.sext"(%arg1) : (i8) -> i32 - "llvm.br"()[^bb1] : () -> () + llvm.return %2 : i32 + } + llvm.func @n7_fshl(%arg0: i7, %arg1: i7, %arg2: i6) -> i7 { + %0 = llvm.sext %arg2 : i6 to i7 + %1 = llvm.intr.fshl(%arg0, %arg1, %0) : (i7, i7, i7) -> i7 + llvm.return %1 : i7 + } + llvm.func @n8_fshr(%arg0: i7, %arg1: i7, %arg2: i6) -> i7 { + %0 = llvm.sext %arg2 : i6 to i7 + %1 = llvm.intr.fshr(%arg0, %arg1, %0) : (i7, i7, i7) -> i7 + llvm.return %1 : i7 + } + llvm.func @t9_fshl(%arg0: i8, %arg1: i8, %arg2: i6) -> i8 { + %0 = llvm.sext %arg2 : i6 to i8 + %1 = llvm.intr.fshl(%arg0, %arg1, %0) : (i8, i8, i8) -> i8 + llvm.return %1 : i8 + } + llvm.func @t10_fshr(%arg0: i8, %arg1: i8, %arg2: i6) -> i8 { + %0 = llvm.sext %arg2 : i6 to i8 + %1 = llvm.intr.fshr(%arg0, %arg1, %0) : (i8, i8, i8) -> i8 + llvm.return %1 : i8 + } + llvm.func @use32(i32) + llvm.func @n11_extrause(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.sext %arg1 : i8 to i32 + llvm.call @use32(%0) : (i32) -> () + %1 = llvm.shl %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @n12_twoshifts_and_extrause(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.sext %arg1 : i8 to i32 + llvm.br ^bb1 ^bb1: // pred: ^bb0 - %1 = "llvm.shl"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.ashr"(%1, %0) : (i32, i32) -> i32 - "llvm.br"()[^bb2] : () -> () + %1 = llvm.shl %arg0, %0 : i32 + %2 = llvm.ashr %1, %0 : i32 + llvm.br ^bb2 ^bb2: // pred: ^bb1 - "llvm.call"(%0) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "n12_twoshifts_and_extrause", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.call @use32(%0) : (i32) -> () + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/shift-cttz-ctlz.ll.mlir b/test/LLVMDialect/InstCombine/shift-cttz-ctlz.ll.mlir new file mode 100644 index 000000000..00205f2d3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shift-cttz-ctlz.ll.mlir @@ -0,0 +1,34 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @shl_cttz_false(%arg0: i32, %arg1: i32) -> i32 { + %0 = "llvm.intr.cttz"(%arg1) <{is_zero_poison = false}> : (i32) -> i32 + %1 = llvm.shl %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @shl_ctlz_false(%arg0: i32, %arg1: i32) -> i32 { + %0 = "llvm.intr.ctlz"(%arg1) <{is_zero_poison = false}> : (i32) -> i32 + %1 = llvm.shl %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @lshr_cttz_false(%arg0: i32, %arg1: i32) -> i32 { + %0 = "llvm.intr.cttz"(%arg1) <{is_zero_poison = false}> : (i32) -> i32 + %1 = llvm.lshr %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @ashr_cttz_false(%arg0: i32, %arg1: i32) -> i32 { + %0 = "llvm.intr.cttz"(%arg1) <{is_zero_poison = false}> : (i32) -> i32 + %1 = llvm.ashr %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @shl_cttz_false_multiuse(%arg0: i32, %arg1: i32) -> i32 { + %0 = "llvm.intr.cttz"(%arg1) <{is_zero_poison = false}> : (i32) -> i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.shl %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @shl_cttz_as_lhs(%arg0: i32, %arg1: i32) -> i32 { + %0 = "llvm.intr.cttz"(%arg1) <{is_zero_poison = false}> : (i32) -> i32 + %1 = llvm.shl %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @use(i32) +} diff --git a/test/LLVMDialect/InstCombine/shift-direction-in-bit-test.ll.mlir b/test/LLVMDialect/InstCombine/shift-direction-in-bit-test.ll.mlir new file mode 100644 index 000000000..ca571b030 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shift-direction-in-bit-test.ll.mlir @@ -0,0 +1,149 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @t1_ne(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @t2_vec_splat(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %arg1 : vector<4xi32> + %3 = llvm.and %2, %arg2 : vector<4xi32> + %4 = llvm.icmp "eq" %3, %1 : vector<4xi32> + llvm.return %4 : vector<4xi1> + } + llvm.func @t3_vec_splat_undef(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.shl %arg0, %arg1 : vector<4xi32> + %12 = llvm.and %11, %arg2 : vector<4xi32> + %13 = llvm.icmp "eq" %12, %10 : vector<4xi32> + llvm.return %13 : vector<4xi1> + } + llvm.func @gen32() -> i32 + llvm.func @t4_commutative(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @gen32() : () -> i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.and %1, %2 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @t5_twoshifts0(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.shl %1, %arg2 : i32 + %3 = llvm.and %2, %arg3 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @t6_twoshifts1(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.shl %arg2, %arg3 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.icmp "eq" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @t7_twoshifts2(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.shl %arg2, %arg3 : i32 + %4 = llvm.and %3, %2 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @t8_twoshifts3(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.shl %0, %arg3 : i32 + %4 = llvm.and %3, %2 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @use32(i32) + llvm.func @t9_extrause0(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @t10_extrause1(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.and %1, %arg2 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @t11_extrause2(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.and %1, %arg2 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } + llvm.func @t12_shift_of_const0(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg2 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @t13_shift_of_const1(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %0, %arg1 : i32 + %3 = llvm.and %2, %arg2 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @t14_and_with_const0(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @t15_and_with_const1(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @n16(%arg0: i32, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %arg0, %arg1 : i32 + %2 = llvm.and %1, %arg2 : i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/shift-flags.ll.mlir b/test/LLVMDialect/InstCombine/shift-flags.ll.mlir new file mode 100644 index 000000000..2cb023001 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shift-flags.ll.mlir @@ -0,0 +1,74 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @shl_add_nuw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(63 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.shl %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_add_nuw_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(63 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.shl %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_add_nuw_and_nsw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(31 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.shl %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_add_nsw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-32 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.shl %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_add_nsw_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.shl %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @lshr_add_exact(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-4 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.lshr %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @lshr_add_exact_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-7 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.lshr %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @ashr_add_exact(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-14 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.ashr %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @ashr_add_exact_fail(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-14 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.and %arg1, %1 : i8 + %4 = llvm.ashr %2, %3 : i8 + llvm.return %4 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/shift-logic.ll.mlir b/test/LLVMDialect/InstCombine/shift-logic.ll.mlir new file mode 100644 index 000000000..32730f3aa --- /dev/null +++ b/test/LLVMDialect/InstCombine/shift-logic.ll.mlir @@ -0,0 +1,424 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g() {addr_space = 0 : i32} : i32 + llvm.func @use(i64) + llvm.func @shl_and(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.and %2, %arg1 : i8 + %4 = llvm.shl %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_and_nonuniform(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[3, 4]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[2, 0]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.and %2, %arg1 : vector<2xi8> + %4 = llvm.shl %3, %1 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @shl_or(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(42 : i16) : i16 + %1 = llvm.mlir.constant(5 : i16) : i16 + %2 = llvm.mlir.constant(7 : i16) : i16 + %3 = llvm.srem %arg1, %0 : i16 + %4 = llvm.shl %arg0, %1 : i16 + %5 = llvm.or %3, %4 : i16 + %6 = llvm.shl %5, %2 : i16 + llvm.return %6 : i16 + } + llvm.func @shl_or_poison(%arg0: vector<2xi16>, %arg1: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.constant(5 : i16) : i16 + %3 = llvm.mlir.undef : vector<2xi16> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi16> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi16> + %8 = llvm.mlir.constant(7 : i16) : i16 + %9 = llvm.mlir.undef : vector<2xi16> + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.insertelement %8, %9[%10 : i32] : vector<2xi16> + %12 = llvm.mlir.constant(1 : i32) : i32 + %13 = llvm.insertelement %1, %11[%12 : i32] : vector<2xi16> + %14 = llvm.srem %arg1, %0 : vector<2xi16> + %15 = llvm.shl %arg0, %7 : vector<2xi16> + %16 = llvm.or %14, %15 : vector<2xi16> + %17 = llvm.shl %16, %13 : vector<2xi16> + llvm.return %17 : vector<2xi16> + } + llvm.func @shl_xor(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.xor %2, %arg1 : i32 + %4 = llvm.shl %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @shl_xor_nonuniform(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[5, 6]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[7, 8]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.shl %arg0, %0 : vector<2xi32> + %3 = llvm.xor %2, %arg1 : vector<2xi32> + %4 = llvm.shl %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @lshr_and(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.mlir.constant(5 : i64) : i64 + %2 = llvm.mlir.constant(7 : i64) : i64 + %3 = llvm.srem %arg1, %0 : i64 + %4 = llvm.lshr %arg0, %1 : i64 + %5 = llvm.and %3, %4 : i64 + %6 = llvm.lshr %5, %2 : i64 + llvm.return %6 : i64 + } + llvm.func @lshr_and_poison(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.mlir.undef : vector<2xi64> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi64> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi64> + %8 = llvm.mlir.constant(7 : i64) : i64 + %9 = llvm.mlir.undef : vector<2xi64> + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.insertelement %8, %9[%10 : i32] : vector<2xi64> + %12 = llvm.mlir.constant(1 : i32) : i32 + %13 = llvm.insertelement %1, %11[%12 : i32] : vector<2xi64> + %14 = llvm.srem %arg1, %0 : vector<2xi64> + %15 = llvm.lshr %arg0, %7 : vector<2xi64> + %16 = llvm.and %14, %15 : vector<2xi64> + %17 = llvm.lshr %16, %13 : vector<2xi64> + llvm.return %17 : vector<2xi64> + } + llvm.func @lshr_or(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<5> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<7> : vector<4xi32>) : vector<4xi32> + %2 = llvm.lshr %arg0, %0 : vector<4xi32> + %3 = llvm.or %2, %arg1 : vector<4xi32> + %4 = llvm.lshr %3, %1 : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @lshr_xor(%arg0: vector<8xi16>, %arg1: vector<8xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(dense<[42, 42, 42, 42, 42, 42, 42, -42]> : vector<8xi16>) : vector<8xi16> + %1 = llvm.mlir.constant(dense<5> : vector<8xi16>) : vector<8xi16> + %2 = llvm.mlir.constant(dense<7> : vector<8xi16>) : vector<8xi16> + %3 = llvm.srem %arg1, %0 : vector<8xi16> + %4 = llvm.lshr %arg0, %1 : vector<8xi16> + %5 = llvm.xor %3, %4 : vector<8xi16> + %6 = llvm.lshr %5, %2 : vector<8xi16> + llvm.return %6 : vector<8xi16> + } + llvm.func @ashr_and(%arg0: vector<16xi8>, %arg1: vector<16xi8>, %arg2: vector<16xi8>) -> vector<16xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<16xi8>) : vector<16xi8> + %1 = llvm.mlir.constant(dense<2> : vector<16xi8>) : vector<16xi8> + %2 = llvm.srem %arg1, %arg2 : vector<16xi8> + %3 = llvm.ashr %arg0, %0 : vector<16xi8> + %4 = llvm.and %2, %3 : vector<16xi8> + %5 = llvm.ashr %4, %1 : vector<16xi8> + llvm.return %5 : vector<16xi8> + } + llvm.func @ashr_or(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<7> : vector<2xi64>) : vector<2xi64> + %2 = llvm.ashr %arg0, %0 : vector<2xi64> + %3 = llvm.or %2, %arg1 : vector<2xi64> + %4 = llvm.ashr %3, %1 : vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @ashr_xor(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.srem %arg1, %0 : i32 + %4 = llvm.ashr %arg0, %1 : i32 + %5 = llvm.xor %3, %4 : i32 + %6 = llvm.ashr %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @shr_mismatch_xor(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.xor %arg1, %2 : i32 + %4 = llvm.lshr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @ashr_overshift_xor(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.xor %arg1, %2 : i32 + %4 = llvm.ashr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @ashr_poison_poison_xor(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(17 : i32) : i32 + %8 = llvm.mlir.undef : vector<2xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<2xi32> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %7, %10[%11 : i32] : vector<2xi32> + %13 = llvm.ashr %arg0, %6 : vector<2xi32> + %14 = llvm.xor %arg1, %13 : vector<2xi32> + %15 = llvm.ashr %14, %12 : vector<2xi32> + llvm.return %15 : vector<2xi32> + } + llvm.func @lshr_or_extra_use(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.or %2, %arg1 : i32 + llvm.store %3, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.lshr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @PR44028(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.addressof @g : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.ashr %arg0, %0 : i32 + %4 = llvm.shl %2, %0 : i32 + %5 = llvm.xor %3, %4 : i32 + %6 = llvm.ashr %5, %0 : i32 + llvm.return %6 : i32 + } + llvm.func @lshr_mul(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(52 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.mul %arg0, %0 overflow : i64 + %3 = llvm.lshr %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @lshr_mul_nuw_nsw(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(52 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.mul %arg0, %0 overflow : i64 + %3 = llvm.lshr %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @lshr_mul_vector(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<52> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 overflow : vector<4xi32> + %3 = llvm.lshr %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @lshr_mul_negative_noexact(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(53 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.mul %arg0, %0 overflow : i64 + %3 = llvm.lshr %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @lshr_mul_negative_oneuse(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(52 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.mul %arg0, %0 overflow : i64 + llvm.call @use(%2) : (i64) -> () + %3 = llvm.lshr %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @lshr_mul_negative_nonuw(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(52 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.mul %arg0, %0 : i64 + %3 = llvm.lshr %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @lshr_mul_negative_nsw(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(52 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.mul %arg0, %0 overflow : i64 + %3 = llvm.lshr %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @shl_add(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.add %2, %arg1 : i8 + %4 = llvm.shl %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_add_multiuse(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(-42 : i8) : i8 + %2 = llvm.mlir.addressof @use : !llvm.ptr + %3 = llvm.mlir.constant(2 : i8) : i8 + %4 = llvm.shl %arg0, %0 : i8 + %5 = llvm.add %4, %1 : i8 + llvm.call %2(%4) : !llvm.ptr, (i8) -> () + %6 = llvm.shl %5, %3 : i8 + llvm.return %6 : i8 + } + llvm.func @shl_add_multiuse_nonconstant(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.addressof @use : !llvm.ptr + %2 = llvm.mlir.constant(2 : i8) : i8 + %3 = llvm.shl %arg0, %0 : i8 + %4 = llvm.add %3, %arg1 : i8 + llvm.call %1(%3) : !llvm.ptr, (i8) -> () + %5 = llvm.shl %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @shl_add_nonuniform(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[3, 4]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[2, 0]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.add %2, %arg1 : vector<2xi8> + %4 = llvm.shl %3, %1 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @shl_add_poison(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.mlir.undef : vector<2xi64> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi64> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi64> + %8 = llvm.mlir.constant(7 : i64) : i64 + %9 = llvm.mlir.undef : vector<2xi64> + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.insertelement %8, %9[%10 : i32] : vector<2xi64> + %12 = llvm.mlir.constant(1 : i32) : i32 + %13 = llvm.insertelement %1, %11[%12 : i32] : vector<2xi64> + %14 = llvm.srem %arg1, %0 : vector<2xi64> + %15 = llvm.shl %arg0, %7 : vector<2xi64> + %16 = llvm.add %14, %15 : vector<2xi64> + %17 = llvm.shl %16, %13 : vector<2xi64> + llvm.return %17 : vector<2xi64> + } + llvm.func @lshr_add(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.add %2, %arg1 : i8 + %4 = llvm.lshr %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @lshr_add_nonuniform(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[3, 4]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[2, 0]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %arg0, %0 : vector<2xi8> + %3 = llvm.add %2, %arg1 : vector<2xi8> + %4 = llvm.lshr %3, %1 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @lshr_add_poison(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.mlir.undef : vector<2xi64> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi64> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi64> + %8 = llvm.mlir.constant(7 : i64) : i64 + %9 = llvm.mlir.undef : vector<2xi64> + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.insertelement %8, %9[%10 : i32] : vector<2xi64> + %12 = llvm.mlir.constant(1 : i32) : i32 + %13 = llvm.insertelement %1, %11[%12 : i32] : vector<2xi64> + %14 = llvm.srem %arg1, %0 : vector<2xi64> + %15 = llvm.lshr %arg0, %7 : vector<2xi64> + %16 = llvm.add %14, %15 : vector<2xi64> + %17 = llvm.lshr %16, %13 : vector<2xi64> + llvm.return %17 : vector<2xi64> + } + llvm.func @shl_sub(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.sub %2, %arg1 : i8 + %4 = llvm.shl %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_sub_no_commute(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.shl %arg1, %0 : i8 + %3 = llvm.sub %arg0, %2 : i8 + %4 = llvm.shl %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_sub_nonuniform(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[3, 4]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[2, 0]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.sub %2, %arg1 : vector<2xi8> + %4 = llvm.shl %3, %1 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @shl_sub_poison(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.mlir.undef : vector<2xi64> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi64> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi64> + %8 = llvm.mlir.constant(7 : i64) : i64 + %9 = llvm.mlir.undef : vector<2xi64> + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.insertelement %8, %9[%10 : i32] : vector<2xi64> + %12 = llvm.mlir.constant(1 : i32) : i32 + %13 = llvm.insertelement %1, %11[%12 : i32] : vector<2xi64> + %14 = llvm.srem %arg1, %0 : vector<2xi64> + %15 = llvm.shl %arg0, %7 : vector<2xi64> + %16 = llvm.sub %14, %15 : vector<2xi64> + %17 = llvm.shl %16, %13 : vector<2xi64> + llvm.return %17 : vector<2xi64> + } + llvm.func @lshr_sub(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.sub %2, %arg1 : i8 + %4 = llvm.lshr %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @lshr_sub_nonuniform(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[3, 4]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[2, 0]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %arg0, %0 : vector<2xi8> + %3 = llvm.sub %2, %arg1 : vector<2xi8> + %4 = llvm.lshr %3, %1 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @lshr_sub_poison(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.mlir.undef : vector<2xi64> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi64> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi64> + %8 = llvm.mlir.constant(7 : i64) : i64 + %9 = llvm.mlir.undef : vector<2xi64> + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.insertelement %8, %9[%10 : i32] : vector<2xi64> + %12 = llvm.mlir.constant(1 : i32) : i32 + %13 = llvm.insertelement %1, %11[%12 : i32] : vector<2xi64> + %14 = llvm.srem %arg1, %0 : vector<2xi64> + %15 = llvm.lshr %arg0, %7 : vector<2xi64> + %16 = llvm.sub %14, %15 : vector<2xi64> + %17 = llvm.lshr %16, %13 : vector<2xi64> + llvm.return %17 : vector<2xi64> + } +} diff --git a/test/LLVMDialect/InstCombine/shift-shift.ll.mlir b/test/LLVMDialect/InstCombine/shift-shift.ll.mlir new file mode 100644 index 000000000..7ffd135c6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shift-shift.ll.mlir @@ -0,0 +1,484 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g() {addr_space = 0 : i32, alignment = 8 : i64} : i8 + llvm.func @use8(i8) + llvm.func @use32(i32) + llvm.func @pr12967() { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.mlir.constant(-2 : i32) : i32 + llvm.br ^bb1(%0 : i32) + ^bb1(%3: i32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.shl %3, %1 : i32 + %5 = llvm.lshr %4, %2 : i32 + llvm.br ^bb1(%5 : i32) + } + llvm.func @pr26760() { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.mlir.constant(-2 : i32) : i32 + llvm.br ^bb1(%0 : i32) + ^bb1(%3: i32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.lshr %3, %1 : i32 + %5 = llvm.shl %4, %2 : i32 + llvm.br ^bb1(%5 : i32) + } + llvm.func @pr8547(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.mlir.constant(24 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + llvm.br ^bb1(%0 : i32) + ^bb1(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.store %4, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.shl %4, %1 : i32 + %6 = llvm.lshr %5, %2 : i32 + %7 = llvm.icmp "eq" %6, %0 : i32 + llvm.cond_br %7, ^bb1(%3 : i32), ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %6 : i32 + } + llvm.func @shl_shl(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(28 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_shl_splat_vec(%arg0: vector<2xi33>) -> vector<2xi33> { + %0 = llvm.mlir.constant(5 : i33) : i33 + %1 = llvm.mlir.constant(dense<5> : vector<2xi33>) : vector<2xi33> + %2 = llvm.mlir.constant(28 : i33) : i33 + %3 = llvm.mlir.constant(dense<28> : vector<2xi33>) : vector<2xi33> + %4 = llvm.shl %arg0, %1 : vector<2xi33> + %5 = llvm.shl %4, %3 : vector<2xi33> + llvm.return %5 : vector<2xi33> + } + llvm.func @shl_shl_vec(%arg0: vector<2xi33>) -> vector<2xi33> { + %0 = llvm.mlir.constant(5 : i33) : i33 + %1 = llvm.mlir.constant(6 : i33) : i33 + %2 = llvm.mlir.constant(dense<[6, 5]> : vector<2xi33>) : vector<2xi33> + %3 = llvm.mlir.constant(28 : i33) : i33 + %4 = llvm.mlir.constant(27 : i33) : i33 + %5 = llvm.mlir.constant(dense<[27, 28]> : vector<2xi33>) : vector<2xi33> + %6 = llvm.shl %arg0, %2 : vector<2xi33> + %7 = llvm.shl %6, %5 : vector<2xi33> + llvm.return %7 : vector<2xi33> + } + llvm.func @lshr_lshr(%arg0: i232) -> i232 { + %0 = llvm.mlir.constant(231 : i232) : i232 + %1 = llvm.mlir.constant(1 : i232) : i232 + %2 = llvm.lshr %arg0, %0 : i232 + %3 = llvm.lshr %2, %1 : i232 + llvm.return %3 : i232 + } + llvm.func @lshr_lshr_splat_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<28> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.lshr %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @lshr_lshr_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[29, 28]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[4, 5]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.lshr %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @shl_trunc_bigger_lshr(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.shl %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_trunc_smaller_lshr(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.shl %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_trunc_bigger_ashr(%arg0: i32) -> i24 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(3 : i24) : i24 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i24 + %4 = llvm.shl %3, %1 : i24 + llvm.return %4 : i24 + } + llvm.func @shl_trunc_smaller_ashr(%arg0: i32) -> i24 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(13 : i24) : i24 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i24 + %4 = llvm.shl %3, %1 : i24 + llvm.return %4 : i24 + } + llvm.func @shl_trunc_bigger_shl(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.shl %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_trunc_smaller_shl(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.shl %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_trunc_bigger_lshr_use1(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.shl %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_trunc_smaller_lshr_use1(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.trunc %2 : i32 to i8 + %4 = llvm.shl %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_trunc_bigger_lshr_use2(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.shl %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @shl_trunc_smaller_lshr_use2(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.shl %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @ashr_ashr_constants_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.ashr %0, %arg0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_ashr_constants_vec(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[33, -2, -128]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(dense<[3, -1, 7]> : vector<3xi8>) : vector<3xi8> + %2 = llvm.ashr %0, %arg0 : vector<3xi8> + %3 = llvm.ashr %2, %1 : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @lshr_lshr_constants_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.lshr %0, %arg0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_lshr_constants_vec(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[33, -2, 1]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(dense<[3, -1, 7]> : vector<3xi8>) : vector<3xi8> + %2 = llvm.lshr %0, %arg0 : vector<3xi8> + %3 = llvm.lshr %2, %1 : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shl_shl_constants_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2013265920 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_shl_constants_vec(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[33, -2, -128]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.constant(dense<[3, -1, 7]> : vector<3xi8>) : vector<3xi8> + %2 = llvm.shl %0, %arg0 : vector<3xi8> + %3 = llvm.shl %2, %1 : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shl_shl_constants_div(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.shl %2, %1 : i32 + %4 = llvm.udiv %arg0, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @ashr_lshr_constants(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.ashr %0, %arg0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_shl_constants(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.ashr %0, %arg0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_ashr_constants(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.lshr %0, %arg0 : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @lshr_shl_constants(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.lshr %0, %arg0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_ashr_constants(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_lshr_constants(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-33 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.shl %0, %arg0 : i32 + %3 = llvm.lshr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_lshr_demand1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(40 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(-32 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.lshr %3, %1 : i8 + %5 = llvm.or %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @shl_ashr_demand2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(40 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(-32 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.ashr %3, %1 : i8 + %5 = llvm.or %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @shl_lshr_demand3(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(40 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(-64 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.lshr %3, %1 : i8 + %5 = llvm.or %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @shl_lshr_demand4(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(44 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(-32 : i8) : i8 + %3 = llvm.shl %0, %arg0 : i8 + %4 = llvm.lshr %3, %1 : i8 + %5 = llvm.or %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @shl_lshr_demand5(%arg0: vector<2xi8>) -> vector<2xi6> { + %0 = llvm.mlir.constant(dense<-108> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg0 : vector<2xi8> + %3 = llvm.lshr %2, %1 : vector<2xi8> + %4 = llvm.trunc %3 : vector<2xi8> to vector<2xi6> + llvm.return %4 : vector<2xi6> + } + llvm.func @shl_lshr_demand5_undef_left(%arg0: vector<2xi8>) -> vector<2xi6> { + %0 = llvm.mlir.constant(-108 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %8 = llvm.shl %6, %arg0 : vector<2xi8> + %9 = llvm.lshr %8, %7 : vector<2xi8> + %10 = llvm.trunc %9 : vector<2xi8> to vector<2xi6> + llvm.return %10 : vector<2xi6> + } + llvm.func @shl_lshr_demand5_undef_right(%arg0: vector<2xi8>) -> vector<2xi6> { + %0 = llvm.mlir.constant(dense<-108> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.shl %0, %arg0 : vector<2xi8> + %9 = llvm.lshr %8, %7 : vector<2xi8> + %10 = llvm.trunc %9 : vector<2xi8> to vector<2xi6> + llvm.return %10 : vector<2xi6> + } + llvm.func @shl_lshr_demand5_nonuniform_vec_left(%arg0: vector<2xi8>) -> vector<2xi6> { + %0 = llvm.mlir.constant(dense<-108> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg0 : vector<2xi8> + %3 = llvm.lshr %2, %1 : vector<2xi8> + %4 = llvm.trunc %3 : vector<2xi8> to vector<2xi6> + llvm.return %4 : vector<2xi6> + } + llvm.func @shl_lshr_demand5_nonuniform_vec_right(%arg0: vector<2xi8>) -> vector<2xi6> { + %0 = llvm.mlir.constant(dense<[-108, -112]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg0 : vector<2xi8> + %3 = llvm.lshr %2, %1 : vector<2xi8> + %4 = llvm.trunc %3 : vector<2xi8> to vector<2xi6> + llvm.return %4 : vector<2xi6> + } + llvm.func @shl_lshr_demand5_nonuniform_vec_both(%arg0: vector<2xi8>) -> vector<2xi6> { + %0 = llvm.mlir.constant(dense<[-104, -108]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[3, 2]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg0 : vector<2xi8> + %3 = llvm.lshr %2, %1 : vector<2xi8> + %4 = llvm.trunc %3 : vector<2xi8> to vector<2xi6> + llvm.return %4 : vector<2xi6> + } + llvm.func @shl_lshr_demand6(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(-32624 : i16) : i16 + %1 = llvm.mlir.constant(4 : i16) : i16 + %2 = llvm.mlir.constant(4094 : i16) : i16 + %3 = llvm.shl %0, %arg0 : i16 + %4 = llvm.lshr %3, %1 : i16 + %5 = llvm.and %4, %2 : i16 + llvm.return %5 : i16 + } + llvm.func @lshr_shl_demand1(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(28 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.lshr %0, %arg0 : i8 + %4 = llvm.shl %3, %1 : i8 + %5 = llvm.or %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_shl_demand2(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(28 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(-16 : i8) : i8 + %3 = llvm.lshr %0, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.shl %3, %1 : i8 + %5 = llvm.and %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_shl_demand3(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(28 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %0, %arg0 : i8 + %3 = llvm.shl %2, %1 : i8 + %4 = llvm.or %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @lshr_shl_demand4(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(60 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.lshr %0, %arg0 : i8 + %4 = llvm.shl %3, %1 : i8 + %5 = llvm.or %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_shl_demand5(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<45> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<108> : vector<2xi8>) : vector<2xi8> + %3 = llvm.lshr %0, %arg0 : vector<2xi8> + %4 = llvm.shl %3, %1 : vector<2xi8> + %5 = llvm.and %4, %2 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @lshr_shl_demand5_undef_left(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<45> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.undef : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mlir.constant(dense<108> : vector<2xi8>) : vector<2xi8> + %9 = llvm.lshr %0, %arg0 : vector<2xi8> + %10 = llvm.shl %9, %7 : vector<2xi8> + %11 = llvm.and %10, %8 : vector<2xi8> + llvm.return %11 : vector<2xi8> + } + llvm.func @lshr_shl_demand5_undef_right(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(45 : i8) : i8 + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %8 = llvm.mlir.constant(dense<108> : vector<2xi8>) : vector<2xi8> + %9 = llvm.lshr %6, %arg0 : vector<2xi8> + %10 = llvm.shl %9, %7 : vector<2xi8> + %11 = llvm.and %10, %8 : vector<2xi8> + llvm.return %11 : vector<2xi8> + } + llvm.func @lshr_shl_demand5_nonuniform_vec_left(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<45> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<108> : vector<2xi8>) : vector<2xi8> + %3 = llvm.lshr %0, %arg0 : vector<2xi8> + %4 = llvm.shl %3, %1 : vector<2xi8> + %5 = llvm.and %4, %2 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @lshr_shl_demand5_nonuniform_vec_right(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[45, 13]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<108> : vector<2xi8>) : vector<2xi8> + %3 = llvm.lshr %0, %arg0 : vector<2xi8> + %4 = llvm.shl %3, %1 : vector<2xi8> + %5 = llvm.and %4, %2 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @lshr_shl_demand5_nonuniform_vec_both(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[45, 13]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[2, 4]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<[-4, -16]> : vector<2xi8>) : vector<2xi8> + %3 = llvm.lshr %0, %arg0 : vector<2xi8> + %4 = llvm.shl %3, %1 : vector<2xi8> + %5 = llvm.and %4, %2 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @ashr_ashr_constexpr() -> i64 { + %0 = llvm.mlir.addressof @g : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(2 : i64) : i64 + %4 = llvm.ashr %1, %2 : i64 + %5 = llvm.ashr %4, %3 : i64 + llvm.return %5 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/shift-sra.ll.mlir b/test/LLVMDialect/InstCombine/shift-sra.ll.mlir index b6ace0036..68affa435 100644 --- a/test/LLVMDialect/InstCombine/shift-sra.ll.mlir +++ b/test/LLVMDialect/InstCombine/shift-sra.ll.mlir @@ -1,128 +1,114 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %2 = "llvm.zext"(%arg0) : (i8) -> i32 - %3 = "llvm.add"(%2, %1) : (i32, i32) -> i32 - %4 = "llvm.ashr"(%3, %0) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i64, %arg2: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 12 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 63 : i64} : () -> i64 - "llvm.cond_br"(%arg2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.ashr %arg0, %1 : i32 + %3 = llvm.and %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @test2(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.add %2, %0 : i32 + %4 = llvm.ashr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @test3(%arg0: i1, %arg1: i64, %arg2: i1) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(12 : i64) : i64 + llvm.cond_br %arg2, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %2 = "llvm.sext"(%arg0) : (i1) -> i64 - "llvm.br"(%2)[^bb3] : (i64) -> () + %2 = llvm.sext %arg0 : i1 to i64 + llvm.br ^bb3(%2 : i64) ^bb2: // pred: ^bb0 - %3 = "llvm.ashr"(%arg1, %1) : (i64, i64) -> i64 - "llvm.br"(%3)[^bb3] : (i64) -> () + %3 = llvm.ashr %arg1, %0 : i64 + llvm.br ^bb3(%3 : i64) ^bb3(%4: i64): // 2 preds: ^bb1, ^bb2 - %5 = "llvm.ashr"(%4, %0) : (i64, i64) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i64, %arg2: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 12 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 63 : i64} : () -> i64 - "llvm.cond_br"(%arg2)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %5 = llvm.ashr %4, %1 : i64 + llvm.return %5 : i64 + } + llvm.func @test4(%arg0: i1, %arg1: i64, %arg2: i1) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(12 : i64) : i64 + llvm.cond_br %arg2, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - %2 = "llvm.sext"(%arg0) : (i1) -> i64 - "llvm.br"(%2)[^bb3] : (i64) -> () + %2 = llvm.sext %arg0 : i1 to i64 + llvm.br ^bb3(%2 : i64) ^bb2: // pred: ^bb0 - %3 = "llvm.ashr"(%arg1, %1) : (i64, i64) -> i64 - "llvm.br"(%3)[^bb3] : (i64) -> () + %3 = llvm.ashr %arg1, %0 : i64 + llvm.br ^bb3(%3 : i64) ^bb3(%4: i64): // 2 preds: ^bb1, ^bb2 - %5 = "llvm.shl"(%4, %0) : (i64, i64) -> i64 - %6 = "llvm.ashr"(%5, %0) : (i64, i64) -> i64 - "llvm.return"(%6) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i1, %arg2: i1, %arg3: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.cond_br"(%arg1)[^bb1, ^bb3] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %5 = llvm.shl %4, %1 : i64 + %6 = llvm.ashr %5, %1 : i64 + llvm.return %6 : i64 + } + llvm.func @test5(%arg0: i32, %arg1: i1, %arg2: i1, %arg3: i1) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + llvm.cond_br %arg1, ^bb1, ^bb3 ^bb1: // pred: ^bb0 - "llvm.cond_br"(%arg2, %1)[^bb2, ^bb4] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i32) -> () + llvm.cond_br %arg2, ^bb2, ^bb4(%0 : i32) ^bb2: // pred: ^bb1 - "llvm.br"(%1)[^bb4] : (i32) -> () + llvm.br ^bb4(%0 : i32) ^bb3: // pred: ^bb0 - "llvm.cond_br"(%arg3, %arg0)[^bb4, ^bb5] {operand_segment_sizes = dense<[1, 1, 0]> : vector<3xi32>} : (i1, i32) -> () + llvm.cond_br %arg3, ^bb4(%arg0 : i32), ^bb5 ^bb4(%2: i32): // 3 preds: ^bb1, ^bb2, ^bb3 - %3 = "llvm.ashr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 ^bb5: // pred: ^bb3 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "ashr_ashr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 17 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 15 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "ashr_overshift", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<7> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.mlir.constant"() {value = dense<5> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.ashr"(%2, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%3) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "ashr_ashr_splat_vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<17> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.mlir.constant"() {value = dense<15> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.ashr"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.ashr"(%2, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%3) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "ashr_overshift_splat_vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.sext"(%arg0) : (i8) -> i32 - %2 = "llvm.ashr"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "hoist_ashr_ahead_of_sext_1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<3> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sext"(%arg0) : (vector<2xi8>) -> vector<2xi32> - %2 = "llvm.ashr"(%1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "hoist_ashr_ahead_of_sext_1_splat", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.sext"(%arg0) : (i8) -> i32 - %2 = "llvm.ashr"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "hoist_ashr_ahead_of_sext_2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<8> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sext"(%arg0) : (vector<2xi8>) -> vector<2xi32> - %2 = "llvm.ashr"(%1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "hoist_ashr_ahead_of_sext_2_splat", type = !llvm.func (vector<2xi8>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %0 : i32 + } + llvm.func @ashr_ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(7 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_overshift(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(17 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.ashr %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @ashr_ashr_splat_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<7> : vector<2xi32>) : vector<2xi32> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.ashr %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @ashr_overshift_splat_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<17> : vector<2xi32>) : vector<2xi32> + %2 = llvm.ashr %arg0, %0 : vector<2xi32> + %3 = llvm.ashr %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @hoist_ashr_ahead_of_sext_1(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.ashr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @hoist_ashr_ahead_of_sext_1_splat(%arg0: vector<2xi8>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.ashr %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @hoist_ashr_ahead_of_sext_2(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.ashr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @hoist_ashr_ahead_of_sext_2_splat(%arg0: vector<2xi8>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.ashr %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/shift.ll.mlir b/test/LLVMDialect/InstCombine/shift.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/shl-and-negC-icmpeq-zero.ll.mlir b/test/LLVMDialect/InstCombine/shl-and-negC-icmpeq-zero.ll.mlir new file mode 100644 index 000000000..865110df2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shl-and-negC-icmpeq-zero.ll.mlir @@ -0,0 +1,180 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @scalar_i8_shl_and_negC_eq(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-4 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %arg0, %arg1 : i8 + %3 = llvm.and %2, %0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @scalar_i16_shl_and_negC_eq(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(-128 : i16) : i16 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.shl %arg0, %arg1 : i16 + %3 = llvm.and %2, %0 : i16 + %4 = llvm.icmp "eq" %3, %1 : i16 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_shl_and_negC_eq(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-262144 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @scalar_i64_shl_and_negC_eq(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(-8589934592 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.shl %arg0, %arg1 : i64 + %3 = llvm.and %2, %0 : i64 + %4 = llvm.icmp "eq" %3, %1 : i64 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_shl_and_negC_ne(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-262144 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @vec_4xi32_shl_and_negC_eq(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<-8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %3 = llvm.shl %arg0, %arg1 : vector<4xi32> + %4 = llvm.and %3, %0 : vector<4xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<4xi32> + llvm.return %5 : vector<4xi1> + } + llvm.func @vec_shl_and_negC_eq_poison1(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %13 = llvm.shl %arg0, %arg1 : vector<4xi32> + %14 = llvm.and %13, %10 : vector<4xi32> + %15 = llvm.icmp "eq" %14, %12 : vector<4xi32> + llvm.return %15 : vector<4xi1> + } + llvm.func @vec_shl_and_negC_eq_poison2(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<-8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %2, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<4xi32> + %12 = llvm.shl %arg0, %arg1 : vector<4xi32> + %13 = llvm.and %12, %0 : vector<4xi32> + %14 = llvm.icmp "eq" %13, %11 : vector<4xi32> + llvm.return %14 : vector<4xi1> + } + llvm.func @vec_shl_and_negC_eq_poison3(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.mlir.undef : vector<4xi32> + %13 = llvm.mlir.constant(0 : i32) : i32 + %14 = llvm.insertelement %11, %12[%13 : i32] : vector<4xi32> + %15 = llvm.mlir.constant(1 : i32) : i32 + %16 = llvm.insertelement %11, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(2 : i32) : i32 + %18 = llvm.insertelement %11, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(3 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.shl %arg0, %arg1 : vector<4xi32> + %22 = llvm.and %21, %10 : vector<4xi32> + %23 = llvm.icmp "eq" %22, %20 : vector<4xi32> + llvm.return %23 : vector<4xi1> + } + llvm.func @scalar_shl_and_negC_eq_extra_use_shl(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.xor %2, %arg2 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.and %2, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_shl_and_negC_eq_extra_use_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.mul %3, %arg2 : i32 + llvm.store %4, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_shl_and_negC_eq_extra_use_shl_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr, %arg4: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.add %2, %arg2 : i32 + llvm.store %4, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_shl_and_negC_eq_X_is_constant1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12345 : i32) : i32 + %1 = llvm.mlir.constant(-8 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_shl_and_negC_eq_X_is_constant2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-8 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_shl_and_negC_slt(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_shl_and_negC_eq_nonzero(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-8 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/shl-and-signbit-icmpeq-zero.ll.mlir b/test/LLVMDialect/InstCombine/shl-and-signbit-icmpeq-zero.ll.mlir new file mode 100644 index 000000000..1341ae382 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shl-and-signbit-icmpeq-zero.ll.mlir @@ -0,0 +1,180 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @scalar_i8_shl_and_signbit_eq(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %arg0, %arg1 : i8 + %3 = llvm.and %2, %0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @scalar_i16_shl_and_signbit_eq(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(-32768 : i16) : i16 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.shl %arg0, %arg1 : i16 + %3 = llvm.and %2, %0 : i16 + %4 = llvm.icmp "eq" %3, %1 : i16 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_shl_and_signbit_eq(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @scalar_i64_shl_and_signbit_eq(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.shl %arg0, %arg1 : i64 + %3 = llvm.and %2, %0 : i64 + %4 = llvm.icmp "eq" %3, %1 : i64 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_shl_and_signbit_ne(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @vec_4xi32_shl_and_signbit_eq(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %3 = llvm.shl %arg0, %arg1 : vector<4xi32> + %4 = llvm.and %3, %0 : vector<4xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<4xi32> + llvm.return %5 : vector<4xi1> + } + llvm.func @vec_4xi32_shl_and_signbit_eq_poison1(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %13 = llvm.shl %arg0, %arg1 : vector<4xi32> + %14 = llvm.and %13, %10 : vector<4xi32> + %15 = llvm.icmp "eq" %14, %12 : vector<4xi32> + llvm.return %15 : vector<4xi1> + } + llvm.func @vec_4xi32_shl_and_signbit_eq_poison2(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<4xi32> + %12 = llvm.shl %arg0, %arg1 : vector<4xi32> + %13 = llvm.and %12, %0 : vector<4xi32> + %14 = llvm.icmp "eq" %13, %11 : vector<4xi32> + llvm.return %14 : vector<4xi1> + } + llvm.func @vec_4xi32_shl_and_signbit_eq_poison3(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.mlir.undef : vector<4xi32> + %13 = llvm.mlir.constant(0 : i32) : i32 + %14 = llvm.insertelement %11, %12[%13 : i32] : vector<4xi32> + %15 = llvm.mlir.constant(1 : i32) : i32 + %16 = llvm.insertelement %11, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(2 : i32) : i32 + %18 = llvm.insertelement %11, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(3 : i32) : i32 + %20 = llvm.insertelement %1, %18[%19 : i32] : vector<4xi32> + %21 = llvm.shl %arg0, %arg1 : vector<4xi32> + %22 = llvm.and %21, %10 : vector<4xi32> + %23 = llvm.icmp "eq" %22, %20 : vector<4xi32> + llvm.return %23 : vector<4xi1> + } + llvm.func @scalar_shl_and_signbit_eq_extra_use_shl(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.xor %2, %arg2 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.and %2, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_shl_and_signbit_eq_extra_use_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.mul %3, %arg2 : i32 + llvm.store %4, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_shl_and_signbit_eq_extra_use_shl_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr, %arg4: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.add %2, %arg2 : i32 + llvm.store %4, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_shl_and_signbit_eq_X_is_constant1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12345 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_shl_and_signbit_eq_X_is_constant2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_shl_and_signbit_slt(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_shl_and_signbit_eq_nonzero(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.shl %arg0, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/shl-bo.ll.mlir b/test/LLVMDialect/InstCombine/shl-bo.ll.mlir new file mode 100644 index 000000000..8b444165f --- /dev/null +++ b/test/LLVMDialect/InstCombine/shl-bo.ll.mlir @@ -0,0 +1,444 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @lshr_add(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.srem %arg0, %0 : i8 + %3 = llvm.lshr %arg1, %1 : i8 + %4 = llvm.add %3, %2 : i8 + %5 = llvm.shl %4, %1 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_add_commute_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %2 = llvm.srem %arg0, %0 : vector<2xi8> + %3 = llvm.lshr %arg1, %1 : vector<2xi8> + %4 = llvm.add %2, %3 : vector<2xi8> + %5 = llvm.shl %4, %1 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @lshr_sub(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.srem %arg0, %0 : i8 + %3 = llvm.lshr %arg1, %1 : i8 + %4 = llvm.sub %2, %3 : i8 + %5 = llvm.shl %4, %1 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_sub_commute_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %2 = llvm.srem %arg0, %0 : vector<2xi8> + %3 = llvm.lshr %arg1, %1 : vector<2xi8> + %4 = llvm.sub %3, %2 : vector<2xi8> + %5 = llvm.shl %4, %1 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @lshr_and(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.srem %arg0, %0 : i8 + %3 = llvm.lshr %arg1, %1 : i8 + %4 = llvm.and %3, %2 : i8 + %5 = llvm.shl %4, %1 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_and_commute_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<6> : vector<2xi8>) : vector<2xi8> + %2 = llvm.srem %arg0, %0 : vector<2xi8> + %3 = llvm.lshr %arg1, %1 : vector<2xi8> + %4 = llvm.and %2, %3 : vector<2xi8> + %5 = llvm.shl %4, %1 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @lshr_or(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.srem %arg0, %0 : i8 + %3 = llvm.lshr %arg1, %1 : i8 + %4 = llvm.or %2, %3 : i8 + %5 = llvm.shl %4, %1 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_or_commute_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<4> : vector<2xi8>) : vector<2xi8> + %2 = llvm.srem %arg0, %0 : vector<2xi8> + %3 = llvm.lshr %arg1, %1 : vector<2xi8> + %4 = llvm.or %3, %2 : vector<2xi8> + %5 = llvm.shl %4, %1 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @lshr_xor(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.srem %arg0, %0 : i8 + %3 = llvm.lshr %arg1, %1 : i8 + %4 = llvm.xor %3, %2 : i8 + %5 = llvm.shl %4, %1 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_xor_commute_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %2 = llvm.srem %arg0, %0 : vector<2xi8> + %3 = llvm.lshr %arg1, %1 : vector<2xi8> + %4 = llvm.xor %2, %3 : vector<2xi8> + %5 = llvm.shl %4, %1 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @lshr_add_use1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.lshr %arg1, %0 : i8 + llvm.call @use(%1) : (i8) -> () + %2 = llvm.add %1, %arg0 : i8 + %3 = llvm.shl %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @lshr_add_use2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.lshr %arg1, %0 : i8 + %2 = llvm.add %1, %arg0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.shl %2, %0 : i8 + llvm.return %3 : i8 + } + llvm.func @lshr_and_add(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(12 : i8) : i8 + %3 = llvm.srem %arg0, %0 : i8 + %4 = llvm.lshr %arg1, %1 : i8 + %5 = llvm.and %4, %2 : i8 + %6 = llvm.add %3, %5 : i8 + %7 = llvm.shl %6, %1 : i8 + llvm.return %7 : i8 + } + llvm.func @lshr_and_add_commute_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<12> : vector<2xi8>) : vector<2xi8> + %3 = llvm.srem %arg0, %0 : vector<2xi8> + %4 = llvm.lshr %arg1, %1 : vector<2xi8> + %5 = llvm.and %4, %2 : vector<2xi8> + %6 = llvm.add %5, %3 : vector<2xi8> + %7 = llvm.shl %6, %1 : vector<2xi8> + llvm.return %7 : vector<2xi8> + } + llvm.func @lshr_and_sub(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(13 : i8) : i8 + %3 = llvm.srem %arg0, %0 : i8 + %4 = llvm.lshr %arg1, %1 : i8 + %5 = llvm.and %4, %2 : i8 + %6 = llvm.sub %3, %5 : i8 + %7 = llvm.shl %6, %1 : i8 + llvm.return %7 : i8 + } + llvm.func @lshr_and_sub_commute_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<13> : vector<2xi8>) : vector<2xi8> + %3 = llvm.srem %arg0, %0 : vector<2xi8> + %4 = llvm.lshr %arg1, %1 : vector<2xi8> + %5 = llvm.and %4, %2 : vector<2xi8> + %6 = llvm.sub %5, %3 : vector<2xi8> + %7 = llvm.shl %6, %1 : vector<2xi8> + llvm.return %7 : vector<2xi8> + } + llvm.func @lshr_and_and(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(13 : i8) : i8 + %3 = llvm.srem %arg0, %0 : i8 + %4 = llvm.lshr %arg1, %1 : i8 + %5 = llvm.and %4, %2 : i8 + %6 = llvm.and %5, %3 : i8 + %7 = llvm.shl %6, %1 : i8 + llvm.return %7 : i8 + } + llvm.func @lshr_and_and_commute_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<13> : vector<2xi8>) : vector<2xi8> + %3 = llvm.srem %arg0, %0 : vector<2xi8> + %4 = llvm.lshr %arg1, %1 : vector<2xi8> + %5 = llvm.and %4, %2 : vector<2xi8> + %6 = llvm.and %3, %5 : vector<2xi8> + %7 = llvm.shl %6, %1 : vector<2xi8> + llvm.return %7 : vector<2xi8> + } + llvm.func @lshr_and_or(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(13 : i8) : i8 + %3 = llvm.srem %arg0, %0 : i8 + %4 = llvm.lshr %arg1, %1 : i8 + %5 = llvm.and %4, %2 : i8 + %6 = llvm.or %3, %5 : i8 + %7 = llvm.shl %6, %1 : i8 + llvm.return %7 : i8 + } + llvm.func @lshr_and_or_disjoint(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(13 : i8) : i8 + %3 = llvm.srem %arg0, %0 : i8 + %4 = llvm.lshr %arg1, %1 : i8 + %5 = llvm.and %4, %2 : i8 + %6 = llvm.or %3, %5 : i8 + %7 = llvm.shl %6, %1 : i8 + llvm.return %7 : i8 + } + llvm.func @ashr_and_or_disjoint(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(13 : i8) : i8 + %3 = llvm.srem %arg0, %0 : i8 + %4 = llvm.ashr %arg1, %1 : i8 + %5 = llvm.and %4, %2 : i8 + %6 = llvm.or %3, %5 : i8 + %7 = llvm.shl %6, %1 : i8 + llvm.return %7 : i8 + } + llvm.func @lshr_and_or_commute_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<13> : vector<2xi8>) : vector<2xi8> + %3 = llvm.srem %arg0, %0 : vector<2xi8> + %4 = llvm.lshr %arg1, %1 : vector<2xi8> + %5 = llvm.and %4, %2 : vector<2xi8> + %6 = llvm.or %5, %3 : vector<2xi8> + %7 = llvm.shl %6, %1 : vector<2xi8> + llvm.return %7 : vector<2xi8> + } + llvm.func @lshr_and_xor(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(13 : i8) : i8 + %3 = llvm.srem %arg0, %0 : i8 + %4 = llvm.lshr %arg1, %1 : i8 + %5 = llvm.and %4, %2 : i8 + %6 = llvm.xor %5, %3 : i8 + %7 = llvm.shl %6, %1 : i8 + llvm.return %7 : i8 + } + llvm.func @lshr_and_xor_commute_splat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<2> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<13> : vector<2xi8>) : vector<2xi8> + %3 = llvm.srem %arg0, %0 : vector<2xi8> + %4 = llvm.lshr %arg1, %1 : vector<2xi8> + %5 = llvm.and %4, %2 : vector<2xi8> + %6 = llvm.xor %3, %5 : vector<2xi8> + %7 = llvm.shl %6, %1 : vector<2xi8> + llvm.return %7 : vector<2xi8> + } + llvm.func @lshr_and_add_use1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(12 : i8) : i8 + %2 = llvm.lshr %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.and %2, %1 : i8 + %4 = llvm.add %arg0, %3 : i8 + %5 = llvm.shl %4, %0 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_and_add_use2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(12 : i8) : i8 + %2 = llvm.lshr %arg1, %0 : i8 + %3 = llvm.and %2, %1 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.add %arg0, %3 : i8 + %5 = llvm.shl %4, %0 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_and_add_use3(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(12 : i8) : i8 + %2 = llvm.lshr %arg1, %0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.add %arg0, %3 : i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.shl %4, %0 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_and_add_use4(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(12 : i8) : i8 + %2 = llvm.lshr %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.and %2, %1 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.add %arg0, %3 : i8 + %5 = llvm.shl %4, %0 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_and_add_use5(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(12 : i8) : i8 + %2 = llvm.lshr %arg1, %0 : i8 + %3 = llvm.and %2, %1 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.add %arg0, %3 : i8 + llvm.call @use(%4) : (i8) -> () + %5 = llvm.shl %4, %0 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_and_add_use6(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(12 : i8) : i8 + %2 = llvm.lshr %arg1, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.and %2, %1 : i8 + llvm.call @use(%3) : (i8) -> () + %4 = llvm.add %arg0, %3 : i8 + %5 = llvm.shl %4, %0 : i8 + llvm.return %5 : i8 + } + llvm.func @lshr_add_shl_v2i8_undef(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.undef : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.undef : vector<2xi8> + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<2xi8> + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<2xi8> + %12 = llvm.lshr %arg1, %6 : vector<2xi8> + %13 = llvm.add %12, %arg0 : vector<2xi8> + %14 = llvm.shl %13, %11 : vector<2xi8> + llvm.return %14 : vector<2xi8> + } + llvm.func @lshr_add_shl_v2i8_nonuniform(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[5, 6]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.lshr %arg1, %0 : vector<2xi8> + %2 = llvm.add %1, %arg0 : vector<2xi8> + %3 = llvm.shl %2, %0 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @lshr_add_and_shl(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(127 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.add %arg1, %3 : i32 + %5 = llvm.shl %4, %0 : i32 + llvm.return %5 : i32 + } + llvm.func @lshr_add_and_shl_v2i32(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<127> : vector<2xi32>) : vector<2xi32> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.and %2, %1 : vector<2xi32> + %4 = llvm.add %arg1, %3 : vector<2xi32> + %5 = llvm.shl %4, %0 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @lshr_add_and_shl_v2i32_undef(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<127> : vector<2xi32>) : vector<2xi32> + %8 = llvm.mlir.undef : vector<2xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<2xi32> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %1, %10[%11 : i32] : vector<2xi32> + %13 = llvm.lshr %arg0, %6 : vector<2xi32> + %14 = llvm.and %13, %7 : vector<2xi32> + %15 = llvm.add %arg1, %14 : vector<2xi32> + %16 = llvm.shl %15, %12 : vector<2xi32> + llvm.return %16 : vector<2xi32> + } + llvm.func @lshr_add_and_shl_v2i32_nonuniform(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[5, 6]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[127, 255]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.and %2, %1 : vector<2xi32> + %4 = llvm.add %arg1, %3 : vector<2xi32> + %5 = llvm.shl %4, %0 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @shl_add_and_lshr(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.add %3, %arg1 : i32 + %5 = llvm.shl %4, %0 : i32 + llvm.return %5 : i32 + } + llvm.func @shl_add_and_lshr_v2i32(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.and %2, %1 : vector<2xi32> + %4 = llvm.add %3, %arg1 : vector<2xi32> + %5 = llvm.shl %4, %0 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @shl_add_and_lshr_v2i32_undef(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(8 : i32) : i32 + %8 = llvm.mlir.undef : vector<2xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi32> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi32> + %13 = llvm.lshr %arg0, %6 : vector<2xi32> + %14 = llvm.and %13, %12 : vector<2xi32> + %15 = llvm.add %14, %arg1 : vector<2xi32> + %16 = llvm.shl %15, %6 : vector<2xi32> + llvm.return %16 : vector<2xi32> + } + llvm.func @shl_add_and_lshr_v2i32_nonuniform(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[4, 5]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[8, 9]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.lshr %arg0, %0 : vector<2xi32> + %3 = llvm.and %2, %1 : vector<2xi32> + %4 = llvm.add %3, %arg1 : vector<2xi32> + %5 = llvm.shl %4, %0 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test_FoldShiftByConstant_CreateSHL(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[0, -1, 0, -1]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<5> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 : vector<4xi32> + %3 = llvm.shl %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_FoldShiftByConstant_CreateSHL2(%arg0: vector<8xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(dense<[0, -1, 0, -1, 0, -1, 0, -1]> : vector<8xi16>) : vector<8xi16> + %1 = llvm.mlir.constant(dense<5> : vector<8xi16>) : vector<8xi16> + %2 = llvm.mul %arg0, %0 : vector<8xi16> + %3 = llvm.shl %2, %1 : vector<8xi16> + llvm.return %3 : vector<8xi16> + } + llvm.func @test_FoldShiftByConstant_CreateAnd(%arg0: vector<16xi8>) -> vector<16xi8> { + %0 = llvm.mlir.constant(dense<5> : vector<16xi8>) : vector<16xi8> + %1 = llvm.ashr %arg0, %0 : vector<16xi8> + %2 = llvm.add %arg0, %1 : vector<16xi8> + %3 = llvm.shl %2, %0 : vector<16xi8> + llvm.return %3 : vector<16xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/shl-demand.ll.mlir b/test/LLVMDialect/InstCombine/shl-demand.ll.mlir index 2e277a5ca..73e5fb615 100644 --- a/test/LLVMDialect/InstCombine/shl-demand.ll.mlir +++ b/test/LLVMDialect/InstCombine/shl-demand.ll.mlir @@ -1,69 +1,140 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.sext"(%arg0) : (i16) -> i32 - %1 = "llvm.shl"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i16 - "llvm.return"(%2) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "sext_shl_trunc_same_size", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.sext"(%arg0) : (i16) -> i32 - %1 = "llvm.shl"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i5 - "llvm.return"(%2) : (i5) -> () - }) {linkage = 10 : i64, sym_name = "sext_shl_trunc_smaller", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.sext"(%arg0) : (i16) -> i32 - %1 = "llvm.shl"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i17 - "llvm.return"(%2) : (i17) -> () - }) {linkage = 10 : i64, sym_name = "sext_shl_trunc_larger", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 65535 : i32} : () -> i32 - %1 = "llvm.sext"(%arg0) : (i16) -> i32 - %2 = "llvm.shl"(%1, %arg1) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sext_shl_mask", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 65536 : i32} : () -> i32 - %1 = "llvm.sext"(%arg0) : (i16) -> i32 - %2 = "llvm.shl"(%1, %arg1) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sext_shl_mask_higher", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 65536 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 196609 : i32} : () -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.shl"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.and"(%3, %0) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "set_shl_mask", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 255 : i32} : () -> i32 - %1 = "llvm.and"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.shl"(%1, %arg1) : (i32, i32) -> i32 - %3 = "llvm.trunc"(%2) : (i32) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "must_drop_poison", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i40): // no predecessors - %0 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 31 : i40} : () -> i40 - %3 = "llvm.ashr"(%arg0, %2) : (i40, i40) -> i40 - %4 = "llvm.trunc"(%3) : (i40) -> i32 - %5 = "llvm.shl"(%4, %1) : (i32, i32) -> i32 - %6 = "llvm.ashr"(%5, %1) : (i32, i32) -> i32 - %7 = "llvm.shl"(%6, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "f_t15_t01_t09", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @src_srem_shl_demand_max_signbit(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.mlir.constant(-2147483648 : i32) : i32 + %3 = llvm.srem %arg0, %0 : i32 + %4 = llvm.shl %3, %1 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @src_srem_shl_demand_min_signbit(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-2147483648 : i32) : i32 + %3 = llvm.srem %arg0, %0 : i32 + %4 = llvm.shl %3, %1 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @src_srem_shl_demand_max_mask(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-4 : i32) : i32 + %3 = llvm.srem %arg0, %0 : i32 + %4 = llvm.shl %3, %1 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @src_srem_shl_demand_max_signbit_mask_hit_first_demand(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(29 : i32) : i32 + %2 = llvm.mlir.constant(-1073741824 : i32) : i32 + %3 = llvm.srem %arg0, %0 : i32 + %4 = llvm.shl %3, %1 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @src_srem_shl_demand_min_signbit_mask_hit_last_demand(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(536870912 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-1073741822 : i32) : i32 + %3 = llvm.srem %arg0, %0 : i32 + %4 = llvm.shl %3, %1 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @src_srem_shl_demand_eliminate_signbit(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1073741824 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.srem %arg0, %0 : i32 + %4 = llvm.shl %3, %1 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @src_srem_shl_demand_max_mask_hit_demand(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(-4 : i32) : i32 + %3 = llvm.srem %arg0, %0 : i32 + %4 = llvm.shl %3, %1 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @src_srem_shl_mask_vector(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<29> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-1073741824> : vector<2xi32>) : vector<2xi32> + %3 = llvm.srem %arg0, %0 : vector<2xi32> + %4 = llvm.shl %3, %1 : vector<2xi32> + %5 = llvm.and %4, %2 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @src_srem_shl_mask_vector_nonconstant(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1073741824> : vector<2xi32>) : vector<2xi32> + %2 = llvm.srem %arg0, %0 : vector<2xi32> + %3 = llvm.shl %2, %arg1 : vector<2xi32> + %4 = llvm.and %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @sext_shl_trunc_same_size(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @sext_shl_trunc_smaller(%arg0: i16, %arg1: i32) -> i5 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i5 + llvm.return %2 : i5 + } + llvm.func @sext_shl_trunc_larger(%arg0: i16, %arg1: i32) -> i17 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i17 + llvm.return %2 : i17 + } + llvm.func @sext_shl_mask(%arg0: i16, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.sext %arg0 : i16 to i32 + %2 = llvm.shl %1, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @sext_shl_mask_higher(%arg0: i16, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(65536 : i32) : i32 + %1 = llvm.sext %arg0 : i16 to i32 + %2 = llvm.shl %1, %arg1 : i32 + %3 = llvm.and %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @set_shl_mask(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(196609 : i32) : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.shl %2, %arg1 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @must_drop_poison(%arg0: i32, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.shl %1, %arg1 overflow : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @f_t15_t01_t09(%arg0: i40) -> i32 { + %0 = llvm.mlir.constant(31 : i40) : i40 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.constant(31 : i32) : i32 + %3 = llvm.ashr %arg0, %0 : i40 + %4 = llvm.trunc %3 : i40 to i32 + %5 = llvm.shl %4, %1 : i32 + %6 = llvm.ashr %5, %1 : i32 + %7 = llvm.shl %6, %2 : i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/shl-factor.ll.mlir b/test/LLVMDialect/InstCombine/shl-factor.ll.mlir index 9b1d9530c..7a5a59e2a 100644 --- a/test/LLVMDialect/InstCombine/shl-factor.ll.mlir +++ b/test/LLVMDialect/InstCombine/shl-factor.ll.mlir @@ -1,153 +1,131 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i6, %arg1: i6, %arg2: i6): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i6, i6) -> i6 - %1 = "llvm.shl"(%arg1, %arg2) : (i6, i6) -> i6 - %2 = "llvm.add"(%0, %1) : (i6, i6) -> i6 - "llvm.return"(%2) : (i6) -> () - }) {linkage = 10 : i64, sym_name = "add_shl_same_amount", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (vector<2xi4>, vector<2xi4>) -> vector<2xi4> - %1 = "llvm.shl"(%arg1, %arg2) : (vector<2xi4>, vector<2xi4>) -> vector<2xi4> - %2 = "llvm.add"(%0, %1) : (vector<2xi4>, vector<2xi4>) -> vector<2xi4> - "llvm.return"(%2) : (vector<2xi4>) -> () - }) {linkage = 10 : i64, sym_name = "add_shl_same_amount_nsw", type = !llvm.func (vector<2xi4>, vector<2xi4>, vector<2xi4>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64, %arg2: i64): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i64, i64) -> i64 - %1 = "llvm.shl"(%arg1, %arg2) : (i64, i64) -> i64 - %2 = "llvm.add"(%0, %1) : (i64, i64) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "add_shl_same_amount_nuw", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.shl"(%arg1, %arg2) : (i8, i8) -> i8 - %2 = "llvm.add"(%0, %1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "add_shl_same_amount_nsw_extra_use1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i8, i8) -> i8 - %1 = "llvm.shl"(%arg1, %arg2) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.add"(%0, %1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "add_shl_same_amount_nuw_extra_use2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.shl"(%arg1, %arg2) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.add"(%0, %1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "add_shl_same_amount_nsw_nuw_extra_use3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i6, %arg1: i6, %arg2: i6): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i6, i6) -> i6 - %1 = "llvm.shl"(%arg1, %arg2) : (i6, i6) -> i6 - %2 = "llvm.add"(%0, %1) : (i6, i6) -> i6 - "llvm.return"(%2) : (i6) -> () - }) {linkage = 10 : i64, sym_name = "add_shl_same_amount_partial_nsw1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i6, %arg1: i6, %arg2: i6): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i6, i6) -> i6 - %1 = "llvm.shl"(%arg1, %arg2) : (i6, i6) -> i6 - %2 = "llvm.add"(%0, %1) : (i6, i6) -> i6 - "llvm.return"(%2) : (i6) -> () - }) {linkage = 10 : i64, sym_name = "add_shl_same_amount_partial_nsw2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i6, %arg1: i6, %arg2: i6): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i6, i6) -> i6 - %1 = "llvm.shl"(%arg1, %arg2) : (i6, i6) -> i6 - %2 = "llvm.add"(%0, %1) : (i6, i6) -> i6 - "llvm.return"(%2) : (i6) -> () - }) {linkage = 10 : i64, sym_name = "add_shl_same_amount_partial_nuw1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i6, %arg1: i6, %arg2: i6): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i6, i6) -> i6 - %1 = "llvm.shl"(%arg1, %arg2) : (i6, i6) -> i6 - %2 = "llvm.add"(%0, %1) : (i6, i6) -> i6 - "llvm.return"(%2) : (i6) -> () - }) {linkage = 10 : i64, sym_name = "add_shl_same_amount_partial_nuw2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i6, %arg1: i6, %arg2: i6): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i6, i6) -> i6 - %1 = "llvm.shl"(%arg1, %arg2) : (i6, i6) -> i6 - %2 = "llvm.sub"(%0, %1) : (i6, i6) -> i6 - "llvm.return"(%2) : (i6) -> () - }) {linkage = 10 : i64, sym_name = "sub_shl_same_amount", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (vector<2xi4>, vector<2xi4>) -> vector<2xi4> - %1 = "llvm.shl"(%arg1, %arg2) : (vector<2xi4>, vector<2xi4>) -> vector<2xi4> - %2 = "llvm.sub"(%0, %1) : (vector<2xi4>, vector<2xi4>) -> vector<2xi4> - "llvm.return"(%2) : (vector<2xi4>) -> () - }) {linkage = 10 : i64, sym_name = "sub_shl_same_amount_nsw", type = !llvm.func (vector<2xi4>, vector<2xi4>, vector<2xi4>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64, %arg2: i64): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i64, i64) -> i64 - %1 = "llvm.shl"(%arg1, %arg2) : (i64, i64) -> i64 - %2 = "llvm.sub"(%0, %1) : (i64, i64) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "sub_shl_same_amount_nuw", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.shl"(%arg1, %arg2) : (i8, i8) -> i8 - %2 = "llvm.sub"(%0, %1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "sub_shl_same_amount_nsw_extra_use1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i8, i8) -> i8 - %1 = "llvm.shl"(%arg1, %arg2) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.sub"(%0, %1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "sub_shl_same_amount_nuw_extra_use2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.shl"(%arg1, %arg2) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.sub"(%0, %1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "sub_shl_same_amount_nsw_nuw_extra_use3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i6, %arg1: i6, %arg2: i6): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i6, i6) -> i6 - %1 = "llvm.shl"(%arg1, %arg2) : (i6, i6) -> i6 - %2 = "llvm.sub"(%0, %1) : (i6, i6) -> i6 - "llvm.return"(%2) : (i6) -> () - }) {linkage = 10 : i64, sym_name = "sub_shl_same_amount_partial_nsw1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i6, %arg1: i6, %arg2: i6): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i6, i6) -> i6 - %1 = "llvm.shl"(%arg1, %arg2) : (i6, i6) -> i6 - %2 = "llvm.sub"(%0, %1) : (i6, i6) -> i6 - "llvm.return"(%2) : (i6) -> () - }) {linkage = 10 : i64, sym_name = "sub_shl_same_amount_partial_nsw2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i6, %arg1: i6, %arg2: i6): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i6, i6) -> i6 - %1 = "llvm.shl"(%arg1, %arg2) : (i6, i6) -> i6 - %2 = "llvm.sub"(%0, %1) : (i6, i6) -> i6 - "llvm.return"(%2) : (i6) -> () - }) {linkage = 10 : i64, sym_name = "sub_shl_same_amount_partial_nuw1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i6, %arg1: i6, %arg2: i6): // no predecessors - %0 = "llvm.shl"(%arg0, %arg2) : (i6, i6) -> i6 - %1 = "llvm.shl"(%arg1, %arg2) : (i6, i6) -> i6 - %2 = "llvm.sub"(%0, %1) : (i6, i6) -> i6 - "llvm.return"(%2) : (i6) -> () - }) {linkage = 10 : i64, sym_name = "sub_shl_same_amount_partial_nuw2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @add_shl_same_amount(%arg0: i6, %arg1: i6, %arg2: i6) -> i6 { + %0 = llvm.shl %arg0, %arg2 : i6 + %1 = llvm.shl %arg1, %arg2 : i6 + %2 = llvm.add %0, %1 : i6 + llvm.return %2 : i6 + } + llvm.func @add_shl_same_amount_nsw(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.shl %arg0, %arg2 overflow : vector<2xi4> + %1 = llvm.shl %arg1, %arg2 overflow : vector<2xi4> + %2 = llvm.add %0, %1 overflow : vector<2xi4> + llvm.return %2 : vector<2xi4> + } + llvm.func @add_shl_same_amount_nuw(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.shl %arg0, %arg2 overflow : i64 + %1 = llvm.shl %arg1, %arg2 overflow : i64 + %2 = llvm.add %0, %1 overflow : i64 + llvm.return %2 : i64 + } + llvm.func @add_shl_same_amount_nsw_extra_use1(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.shl %arg1, %arg2 overflow : i8 + %2 = llvm.add %0, %1 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @add_shl_same_amount_nuw_extra_use2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + %1 = llvm.shl %arg1, %arg2 overflow : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.add %0, %1 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @add_shl_same_amount_nsw_nuw_extra_use3(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.shl %arg1, %arg2 overflow : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.add %0, %1 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @add_shl_same_amount_partial_nsw1(%arg0: i6, %arg1: i6, %arg2: i6) -> i6 { + %0 = llvm.shl %arg0, %arg2 overflow : i6 + %1 = llvm.shl %arg1, %arg2 overflow : i6 + %2 = llvm.add %0, %1 : i6 + llvm.return %2 : i6 + } + llvm.func @add_shl_same_amount_partial_nsw2(%arg0: i6, %arg1: i6, %arg2: i6) -> i6 { + %0 = llvm.shl %arg0, %arg2 : i6 + %1 = llvm.shl %arg1, %arg2 overflow : i6 + %2 = llvm.add %0, %1 overflow : i6 + llvm.return %2 : i6 + } + llvm.func @add_shl_same_amount_partial_nuw1(%arg0: i6, %arg1: i6, %arg2: i6) -> i6 { + %0 = llvm.shl %arg0, %arg2 overflow : i6 + %1 = llvm.shl %arg1, %arg2 overflow : i6 + %2 = llvm.add %0, %1 : i6 + llvm.return %2 : i6 + } + llvm.func @add_shl_same_amount_partial_nuw2(%arg0: i6, %arg1: i6, %arg2: i6) -> i6 { + %0 = llvm.shl %arg0, %arg2 overflow : i6 + %1 = llvm.shl %arg1, %arg2 : i6 + %2 = llvm.add %0, %1 overflow : i6 + llvm.return %2 : i6 + } + llvm.func @sub_shl_same_amount(%arg0: i6, %arg1: i6, %arg2: i6) -> i6 { + %0 = llvm.shl %arg0, %arg2 : i6 + %1 = llvm.shl %arg1, %arg2 : i6 + %2 = llvm.sub %0, %1 : i6 + llvm.return %2 : i6 + } + llvm.func @sub_shl_same_amount_nsw(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.shl %arg0, %arg2 overflow : vector<2xi4> + %1 = llvm.shl %arg1, %arg2 overflow : vector<2xi4> + %2 = llvm.sub %0, %1 overflow : vector<2xi4> + llvm.return %2 : vector<2xi4> + } + llvm.func @sub_shl_same_amount_nuw(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.shl %arg0, %arg2 overflow : i64 + %1 = llvm.shl %arg1, %arg2 overflow : i64 + %2 = llvm.sub %0, %1 overflow : i64 + llvm.return %2 : i64 + } + llvm.func @sub_shl_same_amount_nsw_extra_use1(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.shl %arg1, %arg2 overflow : i8 + %2 = llvm.sub %0, %1 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @sub_shl_same_amount_nuw_extra_use2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + %1 = llvm.shl %arg1, %arg2 overflow : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %0, %1 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @sub_shl_same_amount_nsw_nuw_extra_use3(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.shl %arg0, %arg2 overflow : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.shl %arg1, %arg2 overflow : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %0, %1 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @sub_shl_same_amount_partial_nsw1(%arg0: i6, %arg1: i6, %arg2: i6) -> i6 { + %0 = llvm.shl %arg0, %arg2 overflow : i6 + %1 = llvm.shl %arg1, %arg2 overflow : i6 + %2 = llvm.sub %0, %1 : i6 + llvm.return %2 : i6 + } + llvm.func @sub_shl_same_amount_partial_nsw2(%arg0: i6, %arg1: i6, %arg2: i6) -> i6 { + %0 = llvm.shl %arg0, %arg2 : i6 + %1 = llvm.shl %arg1, %arg2 overflow : i6 + %2 = llvm.sub %0, %1 overflow : i6 + llvm.return %2 : i6 + } + llvm.func @sub_shl_same_amount_partial_nuw1(%arg0: i6, %arg1: i6, %arg2: i6) -> i6 { + %0 = llvm.shl %arg0, %arg2 overflow : i6 + %1 = llvm.shl %arg1, %arg2 overflow : i6 + %2 = llvm.sub %0, %1 : i6 + llvm.return %2 : i6 + } + llvm.func @sub_shl_same_amount_partial_nuw2(%arg0: i6, %arg1: i6, %arg2: i6) -> i6 { + %0 = llvm.shl %arg0, %arg2 overflow : i6 + %1 = llvm.shl %arg1, %arg2 : i6 + %2 = llvm.sub %0, %1 overflow : i6 + llvm.return %2 : i6 + } +} diff --git a/test/LLVMDialect/InstCombine/shl-sub.ll.mlir b/test/LLVMDialect/InstCombine/shl-sub.ll.mlir new file mode 100644 index 000000000..3b7dd18ec --- /dev/null +++ b/test/LLVMDialect/InstCombine/shl-sub.ll.mlir @@ -0,0 +1,169 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @shl_sub_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.shl %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_sub_multiuse_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.shl %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_sub_i8(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.shl %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @shl_sub_i64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.sub %0, %arg0 : i64 + %3 = llvm.shl %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @shl_sub_i64_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<63> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<1> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sub %0, %arg0 : vector<2xi64> + %3 = llvm.shl %1, %2 : vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @shl_sub_i64_vec_poison(%arg0: vector<3xi64>) -> vector<3xi64> { + %0 = llvm.mlir.constant(dense<63> : vector<3xi64>) : vector<3xi64> + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.poison : i64 + %3 = llvm.mlir.undef : vector<3xi64> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi64> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi64> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi64> + %10 = llvm.sub %0, %arg0 : vector<3xi64> + %11 = llvm.shl %9, %10 : vector<3xi64> + llvm.return %11 : vector<3xi64> + } + llvm.func @shl_bad_sub_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.shl %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @bad_shl_sub_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.shl %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_bad_sub2_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.sub %arg0, %0 : i32 + %3 = llvm.shl %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @bad_shl2_sub_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.sub %arg0, %0 : i32 + %3 = llvm.shl %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_bad_sub_i8(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.shl %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @shl_bad_sub_i64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(67 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.sub %0, %arg0 : i64 + %3 = llvm.shl %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @shl_bad_sub_i64_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<53> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<1> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sub %0, %arg0 : vector<2xi64> + %3 = llvm.shl %1, %2 : vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @bad_shl_sub_i64_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<63> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<2> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sub %0, %arg0 : vector<2xi64> + %3 = llvm.shl %1, %2 : vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @shl_sub_i64_vec_undef_bad(%arg0: vector<3xi64>) -> vector<3xi64> { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.undef : i64 + %2 = llvm.mlir.undef : vector<3xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi64> + %9 = llvm.mlir.constant(dense<1> : vector<3xi64>) : vector<3xi64> + %10 = llvm.sub %8, %arg0 : vector<3xi64> + %11 = llvm.shl %9, %10 : vector<3xi64> + llvm.return %11 : vector<3xi64> + } + llvm.func @shl_sub_i64_vec_poison_bad2(%arg0: vector<3xi64>) -> vector<3xi64> { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<3xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi64> + %9 = llvm.mlir.constant(1 : i64) : i64 + %10 = llvm.mlir.undef : vector<3xi64> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi64> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi64> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi64> + %17 = llvm.sub %8, %arg0 : vector<3xi64> + %18 = llvm.shl %16, %17 : vector<3xi64> + llvm.return %18 : vector<3xi64> + } + llvm.func @shl_const_op1_sub_const_op0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.shl %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @shl_const_op1_sub_const_op0_splat(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<3> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %0, %arg0 : vector<2xi32> + %3 = llvm.shl %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @shl_const_op1_sub_const_op0_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + llvm.call @use(%2) : (i32) -> () + %3 = llvm.shl %2, %1 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/shl-unsigned-cmp-const.ll.mlir b/test/LLVMDialect/InstCombine/shl-unsigned-cmp-const.ll.mlir new file mode 100644 index 000000000..d47d16cb7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shl-unsigned-cmp-const.ll.mlir @@ -0,0 +1,175 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @scalar_i8_shl_ult_const_1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @scalar_i8_shl_ult_const_2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @scalar_i8_shl_ult_const_3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @scalar_i16_shl_ult_const(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(1024 : i16) : i16 + %2 = llvm.shl %arg0, %0 : i16 + %3 = llvm.icmp "ult" %2, %1 : i16 + llvm.return %3 : i1 + } + llvm.func @scalar_i32_shl_ult_const(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(11 : i32) : i32 + %1 = llvm.mlir.constant(131072 : i32) : i32 + %2 = llvm.shl %arg0, %0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @scalar_i64_shl_ult_const(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(25 : i64) : i64 + %1 = llvm.mlir.constant(8589934592 : i64) : i64 + %2 = llvm.shl %arg0, %0 : i64 + %3 = llvm.icmp "ult" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @scalar_i8_shl_uge_const(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.icmp "uge" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @scalar_i8_shl_ule_const(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(63 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.icmp "ule" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @scalar_i8_shl_ugt_const(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(63 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @vector_4xi32_shl_ult_const(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<11> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<131072> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 : vector<4xi32> + %3 = llvm.icmp "ult" %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi1> + } + llvm.func @vector_4xi32_shl_ult_const_undef1(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(11 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(dense<131072> : vector<4xi32>) : vector<4xi32> + %12 = llvm.shl %arg0, %10 : vector<4xi32> + %13 = llvm.icmp "ult" %12, %11 : vector<4xi32> + llvm.return %13 : vector<4xi1> + } + llvm.func @vector_4xi32_shl_ult_const_undef2(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<11> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(131072 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %2, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<4xi32> + %12 = llvm.shl %arg0, %0 : vector<4xi32> + %13 = llvm.icmp "ult" %12, %11 : vector<4xi32> + llvm.return %13 : vector<4xi1> + } + llvm.func @vector_4xi32_shl_ult_const_undef3(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(11 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(131072 : i32) : i32 + %12 = llvm.mlir.undef : vector<4xi32> + %13 = llvm.mlir.constant(0 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<4xi32> + %15 = llvm.mlir.constant(1 : i32) : i32 + %16 = llvm.insertelement %11, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(2 : i32) : i32 + %18 = llvm.insertelement %11, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(3 : i32) : i32 + %20 = llvm.insertelement %11, %18[%19 : i32] : vector<4xi32> + %21 = llvm.shl %arg0, %10 : vector<4xi32> + %22 = llvm.icmp "ult" %21, %20 : vector<4xi32> + llvm.return %22 : vector<4xi1> + } + llvm.func @vector_4xi32_shl_uge_const(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<11> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<131072> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 : vector<4xi32> + %3 = llvm.icmp "uge" %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi1> + } + llvm.func @vector_4xi32_shl_ule_const(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<11> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<131071> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 : vector<4xi32> + %3 = llvm.icmp "ule" %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi1> + } + llvm.func @vector_4xi32_shl_ugt_const(%arg0: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<11> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<131071> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 : vector<4xi32> + %3 = llvm.icmp "ugt" %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi1> + } + llvm.func @scalar_i8_shl_ult_const_extra_use_shl(%arg0: i8, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + llvm.store %2, %arg1 {alignment = 1 : i64} : i8, !llvm.ptr + %3 = llvm.icmp "ult" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @scalar_i8_shl_slt_const(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.icmp "slt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @scalar_i8_shl_ugt_const_not_power_of_2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(66 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/should-change-type.ll.mlir b/test/LLVMDialect/InstCombine/should-change-type.ll.mlir index 284fc1205..c774d983e 100644 --- a/test/LLVMDialect/InstCombine/should-change-type.ll.mlir +++ b/test/LLVMDialect/InstCombine/should-change-type.ll.mlir @@ -1,35 +1,30 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i64 - %1 = "llvm.zext"(%arg1) : (i8) -> i64 - %2 = "llvm.add"(%0, %1) : (i64, i64) -> i64 - %3 = "llvm.trunc"(%2) : (i64) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i16): // no predecessors - %0 = "llvm.zext"(%arg0) : (i16) -> i64 - %1 = "llvm.zext"(%arg1) : (i16) -> i64 - %2 = "llvm.add"(%0, %1) : (i64, i64) -> i64 - %3 = "llvm.trunc"(%2) : (i64) -> i16 - "llvm.return"(%3) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.zext"(%arg0) : (i32) -> i64 - %1 = "llvm.zext"(%arg1) : (i32) -> i64 - %2 = "llvm.add"(%0, %1) : (i64, i64) -> i64 - %3 = "llvm.trunc"(%2) : (i64) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i9, %arg1: i9): // no predecessors - %0 = "llvm.zext"(%arg0) : (i9) -> i64 - %1 = "llvm.zext"(%arg1) : (i9) -> i64 - %2 = "llvm.add"(%0, %1) : (i64, i64) -> i64 - %3 = "llvm.trunc"(%2) : (i64) -> i9 - "llvm.return"(%3) : (i9) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.zext %arg0 : i8 to i64 + %1 = llvm.zext %arg1 : i8 to i64 + %2 = llvm.add %0, %1 : i64 + %3 = llvm.trunc %2 : i64 to i8 + llvm.return %3 : i8 + } + llvm.func @test2(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.zext %arg0 : i16 to i64 + %1 = llvm.zext %arg1 : i16 to i64 + %2 = llvm.add %0, %1 : i64 + %3 = llvm.trunc %2 : i64 to i16 + llvm.return %3 : i16 + } + llvm.func @test3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.zext %arg0 : i32 to i64 + %1 = llvm.zext %arg1 : i32 to i64 + %2 = llvm.add %0, %1 : i64 + %3 = llvm.trunc %2 : i64 to i32 + llvm.return %3 : i32 + } + llvm.func @test4(%arg0: i9, %arg1: i9) -> i9 { + %0 = llvm.zext %arg0 : i9 to i64 + %1 = llvm.zext %arg1 : i9 to i64 + %2 = llvm.add %0, %1 : i64 + %3 = llvm.trunc %2 : i64 to i9 + llvm.return %3 : i9 + } +} diff --git a/test/LLVMDialect/InstCombine/shuffle-binop.ll.mlir b/test/LLVMDialect/InstCombine/shuffle-binop.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/shuffle-cast-dist.ll.mlir b/test/LLVMDialect/InstCombine/shuffle-cast-dist.ll.mlir new file mode 100644 index 000000000..6dfa92156 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shuffle-cast-dist.ll.mlir @@ -0,0 +1,70 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @vtrn1(%arg0: vector<2xi32>) -> vector<2xf32> { + %0 = llvm.bitcast %arg0 : vector<2xi32> to vector<2xf32> + %1 = llvm.bitcast %arg0 : vector<2xi32> to vector<2xf32> + %2 = llvm.shufflevector %0, %1 [0, 2] : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @vtrn2(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xf32> { + %0 = llvm.bitcast %arg0 : vector<2xi32> to vector<2xf32> + %1 = llvm.bitcast %arg1 : vector<2xi32> to vector<2xf32> + %2 = llvm.shufflevector %0, %1 [1, 3] : vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @bc_shuf_lenchange(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<4xf32> { + %0 = llvm.bitcast %arg0 : vector<2xi32> to vector<2xf32> + %1 = llvm.bitcast %arg1 : vector<2xi32> to vector<2xf32> + %2 = llvm.shufflevector %0, %1 [3, 2, 1, 0] : vector<2xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @bc_shuf_nonvec(%arg0: i64, %arg1: i64) -> vector<4xf32> { + %0 = llvm.bitcast %arg0 : i64 to vector<2xf32> + %1 = llvm.bitcast %arg1 : i64 to vector<2xf32> + %2 = llvm.shufflevector %0, %1 [3, 2, 1, 0] : vector<2xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @bc_shuf_size(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xf64> { + %0 = llvm.bitcast %arg0 : vector<4xi32> to vector<2xf64> + %1 = llvm.bitcast %arg1 : vector<4xi32> to vector<2xf64> + %2 = llvm.shufflevector %0, %1 [1, 3, 0, 2] : vector<2xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @bc_shuf_mismatch(%arg0: vector<4xi32>, %arg1: vector<2xi64>) -> vector<2xf64> { + %0 = llvm.bitcast %arg0 : vector<4xi32> to vector<2xf64> + %1 = llvm.bitcast %arg1 : vector<2xi64> to vector<2xf64> + %2 = llvm.shufflevector %0, %1 [1, 3] : vector<2xf64> + llvm.return %2 : vector<2xf64> + } + llvm.func @bc_shuf_i8_float(%arg0: vector<8xi8>, %arg1: vector<8xi8>) -> vector<8xf16> { + %0 = llvm.bitcast %arg0 : vector<8xi8> to vector<4xf16> + %1 = llvm.bitcast %arg1 : vector<8xi8> to vector<4xf16> + %2 = llvm.shufflevector %0, %1 [3, 2, 1, 0, 7, 6, 5, 4] : vector<4xf16> + llvm.return %2 : vector<8xf16> + } + llvm.func @bc_shuf_elemtype_mismatch(%arg0: vector<2xf16>, %arg1: vector<2xbf16>) -> vector<4xi16> { + %0 = llvm.bitcast %arg0 : vector<2xf16> to vector<2xi16> + %1 = llvm.bitcast %arg1 : vector<2xbf16> to vector<2xi16> + %2 = llvm.shufflevector %0, %1 [3, 2, 1, 0] : vector<2xi16> + llvm.return %2 : vector<4xi16> + } + llvm.func @bc_shuf_reuse(%arg0: vector<4xi32>) -> vector<2xf32> { + %0 = llvm.bitcast %arg0 : vector<4xi32> to vector<4xf32> + %1 = llvm.shufflevector %0, %0 [0, 4] : vector<4xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @bc_shuf_y_hasoneuse(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xf32> { + %0 = llvm.bitcast %arg0 : vector<4xi32> to vector<4xf32> + %1 = llvm.bitcast %arg1 : vector<4xi32> to vector<4xf32> + %2 = llvm.shufflevector %0, %1 [0, 1, 4, 5] : vector<4xf32> + %3 = llvm.fadd %0, %2 : vector<4xf32> + llvm.return %3 : vector<4xf32> + } + llvm.func @bc_shuf_neither_hasoneuse(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xf32> { + %0 = llvm.bitcast %arg0 : vector<4xi32> to vector<4xf32> + %1 = llvm.bitcast %arg1 : vector<4xi32> to vector<4xf32> + %2 = llvm.shufflevector %0, %0 [0, 1, 4, 5] : vector<4xf32> + %3 = llvm.fadd %0, %1 : vector<4xf32> + %4 = llvm.fadd %3, %2 : vector<4xf32> + llvm.return %4 : vector<4xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/shuffle-cast-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/shuffle-cast-inseltpoison.ll.mlir new file mode 100644 index 000000000..646b9fbd4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shuffle-cast-inseltpoison.ll.mlir @@ -0,0 +1,54 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @trunc_little_endian(%arg0: vector<4xi32>) -> vector<4xi16> { + %0 = llvm.mlir.poison : vector<8xi16> + %1 = llvm.bitcast %arg0 : vector<4xi32> to vector<8xi16> + %2 = llvm.shufflevector %1, %0 [0, 2, 4, 6] : vector<8xi16> + llvm.return %2 : vector<4xi16> + } + llvm.func @trunc_big_endian(%arg0: vector<4xi32>) -> vector<4xi16> { + %0 = llvm.mlir.poison : vector<8xi16> + %1 = llvm.bitcast %arg0 : vector<4xi32> to vector<8xi16> + %2 = llvm.shufflevector %1, %0 [1, 3, 5, 7] : vector<8xi16> + llvm.return %2 : vector<4xi16> + } + llvm.func @use_v8i16(vector<8xi16>) + llvm.func @trunc_little_endian_extra_use(%arg0: vector<2xi64>) -> vector<2xi16> { + %0 = llvm.mlir.poison : vector<8xi16> + %1 = llvm.bitcast %arg0 : vector<2xi64> to vector<8xi16> + llvm.call @use_v8i16(%1) : (vector<8xi16>) -> () + %2 = llvm.shufflevector %1, %0 [0, 4] : vector<8xi16> + llvm.return %2 : vector<2xi16> + } + llvm.func @use_v12i11(vector<12xi11>) + llvm.func @trunc_big_endian_extra_use(%arg0: vector<4xi33>) -> vector<4xi11> { + %0 = llvm.mlir.poison : vector<12xi11> + %1 = llvm.bitcast %arg0 : vector<4xi33> to vector<12xi11> + llvm.call @use_v12i11(%1) : (vector<12xi11>) -> () + %2 = llvm.shufflevector %1, %0 [2, 5, 8, 11] : vector<12xi11> + llvm.return %2 : vector<4xi11> + } + llvm.func @wrong_cast1(%arg0: i128) -> vector<4xi16> { + %0 = llvm.mlir.poison : vector<8xi16> + %1 = llvm.bitcast %arg0 : i128 to vector<8xi16> + %2 = llvm.shufflevector %1, %0 [0, 2, 4, 6] : vector<8xi16> + llvm.return %2 : vector<4xi16> + } + llvm.func @wrong_cast2(%arg0: vector<4xf32>) -> vector<4xi16> { + %0 = llvm.mlir.poison : vector<8xi16> + %1 = llvm.bitcast %arg0 : vector<4xf32> to vector<8xi16> + %2 = llvm.shufflevector %1, %0 [0, 2, 4, 6] : vector<8xi16> + llvm.return %2 : vector<4xi16> + } + llvm.func @wrong_cast3(%arg0: vector<4xi32>) -> vector<4xf16> { + %0 = llvm.mlir.poison : vector<8xf16> + %1 = llvm.bitcast %arg0 : vector<4xi32> to vector<8xf16> + %2 = llvm.shufflevector %1, %0 [0, 2, 4, 6] : vector<8xf16> + llvm.return %2 : vector<4xf16> + } + llvm.func @wrong_shuffle(%arg0: vector<4xi32>) -> vector<2xi16> { + %0 = llvm.mlir.poison : vector<8xi16> + %1 = llvm.bitcast %arg0 : vector<4xi32> to vector<8xi16> + %2 = llvm.shufflevector %1, %0 [0, 2] : vector<8xi16> + llvm.return %2 : vector<2xi16> + } +} diff --git a/test/LLVMDialect/InstCombine/shuffle-cast.ll.mlir b/test/LLVMDialect/InstCombine/shuffle-cast.ll.mlir new file mode 100644 index 000000000..f5f79ecbf --- /dev/null +++ b/test/LLVMDialect/InstCombine/shuffle-cast.ll.mlir @@ -0,0 +1,54 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @trunc_little_endian(%arg0: vector<4xi32>) -> vector<4xi16> { + %0 = llvm.mlir.undef : vector<8xi16> + %1 = llvm.bitcast %arg0 : vector<4xi32> to vector<8xi16> + %2 = llvm.shufflevector %1, %0 [0, 2, 4, 6] : vector<8xi16> + llvm.return %2 : vector<4xi16> + } + llvm.func @trunc_big_endian(%arg0: vector<4xi32>) -> vector<4xi16> { + %0 = llvm.mlir.undef : vector<8xi16> + %1 = llvm.bitcast %arg0 : vector<4xi32> to vector<8xi16> + %2 = llvm.shufflevector %1, %0 [1, 3, 5, 7] : vector<8xi16> + llvm.return %2 : vector<4xi16> + } + llvm.func @use_v8i16(vector<8xi16>) + llvm.func @trunc_little_endian_extra_use(%arg0: vector<2xi64>) -> vector<2xi16> { + %0 = llvm.mlir.undef : vector<8xi16> + %1 = llvm.bitcast %arg0 : vector<2xi64> to vector<8xi16> + llvm.call @use_v8i16(%1) : (vector<8xi16>) -> () + %2 = llvm.shufflevector %1, %0 [0, 4] : vector<8xi16> + llvm.return %2 : vector<2xi16> + } + llvm.func @use_v12i11(vector<12xi11>) + llvm.func @trunc_big_endian_extra_use(%arg0: vector<4xi33>) -> vector<4xi11> { + %0 = llvm.mlir.undef : vector<12xi11> + %1 = llvm.bitcast %arg0 : vector<4xi33> to vector<12xi11> + llvm.call @use_v12i11(%1) : (vector<12xi11>) -> () + %2 = llvm.shufflevector %1, %0 [2, 5, 8, 11] : vector<12xi11> + llvm.return %2 : vector<4xi11> + } + llvm.func @wrong_cast1(%arg0: i128) -> vector<4xi16> { + %0 = llvm.mlir.undef : vector<8xi16> + %1 = llvm.bitcast %arg0 : i128 to vector<8xi16> + %2 = llvm.shufflevector %1, %0 [0, 2, 4, 6] : vector<8xi16> + llvm.return %2 : vector<4xi16> + } + llvm.func @wrong_cast2(%arg0: vector<4xf32>) -> vector<4xi16> { + %0 = llvm.mlir.undef : vector<8xi16> + %1 = llvm.bitcast %arg0 : vector<4xf32> to vector<8xi16> + %2 = llvm.shufflevector %1, %0 [0, 2, 4, 6] : vector<8xi16> + llvm.return %2 : vector<4xi16> + } + llvm.func @wrong_cast3(%arg0: vector<4xi32>) -> vector<4xf16> { + %0 = llvm.mlir.undef : vector<8xf16> + %1 = llvm.bitcast %arg0 : vector<4xi32> to vector<8xf16> + %2 = llvm.shufflevector %1, %0 [0, 2, 4, 6] : vector<8xf16> + llvm.return %2 : vector<4xf16> + } + llvm.func @wrong_shuffle(%arg0: vector<4xi32>) -> vector<2xi16> { + %0 = llvm.mlir.undef : vector<8xi16> + %1 = llvm.bitcast %arg0 : vector<4xi32> to vector<8xi16> + %2 = llvm.shufflevector %1, %0 [0, 2] : vector<8xi16> + llvm.return %2 : vector<2xi16> + } +} diff --git a/test/LLVMDialect/InstCombine/shuffle-select-narrow-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/shuffle-select-narrow-inseltpoison.ll.mlir new file mode 100644 index 000000000..734a3e242 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shuffle-select-narrow-inseltpoison.ll.mlir @@ -0,0 +1,83 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @narrow_shuffle_of_select(%arg0: vector<2xi1>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi1> + %1 = llvm.mlir.poison : vector<4xi8> + %2 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi1> + %3 = llvm.select %2, %arg1, %arg2 : vector<4xi1>, vector<4xi8> + %4 = llvm.shufflevector %3, %1 [0, 1] : vector<4xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @narrow_shuffle_of_select_overspecified_extend(%arg0: vector<2xi1>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi1> + %1 = llvm.mlir.poison : vector<4xi8> + %2 = llvm.shufflevector %arg0, %0 [0, 1, 0, 1] : vector<2xi1> + %3 = llvm.select %2, %arg1, %arg2 : vector<4xi1>, vector<4xi8> + %4 = llvm.shufflevector %3, %1 [0, 1] : vector<4xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @narrow_shuffle_of_select_undefs(%arg0: vector<3xi1>, %arg1: vector<4xf32>, %arg2: vector<4xf32>) -> vector<3xf32> { + %0 = llvm.mlir.poison : vector<3xi1> + %1 = llvm.mlir.poison : vector<4xf32> + %2 = llvm.shufflevector %arg0, %0 [-1, 1, 2, -1] : vector<3xi1> + %3 = llvm.select %2, %arg1, %arg2 : vector<4xi1>, vector<4xf32> + %4 = llvm.shufflevector %3, %1 [0, 1, -1] : vector<4xf32> + llvm.return %4 : vector<3xf32> + } + llvm.func @use(vector<4xi8>) + llvm.func @use_cmp(vector<4xi1>) + llvm.func @narrow_shuffle_of_select_use1(%arg0: vector<2xi1>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi1> + %1 = llvm.mlir.poison : vector<4xi8> + %2 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi1> + %3 = llvm.select %2, %arg1, %arg2 : vector<4xi1>, vector<4xi8> + llvm.call @use(%3) : (vector<4xi8>) -> () + %4 = llvm.shufflevector %3, %1 [0, 1] : vector<4xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @narrow_shuffle_of_select_use2(%arg0: vector<2xi1>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi1> + %1 = llvm.mlir.poison : vector<4xi8> + %2 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi1> + llvm.call @use_cmp(%2) : (vector<4xi1>) -> () + %3 = llvm.select %2, %arg1, %arg2 : vector<4xi1>, vector<4xi8> + %4 = llvm.shufflevector %3, %1 [0, 1] : vector<4xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @narrow_shuffle_of_select_mismatch_types1(%arg0: vector<2xi1>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<3xi8> { + %0 = llvm.mlir.poison : vector<2xi1> + %1 = llvm.mlir.poison : vector<4xi8> + %2 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi1> + %3 = llvm.select %2, %arg1, %arg2 : vector<4xi1>, vector<4xi8> + %4 = llvm.shufflevector %3, %1 [0, 1, 2] : vector<4xi8> + llvm.return %4 : vector<3xi8> + } + llvm.func @narrow_shuffle_of_select_mismatch_types2(%arg0: vector<4xi1>, %arg1: vector<6xi8>, %arg2: vector<6xi8>) -> vector<3xi8> { + %0 = llvm.mlir.poison : vector<4xi1> + %1 = llvm.mlir.poison : vector<6xi8> + %2 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3, -1, -1] : vector<4xi1> + %3 = llvm.select %2, %arg1, %arg2 : vector<6xi1>, vector<6xi8> + %4 = llvm.shufflevector %3, %1 [0, 1, 2] : vector<6xi8> + llvm.return %4 : vector<3xi8> + } + llvm.func @narrow_shuffle_of_select_consts(%arg0: vector<2xi1>) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi1> + %1 = llvm.mlir.constant(dense<[-1, -2, -3, -4]> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi8>) : vector<4xi8> + %3 = llvm.mlir.poison : vector<4xi8> + %4 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi1> + %5 = llvm.select %4, %1, %2 : vector<4xi1>, vector<4xi8> + %6 = llvm.shufflevector %5, %3 [0, 1] : vector<4xi8> + llvm.return %6 : vector<2xi8> + } + llvm.func @narrow_shuffle_of_select_with_widened_ops(%arg0: vector<2xi1>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.mlir.poison : vector<2xi1> + %2 = llvm.mlir.poison : vector<4xi8> + %3 = llvm.shufflevector %arg1, %0 [0, 1, -1, -1] : vector<2xi8> + %4 = llvm.shufflevector %arg2, %0 [0, 1, -1, -1] : vector<2xi8> + %5 = llvm.shufflevector %arg0, %1 [0, 1, -1, -1] : vector<2xi1> + %6 = llvm.select %5, %3, %4 : vector<4xi1>, vector<4xi8> + %7 = llvm.shufflevector %6, %2 [0, 1] : vector<4xi8> + llvm.return %7 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/shuffle-select-narrow.ll.mlir b/test/LLVMDialect/InstCombine/shuffle-select-narrow.ll.mlir new file mode 100644 index 000000000..867bc6abf --- /dev/null +++ b/test/LLVMDialect/InstCombine/shuffle-select-narrow.ll.mlir @@ -0,0 +1,83 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @narrow_shuffle_of_select(%arg0: vector<2xi1>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi1> + %1 = llvm.mlir.undef : vector<4xi8> + %2 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi1> + %3 = llvm.select %2, %arg1, %arg2 : vector<4xi1>, vector<4xi8> + %4 = llvm.shufflevector %3, %1 [0, 1] : vector<4xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @narrow_shuffle_of_select_overspecified_extend(%arg0: vector<2xi1>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi1> + %1 = llvm.mlir.undef : vector<4xi8> + %2 = llvm.shufflevector %arg0, %0 [0, 1, 0, 1] : vector<2xi1> + %3 = llvm.select %2, %arg1, %arg2 : vector<4xi1>, vector<4xi8> + %4 = llvm.shufflevector %3, %1 [0, 1] : vector<4xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @narrow_shuffle_of_select_undefs(%arg0: vector<3xi1>, %arg1: vector<4xf32>, %arg2: vector<4xf32>) -> vector<3xf32> { + %0 = llvm.mlir.undef : vector<3xi1> + %1 = llvm.mlir.undef : vector<4xf32> + %2 = llvm.shufflevector %arg0, %0 [-1, 1, 2, -1] : vector<3xi1> + %3 = llvm.select %2, %arg1, %arg2 : vector<4xi1>, vector<4xf32> + %4 = llvm.shufflevector %3, %1 [0, 1, -1] : vector<4xf32> + llvm.return %4 : vector<3xf32> + } + llvm.func @use(vector<4xi8>) + llvm.func @use_cmp(vector<4xi1>) + llvm.func @narrow_shuffle_of_select_use1(%arg0: vector<2xi1>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi1> + %1 = llvm.mlir.undef : vector<4xi8> + %2 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi1> + %3 = llvm.select %2, %arg1, %arg2 : vector<4xi1>, vector<4xi8> + llvm.call @use(%3) : (vector<4xi8>) -> () + %4 = llvm.shufflevector %3, %1 [0, 1] : vector<4xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @narrow_shuffle_of_select_use2(%arg0: vector<2xi1>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi1> + %1 = llvm.mlir.undef : vector<4xi8> + %2 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi1> + llvm.call @use_cmp(%2) : (vector<4xi1>) -> () + %3 = llvm.select %2, %arg1, %arg2 : vector<4xi1>, vector<4xi8> + %4 = llvm.shufflevector %3, %1 [0, 1] : vector<4xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @narrow_shuffle_of_select_mismatch_types1(%arg0: vector<2xi1>, %arg1: vector<4xi8>, %arg2: vector<4xi8>) -> vector<3xi8> { + %0 = llvm.mlir.undef : vector<2xi1> + %1 = llvm.mlir.undef : vector<4xi8> + %2 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi1> + %3 = llvm.select %2, %arg1, %arg2 : vector<4xi1>, vector<4xi8> + %4 = llvm.shufflevector %3, %1 [0, 1, 2] : vector<4xi8> + llvm.return %4 : vector<3xi8> + } + llvm.func @narrow_shuffle_of_select_mismatch_types2(%arg0: vector<4xi1>, %arg1: vector<6xi8>, %arg2: vector<6xi8>) -> vector<3xi8> { + %0 = llvm.mlir.undef : vector<4xi1> + %1 = llvm.mlir.undef : vector<6xi8> + %2 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3, -1, -1] : vector<4xi1> + %3 = llvm.select %2, %arg1, %arg2 : vector<6xi1>, vector<6xi8> + %4 = llvm.shufflevector %3, %1 [0, 1, 2] : vector<6xi8> + llvm.return %4 : vector<3xi8> + } + llvm.func @narrow_shuffle_of_select_consts(%arg0: vector<2xi1>) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi1> + %1 = llvm.mlir.constant(dense<[-1, -2, -3, -4]> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi8>) : vector<4xi8> + %3 = llvm.mlir.undef : vector<4xi8> + %4 = llvm.shufflevector %arg0, %0 [0, 1, -1, -1] : vector<2xi1> + %5 = llvm.select %4, %1, %2 : vector<4xi1>, vector<4xi8> + %6 = llvm.shufflevector %5, %3 [0, 1] : vector<4xi8> + llvm.return %6 : vector<2xi8> + } + llvm.func @narrow_shuffle_of_select_with_widened_ops(%arg0: vector<2xi1>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.undef : vector<2xi8> + %1 = llvm.mlir.undef : vector<2xi1> + %2 = llvm.mlir.undef : vector<4xi8> + %3 = llvm.shufflevector %arg1, %0 [0, 1, -1, -1] : vector<2xi8> + %4 = llvm.shufflevector %arg2, %0 [0, 1, -1, -1] : vector<2xi8> + %5 = llvm.shufflevector %arg0, %1 [0, 1, -1, -1] : vector<2xi1> + %6 = llvm.select %5, %3, %4 : vector<4xi1>, vector<4xi8> + %7 = llvm.shufflevector %6, %2 [0, 1] : vector<4xi8> + llvm.return %7 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/shuffle_select-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/shuffle_select-inseltpoison.ll.mlir new file mode 100644 index 000000000..cd7aae46a --- /dev/null +++ b/test/LLVMDialect/InstCombine/shuffle_select-inseltpoison.ll.mlir @@ -0,0 +1,895 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @add(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.add %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, 5, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @add_nuw_nsw(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.add %arg0, %0 overflow : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, 5, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @add_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.add %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, 5, -1, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @add_nuw_nsw_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.add %arg0, %0 overflow : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, -1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @sub(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sub %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [0, 1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @mul(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mul %arg0, %0 overflow : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [-1, 5, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @shl(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shl %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [4, 1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @shl_nsw(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [4, 1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @shl_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shl %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @shl_nuw_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [-1, 5, 2, -1] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @lshr_constant_op0(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.lshr %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [4, 5, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @lshr_exact_constant_op0(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.lshr %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [4, 5, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @lshr_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shl %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @lshr_exact_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.lshr %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [-1, 5, 2, -1] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @lshr_constant_op1(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.lshr %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [4, 5, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @ashr(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.ashr %arg0, %0 : vector<3xi32> + %2 = llvm.shufflevector %1, %arg0 [3, 1, 2] : vector<3xi32> + llvm.return %2 : vector<3xi32> + } + llvm.func @and(%arg0: vector<3xi42>) -> vector<3xi42> { + %0 = llvm.mlir.constant(13 : i42) : i42 + %1 = llvm.mlir.constant(12 : i42) : i42 + %2 = llvm.mlir.constant(11 : i42) : i42 + %3 = llvm.mlir.constant(dense<[11, 12, 13]> : vector<3xi42>) : vector<3xi42> + %4 = llvm.and %arg0, %3 : vector<3xi42> + %5 = llvm.shufflevector %arg0, %4 [0, 4, -1] : vector<3xi42> + llvm.return %5 : vector<3xi42> + } + llvm.func @use_v4i32(vector<4xi32>) + llvm.func @or(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.or %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [4, 5, 2, 3] : vector<4xi32> + llvm.call @use_v4i32(%1) : (vector<4xi32>) -> () + llvm.return %2 : vector<4xi32> + } + llvm.func @xor(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.xor %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [0, 5, 2, 3] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @udiv(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.udiv %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @udiv_exact(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.udiv %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @udiv_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.udiv %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, -1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @udiv_exact_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.udiv %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, -1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @sdiv(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sdiv %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [4, 1, 6, 3] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @sdiv_exact(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sdiv %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [4, 1, 6, 3] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @sdiv_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sdiv %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [-1, 1, 6, -1] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @sdiv_exact_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sdiv %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [-1, 1, 6, -1] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @urem(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.urem %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 6, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @urem_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.urem %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 6, -1] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @srem(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.srem %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [0, 1, 6, 3] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @fadd_maybe_nan(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[4.100000e+01, 4.200000e+01, 4.300000e+01, 4.400000e+01]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.fadd %arg0, %0 : vector<4xf32> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 6, 7] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @fadd(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[4.100000e+01, 4.200000e+01, 4.300000e+01, 4.400000e+01]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.fadd %arg0, %0 : vector<4xf32> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 6, 7] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @fsub(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[4.100000e+01, 4.200000e+01, 4.300000e+01, 4.400000e+01]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.fsub %0, %arg0 : vector<4xf64> + %2 = llvm.shufflevector %arg0, %1 [-1, 1, 6, 7] : vector<4xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @fmul(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[4.100000e+01, 4.200000e+01, 4.300000e+01, 4.400000e+01]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %2 = llvm.shufflevector %1, %arg0 [0, 5, 6, 7] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @fdiv_constant_op0(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[4.100000e+01, 4.200000e+01, 4.300000e+01, 4.400000e+01]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<4xf64> + %2 = llvm.shufflevector %arg0, %1 [-1, 1, 6, 7] : vector<4xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @fdiv_constant_op1(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[4.100000e+01, 4.200000e+01, 4.300000e+01, 4.400000e+01]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.fdiv %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf64> + %2 = llvm.shufflevector %arg0, %1 [-1, 1, 6, 7] : vector<4xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @frem(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[4.100000e+01, 4.200000e+01, 4.300000e+01, 4.400000e+01]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.frem %0, %arg0 : vector<4xf64> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 6, 7] : vector<4xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @add_add(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 : vector<4xi32> + %3 = llvm.add %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @add_add_nsw(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 overflow : vector<4xi32> + %3 = llvm.add %arg0, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @add_add_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 : vector<4xi32> + %3 = llvm.add %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, -1, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @add_add_nsw_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 overflow : vector<4xi32> + %3 = llvm.add %arg0, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, -1, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_sub(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.sub %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_sub_nuw(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 overflow : vector<4xi32> + %3 = llvm.sub %1, %arg0 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_sub_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.sub %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_sub_nuw_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 overflow : vector<4xi32> + %3 = llvm.sub %1, %arg0 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_mul(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 : vector<4xi32> + %3 = llvm.mul %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_shl(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 : vector<4xi32> + %3 = llvm.shl %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_shl_nuw(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %3 = llvm.shl %arg0, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_shl_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 : vector<4xi32> + %3 = llvm.shl %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 5, 2, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_shl_nuw_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %3 = llvm.shl %arg0, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 5, 2, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @lshr_lshr(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.lshr %0, %arg0 : vector<4xi32> + %3 = llvm.lshr %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @ashr_ashr(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<[4, 5, 6]> : vector<3xi32>) : vector<3xi32> + %2 = llvm.ashr %arg0, %0 : vector<3xi32> + %3 = llvm.ashr %arg0, %1 : vector<3xi32> + %4 = llvm.shufflevector %2, %3 [3, 1, 2] : vector<3xi32> + llvm.return %4 : vector<3xi32> + } + llvm.func @and_and(%arg0: vector<3xi42>) -> vector<3xi42> { + %0 = llvm.mlir.constant(3 : i42) : i42 + %1 = llvm.mlir.constant(2 : i42) : i42 + %2 = llvm.mlir.constant(1 : i42) : i42 + %3 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi42>) : vector<3xi42> + %4 = llvm.mlir.constant(6 : i42) : i42 + %5 = llvm.mlir.constant(5 : i42) : i42 + %6 = llvm.mlir.constant(4 : i42) : i42 + %7 = llvm.mlir.constant(dense<[4, 5, 6]> : vector<3xi42>) : vector<3xi42> + %8 = llvm.and %arg0, %3 : vector<3xi42> + %9 = llvm.and %arg0, %7 : vector<3xi42> + %10 = llvm.shufflevector %8, %9 [0, 4, -1] : vector<3xi42> + llvm.return %10 : vector<3xi42> + } + llvm.func @or_or(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.or %arg0, %0 : vector<4xi32> + %3 = llvm.or %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.call @use_v4i32(%2) : (vector<4xi32>) -> () + llvm.return %4 : vector<4xi32> + } + llvm.func @xor_xor(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.xor %arg0, %0 : vector<4xi32> + %3 = llvm.xor %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 3] : vector<4xi32> + llvm.call @use_v4i32(%3) : (vector<4xi32>) -> () + llvm.return %4 : vector<4xi32> + } + llvm.func @udiv_udiv(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.udiv %0, %arg0 : vector<4xi32> + %3 = llvm.udiv %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 2, 7] : vector<4xi32> + llvm.call @use_v4i32(%2) : (vector<4xi32>) -> () + llvm.call @use_v4i32(%3) : (vector<4xi32>) -> () + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_sdiv(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_sdiv_exact(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_sdiv_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 6, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_sdiv_exact_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 6, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @urem_urem(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.urem %0, %arg0 : vector<4xi32> + %3 = llvm.urem %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @urem_urem_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.urem %0, %arg0 : vector<4xi32> + %3 = llvm.urem %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @srem_srem(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.srem %0, %arg0 : vector<4xi32> + %3 = llvm.srem %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @srem_srem_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.srem %0, %arg0 : vector<4xi32> + %3 = llvm.srem %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, -1, 6, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @fadd_fadd(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fadd %arg0, %0 : vector<4xf32> + %3 = llvm.fadd %arg0, %1 : vector<4xf32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @fsub_fsub(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf64>) : vector<4xf64> + %2 = llvm.fsub %0, %arg0 : vector<4xf64> + %3 = llvm.fsub %1, %arg0 : vector<4xf64> + %4 = llvm.shufflevector %2, %3 [-1, 1, 6, 7] : vector<4xf64> + llvm.return %4 : vector<4xf64> + } + llvm.func @fmul_fmul(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.fmul %arg0, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %4 = llvm.shufflevector %2, %3 [0, 5, 6, 7] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @fdiv_fdiv(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf64>) : vector<4xf64> + %2 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<4xf64> + %3 = llvm.fdiv %1, %arg0 {fastmathFlags = #llvm.fastmath} : vector<4xf64> + %4 = llvm.shufflevector %2, %3 [-1, 1, 6, 7] : vector<4xf64> + llvm.return %4 : vector<4xf64> + } + llvm.func @frem_frem(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf64>) : vector<4xf64> + %2 = llvm.frem %0, %arg0 : vector<4xf64> + %3 = llvm.frem %arg0, %1 : vector<4xf64> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xf64> + llvm.return %4 : vector<4xf64> + } + llvm.func @add_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 : vector<4xi32> + %3 = llvm.add %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.sub %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_2_vars_nsw(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 overflow : vector<4xi32> + %3 = llvm.sub %1, %arg1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_2_vars_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.sub %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_2_vars_nsw_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 overflow : vector<4xi32> + %3 = llvm.sub %1, %arg1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 : vector<4xi32> + %3 = llvm.mul %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_2_vars_nuw(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 overflow : vector<4xi32> + %3 = llvm.mul %arg1, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_2_vars_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 : vector<4xi32> + %3 = llvm.mul %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, -1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_2_vars_nuw_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 overflow : vector<4xi32> + %3 = llvm.mul %arg1, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, -1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 : vector<4xi32> + %3 = llvm.shl %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_2_vars_nsw(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %3 = llvm.shl %arg1, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_2_vars_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 : vector<4xi32> + %3 = llvm.shl %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 5, 2, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_2_vars_nsw_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %3 = llvm.shl %arg1, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 5, 2, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @lshr_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.lshr %0, %arg0 : vector<4xi32> + %3 = llvm.lshr %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @lshr_2_vars_exact(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.lshr %0, %arg0 : vector<4xi32> + %3 = llvm.lshr %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @lshr_2_vars_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.lshr %0, %arg0 : vector<4xi32> + %3 = llvm.lshr %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @lshr_2_vars_exact_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.lshr %0, %arg0 : vector<4xi32> + %3 = llvm.lshr %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @ashr_2_vars(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<[4, 5, 6]> : vector<3xi32>) : vector<3xi32> + %2 = llvm.ashr %arg0, %0 : vector<3xi32> + %3 = llvm.ashr %arg1, %1 : vector<3xi32> + %4 = llvm.shufflevector %2, %3 [3, 1, 2] : vector<3xi32> + llvm.return %4 : vector<3xi32> + } + llvm.func @and_2_vars(%arg0: vector<3xi42>, %arg1: vector<3xi42>) -> vector<3xi42> { + %0 = llvm.mlir.constant(3 : i42) : i42 + %1 = llvm.mlir.constant(2 : i42) : i42 + %2 = llvm.mlir.constant(1 : i42) : i42 + %3 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi42>) : vector<3xi42> + %4 = llvm.mlir.constant(6 : i42) : i42 + %5 = llvm.mlir.constant(5 : i42) : i42 + %6 = llvm.mlir.constant(4 : i42) : i42 + %7 = llvm.mlir.constant(dense<[4, 5, 6]> : vector<3xi42>) : vector<3xi42> + %8 = llvm.and %arg0, %3 : vector<3xi42> + %9 = llvm.and %arg1, %7 : vector<3xi42> + %10 = llvm.shufflevector %8, %9 [0, 4, -1] : vector<3xi42> + llvm.return %10 : vector<3xi42> + } + llvm.func @or_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.or %arg0, %0 : vector<4xi32> + %3 = llvm.or %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.call @use_v4i32(%2) : (vector<4xi32>) -> () + llvm.return %4 : vector<4xi32> + } + llvm.func @xor_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.xor %arg0, %0 : vector<4xi32> + %3 = llvm.xor %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 3] : vector<4xi32> + llvm.call @use_v4i32(%2) : (vector<4xi32>) -> () + llvm.call @use_v4i32(%3) : (vector<4xi32>) -> () + llvm.return %4 : vector<4xi32> + } + llvm.func @udiv_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.udiv %0, %arg0 : vector<4xi32> + %3 = llvm.udiv %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @udiv_2_vars_exact(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.udiv %0, %arg0 : vector<4xi32> + %3 = llvm.udiv %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @udiv_2_vars_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.udiv %0, %arg0 : vector<4xi32> + %3 = llvm.udiv %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @udiv_2_vars_exact_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.udiv %0, %arg0 : vector<4xi32> + %3 = llvm.udiv %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_2_vars_exact(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_2_vars_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_2_vars_exact_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @urem_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.urem %0, %arg0 : vector<4xi32> + %3 = llvm.urem %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @srem_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.srem %0, %arg0 : vector<4xi32> + %3 = llvm.srem %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, -1, 6, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @fadd_2_vars(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fadd %arg0, %0 : vector<4xf32> + %3 = llvm.fadd %arg1, %1 : vector<4xf32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @fsub_2_vars(%arg0: vector<4xf64>, %arg1: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf64>) : vector<4xf64> + %2 = llvm.fsub %0, %arg0 : vector<4xf64> + %3 = llvm.fsub %1, %arg1 : vector<4xf64> + %4 = llvm.shufflevector %2, %3 [-1, 1, 6, 7] : vector<4xf64> + llvm.return %4 : vector<4xf64> + } + llvm.func @fmul_2_vars(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.fmul %arg1, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %4 = llvm.shufflevector %2, %3 [0, 5, 6, 7] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @frem_2_vars(%arg0: vector<4xf64>, %arg1: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf64>) : vector<4xf64> + %2 = llvm.frem %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<4xf64> + %3 = llvm.frem %1, %arg1 {fastmathFlags = #llvm.fastmath} : vector<4xf64> + %4 = llvm.shufflevector %2, %3 [-1, 1, 6, 7] : vector<4xf64> + llvm.return %4 : vector<4xf64> + } + llvm.func @fdiv_2_vars(%arg0: vector<4xf64>, %arg1: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf64>) : vector<4xf64> + %2 = llvm.fdiv %0, %arg0 : vector<4xf64> + %3 = llvm.fdiv %arg1, %1 : vector<4xf64> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xf64> + llvm.return %4 : vector<4xf64> + } + llvm.func @mul_shl(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 overflow : vector<4xi32> + %3 = llvm.shl %arg0, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_mul(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %3 = llvm.mul %arg0, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, -1, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_is_nop_shl(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 : vector<4xi32> + %3 = llvm.shl %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 6, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_mul_not_constant_shift_amount(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %0, %arg0 : vector<4xi32> + %3 = llvm.mul %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_shl_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 overflow : vector<4xi32> + %3 = llvm.shl %arg1, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_mul_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %3 = llvm.mul %arg1, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, -1, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @add_or(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<5> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[65534, 65535, 65536, 65537]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %3 = llvm.shl %arg0, %0 : vector<4xi32> + %4 = llvm.add %3, %1 : vector<4xi32> + %5 = llvm.or %3, %2 : vector<4xi32> + %6 = llvm.shufflevector %4, %5 [4, 5, 2, 3] : vector<4xi32> + llvm.return %6 : vector<4xi32> + } + llvm.func @or_add(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<-64> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi8>) : vector<4xi8> + %3 = llvm.lshr %arg0, %0 : vector<4xi8> + %4 = llvm.or %3, %1 : vector<4xi8> + %5 = llvm.add %3, %2 overflow : vector<4xi8> + %6 = llvm.shufflevector %4, %5 [4, 5, 2, 3] : vector<4xi8> + llvm.return %6 : vector<4xi8> + } + llvm.func @or_add_not_enough_masking(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<-64> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi8>) : vector<4xi8> + %3 = llvm.lshr %arg0, %0 : vector<4xi8> + %4 = llvm.or %3, %1 : vector<4xi8> + %5 = llvm.add %3, %2 overflow : vector<4xi8> + %6 = llvm.shufflevector %4, %5 [4, 5, 2, 3] : vector<4xi8> + llvm.return %6 : vector<4xi8> + } + llvm.func @add_or_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<5> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[65534, 65535, 65536, 65537]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %3 = llvm.shl %arg0, %0 : vector<4xi32> + %4 = llvm.add %arg1, %1 : vector<4xi32> + %5 = llvm.or %3, %2 : vector<4xi32> + %6 = llvm.shufflevector %4, %5 [4, 5, 2, 3] : vector<4xi32> + llvm.return %6 : vector<4xi32> + } + llvm.func @or_add_2_vars(%arg0: vector<4xi8>, %arg1: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<-64> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi8>) : vector<4xi8> + %3 = llvm.lshr %arg0, %0 : vector<4xi8> + %4 = llvm.or %3, %1 : vector<4xi8> + %5 = llvm.add %arg1, %2 overflow : vector<4xi8> + %6 = llvm.shufflevector %4, %5 [4, 5, 2, 3] : vector<4xi8> + llvm.return %6 : vector<4xi8> + } + llvm.func @PR41419(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [4, 5, 2, 7] : vector<4xi32> + llvm.return %1 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/shuffle_select.ll.mlir b/test/LLVMDialect/InstCombine/shuffle_select.ll.mlir new file mode 100644 index 000000000..cbac548b4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shuffle_select.ll.mlir @@ -0,0 +1,1066 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @add(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.add %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, 5, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @add_nuw_nsw(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.add %arg0, %0 overflow : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, 5, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @add_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.add %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, 5, -1, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @add_nuw_nsw_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.add %arg0, %0 overflow : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, -1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @sub(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sub %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [0, 1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @mul(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mul %arg0, %0 overflow : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [-1, 5, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @shl(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shl %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [4, 1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @shl_nsw(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [4, 1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @shl_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shl %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @shl_nuw_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [-1, 5, 2, -1] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @lshr_constant_op0(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.lshr %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [4, 5, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @lshr_exact_constant_op0(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.lshr %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [4, 5, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @lshr_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shl %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @lshr_exact_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.lshr %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [-1, 5, 2, -1] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @lshr_constant_op1(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.lshr %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [4, 5, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @ashr(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.ashr %arg0, %0 : vector<3xi32> + %2 = llvm.shufflevector %1, %arg0 [3, 1, 2] : vector<3xi32> + llvm.return %2 : vector<3xi32> + } + llvm.func @and(%arg0: vector<3xi42>) -> vector<3xi42> { + %0 = llvm.mlir.constant(13 : i42) : i42 + %1 = llvm.mlir.constant(12 : i42) : i42 + %2 = llvm.mlir.constant(11 : i42) : i42 + %3 = llvm.mlir.constant(dense<[11, 12, 13]> : vector<3xi42>) : vector<3xi42> + %4 = llvm.and %arg0, %3 : vector<3xi42> + %5 = llvm.shufflevector %arg0, %4 [0, 4, -1] : vector<3xi42> + llvm.return %5 : vector<3xi42> + } + llvm.func @use_v4i32(vector<4xi32>) + llvm.func @or(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.or %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [4, 5, 2, 3] : vector<4xi32> + llvm.call @use_v4i32(%1) : (vector<4xi32>) -> () + llvm.return %2 : vector<4xi32> + } + llvm.func @xor(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.xor %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [0, 5, 2, 3] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @udiv(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.udiv %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @udiv_exact(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.udiv %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @udiv_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.udiv %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, -1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @udiv_exact_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.udiv %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, -1, 2, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @sdiv(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sdiv %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [4, 1, 6, 3] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @sdiv_exact(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sdiv %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [4, 1, 6, 3] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @sdiv_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sdiv %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [-1, 1, 6, -1] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @sdiv_exact_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sdiv %arg0, %0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [-1, 1, 6, -1] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @urem(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.urem %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 6, 7] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @urem_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.urem %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 6, -1] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @srem(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[11, 12, 13, 14]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.srem %0, %arg0 : vector<4xi32> + %2 = llvm.shufflevector %arg0, %1 [0, 1, 6, 3] : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @fadd_maybe_nan(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[4.100000e+01, 4.200000e+01, 4.300000e+01, 4.400000e+01]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.fadd %arg0, %0 : vector<4xf32> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 6, 7] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @fadd(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[4.100000e+01, 4.200000e+01, 4.300000e+01, 4.400000e+01]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.fadd %arg0, %0 : vector<4xf32> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 6, 7] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @fsub(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[4.100000e+01, 4.200000e+01, 4.300000e+01, 4.400000e+01]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.fsub %0, %arg0 : vector<4xf64> + %2 = llvm.shufflevector %arg0, %1 [-1, 1, 6, 7] : vector<4xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @fmul(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[4.100000e+01, 4.200000e+01, 4.300000e+01, 4.400000e+01]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %2 = llvm.shufflevector %1, %arg0 [0, 5, 6, 7] : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @fdiv_constant_op0(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[4.100000e+01, 4.200000e+01, 4.300000e+01, 4.400000e+01]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<4xf64> + %2 = llvm.shufflevector %arg0, %1 [-1, 1, 6, 7] : vector<4xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @fdiv_constant_op1(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[4.100000e+01, 4.200000e+01, 4.300000e+01, 4.400000e+01]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.fdiv %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf64> + %2 = llvm.shufflevector %arg0, %1 [-1, 1, 6, 7] : vector<4xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @frem(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[4.100000e+01, 4.200000e+01, 4.300000e+01, 4.400000e+01]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.frem %0, %arg0 : vector<4xf64> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 6, 7] : vector<4xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @add_add(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 : vector<4xi32> + %3 = llvm.add %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @add_add_nsw(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 overflow : vector<4xi32> + %3 = llvm.add %arg0, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @add_add_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 : vector<4xi32> + %3 = llvm.add %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, -1, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @add_add_nsw_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 overflow : vector<4xi32> + %3 = llvm.add %arg0, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, -1, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_sub(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.sub %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_sub_nuw(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 overflow : vector<4xi32> + %3 = llvm.sub %1, %arg0 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_sub_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.sub %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_sub_nuw_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 overflow : vector<4xi32> + %3 = llvm.sub %1, %arg0 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_mul(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 : vector<4xi32> + %3 = llvm.mul %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_shl(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 : vector<4xi32> + %3 = llvm.shl %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_shl_nuw(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %3 = llvm.shl %arg0, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_shl_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 : vector<4xi32> + %3 = llvm.shl %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 5, 2, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_shl_nuw_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %3 = llvm.shl %arg0, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 5, 2, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @lshr_lshr(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.lshr %0, %arg0 : vector<4xi32> + %3 = llvm.lshr %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @ashr_ashr(%arg0: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<[4, 5, 6]> : vector<3xi32>) : vector<3xi32> + %2 = llvm.ashr %arg0, %0 : vector<3xi32> + %3 = llvm.ashr %arg0, %1 : vector<3xi32> + %4 = llvm.shufflevector %2, %3 [3, 1, 2] : vector<3xi32> + llvm.return %4 : vector<3xi32> + } + llvm.func @and_and(%arg0: vector<3xi42>) -> vector<3xi42> { + %0 = llvm.mlir.constant(3 : i42) : i42 + %1 = llvm.mlir.constant(2 : i42) : i42 + %2 = llvm.mlir.constant(1 : i42) : i42 + %3 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi42>) : vector<3xi42> + %4 = llvm.mlir.constant(6 : i42) : i42 + %5 = llvm.mlir.constant(5 : i42) : i42 + %6 = llvm.mlir.constant(4 : i42) : i42 + %7 = llvm.mlir.constant(dense<[4, 5, 6]> : vector<3xi42>) : vector<3xi42> + %8 = llvm.and %arg0, %3 : vector<3xi42> + %9 = llvm.and %arg0, %7 : vector<3xi42> + %10 = llvm.shufflevector %8, %9 [0, 4, -1] : vector<3xi42> + llvm.return %10 : vector<3xi42> + } + llvm.func @or_or(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.or %arg0, %0 : vector<4xi32> + %3 = llvm.or %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.call @use_v4i32(%2) : (vector<4xi32>) -> () + llvm.return %4 : vector<4xi32> + } + llvm.func @xor_xor(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.xor %arg0, %0 : vector<4xi32> + %3 = llvm.xor %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 3] : vector<4xi32> + llvm.call @use_v4i32(%3) : (vector<4xi32>) -> () + llvm.return %4 : vector<4xi32> + } + llvm.func @udiv_udiv(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.udiv %0, %arg0 : vector<4xi32> + %3 = llvm.udiv %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 2, 7] : vector<4xi32> + llvm.call @use_v4i32(%2) : (vector<4xi32>) -> () + llvm.call @use_v4i32(%3) : (vector<4xi32>) -> () + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_sdiv(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_sdiv_exact(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_sdiv_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 6, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_sdiv_exact_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 6, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @urem_urem(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.urem %0, %arg0 : vector<4xi32> + %3 = llvm.urem %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @urem_urem_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.urem %0, %arg0 : vector<4xi32> + %3 = llvm.urem %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @srem_srem(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.srem %0, %arg0 : vector<4xi32> + %3 = llvm.srem %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @srem_srem_undef_mask_elt(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.srem %0, %arg0 : vector<4xi32> + %3 = llvm.srem %1, %arg0 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, -1, 6, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @fadd_fadd(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fadd %arg0, %0 : vector<4xf32> + %3 = llvm.fadd %arg0, %1 : vector<4xf32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @fsub_fsub(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf64>) : vector<4xf64> + %2 = llvm.fsub %0, %arg0 : vector<4xf64> + %3 = llvm.fsub %1, %arg0 : vector<4xf64> + %4 = llvm.shufflevector %2, %3 [-1, 1, 6, 7] : vector<4xf64> + llvm.return %4 : vector<4xf64> + } + llvm.func @fmul_fmul(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.fmul %arg0, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %4 = llvm.shufflevector %2, %3 [0, 5, 6, 7] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @fdiv_fdiv(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf64>) : vector<4xf64> + %2 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<4xf64> + %3 = llvm.fdiv %1, %arg0 {fastmathFlags = #llvm.fastmath} : vector<4xf64> + %4 = llvm.shufflevector %2, %3 [-1, 1, 6, 7] : vector<4xf64> + llvm.return %4 : vector<4xf64> + } + llvm.func @frem_frem(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf64>) : vector<4xf64> + %2 = llvm.frem %0, %arg0 : vector<4xf64> + %3 = llvm.frem %arg0, %1 : vector<4xf64> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xf64> + llvm.return %4 : vector<4xf64> + } + llvm.func @add_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 : vector<4xi32> + %3 = llvm.add %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.sub %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_2_vars_nsw(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 overflow : vector<4xi32> + %3 = llvm.sub %1, %arg1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_2_vars_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.sub %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sub_2_vars_nsw_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 overflow : vector<4xi32> + %3 = llvm.sub %1, %arg1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 : vector<4xi32> + %3 = llvm.mul %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_2_vars_nuw(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 overflow : vector<4xi32> + %3 = llvm.mul %arg1, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_2_vars_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 : vector<4xi32> + %3 = llvm.mul %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, -1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_2_vars_nuw_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 overflow : vector<4xi32> + %3 = llvm.mul %arg1, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, -1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 : vector<4xi32> + %3 = llvm.shl %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_2_vars_nsw(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %3 = llvm.shl %arg1, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_2_vars_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 : vector<4xi32> + %3 = llvm.shl %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 5, 2, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_2_vars_nsw_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %3 = llvm.shl %arg1, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 5, 2, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @lshr_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.lshr %0, %arg0 : vector<4xi32> + %3 = llvm.lshr %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @lshr_2_vars_exact(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.lshr %0, %arg0 : vector<4xi32> + %3 = llvm.lshr %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @lshr_2_vars_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.lshr %0, %arg0 : vector<4xi32> + %3 = llvm.lshr %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @lshr_2_vars_exact_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.lshr %0, %arg0 : vector<4xi32> + %3 = llvm.lshr %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 5, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @ashr_2_vars(%arg0: vector<3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<[4, 5, 6]> : vector<3xi32>) : vector<3xi32> + %2 = llvm.ashr %arg0, %0 : vector<3xi32> + %3 = llvm.ashr %arg1, %1 : vector<3xi32> + %4 = llvm.shufflevector %2, %3 [3, 1, 2] : vector<3xi32> + llvm.return %4 : vector<3xi32> + } + llvm.func @and_2_vars(%arg0: vector<3xi42>, %arg1: vector<3xi42>) -> vector<3xi42> { + %0 = llvm.mlir.constant(3 : i42) : i42 + %1 = llvm.mlir.constant(2 : i42) : i42 + %2 = llvm.mlir.constant(1 : i42) : i42 + %3 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi42>) : vector<3xi42> + %4 = llvm.mlir.constant(6 : i42) : i42 + %5 = llvm.mlir.constant(5 : i42) : i42 + %6 = llvm.mlir.constant(4 : i42) : i42 + %7 = llvm.mlir.constant(dense<[4, 5, 6]> : vector<3xi42>) : vector<3xi42> + %8 = llvm.and %arg0, %3 : vector<3xi42> + %9 = llvm.and %arg1, %7 : vector<3xi42> + %10 = llvm.shufflevector %8, %9 [0, 4, -1] : vector<3xi42> + llvm.return %10 : vector<3xi42> + } + llvm.func @or_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.or %arg0, %0 : vector<4xi32> + llvm.call @use_v4i32(%2) : (vector<4xi32>) -> () + %3 = llvm.or %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @or_2_vars_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.or %arg0, %0 : vector<4xi32> + llvm.call @use_v4i32(%2) : (vector<4xi32>) -> () + %3 = llvm.or %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @xor_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.xor %arg0, %0 : vector<4xi32> + llvm.call @use_v4i32(%2) : (vector<4xi32>) -> () + %3 = llvm.xor %arg1, %1 : vector<4xi32> + llvm.call @use_v4i32(%3) : (vector<4xi32>) -> () + %4 = llvm.shufflevector %2, %3 [0, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @udiv_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.udiv %0, %arg0 : vector<4xi32> + %3 = llvm.udiv %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @udiv_2_vars_exact(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.udiv %0, %arg0 : vector<4xi32> + %3 = llvm.udiv %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @udiv_2_vars_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.udiv %0, %arg0 : vector<4xi32> + %3 = llvm.udiv %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @udiv_2_vars_exact_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.udiv %0, %arg0 : vector<4xi32> + %3 = llvm.udiv %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [-1, 1, 2, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_2_vars_exact(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_2_vars_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @sdiv_2_vars_exact_undef_mask_elt(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sdiv %arg0, %0 : vector<4xi32> + %3 = llvm.sdiv %arg1, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, -1] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @urem_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.urem %0, %arg0 : vector<4xi32> + %3 = llvm.urem %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @srem_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.srem %0, %arg0 : vector<4xi32> + %3 = llvm.srem %1, %arg1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, -1, 6, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @fadd_2_vars(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fadd %arg0, %0 : vector<4xf32> + %3 = llvm.fadd %arg1, %1 : vector<4xf32> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @fsub_2_vars(%arg0: vector<4xf64>, %arg1: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf64>) : vector<4xf64> + %2 = llvm.fsub %0, %arg0 : vector<4xf64> + %3 = llvm.fsub %1, %arg1 : vector<4xf64> + %4 = llvm.shufflevector %2, %3 [-1, 1, 6, 7] : vector<4xf64> + llvm.return %4 : vector<4xf64> + } + llvm.func @fmul_2_vars(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %3 = llvm.fmul %arg1, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + %4 = llvm.shufflevector %2, %3 [0, 5, 6, 7] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @frem_2_vars(%arg0: vector<4xf64>, %arg1: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf64>) : vector<4xf64> + %2 = llvm.frem %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<4xf64> + %3 = llvm.frem %1, %arg1 {fastmathFlags = #llvm.fastmath} : vector<4xf64> + %4 = llvm.shufflevector %2, %3 [-1, 1, 6, 7] : vector<4xf64> + llvm.return %4 : vector<4xf64> + } + llvm.func @fdiv_2_vars(%arg0: vector<4xf64>, %arg1: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf64>) : vector<4xf64> + %1 = llvm.mlir.constant(dense<[5.000000e+00, 6.000000e+00, 7.000000e+00, 8.000000e+00]> : vector<4xf64>) : vector<4xf64> + %2 = llvm.fdiv %0, %arg0 : vector<4xf64> + %3 = llvm.fdiv %arg1, %1 : vector<4xf64> + %4 = llvm.shufflevector %2, %3 [0, 1, 6, 7] : vector<4xf64> + llvm.return %4 : vector<4xf64> + } + llvm.func @mul_shl(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 overflow : vector<4xi32> + %3 = llvm.shl %arg0, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_mul(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %3 = llvm.mul %arg0, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, -1, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_is_nop_shl(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 : vector<4xi32> + %3 = llvm.shl %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [0, 5, 6, 7] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_mul_not_constant_shift_amount(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %0, %arg0 : vector<4xi32> + %3 = llvm.mul %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_shl_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %0 overflow : vector<4xi32> + %3 = llvm.shl %arg1, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shl_mul_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[5, 6, 7, 8]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 overflow : vector<4xi32> + %3 = llvm.mul %arg1, %1 overflow : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, -1, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @mul_neg(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(-9 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.constant(-3 : i32) : i32 + %3 = llvm.mlir.constant(257 : i32) : i32 + %4 = llvm.mlir.undef : vector<4xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xi32> + %13 = llvm.mlir.constant(0 : i32) : i32 + %14 = llvm.mlir.undef : vector<4xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %1, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %13, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.insertelement %1, %20[%21 : i32] : vector<4xi32> + %23 = llvm.mul %arg0, %12 : vector<4xi32> + %24 = llvm.sub %22, %arg0 : vector<4xi32> + %25 = llvm.shufflevector %23, %24 [0, 1, 6, 3] : vector<4xi32> + llvm.return %25 : vector<4xi32> + } + llvm.func @neg_mul(%arg0: vector<3xi79>) -> vector<3xi79> { + %0 = llvm.mlir.constant(0 : i79) : i79 + %1 = llvm.mlir.poison : i79 + %2 = llvm.mlir.undef : vector<3xi79> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi79> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi79> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi79> + %9 = llvm.mlir.constant(-3 : i79) : i79 + %10 = llvm.mlir.undef : vector<3xi79> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %1, %10[%11 : i32] : vector<3xi79> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %9, %12[%13 : i32] : vector<3xi79> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %1, %14[%15 : i32] : vector<3xi79> + %17 = llvm.sub %8, %arg0 overflow : vector<3xi79> + %18 = llvm.mul %arg0, %16 overflow : vector<3xi79> + %19 = llvm.shufflevector %17, %18 [0, 4, 2] : vector<3xi79> + llvm.return %19 : vector<3xi79> + } + llvm.func @mul_neg_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.mlir.undef : vector<4xi32> + %14 = llvm.mlir.constant(0 : i32) : i32 + %15 = llvm.insertelement %1, %13[%14 : i32] : vector<4xi32> + %16 = llvm.mlir.constant(1 : i32) : i32 + %17 = llvm.insertelement %12, %15[%16 : i32] : vector<4xi32> + %18 = llvm.mlir.constant(2 : i32) : i32 + %19 = llvm.insertelement %12, %17[%18 : i32] : vector<4xi32> + %20 = llvm.mlir.constant(3 : i32) : i32 + %21 = llvm.insertelement %1, %19[%20 : i32] : vector<4xi32> + %22 = llvm.mul %arg0, %11 overflow : vector<4xi32> + %23 = llvm.sub %21, %arg1 overflow : vector<4xi32> + %24 = llvm.shufflevector %22, %23 [0, 5, 6, 3] : vector<4xi32> + llvm.return %24 : vector<4xi32> + } + llvm.func @neg_mul_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(6 : i32) : i32 + %12 = llvm.mlir.constant(42 : i32) : i32 + %13 = llvm.mlir.undef : vector<4xi32> + %14 = llvm.mlir.constant(0 : i32) : i32 + %15 = llvm.insertelement %0, %13[%14 : i32] : vector<4xi32> + %16 = llvm.mlir.constant(1 : i32) : i32 + %17 = llvm.insertelement %12, %15[%16 : i32] : vector<4xi32> + %18 = llvm.mlir.constant(2 : i32) : i32 + %19 = llvm.insertelement %0, %17[%18 : i32] : vector<4xi32> + %20 = llvm.mlir.constant(3 : i32) : i32 + %21 = llvm.insertelement %11, %19[%20 : i32] : vector<4xi32> + %22 = llvm.sub %10, %arg1 overflow : vector<4xi32> + %23 = llvm.mul %arg0, %21 overflow : vector<4xi32> + %24 = llvm.shufflevector %22, %23 [0, 5, 2, 7] : vector<4xi32> + llvm.return %24 : vector<4xi32> + } + llvm.func @add_or(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<5> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[65534, 65535, 65536, 65537]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %3 = llvm.shl %arg0, %0 : vector<4xi32> + %4 = llvm.add %3, %1 : vector<4xi32> + %5 = llvm.or %3, %2 : vector<4xi32> + %6 = llvm.shufflevector %4, %5 [4, 5, 2, 3] : vector<4xi32> + llvm.return %6 : vector<4xi32> + } + llvm.func @add_or_disjoint(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[65534, 65535, 65536, 65537]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %arg0, %0 : vector<4xi32> + %3 = llvm.or %arg0, %1 : vector<4xi32> + %4 = llvm.shufflevector %2, %3 [4, 5, 2, 3] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @or_add(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<-64> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi8>) : vector<4xi8> + %3 = llvm.lshr %arg0, %0 : vector<4xi8> + %4 = llvm.or %3, %1 : vector<4xi8> + %5 = llvm.add %3, %2 overflow : vector<4xi8> + %6 = llvm.shufflevector %4, %5 [4, 5, 2, 3] : vector<4xi8> + llvm.return %6 : vector<4xi8> + } + llvm.func @or_add_not_enough_masking(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<-64> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi8>) : vector<4xi8> + %3 = llvm.lshr %arg0, %0 : vector<4xi8> + %4 = llvm.or %3, %1 : vector<4xi8> + %5 = llvm.add %3, %2 overflow : vector<4xi8> + %6 = llvm.shufflevector %4, %5 [4, 5, 2, 3] : vector<4xi8> + llvm.return %6 : vector<4xi8> + } + llvm.func @add_or_2_vars(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<5> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<[65534, 65535, 65536, 65537]> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %3 = llvm.shl %arg0, %0 : vector<4xi32> + %4 = llvm.add %arg1, %1 : vector<4xi32> + %5 = llvm.or %3, %2 : vector<4xi32> + %6 = llvm.shufflevector %4, %5 [4, 5, 2, 3] : vector<4xi32> + llvm.return %6 : vector<4xi32> + } + llvm.func @or_add_2_vars(%arg0: vector<4xi8>, %arg1: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<-64> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi8>) : vector<4xi8> + %3 = llvm.lshr %arg0, %0 : vector<4xi8> + %4 = llvm.or %3, %1 : vector<4xi8> + %5 = llvm.add %arg1, %2 overflow : vector<4xi8> + %6 = llvm.shufflevector %4, %5 [4, 5, 2, 3] : vector<4xi8> + llvm.return %6 : vector<4xi8> + } + llvm.func @PR41419(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.undef : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [4, 5, 2, 7] : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @sel_common_op_commute0(%arg0: vector<5xi4>, %arg1: vector<5xi4>) -> vector<5xi4> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 6, 2, 3, 9] : vector<5xi4> + %1 = llvm.shufflevector %arg0, %0 [0, 6, 7, 3, 4] : vector<5xi4> + llvm.return %1 : vector<5xi4> + } + llvm.func @sel_common_op_commute1(%arg0: vector<5xi4>, %arg1: vector<5xi4>) -> vector<5xi4> { + %0 = llvm.shufflevector %arg1, %arg0 [0, 6, 2, 3, 9] : vector<5xi4> + %1 = llvm.shufflevector %arg0, %0 [0, 6, 7, 3, 4] : vector<5xi4> + llvm.return %1 : vector<5xi4> + } + llvm.func @sel_common_op_commute2(%arg0: vector<5xi4>, %arg1: vector<5xi4>) -> vector<5xi4> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 6, 2, 3, 9] : vector<5xi4> + %1 = llvm.shufflevector %0, %arg0 [0, 6, 7, 3, 4] : vector<5xi4> + llvm.return %1 : vector<5xi4> + } + llvm.func @sel_common_op_commute3(%arg0: vector<5xi4>, %arg1: vector<5xi4>) -> vector<5xi4> { + %0 = llvm.shufflevector %arg1, %arg0 [0, 6, 2, 3, 9] : vector<5xi4> + %1 = llvm.shufflevector %0, %arg0 [0, 6, 7, 3, 4] : vector<5xi4> + llvm.return %1 : vector<5xi4> + } + llvm.func @sel_common_op_commute3_poison_mask_elts(%arg0: vector<5xi4>, %arg1: vector<5xi4>) -> vector<5xi4> { + %0 = llvm.shufflevector %arg1, %arg0 [0, 6, 2, -1, 9] : vector<5xi4> + %1 = llvm.shufflevector %0, %arg0 [0, 6, -1, 3, 4] : vector<5xi4> + llvm.return %1 : vector<5xi4> + } + llvm.func @sel_not_common_op_commute3(%arg0: vector<5xi4>, %arg1: vector<5xi4>, %arg2: vector<5xi4>) -> vector<5xi4> { + %0 = llvm.shufflevector %arg1, %arg2 [0, 6, 2, 3, 9] : vector<5xi4> + %1 = llvm.shufflevector %0, %arg0 [0, 6, 7, 3, 4] : vector<5xi4> + llvm.return %1 : vector<5xi4> + } + llvm.func @not_sel_common_op(%arg0: vector<5xi4>, %arg1: vector<5xi4>) -> vector<5xi4> { + %0 = llvm.shufflevector %arg1, %arg0 [0, 6, 2, 3, 9] : vector<5xi4> + %1 = llvm.shufflevector %0, %arg0 [1, 6, 7, 3, 4] : vector<5xi4> + llvm.return %1 : vector<5xi4> + } + llvm.func @sel_common_op_extra_use(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.shufflevector %arg1, %arg0 [0, 5, 2, 7] : vector<4xi32> + llvm.call @use_v4i32(%0) : (vector<4xi32>) -> () + %1 = llvm.shufflevector %0, %arg0 [0, 1, 6, 7] : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @identity_mask(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 5, -1, -1] : vector<4xf32> + %1 = llvm.shufflevector %0, %arg0 [0, -1, 6, 7] : vector<4xf32> + llvm.return %1 : vector<4xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/shufflevec-bitcast-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/shufflevec-bitcast-inseltpoison.ll.mlir new file mode 100644 index 000000000..4f2965150 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shufflevec-bitcast-inseltpoison.ll.mlir @@ -0,0 +1,94 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(vector<4xi16>) + llvm.func @test(%arg0: vector<16xi8>, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.poison : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [12, 13, 14, 15] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to f32 + %3 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.store %3, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %2, %arg2 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.return + } + llvm.func @splat_bitcast_operand(%arg0: vector<8xi8>) -> vector<4xi16> { + %0 = llvm.mlir.poison : vector<8xi8> + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.shufflevector %arg0, %0 [1, 1, 1, 1, 1, 1, 1, 1] : vector<8xi8> + %3 = llvm.bitcast %2 : vector<8xi8> to vector<4xi16> + %4 = llvm.shufflevector %3, %1 [0, 2, 1, 0] : vector<4xi16> + llvm.return %4 : vector<4xi16> + } + llvm.func @splat_bitcast_operand_uses(%arg0: vector<8xi8>) -> vector<4xi16> { + %0 = llvm.mlir.poison : vector<8xi8> + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.shufflevector %arg0, %0 [1, 1, 1, 1, 1, 1, 1, 1] : vector<8xi8> + %3 = llvm.bitcast %2 : vector<8xi8> to vector<4xi16> + llvm.call @use(%3) : (vector<4xi16>) -> () + %4 = llvm.shufflevector %3, %1 [0, 2, 1, 0] : vector<4xi16> + llvm.return %4 : vector<4xi16> + } + llvm.func @splat_bitcast_operand_same_size_src_elt(%arg0: vector<4xf32>) -> vector<4xi32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.poison : vector<4xi32> + %2 = llvm.shufflevector %arg0, %0 [2, 2, 2, 2] : vector<4xf32> + %3 = llvm.bitcast %2 : vector<4xf32> to vector<4xi32> + %4 = llvm.shufflevector %3, %1 [0, 2, 1, 0] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shuf_bitcast_operand(%arg0: vector<16xi8>) -> vector<4xi32> { + %0 = llvm.mlir.poison : vector<16xi8> + %1 = llvm.mlir.poison : vector<4xi32> + %2 = llvm.shufflevector %arg0, %0 [12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3] : vector<16xi8> + %3 = llvm.bitcast %2 : vector<16xi8> to vector<4xi32> + %4 = llvm.shufflevector %3, %1 [3, 2, 1, 0] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @splat_bitcast_operand_change_type(%arg0: vector<8xi8>) -> vector<5xi16> { + %0 = llvm.mlir.poison : vector<8xi8> + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.shufflevector %arg0, %0 [1, 1, 1, 1, 1, 1, 1, 1] : vector<8xi8> + %3 = llvm.bitcast %2 : vector<8xi8> to vector<4xi16> + %4 = llvm.shufflevector %3, %1 [0, 2, 1, 0, 3] : vector<4xi16> + llvm.return %4 : vector<5xi16> + } + llvm.func @splat_bitcast_operand_wider_src_elt(%arg0: vector<2xi32>) -> vector<4xi16> { + %0 = llvm.mlir.poison : vector<2xi32> + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.shufflevector %arg0, %0 [1, 1] : vector<2xi32> + %3 = llvm.bitcast %2 : vector<2xi32> to vector<4xi16> + %4 = llvm.shufflevector %3, %1 [0, 1, 0, 1] : vector<4xi16> + llvm.return %4 : vector<4xi16> + } + llvm.func @splat_bitcast_operand_wider_src_elt_uses(%arg0: vector<2xi32>) -> vector<4xi16> { + %0 = llvm.mlir.poison : vector<2xi32> + %1 = llvm.mlir.poison : vector<4xi16> + %2 = llvm.shufflevector %arg0, %0 [1, 1] : vector<2xi32> + %3 = llvm.bitcast %2 : vector<2xi32> to vector<4xi16> + llvm.call @use(%3) : (vector<4xi16>) -> () + %4 = llvm.shufflevector %3, %1 [0, 1, 0, 1] : vector<4xi16> + llvm.return %4 : vector<4xi16> + } + llvm.func @shuf_bitcast_operand_wider_src(%arg0: vector<4xi32>) -> vector<16xi8> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.mlir.poison : vector<16xi8> + %2 = llvm.shufflevector %arg0, %0 [3, 2, 1, 0] : vector<4xi32> + %3 = llvm.bitcast %2 : vector<4xi32> to vector<16xi8> + %4 = llvm.shufflevector %3, %1 [12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3] : vector<16xi8> + llvm.return %4 : vector<16xi8> + } + llvm.func @shuf_bitcast_operand_cannot_widen(%arg0: vector<4xi32>) -> vector<16xi8> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.mlir.poison : vector<16xi8> + %2 = llvm.shufflevector %arg0, %0 [3, 2, 1, 0] : vector<4xi32> + %3 = llvm.bitcast %2 : vector<4xi32> to vector<16xi8> + %4 = llvm.shufflevector %3, %1 [12, 13, 12, 13, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3] : vector<16xi8> + llvm.return %4 : vector<16xi8> + } + llvm.func @shuf_bitcast_operand_cannot_widen_undef(%arg0: vector<4xi32>) -> vector<16xi8> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.mlir.poison : vector<16xi8> + %2 = llvm.shufflevector %arg0, %0 [3, 2, 1, 0] : vector<4xi32> + %3 = llvm.bitcast %2 : vector<4xi32> to vector<16xi8> + %4 = llvm.shufflevector %3, %1 [12, -1, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3] : vector<16xi8> + llvm.return %4 : vector<16xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/shufflevec-bitcast.ll.mlir b/test/LLVMDialect/InstCombine/shufflevec-bitcast.ll.mlir new file mode 100644 index 000000000..13b22d691 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shufflevec-bitcast.ll.mlir @@ -0,0 +1,136 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(vector<4xi16>) + llvm.func @test(%arg0: vector<16xi8>, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.undef : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [12, 13, 14, 15] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to f32 + %3 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.store %3, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %2, %arg2 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.return + } + llvm.func @splat_bitcast_operand(%arg0: vector<8xi8>) -> vector<4xi16> { + %0 = llvm.mlir.undef : vector<8xi8> + %1 = llvm.mlir.undef : vector<4xi16> + %2 = llvm.shufflevector %arg0, %0 [1, 1, 1, 1, 1, 1, 1, 1] : vector<8xi8> + %3 = llvm.bitcast %2 : vector<8xi8> to vector<4xi16> + %4 = llvm.shufflevector %3, %1 [0, 2, 1, 0] : vector<4xi16> + llvm.return %4 : vector<4xi16> + } + llvm.func @splat_bitcast_operand_uses(%arg0: vector<8xi8>) -> vector<4xi16> { + %0 = llvm.mlir.undef : vector<8xi8> + %1 = llvm.mlir.undef : vector<4xi16> + %2 = llvm.shufflevector %arg0, %0 [1, 1, 1, 1, 1, 1, 1, 1] : vector<8xi8> + %3 = llvm.bitcast %2 : vector<8xi8> to vector<4xi16> + llvm.call @use(%3) : (vector<4xi16>) -> () + %4 = llvm.shufflevector %3, %1 [0, 2, 1, 0] : vector<4xi16> + llvm.return %4 : vector<4xi16> + } + llvm.func @splat_bitcast_operand_same_size_src_elt(%arg0: vector<4xf32>) -> vector<4xi32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.undef : vector<4xi32> + %2 = llvm.shufflevector %arg0, %0 [2, 2, 2, 2] : vector<4xf32> + %3 = llvm.bitcast %2 : vector<4xf32> to vector<4xi32> + %4 = llvm.shufflevector %3, %1 [0, 2, 1, 0] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @shuf_bitcast_operand(%arg0: vector<16xi8>) -> vector<4xi32> { + %0 = llvm.mlir.undef : vector<16xi8> + %1 = llvm.mlir.undef : vector<4xi32> + %2 = llvm.shufflevector %arg0, %0 [12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3] : vector<16xi8> + %3 = llvm.bitcast %2 : vector<16xi8> to vector<4xi32> + %4 = llvm.shufflevector %3, %1 [3, 2, 1, 0] : vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @splat_bitcast_operand_change_type(%arg0: vector<8xi8>) -> vector<5xi16> { + %0 = llvm.mlir.undef : vector<8xi8> + %1 = llvm.mlir.undef : vector<4xi16> + %2 = llvm.shufflevector %arg0, %0 [1, 1, 1, 1, 1, 1, 1, 1] : vector<8xi8> + %3 = llvm.bitcast %2 : vector<8xi8> to vector<4xi16> + %4 = llvm.shufflevector %3, %1 [0, 2, 1, 0, 3] : vector<4xi16> + llvm.return %4 : vector<5xi16> + } + llvm.func @splat_bitcast_operand_wider_src_elt(%arg0: vector<2xi32>) -> vector<4xi16> { + %0 = llvm.mlir.undef : vector<2xi32> + %1 = llvm.mlir.undef : vector<4xi16> + %2 = llvm.shufflevector %arg0, %0 [1, 1] : vector<2xi32> + %3 = llvm.bitcast %2 : vector<2xi32> to vector<4xi16> + %4 = llvm.shufflevector %3, %1 [0, 1, 0, 1] : vector<4xi16> + llvm.return %4 : vector<4xi16> + } + llvm.func @splat_bitcast_operand_wider_src_elt_uses(%arg0: vector<2xi32>) -> vector<4xi16> { + %0 = llvm.mlir.undef : vector<2xi32> + %1 = llvm.mlir.undef : vector<4xi16> + %2 = llvm.shufflevector %arg0, %0 [1, 1] : vector<2xi32> + %3 = llvm.bitcast %2 : vector<2xi32> to vector<4xi16> + llvm.call @use(%3) : (vector<4xi16>) -> () + %4 = llvm.shufflevector %3, %1 [0, 1, 0, 1] : vector<4xi16> + llvm.return %4 : vector<4xi16> + } + llvm.func @shuf_bitcast_operand_wider_src(%arg0: vector<4xi32>) -> vector<16xi8> { + %0 = llvm.mlir.undef : vector<4xi32> + %1 = llvm.mlir.undef : vector<16xi8> + %2 = llvm.shufflevector %arg0, %0 [3, 2, 1, 0] : vector<4xi32> + %3 = llvm.bitcast %2 : vector<4xi32> to vector<16xi8> + %4 = llvm.shufflevector %3, %1 [12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3] : vector<16xi8> + llvm.return %4 : vector<16xi8> + } + llvm.func @shuf_bitcast_operand_cannot_widen(%arg0: vector<4xi32>) -> vector<16xi8> { + %0 = llvm.mlir.undef : vector<4xi32> + %1 = llvm.mlir.undef : vector<16xi8> + %2 = llvm.shufflevector %arg0, %0 [3, 2, 1, 0] : vector<4xi32> + %3 = llvm.bitcast %2 : vector<4xi32> to vector<16xi8> + %4 = llvm.shufflevector %3, %1 [12, 13, 12, 13, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3] : vector<16xi8> + llvm.return %4 : vector<16xi8> + } + llvm.func @shuf_bitcast_operand_cannot_widen_undef(%arg0: vector<4xi32>) -> vector<16xi8> { + %0 = llvm.mlir.undef : vector<4xi32> + %1 = llvm.mlir.undef : vector<16xi8> + %2 = llvm.shufflevector %arg0, %0 [3, 2, 1, 0] : vector<4xi32> + %3 = llvm.bitcast %2 : vector<4xi32> to vector<16xi8> + %4 = llvm.shufflevector %3, %1 [12, -1, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3] : vector<16xi8> + llvm.return %4 : vector<16xi8> + } + llvm.func @shuf_bitcast_insert(%arg0: vector<2xi8>, %arg1: i8) -> vector<2xi4> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xi4> + %2 = llvm.insertelement %arg1, %arg0[%0 : i32] : vector<2xi8> + %3 = llvm.bitcast %2 : vector<2xi8> to vector<4xi4> + %4 = llvm.shufflevector %3, %1 [0, 1] : vector<4xi4> + llvm.return %4 : vector<2xi4> + } + llvm.func @shuf_bitcast_inserti_use1(%arg0: vector<2xi8>, %arg1: i8, %arg2: !llvm.ptr) -> vector<2xi4> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xi4> + %2 = llvm.insertelement %arg1, %arg0[%0 : i32] : vector<2xi8> + llvm.store %2, %arg2 {alignment = 2 : i64} : vector<2xi8>, !llvm.ptr + %3 = llvm.bitcast %2 : vector<2xi8> to vector<4xi4> + %4 = llvm.shufflevector %3, %1 [0, 1] : vector<4xi4> + llvm.return %4 : vector<2xi4> + } + llvm.func @shuf_bitcast_insert_use2(%arg0: vector<2xi8>, %arg1: i8, %arg2: !llvm.ptr) -> vector<2xi4> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xi4> + %2 = llvm.insertelement %arg1, %arg0[%0 : i32] : vector<2xi8> + %3 = llvm.bitcast %2 : vector<2xi8> to vector<4xi4> + llvm.store %3, %arg2 {alignment = 2 : i64} : vector<4xi4>, !llvm.ptr + %4 = llvm.shufflevector %3, %1 [0, 1] : vector<4xi4> + llvm.return %4 : vector<2xi4> + } + llvm.func @shuf_bitcast_insert_wrong_index(%arg0: vector<2xi8>, %arg1: i8) -> vector<2xi4> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xi4> + %2 = llvm.insertelement %arg1, %arg0[%0 : i32] : vector<2xi8> + %3 = llvm.bitcast %2 : vector<2xi8> to vector<4xi4> + %4 = llvm.shufflevector %3, %1 [0, 1] : vector<4xi4> + llvm.return %4 : vector<2xi4> + } + llvm.func @shuf_bitcast_wrong_size(%arg0: vector<2xi8>, %arg1: i8) -> vector<3xi4> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xi4> + %2 = llvm.insertelement %arg1, %arg0[%0 : i32] : vector<2xi8> + %3 = llvm.bitcast %2 : vector<2xi8> to vector<4xi4> + %4 = llvm.shufflevector %3, %1 [0, 1, 2] : vector<4xi4> + llvm.return %4 : vector<3xi4> + } +} diff --git a/test/LLVMDialect/InstCombine/shufflevec-constant-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/shufflevec-constant-inseltpoison.ll.mlir new file mode 100644 index 000000000..c597fbdf0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shufflevec-constant-inseltpoison.ll.mlir @@ -0,0 +1,16 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @__inff4() -> vector<4xf32> attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<0x7F800000> : vector<2xf32>) : vector<2xf32> + %1 = llvm.bitcast %0 : vector<2xf32> to vector<1xf64> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.poison : vector<2xf32> + %4 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %5 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %6 = llvm.extractelement %1[%2 : i32] : vector<1xf64> + %7 = llvm.bitcast %6 : f64 to i64 + %8 = llvm.bitcast %7 : i64 to vector<2xf32> + %9 = llvm.shufflevector %8, %3 [0, 1, -1, -1] : vector<2xf32> + %10 = llvm.shufflevector %5, %9 [0, 1, 4, 5] : vector<4xf32> + llvm.return %10 : vector<4xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/shufflevec-constant.ll.mlir b/test/LLVMDialect/InstCombine/shufflevec-constant.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/shufflevector-div-rem-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/shufflevector-div-rem-inseltpoison.ll.mlir new file mode 100644 index 000000000..2b4e2f81e --- /dev/null +++ b/test/LLVMDialect/InstCombine/shufflevector-div-rem-inseltpoison.ll.mlir @@ -0,0 +1,99 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_srem_orig(%arg0: i16, %arg1: i1) -> i16 { + %0 = llvm.mlir.poison : vector<2xi16> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<1> : vector<2xi16>) : vector<2xi16> + %3 = llvm.mlir.constant(dense<2> : vector<2xi16>) : vector<2xi16> + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi16> + %6 = llvm.shufflevector %5, %0 [0, 0] : vector<2xi16> + %7 = llvm.select %arg1, %2, %6 : i1, vector<2xi16> + %8 = llvm.srem %7, %3 : vector<2xi16> + %9 = llvm.extractelement %8[%4 : i32] : vector<2xi16> + llvm.return %9 : i16 + } + llvm.func @test_srem(%arg0: i16, %arg1: i1) -> vector<2xi16> { + %0 = llvm.mlir.poison : vector<2xi16> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[2, 1]> : vector<2xi16>) : vector<2xi16> + %3 = llvm.mlir.constant(dense<[77, 99]> : vector<2xi16>) : vector<2xi16> + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi16> + %5 = llvm.srem %4, %2 : vector<2xi16> + %6 = llvm.shufflevector %5, %0 [-1, 0] : vector<2xi16> + %7 = llvm.select %arg1, %3, %6 : i1, vector<2xi16> + llvm.return %7 : vector<2xi16> + } + llvm.func @test_urem(%arg0: i16, %arg1: i1) -> vector<2xi16> { + %0 = llvm.mlir.poison : vector<2xi16> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[3, 1]> : vector<2xi16>) : vector<2xi16> + %3 = llvm.mlir.constant(dense<[77, 99]> : vector<2xi16>) : vector<2xi16> + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi16> + %5 = llvm.urem %4, %2 : vector<2xi16> + %6 = llvm.shufflevector %5, %0 [-1, 0] : vector<2xi16> + %7 = llvm.select %arg1, %3, %6 : i1, vector<2xi16> + llvm.return %7 : vector<2xi16> + } + llvm.func @test_sdiv(%arg0: i16, %arg1: i1) -> vector<2xi16> { + %0 = llvm.mlir.poison : vector<2xi16> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[2, 1]> : vector<2xi16>) : vector<2xi16> + %3 = llvm.mlir.constant(dense<[77, 99]> : vector<2xi16>) : vector<2xi16> + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi16> + %5 = llvm.sdiv %4, %2 : vector<2xi16> + %6 = llvm.shufflevector %5, %0 [-1, 0] : vector<2xi16> + %7 = llvm.select %arg1, %3, %6 : i1, vector<2xi16> + llvm.return %7 : vector<2xi16> + } + llvm.func @test_udiv(%arg0: i16, %arg1: i1) -> vector<2xi16> { + %0 = llvm.mlir.poison : vector<2xi16> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[3, 1]> : vector<2xi16>) : vector<2xi16> + %3 = llvm.mlir.constant(dense<[77, 99]> : vector<2xi16>) : vector<2xi16> + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi16> + %5 = llvm.udiv %4, %2 : vector<2xi16> + %6 = llvm.shufflevector %5, %0 [-1, 0] : vector<2xi16> + %7 = llvm.select %arg1, %3, %6 : i1, vector<2xi16> + llvm.return %7 : vector<2xi16> + } + llvm.func @test_fdiv(%arg0: f32, %arg1: f32, %arg2: i1) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.mlir.constant(dense<[7.700000e+01, 9.900000e+01]> : vector<2xf32>) : vector<2xf32> + %12 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %13 = llvm.insertelement %9, %8[%10 : i32] : vector<2xf32> + %14 = llvm.fdiv %12, %13 : vector<2xf32> + %15 = llvm.shufflevector %14, %0 [-1, 0] : vector<2xf32> + %16 = llvm.select %arg2, %11, %15 : i1, vector<2xf32> + llvm.return %16 : vector<2xf32> + } + llvm.func @test_frem(%arg0: f32, %arg1: f32, %arg2: i1) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.mlir.constant(dense<[7.700000e+01, 9.900000e+01]> : vector<2xf32>) : vector<2xf32> + %12 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %13 = llvm.insertelement %9, %8[%10 : i32] : vector<2xf32> + %14 = llvm.frem %12, %13 : vector<2xf32> + %15 = llvm.shufflevector %14, %0 [-1, 0] : vector<2xf32> + %16 = llvm.select %arg2, %11, %15 : i1, vector<2xf32> + llvm.return %16 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/shufflevector-div-rem.ll.mlir b/test/LLVMDialect/InstCombine/shufflevector-div-rem.ll.mlir new file mode 100644 index 000000000..b47228aa6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shufflevector-div-rem.ll.mlir @@ -0,0 +1,99 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_srem_orig(%arg0: i16, %arg1: i1) -> i16 { + %0 = llvm.mlir.undef : vector<2xi16> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<1> : vector<2xi16>) : vector<2xi16> + %3 = llvm.mlir.constant(dense<2> : vector<2xi16>) : vector<2xi16> + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi16> + %6 = llvm.shufflevector %5, %0 [0, 0] : vector<2xi16> + %7 = llvm.select %arg1, %2, %6 : i1, vector<2xi16> + %8 = llvm.srem %7, %3 : vector<2xi16> + %9 = llvm.extractelement %8[%4 : i32] : vector<2xi16> + llvm.return %9 : i16 + } + llvm.func @test_srem(%arg0: i16, %arg1: i1) -> vector<2xi16> { + %0 = llvm.mlir.undef : vector<2xi16> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[2, 1]> : vector<2xi16>) : vector<2xi16> + %3 = llvm.mlir.constant(dense<[77, 99]> : vector<2xi16>) : vector<2xi16> + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi16> + %5 = llvm.srem %4, %2 : vector<2xi16> + %6 = llvm.shufflevector %5, %0 [-1, 0] : vector<2xi16> + %7 = llvm.select %arg1, %3, %6 : i1, vector<2xi16> + llvm.return %7 : vector<2xi16> + } + llvm.func @test_urem(%arg0: i16, %arg1: i1) -> vector<2xi16> { + %0 = llvm.mlir.undef : vector<2xi16> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[3, 1]> : vector<2xi16>) : vector<2xi16> + %3 = llvm.mlir.constant(dense<[77, 99]> : vector<2xi16>) : vector<2xi16> + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi16> + %5 = llvm.urem %4, %2 : vector<2xi16> + %6 = llvm.shufflevector %5, %0 [-1, 0] : vector<2xi16> + %7 = llvm.select %arg1, %3, %6 : i1, vector<2xi16> + llvm.return %7 : vector<2xi16> + } + llvm.func @test_sdiv(%arg0: i16, %arg1: i1) -> vector<2xi16> { + %0 = llvm.mlir.undef : vector<2xi16> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[2, 1]> : vector<2xi16>) : vector<2xi16> + %3 = llvm.mlir.constant(dense<[77, 99]> : vector<2xi16>) : vector<2xi16> + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi16> + %5 = llvm.sdiv %4, %2 : vector<2xi16> + %6 = llvm.shufflevector %5, %0 [-1, 0] : vector<2xi16> + %7 = llvm.select %arg1, %3, %6 : i1, vector<2xi16> + llvm.return %7 : vector<2xi16> + } + llvm.func @test_udiv(%arg0: i16, %arg1: i1) -> vector<2xi16> { + %0 = llvm.mlir.undef : vector<2xi16> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[3, 1]> : vector<2xi16>) : vector<2xi16> + %3 = llvm.mlir.constant(dense<[77, 99]> : vector<2xi16>) : vector<2xi16> + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xi16> + %5 = llvm.udiv %4, %2 : vector<2xi16> + %6 = llvm.shufflevector %5, %0 [-1, 0] : vector<2xi16> + %7 = llvm.select %arg1, %3, %6 : i1, vector<2xi16> + llvm.return %7 : vector<2xi16> + } + llvm.func @test_fdiv(%arg0: f32, %arg1: f32, %arg2: i1) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.mlir.constant(dense<[7.700000e+01, 9.900000e+01]> : vector<2xf32>) : vector<2xf32> + %12 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %13 = llvm.insertelement %9, %8[%10 : i32] : vector<2xf32> + %14 = llvm.fdiv %12, %13 : vector<2xf32> + %15 = llvm.shufflevector %14, %0 [-1, 0] : vector<2xf32> + %16 = llvm.select %arg2, %11, %15 : i1, vector<2xf32> + llvm.return %16 : vector<2xf32> + } + llvm.func @test_frem(%arg0: f32, %arg1: f32, %arg2: i1) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : f32 + %3 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %4 = llvm.mlir.undef : vector<2xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xf32> + %9 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %10 = llvm.mlir.constant(1 : i32) : i32 + %11 = llvm.mlir.constant(dense<[7.700000e+01, 9.900000e+01]> : vector<2xf32>) : vector<2xf32> + %12 = llvm.insertelement %arg0, %0[%1 : i32] : vector<2xf32> + %13 = llvm.insertelement %9, %8[%10 : i32] : vector<2xf32> + %14 = llvm.frem %12, %13 : vector<2xf32> + %15 = llvm.shufflevector %14, %0 [-1, 0] : vector<2xf32> + %16 = llvm.select %arg2, %11, %15 : i1, vector<2xf32> + llvm.return %16 : vector<2xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/shufflevector_freezepoison.ll.mlir b/test/LLVMDialect/InstCombine/shufflevector_freezepoison.ll.mlir new file mode 100644 index 000000000..5e2c55c71 --- /dev/null +++ b/test/LLVMDialect/InstCombine/shufflevector_freezepoison.ll.mlir @@ -0,0 +1,59 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @shuffle_op0_freeze_poison(%arg0: vector<2xf64>) -> vector<4xf64> { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.freeze %0 : vector<2xf64> + %2 = llvm.shufflevector %1, %arg0 [0, 1, 2, 3] : vector<2xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @shuffle_op1_freeze_poison(%arg0: vector<2xf64>) -> vector<4xf64> { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.freeze %0 : vector<2xf64> + %2 = llvm.shufflevector %arg0, %1 [0, 1, 2, 3] : vector<2xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @shuffle_op0_freeze_poison_use(%arg0: vector<2xf64>) -> vector<4xf64> { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.freeze %0 : vector<2xf64> + llvm.call @use(%1) : (vector<2xf64>) -> () + %2 = llvm.shufflevector %1, %arg0 [0, 1, 2, 3] : vector<2xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @shuffle_op1_freeze_poison_use(%arg0: vector<2xf64>) -> vector<4xf64> { + %0 = llvm.mlir.poison : vector<2xf64> + %1 = llvm.freeze %0 : vector<2xf64> + llvm.call @use(%1) : (vector<2xf64>) -> () + %2 = llvm.shufflevector %arg0, %1 [0, 1, 2, 3] : vector<2xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @shuffle_op0_freeze_undef(%arg0: vector<2xf64>) -> vector<4xf64> { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.freeze %0 : vector<2xf64> + llvm.call @use(%1) : (vector<2xf64>) -> () + %2 = llvm.shufflevector %1, %arg0 [0, 1, 2, 3] : vector<2xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @shuffle_op1_freeze_undef(%arg0: vector<2xf64>) -> vector<4xf64> { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.freeze %0 : vector<2xf64> + llvm.call @use(%1) : (vector<2xf64>) -> () + %2 = llvm.shufflevector %arg0, %1 [0, 1, 2, 3] : vector<2xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @shuffle_bc1(%arg0: vector<2xf64>) -> vector<4xf64> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.freeze %0 : vector<4xf32> + %2 = llvm.bitcast %1 : vector<4xf32> to vector<2xf64> + %3 = llvm.shufflevector %arg0, %2 [0, 1, 2, 3] : vector<2xf64> + llvm.return %3 : vector<4xf64> + } + llvm.func @shuffle_bc2(%arg0: vector<4xf32>) -> vector<8xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.freeze %0 : vector<4xf32> + %2 = llvm.bitcast %1 : vector<4xf32> to vector<2xf64> + llvm.call @use(%2) : (vector<2xf64>) -> () + %3 = llvm.bitcast %2 : vector<2xf64> to vector<4xf32> + %4 = llvm.shufflevector %arg0, %3 [0, 1, 2, 3, 4, 5, 6, 7] : vector<4xf32> + llvm.return %4 : vector<8xf32> + } + llvm.func @use(vector<2xf64>) +} diff --git a/test/LLVMDialect/InstCombine/sign-bit-test-via-right-shifting-all-other-bits.ll.mlir b/test/LLVMDialect/InstCombine/sign-bit-test-via-right-shifting-all-other-bits.ll.mlir index 6a68c32f9..5f2380d95 100644 --- a/test/LLVMDialect/InstCombine/sign-bit-test-via-right-shifting-all-other-bits.ll.mlir +++ b/test/LLVMDialect/InstCombine/sign-bit-test-via-right-shifting-all-other-bits.ll.mlir @@ -1,234 +1,214 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use64", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 32 : i32} : () -> i32 - %3 = "llvm.sub"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.lshr"(%arg0, %3) : (i32, i32) -> i32 - %5 = "llvm.sub"(%arg1, %1) : (i32, i32) -> i32 - %6 = "llvm.lshr"(%4, %5) : (i32, i32) -> i32 - "llvm.call"(%3) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%4) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%5) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%6) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %7 = "llvm.icmp"(%6, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%7) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "highest_bit_test_via_lshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 64 : i32} : () -> i32 - %3 = "llvm.sub"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.zext"(%3) : (i32) -> i64 - %5 = "llvm.lshr"(%arg0, %4) : (i64, i64) -> i64 - %6 = "llvm.trunc"(%5) : (i64) -> i32 - %7 = "llvm.sub"(%arg1, %1) : (i32, i32) -> i32 - %8 = "llvm.lshr"(%6, %7) : (i32, i32) -> i32 - "llvm.call"(%3) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%4) {callee = @use64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%5) {callee = @use64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%6) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%7) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%8) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %9 = "llvm.icmp"(%8, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%9) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "highest_bit_test_via_lshr_with_truncation", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 32 : i32} : () -> i32 - %3 = "llvm.sub"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.ashr"(%arg0, %3) : (i32, i32) -> i32 - %5 = "llvm.sub"(%arg1, %1) : (i32, i32) -> i32 - %6 = "llvm.ashr"(%4, %5) : (i32, i32) -> i32 - "llvm.call"(%3) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%4) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%5) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%6) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %7 = "llvm.icmp"(%6, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%7) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "highest_bit_test_via_ashr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 64 : i32} : () -> i32 - %3 = "llvm.sub"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.zext"(%3) : (i32) -> i64 - %5 = "llvm.ashr"(%arg0, %4) : (i64, i64) -> i64 - %6 = "llvm.trunc"(%5) : (i64) -> i32 - %7 = "llvm.sub"(%arg1, %1) : (i32, i32) -> i32 - %8 = "llvm.ashr"(%6, %7) : (i32, i32) -> i32 - "llvm.call"(%3) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%4) {callee = @use64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%5) {callee = @use64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%6) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%7) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%8) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %9 = "llvm.icmp"(%8, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%9) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "highest_bit_test_via_ashr_with_truncation", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 32 : i32} : () -> i32 - %3 = "llvm.sub"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.lshr"(%arg0, %3) : (i32, i32) -> i32 - %5 = "llvm.sub"(%arg1, %1) : (i32, i32) -> i32 - %6 = "llvm.ashr"(%4, %5) : (i32, i32) -> i32 - "llvm.call"(%3) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%4) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%5) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%6) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %7 = "llvm.icmp"(%6, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%7) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "highest_bit_test_via_lshr_ashr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 64 : i32} : () -> i32 - %3 = "llvm.sub"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.zext"(%3) : (i32) -> i64 - %5 = "llvm.lshr"(%arg0, %4) : (i64, i64) -> i64 - %6 = "llvm.trunc"(%5) : (i64) -> i32 - %7 = "llvm.sub"(%arg1, %1) : (i32, i32) -> i32 - %8 = "llvm.ashr"(%6, %7) : (i32, i32) -> i32 - "llvm.call"(%3) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%4) {callee = @use64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%5) {callee = @use64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%6) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%7) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%8) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %9 = "llvm.icmp"(%8, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%9) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "highest_bit_test_via_lshr_ashe_with_truncation", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 32 : i32} : () -> i32 - %3 = "llvm.sub"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.ashr"(%arg0, %3) : (i32, i32) -> i32 - %5 = "llvm.sub"(%arg1, %1) : (i32, i32) -> i32 - %6 = "llvm.lshr"(%4, %5) : (i32, i32) -> i32 - "llvm.call"(%3) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%4) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%5) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%6) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %7 = "llvm.icmp"(%6, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%7) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "highest_bit_test_via_ashr_lshr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 64 : i32} : () -> i32 - %3 = "llvm.sub"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.zext"(%3) : (i32) -> i64 - %5 = "llvm.ashr"(%arg0, %4) : (i64, i64) -> i64 - %6 = "llvm.trunc"(%5) : (i64) -> i32 - %7 = "llvm.sub"(%arg1, %1) : (i32, i32) -> i32 - %8 = "llvm.lshr"(%6, %7) : (i32, i32) -> i32 - "llvm.call"(%3) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%4) {callee = @use64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%5) {callee = @use64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - "llvm.call"(%6) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%7) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.call"(%8) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %9 = "llvm.icmp"(%8, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%9) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "highest_bit_test_via_ashr_lshr_with_truncation", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "unsigned_sign_bit_extract", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - "llvm.call"(%2) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "unsigned_sign_bit_extract_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - "llvm.call"(%2) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %3 = "llvm.icmp"(%2, %0) {predicate = 0 : i64} : (i32, i32) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "unsigned_sign_bit_extract_extrause__ispositive", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "signed_sign_bit_extract", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %2 = "llvm.ashr"(%arg0, %1) : (i32, i32) -> i32 - "llvm.call"(%2) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "signed_sign_bit_extract_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 63 : i64} : () -> i64 - %2 = "llvm.lshr"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.trunc"(%2) : (i64) -> i32 - %4 = "llvm.icmp"(%3, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "unsigned_sign_bit_extract_with_trunc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 63 : i64} : () -> i64 - %2 = "llvm.lshr"(%arg0, %1) : (i64, i64) -> i64 - "llvm.call"(%2) {callee = @use64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - %3 = "llvm.trunc"(%2) : (i64) -> i32 - "llvm.call"(%3) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %4 = "llvm.icmp"(%3, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "unsigned_sign_bit_extract_with_trunc_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 63 : i64} : () -> i64 - %2 = "llvm.ashr"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.trunc"(%2) : (i64) -> i32 - %4 = "llvm.icmp"(%3, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "signed_sign_bit_extract_trunc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 63 : i64} : () -> i64 - %2 = "llvm.ashr"(%arg0, %1) : (i64, i64) -> i64 - "llvm.call"(%2) {callee = @use64, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - %3 = "llvm.trunc"(%2) : (i64) -> i32 - "llvm.call"(%3) {callee = @use32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %4 = "llvm.icmp"(%3, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "signed_sign_bit_extract_trunc_extrause", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @highest_bit_test_via_lshr(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.sub %arg1, %1 : i32 + %6 = llvm.lshr %4, %5 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.icmp "ne" %6, %2 : i32 + llvm.return %7 : i1 + } + llvm.func @highest_bit_test_via_lshr_with_truncation(%arg0: i64, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.zext %3 : i32 to i64 + %5 = llvm.lshr %arg0, %4 : i64 + %6 = llvm.trunc %5 : i64 to i32 + %7 = llvm.sub %arg1, %1 : i32 + %8 = llvm.lshr %6, %7 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.icmp "ne" %8, %2 : i32 + llvm.return %9 : i1 + } + llvm.func @highest_bit_test_via_ashr(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.ashr %arg0, %3 : i32 + %5 = llvm.sub %arg1, %1 : i32 + %6 = llvm.ashr %4, %5 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.icmp "ne" %6, %2 : i32 + llvm.return %7 : i1 + } + llvm.func @highest_bit_test_via_ashr_with_truncation(%arg0: i64, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.zext %3 : i32 to i64 + %5 = llvm.ashr %arg0, %4 : i64 + %6 = llvm.trunc %5 : i64 to i32 + %7 = llvm.sub %arg1, %1 : i32 + %8 = llvm.ashr %6, %7 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.icmp "ne" %8, %2 : i32 + llvm.return %9 : i1 + } + llvm.func @highest_bit_test_via_lshr_ashr(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.lshr %arg0, %3 : i32 + %5 = llvm.sub %arg1, %1 : i32 + %6 = llvm.ashr %4, %5 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.icmp "ne" %6, %2 : i32 + llvm.return %7 : i1 + } + llvm.func @highest_bit_test_via_lshr_ashe_with_truncation(%arg0: i64, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.zext %3 : i32 to i64 + %5 = llvm.lshr %arg0, %4 : i64 + %6 = llvm.trunc %5 : i64 to i32 + %7 = llvm.sub %arg1, %1 : i32 + %8 = llvm.ashr %6, %7 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.icmp "ne" %8, %2 : i32 + llvm.return %9 : i1 + } + llvm.func @highest_bit_test_via_ashr_lshr(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.ashr %arg0, %3 : i32 + %5 = llvm.sub %arg1, %1 : i32 + %6 = llvm.lshr %4, %5 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%5) : (i32) -> () + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.icmp "ne" %6, %2 : i32 + llvm.return %7 : i1 + } + llvm.func @highest_bit_test_via_ashr_lshr_with_truncation(%arg0: i64, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.zext %3 : i32 to i64 + %5 = llvm.ashr %arg0, %4 : i64 + %6 = llvm.trunc %5 : i64 to i32 + %7 = llvm.sub %arg1, %1 : i32 + %8 = llvm.lshr %6, %7 : i32 + llvm.call @use32(%3) : (i32) -> () + llvm.call @use64(%4) : (i64) -> () + llvm.call @use64(%5) : (i64) -> () + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.icmp "ne" %8, %2 : i32 + llvm.return %9 : i1 + } + llvm.func @unsigned_sign_bit_extract(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @unsigned_sign_bit_extract_extrause(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @unsigned_sign_bit_extract_extrause__ispositive(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @signed_sign_bit_extract(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @signed_sign_bit_extract_extrause(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.icmp "ne" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @unsigned_sign_bit_extract_with_trunc(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @unsigned_sign_bit_extract_with_trunc_extrause(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %arg0, %0 : i64 + llvm.call @use64(%2) : (i64) -> () + %3 = llvm.trunc %2 : i64 to i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @signed_sign_bit_extract_trunc(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @signed_sign_bit_extract_trunc_extrause(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i64 + llvm.call @use64(%2) : (i64) -> () + %3 = llvm.trunc %2 : i64 to i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/sign-test-and-or.ll.mlir b/test/LLVMDialect/InstCombine/sign-test-and-or.ll.mlir new file mode 100644 index 000000000..f9541f5ca --- /dev/null +++ b/test/LLVMDialect/InstCombine/sign-test-and-or.ll.mlir @@ -0,0 +1,254 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo() + llvm.func @test1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.icmp "slt" %arg1, %0 : i32 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @test1_splat(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.icmp "slt" %arg0, %1 : vector<2xi32> + %3 = llvm.icmp "slt" %arg1, %1 : vector<2xi32> + %4 = llvm.or %2, %3 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @test1_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg1, %0 : i32 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @test2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.icmp "sgt" %arg1, %0 : i32 + %3 = llvm.or %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @test2_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg1, %0 : i32 + %4 = llvm.select %2, %1, %3 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @test3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %0 : i32 + %2 = llvm.icmp "slt" %arg1, %0 : i32 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @test3_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg1, %0 : i32 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @test4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + %2 = llvm.icmp "sgt" %arg1, %0 : i32 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @test4_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg1, %0 : i32 + %4 = llvm.select %2, %3, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @test5(%arg0: i32) { + %0 = llvm.mlir.constant(134217728 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.icmp "sgt" %arg0, %2 : i32 + %6 = llvm.and %4, %5 : i1 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo() : () -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @test5_logical(%arg0: i32) { + %0 = llvm.mlir.constant(134217728 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.icmp "sgt" %arg0, %2 : i32 + %7 = llvm.select %5, %6, %3 : i1, i1 + llvm.cond_br %7, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo() : () -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @test6(%arg0: i32) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(134217728 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo() : () -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @test6_logical(%arg0: i32) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(134217728 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "sgt" %arg0, %0 : i32 + %5 = llvm.and %arg0, %1 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + %7 = llvm.select %4, %6, %3 : i1, i1 + llvm.cond_br %7, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo() : () -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @test7(%arg0: i32) { + %0 = llvm.mlir.constant(134217728 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "ne" %2, %1 : i32 + %4 = llvm.icmp "slt" %arg0, %1 : i32 + %5 = llvm.or %3, %4 : i1 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo() : () -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @test7_logical(%arg0: i32) { + %0 = llvm.mlir.constant(134217728 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.icmp "slt" %arg0, %1 : i32 + %6 = llvm.select %4, %2, %5 : i1, i1 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo() : () -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @test8(%arg0: i32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(134217728 : i32) : i32 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.icmp "ne" %3, %0 : i32 + %5 = llvm.or %2, %4 : i1 + llvm.cond_br %5, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo() : () -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @test8_logical(%arg0: i32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(134217728 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.and %arg0, %1 : i32 + %5 = llvm.icmp "ne" %4, %0 : i32 + %6 = llvm.select %3, %2, %5 : i1, i1 + llvm.cond_br %6, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo() : () -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @test9(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1073741824 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.icmp "sgt" %arg0, %2 : i32 + %6 = llvm.and %4, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @test9_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1073741824 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.icmp "sgt" %arg0, %2 : i32 + %7 = llvm.select %5, %6, %3 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @test10(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.icmp "ult" %arg0, %2 : i32 + %6 = llvm.and %4, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @test10_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.icmp "ult" %arg0, %2 : i32 + %7 = llvm.select %5, %6, %3 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @test11(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.icmp "ugt" %arg0, %2 : i32 + %6 = llvm.or %4, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @test11_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "ne" %4, %1 : i32 + %6 = llvm.icmp "ugt" %arg0, %2 : i32 + %7 = llvm.select %5, %3, %6 : i1, i1 + llvm.return %7 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/signbit-lshr-and-icmpeq-zero.ll.mlir b/test/LLVMDialect/InstCombine/signbit-lshr-and-icmpeq-zero.ll.mlir new file mode 100644 index 000000000..106576610 --- /dev/null +++ b/test/LLVMDialect/InstCombine/signbit-lshr-and-icmpeq-zero.ll.mlir @@ -0,0 +1,182 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @scalar_i8_signbit_lshr_and_eq(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.lshr %0, %arg1 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @scalar_i16_signbit_lshr_and_eq(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(-32768 : i16) : i16 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.lshr %0, %arg1 : i16 + %3 = llvm.and %2, %arg0 : i16 + %4 = llvm.icmp "eq" %3, %1 : i16 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_signbit_lshr_and_eq(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @scalar_i64_signbit_lshr_and_eq(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.lshr %0, %arg1 : i64 + %3 = llvm.and %2, %arg0 : i64 + %4 = llvm.icmp "eq" %3, %1 : i64 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_signbit_lshr_and_ne(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @vec_4xi32_signbit_lshr_and_eq(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %3 = llvm.lshr %0, %arg1 : vector<4xi32> + %4 = llvm.and %3, %arg0 : vector<4xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<4xi32> + llvm.return %5 : vector<4xi1> + } + llvm.func @vec_4xi32_signbit_lshr_and_eq_undef1(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(2147473648 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.undef : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %14 = llvm.lshr %11, %arg1 : vector<4xi32> + %15 = llvm.and %14, %arg0 : vector<4xi32> + %16 = llvm.icmp "eq" %15, %13 : vector<4xi32> + llvm.return %16 : vector<4xi1> + } + llvm.func @vec_4xi32_signbit_lshr_and_eq_undef2(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<[-2147483648, -2147483648, -2147483648, 2147473648]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %2, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<4xi32> + %12 = llvm.lshr %0, %arg1 : vector<4xi32> + %13 = llvm.and %12, %arg0 : vector<4xi32> + %14 = llvm.icmp "eq" %13, %11 : vector<4xi32> + llvm.return %14 : vector<4xi1> + } + llvm.func @vec_4xi32_signbit_lshr_and_eq_undef3(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(2147473648 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.undef : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.mlir.undef : vector<4xi32> + %14 = llvm.mlir.constant(0 : i32) : i32 + %15 = llvm.insertelement %2, %13[%14 : i32] : vector<4xi32> + %16 = llvm.mlir.constant(1 : i32) : i32 + %17 = llvm.insertelement %12, %15[%16 : i32] : vector<4xi32> + %18 = llvm.mlir.constant(2 : i32) : i32 + %19 = llvm.insertelement %12, %17[%18 : i32] : vector<4xi32> + %20 = llvm.mlir.constant(3 : i32) : i32 + %21 = llvm.insertelement %12, %19[%20 : i32] : vector<4xi32> + %22 = llvm.lshr %11, %arg1 : vector<4xi32> + %23 = llvm.and %22, %arg0 : vector<4xi32> + %24 = llvm.icmp "eq" %23, %21 : vector<4xi32> + llvm.return %24 : vector<4xi1> + } + llvm.func @scalar_i32_signbit_lshr_and_eq_extra_use_lshr(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %0, %arg1 : i32 + %3 = llvm.xor %2, %arg2 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.and %2, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_signbit_lshr_and_eq_extra_use_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.mul %3, %arg2 : i32 + llvm.store %4, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_signbit_lshr_and_eq_extra_use_lshr_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr, %arg4: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.add %2, %arg2 : i32 + llvm.store %4, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_signbit_lshr_and_eq_X_is_constant1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(12345 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_signbit_lshr_and_eq_X_is_constant2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.lshr %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_signbit_lshr_and_slt(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.lshr %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_signbit_lshr_and_eq_nonzero(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.lshr %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/signbit-shl-and-icmpeq-zero.ll.mlir b/test/LLVMDialect/InstCombine/signbit-shl-and-icmpeq-zero.ll.mlir new file mode 100644 index 000000000..d624dc273 --- /dev/null +++ b/test/LLVMDialect/InstCombine/signbit-shl-and-icmpeq-zero.ll.mlir @@ -0,0 +1,182 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @scalar_i8_signbit_shl_and_eq(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %0, %arg1 : i8 + %3 = llvm.and %2, %arg0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @scalar_i16_signbit_shl_and_eq(%arg0: i16, %arg1: i16) -> i1 { + %0 = llvm.mlir.constant(-32768 : i16) : i16 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.shl %0, %arg1 : i16 + %3 = llvm.and %2, %arg0 : i16 + %4 = llvm.icmp "eq" %3, %1 : i16 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_signbit_shl_and_eq(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @scalar_i64_signbit_shl_and_eq(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(-9223372036854775808 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.shl %0, %arg1 : i64 + %3 = llvm.and %2, %arg0 : i64 + %4 = llvm.icmp "eq" %3, %1 : i64 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_signbit_shl_and_ne(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @vec_4xi32_signbit_shl_and_eq(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %3 = llvm.shl %0, %arg1 : vector<4xi32> + %4 = llvm.and %3, %arg0 : vector<4xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<4xi32> + llvm.return %5 : vector<4xi1> + } + llvm.func @vec_4xi32_signbit_shl_and_eq_undef1(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(2147473648 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.undef : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %14 = llvm.shl %11, %arg1 : vector<4xi32> + %15 = llvm.and %14, %arg0 : vector<4xi32> + %16 = llvm.icmp "eq" %15, %13 : vector<4xi32> + llvm.return %16 : vector<4xi1> + } + llvm.func @vec_4xi32_signbit_shl_and_eq_undef2(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<[-2147483648, -2147483648, -2147483648, 2147473648]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %2, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<4xi32> + %12 = llvm.shl %0, %arg1 : vector<4xi32> + %13 = llvm.and %12, %arg0 : vector<4xi32> + %14 = llvm.icmp "eq" %13, %11 : vector<4xi32> + llvm.return %14 : vector<4xi1> + } + llvm.func @vec_4xi32_signbit_shl_and_eq_undef3(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { + %0 = llvm.mlir.constant(2147473648 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.mlir.undef : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.mlir.undef : vector<4xi32> + %14 = llvm.mlir.constant(0 : i32) : i32 + %15 = llvm.insertelement %2, %13[%14 : i32] : vector<4xi32> + %16 = llvm.mlir.constant(1 : i32) : i32 + %17 = llvm.insertelement %12, %15[%16 : i32] : vector<4xi32> + %18 = llvm.mlir.constant(2 : i32) : i32 + %19 = llvm.insertelement %12, %17[%18 : i32] : vector<4xi32> + %20 = llvm.mlir.constant(3 : i32) : i32 + %21 = llvm.insertelement %12, %19[%20 : i32] : vector<4xi32> + %22 = llvm.shl %11, %arg1 : vector<4xi32> + %23 = llvm.and %22, %arg0 : vector<4xi32> + %24 = llvm.icmp "eq" %23, %21 : vector<4xi32> + llvm.return %24 : vector<4xi1> + } + llvm.func @scalar_i32_signbit_shl_and_eq_extra_use_shl(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.xor %2, %arg2 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.and %2, %arg0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_signbit_shl_and_eq_extra_use_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.mul %3, %arg2 : i32 + llvm.store %4, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_signbit_shl_and_eq_extra_use_shl_and(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr, %arg4: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.store %3, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %4 = llvm.add %2, %arg2 : i32 + llvm.store %4, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_signbit_shl_and_eq_X_is_constant1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(12345 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_signbit_shl_and_eq_X_is_constant2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.shl %0, %arg0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @scalar_i32_signbit_shl_and_slt(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @scalar_i32_signbit_shl_and_eq_nonzero(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/signed-comparison.ll.mlir b/test/LLVMDialect/InstCombine/signed-comparison.ll.mlir index c69a8be10..eddff8c86 100644 --- a/test/LLVMDialect/InstCombine/signed-comparison.ll.mlir +++ b/test/LLVMDialect/InstCombine/signed-comparison.ll.mlir @@ -1,17 +1,14 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 500 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i16) -> i32 - %2 = "llvm.icmp"(%1, %0) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "scalar_zext_slt", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi16>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[500, 0, 501, 65535]> : vector<4xi32>} : () -> vector<4xi32> - %1 = "llvm.zext"(%arg0) : (vector<4xi16>) -> vector<4xi32> - %2 = "llvm.icmp"(%1, %0) {predicate = 2 : i64} : (vector<4xi32>, vector<4xi32>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "vector_zext_slt", type = !llvm.func (vector<4xi16>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @scalar_zext_slt(%arg0: i16) -> i1 { + %0 = llvm.mlir.constant(500 : i32) : i32 + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.icmp "slt" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @vector_zext_slt(%arg0: vector<4xi16>) -> vector<4xi1> { + %0 = llvm.mlir.constant(dense<[500, 0, 501, 65535]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.zext %arg0 : vector<4xi16> to vector<4xi32> + %2 = llvm.icmp "slt" %1, %0 : vector<4xi32> + llvm.return %2 : vector<4xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/signed-mul-lack-of-overflow-check-via-mul-sdiv.ll.mlir b/test/LLVMDialect/InstCombine/signed-mul-lack-of-overflow-check-via-mul-sdiv.ll.mlir index aea57f056..952aa3cc6 100644 --- a/test/LLVMDialect/InstCombine/signed-mul-lack-of-overflow-check-via-mul-sdiv.ll.mlir +++ b/test/LLVMDialect/InstCombine/signed-mul-lack-of-overflow-check-via-mul-sdiv.ll.mlir @@ -1,91 +1,77 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.sdiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg1) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0_basic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %1 = "llvm.sdiv"(%0, %arg0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %2 = "llvm.icmp"(%1, %arg1) {predicate = 0 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t1_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.mul"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.sdiv"(%1, %arg0) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t2_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.mul"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.sdiv"(%1, %arg0) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t3_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.mul"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.sdiv"(%1, %arg0) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%0, %2) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t4_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.sdiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg1) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t5_extrause0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.sdiv"(%0, %arg0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg1) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t6_extrause1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.sdiv"(%0, %arg0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg1) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t7_extrause2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg2) : (i8, i8) -> i8 - %1 = "llvm.sdiv"(%0, %arg1) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg2) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n8_different_x", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.sdiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg2) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n9_different_y", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.sdiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg1) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n10_wrong_pred", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.sdiv %0, %arg0 : i8 + %2 = llvm.icmp "eq" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @t1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mul %arg0, %arg1 : vector<2xi8> + %1 = llvm.sdiv %0, %arg0 : vector<2xi8> + %2 = llvm.icmp "eq" %1, %arg1 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @gen8() -> i8 + llvm.func @t2_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.mul %0, %arg0 : i8 + %2 = llvm.sdiv %1, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %0 : i8 + llvm.return %3 : i1 + } + llvm.func @t3_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.mul %0, %arg0 : i8 + %2 = llvm.sdiv %1, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %0 : i8 + llvm.return %3 : i1 + } + llvm.func @t4_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.mul %0, %arg0 : i8 + %2 = llvm.sdiv %1, %arg0 : i8 + %3 = llvm.icmp "eq" %0, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @use8(i8) + llvm.func @t5_extrause0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sdiv %0, %arg0 : i8 + %2 = llvm.icmp "eq" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @t6_extrause1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.sdiv %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "eq" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @t7_extrause2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sdiv %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "eq" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @n8_different_x(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mul %arg0, %arg2 : i8 + %1 = llvm.sdiv %0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @n9_different_y(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.sdiv %0, %arg0 : i8 + %2 = llvm.icmp "eq" %1, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @n10_wrong_pred(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.sdiv %0, %arg0 : i8 + %2 = llvm.icmp "ult" %1, %arg1 : i8 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/signed-mul-overflow-check-via-mul-sdiv.ll.mlir b/test/LLVMDialect/InstCombine/signed-mul-overflow-check-via-mul-sdiv.ll.mlir index 9b7d6b133..7223323d5 100644 --- a/test/LLVMDialect/InstCombine/signed-mul-overflow-check-via-mul-sdiv.ll.mlir +++ b/test/LLVMDialect/InstCombine/signed-mul-overflow-check-via-mul-sdiv.ll.mlir @@ -1,91 +1,77 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.sdiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg1) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0_basic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %1 = "llvm.sdiv"(%0, %arg0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %2 = "llvm.icmp"(%1, %arg1) {predicate = 1 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t1_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.mul"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.sdiv"(%1, %arg0) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t2_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.mul"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.sdiv"(%1, %arg0) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t3_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.mul"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.sdiv"(%1, %arg0) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%0, %2) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t4_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.sdiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg1) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t5_extrause0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.sdiv"(%0, %arg0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg1) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t6_extrause1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.sdiv"(%0, %arg0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg1) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t7_extrause2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg2) : (i8, i8) -> i8 - %1 = "llvm.sdiv"(%0, %arg1) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg2) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n8_different_x", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.sdiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg2) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n9_different_y", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.sdiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg1) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n10_wrong_pred", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.sdiv %0, %arg0 : i8 + %2 = llvm.icmp "ne" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @t1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mul %arg0, %arg1 : vector<2xi8> + %1 = llvm.sdiv %0, %arg0 : vector<2xi8> + %2 = llvm.icmp "ne" %1, %arg1 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @gen8() -> i8 + llvm.func @t2_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.mul %0, %arg0 : i8 + %2 = llvm.sdiv %1, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %0 : i8 + llvm.return %3 : i1 + } + llvm.func @t3_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.mul %0, %arg0 : i8 + %2 = llvm.sdiv %1, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %0 : i8 + llvm.return %3 : i1 + } + llvm.func @t4_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.mul %0, %arg0 : i8 + %2 = llvm.sdiv %1, %arg0 : i8 + %3 = llvm.icmp "ne" %0, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @use8(i8) + llvm.func @t5_extrause0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sdiv %0, %arg0 : i8 + %2 = llvm.icmp "ne" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @t6_extrause1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.sdiv %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @t7_extrause2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sdiv %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @n8_different_x(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mul %arg0, %arg2 : i8 + %1 = llvm.sdiv %0, %arg1 : i8 + %2 = llvm.icmp "ne" %1, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @n9_different_y(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.sdiv %0, %arg0 : i8 + %2 = llvm.icmp "ne" %1, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @n10_wrong_pred(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.sdiv %0, %arg0 : i8 + %2 = llvm.icmp "ugt" %1, %arg1 : i8 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/signed-truncation-check.ll.mlir b/test/LLVMDialect/InstCombine/signed-truncation-check.ll.mlir new file mode 100644 index 000000000..b360b2ae7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/signed-truncation-check.ll.mlir @@ -0,0 +1,792 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @positive_with_signbit(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.icmp "ult" %4, %2 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @positive_with_signbit_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "sgt" %arg0, %0 : i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %4, %6, %3 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @positive_with_mask(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1107296256 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.mlir.constant(256 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.add %arg0, %2 : i32 + %7 = llvm.icmp "ult" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @positive_with_mask_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1107296256 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.mlir.constant(256 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.add %arg0, %2 : i32 + %8 = llvm.icmp "ult" %7, %3 : i32 + %9 = llvm.select %6, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @positive_with_icmp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(512 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.icmp "ult" %4, %2 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @positive_with_icmp_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(512 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "ult" %arg0, %0 : i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %4, %6, %3 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @positive_with_aggressive_icmp(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(256 : i32) : i32 + %2 = llvm.mlir.constant(512 : i32) : i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.icmp "ult" %4, %2 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @positive_with_aggressive_icmp_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(256 : i32) : i32 + %2 = llvm.mlir.constant(512 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "ult" %arg0, %0 : i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %4, %6, %3 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @positive_with_extra_and(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.icmp "ult" %4, %2 : i32 + %6 = llvm.and %3, %arg1 : i1 + %7 = llvm.and %5, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @positive_with_extra_and_logical(%arg0: i32, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "sgt" %arg0, %0 : i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %4, %arg1, %3 : i1, i1 + %8 = llvm.select %6, %7, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @positive_vec_splat(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<128> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<256> : vector<2xi32>) : vector<2xi32> + %3 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %4 = llvm.add %arg0, %1 : vector<2xi32> + %5 = llvm.icmp "ult" %4, %2 : vector<2xi32> + %6 = llvm.and %3, %5 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @positive_vec_nonsplat(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[128, 256]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[256, 512]> : vector<2xi32>) : vector<2xi32> + %3 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %4 = llvm.add %arg0, %1 : vector<2xi32> + %5 = llvm.icmp "ult" %4, %2 : vector<2xi32> + %6 = llvm.and %3, %5 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @positive_vec_poison0(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(dense<128> : vector<3xi32>) : vector<3xi32> + %10 = llvm.mlir.constant(dense<256> : vector<3xi32>) : vector<3xi32> + %11 = llvm.icmp "sgt" %arg0, %8 : vector<3xi32> + %12 = llvm.add %arg0, %9 : vector<3xi32> + %13 = llvm.icmp "ult" %12, %10 : vector<3xi32> + %14 = llvm.and %11, %13 : vector<3xi1> + llvm.return %14 : vector<3xi1> + } + llvm.func @positive_vec_poison1(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.undef : vector<3xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi32> + %10 = llvm.mlir.constant(dense<256> : vector<3xi32>) : vector<3xi32> + %11 = llvm.icmp "sgt" %arg0, %0 : vector<3xi32> + %12 = llvm.add %arg0, %9 : vector<3xi32> + %13 = llvm.icmp "ult" %12, %10 : vector<3xi32> + %14 = llvm.and %11, %13 : vector<3xi1> + llvm.return %14 : vector<3xi1> + } + llvm.func @positive_vec_poison2(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(dense<128> : vector<3xi32>) : vector<3xi32> + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.mlir.poison : i32 + %4 = llvm.mlir.undef : vector<3xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %2, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %3, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %2, %8[%9 : i32] : vector<3xi32> + %11 = llvm.icmp "sgt" %arg0, %0 : vector<3xi32> + %12 = llvm.add %arg0, %1 : vector<3xi32> + %13 = llvm.icmp "ult" %12, %10 : vector<3xi32> + %14 = llvm.and %11, %13 : vector<3xi1> + llvm.return %14 : vector<3xi1> + } + llvm.func @positive_vec_poison3(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(128 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.mlir.constant(dense<256> : vector<3xi32>) : vector<3xi32> + %18 = llvm.icmp "sgt" %arg0, %8 : vector<3xi32> + %19 = llvm.add %arg0, %16 : vector<3xi32> + %20 = llvm.icmp "ult" %19, %17 : vector<3xi32> + %21 = llvm.and %18, %20 : vector<3xi1> + llvm.return %21 : vector<3xi1> + } + llvm.func @positive_vec_poison4(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(dense<128> : vector<3xi32>) : vector<3xi32> + %10 = llvm.mlir.constant(256 : i32) : i32 + %11 = llvm.mlir.undef : vector<3xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.insertelement %10, %11[%12 : i32] : vector<3xi32> + %14 = llvm.mlir.constant(1 : i32) : i32 + %15 = llvm.insertelement %1, %13[%14 : i32] : vector<3xi32> + %16 = llvm.mlir.constant(2 : i32) : i32 + %17 = llvm.insertelement %10, %15[%16 : i32] : vector<3xi32> + %18 = llvm.icmp "sgt" %arg0, %8 : vector<3xi32> + %19 = llvm.add %arg0, %9 : vector<3xi32> + %20 = llvm.icmp "ult" %19, %17 : vector<3xi32> + %21 = llvm.and %18, %20 : vector<3xi1> + llvm.return %21 : vector<3xi1> + } + llvm.func @positive_vec_poison5(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.undef : vector<3xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<3xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<3xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<3xi32> + %10 = llvm.mlir.constant(256 : i32) : i32 + %11 = llvm.mlir.undef : vector<3xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.insertelement %10, %11[%12 : i32] : vector<3xi32> + %14 = llvm.mlir.constant(1 : i32) : i32 + %15 = llvm.insertelement %2, %13[%14 : i32] : vector<3xi32> + %16 = llvm.mlir.constant(2 : i32) : i32 + %17 = llvm.insertelement %10, %15[%16 : i32] : vector<3xi32> + %18 = llvm.icmp "sgt" %arg0, %0 : vector<3xi32> + %19 = llvm.add %arg0, %9 : vector<3xi32> + %20 = llvm.icmp "ult" %19, %17 : vector<3xi32> + %21 = llvm.and %18, %20 : vector<3xi1> + llvm.return %21 : vector<3xi1> + } + llvm.func @positive_vec_poison6(%arg0: vector<3xi32>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(128 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %1, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %9, %14[%15 : i32] : vector<3xi32> + %17 = llvm.mlir.constant(256 : i32) : i32 + %18 = llvm.mlir.undef : vector<3xi32> + %19 = llvm.mlir.constant(0 : i32) : i32 + %20 = llvm.insertelement %17, %18[%19 : i32] : vector<3xi32> + %21 = llvm.mlir.constant(1 : i32) : i32 + %22 = llvm.insertelement %1, %20[%21 : i32] : vector<3xi32> + %23 = llvm.mlir.constant(2 : i32) : i32 + %24 = llvm.insertelement %17, %22[%23 : i32] : vector<3xi32> + %25 = llvm.icmp "sgt" %arg0, %8 : vector<3xi32> + %26 = llvm.add %arg0, %16 : vector<3xi32> + %27 = llvm.icmp "ult" %26, %24 : vector<3xi32> + %28 = llvm.and %25, %27 : vector<3xi1> + llvm.return %28 : vector<3xi1> + } + llvm.func @gen32() -> i32 + llvm.func @commutative() -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.call @gen32() : () -> i32 + %4 = llvm.icmp "sgt" %3, %0 : i32 + %5 = llvm.add %3, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.and %6, %4 : i1 + llvm.return %7 : i1 + } + llvm.func @commutative_logical() -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.call @gen32() : () -> i32 + %5 = llvm.icmp "sgt" %4, %0 : i32 + %6 = llvm.add %4, %1 : i32 + %7 = llvm.icmp "ult" %6, %2 : i32 + %8 = llvm.select %7, %5, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @commutative_with_icmp() -> i1 { + %0 = llvm.mlir.constant(512 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.call @gen32() : () -> i32 + %4 = llvm.icmp "ult" %3, %0 : i32 + %5 = llvm.add %3, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.and %6, %4 : i1 + llvm.return %7 : i1 + } + llvm.func @commutative_with_icmp_logical() -> i1 { + %0 = llvm.mlir.constant(512 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.call @gen32() : () -> i32 + %5 = llvm.icmp "ult" %4, %0 : i32 + %6 = llvm.add %4, %1 : i32 + %7 = llvm.icmp "ult" %6, %2 : i32 + %8 = llvm.select %7, %5, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @positive_trunc_signbit(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.trunc %arg0 : i32 to i8 + %4 = llvm.icmp "sgt" %3, %0 : i8 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @positive_trunc_signbit_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.trunc %arg0 : i32 to i8 + %5 = llvm.icmp "sgt" %4, %0 : i8 + %6 = llvm.add %arg0, %1 : i32 + %7 = llvm.icmp "ult" %6, %2 : i32 + %8 = llvm.select %5, %7, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @positive_trunc_base(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i16) : i16 + %1 = llvm.mlir.constant(128 : i16) : i16 + %2 = llvm.mlir.constant(256 : i16) : i16 + %3 = llvm.trunc %arg0 : i32 to i16 + %4 = llvm.icmp "sgt" %3, %0 : i16 + %5 = llvm.add %3, %1 : i16 + %6 = llvm.icmp "ult" %5, %2 : i16 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @positive_trunc_base_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i16) : i16 + %1 = llvm.mlir.constant(128 : i16) : i16 + %2 = llvm.mlir.constant(256 : i16) : i16 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.trunc %arg0 : i32 to i16 + %5 = llvm.icmp "sgt" %4, %0 : i16 + %6 = llvm.add %4, %1 : i16 + %7 = llvm.icmp "ult" %6, %2 : i16 + %8 = llvm.select %5, %7, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @positive_different_trunc_both(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i15) : i15 + %1 = llvm.mlir.constant(128 : i16) : i16 + %2 = llvm.mlir.constant(256 : i16) : i16 + %3 = llvm.trunc %arg0 : i32 to i15 + %4 = llvm.icmp "sgt" %3, %0 : i15 + %5 = llvm.trunc %arg0 : i32 to i16 + %6 = llvm.add %5, %1 : i16 + %7 = llvm.icmp "ult" %6, %2 : i16 + %8 = llvm.and %4, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @positive_different_trunc_both_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i15) : i15 + %1 = llvm.mlir.constant(128 : i16) : i16 + %2 = llvm.mlir.constant(256 : i16) : i16 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.trunc %arg0 : i32 to i15 + %5 = llvm.icmp "sgt" %4, %0 : i15 + %6 = llvm.trunc %arg0 : i32 to i16 + %7 = llvm.add %6, %1 : i16 + %8 = llvm.icmp "ult" %7, %2 : i16 + %9 = llvm.select %5, %8, %3 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @use32(i32) + llvm.func @use8(i8) + llvm.func @use1(i1) + llvm.func @oneuse_with_signbit(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.add %arg0, %1 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.icmp "ult" %4, %2 : i32 + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @oneuse_with_signbit_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.add %arg0, %1 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.icmp "ult" %5, %2 : i32 + llvm.call @use1(%6) : (i1) -> () + %7 = llvm.select %4, %6, %3 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @oneuse_with_mask(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(603979776 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.mlir.constant(256 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.add %arg0, %2 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.icmp "ult" %6, %3 : i32 + llvm.call @use1(%7) : (i1) -> () + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @oneuse_with_mask_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(603979776 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.mlir.constant(256 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.icmp "eq" %5, %1 : i32 + llvm.call @use1(%6) : (i1) -> () + %7 = llvm.add %arg0, %2 : i32 + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.icmp "ult" %7, %3 : i32 + llvm.call @use1(%8) : (i1) -> () + %9 = llvm.select %6, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @oneuse_shl_ashr(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.trunc %arg0 : i32 to i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "sgt" %2, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.shl %arg0, %1 : i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.ashr %4, %1 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.icmp "eq" %5, %arg0 : i32 + llvm.call @use1(%6) : (i1) -> () + %7 = llvm.and %3, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @oneuse_shl_ashr_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.trunc %arg0 : i32 to i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "sgt" %3, %0 : i8 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.shl %arg0, %1 : i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.ashr %5, %1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.icmp "eq" %6, %arg0 : i32 + llvm.call @use1(%7) : (i1) -> () + %8 = llvm.select %4, %7, %2 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @oneuse_trunc_sext(%arg0: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.trunc %arg0 : i32 to i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "sgt" %1, %0 : i8 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.trunc %arg0 : i32 to i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.sext %3 : i8 to i32 + llvm.call @use32(%4) : (i32) -> () + %5 = llvm.icmp "eq" %4, %arg0 : i32 + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.and %2, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @oneuse_trunc_sext_logical(%arg0: i32) -> (i1 {llvm.zeroext}) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.trunc %arg0 : i32 to i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "sgt" %2, %0 : i8 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.trunc %arg0 : i32 to i8 + llvm.call @use8(%4) : (i8) -> () + %5 = llvm.sext %4 : i8 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.icmp "eq" %5, %arg0 : i32 + llvm.call @use1(%6) : (i1) -> () + %7 = llvm.select %3, %6, %1 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @negative_not_arg(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.add %arg1, %1 : i32 + %5 = llvm.icmp "ult" %4, %2 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @negative_not_arg_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "sgt" %arg0, %0 : i32 + %5 = llvm.add %arg1, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %4, %6, %3 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @negative_trunc_not_arg(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.trunc %arg0 : i32 to i8 + %4 = llvm.icmp "sgt" %3, %0 : i8 + %5 = llvm.add %arg1, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.and %4, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @negative_trunc_not_arg_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.trunc %arg0 : i32 to i8 + %5 = llvm.icmp "sgt" %4, %0 : i8 + %6 = llvm.add %arg1, %1 : i32 + %7 = llvm.icmp "ult" %6, %2 : i32 + %8 = llvm.select %5, %7, %3 : i1, i1 + llvm.return %8 : i1 + } + llvm.func @positive_with_mask_not_arg(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1140850688 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.mlir.constant(256 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.add %arg1, %2 : i32 + %7 = llvm.icmp "ult" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @positive_with_mask_not_arg_logical(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(1140850688 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.mlir.constant(256 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.add %arg1, %2 : i32 + %8 = llvm.icmp "ult" %7, %3 : i32 + %9 = llvm.select %6, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @negative_with_nonuniform_bad_mask(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1711276033 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.mlir.constant(256 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.add %arg0, %2 : i32 + %7 = llvm.icmp "ult" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @negative_with_nonuniform_bad_mask_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1711276033 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.mlir.constant(256 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.add %arg0, %2 : i32 + %8 = llvm.icmp "ult" %7, %3 : i32 + %9 = llvm.select %6, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @negative_with_uniform_bad_mask(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-16777152 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.mlir.constant(256 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.add %arg0, %2 : i32 + %7 = llvm.icmp "ult" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @negative_with_uniform_bad_mask_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-16777152 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.mlir.constant(256 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.add %arg0, %2 : i32 + %8 = llvm.icmp "ult" %7, %3 : i32 + %9 = llvm.select %6, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @negative_with_wrong_mask(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.mlir.constant(256 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + %6 = llvm.add %arg0, %2 : i32 + %7 = llvm.icmp "ult" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @negative_with_wrong_mask_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.mlir.constant(256 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.and %arg0, %0 : i32 + %6 = llvm.icmp "eq" %5, %1 : i32 + %7 = llvm.add %arg0, %2 : i32 + %8 = llvm.icmp "ult" %7, %3 : i32 + %9 = llvm.select %6, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @negative_not_less_than(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(256 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.add %arg0, %1 : i32 + %4 = llvm.icmp "ult" %3, %1 : i32 + %5 = llvm.and %2, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @negative_not_less_than_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(256 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.icmp "ult" %4, %1 : i32 + %6 = llvm.select %3, %5, %2 : i1, i1 + llvm.return %6 : i1 + } + llvm.func @negative_not_power_of_two(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.icmp "ult" %4, %2 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @negative_not_power_of_two_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "sgt" %arg0, %0 : i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %4, %6, %3 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @negative_not_next_power_of_two(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(64 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.icmp "ult" %4, %2 : i32 + %6 = llvm.and %3, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @negative_not_next_power_of_two_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(64 : i32) : i32 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "sgt" %arg0, %0 : i32 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "ult" %5, %2 : i32 + %7 = llvm.select %4, %6, %3 : i1, i1 + llvm.return %7 : i1 + } + llvm.func @two_signed_truncation_checks(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(512 : i32) : i32 + %1 = llvm.mlir.constant(1024 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.mlir.constant(256 : i32) : i32 + %4 = llvm.add %arg0, %0 : i32 + %5 = llvm.icmp "ult" %4, %1 : i32 + %6 = llvm.add %arg0, %2 : i32 + %7 = llvm.icmp "ult" %6, %3 : i32 + %8 = llvm.and %5, %7 : i1 + llvm.return %8 : i1 + } + llvm.func @two_signed_truncation_checks_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(512 : i32) : i32 + %1 = llvm.mlir.constant(1024 : i32) : i32 + %2 = llvm.mlir.constant(128 : i32) : i32 + %3 = llvm.mlir.constant(256 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.add %arg0, %0 : i32 + %6 = llvm.icmp "ult" %5, %1 : i32 + %7 = llvm.add %arg0, %2 : i32 + %8 = llvm.icmp "ult" %7, %3 : i32 + %9 = llvm.select %6, %8, %4 : i1, i1 + llvm.return %9 : i1 + } + llvm.func @bad_trunc_stc(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(128 : i16) : i16 + %2 = llvm.mlir.constant(256 : i16) : i16 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.trunc %arg0 : i32 to i16 + %5 = llvm.add %4, %1 : i16 + %6 = llvm.icmp "ult" %5, %2 : i16 + %7 = llvm.and %3, %6 : i1 + llvm.return %7 : i1 + } + llvm.func @bad_trunc_stc_logical(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(128 : i16) : i16 + %2 = llvm.mlir.constant(256 : i16) : i16 + %3 = llvm.mlir.constant(false) : i1 + %4 = llvm.icmp "sgt" %arg0, %0 : i32 + %5 = llvm.trunc %arg0 : i32 to i16 + %6 = llvm.add %5, %1 : i16 + %7 = llvm.icmp "ult" %6, %2 : i16 + %8 = llvm.select %4, %7, %3 : i1, i1 + llvm.return %8 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/signext.ll.mlir b/test/LLVMDialect/InstCombine/signext.ll.mlir index 988fe1add..b5a816c35 100644 --- a/test/LLVMDialect/InstCombine/signext.ll.mlir +++ b/test/LLVMDialect/InstCombine/signext.ll.mlir @@ -1,147 +1,130 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32768 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -32768 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 65535 : i32} : () -> i32 - %3 = "llvm.and"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.xor"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.add"(%4, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sextinreg", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32768 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -32768 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 65535 : i32} : () -> i32 - %3 = "llvm.and"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.xor"(%3, %1) : (i32, i32) -> i32 - "llvm.call"(%4) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %5 = "llvm.add"(%4, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sextinreg_extra_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<32768> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.mlir.constant"() {value = dense<-32768> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.mlir.constant"() {value = dense<65535> : vector<2xi32>} : () -> vector<2xi32> - %3 = "llvm.and"(%arg0, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.xor"(%3, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %5 = "llvm.add"(%4, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%5) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "sextinreg_splat", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -32768 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 32768 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 65535 : i32} : () -> i32 - %3 = "llvm.and"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.xor"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.add"(%4, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sextinreg_alt", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-32768> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.mlir.constant"() {value = dense<32768> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.mlir.constant"() {value = dense<65535> : vector<2xi32>} : () -> vector<2xi32> - %3 = "llvm.and"(%arg0, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.xor"(%3, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %5 = "llvm.add"(%4, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%5) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "sextinreg_alt_splat", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = -32768 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 32768 : i32} : () -> i32 - %2 = "llvm.zext"(%arg0) : (i16) -> i32 - %3 = "llvm.xor"(%2, %1) : (i32, i32) -> i32 - %4 = "llvm.add"(%3, %0) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sext", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = -32768 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 32768 : i32} : () -> i32 - %2 = "llvm.zext"(%arg0) : (i16) -> i32 - %3 = "llvm.xor"(%2, %1) : (i32, i32) -> i32 - "llvm.call"(%3) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %4 = "llvm.add"(%3, %0) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sext_extra_use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-32768> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.mlir.constant"() {value = dense<32768> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.zext"(%arg0) : (vector<2xi16>) -> vector<2xi32> - %3 = "llvm.xor"(%2, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.add"(%3, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%4) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "sext_splat", type = !llvm.func (vector<2xi16>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -128 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 128 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 255 : i32} : () -> i32 - %3 = "llvm.and"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.xor"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.add"(%4, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sextinreg2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-128> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.mlir.constant"() {value = dense<128> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.mlir.constant"() {value = dense<255> : vector<2xi32>} : () -> vector<2xi32> - %3 = "llvm.and"(%arg0, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.xor"(%3, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %5 = "llvm.add"(%4, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%5) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "sextinreg2_splat", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.shl"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.ashr"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i16) -> i32 - %2 = "llvm.shl"(%1, %0) : (i32, i32) -> i32 - %3 = "llvm.ashr"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi12>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<20> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.zext"(%arg0) : (vector<2xi12>) -> vector<2xi32> - %2 = "llvm.shl"(%1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.ashr"(%2, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%3) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "test6_splat_vec", type = !llvm.func (vector<2xi12>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -67108864 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 67108864 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %3 = "llvm.lshr"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.xor"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.add"(%4, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "ashr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-67108864> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.mlir.constant"() {value = dense<67108864> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.mlir.constant"() {value = dense<5> : vector<2xi32>} : () -> vector<2xi32> - %3 = "llvm.lshr"(%arg0, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.xor"(%3, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %5 = "llvm.add"(%4, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%5) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "ashr_splat", type = !llvm.func (vector<2xi32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @sextinreg(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.mlir.constant(32768 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.add %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @sextinreg_extra_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.mlir.constant(32768 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.xor %3, %1 : i32 + llvm.call @use(%4) : (i32) -> () + %5 = llvm.add %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @sextinreg_splat(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<65535> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-32768> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<32768> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %0 : vector<2xi32> + %4 = llvm.xor %3, %1 : vector<2xi32> + %5 = llvm.add %4, %2 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @sextinreg_alt(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.mlir.constant(32768 : i32) : i32 + %2 = llvm.mlir.constant(-32768 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.add %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @sextinreg_alt_splat(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<65535> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<32768> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-32768> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %0 : vector<2xi32> + %4 = llvm.xor %3, %1 : vector<2xi32> + %5 = llvm.add %4, %2 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @sext(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(32768 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.zext %arg0 : i16 to i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @sext_extra_use(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(32768 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.zext %arg0 : i16 to i32 + %3 = llvm.xor %2, %0 : i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @sext_splat(%arg0: vector<2xi16>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<32768> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-32768> : vector<2xi32>) : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.xor %2, %0 : vector<2xi32> + %4 = llvm.add %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @sextinreg2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.mlir.constant(-128 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.add %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @sextinreg2_splat(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<255> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<128> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-128> : vector<2xi32>) : vector<2xi32> + %3 = llvm.and %arg0, %0 : vector<2xi32> + %4 = llvm.xor %3, %1 : vector<2xi32> + %5 = llvm.add %4, %2 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test5(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.shl %arg0, %0 : i32 + %2 = llvm.ashr %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @test6(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.zext %arg0 : i16 to i32 + %2 = llvm.shl %1, %0 : i32 + %3 = llvm.ashr %2, %0 : i32 + llvm.return %3 : i32 + } + llvm.func @test6_splat_vec(%arg0: vector<2xi12>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<20> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi12> to vector<2xi32> + %2 = llvm.shl %1, %0 : vector<2xi32> + %3 = llvm.ashr %2, %0 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(67108864 : i32) : i32 + %2 = llvm.mlir.constant(-67108864 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = llvm.xor %3, %1 : i32 + %5 = llvm.add %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @ashr_splat(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<67108864> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<-67108864> : vector<2xi32>) : vector<2xi32> + %3 = llvm.lshr %arg0, %0 : vector<2xi32> + %4 = llvm.xor %3, %1 : vector<2xi32> + %5 = llvm.add %4, %2 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/signmask-of-sext-vs-of-shl-of-zext.ll.mlir b/test/LLVMDialect/InstCombine/signmask-of-sext-vs-of-shl-of-zext.ll.mlir new file mode 100644 index 000000000..395372bf3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/signmask-of-sext-vs-of-shl-of-zext.ll.mlir @@ -0,0 +1,140 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use32(i32) + llvm.func @t0(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.zext %arg0 : i16 to i32 + %3 = llvm.shl %2, %0 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @t1(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.shl %2, %0 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @n2(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.zext %arg0 : i16 to i32 + %3 = llvm.shl %2, %0 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @n3(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(17 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.zext %arg0 : i16 to i32 + %3 = llvm.shl %2, %0 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @n4(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(-1073741824 : i32) : i32 + %2 = llvm.zext %arg0 : i16 to i32 + %3 = llvm.shl %2, %0 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @t5(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.zext %arg0 : i16 to i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %2, %0 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @n6(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.zext %arg0 : i16 to i32 + %3 = llvm.shl %2, %0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @n7(%arg0: i16) -> i32 { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.zext %arg0 : i16 to i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.shl %2, %0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @t8(%arg0: vector<2xi16>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.shl %2, %0 : vector<2xi32> + %4 = llvm.and %3, %1 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @t9(%arg0: vector<2xi16>) -> vector<2xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %8 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %9 = llvm.shl %8, %6 : vector<2xi32> + %10 = llvm.and %9, %7 : vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @t10_undef(%arg0: vector<2xi16>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(-2147483648 : i32) : i32 + %3 = llvm.mlir.undef : vector<2xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi32> + %8 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %9 = llvm.shl %8, %0 : vector<2xi32> + %10 = llvm.and %9, %7 : vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @t10_poison(%arg0: vector<2xi16>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.constant(-2147483648 : i32) : i32 + %3 = llvm.mlir.undef : vector<2xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi32> + %8 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %9 = llvm.shl %8, %0 : vector<2xi32> + %10 = llvm.and %9, %7 : vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @t11(%arg0: vector<2xi16>) -> vector<2xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(-2147483648 : i32) : i32 + %8 = llvm.mlir.undef : vector<2xi32> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi32> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi32> + %13 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %14 = llvm.shl %13, %6 : vector<2xi32> + %15 = llvm.and %14, %12 : vector<2xi32> + llvm.return %15 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/simple_phi_condition.ll.mlir b/test/LLVMDialect/InstCombine/simple_phi_condition.ll.mlir new file mode 100644 index 000000000..f684db6f7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/simple_phi_condition.ll.mlir @@ -0,0 +1,306 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_direct_implication(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : i1) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : i1) + ^bb3(%2: i1): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : i1 + } + llvm.func @test_inverted_implication(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : i1) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : i1) + ^bb3(%2: i1): // 2 preds: ^bb1, ^bb2 + llvm.return %2 : i1 + } + llvm.func @test_edge_dominance(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + llvm.cond_br %arg0, ^bb2(%0 : i1), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : i1) + ^bb2(%2: i1): // 2 preds: ^bb0, ^bb1 + llvm.return %2 : i1 + } + llvm.func @test_direct_implication_complex_cfg(%arg0: i1, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(true) : i1 + llvm.cond_br %arg0, ^bb1, ^bb4 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : i32) + ^bb2(%4: i32): // 2 preds: ^bb1, ^bb2 + %5 = llvm.add %4, %2 : i32 + %6 = llvm.icmp "slt" %5, %arg1 : i32 + llvm.cond_br %6, ^bb2(%5 : i32), ^bb3 + ^bb3: // pred: ^bb2 + llvm.br ^bb5(%3 : i1) + ^bb4: // pred: ^bb0 + llvm.br ^bb5(%0 : i1) + ^bb5(%7: i1): // 2 preds: ^bb3, ^bb4 + llvm.return %7 : i1 + } + llvm.func @test_inverted_implication_complex_cfg(%arg0: i1, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + llvm.cond_br %arg0, ^bb1, ^bb4 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : i32) + ^bb2(%4: i32): // 2 preds: ^bb1, ^bb2 + %5 = llvm.add %4, %2 : i32 + %6 = llvm.icmp "slt" %5, %arg1 : i32 + llvm.cond_br %6, ^bb2(%5 : i32), ^bb3 + ^bb3: // pred: ^bb2 + llvm.br ^bb5(%3 : i1) + ^bb4: // pred: ^bb0 + llvm.br ^bb5(%0 : i1) + ^bb5(%7: i1): // 2 preds: ^bb3, ^bb4 + llvm.return %7 : i1 + } + llvm.func @test_multiple_predecessors(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb5(%1 : i1) + ^bb2: // pred: ^bb0 + llvm.cond_br %arg1, ^bb3, ^bb4 + ^bb3: // pred: ^bb2 + llvm.br ^bb5(%0 : i1) + ^bb4: // pred: ^bb2 + llvm.br ^bb5(%0 : i1) + ^bb5(%2: i1): // 3 preds: ^bb1, ^bb3, ^bb4 + llvm.return %2 : i1 + } + llvm.func @test_multiple_predecessors_wrong_value(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb5(%1 : i1) + ^bb2: // pred: ^bb0 + llvm.cond_br %arg1, ^bb3, ^bb4 + ^bb3: // pred: ^bb2 + llvm.br ^bb5(%1 : i1) + ^bb4: // pred: ^bb2 + llvm.br ^bb5(%0 : i1) + ^bb5(%2: i1): // 3 preds: ^bb1, ^bb3, ^bb4 + llvm.return %2 : i1 + } + llvm.func @test_multiple_predecessors_no_edge_domination(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg1, ^bb5(%0 : i1), ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.cond_br %arg1, ^bb3, ^bb4 + ^bb3: // pred: ^bb2 + llvm.br ^bb5(%1 : i1) + ^bb4: // pred: ^bb2 + llvm.br ^bb5(%1 : i1) + ^bb5(%2: i1): // 3 preds: ^bb1, ^bb3, ^bb4 + llvm.return %2 : i1 + } + llvm.func @test_switch(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(19 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.mlir.constant(42 : i8) : i8 + llvm.switch %arg0 : i8, ^bb4 [ + 1: ^bb1, + 7: ^bb2, + 19: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb5(%2 : i8) + ^bb2: // pred: ^bb0 + llvm.br ^bb5(%1 : i8) + ^bb3: // pred: ^bb0 + llvm.br ^bb5(%0 : i8) + ^bb4: // pred: ^bb0 + llvm.return %3 : i8 + ^bb5(%4: i8): // 3 preds: ^bb1, ^bb2, ^bb3 + llvm.return %4 : i8 + } + llvm.func @test_switch_direct_edge(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(19 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.mlir.constant(42 : i8) : i8 + llvm.switch %arg0 : i8, ^bb3 [ + 1: ^bb1, + 7: ^bb2, + 19: ^bb4(%0 : i8) + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb4(%2 : i8) + ^bb2: // pred: ^bb0 + llvm.br ^bb4(%1 : i8) + ^bb3: // pred: ^bb0 + llvm.return %3 : i8 + ^bb4(%4: i8): // 3 preds: ^bb0, ^bb1, ^bb2 + llvm.return %4 : i8 + } + llvm.func @test_switch_duplicate_direct_edge(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(42 : i8) : i8 + llvm.switch %arg0 : i8, ^bb2 [ + 1: ^bb1, + 7: ^bb3(%0 : i8), + 19: ^bb3(%0 : i8) + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%1 : i8) + ^bb2: // pred: ^bb0 + llvm.return %2 : i8 + ^bb3(%3: i8): // 3 preds: ^bb0, ^bb0, ^bb1 + llvm.return %3 : i8 + } + llvm.func @test_switch_subset(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(24 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.mlir.constant(42 : i8) : i8 + llvm.switch %arg0 : i8, ^bb4 [ + 1: ^bb1, + 7: ^bb2, + 19: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb5(%2 : i8) + ^bb2: // pred: ^bb0 + llvm.br ^bb5(%1 : i8) + ^bb3: // pred: ^bb0 + llvm.return %0 : i8 + ^bb4: // pred: ^bb0 + llvm.return %3 : i8 + ^bb5(%4: i8): // 2 preds: ^bb1, ^bb2 + llvm.return %4 : i8 + } + llvm.func @test_switch_wrong_value(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.mlir.constant(42 : i8) : i8 + llvm.switch %arg0 : i8, ^bb4 [ + 1: ^bb1, + 7: ^bb2, + 19: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb5(%2 : i8) + ^bb2: // pred: ^bb0 + llvm.br ^bb5(%1 : i8) + ^bb3: // pred: ^bb0 + llvm.br ^bb5(%0 : i8) + ^bb4: // pred: ^bb0 + llvm.return %3 : i8 + ^bb5(%4: i8): // 3 preds: ^bb1, ^bb2, ^bb3 + llvm.return %4 : i8 + } + llvm.func @test_switch_inverted(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-3 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.mlir.constant(-1 : i8) : i8 + %3 = llvm.mlir.constant(42 : i8) : i8 + llvm.switch %arg0 : i8, ^bb4 [ + 0: ^bb1, + 1: ^bb2, + 2: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb5(%2 : i8) + ^bb2: // pred: ^bb0 + llvm.br ^bb5(%1 : i8) + ^bb3: // pred: ^bb0 + llvm.br ^bb5(%0 : i8) + ^bb4: // pred: ^bb0 + llvm.return %3 : i8 + ^bb5(%4: i8): // 3 preds: ^bb1, ^bb2, ^bb3 + llvm.return %4 : i8 + } + llvm.func @test_switch_duplicate_edge(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(42 : i8) : i8 + llvm.switch %arg0 : i8, ^bb3 [ + 1: ^bb1, + 7: ^bb2, + 19: ^bb2 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb4(%1 : i8) + ^bb2: // 2 preds: ^bb0, ^bb0 + llvm.br ^bb4(%0 : i8) + ^bb3: // pred: ^bb0 + llvm.return %2 : i8 + ^bb4(%3: i8): // 2 preds: ^bb1, ^bb2 + llvm.return %3 : i8 + } + llvm.func @test_switch_default_edge(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(19 : i8) : i8 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.mlir.constant(1 : i8) : i8 + llvm.switch %arg0 : i8, ^bb4(%0 : i8) [ + 1: ^bb1, + 7: ^bb2, + 19: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb4(%3 : i8) + ^bb2: // pred: ^bb0 + llvm.br ^bb4(%2 : i8) + ^bb3: // pred: ^bb0 + llvm.br ^bb4(%1 : i8) + ^bb4(%4: i8): // 4 preds: ^bb0, ^bb1, ^bb2, ^bb3 + llvm.return %4 : i8 + } + llvm.func @test_switch_default_edge_direct(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(19 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(1 : i8) : i8 + llvm.switch %arg0 : i8, ^bb3(%0 : i8) [ + 1: ^bb1, + 7: ^bb2, + 19: ^bb3(%0 : i8) + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%2 : i8) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%1 : i8) + ^bb3(%3: i8): // 4 preds: ^bb0, ^bb0, ^bb1, ^bb2 + llvm.return %3 : i8 + } + llvm.func @test_switch_default_edge_duplicate(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.mlir.constant(19 : i8) : i8 + llvm.switch %arg0 : i8, ^bb3 [ + 1: ^bb1, + 7: ^bb2, + 19: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb4(%1 : i8) + ^bb2: // pred: ^bb0 + llvm.br ^bb4(%0 : i8) + ^bb3: // 2 preds: ^bb0, ^bb0 + llvm.br ^bb4(%2 : i8) + ^bb4(%3: i8): // 3 preds: ^bb1, ^bb2, ^bb3 + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/simplify-demanded-bits-pointer.ll.mlir b/test/LLVMDialect/InstCombine/simplify-demanded-bits-pointer.ll.mlir new file mode 100644 index 000000000..83822decd --- /dev/null +++ b/test/LLVMDialect/InstCombine/simplify-demanded-bits-pointer.ll.mlir @@ -0,0 +1,54 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func fastcc @cse_insn(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: i1, %arg4: i1, %arg5: i1, %arg6: i1, %arg7: i1, %arg8: i1, %arg9: i1, %arg10: i1, %arg11: i1) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(38 : i16) : i16 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.cond_br %arg4, ^bb3, ^bb4 + ^bb3: // pred: ^bb2 + llvm.unreachable + ^bb4: // pred: ^bb2 + %3 = llvm.load %arg2 {alignment = 8 : i64} : !llvm.ptr -> i16 + %4 = llvm.icmp "eq" %3, %0 : i16 + %5 = llvm.select %4, %1, %1 : i1, !llvm.ptr + llvm.cond_br %arg5, ^bb7, ^bb5 + ^bb5: // pred: ^bb4 + llvm.cond_br %arg6, ^bb7, ^bb6 + ^bb6: // pred: ^bb5 + llvm.cond_br %arg7, ^bb8, ^bb9 + ^bb7: // 2 preds: ^bb4, ^bb5 + llvm.unreachable + ^bb8: // pred: ^bb6 + llvm.br ^bb9 + ^bb9: // 2 preds: ^bb6, ^bb8 + llvm.cond_br %arg8, ^bb10, ^bb11 + ^bb10: // pred: ^bb9 + llvm.unreachable + ^bb11: // pred: ^bb9 + llvm.cond_br %arg9, ^bb12, ^bb15 + ^bb12: // pred: ^bb11 + %6 = llvm.icmp "eq" %1, %1 : !llvm.ptr + %7 = llvm.zext %6 : i1 to i8 + %8 = llvm.icmp "ne" %5, %1 : !llvm.ptr + %9 = llvm.zext %8 : i1 to i8 + %10 = llvm.icmp "ne" %7, %2 : i8 + %11 = llvm.icmp "ne" %9, %2 : i8 + %12 = llvm.and %10, %11 : i1 + %13 = llvm.zext %12 : i1 to i8 + %14 = llvm.icmp "ne" %13, %2 : i8 + llvm.cond_br %14, ^bb13, ^bb15 + ^bb13: // pred: ^bb12 + llvm.cond_br %arg10, ^bb14, ^bb15 + ^bb14: // pred: ^bb13 + llvm.br ^bb15 + ^bb15: // 4 preds: ^bb11, ^bb12, ^bb13, ^bb14 + llvm.cond_br %arg11, ^bb16, ^bb17 + ^bb16: // pred: ^bb15 + llvm.unreachable + ^bb17: // pred: ^bb15 + llvm.unreachable + } +} diff --git a/test/LLVMDialect/InstCombine/simplify-demanded-fpclass.ll.mlir b/test/LLVMDialect/InstCombine/simplify-demanded-fpclass.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/simplify-libcalls-erased.ll.mlir b/test/LLVMDialect/InstCombine/simplify-libcalls-erased.ll.mlir new file mode 100644 index 000000000..6eb60670d --- /dev/null +++ b/test/LLVMDialect/InstCombine/simplify-libcalls-erased.ll.mlir @@ -0,0 +1,12 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @pow_exp(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i1 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %2 = llvm.call @exp(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %3 = llvm.intr.pow(%2, %arg1) {fastmathFlags = #llvm.fastmath} : (f64, f64) -> f64 + %4 = llvm.fcmp "ule" %2, %3 : f64 + llvm.store %4, %1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %3 : f64 + } + llvm.func @exp(f64) -> f64 +} diff --git a/test/LLVMDialect/InstCombine/simplify-libcalls-i16.ll.mlir b/test/LLVMDialect/InstCombine/simplify-libcalls-i16.ll.mlir new file mode 100644 index 000000000..fc2e8f5ec --- /dev/null +++ b/test/LLVMDialect/InstCombine/simplify-libcalls-i16.ll.mlir @@ -0,0 +1,173 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 32 : i64>>} { + llvm.mlir.global external constant @G("%s\00") {addr_space = 0 : i32} + llvm.mlir.global internal constant @str("foog\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global internal constant @str1("blahhh!\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global internal constant @str2("Ponk\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global external constant @_2E_str() {addr_space = 0 : i32} : !llvm.array<5 x i8> + llvm.mlir.global external constant @".str13"() {addr_space = 0 : i32} : !llvm.array<2 x i8> + llvm.mlir.global external constant @".str14"() {addr_space = 0 : i32} : !llvm.array<2 x i8> + llvm.mlir.global external constant @h("h\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hel("hel\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hello_u("hello_u\00") {addr_space = 0 : i32} + llvm.mlir.global external @a("123\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global external @b(dense<0> : tensor<5xi8>) {addr_space = 0 : i32, dso_local} : !llvm.array<5 x i8> + llvm.func @sprintf(!llvm.ptr, !llvm.ptr, ...) -> i16 + llvm.func @foo(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @G : !llvm.ptr + %2 = llvm.call @sprintf(%arg0, %1, %arg1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i16 + llvm.return + } + llvm.func @test1() -> !llvm.ptr { + %0 = llvm.mlir.constant(2 : i16) : i16 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant("foog\00") : !llvm.array<5 x i8> + %3 = llvm.mlir.addressof @str : !llvm.ptr + %4 = llvm.getelementptr inbounds %3[%1, %0] : (!llvm.ptr, i32, i16) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.mlir.constant(103 : i16) : i16 + %6 = llvm.call @strchr(%4, %5) : (!llvm.ptr, i16) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @strchr(!llvm.ptr, i16) -> !llvm.ptr + llvm.func @test2() -> !llvm.ptr { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant("blahhh!\00") : !llvm.array<8 x i8> + %3 = llvm.mlir.addressof @str1 : !llvm.ptr + %4 = llvm.getelementptr inbounds %3[%1, %0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<8 x i8> + %5 = llvm.mlir.constant(0 : i16) : i16 + %6 = llvm.call @strchr(%4, %5) : (!llvm.ptr, i16) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @test3() -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant("Ponk\00") : !llvm.array<5 x i8> + %3 = llvm.mlir.addressof @str2 : !llvm.ptr + %4 = llvm.getelementptr inbounds %3[%1, %0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.mlir.constant(80 : i16) : i16 + %6 = llvm.call @strchr(%4, %5) : (!llvm.ptr, i16) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @memcmp(!llvm.ptr, !llvm.ptr, i16) -> i16 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @PR2341(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.addressof @_2E_str : !llvm.ptr + %1 = llvm.mlir.constant(4 : i16) : i16 + %2 = llvm.mlir.constant(0 : i16) : i16 + %3 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %4 = llvm.call @memcmp(%3, %0, %1) : (!llvm.ptr, !llvm.ptr, i16) -> i16 + %5 = llvm.icmp "eq" %4, %2 : i16 + llvm.return %5 : i1 + } + llvm.func @PR4284() -> i16 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.mlir.constant(-127 : i8) : i8 + %3 = llvm.mlir.constant(1 : i16) : i16 + %4 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %5 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %4 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.store %2, %5 {alignment = 1 : i64} : i8, !llvm.ptr + %6 = llvm.call @memcmp(%4, %5, %3) : (!llvm.ptr, !llvm.ptr, i16) -> i16 + llvm.return %6 : i16 + } + llvm.func @PR4641(%arg0: i32, %arg1: !llvm.ptr, %arg2: i1, %arg3: !llvm.ptr) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.addressof @".str13" : !llvm.ptr + %2 = llvm.mlir.addressof @".str14" : !llvm.ptr + llvm.call @exit(%0) : (i16) -> () + %3 = llvm.select %arg2, %1, %2 : i1, !llvm.ptr + %4 = llvm.call @fopen(%arg3, %3) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.unreachable + } + llvm.func @fopen(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @exit(i16) + llvm.func @PR4645(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.constant(0 : i32) : i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.call @exit(%0) : (i16) -> () + llvm.br ^bb2(%1 : i32) + ^bb2(%2: i32): // pred: ^bb1 + llvm.unreachable + } + llvm.func @MemCpy() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant("h\00") : !llvm.array<2 x i8> + %2 = llvm.mlir.addressof @h : !llvm.ptr + %3 = llvm.mlir.constant(2 : i16) : i16 + %4 = llvm.mlir.constant("hel\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @hel : !llvm.ptr + %6 = llvm.mlir.constant(4 : i16) : i16 + %7 = llvm.mlir.constant("hello_u\00") : !llvm.array<8 x i8> + %8 = llvm.mlir.addressof @hello_u : !llvm.ptr + %9 = llvm.mlir.constant(8 : i16) : i16 + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.alloca %0 x !llvm.array<1024 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%11, %2, %3) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i16) -> () + "llvm.intr.memcpy"(%11, %5, %6) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i16) -> () + "llvm.intr.memcpy"(%11, %8, %9) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i16) -> () + llvm.return %10 : i32 + } + llvm.func @strcmp(!llvm.ptr, !llvm.ptr) -> i16 attributes {passthrough = ["nobuiltin"]} + llvm.func @test9(%arg0: !llvm.ptr) { + %0 = llvm.call @strcmp(%arg0, %arg0) : (!llvm.ptr, !llvm.ptr) -> i16 + llvm.return + } + llvm.func @isdigit(i8) -> i32 + llvm.func @isascii(i8) -> i32 + llvm.func @toascii(i8) -> i32 + llvm.func @fake_isdigit(%arg0: i8) -> i32 { + %0 = llvm.call @isdigit(%arg0) : (i8) -> i32 + llvm.return %0 : i32 + } + llvm.func @fake_isascii(%arg0: i8) -> i32 { + %0 = llvm.call @isascii(%arg0) : (i8) -> i32 + llvm.return %0 : i32 + } + llvm.func @fake_toascii(%arg0: i8) -> i32 { + %0 = llvm.call @toascii(%arg0) : (i8) -> i32 + llvm.return %0 : i32 + } + llvm.func @pow(f64, f64) -> f64 + llvm.func @exp2(f64) -> f64 + llvm.func @fake_exp2(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @fake_ldexp(%arg0: i32) -> f64 { + %0 = llvm.sitofp %arg0 : i32 to f64 + %1 = llvm.call @exp2(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @fake_ldexp_16(%arg0: i16) -> f64 { + %0 = llvm.sitofp %arg0 : i16 to f64 + %1 = llvm.call @exp2(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @snprintf(!llvm.ptr, f64, !llvm.ptr) -> i16 + llvm.func @fake_snprintf(%arg0: i32, %arg1: f64, %arg2: !llvm.ptr, %arg3: !llvm.ptr) -> i16 { + %0 = llvm.call @snprintf(%arg3, %arg1, %arg2) : (!llvm.ptr, f64, !llvm.ptr) -> i16 + llvm.return %0 : i16 + } + llvm.func @strlen(%arg0: !llvm.ptr) -> i4 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.call @strlen(%arg0) : (!llvm.ptr) -> i4 + llvm.return %0 : i4 + } + llvm.func @__stpncpy_chk(!llvm.ptr {llvm.noundef}, !llvm.ptr {llvm.noundef}, i32 {llvm.noundef}, i32 {llvm.noundef}) -> !llvm.ptr + llvm.func @emit_stpncpy() -> (i32 {llvm.signext}) { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<5xi8>) : !llvm.array<5 x i8> + %2 = llvm.mlir.addressof @b : !llvm.ptr + %3 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.addressof @a : !llvm.ptr + %5 = llvm.mlir.constant(2 : i32) : i32 + %6 = llvm.mlir.constant(5 : i32) : i32 + %7 = llvm.mlir.constant(0 : i32) : i32 + %8 = llvm.call @__stpncpy_chk(%2, %4, %5, %6) : (!llvm.ptr, !llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/simplify-libcalls-inreg.ll.mlir b/test/LLVMDialect/InstCombine/simplify-libcalls-inreg.ll.mlir new file mode 100644 index 000000000..2e24858dd --- /dev/null +++ b/test/LLVMDialect/InstCombine/simplify-libcalls-inreg.ll.mlir @@ -0,0 +1,39 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry, dense<32> : vector<4xi64>>, #dlti.dl_entry, dense<64> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.mlir.global common @a(dense<0> : tensor<60xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<60 x i8> + llvm.mlir.global common @b(dense<0> : tensor<60xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<60 x i8> + llvm.mlir.global external constant @h("h\00") {addr_space = 0 : i32} + llvm.func @foo() -> !llvm.ptr + llvm.func @memcmp(!llvm.ptr {llvm.inreg, llvm.nocapture, llvm.noundef}, !llvm.ptr {llvm.inreg, llvm.nocapture, llvm.noundef}, i32 {llvm.inreg, llvm.noundef}) -> i32 + llvm.func @printf(!llvm.ptr, ...) -> i32 + llvm.func @exp2(f64) -> f64 + llvm.func @__sprintf_chk(!llvm.ptr, i32, i32, !llvm.ptr, ...) -> i32 + llvm.func @baz(%arg0: !llvm.ptr {llvm.inreg, llvm.noundef}, %arg1: i32 {llvm.inreg, llvm.noundef}) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @foo() : () -> !llvm.ptr + %2 = llvm.call @memcmp(%1, %arg0, %arg1) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + %4 = llvm.zext %3 : i1 to i32 + llvm.return %4 : i32 + } + llvm.func @test_fewer_params_than_num_register_parameters() { + %0 = llvm.mlir.constant("h\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @h : !llvm.ptr + %2 = llvm.call @printf(%1) vararg(!llvm.func) : (!llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_non_int_params(%arg0: i16 {llvm.signext}) -> f64 { + %0 = llvm.sitofp %arg0 : i16 to f64 + %1 = llvm.call @exp2(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @test_variadic() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(-1 : i32) : i32 + %5 = llvm.mlir.addressof @b : !llvm.ptr + %6 = llvm.call @__sprintf_chk(%2, %3, %4, %5) vararg(!llvm.func) : (!llvm.ptr, i32, i32, !llvm.ptr) -> i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/simplify-libcalls-new.ll.mlir b/test/LLVMDialect/InstCombine/simplify-libcalls-new.ll.mlir new file mode 100644 index 000000000..66518deba --- /dev/null +++ b/test/LLVMDialect/InstCombine/simplify-libcalls-new.ll.mlir @@ -0,0 +1,211 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @new() { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.call @_Znwm(%0) : (i64) -> !llvm.ptr + llvm.call @dummy(%1) : (!llvm.ptr) -> () + %2 = llvm.call @_Znwm(%0) : (i64) -> !llvm.ptr + llvm.call @dummy(%2) : (!llvm.ptr) -> () + %3 = llvm.call @_Znwm(%0) : (i64) -> !llvm.ptr + llvm.call @dummy(%3) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @new_align() { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(8 : i64) : i64 + %2 = llvm.call @_ZnwmSt11align_val_t(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.call @dummy(%2) : (!llvm.ptr) -> () + %3 = llvm.call @_ZnwmSt11align_val_t(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.call @dummy(%3) : (!llvm.ptr) -> () + %4 = llvm.call @_ZnwmSt11align_val_t(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.call @dummy(%4) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @new_nothrow() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %3 = llvm.call @_ZnwmRKSt9nothrow_t(%1, %2) : (i64, !llvm.ptr) -> !llvm.ptr + llvm.call @dummy(%3) : (!llvm.ptr) -> () + %4 = llvm.call @_ZnwmRKSt9nothrow_t(%1, %2) : (i64, !llvm.ptr) -> !llvm.ptr + llvm.call @dummy(%4) : (!llvm.ptr) -> () + %5 = llvm.call @_ZnwmRKSt9nothrow_t(%1, %2) : (i64, !llvm.ptr) -> !llvm.ptr + llvm.call @dummy(%5) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @new_align_nothrow() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.mlir.constant(8 : i64) : i64 + %3 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %4 = llvm.call @_ZnwmSt11align_val_tRKSt9nothrow_t(%1, %2, %3) : (i64, i64, !llvm.ptr) -> !llvm.ptr + llvm.call @dummy(%4) : (!llvm.ptr) -> () + %5 = llvm.call @_ZnwmSt11align_val_tRKSt9nothrow_t(%1, %2, %3) : (i64, i64, !llvm.ptr) -> !llvm.ptr + llvm.call @dummy(%5) : (!llvm.ptr) -> () + %6 = llvm.call @_ZnwmSt11align_val_tRKSt9nothrow_t(%1, %2, %3) : (i64, i64, !llvm.ptr) -> !llvm.ptr + llvm.call @dummy(%6) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @array_new() { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.call @_Znam(%0) : (i64) -> !llvm.ptr + llvm.call @dummy(%1) : (!llvm.ptr) -> () + %2 = llvm.call @_Znam(%0) : (i64) -> !llvm.ptr + llvm.call @dummy(%2) : (!llvm.ptr) -> () + %3 = llvm.call @_Znam(%0) : (i64) -> !llvm.ptr + llvm.call @dummy(%3) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @array_new_align() { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(8 : i64) : i64 + %2 = llvm.call @_ZnamSt11align_val_t(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.call @dummy(%2) : (!llvm.ptr) -> () + %3 = llvm.call @_ZnamSt11align_val_t(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.call @dummy(%3) : (!llvm.ptr) -> () + %4 = llvm.call @_ZnamSt11align_val_t(%0, %1) : (i64, i64) -> !llvm.ptr + llvm.call @dummy(%4) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @array_new_nothrow() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %3 = llvm.call @_ZnamRKSt9nothrow_t(%1, %2) : (i64, !llvm.ptr) -> !llvm.ptr + llvm.call @dummy(%3) : (!llvm.ptr) -> () + %4 = llvm.call @_ZnamRKSt9nothrow_t(%1, %2) : (i64, !llvm.ptr) -> !llvm.ptr + llvm.call @dummy(%4) : (!llvm.ptr) -> () + %5 = llvm.call @_ZnamRKSt9nothrow_t(%1, %2) : (i64, !llvm.ptr) -> !llvm.ptr + llvm.call @dummy(%5) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @array_new_align_nothrow() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.mlir.constant(8 : i64) : i64 + %3 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %4 = llvm.call @_ZnamSt11align_val_tRKSt9nothrow_t(%1, %2, %3) : (i64, i64, !llvm.ptr) -> !llvm.ptr + llvm.call @dummy(%4) : (!llvm.ptr) -> () + %5 = llvm.call @_ZnamSt11align_val_tRKSt9nothrow_t(%1, %2, %3) : (i64, i64, !llvm.ptr) -> !llvm.ptr + llvm.call @dummy(%5) : (!llvm.ptr) -> () + %6 = llvm.call @_ZnamSt11align_val_tRKSt9nothrow_t(%1, %2, %3) : (i64, i64, !llvm.ptr) -> !llvm.ptr + llvm.call @dummy(%6) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @new_hot_cold() { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.call @_Znwm12__hot_cold_t(%0, %1) : (i64, i8) -> !llvm.ptr + llvm.call @dummy(%2) : (!llvm.ptr) -> () + %3 = llvm.call @_Znwm12__hot_cold_t(%0, %1) : (i64, i8) -> !llvm.ptr + llvm.call @dummy(%3) : (!llvm.ptr) -> () + %4 = llvm.call @_Znwm12__hot_cold_t(%0, %1) : (i64, i8) -> !llvm.ptr + llvm.call @dummy(%4) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @new_align_hot_cold() { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(8 : i64) : i64 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.call @_ZnwmSt11align_val_t12__hot_cold_t(%0, %1, %2) : (i64, i64, i8) -> !llvm.ptr + llvm.call @dummy(%3) : (!llvm.ptr) -> () + %4 = llvm.call @_ZnwmSt11align_val_t12__hot_cold_t(%0, %1, %2) : (i64, i64, i8) -> !llvm.ptr + llvm.call @dummy(%4) : (!llvm.ptr) -> () + %5 = llvm.call @_ZnwmSt11align_val_t12__hot_cold_t(%0, %1, %2) : (i64, i64, i8) -> !llvm.ptr + llvm.call @dummy(%5) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @new_nothrow_hot_cold() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %4 = llvm.call @_ZnwmRKSt9nothrow_t12__hot_cold_t(%1, %3, %2) : (i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.call @dummy(%4) : (!llvm.ptr) -> () + %5 = llvm.call @_ZnwmRKSt9nothrow_t12__hot_cold_t(%1, %3, %2) : (i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.call @dummy(%5) : (!llvm.ptr) -> () + %6 = llvm.call @_ZnwmRKSt9nothrow_t12__hot_cold_t(%1, %3, %2) : (i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.call @dummy(%6) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @new_align_nothrow_hot_cold() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.mlir.constant(8 : i64) : i64 + %3 = llvm.mlir.constant(7 : i8) : i8 + %4 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %5 = llvm.call @_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(%1, %2, %4, %3) : (i64, i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.call @dummy(%5) : (!llvm.ptr) -> () + %6 = llvm.call @_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(%1, %2, %4, %3) : (i64, i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.call @dummy(%6) : (!llvm.ptr) -> () + %7 = llvm.call @_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(%1, %2, %4, %3) : (i64, i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.call @dummy(%7) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @array_new_hot_cold() { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.call @_Znam12__hot_cold_t(%0, %1) : (i64, i8) -> !llvm.ptr + llvm.call @dummy(%2) : (!llvm.ptr) -> () + %3 = llvm.call @_Znam12__hot_cold_t(%0, %1) : (i64, i8) -> !llvm.ptr + llvm.call @dummy(%3) : (!llvm.ptr) -> () + %4 = llvm.call @_Znam12__hot_cold_t(%0, %1) : (i64, i8) -> !llvm.ptr + llvm.call @dummy(%4) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @array_new_align_hot_cold() { + %0 = llvm.mlir.constant(10 : i64) : i64 + %1 = llvm.mlir.constant(8 : i64) : i64 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.call @_ZnamSt11align_val_t12__hot_cold_t(%0, %1, %2) : (i64, i64, i8) -> !llvm.ptr + llvm.call @dummy(%3) : (!llvm.ptr) -> () + %4 = llvm.call @_ZnamSt11align_val_t12__hot_cold_t(%0, %1, %2) : (i64, i64, i8) -> !llvm.ptr + llvm.call @dummy(%4) : (!llvm.ptr) -> () + %5 = llvm.call @_ZnamSt11align_val_t12__hot_cold_t(%0, %1, %2) : (i64, i64, i8) -> !llvm.ptr + llvm.call @dummy(%5) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @array_new_nothrow_hot_cold() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.mlir.constant(7 : i8) : i8 + %3 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %4 = llvm.call @_ZnamRKSt9nothrow_t12__hot_cold_t(%1, %3, %2) : (i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.call @dummy(%4) : (!llvm.ptr) -> () + %5 = llvm.call @_ZnamRKSt9nothrow_t12__hot_cold_t(%1, %3, %2) : (i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.call @dummy(%5) : (!llvm.ptr) -> () + %6 = llvm.call @_ZnamRKSt9nothrow_t12__hot_cold_t(%1, %3, %2) : (i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.call @dummy(%6) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @array_new_align_nothrow_hot_cold() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(10 : i64) : i64 + %2 = llvm.mlir.constant(8 : i64) : i64 + %3 = llvm.mlir.constant(7 : i8) : i8 + %4 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %5 = llvm.call @_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t(%1, %2, %4, %3) : (i64, i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.call @dummy(%5) : (!llvm.ptr) -> () + %6 = llvm.call @_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t(%1, %2, %4, %3) : (i64, i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.call @dummy(%6) : (!llvm.ptr) -> () + %7 = llvm.call @_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t(%1, %2, %4, %3) : (i64, i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.call @dummy(%7) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @dummy(!llvm.ptr) + llvm.func @_Znwm(i64) -> !llvm.ptr + llvm.func @_ZnwmSt11align_val_t(i64, i64) -> !llvm.ptr + llvm.func @_ZnwmRKSt9nothrow_t(i64, !llvm.ptr) -> !llvm.ptr + llvm.func @_ZnwmSt11align_val_tRKSt9nothrow_t(i64, i64, !llvm.ptr) -> !llvm.ptr + llvm.func @_Znam(i64) -> !llvm.ptr + llvm.func @_ZnamSt11align_val_t(i64, i64) -> !llvm.ptr + llvm.func @_ZnamRKSt9nothrow_t(i64, !llvm.ptr) -> !llvm.ptr + llvm.func @_ZnamSt11align_val_tRKSt9nothrow_t(i64, i64, !llvm.ptr) -> !llvm.ptr + llvm.func @_Znwm12__hot_cold_t(i64, i8) -> !llvm.ptr + llvm.func @_ZnwmSt11align_val_t12__hot_cold_t(i64, i64, i8) -> !llvm.ptr + llvm.func @_ZnwmRKSt9nothrow_t12__hot_cold_t(i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.func @_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64, i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.func @_Znam12__hot_cold_t(i64, i8) -> !llvm.ptr + llvm.func @_ZnamSt11align_val_t12__hot_cold_t(i64, i64, i8) -> !llvm.ptr + llvm.func @_ZnamRKSt9nothrow_t12__hot_cold_t(i64, !llvm.ptr, i8) -> !llvm.ptr + llvm.func @_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64, i64, !llvm.ptr, i8) -> !llvm.ptr +} diff --git a/test/LLVMDialect/InstCombine/simplify-libcalls.ll.mlir b/test/LLVMDialect/InstCombine/simplify-libcalls.ll.mlir new file mode 100644 index 000000000..a53d3c7c5 --- /dev/null +++ b/test/LLVMDialect/InstCombine/simplify-libcalls.ll.mlir @@ -0,0 +1,171 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 32 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @G("%s\00") {addr_space = 0 : i32} + llvm.mlir.global internal constant @str("foog\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global internal constant @str1("blahhh!\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global internal constant @str2("Ponk\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global external constant @_2E_str() {addr_space = 0 : i32} : !llvm.array<5 x i8> + llvm.mlir.global external constant @".str13"() {addr_space = 0 : i32} : !llvm.array<2 x i8> + llvm.mlir.global external constant @".str14"() {addr_space = 0 : i32} : !llvm.array<2 x i8> + llvm.mlir.global external constant @h("h\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hel("hel\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hello_u("hello_u\00") {addr_space = 0 : i32} + llvm.mlir.global external @a("123\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global external @b(dense<0> : tensor<5xi8>) {addr_space = 0 : i32, dso_local} : !llvm.array<5 x i8> + llvm.func @sprintf(!llvm.ptr, !llvm.ptr, ...) -> i32 + llvm.func @foo(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @G : !llvm.ptr + %2 = llvm.call @sprintf(%arg0, %1, %arg1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test1() -> !llvm.ptr { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant("foog\00") : !llvm.array<5 x i8> + %3 = llvm.mlir.addressof @str : !llvm.ptr + %4 = llvm.getelementptr inbounds %3[%1, %0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.mlir.constant(103 : i32) : i32 + %6 = llvm.call @strchr(%4, %5) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @strchr(!llvm.ptr, i32) -> !llvm.ptr + llvm.func @test2() -> !llvm.ptr { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant("blahhh!\00") : !llvm.array<8 x i8> + %3 = llvm.mlir.addressof @str1 : !llvm.ptr + %4 = llvm.getelementptr inbounds %3[%1, %0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<8 x i8> + %5 = llvm.call @strchr(%4, %1) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @test3() -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant("Ponk\00") : !llvm.array<5 x i8> + %3 = llvm.mlir.addressof @str2 : !llvm.ptr + %4 = llvm.getelementptr inbounds %3[%1, %0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.mlir.constant(80 : i32) : i32 + %6 = llvm.call @strchr(%4, %5) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @memcmp(!llvm.ptr, !llvm.ptr, i32) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @PR2341(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.addressof @_2E_str : !llvm.ptr + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> !llvm.ptr + %4 = llvm.call @memcmp(%3, %0, %1) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } + llvm.func @PR4284() -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.mlir.constant(-127 : i8) : i8 + %3 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %4 = llvm.alloca %0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %3 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.store %2, %4 {alignment = 1 : i64} : i8, !llvm.ptr + %5 = llvm.call @memcmp(%3, %4, %0) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @PR4641(%arg0: i32, %arg1: !llvm.ptr, %arg2: i1, %arg3: !llvm.ptr) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @".str13" : !llvm.ptr + %2 = llvm.mlir.addressof @".str14" : !llvm.ptr + llvm.call @exit(%0) : (i32) -> () + %3 = llvm.select %arg2, %1, %2 : i1, !llvm.ptr + %4 = llvm.call @fopen(%arg3, %3) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.unreachable + } + llvm.func @fopen(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @exit(i32) + llvm.func @PR4645(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.call @exit(%0) : (i32) -> () + llvm.br ^bb2(%1 : i32) + ^bb2(%2: i32): // pred: ^bb1 + llvm.unreachable + } + llvm.func @MemCpy() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant("h\00") : !llvm.array<2 x i8> + %2 = llvm.mlir.addressof @h : !llvm.ptr + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant("hel\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @hel : !llvm.ptr + %6 = llvm.mlir.constant(4 : i32) : i32 + %7 = llvm.mlir.constant("hello_u\00") : !llvm.array<8 x i8> + %8 = llvm.mlir.addressof @hello_u : !llvm.ptr + %9 = llvm.mlir.constant(8 : i32) : i32 + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.alloca %0 x !llvm.array<1024 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%11, %2, %3) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + "llvm.intr.memcpy"(%11, %5, %6) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + "llvm.intr.memcpy"(%11, %8, %9) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.return %10 : i32 + } + llvm.func @strcmp(!llvm.ptr, !llvm.ptr) -> i32 attributes {passthrough = ["nobuiltin"]} + llvm.func @test9(%arg0: !llvm.ptr) { + %0 = llvm.call @strcmp(%arg0, %arg0) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @isdigit(i8) -> i32 + llvm.func @isascii(i8) -> i32 + llvm.func @toascii(i8) -> i32 + llvm.func @fake_isdigit(%arg0: i8) -> i32 { + %0 = llvm.call @isdigit(%arg0) : (i8) -> i32 + llvm.return %0 : i32 + } + llvm.func @fake_isascii(%arg0: i8) -> i32 { + %0 = llvm.call @isascii(%arg0) : (i8) -> i32 + llvm.return %0 : i32 + } + llvm.func @fake_toascii(%arg0: i8) -> i32 { + %0 = llvm.call @toascii(%arg0) : (i8) -> i32 + llvm.return %0 : i32 + } + llvm.func @pow(f64, f64) -> f64 + llvm.func @exp2(f64) -> f64 + llvm.func @fake_exp2(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(2.000000e+00 : f64) : f64 + %1 = llvm.call @pow(%0, %arg0) : (f64, f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @fake_ldexp(%arg0: i32) -> f64 { + %0 = llvm.sitofp %arg0 : i32 to f64 + %1 = llvm.call @exp2(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @fake_ldexp_16(%arg0: i16) -> f64 { + %0 = llvm.sitofp %arg0 : i16 to f64 + %1 = llvm.call @exp2(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @snprintf(!llvm.ptr, f64, !llvm.ptr) -> i32 + llvm.func @fake_snprintf(%arg0: i32, %arg1: f64, %arg2: !llvm.ptr, %arg3: !llvm.ptr) -> i32 { + %0 = llvm.call @snprintf(%arg3, %arg1, %arg2) : (!llvm.ptr, f64, !llvm.ptr) -> i32 + llvm.return %0 : i32 + } + llvm.func @strlen(%arg0: !llvm.ptr) -> i4 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.call @strlen(%arg0) : (!llvm.ptr) -> i4 + llvm.return %0 : i4 + } + llvm.func @__stpncpy_chk(!llvm.ptr {llvm.noundef}, !llvm.ptr {llvm.noundef}, i32 {llvm.noundef}, i32 {llvm.noundef}) -> !llvm.ptr + llvm.func @emit_stpncpy() -> (i32 {llvm.signext}) { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<5xi8>) : !llvm.array<5 x i8> + %2 = llvm.mlir.addressof @b : !llvm.ptr + %3 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.addressof @a : !llvm.ptr + %5 = llvm.mlir.constant(2 : i32) : i32 + %6 = llvm.mlir.constant(5 : i32) : i32 + %7 = llvm.mlir.constant(0 : i32) : i32 + %8 = llvm.call @__stpncpy_chk(%2, %4, %5, %6) : (!llvm.ptr, !llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sincospi.ll.mlir b/test/LLVMDialect/InstCombine/sincospi.ll.mlir index 7c097db27..85c792670 100644 --- a/test/LLVMDialect/InstCombine/sincospi.ll.mlir +++ b/test/LLVMDialect/InstCombine/sincospi.ll.mlir @@ -1,52 +1,68 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "var32", type = f32, value = 0.000000e+00 : f32} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "var64", type = f64, value = 0.000000e+00 : f64} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "__sinpif", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "__cospif", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "__sinpi", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "__cospi", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @var32} : () -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> f32 - %2 = "llvm.call"(%1) {callee = @__sinpif, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %3 = "llvm.call"(%1) {callee = @__cospif, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %4 = "llvm.fadd"(%2, %3) : (f32, f32) -> f32 - "llvm.return"(%4) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_instbased_f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f32} : () -> f32 - %1 = "llvm.call"(%0) {callee = @__sinpif, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %2 = "llvm.call"(%0) {callee = @__cospif, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %3 = "llvm.fadd"(%1, %2) : (f32, f32) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test_constant_f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @var64} : () -> !llvm.ptr - %1 = "llvm.load"(%0) : (!llvm.ptr) -> f64 - %2 = "llvm.call"(%1) {callee = @__sinpi, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %3 = "llvm.call"(%1) {callee = @__cospi, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %4 = "llvm.fadd"(%2, %3) : (f64, f64) -> f64 - "llvm.return"(%4) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_instbased_f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%0) {callee = @__sinpi, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.call"(%0) {callee = @__cospi, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %3 = "llvm.fadd"(%1, %2) : (f64, f64) -> f64 - "llvm.return"(%3) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_constant_f64", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: f64): // no predecessors - %0 = "llvm.call"(%arg1) {callee = @__sinpi, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %1 = "llvm.call"(%arg0, %arg1) : (!llvm.ptr>, f64) -> f64 - %2 = "llvm.fadd"(%0, %1) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test_fptr", type = !llvm.func>, f64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @var32(0.000000e+00 : f32) {addr_space = 0 : i32} : f32 + llvm.mlir.global external @var64(0.000000e+00 : f64) {addr_space = 0 : i32} : f64 + llvm.func @__sinpif(f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @__cospif(f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @__sinpi(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @__cospi(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} + llvm.func @test_instbased_f32() -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.addressof @var32 : !llvm.ptr + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> f32 + %3 = llvm.call @__sinpif(%2) : (f32) -> f32 + %4 = llvm.call @__cospif(%2) : (f32) -> f32 + %5 = llvm.fadd %3, %4 : f32 + llvm.return %5 : f32 + } + llvm.func @test_instbased_f32_other_user(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.addressof @var32 : !llvm.ptr + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> f32 + llvm.store %2, %arg0 {alignment = 4 : i64} : f32, !llvm.ptr + %3 = llvm.call @__sinpif(%2) : (f32) -> f32 + %4 = llvm.call @__cospif(%2) : (f32) -> f32 + %5 = llvm.fadd %3, %4 : f32 + llvm.return %5 : f32 + } + llvm.func @test_constant_f32() -> f32 { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.call @__sinpif(%0) : (f32) -> f32 + %2 = llvm.call @__cospif(%0) : (f32) -> f32 + %3 = llvm.fadd %1, %2 : f32 + llvm.return %3 : f32 + } + llvm.func @test_instbased_f64() -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.mlir.addressof @var64 : !llvm.ptr + %2 = llvm.load %1 {alignment = 8 : i64} : !llvm.ptr -> f64 + %3 = llvm.call @__sinpi(%2) : (f64) -> f64 + %4 = llvm.call @__cospi(%2) : (f64) -> f64 + %5 = llvm.fadd %3, %4 : f64 + llvm.return %5 : f64 + } + llvm.func @test_constant_f64() -> f64 { + %0 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %1 = llvm.call @__sinpi(%0) : (f64) -> f64 + %2 = llvm.call @__cospi(%0) : (f64) -> f64 + %3 = llvm.fadd %1, %2 : f64 + llvm.return %3 : f64 + } + llvm.func @test_fptr(%arg0: !llvm.ptr, %arg1: f64) -> f64 { + %0 = llvm.call @__sinpi(%arg1) : (f64) -> f64 + %1 = llvm.call %arg0(%arg1) : !llvm.ptr, (f64) -> f64 + %2 = llvm.fadd %0, %1 : f64 + llvm.return %2 : f64 + } + llvm.func @test_cospif_used_in_branch_cond() -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.call @__cospif(%0) : (f32) -> f32 + %4 = llvm.fcmp "uno" %3, %0 : f32 + llvm.cond_br %4, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %2 : i1 + ^bb2: // pred: ^bb0 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/sink-alloca.ll.mlir b/test/LLVMDialect/InstCombine/sink-alloca.ll.mlir index 499810331..38ffaa482 100644 --- a/test/LLVMDialect/InstCombine/sink-alloca.ll.mlir +++ b/test/LLVMDialect/InstCombine/sink-alloca.ll.mlir @@ -1,30 +1,22 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "cond", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use_and_return", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.stacksave", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.stackrestore", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 13 : i32} : () -> i32 - %1 = "llvm.call"() {callee = @cond, fastmathFlags = #llvm.fastmath<>} : () -> i1 - "llvm.cond_br"(%1)[^bb3, ^bb1] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @cond() -> i1 + llvm.func @use_and_return(!llvm.ptr) -> !llvm.ptr + llvm.func @foo(%arg0: i32) { + %0 = llvm.mlir.constant(13 : i32) : i32 + %1 = llvm.call @cond() : () -> i1 + llvm.cond_br %1, ^bb3, ^bb1 ^bb1: // pred: ^bb0 - %2 = "llvm.alloca"(%arg0) : (i32) -> !llvm.ptr - %3 = "llvm.call"() {callee = @llvm.stacksave, fastmathFlags = #llvm.fastmath<>} : () -> !llvm.ptr - %4 = "llvm.call"() {callee = @cond, fastmathFlags = #llvm.fastmath<>} : () -> i1 - "llvm.cond_br"(%4)[^bb3, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %2 = llvm.alloca %arg0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %3 = llvm.intr.stacksave : !llvm.ptr + %4 = llvm.call @cond() : () -> i1 + llvm.cond_br %4, ^bb3, ^bb2 ^bb2: // pred: ^bb1 - %5 = "llvm.call"(%2) {callee = @use_and_return, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> !llvm.ptr - "llvm.store"(%0, %5) : (i32, !llvm.ptr) -> () - "llvm.call"(%3) {callee = @llvm.stackrestore, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - %6 = "llvm.call"(%5) {callee = @use_and_return, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> !llvm.ptr - "llvm.br"()[^bb3] : () -> () + %5 = llvm.call @use_and_return(%2) : (!llvm.ptr) -> !llvm.ptr + llvm.store %0, %5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.intr.stackrestore %3 : !llvm.ptr + %6 = llvm.call @use_and_return(%5) : (!llvm.ptr) -> !llvm.ptr + llvm.br ^bb3 ^bb3: // 3 preds: ^bb0, ^bb1, ^bb2 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/sink-instruction-introduces-unnecessary-poison-value.ll.mlir b/test/LLVMDialect/InstCombine/sink-instruction-introduces-unnecessary-poison-value.ll.mlir new file mode 100644 index 000000000..33db2cbb9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sink-instruction-introduces-unnecessary-poison-value.ll.mlir @@ -0,0 +1,38 @@ +#di_basic_type = #llvm.di_basic_type +#di_file = #llvm.di_file<"test.cpp" in ""> +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C_plus_plus_14, file = #di_file, producer = "clang version 18.0.0", isOptimized = false, emissionKind = Full> +#di_subroutine_type = #llvm.di_subroutine_type +#di_global_variable = #llvm.di_global_variable +#di_global_variable1 = #llvm.di_global_variable +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "test", linkageName = "?test@@YAHXZ", file = #di_file, line = 3, scopeLine = 3, subprogramFlags = Definition, type = #di_subroutine_type> +#di_global_variable_expression = #llvm.di_global_variable_expression> +#di_global_variable_expression1 = #llvm.di_global_variable_expression> +#di_local_variable = #llvm.di_local_variable +#di_local_variable1 = #llvm.di_local_variable +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @"?One@@3HA"(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64, dbg_expr = #di_global_variable_expression, dso_local} : i32 + llvm.mlir.global external @"?Two@@3HA"(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64, dbg_expr = #di_global_variable_expression1, dso_local} : i32 + llvm.func @"?test@@YAHXZ"() -> (i32 {llvm.noundef}) { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.intr.dbg.value #di_local_variable = %0 : i32 + %1 = llvm.mlir.addressof @"?Two@@3HA" : !llvm.ptr + %2 = llvm.mlir.addressof @"?One@@3HA" : !llvm.ptr + %3 = llvm.mlir.constant(4 : i32) : i32 + llvm.intr.dbg.value #di_local_variable = %3 : i32 + %4 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.intr.dbg.value #di_local_variable = %4 : i32 + llvm.intr.dbg.value #di_local_variable1 = %4 : i32 + %5 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.switch %5 : i32, ^bb3(%0 : i32) [ + 0: ^bb1, + 2: ^bb2 + ] + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%4 : i32) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%3 : i32) + ^bb3(%6: i32): // 3 preds: ^bb0, ^bb1, ^bb2 + llvm.intr.dbg.value #di_local_variable = %6 : i32 + llvm.return %6 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sink-into-catchswitch.ll.mlir b/test/LLVMDialect/InstCombine/sink-into-catchswitch.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/sink-into-ncd.ll.mlir b/test/LLVMDialect/InstCombine/sink-into-ncd.ll.mlir new file mode 100644 index 000000000..ae155d5c6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sink-into-ncd.ll.mlir @@ -0,0 +1,40 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(!llvm.ptr) -> i32 + llvm.func @test1(%arg0: !llvm.ptr, %arg1: i1) -> i32 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.call @use(%0) : (!llvm.ptr) -> i32 + llvm.br ^bb4(%3 : i32) + ^bb2: // pred: ^bb0 + %4 = llvm.call @use(%1) : (!llvm.ptr) -> i32 + llvm.cond_br %arg1, ^bb4(%4 : i32), ^bb3 + ^bb3: // pred: ^bb2 + %5 = llvm.call @use(%1) : (!llvm.ptr) -> i32 + llvm.br ^bb4(%5 : i32) + ^bb4(%6: i32): // 3 preds: ^bb1, ^bb2, ^bb3 + llvm.return %6 : i32 + } + llvm.func @test2(%arg0: !llvm.ptr, %arg1: i1) -> i32 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + llvm.cond_br %2, ^bb5(%1 : i32), ^bb1 + ^bb1: // pred: ^bb0 + %3 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.cond_br %arg1, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %4 = llvm.call @use(%0) : (!llvm.ptr) -> i32 + llvm.br ^bb5(%4 : i32) + ^bb3: // pred: ^bb1 + %5 = llvm.call @use(%3) : (!llvm.ptr) -> i32 + llvm.cond_br %arg1, ^bb5(%5 : i32), ^bb4 + ^bb4: // pred: ^bb3 + %6 = llvm.call @use(%3) : (!llvm.ptr) -> i32 + llvm.br ^bb5(%6 : i32) + ^bb5(%7: i32): // 4 preds: ^bb0, ^bb2, ^bb3, ^bb4 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sink-into-resume-block.ll.mlir b/test/LLVMDialect/InstCombine/sink-into-resume-block.ll.mlir new file mode 100644 index 000000000..7e54af462 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sink-into-resume-block.ll.mlir @@ -0,0 +1,29 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_noop(%arg0: i32) attributes {personality = @__gxx_personality_v0} { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.call @cond() : () -> i1 + %3 = llvm.add %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + llvm.cond_br %2, ^bb1, ^bb4 + ^bb1: // pred: ^bb0 + llvm.invoke @simple_throw() to ^bb2 unwind ^bb3 : () -> () + ^bb2: // pred: ^bb1 + llvm.unreachable + ^bb3: // pred: ^bb1 + %5 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)> + llvm.call @consume(%3) : (i32) -> () + llvm.call @destructor() : () -> () + llvm.resume %5 : !llvm.struct<(ptr, i32)> + ^bb4: // pred: ^bb0 + llvm.call @consume(%4) : (i32) -> () + llvm.call @sideeffect() : () -> () + llvm.return + } + llvm.func @cond() -> i1 + llvm.func @sideeffect() + llvm.func @simple_throw() attributes {passthrough = ["noreturn"]} + llvm.func @destructor() + llvm.func @consume(i32) + llvm.func @__gxx_personality_v0(...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/sink-not-into-and.ll.mlir b/test/LLVMDialect/InstCombine/sink-not-into-and.ll.mlir new file mode 100644 index 000000000..a1e4d4121 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sink-not-into-and.ll.mlir @@ -0,0 +1,110 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use1(i1) + llvm.func @t0(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + %3 = llvm.and %2, %1 : i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @n1(%arg0: i1, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i32 + %2 = llvm.and %1, %arg0 : i1 + %3 = llvm.xor %2, %0 : i1 + llvm.return %3 : i1 + } + llvm.func @n2(%arg0: i32, %arg1: i32, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.and %arg2, %1 : i1 + %3 = llvm.xor %2, %0 : i1 + llvm.return %3 : i1 + } + llvm.func @n3(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.and %arg1, %arg0 : i1 + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @n4(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + llvm.call @use1(%1) : (i1) -> () + %3 = llvm.and %2, %1 : i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @n5(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.and %2, %1 : i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @n6(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + llvm.call @use1(%1) : (i1) -> () + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.and %2, %1 : i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @t7(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i1 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "eq" %arg2, %arg3 : i32 + %4 = llvm.and %3, %1 : i1 + %5 = llvm.xor %4, %0 : i1 + llvm.return %5 : i1 + } + llvm.func @t8(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + %3 = llvm.xor %2, %0 : i1 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.and %2, %1 : i1 + %5 = llvm.xor %4, %0 : i1 + llvm.return %5 : i1 + } + llvm.func @t9(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i1 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "eq" %arg2, %arg3 : i32 + %4 = llvm.xor %3, %0 : i1 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.and %3, %1 : i1 + %6 = llvm.xor %5, %0 : i1 + llvm.return %6 : i1 + } + llvm.func @n10(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + %3 = llvm.and %2, %1 : i1 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @t11(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i1, %arg5: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + %3 = llvm.and %2, %1 : i1 + %4 = llvm.xor %3, %0 : i1 + %5 = llvm.select %3, %arg4, %arg5 : i1, i1 + llvm.call @use1(%5) : (i1) -> () + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-and.ll.mlir b/test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-and.ll.mlir new file mode 100644 index 000000000..65aff89f3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-and.ll.mlir @@ -0,0 +1,58 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use1(i1) + llvm.func @use8(i8) + llvm.func @t0(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.and %2, %1 : i1 + %4 = llvm.select %3, %arg3, %arg4 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @t1(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg2, %arg3 : i8 + llvm.call @use1(%1) : (i1) -> () + %3 = llvm.xor %1, %0 : i1 + %4 = llvm.and %3, %2 : i1 + %5 = llvm.select %4, %arg4, %arg5 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @n2(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.and %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @n3(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + llvm.call @use1(%1) : (i1) -> () + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.and %2, %1 : i1 + %4 = llvm.select %3, %arg3, %arg4 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @t4(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i8, %arg6: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.select %1, %arg3, %arg4 : i1, i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.xor %arg0, %0 : i1 + %4 = llvm.and %3, %1 : i1 + %5 = llvm.select %4, %arg5, %arg6 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @t4_commutative(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i8, %arg6: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.select %1, %arg3, %arg4 : i1, i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.xor %arg0, %0 : i1 + %4 = llvm.and %1, %3 : i1 + %5 = llvm.select %4, %arg5, %arg6 : i1, i8 + llvm.return %5 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-logical-and.ll.mlir b/test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-logical-and.ll.mlir new file mode 100644 index 000000000..b66a9bf2c --- /dev/null +++ b/test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-logical-and.ll.mlir @@ -0,0 +1,84 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use1(i1) + llvm.func @use8(i8) + llvm.func @t0(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg1, %arg2 : i8 + %3 = llvm.xor %arg0, %0 : i1 + %4 = llvm.select %3, %2, %1 : i1, i1 + %5 = llvm.select %4, %arg3, %arg4 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @t0_commutative(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg1, %arg2 : i8 + %3 = llvm.xor %arg0, %0 : i1 + %4 = llvm.select %2, %3, %1 : i1, i1 + %5 = llvm.select %4, %arg3, %arg4 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @t1(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg2, %arg3 : i8 + llvm.call @use1(%2) : (i1) -> () + %4 = llvm.xor %2, %0 : i1 + %5 = llvm.select %4, %3, %1 : i1, i1 + %6 = llvm.select %5, %arg4, %arg5 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @t1_commutative(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %arg1 : i8 + %3 = llvm.icmp "eq" %arg2, %arg3 : i8 + llvm.call @use1(%2) : (i1) -> () + %4 = llvm.xor %2, %0 : i1 + %5 = llvm.select %3, %4, %1 : i1, i1 + %6 = llvm.select %5, %arg4, %arg5 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @n2(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg1, %arg2 : i8 + %3 = llvm.xor %arg0, %0 : i1 + %4 = llvm.select %3, %2, %1 : i1, i1 + llvm.return %4 : i1 + } + llvm.func @n3(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg1, %arg2 : i8 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.xor %arg0, %0 : i1 + %4 = llvm.select %3, %2, %1 : i1, i1 + %5 = llvm.select %4, %arg3, %arg4 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @t4(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i8, %arg6: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg1, %arg2 : i8 + %3 = llvm.select %2, %arg3, %arg4 : i1, i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.xor %arg0, %0 : i1 + %5 = llvm.select %4, %2, %1 : i1, i1 + %6 = llvm.select %5, %arg5, %arg6 : i1, i8 + llvm.return %6 : i8 + } + llvm.func @t4_commutative(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i8, %arg6: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg1, %arg2 : i8 + %3 = llvm.select %2, %arg3, %arg4 : i1, i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.xor %arg0, %0 : i1 + %5 = llvm.select %2, %4, %1 : i1, i1 + %6 = llvm.select %5, %arg5, %arg6 : i1, i8 + llvm.return %6 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-logical-or.ll.mlir b/test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-logical-or.ll.mlir new file mode 100644 index 000000000..8c32631a4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-logical-or.ll.mlir @@ -0,0 +1,76 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use1(i1) + llvm.func @use8(i8) + llvm.func @t0(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.select %2, %0, %1 : i1, i1 + %4 = llvm.select %3, %arg3, %arg4 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @t0_commutative(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.select %1, %0, %2 : i1, i1 + %4 = llvm.select %3, %arg3, %arg4 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @t1(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg2, %arg3 : i8 + llvm.call @use1(%1) : (i1) -> () + %3 = llvm.xor %1, %0 : i1 + %4 = llvm.select %3, %0, %2 : i1, i1 + %5 = llvm.select %4, %arg4, %arg5 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @t1_commutative(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg2, %arg3 : i8 + llvm.call @use1(%1) : (i1) -> () + %3 = llvm.xor %1, %0 : i1 + %4 = llvm.select %2, %0, %3 : i1, i1 + %5 = llvm.select %4, %arg4, %arg5 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @n2(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.select %2, %0, %1 : i1, i1 + llvm.return %3 : i1 + } + llvm.func @n3(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + llvm.call @use1(%1) : (i1) -> () + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.select %2, %0, %1 : i1, i1 + %4 = llvm.select %3, %arg3, %arg4 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @t4(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i8, %arg6: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.select %1, %arg3, %arg4 : i1, i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.xor %arg0, %0 : i1 + %4 = llvm.select %3, %0, %1 : i1, i1 + %5 = llvm.select %4, %arg5, %arg6 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @t4_commutative(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i8, %arg6: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.select %1, %arg3, %arg4 : i1, i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.xor %arg0, %0 : i1 + %4 = llvm.select %1, %0, %3 : i1, i1 + %5 = llvm.select %4, %arg5, %arg6 : i1, i8 + llvm.return %5 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-or.ll.mlir b/test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-or.ll.mlir new file mode 100644 index 000000000..5e8bfd842 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sink-not-into-another-hand-of-or.ll.mlir @@ -0,0 +1,58 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use1(i1) + llvm.func @use8(i8) + llvm.func @t0(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.or %2, %1 : i1 + %4 = llvm.select %3, %arg3, %arg4 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @t1(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i8 + %2 = llvm.icmp "eq" %arg2, %arg3 : i8 + llvm.call @use1(%1) : (i1) -> () + %3 = llvm.xor %1, %0 : i1 + %4 = llvm.or %3, %2 : i1 + %5 = llvm.select %4, %arg4, %arg5 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @n2(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.or %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @n3(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + llvm.call @use1(%1) : (i1) -> () + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.or %2, %1 : i1 + %4 = llvm.select %3, %arg3, %arg4 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @t4(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i8, %arg6: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.select %1, %arg3, %arg4 : i1, i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.xor %arg0, %0 : i1 + %4 = llvm.or %3, %1 : i1 + %5 = llvm.select %4, %arg5, %arg6 : i1, i8 + llvm.return %5 : i8 + } + llvm.func @t4_commutative(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i8, %arg6: i8) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i8 + %2 = llvm.select %1, %arg3, %arg4 : i1, i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.xor %arg0, %0 : i1 + %4 = llvm.or %1, %3 : i1 + %5 = llvm.select %4, %arg5, %arg6 : i1, i8 + llvm.return %5 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/sink-not-into-logical-and.ll.mlir b/test/LLVMDialect/InstCombine/sink-not-into-logical-and.ll.mlir new file mode 100644 index 000000000..1ce07984b --- /dev/null +++ b/test/LLVMDialect/InstCombine/sink-not-into-logical-and.ll.mlir @@ -0,0 +1,135 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use1(i1) + llvm.func @t0(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %arg2, %arg3 : i32 + %4 = llvm.select %3, %2, %0 : i1, i1 + %5 = llvm.xor %4, %1 : i1 + llvm.return %5 : i1 + } + llvm.func @n1(%arg0: i1, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg1, %arg2 : i32 + %3 = llvm.select %2, %arg0, %0 : i1, i1 + %4 = llvm.xor %3, %1 : i1 + llvm.return %4 : i1 + } + llvm.func @n2(%arg0: i32, %arg1: i32, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %arg1 : i32 + %3 = llvm.select %arg2, %2, %0 : i1, i1 + %4 = llvm.xor %3, %1 : i1 + llvm.return %4 : i1 + } + llvm.func @n3(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.select %arg1, %arg0, %0 : i1, i1 + %3 = llvm.xor %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @n4(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %arg2, %arg3 : i32 + llvm.call @use1(%2) : (i1) -> () + %4 = llvm.select %3, %2, %0 : i1, i1 + %5 = llvm.xor %4, %1 : i1 + llvm.return %5 : i1 + } + llvm.func @n5(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %arg2, %arg3 : i32 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.select %3, %2, %0 : i1, i1 + %5 = llvm.xor %4, %1 : i1 + llvm.return %5 : i1 + } + llvm.func @n6(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %arg2, %arg3 : i32 + llvm.call @use1(%2) : (i1) -> () + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.select %3, %2, %0 : i1, i1 + %5 = llvm.xor %4, %1 : i1 + llvm.return %5 : i1 + } + llvm.func @t7(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i1 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "eq" %arg2, %arg3 : i32 + %5 = llvm.select %4, %2, %1 : i1, i1 + %6 = llvm.xor %5, %0 : i1 + llvm.return %6 : i1 + } + llvm.func @t8(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %arg2, %arg3 : i32 + %4 = llvm.xor %3, %0 : i1 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %3, %2, %1 : i1, i1 + %6 = llvm.xor %5, %0 : i1 + llvm.return %6 : i1 + } + llvm.func @t9(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.icmp "eq" %arg0, %arg1 : i32 + %3 = llvm.xor %2, %0 : i1 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.icmp "eq" %arg2, %arg3 : i32 + %5 = llvm.xor %4, %0 : i1 + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.select %4, %2, %1 : i1, i1 + %7 = llvm.xor %6, %0 : i1 + llvm.return %7 : i1 + } + llvm.func @n10(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %arg2, %arg3 : i32 + %4 = llvm.select %3, %2, %0 : i1, i1 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.xor %4, %1 : i1 + llvm.return %5 : i1 + } + llvm.func @t11(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i1, %arg5: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.icmp "eq" %arg0, %arg1 : i32 + %3 = llvm.icmp "eq" %arg2, %arg3 : i32 + %4 = llvm.select %3, %2, %0 : i1, i1 + %5 = llvm.xor %4, %1 : i1 + %6 = llvm.select %4, %arg4, %arg5 : i1, i1 + llvm.call @use1(%6) : (i1) -> () + llvm.return %5 : i1 + } + llvm.func @PR59704(%arg0: i1, %arg1: i1, %arg2: i64) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(true) : i1 + llvm.cond_br %arg0, ^bb1, ^bb2(%0 : i1) + ^bb1: // pred: ^bb0 + %3 = llvm.icmp "ne" %arg2, %1 : i64 + %4 = llvm.select %3, %3, %0 : i1, i1 + llvm.br ^bb2(%4 : i1) + ^bb2(%5: i1): // 2 preds: ^bb0, ^bb1 + %6 = llvm.xor %5, %2 : i1 + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/sink-not-into-logical-or.ll.mlir b/test/LLVMDialect/InstCombine/sink-not-into-logical-or.ll.mlir new file mode 100644 index 000000000..6057fcafe --- /dev/null +++ b/test/LLVMDialect/InstCombine/sink-not-into-logical-or.ll.mlir @@ -0,0 +1,110 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use1(i1) + llvm.func @t0(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + %3 = llvm.select %2, %0, %1 : i1, i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @n1(%arg0: i1, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i32 + %2 = llvm.select %1, %0, %arg0 : i1, i1 + %3 = llvm.xor %2, %0 : i1 + llvm.return %3 : i1 + } + llvm.func @n2(%arg0: i32, %arg1: i32, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.select %arg2, %0, %1 : i1, i1 + %3 = llvm.xor %2, %0 : i1 + llvm.return %3 : i1 + } + llvm.func @n3(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg1, %0, %arg0 : i1, i1 + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @n4(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + llvm.call @use1(%1) : (i1) -> () + %3 = llvm.select %2, %0, %1 : i1, i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @n5(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.select %2, %0, %1 : i1, i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @n6(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + llvm.call @use1(%1) : (i1) -> () + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.select %2, %0, %1 : i1, i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @t7(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i1 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "eq" %arg2, %arg3 : i32 + %4 = llvm.select %3, %0, %1 : i1, i1 + %5 = llvm.xor %4, %0 : i1 + llvm.return %5 : i1 + } + llvm.func @t8(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + %3 = llvm.xor %2, %0 : i1 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.select %2, %0, %1 : i1, i1 + %5 = llvm.xor %4, %0 : i1 + llvm.return %5 : i1 + } + llvm.func @t9(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i1 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "eq" %arg2, %arg3 : i32 + %4 = llvm.xor %3, %0 : i1 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.select %3, %0, %1 : i1, i1 + %6 = llvm.xor %5, %0 : i1 + llvm.return %6 : i1 + } + llvm.func @n10(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + %3 = llvm.select %2, %0, %1 : i1, i1 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @t11(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i1, %arg5: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + %3 = llvm.select %2, %0, %1 : i1, i1 + %4 = llvm.xor %3, %0 : i1 + %5 = llvm.select %3, %arg4, %arg5 : i1, i1 + llvm.call @use1(%5) : (i1) -> () + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/sink-not-into-or.ll.mlir b/test/LLVMDialect/InstCombine/sink-not-into-or.ll.mlir new file mode 100644 index 000000000..7472af07e --- /dev/null +++ b/test/LLVMDialect/InstCombine/sink-not-into-or.ll.mlir @@ -0,0 +1,110 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use1(i1) + llvm.func @t0(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + %3 = llvm.or %2, %1 : i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @n1(%arg0: i1, %arg1: i32, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg1, %arg2 : i32 + %2 = llvm.or %1, %arg0 : i1 + %3 = llvm.xor %2, %0 : i1 + llvm.return %3 : i1 + } + llvm.func @n2(%arg0: i32, %arg1: i32, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.or %arg2, %1 : i1 + %3 = llvm.xor %2, %0 : i1 + llvm.return %3 : i1 + } + llvm.func @n3(%arg0: i1, %arg1: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.or %arg1, %arg0 : i1 + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @n4(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + llvm.call @use1(%1) : (i1) -> () + %3 = llvm.or %2, %1 : i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @n5(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.or %2, %1 : i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @n6(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + llvm.call @use1(%1) : (i1) -> () + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.or %2, %1 : i1 + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @t7(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i1 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "eq" %arg2, %arg3 : i32 + %4 = llvm.or %3, %1 : i1 + %5 = llvm.xor %4, %0 : i1 + llvm.return %5 : i1 + } + llvm.func @t8(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + %3 = llvm.xor %2, %0 : i1 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.or %2, %1 : i1 + %5 = llvm.xor %4, %0 : i1 + llvm.return %5 : i1 + } + llvm.func @t9(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i1 + llvm.call @use1(%2) : (i1) -> () + %3 = llvm.icmp "eq" %arg2, %arg3 : i32 + %4 = llvm.xor %3, %0 : i1 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.or %3, %1 : i1 + %6 = llvm.xor %5, %0 : i1 + llvm.return %6 : i1 + } + llvm.func @n10(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + %3 = llvm.or %2, %1 : i1 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.xor %3, %0 : i1 + llvm.return %4 : i1 + } + llvm.func @t11(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i1, %arg5: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + %2 = llvm.icmp "eq" %arg2, %arg3 : i32 + %3 = llvm.or %2, %1 : i1 + %4 = llvm.xor %3, %0 : i1 + %5 = llvm.select %3, %arg4, %arg5 : i1, i1 + llvm.call @use1(%5) : (i1) -> () + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/sink_instruction.ll.mlir b/test/LLVMDialect/InstCombine/sink_instruction.ll.mlir new file mode 100644 index 000000000..02985fa5e --- /dev/null +++ b/test/LLVMDialect/InstCombine/sink_instruction.ll.mlir @@ -0,0 +1,112 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i1, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.sdiv %arg1, %arg2 : i32 + %1 = llvm.add %arg2, %arg1 : i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @test2(%arg0: i32) -> i32 attributes {passthrough = ["nounwind", "ssp"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(1000000 : i32) : i32 + llvm.br ^bb1(%arg0, %0 : i32, i32) + ^bb1(%3: i32, %4: i32): // 2 preds: ^bb0, ^bb3 + %5 = llvm.add %3, %1 overflow : i32 + %6 = llvm.sdiv %5, %3 : i32 + %7 = llvm.icmp "eq" %3, %0 : i32 + llvm.cond_br %7, ^bb2, ^bb3(%3 : i32) + ^bb2: // pred: ^bb1 + %8 = llvm.call @bar() : () -> i32 + llvm.br ^bb3(%6 : i32) + ^bb3(%9: i32): // 2 preds: ^bb1, ^bb2 + %10 = llvm.add %4, %1 overflow : i32 + %11 = llvm.icmp "eq" %10, %2 : i32 + llvm.cond_br %11, ^bb4, ^bb1(%9, %10 : i32, i32) + ^bb4: // pred: ^bb3 + llvm.return %9 : i32 + } + llvm.func @bar() -> i32 + llvm.func @test3(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg1 : i32 to i64 + %2 = llvm.getelementptr inbounds %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.switch %arg1 : i32, ^bb2(%0 : i32) [ + 5: ^bb1, + 2: ^bb1 + ] + ^bb1: // 2 preds: ^bb0, ^bb0 + %4 = llvm.add %3, %arg1 overflow : i32 + llvm.br ^bb2(%4 : i32) + ^bb2(%5: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %5 : i32 + } + llvm.func @foo(i32, i32) -> i32 + llvm.func @test4(%arg0: i32, %arg1: i32, %arg2: i1) -> i32 { + %0 = llvm.sdiv %arg0, %arg1 : i32 + %1 = llvm.add %arg1, %arg0 : i32 + llvm.cond_br %arg2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.call @foo(%1, %1) : (i32, i32) -> i32 + llvm.return %2 : i32 + ^bb2: // pred: ^bb0 + llvm.return %0 : i32 + } + llvm.func @test5(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: i32, %arg2: i1) -> i32 { + %0 = llvm.sext %arg1 : i32 to i64 + %1 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.cond_br %arg2, ^bb1, ^bb2(%2 : i32) + ^bb1: // pred: ^bb0 + %3 = llvm.add %arg1, %arg1 overflow : i32 + llvm.br ^bb2(%3 : i32) + ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @test6(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}, %arg1: i32, %arg2: i1) -> i32 { + %0 = llvm.sext %arg1 : i32 to i64 + %1 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + %3 = llvm.add %arg1, %arg1 overflow : i32 + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.switch %arg1 : i32, ^bb2 [ + 5: ^bb3(%2 : i32), + 2: ^bb3(%2 : i32) + ] + ^bb2: // pred: ^bb1 + llvm.br ^bb3(%3 : i32) + ^bb3(%4: i32): // 3 preds: ^bb1, ^bb1, ^bb2 + llvm.return %4 : i32 + } + llvm.func @checkd(f64) + llvm.func @log(f64) -> f64 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind", "willreturn"]} + llvm.func @test7(%arg0: i1, %arg1: f64) { + %0 = llvm.call @log(%arg1) : (f64) -> f64 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @checkd(%0) : (f64) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @abort() + llvm.func @dummy(i64) + llvm.func @test8(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i64, i64) -> !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i64, i1)> + %4 = llvm.select %3, %1, %0 : i1, i64 + llvm.cond_br %3, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.call @dummy(%4) : (i64) -> () + llvm.return %4 : i64 + ^bb2: // pred: ^bb0 + llvm.call @abort() : () -> () + llvm.unreachable + } +} diff --git a/test/LLVMDialect/InstCombine/sink_sideeffecting_instruction.ll.mlir b/test/LLVMDialect/InstCombine/sink_sideeffecting_instruction.ll.mlir new file mode 100644 index 000000000..6a24831d3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sink_sideeffecting_instruction.ll.mlir @@ -0,0 +1,217 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: !llvm.ptr {llvm.nocapture, llvm.writeonly}) -> i32 { + %0 = llvm.call @baz() : () -> i32 + llvm.store %0, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %1 = llvm.call @baz() : () -> i32 + llvm.return %1 : i32 + } + llvm.func @baz() -> i32 + llvm.func @test() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 4, %2 : !llvm.ptr + %4 = llvm.call @foo(%2) : (!llvm.ptr) -> i32 + %5 = llvm.icmp "eq" %4, %1 : i32 + llvm.cond_br %5, ^bb1, ^bb5(%1 : i32) + ^bb1: // pred: ^bb0 + llvm.intr.lifetime.start 4, %3 : !llvm.ptr + %6 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %7 = llvm.icmp "eq" %6, %1 : i32 + %8 = llvm.call @foo(%3) : (!llvm.ptr) -> i32 + llvm.cond_br %7, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %9 = llvm.call @bar() : () -> i32 + llvm.br ^bb4(%9 : i32) + ^bb3: // pred: ^bb1 + llvm.br ^bb4(%8 : i32) + ^bb4(%10: i32): // 2 preds: ^bb2, ^bb3 + llvm.intr.lifetime.end 4, %3 : !llvm.ptr + llvm.br ^bb5(%10 : i32) + ^bb5(%11: i32): // 2 preds: ^bb0, ^bb4 + llvm.intr.lifetime.end 4, %2 : !llvm.ptr + llvm.return %11 : i32 + } + llvm.func @unknown(!llvm.ptr) -> i32 + llvm.func @unknown.as2(!llvm.ptr<2>) -> i32 + llvm.func @sink_write_to_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %3 = llvm.call @unknown(%2) : (!llvm.ptr) -> i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %3 : i32 + } + llvm.func @sink_readwrite_to_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %3 = llvm.call @unknown(%2) : (!llvm.ptr) -> i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %3 : i32 + } + llvm.func @sink_bitcast(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i8 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %3 = llvm.call @unknown(%2) : (!llvm.ptr) -> i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %3 : i32 + } + llvm.func @sink_gep1(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %3 = llvm.getelementptr %2[%0] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + %4 = llvm.call @unknown(%3) : (!llvm.ptr) -> i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %4 : i32 + } + llvm.func @sink_gep2(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %3 = llvm.call @unknown(%2) : (!llvm.ptr) -> i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %3 : i32 + } + llvm.func @sink_addrspacecast(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 8 : i64} : (i32) -> !llvm.ptr + %3 = llvm.addrspacecast %2 : !llvm.ptr to !llvm.ptr<2> + %4 = llvm.call @unknown.as2(%3) : (!llvm.ptr<2>) -> i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %4 : i32 + } + llvm.func @neg_infinite_loop(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %3 = llvm.call @unknown(%2) : (!llvm.ptr) -> i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %3 : i32 + } + llvm.func @neg_throw(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %3 = llvm.call @unknown(%2) : (!llvm.ptr) -> i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %3 : i32 + } + llvm.func @neg_unknown_write(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %3 = llvm.call @unknown(%2) : (!llvm.ptr) -> i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %3 : i32 + } + llvm.func @sink_lifetime1(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 4, %2 : !llvm.ptr + %3 = llvm.call @unknown(%2) : (!llvm.ptr) -> i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.intr.lifetime.end 4, %2 : !llvm.ptr + llvm.return %3 : i32 + } + llvm.func @sink_lifetime2(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 4, %2 : !llvm.ptr + %3 = llvm.call @unknown(%2) : (!llvm.ptr) -> i32 + llvm.cond_br %arg0, ^bb1(%1 : i32), ^bb2 + ^bb1(%4: i32): // 2 preds: ^bb0, ^bb2 + llvm.intr.lifetime.end 4, %2 : !llvm.ptr + llvm.return %4 : i32 + ^bb2: // pred: ^bb0 + llvm.br ^bb1(%3 : i32) + } + llvm.func @sink_lifetime3(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 4, %2 : !llvm.ptr + llvm.intr.lifetime.end 4, %2 : !llvm.ptr + %3 = llvm.call @unknown(%2) : (!llvm.ptr) -> i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %3 : i32 + } + llvm.func @sink_lifetime4a(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 4, %2 : !llvm.ptr + %3 = llvm.call @unknown(%2) : (!llvm.ptr) -> i32 + llvm.intr.lifetime.end 4, %2 : !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %3 : i32 + } + llvm.func @sink_lifetime4b(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 4, %2 : !llvm.ptr + %3 = llvm.call @unknown(%2) : (!llvm.ptr) -> i32 + llvm.intr.lifetime.end 4, %2 : !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %3 : i32 + } + llvm.func @sink_atomicrmw_to_use(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.atomicrmw add %2, %0 seq_cst {alignment = 4 : i64} : !llvm.ptr, i32 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %3 : i32 + } + llvm.func @bar() -> i32 +} diff --git a/test/LLVMDialect/InstCombine/sink_to_unreachable.ll.mlir b/test/LLVMDialect/InstCombine/sink_to_unreachable.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/sitofp.ll.mlir b/test/LLVMDialect/InstCombine/sitofp.ll.mlir new file mode 100644 index 000000000..993e0a6a6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sitofp.ll.mlir @@ -0,0 +1,208 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1.280000e+02 : f64) : f64 + %1 = llvm.sitofp %arg0 : i8 to f64 + %2 = llvm.fcmp "ult" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @test2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1.281000e+02 : f64) : f64 + %1 = llvm.sitofp %arg0 : i8 to f64 + %2 = llvm.fcmp "ugt" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @test3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1.270000e+02 : f64) : f64 + %1 = llvm.sitofp %arg0 : i8 to f64 + %2 = llvm.fcmp "ule" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @test4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1.270000e+02 : f64) : f64 + %1 = llvm.sitofp %arg0 : i8 to f64 + %2 = llvm.fcmp "ult" %1, %0 : f64 + llvm.return %2 : i1 + } + llvm.func @test5(%arg0: i32) -> i32 { + %0 = llvm.sitofp %arg0 : i32 to f64 + %1 = llvm.fptosi %0 : f64 to i32 + %2 = llvm.uitofp %1 : i32 to f64 + %3 = llvm.fptoui %2 : f64 to i32 + llvm.return %3 : i32 + } + llvm.func @test6(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg0, %1 : i32 + %4 = llvm.sitofp %2 : i32 to f64 + %5 = llvm.sitofp %3 : i32 to f64 + %6 = llvm.fadd %4, %5 : f64 + %7 = llvm.fptosi %6 : f64 to i32 + llvm.return %7 : i32 + } + llvm.func @test7(%arg0: i32) -> i32 { + %0 = llvm.sitofp %arg0 : i32 to f64 + %1 = llvm.fptoui %0 : f64 to i32 + llvm.return %1 : i32 + } + llvm.func @test8(%arg0: i32) -> i32 { + %0 = llvm.uitofp %arg0 : i32 to f64 + %1 = llvm.fptosi %0 : f64 to i32 + llvm.return %1 : i32 + } + llvm.func @test9(%arg0: i8) -> i32 { + %0 = llvm.sitofp %arg0 : i8 to f32 + %1 = llvm.fptoui %0 : f32 to i32 + llvm.return %1 : i32 + } + llvm.func @test10(%arg0: i8) -> i32 { + %0 = llvm.sitofp %arg0 : i8 to f32 + %1 = llvm.fptosi %0 : f32 to i32 + llvm.return %1 : i32 + } + llvm.func @test11(%arg0: i32) -> i8 { + %0 = llvm.sitofp %arg0 : i32 to f32 + %1 = llvm.fptosi %0 : f32 to i8 + llvm.return %1 : i8 + } + llvm.func @test12(%arg0: i8) -> i32 { + %0 = llvm.sitofp %arg0 : i8 to f32 + %1 = llvm.fptoui %0 : f32 to i32 + llvm.return %1 : i32 + } + llvm.func @test13(%arg0: i25) -> i32 { + %0 = llvm.uitofp %arg0 : i25 to f32 + %1 = llvm.fptoui %0 : f32 to i32 + llvm.return %1 : i32 + } + llvm.func @test14(%arg0: i24) -> i32 { + %0 = llvm.uitofp %arg0 : i24 to f32 + %1 = llvm.fptoui %0 : f32 to i32 + llvm.return %1 : i32 + } + llvm.func @test15(%arg0: i32) -> i24 { + %0 = llvm.uitofp %arg0 : i32 to f32 + %1 = llvm.fptoui %0 : f32 to i24 + llvm.return %1 : i24 + } + llvm.func @test16(%arg0: i25) -> i32 { + %0 = llvm.sitofp %arg0 : i25 to f32 + %1 = llvm.fptoui %0 : f32 to i32 + llvm.return %1 : i32 + } + llvm.func @test17(%arg0: i26) -> i32 { + %0 = llvm.sitofp %arg0 : i26 to f32 + %1 = llvm.fptoui %0 : f32 to i32 + llvm.return %1 : i32 + } + llvm.func @test18(%arg0: i64) -> i54 { + %0 = llvm.sitofp %arg0 : i64 to f64 + %1 = llvm.fptosi %0 : f64 to i54 + llvm.return %1 : i54 + } + llvm.func @test19(%arg0: i64) -> i55 { + %0 = llvm.sitofp %arg0 : i64 to f64 + %1 = llvm.fptosi %0 : f64 to i55 + llvm.return %1 : i55 + } + llvm.func @masked_input(%arg0: i25) -> i25 { + %0 = llvm.mlir.constant(65535 : i25) : i25 + %1 = llvm.and %arg0, %0 : i25 + %2 = llvm.uitofp %1 : i25 to f32 + %3 = llvm.fptoui %2 : f32 to i25 + llvm.return %3 : i25 + } + llvm.func @max_masked_input(%arg0: i25) -> i25 { + %0 = llvm.mlir.constant(16777215 : i25) : i25 + %1 = llvm.and %arg0, %0 : i25 + %2 = llvm.uitofp %1 : i25 to f32 + %3 = llvm.fptoui %2 : f32 to i25 + llvm.return %3 : i25 + } + llvm.func @consider_lowbits_masked_input(%arg0: i25) -> i25 { + %0 = llvm.mlir.constant(-16777214 : i25) : i25 + %1 = llvm.and %arg0, %0 : i25 + %2 = llvm.uitofp %1 : i25 to f32 + %3 = llvm.fptoui %2 : f32 to i25 + llvm.return %3 : i25 + } + llvm.func @overflow_masked_input(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16777217 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.uitofp %1 : i32 to f32 + %3 = llvm.fptoui %2 : f32 to i32 + llvm.return %3 : i32 + } + llvm.func @low_masked_input(%arg0: i25) -> i25 { + %0 = llvm.mlir.constant(-2 : i25) : i25 + %1 = llvm.and %arg0, %0 : i25 + %2 = llvm.uitofp %1 : i25 to f32 + %3 = llvm.fptoui %2 : f32 to i25 + llvm.return %3 : i25 + } + llvm.func @s32_half_s11(%arg0: i32) -> i11 { + %0 = llvm.sitofp %arg0 : i32 to f16 + %1 = llvm.fptosi %0 : f16 to i11 + llvm.return %1 : i11 + } + llvm.func @s32_half_u11(%arg0: i32) -> i11 { + %0 = llvm.sitofp %arg0 : i32 to f16 + %1 = llvm.fptoui %0 : f16 to i11 + llvm.return %1 : i11 + } + llvm.func @u32_half_s11(%arg0: i32) -> i11 { + %0 = llvm.uitofp %arg0 : i32 to f16 + %1 = llvm.fptosi %0 : f16 to i11 + llvm.return %1 : i11 + } + llvm.func @u32_half_u11(%arg0: i32) -> i11 { + %0 = llvm.uitofp %arg0 : i32 to f16 + %1 = llvm.fptoui %0 : f16 to i11 + llvm.return %1 : i11 + } + llvm.func @s32_half_s12(%arg0: i32) -> i12 { + %0 = llvm.sitofp %arg0 : i32 to f16 + %1 = llvm.fptosi %0 : f16 to i12 + llvm.return %1 : i12 + } + llvm.func @s32_half_u12(%arg0: i32) -> i12 { + %0 = llvm.sitofp %arg0 : i32 to f16 + %1 = llvm.fptoui %0 : f16 to i12 + llvm.return %1 : i12 + } + llvm.func @u32_half_s12(%arg0: i32) -> i12 { + %0 = llvm.uitofp %arg0 : i32 to f16 + %1 = llvm.fptosi %0 : f16 to i12 + llvm.return %1 : i12 + } + llvm.func @u32_half_u12(%arg0: i32) -> i12 { + %0 = llvm.uitofp %arg0 : i32 to f16 + %1 = llvm.fptoui %0 : f16 to i12 + llvm.return %1 : i12 + } + llvm.func @i8_vec_sitofp_test1(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1.280000e+02> : vector<2xf64>) : vector<2xf64> + %1 = llvm.sitofp %arg0 : vector<2xi8> to vector<2xf64> + %2 = llvm.fcmp "ult" %1, %0 : vector<2xf64> + llvm.return %2 : vector<2xi1> + } + llvm.func @i8_vec_sitofp_test2(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1.281000e+02> : vector<2xf64>) : vector<2xf64> + %1 = llvm.sitofp %arg0 : vector<2xi8> to vector<2xf64> + %2 = llvm.fcmp "ugt" %1, %0 : vector<2xf64> + llvm.return %2 : vector<2xi1> + } + llvm.func @i8_vec_sitofp_test3(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1.270000e+02> : vector<2xf64>) : vector<2xf64> + %1 = llvm.sitofp %arg0 : vector<2xi8> to vector<2xf64> + %2 = llvm.fcmp "ule" %1, %0 : vector<2xf64> + llvm.return %2 : vector<2xi1> + } + llvm.func @i8_vec_sitofp_test4(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1.270000e+02> : vector<2xf64>) : vector<2xf64> + %1 = llvm.sitofp %arg0 : vector<2xi8> to vector<2xf64> + %2 = llvm.fcmp "ult" %1, %0 : vector<2xf64> + llvm.return %2 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/smax-icmp.ll.mlir b/test/LLVMDialect/InstCombine/smax-icmp.ll.mlir new file mode 100644 index 000000000..f67767292 --- /dev/null +++ b/test/LLVMDialect/InstCombine/smax-icmp.ll.mlir @@ -0,0 +1,426 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @eq_smax1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "eq" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @eq_smax2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "sgt" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "eq" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @eq_smax3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "sgt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "eq" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @eq_smax4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "sgt" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "eq" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @sle_smax1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "sle" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @sle_smax2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "sgt" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "sle" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @sle_smax3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "sgt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "sge" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @sle_smax4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "sgt" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "sge" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @ne_smax1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "ne" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ne_smax2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "sgt" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "ne" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ne_smax3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "sgt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @ne_smax4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "sgt" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @sgt_smax1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "sgt" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @sgt_smax2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "sgt" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "sgt" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @sgt_smax3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "sgt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "slt" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @sgt_smax4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "sgt" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "slt" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @use(i1) + llvm.func @eq_smax_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "eq" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smax(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @eq_smax_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "eq" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smax(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @slt_smax_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "slt" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smax(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @slt_smax_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "slt" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smax(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @sle_smax_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "sle" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smax(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @sle_smax_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "sle" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smax(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @sgt_smax_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "sgt" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smax(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @sgt_smax_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "sgt" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smax(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @sge_smax_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "sge" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smax(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @sge_smax_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "sge" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smax(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @test_smax_ugt(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.intr.smax(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test_smax_ugt_neg1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-5 : i32) : i32 + %2 = llvm.intr.smax(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test_smax_ugt_neg2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-5 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.intr.smax(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/smin-icmp.ll.mlir b/test/LLVMDialect/InstCombine/smin-icmp.ll.mlir new file mode 100644 index 000000000..abd332198 --- /dev/null +++ b/test/LLVMDialect/InstCombine/smin-icmp.ll.mlir @@ -0,0 +1,665 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @eq_smin1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "eq" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @eq_smin2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "slt" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "eq" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @eq_smin3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "slt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "eq" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @eq_smin4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "slt" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "eq" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @sge_smin1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "sge" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @sge_smin2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "slt" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "sge" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @sge_smin3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "slt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "sle" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @sge_smin4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "slt" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "sle" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @ne_smin1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "ne" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ne_smin2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "slt" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "ne" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ne_smin3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "slt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @ne_smin4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "slt" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @slt_smin1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "slt" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @slt_smin2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "slt" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "slt" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @slt_smin3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "slt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "sgt" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @slt_smin4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "slt" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "sgt" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @sle_smin1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "sle" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @sle_smin2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "slt" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "sle" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @sle_smin3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "slt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "sge" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @sle_smin4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "slt" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "sge" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @sgt_smin1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "slt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "sgt" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @sgt_smin2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "slt" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "sgt" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @sgt_smin3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "slt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "slt" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @sgt_smin4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "slt" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "slt" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @use(i1) + llvm.func @eq_smin_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "eq" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @eq_smin_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "eq" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smin(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @slt_smin_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "slt" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @slt_smin_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "slt" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smin(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @sle_smin_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "sle" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @sle_smin_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "sle" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smin(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @sgt_smin_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "sgt" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @sgt_smin_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "sgt" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smin(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @sge_smin_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "sge" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @sge_smin_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "sge" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.smin(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @use_v2i1(vector<2xi1>) + llvm.func @eq_smin_v2i32(%arg0: vector<2xi32>, %arg1: vector<2xi32>) { + %0 = llvm.intr.smin(%arg0, %arg1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + %1 = llvm.icmp "slt" %0, %arg0 : vector<2xi32> + llvm.call @use_v2i1(%1) : (vector<2xi1>) -> () + %2 = llvm.icmp "sle" %0, %arg0 : vector<2xi32> + llvm.call @use_v2i1(%2) : (vector<2xi1>) -> () + %3 = llvm.icmp "sgt" %0, %arg0 : vector<2xi32> + llvm.call @use_v2i1(%3) : (vector<2xi1>) -> () + %4 = llvm.icmp "sge" %0, %arg0 : vector<2xi32> + llvm.call @use_v2i1(%4) : (vector<2xi1>) -> () + %5 = llvm.icmp "ult" %0, %arg0 : vector<2xi32> + llvm.call @use_v2i1(%5) : (vector<2xi1>) -> () + %6 = llvm.icmp "ule" %0, %arg0 : vector<2xi32> + llvm.call @use_v2i1(%6) : (vector<2xi1>) -> () + %7 = llvm.icmp "ugt" %0, %arg0 : vector<2xi32> + llvm.call @use_v2i1(%7) : (vector<2xi1>) -> () + %8 = llvm.icmp "uge" %0, %arg0 : vector<2xi32> + llvm.call @use_v2i1(%8) : (vector<2xi1>) -> () + %9 = llvm.icmp "eq" %0, %arg0 : vector<2xi32> + llvm.call @use_v2i1(%9) : (vector<2xi1>) -> () + %10 = llvm.icmp "ne" %0, %arg0 : vector<2xi32> + llvm.call @use_v2i1(%10) : (vector<2xi1>) -> () + llvm.return + } + llvm.func @eq_smin_v2i32_constant(%arg0: vector<2xi32>) { + %0 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %1 = llvm.intr.smin(%0, %arg0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + %2 = llvm.icmp "slt" %1, %0 : vector<2xi32> + llvm.call @use_v2i1(%2) : (vector<2xi1>) -> () + %3 = llvm.icmp "sle" %1, %0 : vector<2xi32> + llvm.call @use_v2i1(%3) : (vector<2xi1>) -> () + %4 = llvm.icmp "sgt" %1, %0 : vector<2xi32> + llvm.call @use_v2i1(%4) : (vector<2xi1>) -> () + %5 = llvm.icmp "sge" %1, %0 : vector<2xi32> + llvm.call @use_v2i1(%5) : (vector<2xi1>) -> () + %6 = llvm.icmp "ult" %1, %0 : vector<2xi32> + llvm.call @use_v2i1(%6) : (vector<2xi1>) -> () + %7 = llvm.icmp "ule" %1, %0 : vector<2xi32> + llvm.call @use_v2i1(%7) : (vector<2xi1>) -> () + %8 = llvm.icmp "ugt" %1, %0 : vector<2xi32> + llvm.call @use_v2i1(%8) : (vector<2xi1>) -> () + %9 = llvm.icmp "uge" %1, %0 : vector<2xi32> + llvm.call @use_v2i1(%9) : (vector<2xi1>) -> () + %10 = llvm.icmp "eq" %1, %0 : vector<2xi32> + llvm.call @use_v2i1(%10) : (vector<2xi1>) -> () + %11 = llvm.icmp "ne" %1, %0 : vector<2xi32> + llvm.call @use_v2i1(%11) : (vector<2xi1>) -> () + llvm.return + } + llvm.func @slt_smin_v2i32_constant(%arg0: vector<2xi32>) { + %0 = llvm.mlir.constant(dense<5> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.smin(%0, %arg0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%3) : (vector<2xi1>) -> () + %4 = llvm.icmp "sle" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%4) : (vector<2xi1>) -> () + %5 = llvm.icmp "sgt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%5) : (vector<2xi1>) -> () + %6 = llvm.icmp "sge" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%6) : (vector<2xi1>) -> () + %7 = llvm.icmp "ult" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%7) : (vector<2xi1>) -> () + %8 = llvm.icmp "ule" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%8) : (vector<2xi1>) -> () + %9 = llvm.icmp "ugt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%9) : (vector<2xi1>) -> () + %10 = llvm.icmp "uge" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%10) : (vector<2xi1>) -> () + %11 = llvm.icmp "eq" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%11) : (vector<2xi1>) -> () + %12 = llvm.icmp "ne" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%12) : (vector<2xi1>) -> () + llvm.return + } + llvm.func @sle_smin_v2i32_constant(%arg0: vector<2xi32>) { + %0 = llvm.mlir.constant(dense<[5, 10]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.smin(%0, %arg0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%3) : (vector<2xi1>) -> () + %4 = llvm.icmp "sle" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%4) : (vector<2xi1>) -> () + %5 = llvm.icmp "sgt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%5) : (vector<2xi1>) -> () + %6 = llvm.icmp "sge" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%6) : (vector<2xi1>) -> () + %7 = llvm.icmp "ult" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%7) : (vector<2xi1>) -> () + %8 = llvm.icmp "ule" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%8) : (vector<2xi1>) -> () + %9 = llvm.icmp "ugt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%9) : (vector<2xi1>) -> () + %10 = llvm.icmp "uge" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%10) : (vector<2xi1>) -> () + %11 = llvm.icmp "eq" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%11) : (vector<2xi1>) -> () + %12 = llvm.icmp "ne" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%12) : (vector<2xi1>) -> () + llvm.return + } + llvm.func @sgt_smin_v2i32_constant(%arg0: vector<2xi32>) { + %0 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.smin(%0, %arg0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%3) : (vector<2xi1>) -> () + %4 = llvm.icmp "sle" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%4) : (vector<2xi1>) -> () + %5 = llvm.icmp "sgt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%5) : (vector<2xi1>) -> () + %6 = llvm.icmp "sge" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%6) : (vector<2xi1>) -> () + %7 = llvm.icmp "ult" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%7) : (vector<2xi1>) -> () + %8 = llvm.icmp "ule" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%8) : (vector<2xi1>) -> () + %9 = llvm.icmp "ugt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%9) : (vector<2xi1>) -> () + %10 = llvm.icmp "uge" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%10) : (vector<2xi1>) -> () + %11 = llvm.icmp "eq" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%11) : (vector<2xi1>) -> () + %12 = llvm.icmp "ne" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%12) : (vector<2xi1>) -> () + llvm.return + } + llvm.func @sge_smin_v2i32_constant(%arg0: vector<2xi32>) { + %0 = llvm.mlir.constant(dense<[15, 10]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.smin(%0, %arg0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%3) : (vector<2xi1>) -> () + %4 = llvm.icmp "sle" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%4) : (vector<2xi1>) -> () + %5 = llvm.icmp "sgt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%5) : (vector<2xi1>) -> () + %6 = llvm.icmp "sge" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%6) : (vector<2xi1>) -> () + %7 = llvm.icmp "ult" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%7) : (vector<2xi1>) -> () + %8 = llvm.icmp "ule" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%8) : (vector<2xi1>) -> () + %9 = llvm.icmp "ugt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%9) : (vector<2xi1>) -> () + %10 = llvm.icmp "uge" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%10) : (vector<2xi1>) -> () + %11 = llvm.icmp "eq" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%11) : (vector<2xi1>) -> () + %12 = llvm.icmp "ne" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%12) : (vector<2xi1>) -> () + llvm.return + } + llvm.func @unknown_smin_v2i32_constant(%arg0: vector<2xi32>) { + %0 = llvm.mlir.constant(dense<[5, 15]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.intr.smin(%0, %arg0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%3) : (vector<2xi1>) -> () + %4 = llvm.icmp "sle" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%4) : (vector<2xi1>) -> () + %5 = llvm.icmp "sgt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%5) : (vector<2xi1>) -> () + %6 = llvm.icmp "sge" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%6) : (vector<2xi1>) -> () + %7 = llvm.icmp "ult" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%7) : (vector<2xi1>) -> () + %8 = llvm.icmp "ule" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%8) : (vector<2xi1>) -> () + %9 = llvm.icmp "ugt" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%9) : (vector<2xi1>) -> () + %10 = llvm.icmp "uge" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%10) : (vector<2xi1>) -> () + %11 = llvm.icmp "eq" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%11) : (vector<2xi1>) -> () + %12 = llvm.icmp "ne" %2, %1 : vector<2xi32> + llvm.call @use_v2i1(%12) : (vector<2xi1>) -> () + llvm.return + } + llvm.func @smin_or_bitwise(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.smin(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @smin_and_bitwise(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.intr.smin(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "slt" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @eq_smin_nofold(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %0 : i32 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.intr.smin(%arg0, %0) : (i32, i32) -> i32 + %3 = llvm.icmp "eq" %2, %0 : i32 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/smulo.ll.mlir b/test/LLVMDialect/InstCombine/smulo.ll.mlir new file mode 100644 index 000000000..8bc88c94d --- /dev/null +++ b/test/LLVMDialect/InstCombine/smulo.ll.mlir @@ -0,0 +1,101 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_generic(%arg0: i64, %arg1: i64) -> i1 { + %0 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i64, i1)> + llvm.return %1 : i1 + } + llvm.func @test_constant0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant127(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant128(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant255(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @i1_res(%arg0: i1, %arg1: i1) -> i1 { + %0 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (i1, i1) -> !llvm.struct<(i1, i1)> + %1 = llvm.extractvalue %0[0] : !llvm.struct<(i1, i1)> + llvm.return %1 : i1 + } + llvm.func @v2i1_res(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (vector<2xi1>, vector<2xi1>) -> !llvm.struct<(vector<2xi1>, vector<2xi1>)> + %1 = llvm.extractvalue %0[0] : !llvm.struct<(vector<2xi1>, vector<2xi1>)> + llvm.return %1 : vector<2xi1> + } + llvm.func @i1_res_by_one(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i1, i1) -> !llvm.struct<(i1, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i1, i1)> + llvm.return %2 : i1 + } + llvm.func @v2i1_res_by_one(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = "llvm.intr.smul.with.overflow"(%arg0, %1) : (vector<2xi1>, vector<2xi1>) -> !llvm.struct<(vector<2xi1>, vector<2xi1>)> + %3 = llvm.extractvalue %2[0] : !llvm.struct<(vector<2xi1>, vector<2xi1>)> + llvm.return %3 : vector<2xi1> + } + llvm.func @i1_ov(%arg0: i1, %arg1: i1) -> i1 { + %0 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (i1, i1) -> !llvm.struct<(i1, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i1, i1)> + llvm.return %1 : i1 + } + llvm.func @v2i1_ov(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = "llvm.intr.smul.with.overflow"(%arg0, %arg1) : (vector<2xi1>, vector<2xi1>) -> !llvm.struct<(vector<2xi1>, vector<2xi1>)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(vector<2xi1>, vector<2xi1>)> + llvm.return %1 : vector<2xi1> + } + llvm.func @i1_ov_by_one(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i1, i1) -> !llvm.struct<(i1, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i1, i1)> + llvm.return %2 : i1 + } + llvm.func @v2i1_ov_by_one(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = "llvm.intr.smul.with.overflow"(%arg0, %1) : (vector<2xi1>, vector<2xi1>) -> !llvm.struct<(vector<2xi1>, vector<2xi1>)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(vector<2xi1>, vector<2xi1>)> + llvm.return %3 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/snprintf-2.ll.mlir b/test/LLVMDialect/InstCombine/snprintf-2.ll.mlir new file mode 100644 index 000000000..6be922fd1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/snprintf-2.ll.mlir @@ -0,0 +1,78 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @s("123\00") {addr_space = 0 : i32} + llvm.mlir.global external @adst() {addr_space = 0 : i32} : !llvm.array<0 x ptr> + llvm.mlir.global external @asiz() {addr_space = 0 : i32} : !llvm.array<0 x i32> + llvm.func @snprintf(!llvm.ptr, i64, !llvm.ptr, ...) -> i32 + llvm.func @fold_snprintf_fmt() { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @adst : !llvm.ptr + %3 = llvm.getelementptr %2[%1, %0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %4 = llvm.mlir.constant(2147483647 : i64) : i64 + %5 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %6 = llvm.mlir.addressof @s : !llvm.ptr + %7 = llvm.mlir.addressof @asiz : !llvm.ptr + %8 = llvm.mlir.constant(5 : i32) : i32 + %9 = llvm.getelementptr %2[%1, %8] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %10 = llvm.mlir.constant(5 : i64) : i64 + %11 = llvm.getelementptr %7[%1, %8] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %12 = llvm.mlir.constant(4 : i32) : i32 + %13 = llvm.getelementptr %2[%1, %12] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %14 = llvm.mlir.constant(4 : i64) : i64 + %15 = llvm.getelementptr %7[%1, %12] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %16 = llvm.mlir.constant(3 : i32) : i32 + %17 = llvm.getelementptr %2[%1, %16] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %18 = llvm.mlir.constant(3 : i64) : i64 + %19 = llvm.getelementptr %7[%1, %16] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %20 = llvm.mlir.constant(2 : i32) : i32 + %21 = llvm.getelementptr %2[%1, %20] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %22 = llvm.mlir.constant(2 : i64) : i64 + %23 = llvm.getelementptr %7[%1, %20] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %24 = llvm.mlir.constant(1 : i32) : i32 + %25 = llvm.getelementptr %2[%1, %24] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %26 = llvm.mlir.constant(1 : i64) : i64 + %27 = llvm.getelementptr %7[%1, %24] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %28 = llvm.mlir.constant(0 : i64) : i64 + %29 = llvm.load %3 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %30 = llvm.call @snprintf(%29, %4, %6) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.store %30, %7 {alignment = 4 : i64} : i32, !llvm.ptr + %31 = llvm.load %9 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %32 = llvm.call @snprintf(%31, %10, %6) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.store %32, %11 {alignment = 4 : i64} : i32, !llvm.ptr + %33 = llvm.load %13 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %34 = llvm.call @snprintf(%33, %14, %6) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.store %34, %15 {alignment = 4 : i64} : i32, !llvm.ptr + %35 = llvm.load %17 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %36 = llvm.call @snprintf(%35, %18, %6) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.store %36, %19 {alignment = 4 : i64} : i32, !llvm.ptr + %37 = llvm.load %21 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %38 = llvm.call @snprintf(%37, %22, %6) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.store %38, %23 {alignment = 4 : i64} : i32, !llvm.ptr + %39 = llvm.load %25 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %40 = llvm.call @snprintf(%39, %26, %6) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.store %40, %27 {alignment = 4 : i64} : i32, !llvm.ptr + %41 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %42 = llvm.call @snprintf(%41, %28, %6) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.store %42, %7 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @call_snprintf_fmt_ximax() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @adst : !llvm.ptr + %3 = llvm.getelementptr %2[%1, %0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %4 = llvm.mlir.constant(-1 : i64) : i64 + %5 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %6 = llvm.mlir.addressof @s : !llvm.ptr + %7 = llvm.mlir.addressof @asiz : !llvm.ptr + %8 = llvm.getelementptr %7[%1, %0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %9 = llvm.mlir.constant(2147483648 : i64) : i64 + %10 = llvm.load %3 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %11 = llvm.call @snprintf(%10, %4, %6) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.store %11, %8 {alignment = 4 : i64} : i32, !llvm.ptr + %12 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %13 = llvm.call @snprintf(%12, %9, %6) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.store %13, %7 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/snprintf-3.ll.mlir b/test/LLVMDialect/InstCombine/snprintf-3.ll.mlir new file mode 100644 index 000000000..2fcd6e975 --- /dev/null +++ b/test/LLVMDialect/InstCombine/snprintf-3.ll.mlir @@ -0,0 +1,83 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @pcnt_s("%s\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s("123\00") {addr_space = 0 : i32} + llvm.mlir.global external @adst() {addr_space = 0 : i32} : !llvm.array<0 x ptr> + llvm.mlir.global external @asiz() {addr_space = 0 : i32} : !llvm.array<0 x i32> + llvm.func @snprintf(!llvm.ptr, i64, !llvm.ptr, ...) -> i32 + llvm.func @fold_snprintf_pcnt_s() { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @adst : !llvm.ptr + %3 = llvm.getelementptr %2[%1, %0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %4 = llvm.mlir.constant(2147483647 : i64) : i64 + %5 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %6 = llvm.mlir.addressof @pcnt_s : !llvm.ptr + %7 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %8 = llvm.mlir.addressof @s : !llvm.ptr + %9 = llvm.mlir.addressof @asiz : !llvm.ptr + %10 = llvm.mlir.constant(5 : i32) : i32 + %11 = llvm.getelementptr %2[%1, %10] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %12 = llvm.mlir.constant(5 : i64) : i64 + %13 = llvm.getelementptr %9[%1, %10] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %14 = llvm.mlir.constant(4 : i32) : i32 + %15 = llvm.getelementptr %2[%1, %14] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %16 = llvm.mlir.constant(4 : i64) : i64 + %17 = llvm.getelementptr %9[%1, %14] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %18 = llvm.mlir.constant(3 : i32) : i32 + %19 = llvm.getelementptr %2[%1, %18] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %20 = llvm.mlir.constant(3 : i64) : i64 + %21 = llvm.getelementptr %9[%1, %18] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %22 = llvm.mlir.constant(2 : i32) : i32 + %23 = llvm.getelementptr %2[%1, %22] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %24 = llvm.mlir.constant(2 : i64) : i64 + %25 = llvm.getelementptr %9[%1, %22] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %26 = llvm.mlir.constant(1 : i32) : i32 + %27 = llvm.getelementptr %2[%1, %26] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %28 = llvm.mlir.constant(1 : i64) : i64 + %29 = llvm.getelementptr %9[%1, %26] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %30 = llvm.mlir.constant(0 : i64) : i64 + %31 = llvm.load %3 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %32 = llvm.call @snprintf(%31, %4, %6, %8) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.store %32, %9 {alignment = 4 : i64} : i32, !llvm.ptr + %33 = llvm.load %11 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %34 = llvm.call @snprintf(%33, %12, %6, %8) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.store %34, %13 {alignment = 4 : i64} : i32, !llvm.ptr + %35 = llvm.load %15 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %36 = llvm.call @snprintf(%35, %16, %6, %8) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.store %36, %17 {alignment = 4 : i64} : i32, !llvm.ptr + %37 = llvm.load %19 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %38 = llvm.call @snprintf(%37, %20, %6, %8) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.store %38, %21 {alignment = 4 : i64} : i32, !llvm.ptr + %39 = llvm.load %23 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %40 = llvm.call @snprintf(%39, %24, %6, %8) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.store %40, %25 {alignment = 4 : i64} : i32, !llvm.ptr + %41 = llvm.load %27 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %42 = llvm.call @snprintf(%41, %28, %6, %8) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.store %42, %29 {alignment = 4 : i64} : i32, !llvm.ptr + %43 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %44 = llvm.call @snprintf(%43, %30, %6, %8) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.store %44, %9 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @call_snprintf_pcnt_s_ximax() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @adst : !llvm.ptr + %3 = llvm.getelementptr %2[%1, %0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %4 = llvm.mlir.constant(-1 : i64) : i64 + %5 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %6 = llvm.mlir.addressof @pcnt_s : !llvm.ptr + %7 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %8 = llvm.mlir.addressof @s : !llvm.ptr + %9 = llvm.mlir.addressof @asiz : !llvm.ptr + %10 = llvm.getelementptr %9[%1, %0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %11 = llvm.mlir.constant(2147483648 : i64) : i64 + %12 = llvm.load %3 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %13 = llvm.call @snprintf(%12, %4, %6, %8) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.store %13, %10 {alignment = 4 : i64} : i32, !llvm.ptr + %14 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %15 = llvm.call @snprintf(%14, %11, %6, %8) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.store %15, %9 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/snprintf-4.ll.mlir b/test/LLVMDialect/InstCombine/snprintf-4.ll.mlir new file mode 100644 index 000000000..bafc19110 --- /dev/null +++ b/test/LLVMDialect/InstCombine/snprintf-4.ll.mlir @@ -0,0 +1,85 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @pcnt_c("%c\00") {addr_space = 0 : i32} + llvm.mlir.global external @adst() {addr_space = 0 : i32} : !llvm.array<0 x ptr> + llvm.mlir.global external @asiz() {addr_space = 0 : i32} : !llvm.array<0 x i32> + llvm.func @snprintf(!llvm.ptr, i64, !llvm.ptr, ...) -> i32 + llvm.func @fold_snprintf_pcnt_c(%arg0: i32) { + %0 = llvm.mlir.addressof @adst : !llvm.ptr + %1 = llvm.mlir.constant(2147483647 : i64) : i64 + %2 = llvm.mlir.constant("%c\00") : !llvm.array<3 x i8> + %3 = llvm.mlir.addressof @pcnt_c : !llvm.ptr + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.mlir.addressof @asiz : !llvm.ptr + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.getelementptr %0[%6, %4] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %8 = llvm.mlir.constant(2 : i64) : i64 + %9 = llvm.mlir.constant(2 : i8) : i8 + %10 = llvm.getelementptr %5[%6, %4] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %11 = llvm.mlir.constant(2 : i32) : i32 + %12 = llvm.getelementptr %0[%6, %11] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %13 = llvm.mlir.constant(0 : i8) : i8 + %14 = llvm.getelementptr %5[%6, %11] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %15 = llvm.mlir.constant(3 : i32) : i32 + %16 = llvm.getelementptr %0[%6, %15] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %17 = llvm.mlir.constant(1 : i64) : i64 + %18 = llvm.mlir.constant(3 : i16) : i16 + %19 = llvm.getelementptr %5[%6, %15] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %20 = llvm.mlir.constant(4 : i32) : i32 + %21 = llvm.getelementptr %0[%6, %20] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %22 = llvm.mlir.constant(0 : i64) : i64 + %23 = llvm.getelementptr %5[%6, %20] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %24 = llvm.mlir.constant(5 : i32) : i32 + %25 = llvm.getelementptr %0[%6, %24] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %26 = llvm.getelementptr %5[%6, %24] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %27 = llvm.load %0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %28 = llvm.call @snprintf(%27, %1, %3, %4) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, i32) -> i32 + llvm.store %28, %5 {alignment = 4 : i64} : i32, !llvm.ptr + %29 = llvm.load %7 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %30 = llvm.call @snprintf(%29, %8, %3, %9) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, i8) -> i32 + llvm.store %30, %10 {alignment = 4 : i64} : i32, !llvm.ptr + %31 = llvm.load %12 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %32 = llvm.call @snprintf(%31, %8, %3, %13) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, i8) -> i32 + llvm.store %32, %14 {alignment = 4 : i64} : i32, !llvm.ptr + %33 = llvm.load %16 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %34 = llvm.call @snprintf(%33, %17, %3, %18) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, i16) -> i32 + llvm.store %34, %19 {alignment = 4 : i64} : i32, !llvm.ptr + %35 = llvm.load %21 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %36 = llvm.call @snprintf(%35, %22, %3, %20) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, i32) -> i32 + llvm.store %36, %23 {alignment = 4 : i64} : i32, !llvm.ptr + %37 = llvm.load %21 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %38 = llvm.call @snprintf(%37, %8, %3, %arg0) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, i32) -> i32 + llvm.store %38, %23 {alignment = 4 : i64} : i32, !llvm.ptr + %39 = llvm.load %25 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %40 = llvm.call @snprintf(%39, %17, %3, %arg0) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, i32) -> i32 + llvm.store %40, %26 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @call_snprintf_pcnt_c_ximax(%arg0: i32) { + %0 = llvm.mlir.addressof @adst : !llvm.ptr + %1 = llvm.mlir.constant(-1 : i64) : i64 + %2 = llvm.mlir.constant("%c\00") : !llvm.array<3 x i8> + %3 = llvm.mlir.addressof @pcnt_c : !llvm.ptr + %4 = llvm.mlir.constant(0 : i8) : i8 + %5 = llvm.mlir.addressof @asiz : !llvm.ptr + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.mlir.constant(0 : i32) : i32 + %8 = llvm.getelementptr %0[%7, %6] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %9 = llvm.mlir.constant(2147483648 : i64) : i64 + %10 = llvm.mlir.constant(1 : i8) : i8 + %11 = llvm.getelementptr %5[%7, %6] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %12 = llvm.mlir.constant(2 : i32) : i32 + %13 = llvm.getelementptr %0[%7, %12] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x ptr> + %14 = llvm.mlir.constant(-4294967296 : i64) : i64 + %15 = llvm.getelementptr %5[%7, %12] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i32> + %16 = llvm.load %0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %17 = llvm.call @snprintf(%16, %1, %3, %4) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, i8) -> i32 + llvm.store %17, %5 {alignment = 4 : i64} : i32, !llvm.ptr + %18 = llvm.load %8 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %19 = llvm.call @snprintf(%18, %9, %3, %10) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, i8) -> i32 + llvm.store %19, %11 {alignment = 4 : i64} : i32, !llvm.ptr + %20 = llvm.load %13 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %21 = llvm.call @snprintf(%20, %14, %3, %10) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, i8) -> i32 + llvm.store %21, %15 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/snprintf.ll.mlir b/test/LLVMDialect/InstCombine/snprintf.ll.mlir new file mode 100644 index 000000000..4e28f639b --- /dev/null +++ b/test/LLVMDialect/InstCombine/snprintf.ll.mlir @@ -0,0 +1,146 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private unnamed_addr constant @".str"("str\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.1"("%%\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.2"("%c\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.3"("%s\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.4"(dense<0> : tensor<1xi8>) {addr_space = 0 : i32, alignment = 1 : i64, dso_local} : !llvm.array<1 x i8> + llvm.func @snprintf(!llvm.ptr, i64, !llvm.ptr, ...) -> i32 + llvm.func @test_not_const_fmt(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.call @snprintf(%arg0, %0, %arg1) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_not_const_fmt_zero_size_return_value(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @snprintf(%arg0, %0, %arg1) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_not_const_size(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("str\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.call @snprintf(%arg0, %arg1, %1) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_return_value(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant("str\00") : !llvm.array<4 x i8> + %2 = llvm.mlir.addressof @".str" : !llvm.ptr + %3 = llvm.call @snprintf(%arg0, %0, %2) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.return %3 : i32 + } + llvm.func @test_percentage(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant("%%\00") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @".str.1" : !llvm.ptr + %3 = llvm.call @snprintf(%arg0, %0, %2) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_null_buf_return_value() -> i32 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant("str\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.addressof @".str" : !llvm.ptr + %4 = llvm.call @snprintf(%0, %1, %3) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_percentage_return_value() -> i32 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant("%%\00") : !llvm.array<3 x i8> + %3 = llvm.mlir.addressof @".str.1" : !llvm.ptr + %4 = llvm.call @snprintf(%0, %1, %3) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_correct_copy(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant("str\00") : !llvm.array<4 x i8> + %2 = llvm.mlir.addressof @".str" : !llvm.ptr + %3 = llvm.call @snprintf(%arg0, %0, %2) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_char_zero_size(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant("%c\00") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @".str.2" : !llvm.ptr + %3 = llvm.mlir.constant(65 : i32) : i32 + %4 = llvm.call @snprintf(%arg0, %0, %2, %3) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_char_small_size(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant("%c\00") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @".str.2" : !llvm.ptr + %3 = llvm.mlir.constant(65 : i32) : i32 + %4 = llvm.call @snprintf(%arg0, %0, %2, %3) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_char_ok_size(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant("%c\00") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @".str.2" : !llvm.ptr + %3 = llvm.mlir.constant(65 : i32) : i32 + %4 = llvm.call @snprintf(%arg0, %0, %2, %3) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_str_zero_size(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @".str.3" : !llvm.ptr + %3 = llvm.mlir.constant("str\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.addressof @".str" : !llvm.ptr + %5 = llvm.call @snprintf(%arg0, %0, %2, %4) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %5 : i32 + } + llvm.func @test_str_small_size(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @".str.3" : !llvm.ptr + %3 = llvm.mlir.constant("str\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.addressof @".str" : !llvm.ptr + %5 = llvm.call @snprintf(%arg0, %0, %2, %4) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %5 : i32 + } + llvm.func @test_str_ok_size(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @".str.3" : !llvm.ptr + %3 = llvm.mlir.constant("str\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.addressof @".str" : !llvm.ptr + %5 = llvm.call @snprintf(%arg0, %0, %2, %4) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %5 : i32 + } + llvm.func @test_str_ok_size_tail(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %3 = llvm.mlir.addressof @".str.4" : !llvm.ptr + %4 = llvm.call @snprintf(%arg0, %0, %3) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_str_ok_size_musttail(%arg0: !llvm.ptr, %arg1: i64, %arg2: !llvm.ptr, ...) -> i32 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %3 = llvm.mlir.addressof @".str.4" : !llvm.ptr + %4 = llvm.call @snprintf(%arg0, %0, %3) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_str_ok_size_tail2(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @".str.3" : !llvm.ptr + %3 = llvm.mlir.constant("str\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.addressof @".str" : !llvm.ptr + %5 = llvm.call @snprintf(%arg0, %0, %2, %4) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %5 : i32 + } + llvm.func @test_str_ok_size_musttail2(%arg0: !llvm.ptr, %arg1: i64, %arg2: !llvm.ptr, ...) -> i32 { + %0 = llvm.mlir.constant(8 : i64) : i64 + %1 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @".str.3" : !llvm.ptr + %3 = llvm.mlir.constant("str\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.addressof @".str" : !llvm.ptr + %5 = llvm.call @snprintf(%arg0, %0, %2, %4) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sprintf-1.ll.mlir b/test/LLVMDialect/InstCombine/sprintf-1.ll.mlir new file mode 100644 index 000000000..7b224fe97 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sprintf-1.ll.mlir @@ -0,0 +1,87 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello_world("hello world\0A\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external constant @null_hello("\00hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @h("h\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent_c("%c\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent_d("%d\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent_f("%f\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @percent_s("%s\00") {addr_space = 0 : i32} + llvm.func @sprintf(!llvm.ptr, !llvm.ptr, ...) -> i32 + llvm.func @test_simplify1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("hello world\0A\00") : !llvm.array<13 x i8> + %1 = llvm.mlir.addressof @hello_world : !llvm.ptr + %2 = llvm.call @sprintf(%arg0, %1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify2(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @sprintf(%arg0, %2) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify3(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("\00hello\00") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @null_hello : !llvm.ptr + %2 = llvm.call @sprintf(%arg0, %1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify4(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%c\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_c : !llvm.ptr + %2 = llvm.mlir.constant(104 : i8) : i8 + %3 = llvm.call @sprintf(%arg0, %1, %2) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, i8) -> i32 + llvm.return + } + llvm.func @test_simplify5(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_s : !llvm.ptr + %2 = llvm.call @sprintf(%arg0, %1, %arg1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @test_simplify6(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%d\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_d : !llvm.ptr + %2 = llvm.mlir.constant(187 : i32) : i32 + %3 = llvm.call @sprintf(%arg0, %1, %2) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return + } + llvm.func @test_simplify7(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_s : !llvm.ptr + %2 = llvm.call @sprintf(%arg0, %1, %arg1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %2 : i32 + } + llvm.func @test_simplify8(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_s : !llvm.ptr + %2 = llvm.mlir.constant("hello world\0A\00") : !llvm.array<13 x i8> + %3 = llvm.mlir.addressof @hello_world : !llvm.ptr + %4 = llvm.call @sprintf(%arg0, %1, %3) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_simplify9(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_s : !llvm.ptr + %2 = llvm.call @sprintf(%arg0, %1, %arg1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %2 : i32 + } + llvm.func @test_no_simplify1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%f\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_f : !llvm.ptr + %2 = llvm.mlir.constant(1.870000e+00 : f64) : f64 + %3 = llvm.call @sprintf(%arg0, %1, %2) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, f64) -> i32 + llvm.return + } + llvm.func @test_no_simplify2(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: f64) { + %0 = llvm.call @sprintf(%arg0, %arg1, %arg2) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, f64) -> i32 + llvm.return + } + llvm.func @test_no_simplify3(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 attributes {passthrough = ["minsize"]} { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_s : !llvm.ptr + %2 = llvm.call @sprintf(%arg0, %1, %arg1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sprintf-2.ll.mlir b/test/LLVMDialect/InstCombine/sprintf-2.ll.mlir new file mode 100644 index 000000000..504fe2440 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sprintf-2.ll.mlir @@ -0,0 +1,94 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a() {addr_space = 0 : i32} : !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> { + %0 = llvm.mlir.constant("123456\00") : !llvm.array<7 x i8> + %1 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %2 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %7 = llvm.mlir.constant("123\00\00\00\00") : !llvm.array<7 x i8> + %8 = llvm.mlir.constant("12\00\00\00\00") : !llvm.array<6 x i8> + %9 = llvm.mlir.constant("1\00\00\00\00") : !llvm.array<5 x i8> + %10 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %11 = llvm.insertvalue %9, %10[0] : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %12 = llvm.insertvalue %8, %11[1] : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %13 = llvm.insertvalue %7, %12[2] : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %14 = llvm.mlir.undef : !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + %15 = llvm.insertvalue %13, %14[0] : !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + %16 = llvm.insertvalue %6, %15[1] : !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + llvm.return %16 : !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + } + llvm.mlir.global external constant @pcnt_s("%s\00") {addr_space = 0 : i32} + llvm.func @snprintf(!llvm.ptr, i64, !llvm.ptr, ...) -> i32 + llvm.func @fold_snprintf_member_pC(%arg0: !llvm.ptr) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %3 = llvm.mlir.addressof @pcnt_s : !llvm.ptr + %4 = llvm.mlir.constant("123456\00") : !llvm.array<7 x i8> + %5 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %6 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %7 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %8 = llvm.insertvalue %6, %7[0] : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %9 = llvm.insertvalue %5, %8[1] : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %10 = llvm.insertvalue %4, %9[2] : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %11 = llvm.mlir.constant("123\00\00\00\00") : !llvm.array<7 x i8> + %12 = llvm.mlir.constant("12\00\00\00\00") : !llvm.array<6 x i8> + %13 = llvm.mlir.constant("1\00\00\00\00") : !llvm.array<5 x i8> + %14 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %15 = llvm.insertvalue %13, %14[0] : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %16 = llvm.insertvalue %12, %15[1] : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %17 = llvm.insertvalue %11, %16[2] : !llvm.struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)> + %18 = llvm.mlir.undef : !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + %19 = llvm.insertvalue %17, %18[0] : !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + %20 = llvm.insertvalue %10, %19[1] : !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + %21 = llvm.mlir.addressof @a : !llvm.ptr + %22 = llvm.mlir.constant(0 : i32) : i32 + %23 = llvm.mlir.constant(1 : i64) : i64 + %24 = llvm.mlir.constant(1 : i32) : i32 + %25 = llvm.mlir.constant(2 : i32) : i32 + %26 = llvm.mlir.constant(3 : i32) : i32 + %27 = llvm.mlir.constant(2 : i64) : i64 + %28 = llvm.mlir.constant(4 : i32) : i32 + %29 = llvm.mlir.constant(5 : i32) : i32 + %30 = llvm.mlir.constant(6 : i32) : i32 + %31 = llvm.mlir.constant(7 : i32) : i32 + %32 = llvm.mlir.constant(8 : i32) : i32 + %33 = llvm.call @snprintf(%0, %1, %3, %21) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + llvm.store %33, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %34 = llvm.getelementptr %21[%1, %1, 0, %23] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + %35 = llvm.call @snprintf(%0, %1, %3, %34) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + %36 = llvm.getelementptr %arg0[%24] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %35, %36 {alignment = 4 : i64} : i32, !llvm.ptr + %37 = llvm.getelementptr %21[%1, %1, 1, %1] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + %38 = llvm.call @snprintf(%0, %1, %3, %37) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + %39 = llvm.getelementptr %arg0[%25] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %38, %39 {alignment = 4 : i64} : i32, !llvm.ptr + %40 = llvm.getelementptr %21[%1, %1, 1, %23] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + %41 = llvm.call @snprintf(%0, %1, %3, %40) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + %42 = llvm.getelementptr %arg0[%26] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %41, %42 {alignment = 4 : i64} : i32, !llvm.ptr + %43 = llvm.getelementptr %21[%1, %1, 1, %27] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + %44 = llvm.call @snprintf(%0, %1, %3, %43) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + %45 = llvm.getelementptr %arg0[%28] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %44, %45 {alignment = 4 : i64} : i32, !llvm.ptr + %46 = llvm.getelementptr %21[%1, %1, 2, %1] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + %47 = llvm.call @snprintf(%0, %1, %3, %46) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + %48 = llvm.getelementptr %arg0[%29] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %47, %48 {alignment = 4 : i64} : i32, !llvm.ptr + %49 = llvm.getelementptr %21[%1, %23, 0, %1] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + %50 = llvm.call @snprintf(%0, %1, %3, %49) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + %51 = llvm.getelementptr %arg0[%30] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %50, %51 {alignment = 4 : i64} : i32, !llvm.ptr + %52 = llvm.getelementptr %21[%1, %23, 1, %1] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + %53 = llvm.call @snprintf(%0, %1, %3, %52) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + %54 = llvm.getelementptr %arg0[%31] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %53, %54 {alignment = 4 : i64} : i32, !llvm.ptr + %55 = llvm.getelementptr %21[%1, %23, 2, %1] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<5 x i8>, array<6 x i8>, array<7 x i8>)>> + %56 = llvm.call @snprintf(%0, %1, %3, %55) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + %57 = llvm.getelementptr %arg0[%32] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %56, %57 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/sprintf-3.ll.mlir b/test/LLVMDialect/InstCombine/sprintf-3.ll.mlir index 4e66b8e64..17a0c445d 100644 --- a/test/LLVMDialect/InstCombine/sprintf-3.ll.mlir +++ b/test/LLVMDialect/InstCombine/sprintf-3.ll.mlir @@ -1,14 +1,10 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "percent_s", type = !llvm.array<3 x i8>, value = "%s\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sprintf", type = !llvm.func>, ptr, ...)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @percent_s} : () -> !llvm.ptr> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.call"(%arg0, %1, %arg1) {callee = @sprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>, !llvm.ptr, !llvm.ptr) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "PR51200", type = !llvm.func>, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @percent_s("%s\00") {addr_space = 0 : i32} + llvm.func @sprintf(!llvm.ptr, !llvm.ptr, ...) -> i32 + llvm.func @PR51200(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @percent_s : !llvm.ptr + %2 = llvm.call @sprintf(%arg0, %1, %arg1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sprintf-void.ll.mlir b/test/LLVMDialect/InstCombine/sprintf-void.ll.mlir index 08c16549c..236ac94f4 100644 --- a/test/LLVMDialect/InstCombine/sprintf-void.ll.mlir +++ b/test/LLVMDialect/InstCombine/sprintf-void.ll.mlir @@ -1,15 +1,10 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello_world", type = !llvm.array<13 x i8>, value = "hello world\0A\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sprintf", type = !llvm.func, ptr, ...)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @hello_world} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - "llvm.call"(%arg0, %2) {callee = @sprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_simplify1", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello_world("hello world\0A\00") {addr_space = 0 : i32} + llvm.func @sprintf(!llvm.ptr, !llvm.ptr, ...) + llvm.func @test_simplify1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("hello world\0A\00") : !llvm.array<13 x i8> + %1 = llvm.mlir.addressof @hello_world : !llvm.ptr + llvm.call @sprintf(%arg0, %1) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/sqrt-nofast.ll.mlir b/test/LLVMDialect/InstCombine/sqrt-nofast.ll.mlir index f917b2b5e..aa003f48f 100644 --- a/test/LLVMDialect/InstCombine/sqrt-nofast.ll.mlir +++ b/test/LLVMDialect/InstCombine/sqrt-nofast.ll.mlir @@ -1,26 +1,20 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - "llvm.store"(%arg0, %1) : (f32, !llvm.ptr) -> () - "llvm.store"(%arg1, %2) : (f32, !llvm.ptr) -> () - %3 = "llvm.load"(%1) : (!llvm.ptr) -> f32 - %4 = "llvm.load"(%1) : (!llvm.ptr) -> f32 - %5 = "llvm.fmul"(%3, %4) : (f32, f32) -> f32 - %6 = "llvm.call"(%5) {callee = @llvm.sqrt.f32, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%6) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "mysqrt", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.sqrt.f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64, %arg1: f64): // no predecessors - %0 = "llvm.fmul"(%arg0, %arg0) : (f64, f64) -> f64 - %1 = "llvm.call"(%0) {callee = @sqrtf, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "fake_sqrt", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sqrtf", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @mysqrt(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %2 = llvm.alloca %0 x f32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %1 {alignment = 4 : i64} : f32, !llvm.ptr + llvm.store %arg1, %2 {alignment = 4 : i64} : f32, !llvm.ptr + %3 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> f32 + %4 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> f32 + %5 = llvm.fmul %3, %4 {fastmathFlags = #llvm.fastmath} : f32 + %6 = llvm.intr.sqrt(%5) : (f32) -> f32 + llvm.return %6 : f32 + } + llvm.func @fake_sqrt(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.fmul %arg0, %arg0 {fastmathFlags = #llvm.fastmath} : f64 + %1 = llvm.call @sqrtf(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sqrtf(f64) -> f64 attributes {memory = #llvm.memory_effects} +} diff --git a/test/LLVMDialect/InstCombine/sqrt.ll.mlir b/test/LLVMDialect/InstCombine/sqrt.ll.mlir new file mode 100644 index 000000000..f2cb993b0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sqrt.ll.mlir @@ -0,0 +1,103 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind", "ssp"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @sqrt(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test2(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind", "ssp"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @sqrt(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @test3(%arg0: !llvm.ptr) -> f32 attributes {passthrough = ["nounwind", "ssp", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.undef : f32 + %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> f32 + %4 = llvm.fmul %3, %3 : f32 + %5 = llvm.fadd %1, %4 : f32 + %6 = llvm.fpext %5 : f32 to f64 + %7 = llvm.call @sqrt(%6) : (f64) -> f64 + %8 = llvm.call @foo(%7) : (f64) -> i32 + %9 = llvm.fptrunc %7 : f64 to f32 + llvm.return %9 : f32 + } + llvm.func @<>(%arg0: f32) { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @sqrt(%0) : (f64) -> f64 + llvm.return + } + llvm.func @sqrt_call_nnan_f32(%arg0: f32) -> f32 { + %0 = llvm.call @sqrtf(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %0 : f32 + } + llvm.func @sqrt_call_nnan_f64(%arg0: f64) -> f64 { + %0 = llvm.call @sqrt(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %0 : f64 + } + llvm.func @sqrt_call_fabs_f32(%arg0: f32) -> f32 { + %0 = llvm.intr.fabs(%arg0) : (f32) -> f32 + %1 = llvm.call @sqrtf(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @sqrt_exp(%arg0: f64) -> f64 { + %0 = llvm.intr.exp(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sqrt_exp_2(%arg0: f64) -> f64 { + %0 = llvm.call @exp(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.call @sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sqrt_exp2(%arg0: f64) -> f64 { + %0 = llvm.call @exp2(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.call @sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sqrt_exp10(%arg0: f64) -> f64 { + %0 = llvm.call @exp10(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.call @sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sqrt_exp_nofast_1(%arg0: f64) -> f64 { + %0 = llvm.intr.exp(%arg0) : (f64) -> f64 + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sqrt_exp_nofast_2(%arg0: f64) -> f64 { + %0 = llvm.intr.exp(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.intr.sqrt(%0) : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sqrt_exp_merge_constant(%arg0: f64, %arg1: f64) -> f64 { + %0 = llvm.mlir.constant(1.000000e+01 : f64) : f64 + %1 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : f64 + %2 = llvm.intr.exp(%1) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %3 = llvm.intr.sqrt(%2) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %3 : f64 + } + llvm.func @sqrt_exp_intr_and_libcall(%arg0: f64) -> f64 { + %0 = llvm.call @exp(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sqrt_exp_intr_and_libcall_2(%arg0: f64) -> f64 { + %0 = llvm.intr.exp(%arg0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + %1 = llvm.call @sqrt(%0) {fastmathFlags = #llvm.fastmath} : (f64) -> f64 + llvm.return %1 : f64 + } + llvm.func @sqrt_exp_vec(%arg0: vector<2xf32>) -> vector<2xf32> { + %0 = llvm.intr.exp(%arg0) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> vector<2xf32> + %1 = llvm.intr.sqrt(%0) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> vector<2xf32> + llvm.return %1 : vector<2xf32> + } + llvm.func @foo(f64) -> i32 + llvm.func @sqrt(f64) -> f64 attributes {memory = #llvm.memory_effects} + llvm.func @sqrtf(f32) -> f32 + llvm.func @exp(f64) -> f64 + llvm.func @exp2(f64) -> f64 + llvm.func @exp10(f64) -> f64 +} diff --git a/test/LLVMDialect/InstCombine/srem-canonicalize.ll.mlir b/test/LLVMDialect/InstCombine/srem-canonicalize.ll.mlir new file mode 100644 index 000000000..415340755 --- /dev/null +++ b/test/LLVMDialect/InstCombine/srem-canonicalize.ll.mlir @@ -0,0 +1,36 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_srem_canonicalize_op0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 overflow : i32 + %2 = llvm.srem %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_srem_canonicalize_op1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mul %arg1, %0 : i32 + %3 = llvm.sub %1, %arg0 overflow : i32 + %4 = llvm.srem %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test_srem_canonicalize_nonsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 : i32 + %2 = llvm.srem %1, %arg1 : i32 + llvm.return %2 : i32 + } + llvm.func @test_srem_canonicalize_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %1, %arg0 overflow : vector<2xi32> + %3 = llvm.srem %2, %arg1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @test_srem_canonicalize_multiple_uses(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sub %0, %arg0 overflow : i32 + %2 = llvm.srem %1, %arg1 : i32 + %3 = llvm.srem %2, %1 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/srem-simplify-bug.ll.mlir b/test/LLVMDialect/InstCombine/srem-simplify-bug.ll.mlir index c99c95db9..c9768cdea 100644 --- a/test/LLVMDialect/InstCombine/srem-simplify-bug.ll.mlir +++ b/test/LLVMDialect/InstCombine/srem-simplify-bug.ll.mlir @@ -1,12 +1,10 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.srem"(%2, %1) : (i32, i32) -> i32 - %4 = "llvm.icmp"(%3, %0) {predicate = 1 : i64} : (i32, i32) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.srem %2, %0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/srem-via-sdiv-mul-sub.ll.mlir b/test/LLVMDialect/InstCombine/srem-via-sdiv-mul-sub.ll.mlir index 6a710b62b..4e2f00871 100644 --- a/test/LLVMDialect/InstCombine/srem-via-sdiv-mul-sub.ll.mlir +++ b/test/LLVMDialect/InstCombine/srem-via-sdiv-mul-sub.ll.mlir @@ -1,59 +1,49 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use2xi8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sdiv"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.mul"(%0, %arg1) : (i8, i8) -> i8 - %2 = "llvm.sub"(%arg0, %1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t0_basic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.sdiv"(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.call"(%0) {callee = @use2xi8, fastmathFlags = #llvm.fastmath<>} : (vector<2xi8>) -> () - %1 = "llvm.mul"(%0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %2 = "llvm.sub"(%arg0, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.return"(%2) : (vector<2xi8>) -> () - }) {linkage = 10 : i64, sym_name = "t1_vector", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sdiv"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.mul"(%0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.sub"(%arg0, %1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t4_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.sdiv"(%arg0, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.mul"(%0, %1) : (i8, i8) -> i8 - %3 = "llvm.sub"(%arg0, %2) : (i8, i8) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t5_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.sdiv"(%arg0, %arg2) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.mul"(%0, %arg2) : (i8, i8) -> i8 - %2 = "llvm.sub"(%arg1, %1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "n6_different_x", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.sdiv"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.mul"(%0, %arg2) : (i8, i8) -> i8 - %2 = "llvm.sub"(%arg0, %1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "n6_different_y", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use2xi8(vector<2xi8>) + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.sdiv %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.mul %0, %arg1 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @t1_vector(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.sdiv %arg0, %arg1 : vector<2xi8> + llvm.call @use2xi8(%0) : (vector<2xi8>) -> () + %1 = llvm.mul %0, %arg1 : vector<2xi8> + %2 = llvm.sub %arg0, %1 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @t4_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.sdiv %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.mul %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @gen8() -> i8 + llvm.func @t5_commutative(%arg0: i8) -> i8 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.sdiv %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.mul %0, %1 : i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @n6_different_x(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.sdiv %arg0, %arg2 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.mul %0, %arg2 : i8 + %2 = llvm.sub %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @n6_different_y(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.sdiv %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.mul %0, %arg2 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/srem1.ll.mlir b/test/LLVMDialect/InstCombine/srem1.ll.mlir index 02c83eccf..1b4840f87 100644 --- a/test/LLVMDialect/InstCombine/srem1.ll.mlir +++ b/test/LLVMDialect/InstCombine/srem1.ll.mlir @@ -1,23 +1,19 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "g_127", type = i32} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i16): // no predecessors - %0 = "llvm.mlir.undef"() : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @g_127} : () -> !llvm.ptr - %2 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = -1734012817166602727 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.call"(%arg2, %4) {callee = @rshift_s_s, fastmathFlags = #llvm.fastmath<>} : (i32, i32) -> i32 - %6 = "llvm.sext"(%5) : (i32) -> i64 - %7 = "llvm.or"(%3, %6) : (i64, i64) -> i64 - %8 = "llvm.srem"(%7, %2) : (i64, i64) -> i64 - %9 = "llvm.icmp"(%8, %2) {predicate = 0 : i64} : (i64, i64) -> i1 - %10 = "llvm.zext"(%9) : (i1) -> i32 - "llvm.store"(%10, %1) : (i32, !llvm.ptr) -> () - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "func_56", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "rshift_s_s", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g_127() {addr_space = 0 : i32} : i32 + llvm.func @func_56(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i16 {llvm.signext}) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1734012817166602727 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.addressof @g_127 : !llvm.ptr + %4 = llvm.mlir.undef : i32 + %5 = llvm.call @rshift_s_s(%arg2, %0) vararg(!llvm.func) : (i32, i32) -> i32 + %6 = llvm.sext %5 : i32 to i64 + %7 = llvm.or %1, %6 : i64 + %8 = llvm.srem %7, %2 : i64 + %9 = llvm.icmp "eq" %8, %2 : i64 + %10 = llvm.zext %9 : i1 to i32 + llvm.store %10, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %4 : i32 + } + llvm.func @rshift_s_s(...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/ssub-with-overflow.ll.mlir b/test/LLVMDialect/InstCombine/ssub-with-overflow.ll.mlir new file mode 100644 index 000000000..a8699f0ea --- /dev/null +++ b/test/LLVMDialect/InstCombine/ssub-with-overflow.ll.mlir @@ -0,0 +1,110 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @simple_fold(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(13 : i32) : i32 + %2 = llvm.sub %arg0, %0 overflow : i32 + %3 = "llvm.intr.ssub.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @fold_mixed_signs(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(13 : i32) : i32 + %1 = llvm.mlir.constant(-7 : i32) : i32 + %2 = llvm.sub %arg0, %0 overflow : i32 + %3 = "llvm.intr.ssub.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @fold_on_constant_sub_no_overflow(%arg0: i8) -> !llvm.struct<(i8, i1)> { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(28 : i8) : i8 + %2 = llvm.sub %arg0, %0 overflow : i8 + %3 = "llvm.intr.ssub.with.overflow"(%2, %1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.return %3 : !llvm.struct<(i8, i1)> + } + llvm.func @no_fold_on_constant_sub_overflow(%arg0: i8) -> !llvm.struct<(i8, i1)> { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(29 : i8) : i8 + %2 = llvm.sub %arg0, %0 overflow : i8 + %3 = "llvm.intr.ssub.with.overflow"(%2, %1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.return %3 : !llvm.struct<(i8, i1)> + } + llvm.func @fold_simple_splat_constant(%arg0: vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> { + %0 = llvm.mlir.constant(dense<12> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<30> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %arg0, %0 overflow : vector<2xi32> + %3 = "llvm.intr.ssub.with.overflow"(%2, %1) : (vector<2xi32>, vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> + llvm.return %3 : !llvm.struct<(vector<2xi32>, vector<2xi1>)> + } + llvm.func @no_fold_splat_undef_constant(%arg0: vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<30> : vector<2xi32>) : vector<2xi32> + %8 = llvm.sub %arg0, %6 overflow : vector<2xi32> + %9 = "llvm.intr.ssub.with.overflow"(%8, %7) : (vector<2xi32>, vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> + llvm.return %9 : !llvm.struct<(vector<2xi32>, vector<2xi1>)> + } + llvm.func @no_fold_splat_not_constant(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> { + %0 = llvm.mlir.constant(dense<30> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sub %arg0, %arg1 overflow : vector<2xi32> + %2 = "llvm.intr.ssub.with.overflow"(%1, %0) : (vector<2xi32>, vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> + llvm.return %2 : !llvm.struct<(vector<2xi32>, vector<2xi1>)> + } + llvm.func @fold_nuwnsw(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.sub %arg0, %0 overflow : i32 + %3 = "llvm.intr.ssub.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @no_fold_nuw(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.sub %arg0, %0 overflow : i32 + %3 = "llvm.intr.ssub.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @no_fold_wrapped_sub(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.sub %arg0, %0 : i32 + %3 = "llvm.intr.ssub.with.overflow"(%1, %2) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @fold_add_simple(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(-12 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = "llvm.intr.ssub.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @keep_ssubo_undef(%arg0: vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = "llvm.intr.ssub.with.overflow"(%arg0, %6) : (vector<2xi32>, vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> + llvm.return %7 : !llvm.struct<(vector<2xi32>, vector<2xi1>)> + } + llvm.func @keep_ssubo_non_splat(%arg0: vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> { + %0 = llvm.mlir.constant(dense<[30, 31]> : vector<2xi32>) : vector<2xi32> + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %0) : (vector<2xi32>, vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> + llvm.return %1 : !llvm.struct<(vector<2xi32>, vector<2xi1>)> + } + llvm.func @keep_ssubo_one_element_is_128(%arg0: vector<2xi8>) -> !llvm.struct<(vector<2xi8>, vector<2xi1>)> { + %0 = llvm.mlir.constant(dense<[0, -128]> : vector<2xi8>) : vector<2xi8> + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %0) : (vector<2xi8>, vector<2xi8>) -> !llvm.struct<(vector<2xi8>, vector<2xi1>)> + llvm.return %1 : !llvm.struct<(vector<2xi8>, vector<2xi1>)> + } + llvm.func @keep_ssubo_128(%arg0: i8) -> !llvm.struct<(i8, i1)> { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.return %1 : !llvm.struct<(i8, i1)> + } +} diff --git a/test/LLVMDialect/InstCombine/ssubo.ll.mlir b/test/LLVMDialect/InstCombine/ssubo.ll.mlir new file mode 100644 index 000000000..ce3d3003d --- /dev/null +++ b/test/LLVMDialect/InstCombine/ssubo.ll.mlir @@ -0,0 +1,92 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i1) + llvm.func @test_generic(%arg0: i64, %arg1: i64) -> i1 { + %0 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i64, i1)> + llvm.return %1 : i1 + } + llvm.func @test_constant0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant127(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant128(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant255(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @sub_eq0(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.call @use(%2) : (i1) -> () + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %4 = llvm.icmp "eq" %3, %0 : i8 + llvm.return %4 : i1 + } + llvm.func @sub_ne0(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.call @use(%2) : (i1) -> () + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %4 = llvm.icmp "ne" %3, %0 : i8 + llvm.return %4 : i1 + } + llvm.func @sub_eq1(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.call @use(%2) : (i1) -> () + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %4 = llvm.icmp "eq" %3, %0 : i8 + llvm.return %4 : i1 + } + llvm.func @sub_sgt0(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.call @use(%2) : (i1) -> () + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %4 = llvm.icmp "sgt" %3, %0 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/stack-overalign.ll.mlir b/test/LLVMDialect/InstCombine/stack-overalign.ll.mlir new file mode 100644 index 000000000..1a5e23e2a --- /dev/null +++ b/test/LLVMDialect/InstCombine/stack-overalign.ll.mlir @@ -0,0 +1,15 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @dst(dense<0> : tensor<1024xi8>) {addr_space = 0 : i32, alignment = 32 : i64} : !llvm.array<1024 x i8> + llvm.func @foo() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<1024xi8>) : !llvm.array<1024 x i8> + %3 = llvm.mlir.addressof @dst : !llvm.ptr + %4 = llvm.mlir.constant(1024 : i32) : i32 + %5 = llvm.alloca %0 x !llvm.array<1024 x i8> {alignment = 64 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%3, %5, %4) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () + llvm.call @frob(%5) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @frob(!llvm.ptr) +} diff --git a/test/LLVMDialect/InstCombine/stacksave-debuginfo.ll.mlir b/test/LLVMDialect/InstCombine/stacksave-debuginfo.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/stacksaverestore.ll.mlir b/test/LLVMDialect/InstCombine/stacksaverestore.ll.mlir new file mode 100644 index 000000000..c4f951989 --- /dev/null +++ b/test/LLVMDialect/InstCombine/stacksaverestore.ll.mlir @@ -0,0 +1,90 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @glob(0 : i32) {addr_space = 0 : i32} : i32 + llvm.func @test1(%arg0: i32) -> !llvm.ptr { + %0 = llvm.intr.stacksave : !llvm.ptr + llvm.intr.stackrestore %0 : !llvm.ptr + %1 = llvm.alloca %arg0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test2(%arg0: !llvm.ptr) { + llvm.intr.stackrestore %arg0 : !llvm.ptr + llvm.return + } + llvm.func @foo(%arg0: i32) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.cond_br %4, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %5 = llvm.add %arg0, %1 : i32 + %6 = llvm.icmp "slt" %arg0, %2 : i32 + %7 = llvm.select %6, %2, %arg0 : i1, i32 + llvm.br ^bb2(%0 : i32) + ^bb2(%8: i32): // 2 preds: ^bb1, ^bb2 + %9 = llvm.intr.stacksave : !llvm.ptr + %10 = llvm.alloca %arg0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %11 = llvm.getelementptr %10[%5] : (!llvm.ptr, i32) -> !llvm.ptr, i8 + llvm.store %3, %11 {alignment = 1 : i64} : i8, !llvm.ptr + %12 = llvm.intr.stacksave : !llvm.ptr + %13 = llvm.alloca %arg0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %14 = llvm.intr.stacksave : !llvm.ptr + %15 = llvm.alloca %arg0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + %16 = llvm.intr.stacksave : !llvm.ptr + %17 = llvm.alloca %arg0 x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.call @bar(%8, %10, %13, %15, %17, %arg0) : (i32, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> () + llvm.intr.stackrestore %16 : !llvm.ptr + llvm.intr.stackrestore %14 : !llvm.ptr + llvm.intr.stackrestore %12 : !llvm.ptr + llvm.intr.stackrestore %9 : !llvm.ptr + %18 = llvm.add %8, %2 : i32 + %19 = llvm.icmp "eq" %18, %7 : i32 + llvm.cond_br %19, ^bb3, ^bb2(%18 : i32) + ^bb3: // 2 preds: ^bb0, ^bb2 + llvm.return + } + llvm.func @bar(i32, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i32) + llvm.func @inalloca_callee(!llvm.ptr {llvm.inalloca = i32}) + llvm.func @test3(%arg0: i32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.addressof @glob : !llvm.ptr + llvm.br ^bb1(%0 : i32) + ^bb1(%3: i32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.intr.stacksave : !llvm.ptr + %5 = llvm.alloca inalloca %1 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %0, %5 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.call @inalloca_callee(%5) : (!llvm.ptr) -> () + llvm.intr.stackrestore %4 : !llvm.ptr + %6 = llvm.intr.stacksave : !llvm.ptr + llvm.store %0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.intr.stackrestore %6 : !llvm.ptr + %7 = llvm.add %1, %3 : i32 + %8 = llvm.icmp "eq" %7, %arg0 : i32 + llvm.cond_br %8, ^bb1(%7 : i32), ^bb2 + ^bb2: // pred: ^bb1 + llvm.return + } + llvm.func @test4(%arg0: i32, %arg1: !llvm.ptr, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(100 : i32) : i32 + llvm.br ^bb1(%0, %0 : i32, i32) + ^bb1(%3: i32, %4: i32): // 2 preds: ^bb0, ^bb1 + %5 = llvm.intr.stacksave : !llvm.ptr + %6 = llvm.load %arg1 {alignment = 4 : i64} : !llvm.ptr -> i32 + %7 = llvm.mul %6, %arg0 overflow : i32 + %8 = llvm.add %7, %3 overflow : i32 + llvm.intr.stackrestore %5 : !llvm.ptr + %9 = llvm.load %arg2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %10 = llvm.mul %9, %arg0 overflow : i32 + %11 = llvm.add %10, %8 overflow : i32 + llvm.intr.stackrestore %5 : !llvm.ptr + %12 = llvm.add %4, %1 overflow : i32 + %13 = llvm.icmp "eq" %12, %2 : i32 + llvm.cond_br %13, ^bb2, ^bb1(%11, %12 : i32, i32) + ^bb2: // pred: ^bb1 + llvm.return %11 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/statepoint-cleanup.ll.mlir b/test/LLVMDialect/InstCombine/statepoint-cleanup.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/statepoint-iter.ll.mlir b/test/LLVMDialect/InstCombine/statepoint-iter.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/statepoint.ll.mlir b/test/LLVMDialect/InstCombine/statepoint.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/stdio-custom-dl.ll.mlir b/test/LLVMDialect/InstCombine/stdio-custom-dl.ll.mlir new file mode 100644 index 000000000..24fb8d1f4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/stdio-custom-dl.ll.mlir @@ -0,0 +1,18 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private unnamed_addr constant @".str"("file\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.1"("w\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.2"("str\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.func internal @fputs_test_custom_dl() attributes {dso_local} { + %0 = llvm.mlir.constant("file\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.constant("w\00") : !llvm.array<2 x i8> + %3 = llvm.mlir.addressof @".str.1" : !llvm.ptr + %4 = llvm.mlir.constant("str\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.addressof @".str.2" : !llvm.ptr + %6 = llvm.call @fopen(%1, %3) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + %7 = llvm.call @fputs(%5, %6) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @fopen(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @fputs(!llvm.ptr {llvm.nocapture, llvm.readonly}, !llvm.ptr {llvm.nocapture}) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/stdiocall-bad-sig.ll.mlir b/test/LLVMDialect/InstCombine/stdiocall-bad-sig.ll.mlir new file mode 100644 index 000000000..a4d895f72 --- /dev/null +++ b/test/LLVMDialect/InstCombine/stdiocall-bad-sig.ll.mlir @@ -0,0 +1,37 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @ca1("1") {addr_space = 0 : i32} + llvm.mlir.global external constant @pcnt_s("%s\00") {addr_space = 0 : i32} + llvm.func @fwrite(!llvm.ptr, i64, i64, !llvm.ptr) -> i32 + llvm.func @fputc(!llvm.ptr, !llvm.ptr) -> i8 + llvm.func @printf(!llvm.ptr) + llvm.func @fprintf(!llvm.ptr, !llvm.ptr) -> i8 + llvm.func @sprintf(!llvm.ptr, !llvm.ptr) -> i8 + llvm.func @call_fwrite(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("1") : !llvm.array<1 x i8> + %1 = llvm.mlir.addressof @ca1 : !llvm.ptr + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.call @fwrite(%1, %2, %2, %arg0) : (!llvm.ptr, i64, i64, !llvm.ptr) -> i32 + llvm.return + } + llvm.func @call_printf(%arg0: !llvm.ptr) { + %0 = llvm.mlir.addressof @printf : !llvm.ptr + %1 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @pcnt_s : !llvm.ptr + %3 = llvm.call %0(%2) : !llvm.ptr, (!llvm.ptr) -> i32 + llvm.return + } + llvm.func @call_fprintf(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.addressof @fprintf : !llvm.ptr + %1 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @pcnt_s : !llvm.ptr + %3 = llvm.call %0(%arg0, %2, %arg1) vararg(!llvm.func) : !llvm.ptr, (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i8 + llvm.return %3 : i8 + } + llvm.func @call_sprintf(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.addressof @sprintf : !llvm.ptr + %1 = llvm.mlir.constant("%s\00") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @pcnt_s : !llvm.ptr + %3 = llvm.call %0(%arg0, %2, %arg1) vararg(!llvm.func) : !llvm.ptr, (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i8 + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/store-load-unaliased-gep.ll.mlir b/test/LLVMDialect/InstCombine/store-load-unaliased-gep.ll.mlir index b89edb1dc..8c72968bd 100644 --- a/test/LLVMDialect/InstCombine/store-load-unaliased-gep.ll.mlir +++ b/test/LLVMDialect/InstCombine/store-load-unaliased-gep.ll.mlir @@ -1,16 +1,13 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - %4 = "llvm.getelementptr"(%3, %1) : (!llvm.ptr, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%3, %0) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%arg0, %4) : (i32, !llvm.ptr) -> () - "llvm.store"(%1, %5) : (i32, !llvm.ptr) -> () - %6 = "llvm.load"(%4) : (!llvm.ptr) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %4 = llvm.getelementptr inbounds %3[%1] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %arg0, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %2, %4 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/store.ll.mlir b/test/LLVMDialect/InstCombine/store.ll.mlir index 4227ddc05..c1596490b 100644 --- a/test/LLVMDialect/InstCombine/store.ll.mlir +++ b/test/LLVMDialect/InstCombine/store.ll.mlir @@ -1,213 +1,198 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "Unknown", type = i32} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.undef"() : () -> i32 - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "store_of_undef", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.undef"() : () -> i32 - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "store_of_poison", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.undef"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 123 : i32} : () -> i32 - "llvm.store"(%1, %0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "store_into_undef", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 124 : i32} : () -> i32 - "llvm.store"(%1, %0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "store_into_null", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %2 = "llvm.add"(%1, %0) : (i32, i32) -> i32 - "llvm.store"(%2, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 24 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr - %2 = "llvm.getelementptr"(%1, %arg0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%0, %2) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "store_at_gep_off_null_inbounds", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 24 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr - %2 = "llvm.getelementptr"(%1, %arg0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%0, %2) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "store_at_gep_off_null_not_inbounds", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 24 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr - %2 = "llvm.getelementptr"(%1, %arg0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%0, %2) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "store_at_gep_off_no_null_opt", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 47 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -987654321 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - "llvm.cond_br"(%arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +#tbaa_root = #llvm.tbaa_root +#tbaa_type_desc = #llvm.tbaa_type_desc}> +#tbaa_type_desc1 = #llvm.tbaa_type_desc}> +#tbaa_type_desc2 = #llvm.tbaa_type_desc}> +#tbaa_tag = #llvm.tbaa_tag +#tbaa_tag1 = #llvm.tbaa_tag +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @Unknown() {addr_space = 0 : i32} : i32 + llvm.func @store_of_undef(%arg0: !llvm.ptr) { + %0 = llvm.mlir.undef : i32 + llvm.store %0, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @store_of_poison(%arg0: !llvm.ptr) { + %0 = llvm.mlir.poison : i32 + llvm.store %0, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @store_into_undef(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.ptr + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @store_into_null(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(124 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test2(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %2 = llvm.add %1, %0 : i32 + llvm.store %2, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @store_at_gep_off_null_inbounds(%arg0: i64) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.getelementptr inbounds %0[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @store_at_gep_off_null_not_inbounds(%arg0: i64) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.getelementptr %0[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @store_at_gep_off_no_null_opt(%arg0: i64) attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.getelementptr inbounds %0[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test3(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(47 : i32) : i32 + %2 = llvm.mlir.constant(-987654321 : i32) : i32 + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.store"(%1, %3) : (i32, !llvm.ptr) -> () - "llvm.br"()[^bb3] : () -> () + llvm.store %2, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 ^bb2: // pred: ^bb0 - "llvm.store"(%0, %3) : (i32, !llvm.ptr) -> () - "llvm.br"()[^bb3] : () -> () + llvm.store %1, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 ^bb3: // 2 preds: ^bb1, ^bb2 - %4 = "llvm.load"(%3) : (!llvm.ptr) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = -987654321 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 47 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr - "llvm.store"(%1, %3) : (i32, !llvm.ptr) -> () - "llvm.cond_br"(%arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %4 : i32 + } + llvm.func @test4(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(47 : i32) : i32 + %2 = llvm.mlir.constant(-987654321 : i32) : i32 + %3 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.store"(%0, %3) : (i32, !llvm.ptr) -> () - "llvm.br"()[^bb2] : () -> () + llvm.store %2, %3 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb2 ^bb2: // 2 preds: ^bb0, ^bb1 - %4 = "llvm.load"(%3) : (!llvm.ptr) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = -987654321 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 47 : i32} : () -> i32 - "llvm.store"(%1, %arg1) : (i32, !llvm.ptr) -> () - "llvm.cond_br"(%arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %4 : i32 + } + llvm.func @test5(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(47 : i32) : i32 + %1 = llvm.mlir.constant(-987654321 : i32) : i32 + llvm.store %0, %arg1 {alignment = 1 : i64} : i32, !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.store"(%0, %arg1) : (i32, !llvm.ptr) -> () - "llvm.br"()[^bb2] : () -> () + llvm.store %1, %arg1 {alignment = 1 : i64} : i32, !llvm.ptr + llvm.br ^bb2 ^bb2: // 2 preds: ^bb0, ^bb1 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr, %arg2: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0.000000e+00 : f32} : () -> f32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - "llvm.store"(%3, %arg2) : (i32, !llvm.ptr) -> () - "llvm.br"(%2)[^bb1] : (i32) -> () + llvm.return + } + llvm.func @test6(%arg0: i32, %arg1: !llvm.ptr, %arg2: !llvm.ptr) attributes {passthrough = ["nounwind", "ssp", ["uwtable", "2"]]} { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(1 : i32) : i32 + llvm.store %0, %arg2 {alignment = 4 : i64, tbaa = [#tbaa_tag]} : i32, !llvm.ptr + llvm.br ^bb1(%1 : i32) ^bb1(%4: i32): // 2 preds: ^bb0, ^bb2 - %5 = "llvm.load"(%arg2) : (!llvm.ptr) -> i32 - %6 = "llvm.icmp"(%5, %arg0) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.cond_br"(%6)[^bb2, ^bb3] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () + %5 = llvm.load %arg2 {alignment = 4 : i64, tbaa = [#tbaa_tag]} : !llvm.ptr -> i32 + %6 = llvm.icmp "slt" %5, %arg0 : i32 + llvm.cond_br %6, ^bb2, ^bb3 ^bb2: // pred: ^bb1 - %7 = "llvm.sext"(%5) : (i32) -> i64 - %8 = "llvm.getelementptr"(%arg1, %7) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%1, %8) : (f32, !llvm.ptr) -> () - %9 = "llvm.load"(%arg2) : (!llvm.ptr) -> i32 - %10 = "llvm.add"(%9, %0) : (i32, i32) -> i32 - "llvm.store"(%10, %arg2) : (i32, !llvm.ptr) -> () - "llvm.br"(%10)[^bb1] : (i32) -> () + %7 = llvm.sext %5 : i32 to i64 + %8 = llvm.getelementptr inbounds %arg1[%7] : (!llvm.ptr, i64) -> !llvm.ptr, f32 + llvm.store %2, %8 {alignment = 4 : i64, tbaa = [#tbaa_tag1]} : f32, !llvm.ptr + %9 = llvm.load %arg2 {alignment = 4 : i64, tbaa = [#tbaa_tag]} : !llvm.ptr -> i32 + %10 = llvm.add %9, %3 overflow : i32 + llvm.store %10, %arg2 {alignment = 4 : i64, tbaa = [#tbaa_tag]} : i32, !llvm.ptr + llvm.br ^bb1(%10 : i32) ^bb3: // pred: ^bb1 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "dse1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "dse2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "dse3", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "dse4", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "dse5", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "write_back1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "write_back2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "write_back3", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "write_back4", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "write_back5", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "write_back6", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - "llvm.store"(%0, %arg0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "write_back7", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @Unknown} : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - "llvm.store"(%1, %0) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "store_to_constant", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return + } + llvm.func @dse1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.store %0, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @dse2(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.store %0, %arg0 atomic unordered {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @dse3(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.store %0, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %arg0 atomic unordered {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @dse4(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.store %0, %arg0 atomic unordered {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %arg0 atomic unordered {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @dse5(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.store %0, %arg0 atomic unordered {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %0, %arg0 atomic seq_cst {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @write_back1(%arg0: !llvm.ptr) { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %0, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @write_back2(%arg0: !llvm.ptr) { + %0 = llvm.load %arg0 atomic unordered {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %0, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @write_back3(%arg0: !llvm.ptr) { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %0, %arg0 atomic unordered {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @write_back4(%arg0: !llvm.ptr) { + %0 = llvm.load %arg0 atomic unordered {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %0, %arg0 atomic unordered {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @write_back5(%arg0: !llvm.ptr) { + %0 = llvm.load %arg0 atomic unordered {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %0, %arg0 atomic seq_cst {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @write_back6(%arg0: !llvm.ptr) { + %0 = llvm.load %arg0 atomic seq_cst {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %0, %arg0 atomic unordered {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @write_back7(%arg0: !llvm.ptr) { + %0 = llvm.load volatile %arg0 atomic seq_cst {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store %0, %arg0 atomic unordered {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @store_to_constant() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @Unknown : !llvm.ptr + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @store_to_readonly_noalias(%arg0: !llvm.ptr {llvm.noalias, llvm.readonly}) { + %0 = llvm.mlir.constant(3 : i32) : i32 + llvm.store %0, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/storemerge-dbg.ll.mlir b/test/LLVMDialect/InstCombine/storemerge-dbg.ll.mlir index 1567aee03..378c7a6f2 100644 --- a/test/LLVMDialect/InstCombine/storemerge-dbg.ll.mlir +++ b/test/LLVMDialect/InstCombine/storemerge-dbg.ll.mlir @@ -1,22 +1,19 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "escape", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - "llvm.cond_br"(%arg0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @escape(i32) -> i32 + llvm.func @foo(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - "llvm.store"(%1, %2) : (i32, !llvm.ptr) -> () - "llvm.br"()[^bb3] : () -> () + llvm.store %0, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 ^bb2: // pred: ^bb0 - "llvm.store"(%0, %2) : (i32, !llvm.ptr) -> () - "llvm.br"()[^bb3] : () -> () + llvm.store %1, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 ^bb3: // 2 preds: ^bb1, ^bb2 - %3 = "llvm.load"(%2) : (!llvm.ptr) -> i32 - %4 = "llvm.call"(%3) {callee = @escape, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + %3 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32 + %4 = llvm.call @escape(%3) : (i32) -> i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/stpcpy-1.ll.mlir b/test/LLVMDialect/InstCombine/stpcpy-1.ll.mlir new file mode 100644 index 000000000..87fddc36f --- /dev/null +++ b/test/LLVMDialect/InstCombine/stpcpy-1.ll.mlir @@ -0,0 +1,50 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global common @a(dense<0> : tensor<32xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i8> + llvm.mlir.global common @b(dense<0> : tensor<32xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i8> + llvm.mlir.global external constant @percent_s("%s\00") {addr_space = 0 : i32} + llvm.func @stpcpy(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @test_simplify1() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.call @stpcpy(%2, %4) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @test_simplify2() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.call @stpcpy(%2, %2) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @test_simplify3(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.call @stpcpy(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return + } + llvm.func @test_no_simplify1() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.call @stpcpy(%2, %3) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @test_no_simplify2(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.call @stpcpy(%arg0, %arg1) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test_no_incompatible_attr() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.call @stpcpy(%2, %4) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/stpcpy-2.ll.mlir b/test/LLVMDialect/InstCombine/stpcpy-2.ll.mlir new file mode 100644 index 000000000..dbc111159 --- /dev/null +++ b/test/LLVMDialect/InstCombine/stpcpy-2.ll.mlir @@ -0,0 +1,14 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global common @a(dense<0> : tensor<32xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i8> + llvm.func @stpcpy(!llvm.ptr, !llvm.ptr) -> i16 + llvm.func @test_no_simplify1() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.call @stpcpy(%2, %4) : (!llvm.ptr, !llvm.ptr) -> i16 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/stpcpy_chk-1.ll.mlir b/test/LLVMDialect/InstCombine/stpcpy_chk-1.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/stpcpy_chk-2.ll.mlir b/test/LLVMDialect/InstCombine/stpcpy_chk-2.ll.mlir new file mode 100644 index 000000000..aae15d834 --- /dev/null +++ b/test/LLVMDialect/InstCombine/stpcpy_chk-2.ll.mlir @@ -0,0 +1,15 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @a(dense<0> : tensor<60xi16>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<60 x i16> + llvm.mlir.global private constant @".str"("abcdefg\00") {addr_space = 0 : i32, dso_local} + llvm.func @test_no_simplify() { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi16>) : !llvm.array<60 x i16> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("abcdefg\00") : !llvm.array<8 x i8> + %4 = llvm.mlir.addressof @".str" : !llvm.ptr + %5 = llvm.mlir.constant(8 : i32) : i32 + %6 = llvm.call @__strcpy_chk(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i32) -> i16 + llvm.return + } + llvm.func @__strcpy_chk(!llvm.ptr, !llvm.ptr, i32) -> i16 +} diff --git a/test/LLVMDialect/InstCombine/stpncpy-1.ll.mlir b/test/LLVMDialect/InstCombine/stpncpy-1.ll.mlir index 576026ea2..c2d812027 100644 --- a/test/LLVMDialect/InstCombine/stpncpy-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/stpncpy-1.ll.mlir @@ -1,184 +1,162 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a4", type = !llvm.array<4 x i8>, value = "1234"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "s4", type = !llvm.array<5 x i8>, value = "1234\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = "str", type = !llvm.array<4 x i8>, value = "4\00\00\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = "str.1", type = !llvm.array<10 x i8>, value = "4\00\00\00\00\00\00\00\00\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = "str.2", type = !llvm.array<10 x i8>, value = "1234\00\00\00\00\00\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = "str.3", type = !llvm.array<4 x i8>, value = "4\00\00\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = "str.4", type = !llvm.array<10 x i8>, value = "4\00\00\00\00\00\00\00\00\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = "str.5", type = !llvm.array<10 x i8>, value = "1234\00\00\00\00\00\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "stpncpy", type = !llvm.func (ptr, ptr, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sink", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.call"(%arg0, %arg0, %1) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %2) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %3 = "llvm.call"(%arg0, %arg0, %0) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %3) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_stpncpy_overlap", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %2 = "llvm.call"(%arg0, %arg0, %1) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %2) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %3 = "llvm.call"(%arg0, %arg0, %0) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %3) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %4 = "llvm.call"(%arg0, %arg0, %arg1) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %4) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "call_stpncpy_overlap", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %6 = "llvm.mlir.addressof"() {global_name = @s4} : () -> !llvm.ptr> - %7 = "llvm.getelementptr"(%6, %5, %4) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %8 = "llvm.call"(%arg0, %7, %3) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %8) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %9 = "llvm.call"(%arg0, %7, %2) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %9) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %10 = "llvm.call"(%arg0, %7, %1) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %10) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %11 = "llvm.call"(%arg0, %7, %0) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %11) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %12 = "llvm.call"(%arg0, %7, %arg1) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %12) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_stpncpy_s0", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %7 = "llvm.mlir.addressof"() {global_name = @s4} : () -> !llvm.ptr> - %8 = "llvm.getelementptr"(%7, %6, %5) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %9 = "llvm.call"(%arg0, %8, %4) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %9) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %10 = "llvm.call"(%arg0, %8, %3) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %10) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %11 = "llvm.call"(%arg0, %8, %2) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %11) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %12 = "llvm.call"(%arg0, %8, %1) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %12) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %13 = "llvm.call"(%arg0, %8, %0) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %13) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_stpncpy_s1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %6 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %7 = "llvm.mlir.addressof"() {global_name = @s4} : () -> !llvm.ptr> - %8 = "llvm.getelementptr"(%7, %6, %6) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %9 = "llvm.call"(%arg0, %8, %5) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %9) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %10 = "llvm.call"(%arg0, %8, %4) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %10) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %11 = "llvm.call"(%arg0, %8, %3) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %11) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %12 = "llvm.call"(%arg0, %8, %2) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %12) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %13 = "llvm.call"(%arg0, %8, %1) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %13) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %14 = "llvm.call"(%arg0, %8, %0) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %14) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_stpncpy_s4", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @s4} : () -> !llvm.ptr> - %1 = "llvm.mlir.addressof"() {global_name = @s4} : () -> !llvm.ptr> - %2 = "llvm.mlir.addressof"() {global_name = @a4} : () -> !llvm.ptr> - %3 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %5 = "llvm.mlir.addressof"() {global_name = @a4} : () -> !llvm.ptr> - %6 = "llvm.getelementptr"(%5, %4, %3) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %7 = "llvm.call"(%arg0, %6, %arg1) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %7) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %8 = "llvm.getelementptr"(%2, %4, %4) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %9 = "llvm.call"(%arg0, %8, %arg1) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %9) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %10 = "llvm.getelementptr"(%1, %4, %3) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %11 = "llvm.call"(%arg0, %10, %arg1) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %11) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %12 = "llvm.getelementptr"(%0, %4, %4) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %13 = "llvm.call"(%arg0, %12, %arg1) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %13) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "call_stpncpy_xx_n", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %6 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %7 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %8 = "llvm.mlir.addressof"() {global_name = @a4} : () -> !llvm.ptr> - %9 = "llvm.getelementptr"(%8, %7, %7) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %10 = "llvm.call"(%arg0, %9, %6) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %10) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %11 = "llvm.call"(%arg0, %9, %5) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %11) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %12 = "llvm.call"(%arg0, %9, %4) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %12) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %13 = "llvm.call"(%arg0, %9, %3) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %13) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %14 = "llvm.call"(%arg0, %9, %2) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %14) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %15 = "llvm.call"(%arg0, %9, %1) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %15) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %16 = "llvm.call"(%arg0, %9, %0) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %16) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_stpncpy_a4", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.call"(%arg0, %arg1, %1) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %2) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %3 = "llvm.call"(%arg0, %arg1, %0) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %3) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_stpncpy_s", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %1) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %2 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %2) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "call_stpncpy_s", type = !llvm.func, ptr, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a4("1234") {addr_space = 0 : i32} + llvm.mlir.global external constant @s4("1234\00") {addr_space = 0 : i32} + llvm.mlir.global private constant @str("4\00\00\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global private constant @str.1("4\00\00\00\00\00\00\00\00\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global private constant @str.2("1234\00\00\00\00\00\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global private unnamed_addr constant @str.3("4\00\00\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @str.4("4\00\00\00\00\00\00\00\00\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @str.5("1234\00\00\00\00\00\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.func @stpncpy(!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.func @sink(!llvm.ptr, !llvm.ptr) + llvm.func @fold_stpncpy_overlap(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.call @stpncpy(%arg0, %arg0, %0) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> () + %3 = llvm.call @stpncpy(%arg0, %arg0, %1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %3) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @call_stpncpy_overlap(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.call @stpncpy(%arg0, %arg0, %0) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> () + %3 = llvm.call @stpncpy(%arg0, %arg0, %1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %3) : (!llvm.ptr, !llvm.ptr) -> () + %4 = llvm.call @stpncpy(%arg0, %arg0, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %4) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @fold_stpncpy_s0(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @s4 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.mlir.constant(1 : i64) : i64 + %6 = llvm.mlir.constant(2 : i64) : i64 + %7 = llvm.mlir.constant(9 : i64) : i64 + %8 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %9 = llvm.call @stpncpy(%arg0, %8, %4) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %9) : (!llvm.ptr, !llvm.ptr) -> () + %10 = llvm.call @stpncpy(%arg0, %8, %5) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %10) : (!llvm.ptr, !llvm.ptr) -> () + %11 = llvm.call @stpncpy(%arg0, %8, %6) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %11) : (!llvm.ptr, !llvm.ptr) -> () + %12 = llvm.call @stpncpy(%arg0, %8, %7) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %12) : (!llvm.ptr, !llvm.ptr) -> () + %13 = llvm.call @stpncpy(%arg0, %8, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %13) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @fold_stpncpy_s1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @s4 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.mlir.constant(1 : i64) : i64 + %6 = llvm.mlir.constant(2 : i64) : i64 + %7 = llvm.mlir.constant(3 : i64) : i64 + %8 = llvm.mlir.constant(9 : i64) : i64 + %9 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %10 = llvm.call @stpncpy(%arg0, %9, %4) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %10) : (!llvm.ptr, !llvm.ptr) -> () + %11 = llvm.call @stpncpy(%arg0, %9, %5) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %11) : (!llvm.ptr, !llvm.ptr) -> () + %12 = llvm.call @stpncpy(%arg0, %9, %6) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %12) : (!llvm.ptr, !llvm.ptr) -> () + %13 = llvm.call @stpncpy(%arg0, %9, %7) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %13) : (!llvm.ptr, !llvm.ptr) -> () + %14 = llvm.call @stpncpy(%arg0, %9, %8) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %14) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @fold_stpncpy_s4(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @s4 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(2 : i64) : i64 + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.constant(4 : i64) : i64 + %7 = llvm.mlir.constant(9 : i64) : i64 + %8 = llvm.call @stpncpy(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %8) : (!llvm.ptr, !llvm.ptr) -> () + %9 = llvm.call @stpncpy(%arg0, %1, %3) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %9) : (!llvm.ptr, !llvm.ptr) -> () + %10 = llvm.call @stpncpy(%arg0, %1, %4) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %10) : (!llvm.ptr, !llvm.ptr) -> () + %11 = llvm.call @stpncpy(%arg0, %1, %5) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %11) : (!llvm.ptr, !llvm.ptr) -> () + %12 = llvm.call @stpncpy(%arg0, %1, %6) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %12) : (!llvm.ptr, !llvm.ptr) -> () + %13 = llvm.call @stpncpy(%arg0, %1, %7) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %13) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @call_stpncpy_xx_n(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("1234") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @a4 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %5 = llvm.mlir.addressof @s4 : !llvm.ptr + %6 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<4 x i8> + %7 = llvm.call @stpncpy(%arg0, %6, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %7) : (!llvm.ptr, !llvm.ptr) -> () + %8 = llvm.call @stpncpy(%arg0, %1, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %8) : (!llvm.ptr, !llvm.ptr) -> () + %9 = llvm.getelementptr %5[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %10 = llvm.call @stpncpy(%arg0, %9, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %10) : (!llvm.ptr, !llvm.ptr) -> () + %11 = llvm.call @stpncpy(%arg0, %5, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %11) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @fold_stpncpy_a4(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("1234") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @a4 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(2 : i64) : i64 + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.constant(4 : i64) : i64 + %7 = llvm.mlir.constant(5 : i64) : i64 + %8 = llvm.mlir.constant(9 : i64) : i64 + %9 = llvm.call @stpncpy(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %9) : (!llvm.ptr, !llvm.ptr) -> () + %10 = llvm.call @stpncpy(%arg0, %1, %3) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %10) : (!llvm.ptr, !llvm.ptr) -> () + %11 = llvm.call @stpncpy(%arg0, %1, %4) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %11) : (!llvm.ptr, !llvm.ptr) -> () + %12 = llvm.call @stpncpy(%arg0, %1, %5) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %12) : (!llvm.ptr, !llvm.ptr) -> () + %13 = llvm.call @stpncpy(%arg0, %1, %6) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %13) : (!llvm.ptr, !llvm.ptr) -> () + %14 = llvm.call @stpncpy(%arg0, %1, %7) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %14) : (!llvm.ptr, !llvm.ptr) -> () + %15 = llvm.call @stpncpy(%arg0, %1, %8) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %15) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @fold_stpncpy_s(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.call @stpncpy(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> () + %3 = llvm.call @stpncpy(%arg0, %arg1, %1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %3) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @call_stpncpy_s(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64) { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.call @stpncpy(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> () + %2 = llvm.call @stpncpy(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/str-int-2.ll.mlir b/test/LLVMDialect/InstCombine/str-int-2.ll.mlir index 666a7047c..0cf68ffe1 100644 --- a/test/LLVMDialect/InstCombine/str-int-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/str-int-2.ll.mlir @@ -1,142 +1,112 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str", type = !llvm.array<3 x i8>, value = "12\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str.1", type = !llvm.array<2 x i8>, value = "0\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str.2", type = !llvm.array<11 x i8>, value = "4294967296\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str.3", type = !llvm.array<24 x i8>, value = "10000000000000000000000\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str.4", type = !llvm.array<20 x i8>, value = "9923372036854775807\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str.5", type = !llvm.array<11 x i8>, value = "4994967295\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str.6", type = !llvm.array<10 x i8>, value = "499496729\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str.7", type = !llvm.array<11 x i8>, value = "4994967295\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtol", type = !llvm.func, ptr>, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atoi", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atol", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atoll", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtoll", type = !llvm.func, ptr>, i32)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "strtol_dec", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0, %1) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "strtol_base_zero", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "strtol_hex", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "strtol_endptr_not_null", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @".str.1"} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "strtol_endptr_maybe_null", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%2) {callee = @atoi, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "atoi_test", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.call"(%arg0, %1, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "strtol_not_const_str", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @atoi, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "atoi_not_const_str", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0, %arg0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "strtol_not_const_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @".str.2"} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "strtol_long_int", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @".str.3"} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "strtol_big_overflow", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @".str.6"} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%2) {callee = @atol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "atol_test", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @".str.5"} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%2) {callee = @atoll, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "atoll_test", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @".str.7"} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @strtoll, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "strtoll_test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private unnamed_addr constant @".str"("12\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.1"("0\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.2"("4294967296\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.3"("10000000000000000000000\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.4"("9923372036854775807\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.5"("4994967295\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.6"("499496729\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.7"("4994967295\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.func @strtol(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @atoi(!llvm.ptr) -> i32 + llvm.func @atol(!llvm.ptr) -> i64 + llvm.func @atoll(!llvm.ptr) -> i64 + llvm.func @strtoll(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @strtol_dec() -> i64 { + %0 = llvm.mlir.constant("12\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.call @strtol(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %4 : i64 + } + llvm.func @strtol_base_zero() -> i64 { + %0 = llvm.mlir.constant("12\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strtol(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %4 : i64 + } + llvm.func @strtol_hex() -> i64 { + %0 = llvm.mlir.constant("12\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(16 : i32) : i32 + %4 = llvm.call @strtol(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %4 : i64 + } + llvm.func @strtol_endptr_not_null(%arg0: !llvm.ptr {llvm.nonnull}) -> i64 { + %0 = llvm.mlir.constant("12\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.constant(10 : i32) : i32 + %3 = llvm.call @strtol(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %3 : i64 + } + llvm.func @strtol_endptr_maybe_null(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant("0\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @".str.1" : !llvm.ptr + %2 = llvm.mlir.constant(10 : i32) : i32 + %3 = llvm.call @strtol(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %3 : i64 + } + llvm.func @atoi_test() -> i32 { + %0 = llvm.mlir.constant("12\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.call @atoi(%1) : (!llvm.ptr) -> i32 + llvm.return %2 : i32 + } + llvm.func @strtol_not_const_str(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.call @strtol(%arg0, %0, %1) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %2 : i64 + } + llvm.func @atoi_not_const_str(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.call @atoi(%arg0) : (!llvm.ptr) -> i32 + llvm.return %0 : i32 + } + llvm.func @strtol_not_const_base(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant("12\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.call @strtol(%1, %2, %arg0) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %3 : i64 + } + llvm.func @strtol_long_int() -> i64 { + %0 = llvm.mlir.constant("4294967296\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @".str.2" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.call @strtol(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %4 : i64 + } + llvm.func @strtol_big_overflow() -> i64 { + %0 = llvm.mlir.constant("10000000000000000000000\00") : !llvm.array<24 x i8> + %1 = llvm.mlir.addressof @".str.3" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.call @strtol(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %4 : i64 + } + llvm.func @atol_test() -> i64 { + %0 = llvm.mlir.constant("499496729\00") : !llvm.array<10 x i8> + %1 = llvm.mlir.addressof @".str.6" : !llvm.ptr + %2 = llvm.call @atol(%1) : (!llvm.ptr) -> i64 + llvm.return %2 : i64 + } + llvm.func @atoll_test() -> i64 { + %0 = llvm.mlir.constant("4994967295\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @".str.5" : !llvm.ptr + %2 = llvm.call @atoll(%1) : (!llvm.ptr) -> i64 + llvm.return %2 : i64 + } + llvm.func @strtoll_test() -> i64 { + %0 = llvm.mlir.constant("4994967295\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @".str.7" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.call @strtoll(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %4 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/str-int-3.ll.mlir b/test/LLVMDialect/InstCombine/str-int-3.ll.mlir new file mode 100644 index 000000000..9febc1f57 --- /dev/null +++ b/test/LLVMDialect/InstCombine/str-int-3.ll.mlir @@ -0,0 +1,314 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a() {addr_space = 0 : i32} : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> { + %0 = llvm.mlir.constant("67890\00\00") : !llvm.array<7 x i8> + %1 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %2 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %7 = llvm.mlir.constant("56789\00\00") : !llvm.array<7 x i8> + %8 = llvm.mlir.constant("12\00\00\00") : !llvm.array<5 x i8> + %9 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %10 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %11 = llvm.insertvalue %9, %10[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %12 = llvm.insertvalue %8, %11[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %13 = llvm.insertvalue %7, %12[2] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %14 = llvm.mlir.undef : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %15 = llvm.insertvalue %13, %14[0] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %16 = llvm.insertvalue %6, %15[1] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + llvm.return %16 : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + } + llvm.func @atoi(!llvm.ptr) -> i32 + llvm.func @atol(!llvm.ptr) -> i64 + llvm.func @atoll(!llvm.ptr) -> i64 + llvm.func @strtol(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @strtoll(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @fold_atoi_member(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("67890\00\00") : !llvm.array<7 x i8> + %1 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %2 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %7 = llvm.mlir.constant("56789\00\00") : !llvm.array<7 x i8> + %8 = llvm.mlir.constant("12\00\00\00") : !llvm.array<5 x i8> + %9 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %10 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %11 = llvm.insertvalue %9, %10[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %12 = llvm.insertvalue %8, %11[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %13 = llvm.insertvalue %7, %12[2] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %14 = llvm.mlir.undef : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %15 = llvm.insertvalue %13, %14[0] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %16 = llvm.insertvalue %6, %15[1] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %17 = llvm.mlir.addressof @a : !llvm.ptr + %18 = llvm.mlir.constant(0 : i64) : i64 + %19 = llvm.mlir.constant(1 : i32) : i32 + %20 = llvm.mlir.constant(1 : i64) : i64 + %21 = llvm.mlir.constant(0 : i32) : i32 + %22 = llvm.mlir.constant(2 : i32) : i32 + %23 = llvm.mlir.constant(3 : i32) : i32 + %24 = llvm.call @atoi(%17) : (!llvm.ptr) -> i32 + llvm.store %24, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %25 = llvm.getelementptr %17[%18, %18, 1, %18] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %26 = llvm.call @atoi(%25) : (!llvm.ptr) -> i32 + %27 = llvm.getelementptr %arg0[%19] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %26, %27 {alignment = 4 : i64} : i32, !llvm.ptr + %28 = llvm.getelementptr %17[%18, %20, 0, %18] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %29 = llvm.call @atoi(%28) : (!llvm.ptr) -> i32 + %30 = llvm.getelementptr %arg0[%22] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %29, %30 {alignment = 4 : i64} : i32, !llvm.ptr + %31 = llvm.getelementptr %17[%18, %20, 1, %18] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %32 = llvm.call @atoi(%31) : (!llvm.ptr) -> i32 + %33 = llvm.getelementptr %arg0[%23] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %32, %33 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_atoi_offset_out_of_bounds(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant("67890\00\00") : !llvm.array<7 x i8> + %4 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %5 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %6 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %7 = llvm.insertvalue %5, %6[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %8 = llvm.insertvalue %4, %7[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %9 = llvm.insertvalue %3, %8[2] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %10 = llvm.mlir.constant("56789\00\00") : !llvm.array<7 x i8> + %11 = llvm.mlir.constant("12\00\00\00") : !llvm.array<5 x i8> + %12 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %13 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %14 = llvm.insertvalue %12, %13[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %15 = llvm.insertvalue %11, %14[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %16 = llvm.insertvalue %10, %15[2] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %17 = llvm.mlir.undef : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %18 = llvm.insertvalue %16, %17[0] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %19 = llvm.insertvalue %9, %18[1] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %20 = llvm.mlir.addressof @a : !llvm.ptr + %21 = llvm.getelementptr inbounds %20[%2, %0, 0, %0] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %22 = llvm.mlir.constant(33 : i64) : i64 + %23 = llvm.call @atoi(%21) : (!llvm.ptr) -> i32 + llvm.store %23, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %24 = llvm.getelementptr %20[%0, %0, 0, %22] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %25 = llvm.call @atoi(%24) : (!llvm.ptr) -> i32 + llvm.store %25, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_atol_member(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("67890\00\00") : !llvm.array<7 x i8> + %1 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %2 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %7 = llvm.mlir.constant("56789\00\00") : !llvm.array<7 x i8> + %8 = llvm.mlir.constant("12\00\00\00") : !llvm.array<5 x i8> + %9 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %10 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %11 = llvm.insertvalue %9, %10[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %12 = llvm.insertvalue %8, %11[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %13 = llvm.insertvalue %7, %12[2] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %14 = llvm.mlir.undef : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %15 = llvm.insertvalue %13, %14[0] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %16 = llvm.insertvalue %6, %15[1] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %17 = llvm.mlir.addressof @a : !llvm.ptr + %18 = llvm.mlir.constant(0 : i64) : i64 + %19 = llvm.mlir.constant(1 : i32) : i32 + %20 = llvm.mlir.constant(2 : i32) : i32 + %21 = llvm.mlir.constant(1 : i64) : i64 + %22 = llvm.mlir.constant(0 : i32) : i32 + %23 = llvm.mlir.constant(3 : i32) : i32 + %24 = llvm.mlir.constant(4 : i32) : i32 + %25 = llvm.mlir.constant(5 : i32) : i32 + %26 = llvm.call @atol(%17) : (!llvm.ptr) -> i64 + llvm.store %26, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %27 = llvm.getelementptr %17[%18, %18, 1, %18] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %28 = llvm.call @atol(%27) : (!llvm.ptr) -> i64 + %29 = llvm.getelementptr %arg0[%19] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %28, %29 {alignment = 4 : i64} : i64, !llvm.ptr + %30 = llvm.getelementptr %17[%18, %18, 2, %18] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %31 = llvm.call @atol(%30) : (!llvm.ptr) -> i64 + %32 = llvm.getelementptr %arg0[%20] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %31, %32 {alignment = 4 : i64} : i64, !llvm.ptr + %33 = llvm.getelementptr %17[%18, %21, 0, %18] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %34 = llvm.call @atol(%33) : (!llvm.ptr) -> i64 + %35 = llvm.getelementptr %arg0[%23] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %34, %35 {alignment = 4 : i64} : i64, !llvm.ptr + %36 = llvm.getelementptr %17[%18, %21, 1, %18] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %37 = llvm.call @atol(%36) : (!llvm.ptr) -> i64 + %38 = llvm.getelementptr %arg0[%24] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %37, %38 {alignment = 4 : i64} : i64, !llvm.ptr + %39 = llvm.getelementptr %17[%18, %21, 2, %18] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %40 = llvm.call @atol(%39) : (!llvm.ptr) -> i64 + %41 = llvm.getelementptr %arg0[%25] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %40, %41 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_atoll_member_pC(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("67890\00\00") : !llvm.array<7 x i8> + %1 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %2 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %7 = llvm.mlir.constant("56789\00\00") : !llvm.array<7 x i8> + %8 = llvm.mlir.constant("12\00\00\00") : !llvm.array<5 x i8> + %9 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %10 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %11 = llvm.insertvalue %9, %10[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %12 = llvm.insertvalue %8, %11[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %13 = llvm.insertvalue %7, %12[2] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %14 = llvm.mlir.undef : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %15 = llvm.insertvalue %13, %14[0] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %16 = llvm.insertvalue %6, %15[1] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %17 = llvm.mlir.addressof @a : !llvm.ptr + %18 = llvm.mlir.constant(0 : i64) : i64 + %19 = llvm.mlir.constant(1 : i32) : i32 + %20 = llvm.mlir.constant(1 : i64) : i64 + %21 = llvm.mlir.constant(2 : i32) : i32 + %22 = llvm.mlir.constant(3 : i64) : i64 + %23 = llvm.mlir.constant(0 : i32) : i32 + %24 = llvm.mlir.constant(2 : i64) : i64 + %25 = llvm.mlir.constant(3 : i32) : i32 + %26 = llvm.mlir.constant(4 : i32) : i32 + %27 = llvm.mlir.constant(4 : i64) : i64 + %28 = llvm.mlir.constant(5 : i32) : i32 + %29 = llvm.call @atol(%17) : (!llvm.ptr) -> i64 + llvm.store %29, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %30 = llvm.getelementptr %17[%18, %18, 1, %20] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %31 = llvm.call @atol(%30) : (!llvm.ptr) -> i64 + %32 = llvm.getelementptr %arg0[%19] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %31, %32 {alignment = 4 : i64} : i64, !llvm.ptr + %33 = llvm.getelementptr %17[%18, %18, 2, %22] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %34 = llvm.call @atol(%33) : (!llvm.ptr) -> i64 + %35 = llvm.getelementptr %arg0[%21] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %34, %35 {alignment = 4 : i64} : i64, !llvm.ptr + %36 = llvm.getelementptr %17[%18, %20, 0, %24] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %37 = llvm.call @atol(%36) : (!llvm.ptr) -> i64 + %38 = llvm.getelementptr %arg0[%25] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %37, %38 {alignment = 4 : i64} : i64, !llvm.ptr + %39 = llvm.getelementptr %17[%18, %20, 1, %22] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %40 = llvm.call @atol(%39) : (!llvm.ptr) -> i64 + %41 = llvm.getelementptr %arg0[%26] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %40, %41 {alignment = 4 : i64} : i64, !llvm.ptr + %42 = llvm.getelementptr %17[%18, %20, 2, %27] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %43 = llvm.call @atol(%42) : (!llvm.ptr) -> i64 + %44 = llvm.getelementptr %arg0[%28] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %43, %44 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_strtol_member_pC(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("67890\00\00") : !llvm.array<7 x i8> + %1 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %2 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %7 = llvm.mlir.constant("56789\00\00") : !llvm.array<7 x i8> + %8 = llvm.mlir.constant("12\00\00\00") : !llvm.array<5 x i8> + %9 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %10 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %11 = llvm.insertvalue %9, %10[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %12 = llvm.insertvalue %8, %11[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %13 = llvm.insertvalue %7, %12[2] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %14 = llvm.mlir.undef : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %15 = llvm.insertvalue %13, %14[0] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %16 = llvm.insertvalue %6, %15[1] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %17 = llvm.mlir.addressof @a : !llvm.ptr + %18 = llvm.mlir.zero : !llvm.ptr + %19 = llvm.mlir.constant(0 : i32) : i32 + %20 = llvm.mlir.constant(0 : i64) : i64 + %21 = llvm.mlir.constant(1 : i32) : i32 + %22 = llvm.mlir.constant(1 : i64) : i64 + %23 = llvm.mlir.constant(2 : i32) : i32 + %24 = llvm.mlir.constant(3 : i64) : i64 + %25 = llvm.mlir.constant(2 : i64) : i64 + %26 = llvm.mlir.constant(3 : i32) : i32 + %27 = llvm.mlir.constant(4 : i32) : i32 + %28 = llvm.mlir.constant(4 : i64) : i64 + %29 = llvm.mlir.constant(5 : i32) : i32 + %30 = llvm.call @strtol(%17, %18, %19) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.store %30, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %31 = llvm.getelementptr %17[%20, %20, 1, %22] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %32 = llvm.call @strtol(%31, %18, %19) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %33 = llvm.getelementptr %arg0[%21] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %32, %33 {alignment = 4 : i64} : i64, !llvm.ptr + %34 = llvm.getelementptr %17[%20, %20, 2, %24] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %35 = llvm.call @strtol(%34, %18, %19) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %36 = llvm.getelementptr %arg0[%23] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %35, %36 {alignment = 4 : i64} : i64, !llvm.ptr + %37 = llvm.getelementptr %17[%20, %22, 0, %25] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %38 = llvm.call @strtol(%37, %18, %19) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %39 = llvm.getelementptr %arg0[%26] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %38, %39 {alignment = 4 : i64} : i64, !llvm.ptr + %40 = llvm.getelementptr %17[%20, %22, 1, %24] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %41 = llvm.call @strtol(%40, %18, %19) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %42 = llvm.getelementptr %arg0[%27] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %41, %42 {alignment = 4 : i64} : i64, !llvm.ptr + %43 = llvm.getelementptr %17[%20, %22, 2, %28] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %44 = llvm.call @strtol(%43, %18, %19) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %45 = llvm.getelementptr %arg0[%29] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %44, %45 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_strtoll_member_pC(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("67890\00\00") : !llvm.array<7 x i8> + %1 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %2 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %7 = llvm.mlir.constant("56789\00\00") : !llvm.array<7 x i8> + %8 = llvm.mlir.constant("12\00\00\00") : !llvm.array<5 x i8> + %9 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %10 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %11 = llvm.insertvalue %9, %10[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %12 = llvm.insertvalue %8, %11[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %13 = llvm.insertvalue %7, %12[2] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)> + %14 = llvm.mlir.undef : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %15 = llvm.insertvalue %13, %14[0] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %16 = llvm.insertvalue %6, %15[1] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %17 = llvm.mlir.addressof @a : !llvm.ptr + %18 = llvm.mlir.zero : !llvm.ptr + %19 = llvm.mlir.constant(0 : i32) : i32 + %20 = llvm.mlir.constant(0 : i64) : i64 + %21 = llvm.mlir.constant(1 : i32) : i32 + %22 = llvm.mlir.constant(1 : i64) : i64 + %23 = llvm.mlir.constant(2 : i32) : i32 + %24 = llvm.mlir.constant(3 : i64) : i64 + %25 = llvm.mlir.constant(2 : i64) : i64 + %26 = llvm.mlir.constant(3 : i32) : i32 + %27 = llvm.mlir.constant(4 : i32) : i32 + %28 = llvm.mlir.constant(4 : i64) : i64 + %29 = llvm.mlir.constant(5 : i32) : i32 + %30 = llvm.call @strtoll(%17, %18, %19) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.store %30, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %31 = llvm.getelementptr %17[%20, %20, 1, %22] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %32 = llvm.call @strtoll(%31, %18, %19) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %33 = llvm.getelementptr %arg0[%21] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %32, %33 {alignment = 4 : i64} : i64, !llvm.ptr + %34 = llvm.getelementptr %17[%20, %20, 2, %24] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %35 = llvm.call @strtoll(%34, %18, %19) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %36 = llvm.getelementptr %arg0[%23] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %35, %36 {alignment = 4 : i64} : i64, !llvm.ptr + %37 = llvm.getelementptr %17[%20, %22, 0, %25] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %38 = llvm.call @strtoll(%37, %18, %19) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %39 = llvm.getelementptr %arg0[%26] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %38, %39 {alignment = 4 : i64} : i64, !llvm.ptr + %40 = llvm.getelementptr %17[%20, %22, 1, %24] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %41 = llvm.call @strtoll(%40, %18, %19) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %42 = llvm.getelementptr %arg0[%27] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %41, %42 {alignment = 4 : i64} : i64, !llvm.ptr + %43 = llvm.getelementptr %17[%20, %22, 2, %28] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>, array<7 x i8>)>> + %44 = llvm.call @strtoll(%43, %18, %19) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %45 = llvm.getelementptr %arg0[%29] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %44, %45 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/str-int-4.ll.mlir b/test/LLVMDialect/InstCombine/str-int-4.ll.mlir new file mode 100644 index 000000000..35777c507 --- /dev/null +++ b/test/LLVMDialect/InstCombine/str-int-4.ll.mlir @@ -0,0 +1,276 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @ws("\09\0D\0A\0B\0C \00") {addr_space = 0 : i32} + llvm.mlir.global external constant @ws_im123("\09\0D\0A\0B\0C -123\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @ws_ip234("\09\0D\0A\0B\0C +234\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @wsplus(" +\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i0(" 0\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i8(" 8\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i9(" 9\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @ia(" a\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i08("08\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @x0x("0x\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @wsplusws0(" + 0\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i19azAZ("19azAZ\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i32min(" -2147483648\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i32min_m1(" -2147483649\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @o32min(" +020000000000\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @mo32min(" -020000000000\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @x32min(" +0x80000000\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @mx32min(" -0x80000000\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i32max(" 2147483647\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @x32max(" 0x7fffffff\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i32max_p1(" 2147483648\00") {addr_space = 0 : i32} + llvm.mlir.global external @endptr() {addr_space = 0 : i32} : !llvm.ptr + llvm.mlir.global external constant @i64min(" -9223372036854775808\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i64min_m1(" -9223372036854775809\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i64max(" 9223372036854775807\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i64max_p1(" 9223372036854775808\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @ui64max(" 18446744073709551615\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @ui64max_p1(" 18446744073709551616\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i_1_2_3_(" 1 2\09\\3\0A\00") {addr_space = 0 : i32} + llvm.func @strtol(!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.func @strtoll(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @fold_strtol(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("\09\0D\0A\0B\0C -123\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @ws_im123 : !llvm.ptr + %2 = llvm.mlir.addressof @endptr : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.mlir.constant("\09\0D\0A\0B\0C +234\00") : !llvm.array<11 x i8> + %5 = llvm.mlir.addressof @ws_ip234 : !llvm.ptr + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.mlir.constant(" 0\00") : !llvm.array<3 x i8> + %8 = llvm.mlir.addressof @i0 : !llvm.ptr + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.mlir.constant(2 : i32) : i32 + %11 = llvm.mlir.constant(" 9\00") : !llvm.array<3 x i8> + %12 = llvm.mlir.addressof @i9 : !llvm.ptr + %13 = llvm.mlir.constant(3 : i32) : i32 + %14 = llvm.mlir.constant(" a\00") : !llvm.array<3 x i8> + %15 = llvm.mlir.addressof @ia : !llvm.ptr + %16 = llvm.mlir.constant(16 : i32) : i32 + %17 = llvm.mlir.constant(4 : i32) : i32 + %18 = llvm.mlir.constant("19azAZ\00") : !llvm.array<7 x i8> + %19 = llvm.mlir.addressof @i19azAZ : !llvm.ptr + %20 = llvm.mlir.constant(36 : i32) : i32 + %21 = llvm.mlir.constant(5 : i32) : i32 + %22 = llvm.mlir.constant(" -2147483648\00") : !llvm.array<13 x i8> + %23 = llvm.mlir.addressof @i32min : !llvm.ptr + %24 = llvm.mlir.constant(6 : i32) : i32 + %25 = llvm.mlir.constant(" -020000000000\00") : !llvm.array<15 x i8> + %26 = llvm.mlir.addressof @mo32min : !llvm.ptr + %27 = llvm.mlir.constant(7 : i32) : i32 + %28 = llvm.mlir.constant(" -0x80000000\00") : !llvm.array<13 x i8> + %29 = llvm.mlir.addressof @mx32min : !llvm.ptr + %30 = llvm.mlir.constant(8 : i32) : i32 + %31 = llvm.mlir.constant(9 : i32) : i32 + %32 = llvm.mlir.constant(" 2147483647\00") : !llvm.array<12 x i8> + %33 = llvm.mlir.addressof @i32max : !llvm.ptr + %34 = llvm.mlir.constant(" 0x7fffffff\00") : !llvm.array<12 x i8> + %35 = llvm.mlir.addressof @x32max : !llvm.ptr + %36 = llvm.mlir.constant(11 : i32) : i32 + %37 = llvm.call @strtol(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.store %37, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %38 = llvm.call @strtol(%5, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %39 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %38, %39 {alignment = 4 : i64} : i32, !llvm.ptr + %40 = llvm.call @strtol(%8, %2, %9) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %41 = llvm.getelementptr %arg0[%10] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %40, %41 {alignment = 4 : i64} : i32, !llvm.ptr + %42 = llvm.call @strtol(%12, %2, %9) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %43 = llvm.getelementptr %arg0[%13] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %42, %43 {alignment = 4 : i64} : i32, !llvm.ptr + %44 = llvm.call @strtol(%15, %2, %16) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %45 = llvm.getelementptr %arg0[%17] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %44, %45 {alignment = 4 : i64} : i32, !llvm.ptr + %46 = llvm.call @strtol(%19, %2, %20) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %47 = llvm.getelementptr %arg0[%21] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %46, %47 {alignment = 4 : i64} : i32, !llvm.ptr + %48 = llvm.call @strtol(%23, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %49 = llvm.getelementptr %arg0[%24] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %48, %49 {alignment = 4 : i64} : i32, !llvm.ptr + %50 = llvm.call @strtol(%26, %2, %9) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %51 = llvm.getelementptr %arg0[%27] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %50, %51 {alignment = 4 : i64} : i32, !llvm.ptr + %52 = llvm.call @strtol(%29, %2, %9) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %53 = llvm.getelementptr %arg0[%30] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %52, %53 {alignment = 4 : i64} : i32, !llvm.ptr + %54 = llvm.call @strtol(%29, %2, %16) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %55 = llvm.getelementptr %arg0[%31] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %54, %55 {alignment = 4 : i64} : i32, !llvm.ptr + %56 = llvm.call @strtol(%33, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %57 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %56, %57 {alignment = 4 : i64} : i32, !llvm.ptr + %58 = llvm.call @strtol(%35, %2, %9) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %59 = llvm.getelementptr %arg0[%36] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %58, %59 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @call_strtol(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(" -2147483649\00") : !llvm.array<13 x i8> + %1 = llvm.mlir.addressof @i32min_m1 : !llvm.ptr + %2 = llvm.mlir.addressof @endptr : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.mlir.constant(" 2147483648\00") : !llvm.array<12 x i8> + %5 = llvm.mlir.addressof @i32max_p1 : !llvm.ptr + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.mlir.constant(" +\00") : !llvm.array<3 x i8> + %8 = llvm.mlir.addressof @wsplus : !llvm.ptr + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.mlir.constant(2 : i32) : i32 + %11 = llvm.mlir.constant(" a\00") : !llvm.array<3 x i8> + %12 = llvm.mlir.addressof @ia : !llvm.ptr + %13 = llvm.mlir.constant(3 : i32) : i32 + %14 = llvm.mlir.constant(" 8\00") : !llvm.array<3 x i8> + %15 = llvm.mlir.addressof @i8 : !llvm.ptr + %16 = llvm.mlir.constant(8 : i32) : i32 + %17 = llvm.mlir.constant(4 : i32) : i32 + %18 = llvm.mlir.constant("0x\00") : !llvm.array<3 x i8> + %19 = llvm.mlir.addressof @x0x : !llvm.ptr + %20 = llvm.mlir.constant(5 : i32) : i32 + %21 = llvm.mlir.constant(" + 0\00") : !llvm.array<5 x i8> + %22 = llvm.mlir.addressof @wsplusws0 : !llvm.ptr + %23 = llvm.mlir.constant(6 : i32) : i32 + %24 = llvm.mlir.constant("19azAZ\00") : !llvm.array<7 x i8> + %25 = llvm.mlir.addressof @i19azAZ : !llvm.ptr + %26 = llvm.mlir.constant(35 : i32) : i32 + %27 = llvm.mlir.constant(7 : i32) : i32 + %28 = llvm.mlir.constant(" +020000000000\00") : !llvm.array<15 x i8> + %29 = llvm.mlir.addressof @o32min : !llvm.ptr + %30 = llvm.mlir.constant(" +0x80000000\00") : !llvm.array<13 x i8> + %31 = llvm.mlir.addressof @x32min : !llvm.ptr + %32 = llvm.mlir.constant(9 : i32) : i32 + %33 = llvm.mlir.constant("\09\0D\0A\0B\0C \00") : !llvm.array<7 x i8> + %34 = llvm.mlir.addressof @ws : !llvm.ptr + %35 = llvm.mlir.constant(11 : i32) : i32 + %36 = llvm.mlir.constant(12 : i32) : i32 + %37 = llvm.mlir.constant(" 0\00") : !llvm.array<3 x i8> + %38 = llvm.mlir.addressof @i0 : !llvm.ptr + %39 = llvm.mlir.constant(13 : i32) : i32 + %40 = llvm.mlir.constant(256 : i32) : i32 + %41 = llvm.mlir.constant(14 : i32) : i32 + %42 = llvm.call @strtol(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.store %42, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %43 = llvm.call @strtol(%5, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %44 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %43, %44 {alignment = 4 : i64} : i32, !llvm.ptr + %45 = llvm.call @strtol(%8, %2, %9) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %46 = llvm.getelementptr %arg0[%10] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %45, %46 {alignment = 4 : i64} : i32, !llvm.ptr + %47 = llvm.call @strtol(%12, %2, %9) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %48 = llvm.getelementptr %arg0[%13] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %47, %48 {alignment = 4 : i64} : i32, !llvm.ptr + %49 = llvm.call @strtol(%15, %2, %16) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %50 = llvm.getelementptr %arg0[%17] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %49, %50 {alignment = 4 : i64} : i32, !llvm.ptr + %51 = llvm.call @strtol(%19, %2, %9) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %52 = llvm.getelementptr %arg0[%20] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %51, %52 {alignment = 4 : i64} : i32, !llvm.ptr + %53 = llvm.call @strtol(%22, %2, %9) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %54 = llvm.getelementptr %arg0[%23] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %53, %54 {alignment = 4 : i64} : i32, !llvm.ptr + %55 = llvm.call @strtol(%25, %2, %26) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %56 = llvm.getelementptr %arg0[%27] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %55, %56 {alignment = 4 : i64} : i32, !llvm.ptr + %57 = llvm.call @strtol(%29, %2, %9) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %58 = llvm.getelementptr %arg0[%16] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %57, %58 {alignment = 4 : i64} : i32, !llvm.ptr + %59 = llvm.call @strtol(%31, %2, %9) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %60 = llvm.getelementptr %arg0[%32] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %59, %60 {alignment = 4 : i64} : i32, !llvm.ptr + %61 = llvm.call @strtol(%31, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %62 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %61, %62 {alignment = 4 : i64} : i32, !llvm.ptr + %63 = llvm.call @strtol(%34, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %64 = llvm.getelementptr %arg0[%35] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %63, %64 {alignment = 4 : i64} : i32, !llvm.ptr + %65 = llvm.getelementptr %34[%9, %23] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<7 x i8> + %66 = llvm.call @strtol(%65, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %67 = llvm.getelementptr %arg0[%36] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %66, %67 {alignment = 4 : i64} : i32, !llvm.ptr + %68 = llvm.call @strtol(%38, %2, %6) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %69 = llvm.getelementptr %arg0[%39] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %68, %69 {alignment = 4 : i64} : i32, !llvm.ptr + %70 = llvm.call @strtol(%38, %2, %40) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %71 = llvm.getelementptr %arg0[%41] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %70, %71 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_strtoll(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("\09\0D\0A\0B\0C -123\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @ws_im123 : !llvm.ptr + %2 = llvm.mlir.addressof @endptr : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.mlir.constant("\09\0D\0A\0B\0C +234\00") : !llvm.array<11 x i8> + %5 = llvm.mlir.addressof @ws_ip234 : !llvm.ptr + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.mlir.constant(" -9223372036854775808\00") : !llvm.array<22 x i8> + %8 = llvm.mlir.addressof @i64min : !llvm.ptr + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.mlir.constant(" 9223372036854775807\00") : !llvm.array<21 x i8> + %11 = llvm.mlir.addressof @i64max : !llvm.ptr + %12 = llvm.mlir.constant(3 : i32) : i32 + %13 = llvm.call @strtoll(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.store %13, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %14 = llvm.call @strtoll(%5, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %15 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %14, %15 {alignment = 4 : i64} : i64, !llvm.ptr + %16 = llvm.call @strtoll(%8, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %17 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %16, %17 {alignment = 4 : i64} : i64, !llvm.ptr + %18 = llvm.call @strtoll(%11, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %19 = llvm.getelementptr %arg0[%12] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %18, %19 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @call_strtoll(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(" -9223372036854775809\00") : !llvm.array<22 x i8> + %1 = llvm.mlir.addressof @i64min_m1 : !llvm.ptr + %2 = llvm.mlir.addressof @endptr : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.mlir.constant(" 9223372036854775808\00") : !llvm.array<21 x i8> + %5 = llvm.mlir.addressof @i64max_p1 : !llvm.ptr + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.mlir.constant("\09\0D\0A\0B\0C \00") : !llvm.array<7 x i8> + %8 = llvm.mlir.addressof @ws : !llvm.ptr + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.mlir.constant(6 : i32) : i32 + %12 = llvm.mlir.constant(3 : i32) : i32 + %13 = llvm.call @strtoll(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.store %13, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %14 = llvm.call @strtoll(%5, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %15 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %14, %15 {alignment = 4 : i64} : i64, !llvm.ptr + %16 = llvm.call @strtoll(%8, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %17 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %16, %17 {alignment = 4 : i64} : i64, !llvm.ptr + %18 = llvm.getelementptr %8[%10, %11] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<7 x i8> + %19 = llvm.call @strtoll(%18, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %20 = llvm.getelementptr %arg0[%12] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %19, %20 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @call_strtol_trailing_space(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(" 1 2\09\\3\0A\00") : !llvm.array<9 x i8> + %1 = llvm.mlir.addressof @i_1_2_3_ : !llvm.ptr + %2 = llvm.mlir.addressof @endptr : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.mlir.constant(4 : i32) : i32 + %8 = llvm.mlir.constant(3 : i32) : i32 + %9 = llvm.call @strtol(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %10 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %9, %10 {alignment = 4 : i64} : i32, !llvm.ptr + %11 = llvm.getelementptr %1[%5, %6] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<9 x i8> + %12 = llvm.call @strtol(%11, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %13 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %12, %13 {alignment = 4 : i64} : i32, !llvm.ptr + %14 = llvm.getelementptr %1[%5, %7] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<9 x i8> + %15 = llvm.call @strtol(%14, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %16 = llvm.getelementptr %arg0[%8] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %15, %16 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/str-int-5.ll.mlir b/test/LLVMDialect/InstCombine/str-int-5.ll.mlir index 97c943901..058357d31 100644 --- a/test/LLVMDialect/InstCombine/str-int-5.ll.mlir +++ b/test/LLVMDialect/InstCombine/str-int-5.ll.mlir @@ -1,282 +1,221 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "ws", type = !llvm.array<7 x i8>, value = "\09\0D\0A\0B\0C \00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "ws_im123", type = !llvm.array<11 x i8>, value = "\09\0D\0A\0B\0C -123\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "ws_ip234", type = !llvm.array<11 x i8>, value = "\09\0D\0A\0B\0C +234\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "i32min", type = !llvm.array<13 x i8>, value = " -2147483648\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "i32min_m1", type = !llvm.array<13 x i8>, value = " -2147483649\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "o32min", type = !llvm.array<15 x i8>, value = " +020000000000\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "mo32min", type = !llvm.array<15 x i8>, value = " -020000000000\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "x32min", type = !llvm.array<13 x i8>, value = " +0x80000000\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "mx32min", type = !llvm.array<13 x i8>, value = " +0x80000000\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "i32max", type = !llvm.array<12 x i8>, value = " 2147483647\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "i32max_p1", type = !llvm.array<12 x i8>, value = " 2147483648\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "mX01", type = !llvm.array<6 x i8>, value = " -0X1\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "ui32max", type = !llvm.array<12 x i8>, value = " 4294967295\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "ui32max_p1", type = !llvm.array<12 x i8>, value = " 4294967296\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "i64min", type = !llvm.array<22 x i8>, value = " -9223372036854775808\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "i64min_m1", type = !llvm.array<22 x i8>, value = " -9223372036854775809\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "i64max", type = !llvm.array<21 x i8>, value = " 9223372036854775807\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "i64max_p1", type = !llvm.array<21 x i8>, value = " 9223372036854775808\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "ui64max", type = !llvm.array<22 x i8>, value = " 18446744073709551615\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "x64max", type = !llvm.array<20 x i8>, value = " 0xffffffffffffffff\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "ui64max_p1", type = !llvm.array<22 x i8>, value = " 18446744073709551616\00"} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "endptr", type = !llvm.ptr} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtoul", type = !llvm.func, ptr>, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtoull", type = !llvm.func, ptr>, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 11 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %2 = "llvm.mlir.addressof"() {global_name = @ui32max} : () -> !llvm.ptr> - %3 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %4 = "llvm.mlir.addressof"() {global_name = @i32max_p1} : () -> !llvm.ptr> - %5 = "llvm.mlir.constant"() {value = 9 : i32} : () -> i32 - %6 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %7 = "llvm.mlir.addressof"() {global_name = @mX01} : () -> !llvm.ptr> - %8 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %9 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %10 = "llvm.mlir.addressof"() {global_name = @i32max} : () -> !llvm.ptr> - %11 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %12 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %13 = "llvm.mlir.addressof"() {global_name = @mx32min} : () -> !llvm.ptr> - %14 = "llvm.mlir.constant"() {value = 6 : i32} : () -> i32 - %15 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %16 = "llvm.mlir.addressof"() {global_name = @x32min} : () -> !llvm.ptr> - %17 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %18 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %19 = "llvm.mlir.addressof"() {global_name = @mo32min} : () -> !llvm.ptr> - %20 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %21 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %22 = "llvm.mlir.addressof"() {global_name = @o32min} : () -> !llvm.ptr> - %23 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %24 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %25 = "llvm.mlir.addressof"() {global_name = @i32min} : () -> !llvm.ptr> - %26 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %27 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %28 = "llvm.mlir.addressof"() {global_name = @i32min_m1} : () -> !llvm.ptr> - %29 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %30 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %31 = "llvm.mlir.addressof"() {global_name = @ws_ip234} : () -> !llvm.ptr> - %32 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %33 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %34 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %35 = "llvm.mlir.addressof"() {global_name = @ws_im123} : () -> !llvm.ptr> - %36 = "llvm.getelementptr"(%35, %34, %34) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %37 = "llvm.call"(%36, %33, %32) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %38 = "llvm.getelementptr"(%arg0, %34) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%37, %38) : (i32, !llvm.ptr) -> () - %39 = "llvm.getelementptr"(%31, %34, %34) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %40 = "llvm.call"(%39, %30, %32) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %41 = "llvm.getelementptr"(%arg0, %29) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%40, %41) : (i32, !llvm.ptr) -> () - %42 = "llvm.getelementptr"(%28, %34, %34) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %43 = "llvm.call"(%42, %27, %32) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %44 = "llvm.getelementptr"(%arg0, %26) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%43, %44) : (i32, !llvm.ptr) -> () - %45 = "llvm.getelementptr"(%25, %34, %34) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %46 = "llvm.call"(%45, %24, %32) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %47 = "llvm.getelementptr"(%arg0, %23) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%46, %47) : (i32, !llvm.ptr) -> () - %48 = "llvm.getelementptr"(%22, %34, %34) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %49 = "llvm.call"(%48, %21, %34) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %50 = "llvm.getelementptr"(%arg0, %20) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%49, %50) : (i32, !llvm.ptr) -> () - %51 = "llvm.getelementptr"(%19, %34, %34) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %52 = "llvm.call"(%51, %18, %34) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %53 = "llvm.getelementptr"(%arg0, %17) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%52, %53) : (i32, !llvm.ptr) -> () - %54 = "llvm.getelementptr"(%16, %34, %34) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %55 = "llvm.call"(%54, %15, %34) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %56 = "llvm.getelementptr"(%arg0, %14) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%55, %56) : (i32, !llvm.ptr) -> () - %57 = "llvm.getelementptr"(%13, %34, %34) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %58 = "llvm.call"(%57, %12, %34) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %59 = "llvm.getelementptr"(%arg0, %11) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%55, %59) : (i32, !llvm.ptr) -> () - %60 = "llvm.getelementptr"(%10, %34, %34) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %61 = "llvm.call"(%60, %9, %32) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %62 = "llvm.getelementptr"(%arg0, %8) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%61, %62) : (i32, !llvm.ptr) -> () - %63 = "llvm.getelementptr"(%7, %34, %34) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %64 = "llvm.call"(%63, %6, %34) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %65 = "llvm.getelementptr"(%arg0, %5) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%64, %65) : (i32, !llvm.ptr) -> () - %66 = "llvm.getelementptr"(%4, %34, %34) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %67 = "llvm.call"(%66, %3, %32) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %68 = "llvm.getelementptr"(%arg0, %32) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%67, %68) : (i32, !llvm.ptr) -> () - %69 = "llvm.getelementptr"(%2, %34, %34) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %70 = "llvm.call"(%69, %1, %32) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %71 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%70, %71) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strtoul", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 6 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @ws} : () -> !llvm.ptr> - %4 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %5 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %6 = "llvm.mlir.addressof"() {global_name = @ws} : () -> !llvm.ptr> - %7 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %8 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %9 = "llvm.mlir.addressof"() {global_name = @ui32max_p1} : () -> !llvm.ptr> - %10 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %11 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %12 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %13 = "llvm.mlir.addressof"() {global_name = @i64min_m1} : () -> !llvm.ptr> - %14 = "llvm.getelementptr"(%13, %12, %12) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %15 = "llvm.call"(%14, %11, %10) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %16 = "llvm.getelementptr"(%arg0, %12) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%15, %16) : (i32, !llvm.ptr) -> () - %17 = "llvm.getelementptr"(%9, %12, %12) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %18 = "llvm.call"(%17, %8, %10) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %19 = "llvm.getelementptr"(%arg0, %7) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%18, %19) : (i32, !llvm.ptr) -> () - %20 = "llvm.getelementptr"(%6, %12, %12) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %21 = "llvm.call"(%20, %5, %10) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %22 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%21, %22) : (i32, !llvm.ptr) -> () - %23 = "llvm.getelementptr"(%3, %12, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %24 = "llvm.call"(%23, %1, %10) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - %25 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%24, %25) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "call_strtoul", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %1 = "llvm.mlir.addressof"() {global_name = @x64max} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 9 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %4 = "llvm.mlir.addressof"() {global_name = @ui64max} : () -> !llvm.ptr> - %5 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %6 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %7 = "llvm.mlir.addressof"() {global_name = @i64max_p1} : () -> !llvm.ptr> - %8 = "llvm.mlir.constant"() {value = 7 : i32} : () -> i32 - %9 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %10 = "llvm.mlir.addressof"() {global_name = @i64max} : () -> !llvm.ptr> - %11 = "llvm.mlir.constant"() {value = 6 : i32} : () -> i32 - %12 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %13 = "llvm.mlir.addressof"() {global_name = @i64min} : () -> !llvm.ptr> - %14 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %15 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %16 = "llvm.mlir.addressof"() {global_name = @x32min} : () -> !llvm.ptr> - %17 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %18 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %19 = "llvm.mlir.addressof"() {global_name = @o32min} : () -> !llvm.ptr> - %20 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %21 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %22 = "llvm.mlir.addressof"() {global_name = @i32min} : () -> !llvm.ptr> - %23 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %24 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %25 = "llvm.mlir.addressof"() {global_name = @i64min_m1} : () -> !llvm.ptr> - %26 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %27 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %28 = "llvm.mlir.addressof"() {global_name = @ws_ip234} : () -> !llvm.ptr> - %29 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %30 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %31 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %32 = "llvm.mlir.addressof"() {global_name = @ws_im123} : () -> !llvm.ptr> - %33 = "llvm.getelementptr"(%32, %31, %31) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %34 = "llvm.call"(%33, %30, %29) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %35 = "llvm.getelementptr"(%arg0, %31) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%34, %35) : (i64, !llvm.ptr) -> () - %36 = "llvm.getelementptr"(%28, %31, %31) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %37 = "llvm.call"(%36, %27, %29) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %38 = "llvm.getelementptr"(%arg0, %26) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%37, %38) : (i64, !llvm.ptr) -> () - %39 = "llvm.getelementptr"(%25, %31, %31) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %40 = "llvm.call"(%39, %24, %29) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %41 = "llvm.getelementptr"(%arg0, %23) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%40, %41) : (i64, !llvm.ptr) -> () - %42 = "llvm.getelementptr"(%22, %31, %31) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %43 = "llvm.call"(%42, %21, %29) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %44 = "llvm.getelementptr"(%arg0, %20) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%43, %44) : (i64, !llvm.ptr) -> () - %45 = "llvm.getelementptr"(%19, %31, %31) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %46 = "llvm.call"(%45, %18, %31) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %47 = "llvm.getelementptr"(%arg0, %17) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%46, %47) : (i64, !llvm.ptr) -> () - %48 = "llvm.getelementptr"(%16, %31, %31) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %49 = "llvm.call"(%48, %15, %31) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %50 = "llvm.getelementptr"(%arg0, %14) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%49, %50) : (i64, !llvm.ptr) -> () - %51 = "llvm.getelementptr"(%13, %31, %31) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %52 = "llvm.call"(%51, %12, %29) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %53 = "llvm.getelementptr"(%arg0, %11) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%52, %53) : (i64, !llvm.ptr) -> () - %54 = "llvm.getelementptr"(%10, %31, %31) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %55 = "llvm.call"(%54, %9, %29) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %56 = "llvm.getelementptr"(%arg0, %8) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%55, %56) : (i64, !llvm.ptr) -> () - %57 = "llvm.getelementptr"(%7, %31, %31) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %58 = "llvm.call"(%57, %6, %29) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %59 = "llvm.getelementptr"(%arg0, %5) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%58, %59) : (i64, !llvm.ptr) -> () - %60 = "llvm.getelementptr"(%4, %31, %31) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %61 = "llvm.call"(%60, %3, %29) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %62 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%61, %62) : (i64, !llvm.ptr) -> () - %63 = "llvm.getelementptr"(%1, %31, %31) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %64 = "llvm.call"(%63, %0, %31) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %65 = "llvm.getelementptr"(%arg0, %29) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%64, %65) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strtoull", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 6 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @ws} : () -> !llvm.ptr> - %4 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %5 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %6 = "llvm.mlir.addressof"() {global_name = @ws} : () -> !llvm.ptr> - %7 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %8 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %9 = "llvm.mlir.addressof"() {global_name = @endptr} : () -> !llvm.ptr> - %10 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %11 = "llvm.mlir.addressof"() {global_name = @ui64max_p1} : () -> !llvm.ptr> - %12 = "llvm.getelementptr"(%11, %10, %10) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %13 = "llvm.call"(%12, %9, %8) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %14 = "llvm.getelementptr"(%arg0, %7) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%13, %14) : (i64, !llvm.ptr) -> () - %15 = "llvm.getelementptr"(%6, %10, %10) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %16 = "llvm.call"(%15, %5, %8) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %17 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%16, %17) : (i64, !llvm.ptr) -> () - %18 = "llvm.getelementptr"(%3, %10, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %19 = "llvm.call"(%18, %1, %8) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %20 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%19, %20) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "call_strtoull", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @ws("\09\0D\0A\0B\0C \00") {addr_space = 0 : i32} + llvm.mlir.global external constant @ws_im123("\09\0D\0A\0B\0C -123\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @ws_ip234("\09\0D\0A\0B\0C +234\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i32min(" -2147483648\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i32min_m1(" -2147483649\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @o32min(" +020000000000\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @mo32min(" -020000000000\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @x32min(" +0x80000000\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @mx32min(" +0x80000000\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i32max(" 2147483647\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i32max_p1(" 2147483648\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @mX01(" -0X1\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @ui32max(" 4294967295\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @ui32max_p1(" 4294967296\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i64min(" -9223372036854775808\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i64min_m1(" -9223372036854775809\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i64max(" 9223372036854775807\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @i64max_p1(" 9223372036854775808\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @ui64max(" 18446744073709551615\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @x64max(" 0xffffffffffffffff\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @ui64max_p1(" 18446744073709551616\00") {addr_space = 0 : i32} + llvm.mlir.global external @endptr() {addr_space = 0 : i32} : !llvm.ptr + llvm.func @strtoul(!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.func @strtoull(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @fold_strtoul(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("\09\0D\0A\0B\0C -123\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @ws_im123 : !llvm.ptr + %2 = llvm.mlir.addressof @endptr : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.mlir.constant("\09\0D\0A\0B\0C +234\00") : !llvm.array<11 x i8> + %5 = llvm.mlir.addressof @ws_ip234 : !llvm.ptr + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.mlir.constant(" -2147483649\00") : !llvm.array<13 x i8> + %8 = llvm.mlir.addressof @i32min_m1 : !llvm.ptr + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.mlir.constant(" -2147483648\00") : !llvm.array<13 x i8> + %11 = llvm.mlir.addressof @i32min : !llvm.ptr + %12 = llvm.mlir.constant(3 : i32) : i32 + %13 = llvm.mlir.constant(" +020000000000\00") : !llvm.array<15 x i8> + %14 = llvm.mlir.addressof @o32min : !llvm.ptr + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.mlir.constant(4 : i32) : i32 + %17 = llvm.mlir.constant(" -020000000000\00") : !llvm.array<15 x i8> + %18 = llvm.mlir.addressof @mo32min : !llvm.ptr + %19 = llvm.mlir.constant(5 : i32) : i32 + %20 = llvm.mlir.constant(" +0x80000000\00") : !llvm.array<13 x i8> + %21 = llvm.mlir.addressof @x32min : !llvm.ptr + %22 = llvm.mlir.constant(6 : i32) : i32 + %23 = llvm.mlir.addressof @mx32min : !llvm.ptr + %24 = llvm.mlir.constant(7 : i32) : i32 + %25 = llvm.mlir.constant(" 2147483647\00") : !llvm.array<12 x i8> + %26 = llvm.mlir.addressof @i32max : !llvm.ptr + %27 = llvm.mlir.constant(8 : i32) : i32 + %28 = llvm.mlir.constant(" -0X1\00") : !llvm.array<6 x i8> + %29 = llvm.mlir.addressof @mX01 : !llvm.ptr + %30 = llvm.mlir.constant(9 : i32) : i32 + %31 = llvm.mlir.constant(" 2147483648\00") : !llvm.array<12 x i8> + %32 = llvm.mlir.addressof @i32max_p1 : !llvm.ptr + %33 = llvm.mlir.constant(" 4294967295\00") : !llvm.array<12 x i8> + %34 = llvm.mlir.addressof @ui32max : !llvm.ptr + %35 = llvm.mlir.constant(11 : i32) : i32 + %36 = llvm.call @strtoul(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.store %36, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %37 = llvm.call @strtoul(%5, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %38 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %37, %38 {alignment = 4 : i64} : i32, !llvm.ptr + %39 = llvm.call @strtoul(%8, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %40 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %39, %40 {alignment = 4 : i64} : i32, !llvm.ptr + %41 = llvm.call @strtoul(%11, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %42 = llvm.getelementptr %arg0[%12] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %41, %42 {alignment = 4 : i64} : i32, !llvm.ptr + %43 = llvm.call @strtoul(%14, %2, %15) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %44 = llvm.getelementptr %arg0[%16] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %43, %44 {alignment = 4 : i64} : i32, !llvm.ptr + %45 = llvm.call @strtoul(%18, %2, %15) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %46 = llvm.getelementptr %arg0[%19] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %45, %46 {alignment = 4 : i64} : i32, !llvm.ptr + %47 = llvm.call @strtoul(%21, %2, %15) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %48 = llvm.getelementptr %arg0[%22] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %47, %48 {alignment = 4 : i64} : i32, !llvm.ptr + %49 = llvm.call @strtoul(%23, %2, %15) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %50 = llvm.getelementptr %arg0[%24] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %47, %50 {alignment = 4 : i64} : i32, !llvm.ptr + %51 = llvm.call @strtoul(%26, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %52 = llvm.getelementptr %arg0[%27] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %51, %52 {alignment = 4 : i64} : i32, !llvm.ptr + %53 = llvm.call @strtoul(%29, %2, %15) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %54 = llvm.getelementptr %arg0[%30] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %53, %54 {alignment = 4 : i64} : i32, !llvm.ptr + %55 = llvm.call @strtoul(%32, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %56 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %55, %56 {alignment = 4 : i64} : i32, !llvm.ptr + %57 = llvm.call @strtoul(%34, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %58 = llvm.getelementptr %arg0[%35] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %57, %58 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @call_strtoul(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(" -9223372036854775809\00") : !llvm.array<22 x i8> + %1 = llvm.mlir.addressof @i64min_m1 : !llvm.ptr + %2 = llvm.mlir.addressof @endptr : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.mlir.constant(" 4294967296\00") : !llvm.array<12 x i8> + %5 = llvm.mlir.addressof @ui32max_p1 : !llvm.ptr + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.mlir.constant("\09\0D\0A\0B\0C \00") : !llvm.array<7 x i8> + %8 = llvm.mlir.addressof @ws : !llvm.ptr + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.mlir.constant(6 : i32) : i32 + %12 = llvm.mlir.constant(3 : i32) : i32 + %13 = llvm.call @strtoul(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.store %13, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %14 = llvm.call @strtoul(%5, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %15 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %14, %15 {alignment = 4 : i64} : i32, !llvm.ptr + %16 = llvm.call @strtoul(%8, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %17 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %16, %17 {alignment = 4 : i64} : i32, !llvm.ptr + %18 = llvm.getelementptr %8[%10, %11] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<7 x i8> + %19 = llvm.call @strtoul(%18, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + %20 = llvm.getelementptr %arg0[%12] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %19, %20 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_strtoull(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("\09\0D\0A\0B\0C -123\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @ws_im123 : !llvm.ptr + %2 = llvm.mlir.addressof @endptr : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.mlir.constant("\09\0D\0A\0B\0C +234\00") : !llvm.array<11 x i8> + %5 = llvm.mlir.addressof @ws_ip234 : !llvm.ptr + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.mlir.constant(" -9223372036854775809\00") : !llvm.array<22 x i8> + %8 = llvm.mlir.addressof @i64min_m1 : !llvm.ptr + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.mlir.constant(" -2147483648\00") : !llvm.array<13 x i8> + %11 = llvm.mlir.addressof @i32min : !llvm.ptr + %12 = llvm.mlir.constant(3 : i32) : i32 + %13 = llvm.mlir.constant(" +020000000000\00") : !llvm.array<15 x i8> + %14 = llvm.mlir.addressof @o32min : !llvm.ptr + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.mlir.constant(4 : i32) : i32 + %17 = llvm.mlir.constant(" +0x80000000\00") : !llvm.array<13 x i8> + %18 = llvm.mlir.addressof @x32min : !llvm.ptr + %19 = llvm.mlir.constant(5 : i32) : i32 + %20 = llvm.mlir.constant(" -9223372036854775808\00") : !llvm.array<22 x i8> + %21 = llvm.mlir.addressof @i64min : !llvm.ptr + %22 = llvm.mlir.constant(6 : i32) : i32 + %23 = llvm.mlir.constant(" 9223372036854775807\00") : !llvm.array<21 x i8> + %24 = llvm.mlir.addressof @i64max : !llvm.ptr + %25 = llvm.mlir.constant(7 : i32) : i32 + %26 = llvm.mlir.constant(" 9223372036854775808\00") : !llvm.array<21 x i8> + %27 = llvm.mlir.addressof @i64max_p1 : !llvm.ptr + %28 = llvm.mlir.constant(8 : i32) : i32 + %29 = llvm.mlir.constant(" 18446744073709551615\00") : !llvm.array<22 x i8> + %30 = llvm.mlir.addressof @ui64max : !llvm.ptr + %31 = llvm.mlir.constant(9 : i32) : i32 + %32 = llvm.mlir.constant(" 0xffffffffffffffff\00") : !llvm.array<20 x i8> + %33 = llvm.mlir.addressof @x64max : !llvm.ptr + %34 = llvm.call @strtoull(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.store %34, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %35 = llvm.call @strtoull(%5, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %36 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %35, %36 {alignment = 4 : i64} : i64, !llvm.ptr + %37 = llvm.call @strtoull(%8, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %38 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %37, %38 {alignment = 4 : i64} : i64, !llvm.ptr + %39 = llvm.call @strtoull(%11, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %40 = llvm.getelementptr %arg0[%12] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %39, %40 {alignment = 4 : i64} : i64, !llvm.ptr + %41 = llvm.call @strtoull(%14, %2, %15) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %42 = llvm.getelementptr %arg0[%16] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %41, %42 {alignment = 4 : i64} : i64, !llvm.ptr + %43 = llvm.call @strtoull(%18, %2, %15) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %44 = llvm.getelementptr %arg0[%19] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %43, %44 {alignment = 4 : i64} : i64, !llvm.ptr + %45 = llvm.call @strtoull(%21, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %46 = llvm.getelementptr %arg0[%22] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %45, %46 {alignment = 4 : i64} : i64, !llvm.ptr + %47 = llvm.call @strtoull(%24, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %48 = llvm.getelementptr %arg0[%25] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %47, %48 {alignment = 4 : i64} : i64, !llvm.ptr + %49 = llvm.call @strtoull(%27, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %50 = llvm.getelementptr %arg0[%28] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %49, %50 {alignment = 4 : i64} : i64, !llvm.ptr + %51 = llvm.call @strtoull(%30, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %52 = llvm.getelementptr %arg0[%31] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %51, %52 {alignment = 4 : i64} : i64, !llvm.ptr + %53 = llvm.call @strtoull(%33, %2, %15) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %54 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %53, %54 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @call_strtoull(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(" 18446744073709551616\00") : !llvm.array<22 x i8> + %1 = llvm.mlir.addressof @ui64max_p1 : !llvm.ptr + %2 = llvm.mlir.addressof @endptr : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.mlir.constant("\09\0D\0A\0B\0C \00") : !llvm.array<7 x i8> + %6 = llvm.mlir.addressof @ws : !llvm.ptr + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.mlir.constant(6 : i32) : i32 + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.call @strtoull(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %12 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %11, %12 {alignment = 4 : i64} : i64, !llvm.ptr + %13 = llvm.call @strtoull(%6, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %14 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %13, %14 {alignment = 4 : i64} : i64, !llvm.ptr + %15 = llvm.getelementptr %6[%8, %9] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<7 x i8> + %16 = llvm.call @strtoull(%15, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %17 = llvm.getelementptr %arg0[%10] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %16, %17 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/str-int.ll.mlir b/test/LLVMDialect/InstCombine/str-int.ll.mlir index 9fd565e60..163004659 100644 --- a/test/LLVMDialect/InstCombine/str-int.ll.mlir +++ b/test/LLVMDialect/InstCombine/str-int.ll.mlir @@ -1,144 +1,114 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str", type = !llvm.array<3 x i8>, value = "12\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str.1", type = !llvm.array<2 x i8>, value = "0\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str.2", type = !llvm.array<11 x i8>, value = "4294967296\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str.3", type = !llvm.array<24 x i8>, value = "10000000000000000000000\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str.4", type = !llvm.array<20 x i8>, value = "9923372036854775807\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str.5", type = !llvm.array<11 x i8>, value = "4994967295\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str.6", type = !llvm.array<10 x i8>, value = "499496729\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str.7", type = !llvm.array<11 x i8>, value = "4994967295\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtol", type = !llvm.func, ptr>, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atoi", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atol", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atoll", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtoll", type = !llvm.func, ptr>, i32)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "strtol_dec", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.null"() : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0, %1) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "strtol_base_zero", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "strtol_hex", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr>, i32) -> !llvm.ptr> - %6 = "llvm.call"(%3, %5, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "strtol_endptr_not_null", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @".str.1"} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "strtol_endptr_maybe_null", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%2) {callee = @atoi, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "atoi_test", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.call"(%arg0, %1, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "strtol_not_const_str", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @atoi, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "atoi_not_const_str", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0, %arg0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "strtol_not_const_base", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @".str.2"} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "strtol_long_int", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @".str.3"} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "strtol_big_overflow", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @".str.6"} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%2) {callee = @atol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "atol_test", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @".str.5"} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %3 = "llvm.call"(%2) {callee = @atoll, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "atoll_test", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @".str.7"} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1, %0) {callee = @strtoll, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "strtoll_test", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private unnamed_addr constant @".str"("12\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.1"("0\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.2"("4294967296\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.3"("10000000000000000000000\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.4"("9923372036854775807\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.5"("4994967295\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.6"("499496729\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.mlir.global private unnamed_addr constant @".str.7"("4994967295\00") {addr_space = 0 : i32, alignment = 1 : i64, dso_local} + llvm.func @strtol(!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.func @atoi(!llvm.ptr) -> i32 + llvm.func @atol(!llvm.ptr) -> i32 + llvm.func @atoll(!llvm.ptr) -> i64 + llvm.func @strtoll(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @strtol_dec() -> i32 { + %0 = llvm.mlir.constant("12\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.call @strtol(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @strtol_base_zero() -> i32 { + %0 = llvm.mlir.constant("12\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strtol(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @strtol_hex() -> i32 { + %0 = llvm.mlir.constant("12\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(16 : i32) : i32 + %4 = llvm.call @strtol(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @strtol_endptr_not_null(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant("12\00") : !llvm.array<3 x i8> + %2 = llvm.mlir.addressof @".str" : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + %5 = llvm.call @strtol(%2, %4, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @strtol_endptr_maybe_null(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant("0\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @".str.1" : !llvm.ptr + %2 = llvm.mlir.constant(10 : i32) : i32 + %3 = llvm.call @strtol(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @atoi_test() -> i32 { + %0 = llvm.mlir.constant("12\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.call @atoi(%1) : (!llvm.ptr) -> i32 + llvm.return %2 : i32 + } + llvm.func @strtol_not_const_str(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.call @strtol(%arg0, %0, %1) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @atoi_not_const_str(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.call @atoi(%arg0) : (!llvm.ptr) -> i32 + llvm.return %0 : i32 + } + llvm.func @strtol_not_const_base(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant("12\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @".str" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.call @strtol(%1, %2, %arg0) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @strtol_long_int() -> i32 { + %0 = llvm.mlir.constant("4294967296\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @".str.2" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.call @strtol(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @strtol_big_overflow() -> i32 { + %0 = llvm.mlir.constant("10000000000000000000000\00") : !llvm.array<24 x i8> + %1 = llvm.mlir.addressof @".str.3" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.call @strtol(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @atol_test() -> i32 { + %0 = llvm.mlir.constant("499496729\00") : !llvm.array<10 x i8> + %1 = llvm.mlir.addressof @".str.6" : !llvm.ptr + %2 = llvm.call @atol(%1) : (!llvm.ptr) -> i32 + llvm.return %2 : i32 + } + llvm.func @atoll_test() -> i64 { + %0 = llvm.mlir.constant("4994967295\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @".str.5" : !llvm.ptr + %2 = llvm.call @atoll(%1) : (!llvm.ptr) -> i64 + llvm.return %2 : i64 + } + llvm.func @strtoll_test() -> i64 { + %0 = llvm.mlir.constant("4994967295\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @".str.7" : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.call @strtoll(%1, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return %4 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/strcall-bad-sig.ll.mlir b/test/LLVMDialect/InstCombine/strcall-bad-sig.ll.mlir new file mode 100644 index 000000000..fedac8d45 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strcall-bad-sig.ll.mlir @@ -0,0 +1,101 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a("1\00") {addr_space = 0 : i32} + llvm.func @atoi(!llvm.ptr) -> !llvm.ptr + llvm.func @atol(!llvm.ptr) -> !llvm.ptr + llvm.func @atoll(!llvm.ptr) -> !llvm.ptr + llvm.func @call_bad_ato(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("1\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.call @atoi(%1) : (!llvm.ptr) -> !llvm.ptr + llvm.store %4, %arg0 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %5 = llvm.call @atol(%1) : (!llvm.ptr) -> !llvm.ptr + %6 = llvm.getelementptr %arg0[%2] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + llvm.store %5, %6 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %7 = llvm.call @atol(%1) : (!llvm.ptr) -> !llvm.ptr + %8 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + llvm.store %7, %8 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @strncasecmp(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @call_bad_strncasecmp() -> !llvm.ptr { + %0 = llvm.mlir.constant("1\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<2 x i8> + %5 = llvm.call @strncasecmp(%1, %4) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @strcoll(!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i1 + llvm.func @call_bad_strcoll() -> i1 { + %0 = llvm.mlir.constant("1\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<2 x i8> + %5 = llvm.call @strcoll(%1, %4, %1) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i1 + llvm.return %5 : i1 + } + llvm.func @strndup(!llvm.ptr) -> !llvm.ptr + llvm.func @call_bad_strndup() -> !llvm.ptr { + %0 = llvm.mlir.constant("1\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.call @strndup(%1) : (!llvm.ptr) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @strtok(!llvm.ptr, !llvm.ptr, i1) -> i1 + llvm.func @call_bad_strtok() -> i1 { + %0 = llvm.mlir.constant("1\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(false) : i1 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<2 x i8> + %6 = llvm.call @strtok(%1, %5, %4) : (!llvm.ptr, !llvm.ptr, i1) -> i1 + llvm.return %6 : i1 + } + llvm.func @strtok_r(!llvm.ptr, !llvm.ptr) -> i1 + llvm.func @call_bad_strtok_r() -> i1 { + %0 = llvm.mlir.constant("1\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<2 x i8> + %5 = llvm.call @strtok_r(%1, %4) : (!llvm.ptr, !llvm.ptr) -> i1 + llvm.return %5 : i1 + } + llvm.func @strtol(!llvm.ptr, !llvm.ptr) -> i32 + llvm.func @strtoul(!llvm.ptr, !llvm.ptr) -> i32 + llvm.func @strtoll(!llvm.ptr, !llvm.ptr) -> i64 + llvm.func @strtoull(!llvm.ptr, !llvm.ptr) -> i64 + llvm.func @call_bad_strto(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant("1\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.call @strtol(%1, %2) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.store %5, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %6 = llvm.call @strtoul(%1, %2) : (!llvm.ptr, !llvm.ptr) -> i32 + %7 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %6, %7 {alignment = 4 : i64} : i32, !llvm.ptr + %8 = llvm.call @strtoll(%1, %2) : (!llvm.ptr, !llvm.ptr) -> i64 + llvm.store %8, %arg1 {alignment = 4 : i64} : i64, !llvm.ptr + %9 = llvm.call @strtoull(%1, %2) : (!llvm.ptr, !llvm.ptr) -> i64 + %10 = llvm.getelementptr %arg1[%4] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %9, %10 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @strxfrm(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @call_bad_strxfrm() -> !llvm.ptr { + %0 = llvm.mlir.constant("1\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<2 x i8> + %5 = llvm.call @strxfrm(%1, %4) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/strcall-no-nul.ll.mlir b/test/LLVMDialect/InstCombine/strcall-no-nul.ll.mlir index 146e2f241..b752e8284 100644 --- a/test/LLVMDialect/InstCombine/strcall-no-nul.ll.mlir +++ b/test/LLVMDialect/InstCombine/strcall-no-nul.ll.mlir @@ -1,293 +1,246 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a5", type = !llvm.array<5 x i8>, value = "%s\0045"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strchr", type = !llvm.func (ptr, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strrchr", type = !llvm.func (ptr, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strcmp", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strncmp", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strstr", type = !llvm.func (ptr, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "stpcpy", type = !llvm.func (ptr, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strcpy", type = !llvm.func (ptr, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "stpncpy", type = !llvm.func (ptr, ptr, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strncpy", type = !llvm.func (ptr, ptr, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strlen", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strnlen", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strpbrk", type = !llvm.func (ptr, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strspn", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strcspn", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atoi", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atol", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atoll", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtol", type = !llvm.func, ptr>, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtoll", type = !llvm.func, ptr>, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtoul", type = !llvm.func, ptr>, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtoull", type = !llvm.func, ptr>, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sprintf", type = !llvm.func, ptr, ...)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "snprintf", type = !llvm.func, i64, ptr, ...)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %1) {callee = @strchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_strchr_past_end", type = !llvm.func ()>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %3, %3) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.getelementptr"(%2, %3, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %7 = "llvm.call"(%5, %6) {callee = @strcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i32 - %8 = "llvm.getelementptr"(%arg0, %3) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%7, %8) : (i32, !llvm.ptr) -> () - %9 = "llvm.call"(%6, %5) {callee = @strcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i32 - %10 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%9, %10) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strcmp_past_end", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %4 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %5 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %6 = "llvm.getelementptr"(%5, %4, %4) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %7 = "llvm.getelementptr"(%3, %4, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %8 = "llvm.call"(%6, %7, %1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %9 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%8, %9) : (i32, !llvm.ptr) -> () - %10 = "llvm.call"(%7, %6, %1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %11 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%10, %11) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strncmp_past_end", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %1) {callee = @strrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_strrchr_past_end", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %3, %3) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.getelementptr"(%2, %3, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %7 = "llvm.call"(%5, %6) {callee = @strstr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr - %8 = "llvm.getelementptr"(%arg0, %3) : (!llvm.ptr>, i32) -> !llvm.ptr> - "llvm.store"(%7, %8) : (!llvm.ptr, !llvm.ptr>) -> () - %9 = "llvm.call"(%6, %5) {callee = @strstr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr - %10 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr>, i32) -> !llvm.ptr> - "llvm.store"(%9, %10) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strstr_past_end", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3) {callee = @strlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strlen_past_end", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3) {callee = @strcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_stpcpy_past_end", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3) {callee = @strcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_strcpy_past_end", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %0) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_stpncpy_past_end", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%arg0, %4, %0) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"(%5) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_strncpy_past_end", type = !llvm.func (ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %3, %3) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.getelementptr"(%2, %3, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %7 = "llvm.call"(%5, %6) {callee = @strpbrk, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr - %8 = "llvm.getelementptr"(%arg0, %3) : (!llvm.ptr>, i32) -> !llvm.ptr> - "llvm.store"(%7, %8) : (!llvm.ptr, !llvm.ptr>) -> () - %9 = "llvm.call"(%6, %5) {callee = @strpbrk, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr - %10 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr>, i32) -> !llvm.ptr> - "llvm.store"(%9, %10) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strpbrk_past_end", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %3, %3) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.getelementptr"(%2, %3, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %7 = "llvm.call"(%5, %6) {callee = @strspn, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i64 - %8 = "llvm.getelementptr"(%arg0, %3) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%7, %8) : (i64, !llvm.ptr) -> () - %9 = "llvm.call"(%6, %5) {callee = @strspn, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i64 - %10 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%9, %10) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strspn_past_end", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %3, %3) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.getelementptr"(%2, %3, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %7 = "llvm.call"(%5, %6) {callee = @strcspn, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i64 - %8 = "llvm.getelementptr"(%arg0, %3) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%7, %8) : (i64, !llvm.ptr) -> () - %9 = "llvm.call"(%6, %5) {callee = @strcspn, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i64 - %10 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%9, %10) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strcspn_past_end", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3) {callee = @atoi, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "fold_atoi_past_end", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %3 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %6 = "llvm.mlir.null"() : () -> !llvm.ptr> - %7 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %8 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %9 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %10 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %11 = "llvm.getelementptr"(%10, %9, %8) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %12 = "llvm.call"(%11) {callee = @atol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i64 - %13 = "llvm.getelementptr"(%arg0, %9) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%12, %13) : (i64, !llvm.ptr) -> () - %14 = "llvm.call"(%11) {callee = @atoll, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i64 - %15 = "llvm.getelementptr"(%arg0, %7) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%14, %15) : (i64, !llvm.ptr) -> () - %16 = "llvm.call"(%11, %6, %9) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %17 = "llvm.getelementptr"(%arg0, %5) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%16, %17) : (i64, !llvm.ptr) -> () - %18 = "llvm.call"(%11, %6, %4) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %19 = "llvm.getelementptr"(%arg0, %3) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%18, %19) : (i64, !llvm.ptr) -> () - %20 = "llvm.call"(%11, %6, %2) {callee = @strtoll, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %21 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%20, %21) : (i64, !llvm.ptr) -> () - %22 = "llvm.call"(%11, %6, %0) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - %23 = "llvm.getelementptr"(%arg0, %8) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%22, %23) : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_atol_strtol_past_end", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %3, %3) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.getelementptr"(%2, %3, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %7 = "llvm.call"(%arg1, %6) {callee = @sprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i32 - %8 = "llvm.getelementptr"(%arg0, %3) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%7, %8) : (i32, !llvm.ptr) -> () - %9 = "llvm.call"(%arg1, %5, %6) {callee = @sprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i32 - %10 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%9, %10) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_sprintf_past_end", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %3 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %4 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %5 = "llvm.getelementptr"(%4, %3, %3) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.getelementptr"(%2, %3, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %7 = "llvm.call"(%arg1, %arg2, %6) {callee = @snprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64, !llvm.ptr) -> i32 - %8 = "llvm.getelementptr"(%arg0, %3) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%7, %8) : (i32, !llvm.ptr) -> () - %9 = "llvm.call"(%arg1, %arg2, %5, %6) {callee = @snprintf, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 - %10 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.store"(%9, %10) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_snprintf_past_end", type = !llvm.func, ptr, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a5("%s\0045") {addr_space = 0 : i32} + llvm.func @strchr(!llvm.ptr, i32) -> !llvm.ptr + llvm.func @strrchr(!llvm.ptr, i32) -> !llvm.ptr + llvm.func @strcmp(!llvm.ptr, !llvm.ptr) -> i32 + llvm.func @strncmp(!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.func @strstr(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @stpcpy(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @strcpy(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @stpncpy(!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.func @strncpy(!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.func @strlen(!llvm.ptr) -> i64 + llvm.func @strnlen(!llvm.ptr, i64) -> i64 + llvm.func @strpbrk(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @strspn(!llvm.ptr, !llvm.ptr) -> i64 + llvm.func @strcspn(!llvm.ptr, !llvm.ptr) -> i64 + llvm.func @atoi(!llvm.ptr) -> i32 + llvm.func @atol(!llvm.ptr) -> i64 + llvm.func @atoll(!llvm.ptr) -> i64 + llvm.func @strtol(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @strtoll(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @strtoul(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @strtoull(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @sprintf(!llvm.ptr, !llvm.ptr, ...) -> i32 + llvm.func @snprintf(!llvm.ptr, i64, !llvm.ptr, ...) -> i32 + llvm.func @fold_strchr_past_end() -> !llvm.ptr { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.call @strchr(%4, %2) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @fold_strcmp_past_end(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @strcmp(%1, %5) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.store %6, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %7 = llvm.call @strcmp(%5, %1) : (!llvm.ptr, !llvm.ptr) -> i32 + %8 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %7, %8 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_strncmp_past_end(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(5 : i64) : i64 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %7 = llvm.call @strncmp(%1, %6, %4) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %7, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %8 = llvm.call @strncmp(%6, %1, %4) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %9 = llvm.getelementptr %arg0[%5] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %8, %9 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_strrchr_past_end(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.call @strrchr(%4, %2) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @fold_strstr_past_end(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @strstr(%1, %5) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.store %6, %arg0 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %7 = llvm.call @strstr(%5, %1) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + %8 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + llvm.store %7, %8 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @fold_strlen_past_end() -> i64 { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.call @strlen(%4) : (!llvm.ptr) -> i64 + llvm.return %5 : i64 + } + llvm.func @fold_stpcpy_past_end(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.call @strcpy(%arg0, %4) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @fold_strcpy_past_end(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.call @strcpy(%arg0, %4) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @fold_stpncpy_past_end(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(5 : i64) : i64 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @strncpy(%arg0, %5, %4) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @fold_strncpy_past_end(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(5 : i64) : i64 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @strncpy(%arg0, %5, %4) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @fold_strpbrk_past_end(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @strpbrk(%1, %5) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.store %6, %arg0 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + %7 = llvm.call @strpbrk(%5, %1) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + %8 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.ptr + llvm.store %7, %8 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @fold_strspn_past_end(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @strspn(%1, %5) : (!llvm.ptr, !llvm.ptr) -> i64 + llvm.store %6, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %7 = llvm.call @strspn(%5, %1) : (!llvm.ptr, !llvm.ptr) -> i64 + %8 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %7, %8 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_strcspn_past_end(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @strcspn(%1, %5) : (!llvm.ptr, !llvm.ptr) -> i64 + llvm.store %6, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %7 = llvm.call @strcspn(%5, %1) : (!llvm.ptr, !llvm.ptr) -> i64 + %8 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %7, %8 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_atoi_past_end() -> i32 { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.call @atoi(%4) : (!llvm.ptr) -> i32 + llvm.return %5 : i32 + } + llvm.func @fold_atol_strtol_past_end(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.mlir.zero : !llvm.ptr + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.mlir.constant(8 : i32) : i32 + %8 = llvm.mlir.constant(3 : i32) : i32 + %9 = llvm.mlir.constant(10 : i32) : i32 + %10 = llvm.mlir.constant(4 : i32) : i32 + %11 = llvm.mlir.constant(16 : i32) : i32 + %12 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %13 = llvm.call @atol(%12) : (!llvm.ptr) -> i64 + llvm.store %13, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %14 = llvm.call @atoll(%12) : (!llvm.ptr) -> i64 + %15 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %14, %15 {alignment = 4 : i64} : i64, !llvm.ptr + %16 = llvm.call @strtol(%12, %5, %2) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %17 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %16, %17 {alignment = 4 : i64} : i64, !llvm.ptr + %18 = llvm.call @strtoul(%12, %5, %7) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %19 = llvm.getelementptr %arg0[%8] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %18, %19 {alignment = 4 : i64} : i64, !llvm.ptr + %20 = llvm.call @strtoll(%12, %5, %9) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %21 = llvm.getelementptr %arg0[%10] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %20, %21 {alignment = 4 : i64} : i64, !llvm.ptr + %22 = llvm.call @strtoul(%12, %5, %11) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + %23 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %22, %23 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_sprintf_past_end(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @sprintf(%arg1, %5) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.store %6, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %7 = llvm.call @sprintf(%arg1, %1, %5) vararg(!llvm.func) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> i32 + %8 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %7, %8 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_snprintf_past_end(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64) { + %0 = llvm.mlir.constant("%s\0045") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %6 = llvm.call @snprintf(%arg1, %arg2, %5) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr) -> i32 + llvm.store %6, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %7 = llvm.call @snprintf(%arg1, %arg2, %1, %5) vararg(!llvm.func) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> i32 + %8 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i32) -> !llvm.ptr, i32 + llvm.store %7, %8 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strcat-1.ll.mlir b/test/LLVMDialect/InstCombine/strcat-1.ll.mlir new file mode 100644 index 000000000..191e15f72 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strcat-1.ll.mlir @@ -0,0 +1,25 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external constant @null_hello("\00hello\00") {addr_space = 0 : i32} + llvm.func @strcat(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @puts(!llvm.ptr) -> i32 + llvm.func @main() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %3 = llvm.mlir.addressof @hello : !llvm.ptr + %4 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %5 = llvm.mlir.addressof @null : !llvm.ptr + %6 = llvm.mlir.constant("\00hello\00") : !llvm.array<7 x i8> + %7 = llvm.mlir.addressof @null_hello : !llvm.ptr + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.alloca %0 x !llvm.array<1024 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %9 {alignment = 1 : i64} : i8, !llvm.ptr + %10 = llvm.call @strcat(%9, %3) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + %11 = llvm.call @strcat(%10, %5) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + %12 = llvm.call @strcat(%11, %7) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + %13 = llvm.call @puts(%12) : (!llvm.ptr) -> i32 + llvm.return %8 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/strcat-2.ll.mlir b/test/LLVMDialect/InstCombine/strcat-2.ll.mlir new file mode 100644 index 000000000..7d1faef02 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strcat-2.ll.mlir @@ -0,0 +1,24 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @empty(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global common @a(dense<0> : tensor<32xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i8> + llvm.func @strcat(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @test_simplify1() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.call @strcat(%2, %4) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return + } + llvm.func @test_simplify2() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %4 = llvm.mlir.addressof @empty : !llvm.ptr + %5 = llvm.call @strcat(%2, %4) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strcat-3.ll.mlir b/test/LLVMDialect/InstCombine/strcat-3.ll.mlir new file mode 100644 index 000000000..0438ee444 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strcat-3.ll.mlir @@ -0,0 +1,15 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @empty(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global common @a(dense<0> : tensor<32xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i8> + llvm.func @strcat(!llvm.ptr, !llvm.ptr) -> i16 + llvm.func @test_nosimplify1() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.call @strcat(%2, %4) : (!llvm.ptr, !llvm.ptr) -> i16 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strchr-1.ll.mlir b/test/LLVMDialect/InstCombine/strchr-1.ll.mlir new file mode 100644 index 000000000..fabd5cc88 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strchr-1.ll.mlir @@ -0,0 +1,84 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello world\\n\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external constant @newlines("\0D\0A\00") {addr_space = 0 : i32} + llvm.mlir.global external @chp() {addr_space = 0 : i32} : !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @strchr(!llvm.ptr, i32) -> !llvm.ptr + llvm.func @test_simplify1() { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(119 : i32) : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.mlir.addressof @chp : !llvm.ptr + %5 = llvm.call @strchr(%1, %2) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.store %5, %4 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test_simplify2() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.mlir.constant(119 : i32) : i32 + %4 = llvm.mlir.zero : !llvm.ptr + %5 = llvm.mlir.addressof @chp : !llvm.ptr + %6 = llvm.call @strchr(%2, %3) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.store %6, %5 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test_simplify3() { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.mlir.addressof @chp : !llvm.ptr + %5 = llvm.call @strchr(%1, %2) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.store %5, %4 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test_simplify4(%arg0: i32) { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.addressof @chp : !llvm.ptr + %4 = llvm.call @strchr(%1, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.store %4, %3 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test_simplify5() { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(65280 : i32) : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.mlir.addressof @chp : !llvm.ptr + %5 = llvm.call @strchr(%1, %2) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.store %5, %4 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test_simplify6(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.addressof @chp : !llvm.ptr + %3 = llvm.call @strchr(%arg0, %0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.store %3, %2 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test_simplify7(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant("\0D\0A\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @newlines : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.call @strchr(%1, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + %4 = llvm.icmp "ne" %3, %2 : !llvm.ptr + llvm.return %4 : i1 + } + llvm.func @test1(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.call @strchr(%arg0, %arg1) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test2(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.call @strchr(%arg0, %arg1) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/strchr-2.ll.mlir b/test/LLVMDialect/InstCombine/strchr-2.ll.mlir index b61c73e6e..4321ecf78 100644 --- a/test/LLVMDialect/InstCombine/strchr-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/strchr-2.ll.mlir @@ -1,19 +1,15 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello", type = !llvm.array<14 x i8>, value = "hello world\\n\00"} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "chr", type = i8, value = 0 : i8} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strchr", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @chr} : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 119 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1) {callee = @strchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> i8 - "llvm.store"(%5, %0) : (i8, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_nosimplify1", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello world\\n\00") {addr_space = 0 : i32} + llvm.mlir.global external @chr(0 : i8) {addr_space = 0 : i32} : i8 + llvm.func @strchr(!llvm.ptr, i32) -> i8 + llvm.func @test_nosimplify1() { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(119 : i32) : i32 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.mlir.addressof @chr : !llvm.ptr + %5 = llvm.call @strchr(%1, %2) : (!llvm.ptr, i32) -> i8 + llvm.store %5, %4 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strchr-3.ll.mlir b/test/LLVMDialect/InstCombine/strchr-3.ll.mlir new file mode 100644 index 000000000..78db2f419 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strchr-3.ll.mlir @@ -0,0 +1,55 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @s1("\01\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s11("\01\01\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s111("\01\01\01\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s000(dense<0> : tensor<4xi8>) {addr_space = 0 : i32} : !llvm.array<4 x i8> + llvm.mlir.global external constant @s11102("\01\01\01\00\02\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s21111("\02\01\01\01\01\00") {addr_space = 0 : i32} + llvm.func @strchr(!llvm.ptr, i32) -> !llvm.ptr + llvm.func @fold_strchr_s1_C(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @s1 : !llvm.ptr + %2 = llvm.call @strchr(%1, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @fold_strchr_s11_C(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\00") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @s11 : !llvm.ptr + %2 = llvm.call @strchr(%1, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @fold_strchr_s111_C(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s111 : !llvm.ptr + %2 = llvm.call @strchr(%1, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @fold_strchr_s000_C(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.addressof @s000 : !llvm.ptr + %3 = llvm.call @strchr(%2, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @xform_strchr_s21111_C(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\02\01\01\01\01\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @s21111 : !llvm.ptr + %2 = llvm.call @strchr(%1, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @fold_strchr_s21111p1_C(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\02\01\01\01\01\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @s21111 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.getelementptr inbounds %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<6 x i8> + %5 = llvm.call @strchr(%4, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @fold_strchr_s11102_C(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("\01\01\01\00\02\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @s11102 : !llvm.ptr + %2 = llvm.call @strchr(%1, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/strchr-4.ll.mlir b/test/LLVMDialect/InstCombine/strchr-4.ll.mlir new file mode 100644 index 000000000..28ad85422 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strchr-4.ll.mlir @@ -0,0 +1,35 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a5("12345") {addr_space = 0 : i32} + llvm.func @strchr(!llvm.ptr, i32) -> !llvm.ptr + llvm.func @fold_strchr_s_c_eq_s(%arg0: !llvm.ptr, %arg1: i32) -> i1 { + %0 = llvm.call @strchr(%arg0, %arg1) : (!llvm.ptr, i32) -> !llvm.ptr + %1 = llvm.icmp "eq" %0, %arg0 : !llvm.ptr + llvm.return %1 : i1 + } + llvm.func @fold_strchr_s_c_neq_s(%arg0: !llvm.ptr, %arg1: i32) -> i1 { + %0 = llvm.call @strchr(%arg0, %arg1) : (!llvm.ptr, i32) -> !llvm.ptr + %1 = llvm.icmp "ne" %0, %arg0 : !llvm.ptr + llvm.return %1 : i1 + } + llvm.func @fold_strchr_s_nul_eqz(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.call @strchr(%arg0, %0) : (!llvm.ptr, i32) -> !llvm.ptr + %3 = llvm.icmp "eq" %2, %1 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @fold_strchr_s_nul_nez(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.call @strchr(%arg0, %0) : (!llvm.ptr, i32) -> !llvm.ptr + %3 = llvm.icmp "ne" %2, %1 : !llvm.ptr + llvm.return %3 : i1 + } + llvm.func @fold_strchr_a_c_eq_a(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.call @strchr(%1, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + %3 = llvm.icmp "eq" %2, %1 : !llvm.ptr + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/strcmp-1.ll.mlir b/test/LLVMDialect/InstCombine/strcmp-1.ll.mlir new file mode 100644 index 000000000..541c1900a --- /dev/null +++ b/test/LLVMDialect/InstCombine/strcmp-1.ll.mlir @@ -0,0 +1,66 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hell("hell\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @bell("bell\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.func @strcmp(!llvm.ptr, !llvm.ptr) -> i32 + llvm.func @test1(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @strcmp(%2, %arg0) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %3 : i32 + } + llvm.func @test2(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @strcmp(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %3 : i32 + } + llvm.func @test3() -> i32 { + %0 = llvm.mlir.constant("hell\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @hell : !llvm.ptr + %2 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %3 = llvm.mlir.addressof @hello : !llvm.ptr + %4 = llvm.call @strcmp(%1, %3) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %4 : i32 + } + llvm.func @test4() -> i32 { + %0 = llvm.mlir.constant("hell\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @hell : !llvm.ptr + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %4 = llvm.mlir.addressof @null : !llvm.ptr + %5 = llvm.call @strcmp(%1, %4) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %5 : i32 + } + llvm.func @test5(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant("hell\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @hell : !llvm.ptr + %2 = llvm.mlir.constant("bell\00") : !llvm.array<5 x i8> + %3 = llvm.mlir.addressof @bell : !llvm.ptr + %4 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %5 = llvm.mlir.addressof @hello : !llvm.ptr + %6 = llvm.select %arg0, %1, %3 : i1, !llvm.ptr + %7 = llvm.call @strcmp(%5, %6) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %7 : i32 + } + llvm.func @test6(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.call @strcmp(%arg0, %arg0) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %0 : i32 + } + llvm.func @test7(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant("hell\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @hell : !llvm.ptr + %2 = llvm.mlir.constant("bell\00") : !llvm.array<5 x i8> + %3 = llvm.mlir.addressof @bell : !llvm.ptr + %4 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %5 = llvm.mlir.addressof @hello : !llvm.ptr + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.select %arg0, %1, %3 : i1, !llvm.ptr + %8 = llvm.call @strcmp(%5, %7) : (!llvm.ptr, !llvm.ptr) -> i32 + %9 = llvm.icmp "eq" %8, %6 : i32 + llvm.return %9 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/strcmp-2.ll.mlir b/test/LLVMDialect/InstCombine/strcmp-2.ll.mlir index b50f981d9..e5031655e 100644 --- a/test/LLVMDialect/InstCombine/strcmp-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/strcmp-2.ll.mlir @@ -1,18 +1,13 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello", type = !llvm.array<6 x i8>, value = "hello\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hell", type = !llvm.array<5 x i8>, value = "hell\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strcmp", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @hell} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.getelementptr"(%0, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%3, %4) {callee = @strcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i16 - "llvm.return"(%5) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "test_nosimplify", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hell("hell\00") {addr_space = 0 : i32} + llvm.func @strcmp(!llvm.ptr, !llvm.ptr) -> i16 + llvm.func @test_nosimplify() -> i16 { + %0 = llvm.mlir.constant("hell\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @hell : !llvm.ptr + %2 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %3 = llvm.mlir.addressof @hello : !llvm.ptr + %4 = llvm.call @strcmp(%1, %3) : (!llvm.ptr, !llvm.ptr) -> i16 + llvm.return %4 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/strcmp-3.ll.mlir b/test/LLVMDialect/InstCombine/strcmp-3.ll.mlir new file mode 100644 index 000000000..6e08a3c8c --- /dev/null +++ b/test/LLVMDialect/InstCombine/strcmp-3.ll.mlir @@ -0,0 +1,159 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a5() {addr_space = 0 : i32} : !llvm.array<5 x array<4 x i8>> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %5 = llvm.insertvalue %3, %4[0] : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %3, %5[1] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %2, %6[2] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %1, %7[3] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[4] : !llvm.array<5 x array<4 x i8>> + llvm.return %9 : !llvm.array<5 x array<4 x i8>> + } + llvm.func @strcmp(!llvm.ptr, !llvm.ptr) -> i32 + llvm.func @fold_strcmp_a5i0_a5i1_to_0() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %5 = llvm.insertvalue %3, %4[0] : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %3, %5[1] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %2, %6[2] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %1, %7[3] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[4] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.mlir.addressof @a5 : !llvm.ptr + %11 = llvm.mlir.constant(0 : i64) : i64 + %12 = llvm.mlir.constant(1 : i64) : i64 + %13 = llvm.getelementptr %10[%11, %12, %11] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %14 = llvm.call @strcmp(%10, %13) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %14 : i32 + } + llvm.func @call_strcmp_a5i0_a5iI(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %5 = llvm.insertvalue %3, %4[0] : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %3, %5[1] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %2, %6[2] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %1, %7[3] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[4] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.mlir.addressof @a5 : !llvm.ptr + %11 = llvm.mlir.constant(0 : i64) : i64 + %12 = llvm.getelementptr %10[%11, %arg0, %11] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %13 = llvm.call @strcmp(%10, %12) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %13 : i32 + } + llvm.func @call_strcmp_a5iI_a5i0(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %5 = llvm.insertvalue %3, %4[0] : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %3, %5[1] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %2, %6[2] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %1, %7[3] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[4] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.mlir.addressof @a5 : !llvm.ptr + %11 = llvm.mlir.constant(0 : i64) : i64 + %12 = llvm.getelementptr %10[%11, %arg0, %11] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %13 = llvm.call @strcmp(%12, %10) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %13 : i32 + } + llvm.func @fold_strcmp_a5i0_a5i1_p1_to_0() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %5 = llvm.insertvalue %3, %4[0] : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %3, %5[1] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %2, %6[2] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %1, %7[3] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[4] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.mlir.addressof @a5 : !llvm.ptr + %11 = llvm.mlir.constant(0 : i64) : i64 + %12 = llvm.mlir.constant(1 : i64) : i64 + %13 = llvm.getelementptr %10[%11, %12, %12] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %14 = llvm.call @strcmp(%10, %13) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %14 : i32 + } + llvm.func @call_strcmp_a5i0_a5i1_pI(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %5 = llvm.insertvalue %3, %4[0] : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %3, %5[1] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %2, %6[2] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %1, %7[3] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[4] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.mlir.addressof @a5 : !llvm.ptr + %11 = llvm.mlir.constant(0 : i64) : i64 + %12 = llvm.mlir.constant(1 : i64) : i64 + %13 = llvm.getelementptr %10[%11, %12, %arg0] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %14 = llvm.call @strcmp(%10, %13) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %14 : i32 + } + llvm.func @fold_strcmp_a5i0_p1_a5i1_to_0() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %5 = llvm.insertvalue %3, %4[0] : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %3, %5[1] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %2, %6[2] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %1, %7[3] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[4] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.mlir.addressof @a5 : !llvm.ptr + %11 = llvm.mlir.constant(0 : i64) : i64 + %12 = llvm.mlir.constant(1 : i64) : i64 + %13 = llvm.getelementptr %10[%11, %11, %12] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %14 = llvm.getelementptr %10[%11, %12, %11] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strcmp(%13, %14) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %15 : i32 + } + llvm.func @fold_strcmp_a5i0_a5i2_to_0() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %5 = llvm.insertvalue %3, %4[0] : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %3, %5[1] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %2, %6[2] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %1, %7[3] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[4] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.mlir.addressof @a5 : !llvm.ptr + %11 = llvm.mlir.constant(0 : i64) : i64 + %12 = llvm.mlir.constant(2 : i64) : i64 + %13 = llvm.getelementptr %10[%11, %12, %11] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %14 = llvm.call @strcmp(%10, %13) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %14 : i32 + } + llvm.func @fold_strcmp_a5i2_a5i0_to_m1() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %5 = llvm.insertvalue %3, %4[0] : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %3, %5[1] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %2, %6[2] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %1, %7[3] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[4] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.mlir.addressof @a5 : !llvm.ptr + %11 = llvm.mlir.constant(0 : i64) : i64 + %12 = llvm.mlir.constant(2 : i64) : i64 + %13 = llvm.getelementptr %10[%11, %12, %11] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %14 = llvm.call @strcmp(%13, %10) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %14 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/strcmp-4.ll.mlir b/test/LLVMDialect/InstCombine/strcmp-4.ll.mlir new file mode 100644 index 000000000..fd5682323 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strcmp-4.ll.mlir @@ -0,0 +1,16 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @s9("123456789\00") {addr_space = 0 : i32} + llvm.func @strcmp(!llvm.ptr, !llvm.ptr) -> i32 + llvm.func @fold_strcmp_s3_x_s4_s3(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant("123456789\00") : !llvm.array<10 x i8> + %1 = llvm.mlir.addressof @s9 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(6 : i64) : i64 + %4 = llvm.mlir.constant(5 : i64) : i64 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<10 x i8> + %6 = llvm.getelementptr %1[%2, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<10 x i8> + %7 = llvm.select %arg0, %5, %6 : i1, !llvm.ptr + %8 = llvm.call @strcmp(%7, %5) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %8 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/strcmp-memcmp.ll.mlir b/test/LLVMDialect/InstCombine/strcmp-memcmp.ll.mlir new file mode 100644 index 000000000..683a0d946 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strcmp-memcmp.ll.mlir @@ -0,0 +1,352 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @key("key\00") {addr_space = 0 : i32, alignment = 1 : i64} + llvm.mlir.global external constant @abc("abc\00de\00\00") {addr_space = 0 : i32, alignment = 1 : i64} + llvm.func @use(i32) + llvm.func @strcmp_memcmp(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strcmp(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "eq" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strcmp(!llvm.ptr {llvm.nocapture}, !llvm.ptr {llvm.nocapture}) -> i32 + llvm.func @strcmp_memcmp2(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strcmp(%1, %arg0) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "eq" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strcmp_memcmp3(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strcmp(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "ne" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strcmp_memcmp4(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strcmp(%1, %arg0) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "ne" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strcmp_memcmp5(%arg0: !llvm.ptr {llvm.dereferenceable = 5 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strcmp(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "eq" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strcmp_memcmp6(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strcmp(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "sgt" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strcmp_memcmp7(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strcmp(%1, %arg0) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "slt" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strcmp_memcmp8(%arg0: !llvm.ptr {llvm.dereferenceable = 4 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strcmp(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "eq" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strcmp_memcmp9(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("abc\00de\00\00") : !llvm.array<8 x i8> + %1 = llvm.mlir.addressof @abc : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strcmp(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "eq" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strncmp_memcmp(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "eq" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp(!llvm.ptr {llvm.nocapture}, !llvm.ptr {llvm.nocapture}, i64) -> i32 + llvm.func @strncmp_memcmp2(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(11 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "ne" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp3(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(11 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "eq" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp4(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "eq" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp5(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "eq" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp6(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "ne" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp7(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(4 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "eq" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp8(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(3 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "eq" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp9(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "sgt" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp10(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "slt" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp11(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(12 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "eq" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp12(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(12 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "eq" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp13(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("abc\00de\00\00") : !llvm.array<8 x i8> + %1 = llvm.mlir.addressof @abc : !llvm.ptr + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "eq" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp14(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("abc\00de\00\00") : !llvm.array<8 x i8> + %1 = llvm.mlir.addressof @abc : !llvm.ptr + %2 = llvm.mlir.constant(12 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "eq" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strcmp_memcmp_bad(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.call @strcmp(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "sgt" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strcmp_memcmp_bad2(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.call @strcmp(%1, %arg0) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "slt" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strcmp_memcmp_bad3(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.call @strcmp(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %2 : i32 + } + llvm.func @strcmp_memcmp_bad4(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strcmp(%1, %arg0) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "eq" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strcmp_memcmp_bad5(%arg0: !llvm.ptr {llvm.dereferenceable = 3 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strcmp(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "eq" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strcmp_memcmp_bad6(%arg0: !llvm.ptr {llvm.dereferenceable = 4 : i64}, %arg1: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @strcmp(%arg0, %arg1) : (!llvm.ptr, !llvm.ptr) -> i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + %3 = llvm.zext %2 : i1 to i32 + llvm.return %3 : i32 + } + llvm.func @strcmp_memcmp_bad7(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strcmp(%1, %arg0) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "eq" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strcmp_memcmp_bad8(%arg0: !llvm.ptr {llvm.dereferenceable = 4 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strcmp(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.call @use(%3) : (i32) -> () + llvm.return %2 : i32 + } + llvm.func @strncmp_memcmp_bad(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.call @strncmp(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "sgt" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp_bad1(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.call @strncmp(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "slt" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp_bad2(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}, %arg1: i64) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.call @strncmp(%1, %arg0, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %4 = llvm.icmp "slt" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @strncmp_memcmp_bad3(%arg0: !llvm.ptr {llvm.nocapture, llvm.readonly}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%1, %arg0, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %5 = llvm.icmp "eq" %4, %3 : i32 + %6 = llvm.zext %5 : i1 to i32 + llvm.return %6 : i32 + } + llvm.func @strncmp_memcmp_bad4(%arg0: !llvm.ptr {llvm.dereferenceable = 4 : i64}) -> i32 attributes {passthrough = ["nofree", "nosync"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(2 : i64) : i64 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.call @strncmp(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.call @use(%4) : (i32) -> () + llvm.return %3 : i32 + } + llvm.func @strcmp_memcmp_msan(%arg0: !llvm.ptr {llvm.dereferenceable = 12 : i64}) -> i32 attributes {passthrough = ["sanitize_memory"]} { + %0 = llvm.mlir.constant("key\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @key : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strcmp(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> i32 + %4 = llvm.icmp "eq" %3, %2 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @memcmp(!llvm.ptr {llvm.nocapture}, !llvm.ptr {llvm.nocapture}, i64) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/strcpy-1.ll.mlir b/test/LLVMDialect/InstCombine/strcpy-1.ll.mlir new file mode 100644 index 000000000..0faccfea3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strcpy-1.ll.mlir @@ -0,0 +1,49 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global common @a(dense<0> : tensor<32xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i8> + llvm.mlir.global common @b(dense<0> : tensor<32xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i8> + llvm.func @strcpy(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @test_simplify1() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.call @strcpy(%2, %4) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return + } + llvm.func @test_simplify2() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.call @strcpy(%2, %2) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @test_simplify3(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.call @strcpy(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return + } + llvm.func @test_no_simplify1() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.call @strcpy(%2, %3) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @test_no_simplify2(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.call @strcpy(%arg0, %arg1) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test_no_incompatible_attr() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.call @strcpy(%2, %4) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strcpy-2.ll.mlir b/test/LLVMDialect/InstCombine/strcpy-2.ll.mlir new file mode 100644 index 000000000..5e6196c37 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strcpy-2.ll.mlir @@ -0,0 +1,14 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global common @a(dense<0> : tensor<32xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i8> + llvm.func @strcpy(!llvm.ptr, !llvm.ptr) -> i16 + llvm.func @test_no_simplify1() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.call @strcpy(%2, %4) : (!llvm.ptr, !llvm.ptr) -> i16 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strcpy-nonzero-as.ll.mlir b/test/LLVMDialect/InstCombine/strcpy-nonzero-as.ll.mlir index 0bbe8a5e4..8182a2149 100644 --- a/test/LLVMDialect/InstCombine/strcpy-nonzero-as.ll.mlir +++ b/test/LLVMDialect/InstCombine/strcpy-nonzero-as.ll.mlir @@ -1,52 +1,37 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = "str", type = !llvm.array<17 x i8>, value = "exactly 16 chars\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strcpy", type = !llvm.func (ptr, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "stpcpy", type = !llvm.func (ptr, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strncpy", type = !llvm.func (ptr, ptr, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "stpncpy", type = !llvm.func (ptr, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @str} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%arg0, %2) {callee = @strcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_strcpy_to_memcpy", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @str} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%arg0, %2) {callee = @stpcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_stpcpy_to_memcpy", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @stpcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_stpcpy_to_strcpy", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 17 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @str} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %0) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_strncpy_to_memcpy", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 17 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @str} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %0) {callee = @stpncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_stpncpy_to_memcpy", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<[128, 128, 128, 64]> : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.global_memory_space", 200 : ui64>, #dlti.dl_entry<"dlti.program_memory_space", 200 : ui64>, #dlti.dl_entry<"dlti.alloca_memory_space", 200 : ui64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private unnamed_addr constant @str("exactly 16 chars\00") {addr_space = 200 : i32, alignment = 1 : i64, dso_local} + llvm.func @strcpy(!llvm.ptr<200>, !llvm.ptr<200>) -> !llvm.ptr<200> + llvm.func @stpcpy(!llvm.ptr<200>, !llvm.ptr<200>) -> !llvm.ptr<200> + llvm.func @strncpy(!llvm.ptr<200>, !llvm.ptr<200>, i64) -> !llvm.ptr<200> + llvm.func @stpncpy(!llvm.ptr<200>, !llvm.ptr<200>, i64) -> !llvm.ptr<200> + llvm.func @test_strcpy_to_memcpy(%arg0: !llvm.ptr<200>) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant("exactly 16 chars\00") : !llvm.array<17 x i8> + %1 = llvm.mlir.addressof @str : !llvm.ptr<200> + %2 = llvm.call @strcpy(%arg0, %1) : (!llvm.ptr<200>, !llvm.ptr<200>) -> !llvm.ptr<200> + llvm.return + } + llvm.func @test_stpcpy_to_memcpy(%arg0: !llvm.ptr<200>) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant("exactly 16 chars\00") : !llvm.array<17 x i8> + %1 = llvm.mlir.addressof @str : !llvm.ptr<200> + %2 = llvm.call @stpcpy(%arg0, %1) : (!llvm.ptr<200>, !llvm.ptr<200>) -> !llvm.ptr<200> + llvm.return + } + llvm.func @test_stpcpy_to_strcpy(%arg0: !llvm.ptr<200>, %arg1: !llvm.ptr<200>) attributes {passthrough = ["nounwind"]} { + %0 = llvm.call @stpcpy(%arg0, %arg1) : (!llvm.ptr<200>, !llvm.ptr<200>) -> !llvm.ptr<200> + llvm.return + } + llvm.func @test_strncpy_to_memcpy(%arg0: !llvm.ptr<200>) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant("exactly 16 chars\00") : !llvm.array<17 x i8> + %1 = llvm.mlir.addressof @str : !llvm.ptr<200> + %2 = llvm.mlir.constant(17 : i64) : i64 + %3 = llvm.call @strncpy(%arg0, %1, %2) : (!llvm.ptr<200>, !llvm.ptr<200>, i64) -> !llvm.ptr<200> + llvm.return + } + llvm.func @test_stpncpy_to_memcpy(%arg0: !llvm.ptr<200>) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant("exactly 16 chars\00") : !llvm.array<17 x i8> + %1 = llvm.mlir.addressof @str : !llvm.ptr<200> + %2 = llvm.mlir.constant(17 : i64) : i64 + %3 = llvm.call @stpncpy(%arg0, %1, %2) : (!llvm.ptr<200>, !llvm.ptr<200>, i64) -> !llvm.ptr<200> + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strcpy_chk-1.ll.mlir b/test/LLVMDialect/InstCombine/strcpy_chk-1.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/strcpy_chk-2.ll.mlir b/test/LLVMDialect/InstCombine/strcpy_chk-2.ll.mlir new file mode 100644 index 000000000..85923095d --- /dev/null +++ b/test/LLVMDialect/InstCombine/strcpy_chk-2.ll.mlir @@ -0,0 +1,15 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @a(dense<0> : tensor<60xi16>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<60 x i16> + llvm.mlir.global private constant @".str"("abcdefg\00") {addr_space = 0 : i32, dso_local} + llvm.func @test_no_simplify() { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi16>) : !llvm.array<60 x i16> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("abcdefg\00") : !llvm.array<8 x i8> + %4 = llvm.mlir.addressof @".str" : !llvm.ptr + %5 = llvm.mlir.constant(8 : i32) : i32 + %6 = llvm.call @__strcpy_chk(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i32) -> i16 + llvm.return + } + llvm.func @__strcpy_chk(!llvm.ptr, !llvm.ptr, i32) -> i16 +} diff --git a/test/LLVMDialect/InstCombine/strcpy_chk-64.ll.mlir b/test/LLVMDialect/InstCombine/strcpy_chk-64.ll.mlir index 6e14ae4f1..277213b6b 100644 --- a/test/LLVMDialect/InstCombine/strcpy_chk-64.ll.mlir +++ b/test/LLVMDialect/InstCombine/strcpy_chk-64.ll.mlir @@ -1,29 +1,20 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %arg0, %0) {callee = @__strcpy_chk, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%4) {callee = @func2, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "func", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 32 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %3 = "llvm.alloca"(%2) : (i32) -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %arg0, %0) {callee = @__strcpy_chk, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%4) {callee = @func2, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "func_no_null_opt", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "__strcpy_chk", type = !llvm.func (ptr, ptr, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "func2", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @func(%arg0: !llvm.ptr) attributes {passthrough = ["nounwind", "ssp"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 16 : i64} : (i32) -> !llvm.ptr + %3 = llvm.call @__strcpy_chk(%2, %arg0, %1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @func2(%2) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @func_no_null_opt(%arg0: !llvm.ptr) attributes {passthrough = ["nounwind", "null_pointer_is_valid", "ssp"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.alloca %0 x !llvm.array<32 x i8> {alignment = 16 : i64} : (i32) -> !llvm.ptr + %3 = llvm.call @__strcpy_chk(%2, %arg0, %1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @func2(%2) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @__strcpy_chk(!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr attributes {passthrough = ["nounwind"]} + llvm.func @func2(!llvm.ptr) +} diff --git a/test/LLVMDialect/InstCombine/strcspn-1.ll.mlir b/test/LLVMDialect/InstCombine/strcspn-1.ll.mlir new file mode 100644 index 000000000..bed8eeafc --- /dev/null +++ b/test/LLVMDialect/InstCombine/strcspn-1.ll.mlir @@ -0,0 +1,32 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @abcba("abcba\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @abc("abc\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.func @strcspn(!llvm.ptr, !llvm.ptr) -> i64 + llvm.func @test_simplify1(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @strcspn(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> i64 + llvm.return %3 : i64 + } + llvm.func @test_simplify2(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @strcspn(%2, %arg0) : (!llvm.ptr, !llvm.ptr) -> i64 + llvm.return %3 : i64 + } + llvm.func @test_simplify3() -> i64 { + %0 = llvm.mlir.constant("abcba\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @abcba : !llvm.ptr + %2 = llvm.mlir.constant("abc\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.addressof @abc : !llvm.ptr + %4 = llvm.call @strcspn(%1, %3) : (!llvm.ptr, !llvm.ptr) -> i64 + llvm.return %4 : i64 + } + llvm.func @test_no_simplify1(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i64 { + %0 = llvm.call @strcspn(%arg0, %arg1) : (!llvm.ptr, !llvm.ptr) -> i64 + llvm.return %0 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/strcspn-2.ll.mlir b/test/LLVMDialect/InstCombine/strcspn-2.ll.mlir new file mode 100644 index 000000000..4cc9f9585 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strcspn-2.ll.mlir @@ -0,0 +1,11 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.func @strcspn(!llvm.ptr, !llvm.ptr) -> f64 + llvm.func @test_no_simplify1(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @strcspn(%2, %arg0) : (!llvm.ptr, !llvm.ptr) -> f64 + llvm.return %3 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/strict-sub-underflow-check-to-comparison-of-sub-operands.ll.mlir b/test/LLVMDialect/InstCombine/strict-sub-underflow-check-to-comparison-of-sub-operands.ll.mlir index 98e47cdd3..54e102f4c 100644 --- a/test/LLVMDialect/InstCombine/strict-sub-underflow-check-to-comparison-of-sub-operands.ll.mlir +++ b/test/LLVMDialect/InstCombine/strict-sub-underflow-check-to-comparison-of-sub-operands.ll.mlir @@ -1,68 +1,57 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.assume", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen8", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.icmp"(%arg1, %0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.call"(%1) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %2 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%2) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %3 = "llvm.icmp"(%2, %arg0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.icmp"(%arg1, %0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.call"(%1) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %2 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%2) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %3 = "llvm.icmp"(%2, %arg0) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.call"(%1) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %2 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %3 = "llvm.sub"(%2, %arg0) : (i8, i8) -> i8 - "llvm.call"(%3) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %4 = "llvm.icmp"(%2, %3) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.call"(%1) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %2 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %3 = "llvm.sub"(%2, %arg0) : (i8, i8) -> i8 - "llvm.call"(%3) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %4 = "llvm.icmp"(%2, %3) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n4_maybezero", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i8} : () -> i8 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.call"(%1) {callee = @llvm.assume, fastmathFlags = #llvm.fastmath<>} : (i1) -> () - %2 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%2) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %3 = "llvm.icmp"(%2, %arg0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n5_wrongnonzero", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @gen8() -> i8 + llvm.func @use8(i8) + llvm.func @t0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg1, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ult" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @t1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg1, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "uge" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @t2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.sub %2, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ugt" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @t3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "slt" %arg0, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.sub %2, %arg0 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.icmp "ule" %2, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @n4_maybezero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "ult" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n5_wrongnonzero(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.icmp "sgt" %arg0, %0 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ult" %2, %arg0 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/strlcpy-1.ll.mlir b/test/LLVMDialect/InstCombine/strlcpy-1.ll.mlir index b792aeb68..1ff697184 100644 --- a/test/LLVMDialect/InstCombine/strlcpy-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/strlcpy-1.ll.mlir @@ -1,147 +1,134 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "s4", type = !llvm.array<5 x i8>, value = "1234\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a5", type = !llvm.array<5 x i8>, value = "12345"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strlcpy", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sink", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %5 = "llvm.mlir.addressof"() {global_name = @s4} : () -> !llvm.ptr> - %6 = "llvm.getelementptr"(%5, %4, %3) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %7 = "llvm.call"(%arg0, %6, %2) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %7) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %8 = "llvm.call"(%arg0, %6, %1) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %8) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %9 = "llvm.call"(%arg0, %6, %0) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %9) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strlcpy_s0", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %6 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %7 = "llvm.mlir.addressof"() {global_name = @s4} : () -> !llvm.ptr> - %8 = "llvm.getelementptr"(%7, %6, %5) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %9 = "llvm.call"(%arg0, %8, %4) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %9) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %10 = "llvm.call"(%arg0, %8, %3) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %10) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %11 = "llvm.call"(%arg0, %8, %2) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %11) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %12 = "llvm.call"(%arg0, %8, %1) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %12) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %13 = "llvm.call"(%arg0, %8, %0) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %13) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strlcpy_s1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %6 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %7 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %8 = "llvm.mlir.addressof"() {global_name = @s4} : () -> !llvm.ptr> - %9 = "llvm.getelementptr"(%8, %7, %7) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %10 = "llvm.call"(%arg0, %9, %6) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %10) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %11 = "llvm.call"(%arg0, %9, %5) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %11) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %12 = "llvm.call"(%arg0, %9, %4) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %12) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %13 = "llvm.call"(%arg0, %9, %3) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %13) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %14 = "llvm.call"(%arg0, %9, %2) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %14) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %15 = "llvm.call"(%arg0, %9, %1) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %15) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %16 = "llvm.call"(%arg0, %9, %1) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %16) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %17 = "llvm.call"(%arg0, %9, %0) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %17) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strlcpy_s5", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %3 = "llvm.call"(%arg0, %arg1, %2) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %3) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %4 = "llvm.call"(%arg0, %arg1, %1) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %4) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %5 = "llvm.call"(%0, %arg1, %1) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %5) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strlcpy_s_0", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @s4} : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @s4} : () -> !llvm.ptr> - %3 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %4 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %5 = "llvm.mlir.addressof"() {global_name = @s4} : () -> !llvm.ptr> - %6 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %7 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %8 = "llvm.call"(%arg0, %arg1, %7) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %8) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %9 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %9) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %10 = "llvm.or"(%arg2, %6) : (i64, i64) -> i64 - %11 = "llvm.call"(%arg0, %arg1, %10) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %11) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %12 = "llvm.getelementptr"(%5, %4, %3) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %13 = "llvm.call"(%arg0, %12, %arg2) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %13) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %14 = "llvm.getelementptr"(%2, %4, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %15 = "llvm.call"(%arg0, %14, %arg2) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %15) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %16 = "llvm.getelementptr"(%0, %4, %4) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %17 = "llvm.call"(%arg0, %16, %arg2) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %17) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "call_strlcpy_s0_n", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %5 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %6 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %7 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %8 = "llvm.getelementptr"(%7, %6, %6) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %9 = "llvm.call"(%arg0, %8, %5) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %9) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %10 = "llvm.call"(%arg0, %8, %4) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %10) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %11 = "llvm.call"(%arg0, %8, %3) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %11) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %12 = "llvm.call"(%arg0, %8, %2) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %12) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %13 = "llvm.call"(%arg0, %8, %1) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %13) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - %14 = "llvm.call"(%arg0, %8, %0) {callee = @strlcpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i64 - "llvm.call"(%arg0, %14) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strlcpy_a5", type = !llvm.func, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @s4("1234\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @a5("12345") {addr_space = 0 : i32} + llvm.func @strlcpy(!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.func @sink(!llvm.ptr, i64) + llvm.func @fold_strlcpy_s0(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @s4 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.mlir.constant(1 : i64) : i64 + %6 = llvm.mlir.constant(-1 : i64) : i64 + %7 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %8 = llvm.call @strlcpy(%arg0, %7, %4) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %8) : (!llvm.ptr, i64) -> () + %9 = llvm.call @strlcpy(%arg0, %7, %5) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %9) : (!llvm.ptr, i64) -> () + %10 = llvm.call @strlcpy(%arg0, %7, %6) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %10) : (!llvm.ptr, i64) -> () + llvm.return + } + llvm.func @fold_strlcpy_s1(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @s4 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.mlir.constant(1 : i64) : i64 + %6 = llvm.mlir.constant(2 : i64) : i64 + %7 = llvm.mlir.constant(3 : i64) : i64 + %8 = llvm.mlir.constant(-1 : i64) : i64 + %9 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %10 = llvm.call @strlcpy(%arg0, %9, %4) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %10) : (!llvm.ptr, i64) -> () + %11 = llvm.call @strlcpy(%arg0, %9, %5) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %11) : (!llvm.ptr, i64) -> () + %12 = llvm.call @strlcpy(%arg0, %9, %6) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %12) : (!llvm.ptr, i64) -> () + %13 = llvm.call @strlcpy(%arg0, %9, %7) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %13) : (!llvm.ptr, i64) -> () + %14 = llvm.call @strlcpy(%arg0, %9, %8) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %14) : (!llvm.ptr, i64) -> () + llvm.return + } + llvm.func @fold_strlcpy_s5(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @s4 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(2 : i64) : i64 + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.constant(4 : i64) : i64 + %7 = llvm.mlir.constant(5 : i64) : i64 + %8 = llvm.mlir.constant(-1 : i64) : i64 + %9 = llvm.call @strlcpy(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %9) : (!llvm.ptr, i64) -> () + %10 = llvm.call @strlcpy(%arg0, %1, %3) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %10) : (!llvm.ptr, i64) -> () + %11 = llvm.call @strlcpy(%arg0, %1, %4) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %11) : (!llvm.ptr, i64) -> () + %12 = llvm.call @strlcpy(%arg0, %1, %5) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %12) : (!llvm.ptr, i64) -> () + %13 = llvm.call @strlcpy(%arg0, %1, %6) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %13) : (!llvm.ptr, i64) -> () + %14 = llvm.call @strlcpy(%arg0, %1, %7) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %14) : (!llvm.ptr, i64) -> () + %15 = llvm.call @strlcpy(%arg0, %1, %7) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %15) : (!llvm.ptr, i64) -> () + %16 = llvm.call @strlcpy(%arg0, %1, %8) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %16) : (!llvm.ptr, i64) -> () + llvm.return + } + llvm.func @fold_strlcpy_s_0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64) { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.call @strlcpy(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %3) : (!llvm.ptr, i64) -> () + %4 = llvm.call @strlcpy(%arg0, %arg1, %1) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %4) : (!llvm.ptr, i64) -> () + %5 = llvm.call @strlcpy(%2, %arg1, %1) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %5) : (!llvm.ptr, i64) -> () + llvm.return + } + llvm.func @call_strlcpy_s0_n(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64) { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %3 = llvm.mlir.addressof @s4 : !llvm.ptr + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(4 : i32) : i32 + %6 = llvm.mlir.constant(3 : i32) : i32 + %7 = llvm.call @strlcpy(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %7) : (!llvm.ptr, i64) -> () + %8 = llvm.call @strlcpy(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %8) : (!llvm.ptr, i64) -> () + %9 = llvm.or %arg2, %1 : i64 + %10 = llvm.call @strlcpy(%arg0, %arg1, %9) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %10) : (!llvm.ptr, i64) -> () + %11 = llvm.getelementptr %3[%4, %5] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %12 = llvm.call @strlcpy(%arg0, %11, %arg2) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %12) : (!llvm.ptr, i64) -> () + %13 = llvm.getelementptr %3[%4, %6] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %14 = llvm.call @strlcpy(%arg0, %13, %arg2) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %14) : (!llvm.ptr, i64) -> () + %15 = llvm.call @strlcpy(%arg0, %3, %arg2) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %15) : (!llvm.ptr, i64) -> () + llvm.return + } + llvm.func @fold_strlcpy_a5(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(2 : i64) : i64 + %5 = llvm.mlir.constant(5 : i64) : i64 + %6 = llvm.mlir.constant(6 : i64) : i64 + %7 = llvm.mlir.constant(9 : i64) : i64 + %8 = llvm.call @strlcpy(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %8) : (!llvm.ptr, i64) -> () + %9 = llvm.call @strlcpy(%arg0, %1, %3) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %9) : (!llvm.ptr, i64) -> () + %10 = llvm.call @strlcpy(%arg0, %1, %4) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %10) : (!llvm.ptr, i64) -> () + %11 = llvm.call @strlcpy(%arg0, %1, %5) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %11) : (!llvm.ptr, i64) -> () + %12 = llvm.call @strlcpy(%arg0, %1, %6) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %12) : (!llvm.ptr, i64) -> () + %13 = llvm.call @strlcpy(%arg0, %1, %7) : (!llvm.ptr, !llvm.ptr, i64) -> i64 + llvm.call @sink(%arg0, %13) : (!llvm.ptr, i64) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strlen-1.ll.mlir b/test/LLVMDialect/InstCombine/strlen-1.ll.mlir new file mode 100644 index 000000000..0c811f527 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strlen-1.ll.mlir @@ -0,0 +1,192 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @longer("longer\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external constant @null_hello("\00hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @nullstring(0 : i8) {addr_space = 0 : i32} : i8 + llvm.mlir.global common @a(dense<0> : tensor<32xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i8> + llvm.mlir.global external constant @null_hello_mid("hello wor\00ld\00") {addr_space = 0 : i32} + llvm.func @strlen(!llvm.ptr) -> i32 + llvm.func @test_simplify1() -> i32 { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.call @strlen(%1) : (!llvm.ptr) -> i32 + llvm.return %2 : i32 + } + llvm.func @test_simplify2() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @strlen(%2) : (!llvm.ptr) -> i32 + llvm.return %3 : i32 + } + llvm.func @test_simplify3() -> i32 { + %0 = llvm.mlir.constant("\00hello\00") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @null_hello : !llvm.ptr + %2 = llvm.call @strlen(%1) : (!llvm.ptr) -> i32 + llvm.return %2 : i32 + } + llvm.func @test_simplify4() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.addressof @nullstring : !llvm.ptr + %2 = llvm.call @strlen(%1) : (!llvm.ptr) -> i32 + llvm.return %2 : i32 + } + llvm.func @test_simplify5() -> i1 { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strlen(%1) : (!llvm.ptr) -> i32 + %4 = llvm.icmp "eq" %3, %2 : i32 + llvm.return %4 : i1 + } + llvm.func @test_simplify6(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @strlen(%arg0) : (!llvm.ptr) -> i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @test_simplify7() -> i1 { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.call @strlen(%1) : (!llvm.ptr) -> i32 + %4 = llvm.icmp "ne" %3, %2 : i32 + llvm.return %4 : i1 + } + llvm.func @test_simplify8(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @strlen(%arg0) : (!llvm.ptr) -> i32 + %2 = llvm.icmp "ne" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @test_simplify9(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant("longer\00") : !llvm.array<7 x i8> + %3 = llvm.mlir.addressof @longer : !llvm.ptr + %4 = llvm.select %arg0, %1, %3 : i1, !llvm.ptr + %5 = llvm.call @strlen(%4) : (!llvm.ptr) -> i32 + llvm.return %5 : i32 + } + llvm.func @test_simplify10_inbounds(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<6 x i8> + %4 = llvm.call @strlen(%3) : (!llvm.ptr) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_simplify10_no_inbounds(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.getelementptr %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<6 x i8> + %4 = llvm.call @strlen(%3) : (!llvm.ptr) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_simplify11(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant("hello wor\00ld\00") : !llvm.array<13 x i8> + %2 = llvm.mlir.addressof @null_hello_mid : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.getelementptr inbounds %2[%3, %4] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<13 x i8> + %6 = llvm.call @strlen(%5) : (!llvm.ptr) -> i32 + llvm.return %6 : i32 + } + llvm.func @test_no_simplify1() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.call @strlen(%2) : (!llvm.ptr) -> i32 + llvm.return %3 : i32 + } + llvm.func @test_no_simplify2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant("\00hello\00") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @null_hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<7 x i8> + %4 = llvm.call @strlen(%3) : (!llvm.ptr) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_no_simplify2_no_null_opt(%arg0: i32) -> i32 attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.constant("\00hello\00") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @null_hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<7 x i8> + %4 = llvm.call @strlen(%3) : (!llvm.ptr) -> i32 + llvm.return %4 : i32 + } + llvm.func @test_no_simplify3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant("hello wor\00ld\00") : !llvm.array<13 x i8> + %2 = llvm.mlir.addressof @null_hello_mid : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.getelementptr inbounds %2[%3, %4] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<13 x i8> + %6 = llvm.call @strlen(%5) : (!llvm.ptr) -> i32 + llvm.return %6 : i32 + } + llvm.func @test_no_simplify3_on_null_opt(%arg0: i32) -> i32 attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant("hello wor\00ld\00") : !llvm.array<13 x i8> + %2 = llvm.mlir.addressof @null_hello_mid : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.getelementptr inbounds %2[%3, %4] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<13 x i8> + %6 = llvm.call @strlen(%5) : (!llvm.ptr) -> i32 + llvm.return %6 : i32 + } + llvm.func @test1(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.call @strlen(%arg0) : (!llvm.ptr) -> i32 + llvm.return %0 : i32 + } + llvm.func @test2(%arg0: !llvm.ptr) -> i32 attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.call @strlen(%arg0) : (!llvm.ptr) -> i32 + llvm.return %0 : i32 + } + llvm.func @strlen0_after_write_to_first_byte_global() -> i1 { + %0 = llvm.mlir.constant(49 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %3 = llvm.mlir.addressof @a : !llvm.ptr + %4 = llvm.mlir.constant(0 : i32) : i32 + llvm.store %0, %3 {alignment = 16 : i64} : i8, !llvm.ptr + %5 = llvm.call @strlen(%3) : (!llvm.ptr) -> i32 + %6 = llvm.icmp "eq" %5, %4 : i32 + llvm.return %6 : i1 + } + llvm.func @strlen0_after_write_to_second_byte_global() -> i1 { + %0 = llvm.mlir.constant(49 : i8) : i8 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %5 = llvm.mlir.addressof @a : !llvm.ptr + %6 = llvm.getelementptr inbounds %5[%2, %1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<32 x i8> + %7 = llvm.mlir.constant(0 : i32) : i32 + llvm.store %0, %6 {alignment = 16 : i64} : i8, !llvm.ptr + %8 = llvm.call @strlen(%5) : (!llvm.ptr) -> i32 + %9 = llvm.icmp "eq" %8, %7 : i32 + llvm.return %9 : i1 + } + llvm.func @strlen0_after_write_to_first_byte(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(49 : i8) : i8 + %1 = llvm.mlir.constant(0 : i32) : i32 + llvm.store %0, %arg0 {alignment = 1 : i64} : i8, !llvm.ptr + %2 = llvm.call @strlen(%arg0) : (!llvm.ptr) -> i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @strlen0_after_write_to_second_byte(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(49 : i8) : i8 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + llvm.store %1, %3 {alignment = 1 : i64} : i8, !llvm.ptr + %4 = llvm.call @strlen(%arg0) : (!llvm.ptr) -> i32 + %5 = llvm.icmp "eq" %4, %2 : i32 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/strlen-2.ll.mlir b/test/LLVMDialect/InstCombine/strlen-2.ll.mlir index 00f95e452..0996245df 100644 --- a/test/LLVMDialect/InstCombine/strlen-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/strlen-2.ll.mlir @@ -1,15 +1,11 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello", type = !llvm.array<6 x i8>, value = "hello\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strlen", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 187 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.func @strlen(!llvm.ptr, i32) -> i32 + llvm.func @test_no_simplify1() -> i32 { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(187 : i32) : i32 + %3 = llvm.call @strlen(%1, %2) : (!llvm.ptr, i32) -> i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/strlen-3.ll.mlir b/test/LLVMDialect/InstCombine/strlen-3.ll.mlir index dbd7b9c56..a4d11ad0b 100644 --- a/test/LLVMDialect/InstCombine/strlen-3.ll.mlir +++ b/test/LLVMDialect/InstCombine/strlen-3.ll.mlir @@ -1,9 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.call"(%arg0) {callee = @strlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i64 - "llvm.return"(%0) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "strlen", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @strlen(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @strlen(%arg0) : (!llvm.ptr) -> i64 + llvm.return %0 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/strlen-4.ll.mlir b/test/LLVMDialect/InstCombine/strlen-4.ll.mlir new file mode 100644 index 000000000..0aa959add --- /dev/null +++ b/test/LLVMDialect/InstCombine/strlen-4.ll.mlir @@ -0,0 +1,119 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @sx() {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.mlir.global external constant @s3("123\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s5("12345\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s7("1234567\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s5_3("12345\00123\00") {addr_space = 0 : i32} + llvm.func @strlen(!llvm.ptr) -> i64 + llvm.func @fold_strlen_s3_pi_s5(%arg0: i1, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @s5 : !llvm.ptr + %5 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i8> + %6 = llvm.select %arg0, %5, %4 : i1, !llvm.ptr + %7 = llvm.call @strlen(%6) : (!llvm.ptr) -> i64 + llvm.return %7 : i64 + } + llvm.func @fold_strlen_s3_pi_p1_s5(%arg0: i1, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %5 = llvm.mlir.addressof @s5 : !llvm.ptr + %6 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i8> + %7 = llvm.getelementptr %6[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %8 = llvm.select %arg0, %7, %5 : i1, !llvm.ptr + %9 = llvm.call @strlen(%8) : (!llvm.ptr) -> i64 + llvm.return %9 : i64 + } + llvm.func @call_strlen_s5_3_pi_s5(%arg0: i1, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant("12345\00123\00") : !llvm.array<10 x i8> + %1 = llvm.mlir.addressof @s5_3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @s5 : !llvm.ptr + %5 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<10 x i8> + %6 = llvm.select %arg0, %5, %4 : i1, !llvm.ptr + %7 = llvm.call @strlen(%6) : (!llvm.ptr) -> i64 + llvm.return %7 : i64 + } + llvm.func @call_strlen_s5_3_s5_pj(%arg0: i1, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @s5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant("12345\00123\00") : !llvm.array<10 x i8> + %4 = llvm.mlir.addressof @s5_3 : !llvm.ptr + %5 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<6 x i8> + %6 = llvm.select %arg0, %4, %5 : i1, !llvm.ptr + %7 = llvm.call @strlen(%6) : (!llvm.ptr) -> i64 + llvm.return %7 : i64 + } + llvm.func @fold_strlen_s3_s5_pj(%arg0: i1, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @s5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.addressof @s3 : !llvm.ptr + %5 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<6 x i8> + %6 = llvm.select %arg0, %4, %5 : i1, !llvm.ptr + %7 = llvm.call @strlen(%6) : (!llvm.ptr) -> i64 + llvm.return %7 : i64 + } + llvm.func @call_strlen_s3_s5_3_pj(%arg0: i1, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant("12345\00123\00") : !llvm.array<10 x i8> + %1 = llvm.mlir.addressof @s5_3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.addressof @s3 : !llvm.ptr + %5 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<10 x i8> + %6 = llvm.select %arg0, %4, %5 : i1, !llvm.ptr + %7 = llvm.call @strlen(%6) : (!llvm.ptr) -> i64 + llvm.return %7 : i64 + } + llvm.func @fold_strlen_s3_pi_s5_pj(%arg0: i1, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @s5 : !llvm.ptr + %5 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i8> + %6 = llvm.getelementptr inbounds %4[%2, %arg2] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<6 x i8> + %7 = llvm.select %arg0, %5, %6 : i1, !llvm.ptr + %8 = llvm.call @strlen(%7) : (!llvm.ptr) -> i64 + llvm.return %8 : i64 + } + llvm.func @fold_strlen_s3_s5_s7(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %3 = llvm.mlir.addressof @s5 : !llvm.ptr + %4 = llvm.mlir.constant("1234567\00") : !llvm.array<8 x i8> + %5 = llvm.mlir.addressof @s7 : !llvm.ptr + %6 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %7 = llvm.mlir.addressof @s3 : !llvm.ptr + %8 = llvm.icmp "eq" %arg0, %0 : i32 + %9 = llvm.icmp "eq" %arg0, %1 : i32 + %10 = llvm.select %9, %3, %5 : i1, !llvm.ptr + %11 = llvm.select %8, %7, %10 : i1, !llvm.ptr + %12 = llvm.call @strlen(%11) : (!llvm.ptr) -> i64 + llvm.return %12 : i64 + } + llvm.func @call_strlen_sx_s5_s7(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %3 = llvm.mlir.addressof @s5 : !llvm.ptr + %4 = llvm.mlir.constant("1234567\00") : !llvm.array<8 x i8> + %5 = llvm.mlir.addressof @s7 : !llvm.ptr + %6 = llvm.mlir.addressof @sx : !llvm.ptr + %7 = llvm.icmp "eq" %arg0, %0 : i32 + %8 = llvm.icmp "eq" %arg0, %1 : i32 + %9 = llvm.select %8, %3, %5 : i1, !llvm.ptr + %10 = llvm.select %7, %6, %9 : i1, !llvm.ptr + %11 = llvm.call @strlen(%10) : (!llvm.ptr) -> i64 + llvm.return %11 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/strlen-5.ll.mlir b/test/LLVMDialect/InstCombine/strlen-5.ll.mlir new file mode 100644 index 000000000..dc229cb1d --- /dev/null +++ b/test/LLVMDialect/InstCombine/strlen-5.ll.mlir @@ -0,0 +1,403 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a5_4() {addr_space = 0 : i32} : !llvm.array<5 x array<4 x i8>> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + llvm.return %10 : !llvm.array<5 x array<4 x i8>> + } + llvm.func @strlen(!llvm.ptr) -> i64 + llvm.func @fold_a5_4_i0_to_3() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.call @strlen(%11) : (!llvm.ptr) -> i64 + llvm.return %12 : i64 + } + llvm.func @fold_a5_4_i0_p1_to_2() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(1 : i64) : i64 + %14 = llvm.getelementptr %11[%12, %12, %13] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.return %15 : i64 + } + llvm.func @fold_a5_4_i0_p2_to_1() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(2 : i64) : i64 + %14 = llvm.getelementptr %11[%12, %12, %13] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.return %15 : i64 + } + llvm.func @fold_a5_4_i0_p3_to_0() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(3 : i64) : i64 + %14 = llvm.getelementptr %11[%12, %12, %13] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.return %15 : i64 + } + llvm.func @fold_a5_4_i1_to_2() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(1 : i64) : i64 + %14 = llvm.getelementptr %11[%12, %13, %12] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.return %15 : i64 + } + llvm.func @fold_a5_4_i1_p1_to_1() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(1 : i64) : i64 + %14 = llvm.getelementptr %11[%12, %13, %13] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.return %15 : i64 + } + llvm.func @fold_a5_4_i1_p2_to_0() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(1 : i64) : i64 + %14 = llvm.mlir.constant(2 : i64) : i64 + %15 = llvm.getelementptr %11[%12, %13, %14] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %16 = llvm.call @strlen(%15) : (!llvm.ptr) -> i64 + llvm.return %16 : i64 + } + llvm.func @fold_a5_4_i1_p3_to_0() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(1 : i64) : i64 + %14 = llvm.mlir.constant(3 : i64) : i64 + %15 = llvm.getelementptr %11[%12, %13, %14] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %16 = llvm.call @strlen(%15) : (!llvm.ptr) -> i64 + llvm.return %16 : i64 + } + llvm.func @fold_a5_4_i2_to_1() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(2 : i64) : i64 + %14 = llvm.getelementptr %11[%12, %13, %12] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.return %15 : i64 + } + llvm.func @fold_a5_4_i2_p1_to_0() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(2 : i64) : i64 + %14 = llvm.mlir.constant(1 : i64) : i64 + %15 = llvm.getelementptr %11[%12, %13, %14] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %16 = llvm.call @strlen(%15) : (!llvm.ptr) -> i64 + llvm.return %16 : i64 + } + llvm.func @fold_a5_4_i2_p2_to_0() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(2 : i64) : i64 + %14 = llvm.getelementptr %11[%12, %13, %13] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.return %15 : i64 + } + llvm.func @fold_a5_4_i2_p3_to_0() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(2 : i64) : i64 + %14 = llvm.mlir.constant(3 : i64) : i64 + %15 = llvm.getelementptr %11[%12, %13, %14] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %16 = llvm.call @strlen(%15) : (!llvm.ptr) -> i64 + llvm.return %16 : i64 + } + llvm.func @fold_a5_4_i3_to_0() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(3 : i64) : i64 + %14 = llvm.getelementptr %11[%12, %13, %12] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.return %15 : i64 + } + llvm.func @fold_a5_4_i3_p1_to_0() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(3 : i64) : i64 + %14 = llvm.mlir.constant(1 : i64) : i64 + %15 = llvm.getelementptr %11[%12, %13, %14] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %16 = llvm.call @strlen(%15) : (!llvm.ptr) -> i64 + llvm.return %16 : i64 + } + llvm.func @fold_a5_4_i3_p2_to_0() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(3 : i64) : i64 + %14 = llvm.mlir.constant(2 : i64) : i64 + %15 = llvm.getelementptr %11[%12, %13, %14] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %16 = llvm.call @strlen(%15) : (!llvm.ptr) -> i64 + llvm.return %16 : i64 + } + llvm.func @fold_a5_3_i4_p3_to_0() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(3 : i64) : i64 + %14 = llvm.getelementptr %11[%12, %13, %13] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.return %15 : i64 + } + llvm.func @fold_a5_4_i4_to_0() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(4 : i64) : i64 + %14 = llvm.getelementptr %11[%12, %13, %12] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.return %15 : i64 + } + llvm.func @fold_a5_4_i4_p1_to_0() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(4 : i64) : i64 + %14 = llvm.mlir.constant(1 : i64) : i64 + %15 = llvm.getelementptr %11[%12, %13, %14] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %16 = llvm.call @strlen(%15) : (!llvm.ptr) -> i64 + llvm.return %16 : i64 + } + llvm.func @fold_a5_4_i4_p2_to_0() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(4 : i64) : i64 + %14 = llvm.mlir.constant(2 : i64) : i64 + %15 = llvm.getelementptr %11[%12, %13, %14] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %16 = llvm.call @strlen(%15) : (!llvm.ptr) -> i64 + llvm.return %16 : i64 + } + llvm.func @fold_a5_4_i4_p3_to_0() -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(4 : i64) : i64 + %14 = llvm.mlir.constant(3 : i64) : i64 + %15 = llvm.getelementptr %11[%12, %13, %14] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %16 = llvm.call @strlen(%15) : (!llvm.ptr) -> i64 + llvm.return %16 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/strlen-6.ll.mlir b/test/LLVMDialect/InstCombine/strlen-6.ll.mlir new file mode 100644 index 000000000..94e06dc42 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strlen-6.ll.mlir @@ -0,0 +1,324 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a_s3() {addr_space = 0 : i32} : !llvm.struct<"struct.A_a4", (array<4 x i8>)> { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.undef : !llvm.struct<"struct.A_a4", (array<4 x i8>)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<"struct.A_a4", (array<4 x i8>)> + llvm.return %2 : !llvm.struct<"struct.A_a4", (array<4 x i8>)> + } + llvm.mlir.global external constant @a_s3_s4() {addr_space = 0 : i32} : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %2 = llvm.mlir.undef : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + llvm.return %4 : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + } + llvm.mlir.global external constant @a_s3_i32_s4() {addr_space = 0 : i32} : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + llvm.return %6 : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + } + llvm.mlir.global external constant @ax_s3() {addr_space = 0 : i32} : !llvm.struct<(i8, array<4 x i8>)> { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.undef : !llvm.struct<(i8, array<4 x i8>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<(i8, array<4 x i8>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<(i8, array<4 x i8>)> + llvm.return %4 : !llvm.struct<(i8, array<4 x i8>)> + } + llvm.mlir.global external constant @ax_s5() {addr_space = 0 : i32} : !llvm.struct<(i16, array<6 x i8>)> { + %0 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.constant(5 : i16) : i16 + %2 = llvm.mlir.undef : !llvm.struct<(i16, array<6 x i8>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<(i16, array<6 x i8>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<(i16, array<6 x i8>)> + llvm.return %4 : !llvm.struct<(i16, array<6 x i8>)> + } + llvm.mlir.global external constant @ax_s7() {addr_space = 0 : i32} : !llvm.struct<(i32, i32, array<8 x i8>)> { + %0 = llvm.mlir.constant("1234567\00") : !llvm.array<8 x i8> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.mlir.undef : !llvm.struct<(i32, i32, array<8 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<(i32, i32, array<8 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<(i32, i32, array<8 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<(i32, i32, array<8 x i8>)> + llvm.return %6 : !llvm.struct<(i32, i32, array<8 x i8>)> + } + llvm.mlir.global external @ax() {addr_space = 0 : i32} : !llvm.array<0 x i64> + llvm.func @strlen(!llvm.ptr) -> i64 + llvm.func @fold_strlen_a_S3_to_3() -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.undef : !llvm.struct<"struct.A_a4", (array<4 x i8>)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<"struct.A_a4", (array<4 x i8>)> + %3 = llvm.mlir.addressof @a_s3 : !llvm.ptr + %4 = llvm.call @strlen(%3) : (!llvm.ptr) -> i64 + llvm.return %4 : i64 + } + llvm.func @fold_strlen_a_S3_p1_to_2() -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.undef : !llvm.struct<"struct.A_a4", (array<4 x i8>)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<"struct.A_a4", (array<4 x i8>)> + %3 = llvm.mlir.addressof @a_s3 : !llvm.ptr + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.getelementptr %3[%4, 0, %5] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4", (array<4 x i8>)> + %7 = llvm.call @strlen(%6) : (!llvm.ptr) -> i64 + llvm.return %7 : i64 + } + llvm.func @fold_strlen_a_S3_p2_to_1() -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.undef : !llvm.struct<"struct.A_a4", (array<4 x i8>)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<"struct.A_a4", (array<4 x i8>)> + %3 = llvm.mlir.addressof @a_s3 : !llvm.ptr + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(2 : i32) : i32 + %6 = llvm.getelementptr %3[%4, 0, %5] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4", (array<4 x i8>)> + %7 = llvm.call @strlen(%6) : (!llvm.ptr) -> i64 + llvm.return %7 : i64 + } + llvm.func @fold_strlen_a_S3_p3_to_0() -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.undef : !llvm.struct<"struct.A_a4", (array<4 x i8>)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<"struct.A_a4", (array<4 x i8>)> + %3 = llvm.mlir.addressof @a_s3 : !llvm.ptr + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.getelementptr %3[%4, 0, %5] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4", (array<4 x i8>)> + %7 = llvm.call @strlen(%6) : (!llvm.ptr) -> i64 + llvm.return %7 : i64 + } + llvm.func @fold_strlen_a_S3_s4_to_3() -> i64 { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %2 = llvm.mlir.undef : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %5 = llvm.mlir.addressof @a_s3_s4 : !llvm.ptr + %6 = llvm.call @strlen(%5) : (!llvm.ptr) -> i64 + llvm.return %6 : i64 + } + llvm.func @fold_strlen_a_S3_p2_s4_to_1() -> i64 { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %2 = llvm.mlir.undef : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %5 = llvm.mlir.addressof @a_s3_s4 : !llvm.ptr + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.getelementptr %5[%6, 0, %7] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %9 = llvm.call @strlen(%8) : (!llvm.ptr) -> i64 + llvm.return %9 : i64 + } + llvm.func @fold_strlen_a_s3_S4_to_4() { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %2 = llvm.mlir.undef : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %5 = llvm.mlir.addressof @a_s3_s4 : !llvm.ptr + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.mlir.constant(4 : i32) : i32 + %8 = llvm.mlir.addressof @ax : !llvm.ptr + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.mlir.constant(0 : i64) : i64 + %11 = llvm.mlir.constant(1 : i64) : i64 + %12 = llvm.getelementptr %5[%6, 0, %7] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %13 = llvm.call @strlen(%12) : (!llvm.ptr) -> i64 + llvm.store %13, %8 {alignment = 4 : i64} : i64, !llvm.ptr + %14 = llvm.getelementptr %5[%6, 1, %6] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + %16 = llvm.getelementptr inbounds %8[%10, %11] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i64> + llvm.store %13, %16 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_strlen_a_s3_S4_p1_to_3() { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %2 = llvm.mlir.undef : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %5 = llvm.mlir.addressof @a_s3_s4 : !llvm.ptr + %6 = llvm.mlir.constant(0 : i32) : i32 + %7 = llvm.mlir.constant(5 : i32) : i32 + %8 = llvm.mlir.addressof @ax : !llvm.ptr + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.mlir.constant(0 : i64) : i64 + %11 = llvm.mlir.constant(1 : i64) : i64 + %12 = llvm.getelementptr %5[%6, 0, %7] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %13 = llvm.call @strlen(%12) : (!llvm.ptr) -> i64 + llvm.store %13, %8 {alignment = 4 : i64} : i64, !llvm.ptr + %14 = llvm.getelementptr %5[%6, 1, %9] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_a5", (array<4 x i8>, array<5 x i8>)> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + %16 = llvm.getelementptr inbounds %8[%10, %11] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i64> + llvm.store %13, %16 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_strlen_a_s3_i32_S4_to_4() { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %7 = llvm.mlir.addressof @a_s3_i32_s4 : !llvm.ptr + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.mlir.constant(8 : i32) : i32 + %10 = llvm.mlir.addressof @ax : !llvm.ptr + %11 = llvm.mlir.constant(2 : i32) : i32 + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(1 : i64) : i64 + %14 = llvm.getelementptr %7[%8, 0, %9] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.store %15, %10 {alignment = 4 : i64} : i64, !llvm.ptr + %16 = llvm.getelementptr %7[%8, 2, %8] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %17 = llvm.call @strlen(%16) : (!llvm.ptr) -> i64 + %18 = llvm.getelementptr inbounds %10[%12, %13] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i64> + llvm.store %15, %18 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_strlen_a_s3_i32_S4_p1_to_3() { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %7 = llvm.mlir.addressof @a_s3_i32_s4 : !llvm.ptr + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.mlir.constant(9 : i32) : i32 + %10 = llvm.mlir.addressof @ax : !llvm.ptr + %11 = llvm.mlir.constant(2 : i32) : i32 + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(1 : i64) : i64 + %14 = llvm.getelementptr %7[%8, 0, %9] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.store %15, %10 {alignment = 4 : i64} : i64, !llvm.ptr + %16 = llvm.getelementptr %7[%8, 2, %8] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %17 = llvm.call @strlen(%16) : (!llvm.ptr) -> i64 + %18 = llvm.getelementptr inbounds %10[%12, %13] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i64> + llvm.store %15, %18 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_strlen_a_s3_i32_S4_p2_to_2() { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %7 = llvm.mlir.addressof @a_s3_i32_s4 : !llvm.ptr + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.mlir.constant(10 : i32) : i32 + %10 = llvm.mlir.addressof @ax : !llvm.ptr + %11 = llvm.mlir.constant(2 : i32) : i32 + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(1 : i64) : i64 + %14 = llvm.getelementptr %7[%8, 0, %9] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.store %15, %10 {alignment = 4 : i64} : i64, !llvm.ptr + %16 = llvm.getelementptr %7[%8, 2, %11] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %17 = llvm.call @strlen(%16) : (!llvm.ptr) -> i64 + %18 = llvm.getelementptr inbounds %10[%12, %13] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i64> + llvm.store %15, %18 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_strlen_a_s3_i32_S4_p3_to_1() { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %7 = llvm.mlir.addressof @a_s3_i32_s4 : !llvm.ptr + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.mlir.constant(11 : i32) : i32 + %10 = llvm.mlir.addressof @ax : !llvm.ptr + %11 = llvm.mlir.constant(2 : i32) : i32 + %12 = llvm.mlir.constant(3 : i32) : i32 + %13 = llvm.mlir.constant(0 : i64) : i64 + %14 = llvm.mlir.constant(1 : i64) : i64 + %15 = llvm.getelementptr %7[%8, 0, %9] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %16 = llvm.call @strlen(%15) : (!llvm.ptr) -> i64 + llvm.store %16, %10 {alignment = 4 : i64} : i64, !llvm.ptr + %17 = llvm.getelementptr %7[%8, 2, %12] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %18 = llvm.call @strlen(%17) : (!llvm.ptr) -> i64 + %19 = llvm.getelementptr inbounds %10[%13, %14] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i64> + llvm.store %16, %19 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_strlen_a_s3_i32_S4_p4_to_0() { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %7 = llvm.mlir.addressof @a_s3_i32_s4 : !llvm.ptr + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.mlir.constant(12 : i32) : i32 + %10 = llvm.mlir.addressof @ax : !llvm.ptr + %11 = llvm.mlir.constant(2 : i32) : i32 + %12 = llvm.mlir.constant(4 : i32) : i32 + %13 = llvm.mlir.constant(0 : i64) : i64 + %14 = llvm.mlir.constant(1 : i64) : i64 + %15 = llvm.getelementptr %7[%8, 0, %9] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %16 = llvm.call @strlen(%15) : (!llvm.ptr) -> i64 + llvm.store %16, %10 {alignment = 4 : i64} : i64, !llvm.ptr + %17 = llvm.getelementptr %7[%8, 2, %12] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A_a4_i32_a5", (array<4 x i8>, i32, array<5 x i8>)> + %18 = llvm.call @strlen(%17) : (!llvm.ptr) -> i64 + %19 = llvm.getelementptr inbounds %10[%13, %14] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i64> + llvm.store %16, %19 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_strlen_ax_s() { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.undef : !llvm.struct<(i8, array<4 x i8>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<(i8, array<4 x i8>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<(i8, array<4 x i8>)> + %5 = llvm.mlir.addressof @ax_s3 : !llvm.ptr + %6 = llvm.mlir.constant(0 : i64) : i64 + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.mlir.addressof @ax : !llvm.ptr + %9 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %10 = llvm.mlir.constant(5 : i16) : i16 + %11 = llvm.mlir.undef : !llvm.struct<(i16, array<6 x i8>)> + %12 = llvm.insertvalue %10, %11[0] : !llvm.struct<(i16, array<6 x i8>)> + %13 = llvm.insertvalue %9, %12[1] : !llvm.struct<(i16, array<6 x i8>)> + %14 = llvm.mlir.addressof @ax_s5 : !llvm.ptr + %15 = llvm.mlir.constant(1 : i64) : i64 + %16 = llvm.mlir.constant("1234567\00") : !llvm.array<8 x i8> + %17 = llvm.mlir.constant(0 : i32) : i32 + %18 = llvm.mlir.constant(7 : i32) : i32 + %19 = llvm.mlir.undef : !llvm.struct<(i32, i32, array<8 x i8>)> + %20 = llvm.insertvalue %18, %19[0] : !llvm.struct<(i32, i32, array<8 x i8>)> + %21 = llvm.insertvalue %17, %20[1] : !llvm.struct<(i32, i32, array<8 x i8>)> + %22 = llvm.insertvalue %16, %21[2] : !llvm.struct<(i32, i32, array<8 x i8>)> + %23 = llvm.mlir.addressof @ax_s7 : !llvm.ptr + %24 = llvm.mlir.constant(2 : i32) : i32 + %25 = llvm.mlir.constant(2 : i64) : i64 + %26 = llvm.getelementptr %5[%6, 1, %6] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.struct<(i8, array<4 x i8>)> + %27 = llvm.call @strlen(%26) : (!llvm.ptr) -> i64 + llvm.store %27, %8 {alignment = 4 : i64} : i64, !llvm.ptr + %28 = llvm.getelementptr %14[%6, 1, %6] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.struct<(i16, array<6 x i8>)> + %29 = llvm.call @strlen(%28) : (!llvm.ptr) -> i64 + %30 = llvm.getelementptr inbounds %8[%6, %15] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i64> + llvm.store %29, %30 {alignment = 4 : i64} : i64, !llvm.ptr + %31 = llvm.getelementptr %23[%6, 2, %6] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.struct<(i32, i32, array<8 x i8>)> + %32 = llvm.call @strlen(%31) : (!llvm.ptr) -> i64 + %33 = llvm.getelementptr inbounds %8[%6, %25] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i64> + llvm.store %32, %33 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strlen-7.ll.mlir b/test/LLVMDialect/InstCombine/strlen-7.ll.mlir new file mode 100644 index 000000000..d1c30bcdc --- /dev/null +++ b/test/LLVMDialect/InstCombine/strlen-7.ll.mlir @@ -0,0 +1,167 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a() {addr_space = 0 : i32, alignment = 16 : i64} : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %2 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %5 = llvm.mlir.constant("12\00\00\00") : !llvm.array<5 x i8> + %6 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %7 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %8 = llvm.insertvalue %6, %7[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %9 = llvm.insertvalue %5, %8[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %10 = llvm.mlir.undef : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %11 = llvm.insertvalue %9, %10[0] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %12 = llvm.insertvalue %4, %11[1] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + llvm.return %12 : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + } + llvm.func @strlen(!llvm.ptr) -> i64 + llvm.func @fold_strlen_A(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %2 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %5 = llvm.mlir.constant("12\00\00\00") : !llvm.array<5 x i8> + %6 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %7 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %8 = llvm.insertvalue %6, %7[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %9 = llvm.insertvalue %5, %8[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %10 = llvm.mlir.undef : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %11 = llvm.insertvalue %9, %10[0] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %12 = llvm.insertvalue %4, %11[1] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %13 = llvm.mlir.addressof @a : !llvm.ptr + %14 = llvm.mlir.constant(0 : i64) : i64 + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.mlir.constant(1 : i64) : i64 + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.mlir.constant(2 : i64) : i64 + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.mlir.constant(3 : i64) : i64 + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.mlir.constant(4 : i32) : i32 + %23 = llvm.mlir.constant(5 : i32) : i32 + %24 = llvm.mlir.constant(6 : i32) : i32 + %25 = llvm.mlir.constant(7 : i32) : i32 + %26 = llvm.mlir.constant(4 : i64) : i64 + %27 = llvm.mlir.constant(8 : i32) : i32 + %28 = llvm.mlir.constant(9 : i32) : i32 + %29 = llvm.mlir.constant(10 : i32) : i32 + %30 = llvm.mlir.constant(11 : i32) : i32 + %31 = llvm.mlir.constant(12 : i32) : i32 + %32 = llvm.mlir.constant(14 : i32) : i32 + %33 = llvm.mlir.constant(15 : i32) : i32 + %34 = llvm.mlir.constant(16 : i32) : i32 + %35 = llvm.mlir.constant(17 : i32) : i32 + %36 = llvm.mlir.constant(18 : i32) : i32 + %37 = llvm.call @strlen(%13) : (!llvm.ptr) -> i64 + llvm.store %37, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %38 = llvm.getelementptr %13[%14, %14, 0, %16] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %39 = llvm.call @strlen(%38) : (!llvm.ptr) -> i64 + %40 = llvm.getelementptr %arg0[%17] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %39, %40 {alignment = 4 : i64} : i64, !llvm.ptr + %41 = llvm.getelementptr %13[%14, %14, 0, %18] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %42 = llvm.call @strlen(%41) : (!llvm.ptr) -> i64 + %43 = llvm.getelementptr %arg0[%19] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %42, %43 {alignment = 4 : i64} : i64, !llvm.ptr + %44 = llvm.getelementptr %13[%14, %14, 0, %20] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %45 = llvm.call @strlen(%44) : (!llvm.ptr) -> i64 + %46 = llvm.getelementptr %arg0[%21] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %45, %46 {alignment = 4 : i64} : i64, !llvm.ptr + %47 = llvm.getelementptr %13[%14, %14, 1, %14] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %48 = llvm.call @strlen(%47) : (!llvm.ptr) -> i64 + %49 = llvm.getelementptr %arg0[%22] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %48, %49 {alignment = 4 : i64} : i64, !llvm.ptr + %50 = llvm.getelementptr %13[%14, %14, 1, %16] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %51 = llvm.call @strlen(%50) : (!llvm.ptr) -> i64 + %52 = llvm.getelementptr %arg0[%23] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %51, %52 {alignment = 4 : i64} : i64, !llvm.ptr + %53 = llvm.getelementptr %13[%14, %14, 1, %18] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %54 = llvm.call @strlen(%53) : (!llvm.ptr) -> i64 + %55 = llvm.getelementptr %arg0[%24] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %54, %55 {alignment = 4 : i64} : i64, !llvm.ptr + %56 = llvm.getelementptr %13[%14, %14, 1, %20] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %57 = llvm.call @strlen(%56) : (!llvm.ptr) -> i64 + %58 = llvm.getelementptr %arg0[%25] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %57, %58 {alignment = 4 : i64} : i64, !llvm.ptr + %59 = llvm.getelementptr %13[%14, %14, 1, %26] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %60 = llvm.call @strlen(%59) : (!llvm.ptr) -> i64 + %61 = llvm.getelementptr %arg0[%27] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %60, %61 {alignment = 4 : i64} : i64, !llvm.ptr + %62 = llvm.getelementptr %13[%14, %16, 0, %14] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %63 = llvm.call @strlen(%62) : (!llvm.ptr) -> i64 + %64 = llvm.getelementptr %arg0[%28] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %63, %64 {alignment = 4 : i64} : i64, !llvm.ptr + %65 = llvm.getelementptr %13[%14, %16, 0, %16] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %66 = llvm.call @strlen(%65) : (!llvm.ptr) -> i64 + %67 = llvm.getelementptr %arg0[%29] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %66, %67 {alignment = 4 : i64} : i64, !llvm.ptr + %68 = llvm.getelementptr %13[%14, %16, 0, %18] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %69 = llvm.call @strlen(%68) : (!llvm.ptr) -> i64 + %70 = llvm.getelementptr %arg0[%30] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %69, %70 {alignment = 4 : i64} : i64, !llvm.ptr + %71 = llvm.getelementptr %13[%14, %16, 0, %20] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %72 = llvm.call @strlen(%71) : (!llvm.ptr) -> i64 + %73 = llvm.getelementptr %arg0[%31] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %72, %73 {alignment = 4 : i64} : i64, !llvm.ptr + %74 = llvm.getelementptr %13[%14, %16, 1, %14] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %75 = llvm.call @strlen(%74) : (!llvm.ptr) -> i64 + %76 = llvm.getelementptr %arg0[%32] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %75, %76 {alignment = 4 : i64} : i64, !llvm.ptr + %77 = llvm.getelementptr %13[%14, %16, 1, %16] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %78 = llvm.call @strlen(%77) : (!llvm.ptr) -> i64 + %79 = llvm.getelementptr %arg0[%33] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %78, %79 {alignment = 4 : i64} : i64, !llvm.ptr + %80 = llvm.getelementptr %13[%14, %16, 1, %18] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %81 = llvm.call @strlen(%80) : (!llvm.ptr) -> i64 + %82 = llvm.getelementptr %arg0[%34] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %81, %82 {alignment = 4 : i64} : i64, !llvm.ptr + %83 = llvm.getelementptr %13[%14, %16, 1, %20] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %84 = llvm.call @strlen(%83) : (!llvm.ptr) -> i64 + %85 = llvm.getelementptr %arg0[%35] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %84, %85 {alignment = 4 : i64} : i64, !llvm.ptr + %86 = llvm.getelementptr %13[%14, %16, 1, %26] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %87 = llvm.call @strlen(%86) : (!llvm.ptr) -> i64 + %88 = llvm.getelementptr %arg0[%36] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %87, %88 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } + llvm.func @fold_strlen_A_pI(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("1234\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %2 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %5 = llvm.mlir.constant("12\00\00\00") : !llvm.array<5 x i8> + %6 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %7 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %8 = llvm.insertvalue %6, %7[0] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %9 = llvm.insertvalue %5, %8[1] : !llvm.struct<"struct.A", (array<4 x i8>, array<5 x i8>)> + %10 = llvm.mlir.undef : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %11 = llvm.insertvalue %9, %10[0] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %12 = llvm.insertvalue %4, %11[1] : !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %13 = llvm.mlir.addressof @a : !llvm.ptr + %14 = llvm.mlir.constant(0 : i64) : i64 + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.mlir.constant(1 : i32) : i32 + %17 = llvm.mlir.constant(1 : i64) : i64 + %18 = llvm.mlir.constant(2 : i32) : i32 + %19 = llvm.mlir.constant(3 : i32) : i32 + %20 = llvm.getelementptr %13[%14, %14, 0, %arg1] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %21 = llvm.call @strlen(%20) : (!llvm.ptr) -> i64 + llvm.store %21, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %22 = llvm.getelementptr %13[%14, %14, 1, %arg1] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %23 = llvm.call @strlen(%22) : (!llvm.ptr) -> i64 + %24 = llvm.getelementptr %arg0[%16] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %23, %24 {alignment = 4 : i64} : i64, !llvm.ptr + %25 = llvm.getelementptr %13[%14, %17, 0, %arg1] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %26 = llvm.call @strlen(%25) : (!llvm.ptr) -> i64 + %27 = llvm.getelementptr %arg0[%18] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %26, %27 {alignment = 4 : i64} : i64, !llvm.ptr + %28 = llvm.getelementptr %13[%14, %17, 1, %arg1] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<2 x struct<"struct.A", (array<4 x i8>, array<5 x i8>)>> + %29 = llvm.call @strlen(%28) : (!llvm.ptr) -> i64 + %30 = llvm.getelementptr %arg0[%19] : (!llvm.ptr, i32) -> !llvm.ptr, i64 + llvm.store %29, %30 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strlen-8.ll.mlir b/test/LLVMDialect/InstCombine/strlen-8.ll.mlir new file mode 100644 index 000000000..385f8f6ed --- /dev/null +++ b/test/LLVMDialect/InstCombine/strlen-8.ll.mlir @@ -0,0 +1,111 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a5_4() {addr_space = 0 : i32} : !llvm.array<5 x array<4 x i8>> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + llvm.return %10 : !llvm.array<5 x array<4 x i8>> + } + llvm.func @strlen(!llvm.ptr) -> i64 + llvm.func @fold_a5_4_i0_pI(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.getelementptr %11[%12, %12, %arg0] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %14 = llvm.call @strlen(%13) : (!llvm.ptr) -> i64 + llvm.return %14 : i64 + } + llvm.func @fold_a5_4_i1_pI(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(1 : i64) : i64 + %14 = llvm.getelementptr %11[%12, %13, %arg0] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.return %15 : i64 + } + llvm.func @fold_a5_4_i2_pI(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(2 : i64) : i64 + %14 = llvm.getelementptr %11[%12, %13, %arg0] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.return %15 : i64 + } + llvm.func @fold_a5_4_i3_pI_to_0(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(3 : i64) : i64 + %14 = llvm.getelementptr %11[%12, %13, %arg0] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.return %15 : i64 + } + llvm.func @fold_a5_4_i4_pI_to_0(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<4xi8>) : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("1\00\00\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.constant("12\00\00") : !llvm.array<4 x i8> + %4 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %5 = llvm.mlir.undef : !llvm.array<5 x array<4 x i8>> + %6 = llvm.insertvalue %4, %5[0] : !llvm.array<5 x array<4 x i8>> + %7 = llvm.insertvalue %3, %6[1] : !llvm.array<5 x array<4 x i8>> + %8 = llvm.insertvalue %2, %7[2] : !llvm.array<5 x array<4 x i8>> + %9 = llvm.insertvalue %1, %8[3] : !llvm.array<5 x array<4 x i8>> + %10 = llvm.insertvalue %1, %9[4] : !llvm.array<5 x array<4 x i8>> + %11 = llvm.mlir.addressof @a5_4 : !llvm.ptr + %12 = llvm.mlir.constant(0 : i64) : i64 + %13 = llvm.mlir.constant(4 : i64) : i64 + %14 = llvm.getelementptr %11[%12, %13, %arg0] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<5 x array<4 x i8>> + %15 = llvm.call @strlen(%14) : (!llvm.ptr) -> i64 + llvm.return %15 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/strlen-9.ll.mlir b/test/LLVMDialect/InstCombine/strlen-9.ll.mlir new file mode 100644 index 000000000..9c372c6ac --- /dev/null +++ b/test/LLVMDialect/InstCombine/strlen-9.ll.mlir @@ -0,0 +1,53 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a5("12345") {addr_space = 0 : i32} + llvm.mlir.global external constant @s5("12345\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @z0(dense<0> : tensor<0xi8>) {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.mlir.global external constant @z5(dense<0> : tensor<5xi8>) {addr_space = 0 : i32} : !llvm.array<5 x i8> + llvm.func @strlen(!llvm.ptr) -> i64 + llvm.func @fold_strlen_no_nul(%arg0: !llvm.ptr, %arg1: i32) { + %0 = llvm.mlir.constant("12345") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(1 : i64) : i64 + %5 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %6 = llvm.mlir.addressof @s5 : !llvm.ptr + %7 = llvm.mlir.constant(6 : i32) : i32 + %8 = llvm.mlir.constant(2 : i64) : i64 + %9 = llvm.mlir.constant(3 : i64) : i64 + %10 = llvm.mlir.constant(dense<0> : tensor<0xi8>) : !llvm.array<0 x i8> + %11 = llvm.mlir.addressof @z0 : !llvm.ptr + %12 = llvm.mlir.constant(4 : i64) : i64 + %13 = llvm.mlir.constant(5 : i64) : i64 + %14 = llvm.mlir.constant(0 : i8) : i8 + %15 = llvm.mlir.constant(dense<0> : tensor<5xi8>) : !llvm.array<5 x i8> + %16 = llvm.mlir.addressof @z5 : !llvm.ptr + %17 = llvm.mlir.constant(6 : i64) : i64 + %18 = llvm.call @strlen(%1) : (!llvm.ptr) -> i64 + llvm.store %18, %arg0 {alignment = 4 : i64} : i64, !llvm.ptr + %19 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %20 = llvm.call @strlen(%19) : (!llvm.ptr) -> i64 + %21 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %20, %21 {alignment = 4 : i64} : i64, !llvm.ptr + %22 = llvm.getelementptr %6[%2, %7] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<6 x i8> + %23 = llvm.call @strlen(%22) : (!llvm.ptr) -> i64 + %24 = llvm.getelementptr %arg0[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %23, %24 {alignment = 4 : i64} : i64, !llvm.ptr + %25 = llvm.getelementptr %1[%2, %arg1] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %26 = llvm.call @strlen(%25) : (!llvm.ptr) -> i64 + %27 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %26, %27 {alignment = 4 : i64} : i64, !llvm.ptr + %28 = llvm.call @strlen(%11) : (!llvm.ptr) -> i64 + %29 = llvm.getelementptr %arg0[%12] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %28, %29 {alignment = 4 : i64} : i64, !llvm.ptr + %30 = llvm.getelementptr %11[%2, %arg1] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<0 x i8> + %31 = llvm.call @strlen(%30) : (!llvm.ptr) -> i64 + %32 = llvm.getelementptr %arg0[%13] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %31, %32 {alignment = 4 : i64} : i64, !llvm.ptr + %33 = llvm.getelementptr %16[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<5 x i8> + %34 = llvm.call @strlen(%33) : (!llvm.ptr) -> i64 + %35 = llvm.getelementptr %arg0[%17] : (!llvm.ptr, i64) -> !llvm.ptr, i64 + llvm.store %34, %35 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strlen_chk.ll.mlir b/test/LLVMDialect/InstCombine/strlen_chk.ll.mlir index 527677616..415603b07 100644 --- a/test/LLVMDialect/InstCombine/strlen_chk.ll.mlir +++ b/test/LLVMDialect/InstCombine/strlen_chk.ll.mlir @@ -1,48 +1,36 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello", type = !llvm.array<6 x i8>, value = "hello\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello_no_nul", type = !llvm.array<5 x i8>, value = "hello"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "__strlen_chk", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %1 = "llvm.call"(%arg0, %0) {callee = @__strlen_chk, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "unknown_str_known_object_size", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @__strlen_chk, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "known_str_known_object_size", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @__strlen_chk, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "known_str_too_small_object_size", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @hello_no_nul} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @__strlen_chk, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "known_str_no_nul", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.call"(%arg0, %0) {callee = @__strlen_chk, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "unknown_str_unknown_object_size", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hello_no_nul("hello") {addr_space = 0 : i32} + llvm.func @__strlen_chk(!llvm.ptr, i32) -> i32 + llvm.func @unknown_str_known_object_size(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.call @__strlen_chk(%arg0, %0) : (!llvm.ptr, i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @known_str_known_object_size(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(6 : i32) : i32 + %3 = llvm.call @__strlen_chk(%1, %2) : (!llvm.ptr, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @known_str_too_small_object_size(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(5 : i32) : i32 + %3 = llvm.call @__strlen_chk(%1, %2) : (!llvm.ptr, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @known_str_no_nul(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant("hello") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @hello_no_nul : !llvm.ptr + %2 = llvm.mlir.constant(5 : i32) : i32 + %3 = llvm.call @__strlen_chk(%1, %2) : (!llvm.ptr, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @unknown_str_unknown_object_size(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.call @__strlen_chk(%arg0, %0) : (!llvm.ptr, i32) -> i32 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/strncat-1.ll.mlir b/test/LLVMDialect/InstCombine/strncat-1.ll.mlir new file mode 100644 index 000000000..e49892c39 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strncat-1.ll.mlir @@ -0,0 +1,27 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external constant @null_hello("\00hello\00") {addr_space = 0 : i32} + llvm.func @strncat(!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.func @puts(!llvm.ptr) -> i32 + llvm.func @main() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %3 = llvm.mlir.addressof @hello : !llvm.ptr + %4 = llvm.mlir.constant(6 : i32) : i32 + %5 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %6 = llvm.mlir.addressof @null : !llvm.ptr + %7 = llvm.mlir.constant(42 : i32) : i32 + %8 = llvm.mlir.constant("\00hello\00") : !llvm.array<7 x i8> + %9 = llvm.mlir.addressof @null_hello : !llvm.ptr + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.alloca %0 x !llvm.array<1024 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %11 {alignment = 1 : i64} : i8, !llvm.ptr + %12 = llvm.call @strncat(%11, %3, %4) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + %13 = llvm.call @strncat(%12, %6, %7) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + %14 = llvm.call @strncat(%13, %9, %7) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + %15 = llvm.call @puts(%14) : (!llvm.ptr) -> i32 + llvm.return %10 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/strncat-2.ll.mlir b/test/LLVMDialect/InstCombine/strncat-2.ll.mlir new file mode 100644 index 000000000..33bfb4696 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strncat-2.ll.mlir @@ -0,0 +1,71 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @empty(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global common @a(dense<0> : tensor<32xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i8> + llvm.func @strncat(!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.func @test_simplify1() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.mlir.constant(13 : i32) : i32 + %6 = llvm.call @strncat(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return + } + llvm.func @test_simplify2() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %4 = llvm.mlir.addressof @empty : !llvm.ptr + %5 = llvm.mlir.constant(13 : i32) : i32 + %6 = llvm.call @strncat(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return + } + llvm.func @test_simplify3() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.call @strncat(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return + } + llvm.func @test_nosimplify1() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.call @strncat(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return + } + llvm.func @test1(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @strncat(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test2(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @strncat(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test3(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.call @strncat(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test4(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.call @strncat(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test5(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(10 : i32) : i32 + %3 = llvm.call @strncat(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/strncat-3.ll.mlir b/test/LLVMDialect/InstCombine/strncat-3.ll.mlir new file mode 100644 index 000000000..fa51729d2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strncat-3.ll.mlir @@ -0,0 +1,16 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @empty(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global common @a(dense<0> : tensor<32xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i8> + llvm.func @strncat(!llvm.ptr, !llvm.ptr, i32) -> i16 + llvm.func @test_nosimplify1() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.mlir.constant(13 : i32) : i32 + %6 = llvm.call @strncat(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i32) -> i16 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strncmp-1.ll.mlir b/test/LLVMDialect/InstCombine/strncmp-1.ll.mlir new file mode 100644 index 000000000..4ac47628a --- /dev/null +++ b/test/LLVMDialect/InstCombine/strncmp-1.ll.mlir @@ -0,0 +1,83 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hell("hell\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @bell("bell\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.func @strncmp(!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.func @test1(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.call @strncmp(%2, %arg0, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @test2(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.call @strncmp(%arg0, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %4 : i32 + } + llvm.func @test3() -> i32 { + %0 = llvm.mlir.constant("hell\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @hell : !llvm.ptr + %2 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %3 = llvm.mlir.addressof @hello : !llvm.ptr + %4 = llvm.mlir.constant(10 : i32) : i32 + %5 = llvm.call @strncmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @test4() -> i32 { + %0 = llvm.mlir.constant("hell\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @hell : !llvm.ptr + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %4 = llvm.mlir.addressof @null : !llvm.ptr + %5 = llvm.mlir.constant(10 : i32) : i32 + %6 = llvm.call @strncmp(%1, %4, %5) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %6 : i32 + } + llvm.func @test5() -> i32 { + %0 = llvm.mlir.constant("hell\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @hell : !llvm.ptr + %2 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %3 = llvm.mlir.addressof @hello : !llvm.ptr + %4 = llvm.mlir.constant(4 : i32) : i32 + %5 = llvm.call @strncmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %5 : i32 + } + llvm.func @test6(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.call @strncmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test7(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @strncmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test8(%arg0: !llvm.ptr, %arg1: i32) -> i32 { + %0 = llvm.call @strncmp(%arg0, %arg0, %arg1) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %0 : i32 + } + llvm.func @test9(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> i32 { + %0 = llvm.call @strncmp(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %0 : i32 + } + llvm.func @test10(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @strncmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test11(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.call @strncmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test12(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> i32 attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.call @strncmp(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/strncmp-2.ll.mlir b/test/LLVMDialect/InstCombine/strncmp-2.ll.mlir index 1c5212f70..9654866ca 100644 --- a/test/LLVMDialect/InstCombine/strncmp-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/strncmp-2.ll.mlir @@ -1,19 +1,14 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello", type = !llvm.array<6 x i8>, value = "hello\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hell", type = !llvm.array<5 x i8>, value = "hell\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strncmp", type = !llvm.func, ptr, i32)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @hell} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%4, %5, %0) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i16 - "llvm.return"(%6) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "test_nosimplify", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @hell("hell\00") {addr_space = 0 : i32} + llvm.func @strncmp(!llvm.ptr, !llvm.ptr, i32) -> i16 + llvm.func @test_nosimplify() -> i16 { + %0 = llvm.mlir.constant("hell\00") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @hell : !llvm.ptr + %2 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %3 = llvm.mlir.addressof @hello : !llvm.ptr + %4 = llvm.mlir.constant(10 : i32) : i32 + %5 = llvm.call @strncmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i32) -> i16 + llvm.return %5 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/strncmp-3.ll.mlir b/test/LLVMDialect/InstCombine/strncmp-3.ll.mlir index ec042e526..3944bafd1 100644 --- a/test/LLVMDialect/InstCombine/strncmp-3.ll.mlir +++ b/test/LLVMDialect/InstCombine/strncmp-3.ll.mlir @@ -1,53 +1,39 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "ax", type = !llvm.array<0 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "bx", type = !llvm.array<0 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a12345", type = !llvm.array<5 x i8>, value = "\01\02\03\04\05"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a123456", type = !llvm.array<6 x i8>, value = "\01\02\03\04\05\06"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strncmp", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4294967296 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @bx} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%4, %5, %0) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "call_strncmp_ax_bx_uimax_p1", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4294967296 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @bx} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%4, %5, %0) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "call_strncmp_ax_bx_uimax_p2", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4294967297 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @a123456} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%4, %5, %0) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "fold_strncmp_a12345_2_uimax_p2", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4294967298 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @a12345} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @a123456} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %6 = "llvm.call"(%4, %5, %0) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "fold_strncmp_a12345_2_uimax_p3", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @ax() {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.mlir.global external @bx() {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.mlir.global external constant @a12345("\01\02\03\04\05") {addr_space = 0 : i32} + llvm.mlir.global external constant @a123456("\01\02\03\04\05\06") {addr_space = 0 : i32} + llvm.func @strncmp(!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.func @call_strncmp_ax_bx_uimax_p1() -> i32 { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.addressof @bx : !llvm.ptr + %2 = llvm.mlir.constant(4294967296 : i64) : i64 + %3 = llvm.call @strncmp(%0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %3 : i32 + } + llvm.func @call_strncmp_ax_bx_uimax_p2() -> i32 { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.addressof @bx : !llvm.ptr + %2 = llvm.mlir.constant(4294967296 : i64) : i64 + %3 = llvm.call @strncmp(%0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %3 : i32 + } + llvm.func @fold_strncmp_a12345_2_uimax_p2() -> i32 { + %0 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %1 = llvm.mlir.addressof @a12345 : !llvm.ptr + %2 = llvm.mlir.constant("\01\02\03\04\05\06") : !llvm.array<6 x i8> + %3 = llvm.mlir.addressof @a123456 : !llvm.ptr + %4 = llvm.mlir.constant(4294967297 : i64) : i64 + %5 = llvm.call @strncmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %5 : i32 + } + llvm.func @fold_strncmp_a12345_2_uimax_p3() -> i32 { + %0 = llvm.mlir.constant("\01\02\03\04\05\06") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @a123456 : !llvm.ptr + %2 = llvm.mlir.constant("\01\02\03\04\05") : !llvm.array<5 x i8> + %3 = llvm.mlir.addressof @a12345 : !llvm.ptr + %4 = llvm.mlir.constant(4294967298 : i64) : i64 + %5 = llvm.call @strncmp(%1, %3, %4) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/strncmp-4.ll.mlir b/test/LLVMDialect/InstCombine/strncmp-4.ll.mlir new file mode 100644 index 000000000..c76c4ee9b --- /dev/null +++ b/test/LLVMDialect/InstCombine/strncmp-4.ll.mlir @@ -0,0 +1,104 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a() {addr_space = 0 : i32} : !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> { + %0 = llvm.mlir.constant("2345") : !llvm.array<4 x i8> + %1 = llvm.mlir.constant("1231") : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("123") : !llvm.array<3 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + llvm.return %6 : !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + } + llvm.func @strncmp(!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.func @fold_strncmp_Aa_b(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("2345") : !llvm.array<4 x i8> + %1 = llvm.mlir.constant("1231") : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("123") : !llvm.array<3 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + %7 = llvm.mlir.addressof @a : !llvm.ptr + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.mlir.constant(0 : i64) : i64 + %11 = llvm.mlir.constant(1 : i64) : i64 + %12 = llvm.mlir.constant(2 : i64) : i64 + %13 = llvm.mlir.constant(3 : i64) : i64 + %14 = llvm.mlir.constant(4 : i64) : i64 + %15 = llvm.mlir.constant(5 : i64) : i64 + %16 = llvm.mlir.constant(6 : i64) : i64 + %17 = llvm.mlir.constant(7 : i64) : i64 + %18 = llvm.mlir.constant(8 : i64) : i64 + %19 = llvm.mlir.constant(9 : i64) : i64 + %20 = llvm.getelementptr %7[%8, 1, %8] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + %21 = llvm.call @strncmp(%7, %20, %10) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %21, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %22 = llvm.call @strncmp(%7, %20, %11) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %23 = llvm.getelementptr %arg0[%11] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %22, %23 {alignment = 4 : i64} : i32, !llvm.ptr + %24 = llvm.call @strncmp(%7, %20, %12) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %25 = llvm.getelementptr %arg0[%12] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %24, %25 {alignment = 4 : i64} : i32, !llvm.ptr + %26 = llvm.call @strncmp(%7, %20, %13) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %27 = llvm.getelementptr %arg0[%13] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %26, %27 {alignment = 4 : i64} : i32, !llvm.ptr + %28 = llvm.call @strncmp(%7, %20, %14) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %29 = llvm.getelementptr %arg0[%14] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %28, %29 {alignment = 4 : i64} : i32, !llvm.ptr + %30 = llvm.call @strncmp(%7, %20, %15) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %31 = llvm.getelementptr %arg0[%15] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %30, %31 {alignment = 4 : i64} : i32, !llvm.ptr + %32 = llvm.call @strncmp(%7, %20, %16) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %33 = llvm.getelementptr %arg0[%16] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %32, %33 {alignment = 4 : i64} : i32, !llvm.ptr + %34 = llvm.call @strncmp(%7, %20, %17) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %35 = llvm.getelementptr %arg0[%17] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %34, %35 {alignment = 4 : i64} : i32, !llvm.ptr + %36 = llvm.call @strncmp(%7, %20, %18) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %37 = llvm.getelementptr %arg0[%18] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %36, %37 {alignment = 4 : i64} : i32, !llvm.ptr + %38 = llvm.call @strncmp(%7, %20, %19) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %39 = llvm.getelementptr %arg0[%19] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %38, %39 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_strncmp_Ab_a(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("2345") : !llvm.array<4 x i8> + %1 = llvm.mlir.constant("1231") : !llvm.array<4 x i8> + %2 = llvm.mlir.constant("123") : !llvm.array<3 x i8> + %3 = llvm.mlir.undef : !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + %6 = llvm.insertvalue %0, %5[2] : !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + %7 = llvm.mlir.addressof @a : !llvm.ptr + %8 = llvm.mlir.constant(0 : i32) : i32 + %9 = llvm.mlir.constant(1 : i32) : i32 + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.mlir.constant(0 : i64) : i64 + %12 = llvm.mlir.constant(1 : i64) : i64 + %13 = llvm.mlir.constant(2 : i64) : i64 + %14 = llvm.mlir.constant(3 : i64) : i64 + %15 = llvm.mlir.constant(4 : i64) : i64 + %16 = llvm.mlir.constant(5 : i64) : i64 + %17 = llvm.getelementptr %7[%8, 1, %10] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.struct<"struct.A", (array<3 x i8>, array<4 x i8>, array<4 x i8>)> + %18 = llvm.call @strncmp(%17, %7, %11) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %18, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %19 = llvm.call @strncmp(%17, %7, %12) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %20 = llvm.getelementptr %arg0[%12] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %19, %20 {alignment = 4 : i64} : i32, !llvm.ptr + %21 = llvm.call @strncmp(%17, %7, %13) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %22 = llvm.getelementptr %arg0[%13] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %21, %22 {alignment = 4 : i64} : i32, !llvm.ptr + %23 = llvm.call @strncmp(%17, %7, %14) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %24 = llvm.getelementptr %arg0[%14] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %23, %24 {alignment = 4 : i64} : i32, !llvm.ptr + %25 = llvm.call @strncmp(%17, %7, %15) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %26 = llvm.getelementptr %arg0[%15] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %25, %26 {alignment = 4 : i64} : i32, !llvm.ptr + %27 = llvm.call @strncmp(%17, %7, %16) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %28 = llvm.getelementptr %arg0[%16] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %27, %28 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strncmp-5.ll.mlir b/test/LLVMDialect/InstCombine/strncmp-5.ll.mlir index 1fd52c9ff..623ad7011 100644 --- a/test/LLVMDialect/InstCombine/strncmp-5.ll.mlir +++ b/test/LLVMDialect/InstCombine/strncmp-5.ll.mlir @@ -1,226 +1,178 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "ax", type = !llvm.array<8 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a01230123", type = !llvm.array<8 x i8>, value = "01230123"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "b01230123", type = !llvm.array<8 x i8>, value = "01230123"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "c01230129", type = !llvm.array<8 x i8>, value = "01230129"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "d9123_12", type = !llvm.array<7 x i8>, value = "9123\0012"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "e9123_34", type = !llvm.array<7 x i8>, value = "9123\0034"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strncmp", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @b01230123} : () -> !llvm.ptr> - %3 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %4 = "llvm.mlir.addressof"() {global_name = @b01230123} : () -> !llvm.ptr> - %5 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %6 = "llvm.mlir.addressof"() {global_name = @b01230123} : () -> !llvm.ptr> - %7 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %8 = "llvm.mlir.addressof"() {global_name = @b01230123} : () -> !llvm.ptr> - %9 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %10 = "llvm.mlir.addressof"() {global_name = @b01230123} : () -> !llvm.ptr> - %11 = "llvm.mlir.addressof"() {global_name = @b01230123} : () -> !llvm.ptr> - %12 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %13 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %14 = "llvm.getelementptr"(%13, %12, %12) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %15 = "llvm.getelementptr"(%11, %12, %12) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %16 = "llvm.getelementptr"(%10, %12, %9) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %17 = "llvm.getelementptr"(%8, %12, %7) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %18 = "llvm.getelementptr"(%6, %12, %5) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %19 = "llvm.getelementptr"(%4, %12, %3) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %20 = "llvm.getelementptr"(%2, %12, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %21 = "llvm.call"(%14, %15, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %22 = "llvm.getelementptr"(%arg0, %12) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%21, %22) : (i32, !llvm.ptr) -> () - %23 = "llvm.call"(%14, %16, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %24 = "llvm.getelementptr"(%arg0, %9) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%23, %24) : (i32, !llvm.ptr) -> () - %25 = "llvm.call"(%14, %17, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %26 = "llvm.getelementptr"(%arg0, %7) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%25, %26) : (i32, !llvm.ptr) -> () - %27 = "llvm.call"(%14, %18, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %28 = "llvm.getelementptr"(%arg0, %5) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%27, %28) : (i32, !llvm.ptr) -> () - %29 = "llvm.call"(%14, %19, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %30 = "llvm.getelementptr"(%arg0, %3) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%29, %30) : (i32, !llvm.ptr) -> () - %31 = "llvm.call"(%14, %20, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %32 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%31, %32) : (i32, !llvm.ptr) -> () - %33 = "llvm.call"(%20, %14, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %34 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%33, %34) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strncmp_a_b_n", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.getelementptr"(%0, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%3, %4, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %6 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%5, %6) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "call_strncmp_a_ax_n", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @c01230129} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @c01230129} : () -> !llvm.ptr> - %4 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %5 = "llvm.mlir.addressof"() {global_name = @c01230129} : () -> !llvm.ptr> - %6 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %7 = "llvm.mlir.addressof"() {global_name = @c01230129} : () -> !llvm.ptr> - %8 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %9 = "llvm.mlir.addressof"() {global_name = @c01230129} : () -> !llvm.ptr> - %10 = "llvm.mlir.addressof"() {global_name = @c01230129} : () -> !llvm.ptr> - %11 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %12 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %13 = "llvm.getelementptr"(%12, %11, %11) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %14 = "llvm.getelementptr"(%10, %11, %11) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %15 = "llvm.getelementptr"(%9, %11, %8) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %16 = "llvm.getelementptr"(%7, %11, %6) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %17 = "llvm.getelementptr"(%5, %11, %4) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %18 = "llvm.getelementptr"(%3, %11, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %19 = "llvm.getelementptr"(%1, %11, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %20 = "llvm.call"(%13, %14, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %21 = "llvm.getelementptr"(%arg0, %11) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%20, %21) : (i32, !llvm.ptr) -> () - %22 = "llvm.call"(%13, %15, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %23 = "llvm.getelementptr"(%arg0, %8) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%22, %23) : (i32, !llvm.ptr) -> () - %24 = "llvm.call"(%13, %16, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %25 = "llvm.getelementptr"(%arg0, %6) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%24, %25) : (i32, !llvm.ptr) -> () - %26 = "llvm.call"(%13, %17, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %27 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%26, %27) : (i32, !llvm.ptr) -> () - %28 = "llvm.call"(%13, %18, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %29 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%28, %29) : (i32, !llvm.ptr) -> () - %30 = "llvm.call"(%13, %18, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %31 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%30, %31) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strncmp_a_c_n", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 7 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @d9123_12} : () -> !llvm.ptr> - %2 = "llvm.mlir.addressof"() {global_name = @d9123_12} : () -> !llvm.ptr> - %3 = "llvm.mlir.addressof"() {global_name = @d9123_12} : () -> !llvm.ptr> - %4 = "llvm.mlir.addressof"() {global_name = @d9123_12} : () -> !llvm.ptr> - %5 = "llvm.mlir.addressof"() {global_name = @d9123_12} : () -> !llvm.ptr> - %6 = "llvm.mlir.addressof"() {global_name = @d9123_12} : () -> !llvm.ptr> - %7 = "llvm.mlir.addressof"() {global_name = @d9123_12} : () -> !llvm.ptr> - %8 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %9 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %10 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %11 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %12 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %13 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %14 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %15 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %16 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %17 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %18 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %19 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %20 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %21 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %22 = "llvm.getelementptr"(%21, %20, %20) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %23 = "llvm.getelementptr"(%19, %20, %18) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %24 = "llvm.getelementptr"(%17, %20, %16) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %25 = "llvm.getelementptr"(%15, %20, %14) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %26 = "llvm.getelementptr"(%13, %20, %12) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %27 = "llvm.getelementptr"(%11, %20, %10) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %28 = "llvm.getelementptr"(%9, %20, %8) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %29 = "llvm.getelementptr"(%7, %20, %20) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %30 = "llvm.getelementptr"(%6, %20, %18) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %31 = "llvm.getelementptr"(%5, %20, %16) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %32 = "llvm.getelementptr"(%4, %20, %14) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %33 = "llvm.getelementptr"(%3, %20, %12) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %34 = "llvm.getelementptr"(%2, %20, %10) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %35 = "llvm.getelementptr"(%1, %20, %8) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %36 = "llvm.call"(%22, %29, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %37 = "llvm.getelementptr"(%arg0, %20) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%36, %37) : (i32, !llvm.ptr) -> () - %38 = "llvm.call"(%22, %30, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %39 = "llvm.getelementptr"(%arg0, %18) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%38, %39) : (i32, !llvm.ptr) -> () - %40 = "llvm.call"(%23, %30, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %41 = "llvm.getelementptr"(%arg0, %16) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%40, %41) : (i32, !llvm.ptr) -> () - %42 = "llvm.call"(%24, %31, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %43 = "llvm.getelementptr"(%arg0, %14) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%42, %43) : (i32, !llvm.ptr) -> () - %44 = "llvm.call"(%25, %32, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %45 = "llvm.getelementptr"(%arg0, %12) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%44, %45) : (i32, !llvm.ptr) -> () - %46 = "llvm.call"(%26, %33, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %47 = "llvm.getelementptr"(%arg0, %12) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%46, %47) : (i32, !llvm.ptr) -> () - %48 = "llvm.call"(%33, %26, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %49 = "llvm.getelementptr"(%arg0, %10) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%48, %49) : (i32, !llvm.ptr) -> () - %50 = "llvm.call"(%27, %34, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %51 = "llvm.getelementptr"(%arg0, %8) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%50, %51) : (i32, !llvm.ptr) -> () - %52 = "llvm.call"(%28, %35, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %53 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%52, %53) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strncmp_a_d_n", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @d9123_12} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @a01230123} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.getelementptr"(%1, %2, %2) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %6 = "llvm.or"(%arg1, %0) : (i64, i64) -> i64 - %7 = "llvm.call"(%4, %5, %6) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %8 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%7, %8) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strncmp_a_d_nz", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @e9123_34} : () -> !llvm.ptr> - %3 = "llvm.mlir.addressof"() {global_name = @e9123_34} : () -> !llvm.ptr> - %4 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %5 = "llvm.mlir.addressof"() {global_name = @d9123_12} : () -> !llvm.ptr> - %6 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %7 = "llvm.mlir.addressof"() {global_name = @d9123_12} : () -> !llvm.ptr> - %8 = "llvm.getelementptr"(%7, %6, %6) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %9 = "llvm.getelementptr"(%5, %6, %4) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %10 = "llvm.getelementptr"(%3, %6, %6) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %11 = "llvm.getelementptr"(%2, %6, %4) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %12 = "llvm.call"(%8, %10, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %13 = "llvm.getelementptr"(%arg0, %6) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%12, %13) : (i32, !llvm.ptr) -> () - %14 = "llvm.call"(%8, %11, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %15 = "llvm.getelementptr"(%arg0, %4) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%14, %15) : (i32, !llvm.ptr) -> () - %16 = "llvm.call"(%9, %10, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %17 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%16, %17) : (i32, !llvm.ptr) -> () - %18 = "llvm.call"(%9, %11, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %19 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%18, %19) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strncmp_d_e_n", type = !llvm.func, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @ax() {addr_space = 0 : i32} : !llvm.array<8 x i8> + llvm.mlir.global external constant @a01230123("01230123") {addr_space = 0 : i32} + llvm.mlir.global external constant @b01230123("01230123") {addr_space = 0 : i32} + llvm.mlir.global external constant @c01230129("01230129") {addr_space = 0 : i32} + llvm.mlir.global external constant @d9123_12("9123\0012") {addr_space = 0 : i32} + llvm.mlir.global external constant @e9123_34("9123\0034") {addr_space = 0 : i32} + llvm.func @strncmp(!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.func @fold_strncmp_a_b_n(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("01230123") : !llvm.array<8 x i8> + %1 = llvm.mlir.addressof @b01230123 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(2 : i64) : i64 + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.constant(4 : i64) : i64 + %7 = llvm.mlir.constant(5 : i64) : i64 + %8 = llvm.mlir.addressof @a01230123 : !llvm.ptr + %9 = llvm.mlir.constant(6 : i64) : i64 + %10 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %11 = llvm.getelementptr %1[%2, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %12 = llvm.getelementptr %1[%2, %5] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %13 = llvm.getelementptr %1[%2, %6] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %14 = llvm.getelementptr %1[%2, %7] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %15 = llvm.call @strncmp(%8, %1, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %15, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %16 = llvm.call @strncmp(%8, %10, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %17 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %16, %17 {alignment = 4 : i64} : i32, !llvm.ptr + %18 = llvm.call @strncmp(%8, %11, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %19 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %18, %19 {alignment = 4 : i64} : i32, !llvm.ptr + %20 = llvm.call @strncmp(%8, %12, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %21 = llvm.getelementptr %arg0[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %20, %21 {alignment = 4 : i64} : i32, !llvm.ptr + %22 = llvm.call @strncmp(%8, %13, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %23 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %22, %23 {alignment = 4 : i64} : i32, !llvm.ptr + %24 = llvm.call @strncmp(%8, %14, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %25 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %24, %25 {alignment = 4 : i64} : i32, !llvm.ptr + %26 = llvm.call @strncmp(%14, %8, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %27 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %26, %27 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @call_strncmp_a_ax_n(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("01230123") : !llvm.array<8 x i8> + %1 = llvm.mlir.addressof @a01230123 : !llvm.ptr + %2 = llvm.mlir.addressof @ax : !llvm.ptr + %3 = llvm.call @strncmp(%1, %2, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %3, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_strncmp_a_c_n(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("01230129") : !llvm.array<8 x i8> + %1 = llvm.mlir.addressof @c01230129 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(2 : i64) : i64 + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.constant(4 : i64) : i64 + %7 = llvm.mlir.constant(5 : i64) : i64 + %8 = llvm.mlir.constant("01230123") : !llvm.array<8 x i8> + %9 = llvm.mlir.addressof @a01230123 : !llvm.ptr + %10 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %11 = llvm.getelementptr %1[%2, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %12 = llvm.getelementptr %1[%2, %5] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %13 = llvm.getelementptr %1[%2, %6] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %14 = llvm.getelementptr %1[%2, %7] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %15 = llvm.call @strncmp(%9, %1, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %15, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %16 = llvm.call @strncmp(%9, %10, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %17 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %16, %17 {alignment = 4 : i64} : i32, !llvm.ptr + %18 = llvm.call @strncmp(%9, %11, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %19 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %18, %19 {alignment = 4 : i64} : i32, !llvm.ptr + %20 = llvm.call @strncmp(%9, %12, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %21 = llvm.getelementptr %arg0[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %20, %21 {alignment = 4 : i64} : i32, !llvm.ptr + %22 = llvm.call @strncmp(%9, %13, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %23 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %22, %23 {alignment = 4 : i64} : i32, !llvm.ptr + %24 = llvm.call @strncmp(%9, %13, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %25 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %24, %25 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_strncmp_a_d_n(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("01230123") : !llvm.array<8 x i8> + %1 = llvm.mlir.addressof @a01230123 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(2 : i64) : i64 + %5 = llvm.mlir.constant(3 : i64) : i64 + %6 = llvm.mlir.constant(4 : i64) : i64 + %7 = llvm.mlir.constant(5 : i64) : i64 + %8 = llvm.mlir.constant(6 : i64) : i64 + %9 = llvm.mlir.constant("9123\0012") : !llvm.array<7 x i8> + %10 = llvm.mlir.addressof @d9123_12 : !llvm.ptr + %11 = llvm.mlir.constant(7 : i64) : i64 + %12 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %13 = llvm.getelementptr %1[%2, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %14 = llvm.getelementptr %1[%2, %5] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %15 = llvm.getelementptr %1[%2, %6] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %16 = llvm.getelementptr %1[%2, %7] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %17 = llvm.getelementptr %1[%2, %8] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<8 x i8> + %18 = llvm.getelementptr %10[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %19 = llvm.getelementptr %10[%2, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %20 = llvm.getelementptr %10[%2, %5] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %21 = llvm.getelementptr %10[%2, %6] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %22 = llvm.getelementptr %10[%2, %7] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %23 = llvm.getelementptr %10[%2, %8] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %24 = llvm.call @strncmp(%1, %10, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %24, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %25 = llvm.call @strncmp(%1, %18, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %26 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %25, %26 {alignment = 4 : i64} : i32, !llvm.ptr + %27 = llvm.call @strncmp(%12, %18, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %28 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %27, %28 {alignment = 4 : i64} : i32, !llvm.ptr + %29 = llvm.call @strncmp(%13, %19, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %30 = llvm.getelementptr %arg0[%5] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %29, %30 {alignment = 4 : i64} : i32, !llvm.ptr + %31 = llvm.call @strncmp(%14, %20, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %32 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %31, %32 {alignment = 4 : i64} : i32, !llvm.ptr + %33 = llvm.call @strncmp(%15, %21, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %34 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %33, %34 {alignment = 4 : i64} : i32, !llvm.ptr + %35 = llvm.call @strncmp(%21, %15, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %36 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %35, %36 {alignment = 4 : i64} : i32, !llvm.ptr + %37 = llvm.call @strncmp(%16, %22, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %38 = llvm.getelementptr %arg0[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %37, %38 {alignment = 4 : i64} : i32, !llvm.ptr + %39 = llvm.call @strncmp(%17, %23, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %40 = llvm.getelementptr %arg0[%11] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %39, %40 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_strncmp_a_d_nz(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant("01230123") : !llvm.array<8 x i8> + %2 = llvm.mlir.addressof @a01230123 : !llvm.ptr + %3 = llvm.mlir.constant("9123\0012") : !llvm.array<7 x i8> + %4 = llvm.mlir.addressof @d9123_12 : !llvm.ptr + %5 = llvm.or %arg1, %0 : i64 + %6 = llvm.call @strncmp(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %6, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_strncmp_d_e_n(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("9123\0012") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @d9123_12 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant("9123\0034") : !llvm.array<7 x i8> + %5 = llvm.mlir.addressof @e9123_34 : !llvm.ptr + %6 = llvm.mlir.constant(2 : i64) : i64 + %7 = llvm.mlir.constant(3 : i64) : i64 + %8 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %9 = llvm.getelementptr %5[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %10 = llvm.call @strncmp(%1, %5, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %10, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %11 = llvm.call @strncmp(%1, %9, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %12 = llvm.getelementptr %arg0[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %11, %12 {alignment = 4 : i64} : i32, !llvm.ptr + %13 = llvm.call @strncmp(%8, %5, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %14 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %13, %14 {alignment = 4 : i64} : i32, !llvm.ptr + %15 = llvm.call @strncmp(%8, %9, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %16 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %15, %16 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strncmp-6.ll.mlir b/test/LLVMDialect/InstCombine/strncmp-6.ll.mlir index 56ad5f128..3025d6495 100644 --- a/test/LLVMDialect/InstCombine/strncmp-6.ll.mlir +++ b/test/LLVMDialect/InstCombine/strncmp-6.ll.mlir @@ -1,68 +1,58 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a", type = !llvm.array<7 x i8>, value = "abcdef\7F"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "b", type = !llvm.array<7 x i8>, value = "abcdef\80"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strncmp", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @b} : () -> !llvm.ptr> - %4 = "llvm.mlir.addressof"() {global_name = @b} : () -> !llvm.ptr> - %5 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %6 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %7 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %8 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %9 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %10 = "llvm.getelementptr"(%9, %8, %7) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %11 = "llvm.getelementptr"(%6, %8, %5) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %12 = "llvm.getelementptr"(%4, %8, %7) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %13 = "llvm.getelementptr"(%3, %8, %5) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %14 = "llvm.call"(%10, %12, %2) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %15 = "llvm.getelementptr"(%arg0, %8) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%14, %15) : (i32, !llvm.ptr) -> () - %16 = "llvm.call"(%12, %10, %2) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %17 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%16, %17) : (i32, !llvm.ptr) -> () - %18 = "llvm.call"(%11, %13, %1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %19 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%18, %19) : (i32, !llvm.ptr) -> () - %20 = "llvm.call"(%13, %11, %1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %21 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%20, %21) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strncmp_cst_cst", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %3 = "llvm.mlir.addressof"() {global_name = @b} : () -> !llvm.ptr> - %4 = "llvm.mlir.addressof"() {global_name = @b} : () -> !llvm.ptr> - %5 = "llvm.mlir.constant"() {value = 6 : i64} : () -> i64 - %6 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %7 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %8 = "llvm.mlir.addressof"() {global_name = @a} : () -> !llvm.ptr> - %9 = "llvm.getelementptr"(%8, %7, %7) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %10 = "llvm.getelementptr"(%6, %7, %5) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %11 = "llvm.getelementptr"(%4, %7, %7) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %12 = "llvm.getelementptr"(%3, %7, %5) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %13 = "llvm.call"(%9, %11, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %14 = "llvm.getelementptr"(%arg0, %7) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%13, %14) : (i32, !llvm.ptr) -> () - %15 = "llvm.call"(%11, %9, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %16 = "llvm.getelementptr"(%arg0, %2) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%15, %16) : (i32, !llvm.ptr) -> () - %17 = "llvm.call"(%10, %12, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %18 = "llvm.getelementptr"(%arg0, %1) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%17, %18) : (i32, !llvm.ptr) -> () - %19 = "llvm.call"(%12, %10, %arg1) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> i32 - %20 = "llvm.getelementptr"(%arg0, %0) : (!llvm.ptr, i64) -> !llvm.ptr - "llvm.store"(%19, %20) : (i32, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strncmp_cst_var", type = !llvm.func, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @a("abcdef\7F") {addr_space = 0 : i32} + llvm.mlir.global external constant @b("abcdef\80") {addr_space = 0 : i32} + llvm.func @strncmp(!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.func @fold_strncmp_cst_cst(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("abcdef\7F") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(5 : i64) : i64 + %4 = llvm.mlir.constant(6 : i64) : i64 + %5 = llvm.mlir.constant("abcdef\80") : !llvm.array<7 x i8> + %6 = llvm.mlir.addressof @b : !llvm.ptr + %7 = llvm.mlir.constant(2 : i64) : i64 + %8 = llvm.mlir.constant(1 : i64) : i64 + %9 = llvm.mlir.constant(3 : i64) : i64 + %10 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %11 = llvm.getelementptr %1[%2, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %12 = llvm.getelementptr %6[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %13 = llvm.getelementptr %6[%2, %4] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %14 = llvm.call @strncmp(%10, %12, %7) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %14, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %15 = llvm.call @strncmp(%12, %10, %7) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %16 = llvm.getelementptr %arg0[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %15, %16 {alignment = 4 : i64} : i32, !llvm.ptr + %17 = llvm.call @strncmp(%11, %13, %8) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %18 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %17, %18 {alignment = 4 : i64} : i32, !llvm.ptr + %19 = llvm.call @strncmp(%13, %11, %8) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %20 = llvm.getelementptr %arg0[%9] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %19, %20 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @fold_strncmp_cst_var(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("abcdef\7F") : !llvm.array<7 x i8> + %1 = llvm.mlir.addressof @a : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(6 : i64) : i64 + %4 = llvm.mlir.constant("abcdef\80") : !llvm.array<7 x i8> + %5 = llvm.mlir.addressof @b : !llvm.ptr + %6 = llvm.mlir.constant(1 : i64) : i64 + %7 = llvm.mlir.constant(2 : i64) : i64 + %8 = llvm.mlir.constant(3 : i64) : i64 + %9 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %10 = llvm.getelementptr %5[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<7 x i8> + %11 = llvm.call @strncmp(%1, %5, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + llvm.store %11, %arg0 {alignment = 4 : i64} : i32, !llvm.ptr + %12 = llvm.call @strncmp(%5, %1, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %13 = llvm.getelementptr %arg0[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %12, %13 {alignment = 4 : i64} : i32, !llvm.ptr + %14 = llvm.call @strncmp(%9, %10, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %15 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %14, %15 {alignment = 4 : i64} : i32, !llvm.ptr + %16 = llvm.call @strncmp(%10, %9, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> i32 + %17 = llvm.getelementptr %arg0[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %16, %17 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strncmp-wrong-datalayout.ll.mlir b/test/LLVMDialect/InstCombine/strncmp-wrong-datalayout.ll.mlir index 1a4a014d1..f3c8aeaaa 100644 --- a/test/LLVMDialect/InstCombine/strncmp-wrong-datalayout.ll.mlir +++ b/test/LLVMDialect/InstCombine/strncmp-wrong-datalayout.ll.mlir @@ -1,11 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strncmp", type = !llvm.func, ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @strncmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @strncmp(!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.func @test6(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.call @strncmp(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/strncpy-1.ll.mlir b/test/LLVMDialect/InstCombine/strncpy-1.ll.mlir new file mode 100644 index 000000000..01373c608 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strncpy-1.ll.mlir @@ -0,0 +1,146 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external constant @null_hello("\00hello\00") {addr_space = 0 : i32} + llvm.mlir.global common @a(dense<0> : tensor<32xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i8> + llvm.mlir.global common @b(dense<0> : tensor<32xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i8> + llvm.func @strncpy(!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.func @puts(!llvm.ptr) -> i32 + llvm.func @test_simplify1() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %3 = llvm.mlir.addressof @hello : !llvm.ptr + %4 = llvm.mlir.constant(6 : i32) : i32 + %5 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %6 = llvm.mlir.addressof @null : !llvm.ptr + %7 = llvm.mlir.constant(42 : i32) : i32 + %8 = llvm.mlir.constant("\00hello\00") : !llvm.array<7 x i8> + %9 = llvm.mlir.addressof @null_hello : !llvm.ptr + %10 = llvm.mlir.constant(0 : i32) : i32 + %11 = llvm.alloca %0 x !llvm.array<1024 x i8> {alignment = 1 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %11 {alignment = 1 : i64} : i8, !llvm.ptr + %12 = llvm.call @strncpy(%11, %3, %4) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + %13 = llvm.call @strncpy(%12, %6, %7) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + %14 = llvm.call @strncpy(%13, %9, %7) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + %15 = llvm.call @puts(%14) : (!llvm.ptr) -> i32 + llvm.return %10 : i32 + } + llvm.func @test_simplify2() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %4 = llvm.mlir.addressof @null : !llvm.ptr + %5 = llvm.mlir.constant(32 : i32) : i32 + %6 = llvm.call @strncpy(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return + } + llvm.func @test_simplify3() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.call @strncpy(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @test_simplify4() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.mlir.constant(6 : i32) : i32 + %6 = llvm.call @strncpy(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return + } + llvm.func @test_simplify5(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.call @strncpy(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return + } + llvm.func @test_simplify6(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(32 : i32) : i32 + %3 = llvm.call @strncpy(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return + } + llvm.func @test_simplify7(%arg0: !llvm.ptr, %arg1: i32) { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @strncpy(%arg0, %2, %arg1) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return + } + llvm.func @test1(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.call @strncpy(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test2(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(5 : i32) : i32 + %3 = llvm.call @strncpy(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @test3(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.call @strncpy(%arg0, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @test4(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.call @strncpy(%arg0, %2, %3) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @test_no_simplify1() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(32 : i32) : i32 + %5 = llvm.call @strncpy(%2, %3, %4) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return + } + llvm.func @test_no_simplify2() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.mlir.constant(8 : i32) : i32 + %6 = llvm.call @strncpy(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return + } + llvm.func @test_no_simplify3(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.call @strncpy(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test_no_simplify4(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.call @strncpy(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return %1 : !llvm.ptr + } + llvm.func @test_no_incompatible_attr() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.mlir.constant(6 : i32) : i32 + %6 = llvm.call @strncpy(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i32) -> !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strncpy-2.ll.mlir b/test/LLVMDialect/InstCombine/strncpy-2.ll.mlir new file mode 100644 index 000000000..0d5b28c5d --- /dev/null +++ b/test/LLVMDialect/InstCombine/strncpy-2.ll.mlir @@ -0,0 +1,15 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global common @a(dense<0> : tensor<32xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i8> + llvm.func @strncpy(!llvm.ptr, !llvm.ptr, i32) -> i16 + llvm.func @test_no_simplify1() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi8>) : !llvm.array<32 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @hello : !llvm.ptr + %5 = llvm.mlir.constant(6 : i32) : i32 + %6 = llvm.call @strncpy(%2, %4, %5) : (!llvm.ptr, !llvm.ptr, i32) -> i16 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strncpy-3.ll.mlir b/test/LLVMDialect/InstCombine/strncpy-3.ll.mlir index 1429d8fe1..99b6053b0 100644 --- a/test/LLVMDialect/InstCombine/strncpy-3.ll.mlir +++ b/test/LLVMDialect/InstCombine/strncpy-3.ll.mlir @@ -1,56 +1,41 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "str", type = !llvm.array<2 x i8>, value = "a\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "str2", type = !llvm.array<3 x i8>, value = "abc"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "str3", type = !llvm.array<4 x i8>, value = "abcd"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strncpy", type = !llvm.func (ptr, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @str} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %0) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fill_with_zeros", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @str2} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %0) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fill_with_zeros2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @str3} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %0) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fill_with_zeros3", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 128 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @str3} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %0) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fill_with_zeros4", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 129 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @str3} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%arg0, %3, %0) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "no_simplify", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @str("a\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @str2("abc") {addr_space = 0 : i32} + llvm.mlir.global external constant @str3("abcd") {addr_space = 0 : i32} + llvm.func @strncpy(!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.func @fill_with_zeros(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("a\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @str : !llvm.ptr + %2 = llvm.mlir.constant(4 : i64) : i64 + %3 = llvm.call @strncpy(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return + } + llvm.func @fill_with_zeros2(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("abc") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @str2 : !llvm.ptr + %2 = llvm.mlir.constant(4 : i64) : i64 + %3 = llvm.call @strncpy(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return + } + llvm.func @fill_with_zeros3(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("abcd") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @str3 : !llvm.ptr + %2 = llvm.mlir.constant(4 : i64) : i64 + %3 = llvm.call @strncpy(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return + } + llvm.func @fill_with_zeros4(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("abcd") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @str3 : !llvm.ptr + %2 = llvm.mlir.constant(128 : i64) : i64 + %3 = llvm.call @strncpy(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return + } + llvm.func @no_simplify(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant("abcd") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @str3 : !llvm.ptr + %2 = llvm.mlir.constant(129 : i64) : i64 + %3 = llvm.call @strncpy(%arg0, %1, %2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strncpy-4.ll.mlir b/test/LLVMDialect/InstCombine/strncpy-4.ll.mlir index 980551e29..2bbb94590 100644 --- a/test/LLVMDialect/InstCombine/strncpy-4.ll.mlir +++ b/test/LLVMDialect/InstCombine/strncpy-4.ll.mlir @@ -1,75 +1,67 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "s4", type = !llvm.array<9 x i8>, value = "1234\00567\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strncpy", type = !llvm.func (ptr, ptr, i64)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sink", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.call"(%arg0, %arg0, %1) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %2) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %3 = "llvm.call"(%arg0, %arg0, %0) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %3) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strncpy_overlap", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %2 = "llvm.call"(%arg0, %arg0, %1) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %2) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %3 = "llvm.call"(%arg0, %arg0, %0) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %3) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %4 = "llvm.call"(%arg0, %arg0, %arg1) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %4) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "call_strncpy_overlap", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %2 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %3 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %4 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %5 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %6 = "llvm.mlir.addressof"() {global_name = @s4} : () -> !llvm.ptr> - %7 = "llvm.getelementptr"(%6, %5, %4) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %8 = "llvm.call"(%arg0, %7, %3) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %8) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %9 = "llvm.call"(%arg0, %7, %2) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %9) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %10 = "llvm.call"(%arg0, %7, %1) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %10) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %11 = "llvm.call"(%arg0, %7, %0) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %11) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %12 = "llvm.call"(%arg0, %7, %arg1) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %12) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strncpy_s0", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.call"(%arg0, %arg1, %1) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %2) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %3 = "llvm.call"(%arg0, %arg1, %0) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %3) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "fold_strncpy_s", type = !llvm.func, ptr, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %2 = "llvm.call"(%arg0, %arg1, %1) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %2) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %3 = "llvm.call"(%arg0, %arg1, %0) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %3) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %4 = "llvm.call"(%arg0, %arg1, %arg2) {callee = @strncpy, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - "llvm.call"(%arg0, %4) {callee = @sink, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "call_strncpy_s", type = !llvm.func, ptr, i64)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @s4("1234\00567\00") {addr_space = 0 : i32} + llvm.func @strncpy(!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.func @sink(!llvm.ptr, !llvm.ptr) + llvm.func @fold_strncpy_overlap(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.call @strncpy(%arg0, %arg0, %0) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> () + %3 = llvm.call @strncpy(%arg0, %arg0, %1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %3) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @call_strncpy_overlap(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.call @strncpy(%arg0, %arg0, %0) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> () + %3 = llvm.call @strncpy(%arg0, %arg0, %1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %3) : (!llvm.ptr, !llvm.ptr) -> () + %4 = llvm.call @strncpy(%arg0, %arg0, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %4) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @fold_strncpy_s0(%arg0: !llvm.ptr, %arg1: i64) { + %0 = llvm.mlir.constant("1234\00567\00") : !llvm.array<9 x i8> + %1 = llvm.mlir.addressof @s4 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.mlir.constant(1 : i64) : i64 + %6 = llvm.mlir.constant(2 : i64) : i64 + %7 = llvm.mlir.constant(9 : i64) : i64 + %8 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<9 x i8> + %9 = llvm.call @strncpy(%arg0, %8, %4) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %9) : (!llvm.ptr, !llvm.ptr) -> () + %10 = llvm.call @strncpy(%arg0, %8, %5) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %10) : (!llvm.ptr, !llvm.ptr) -> () + %11 = llvm.call @strncpy(%arg0, %8, %6) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %11) : (!llvm.ptr, !llvm.ptr) -> () + %12 = llvm.call @strncpy(%arg0, %8, %7) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %12) : (!llvm.ptr, !llvm.ptr) -> () + %13 = llvm.call @strncpy(%arg0, %8, %arg1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %13) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @fold_strncpy_s(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64) { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.call @strncpy(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> () + %3 = llvm.call @strncpy(%arg0, %arg1, %1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %3) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @call_strncpy_s(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64) { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.mlir.constant(9 : i64) : i64 + %2 = llvm.call @strncpy(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> () + %3 = llvm.call @strncpy(%arg0, %arg1, %1) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %3) : (!llvm.ptr, !llvm.ptr) -> () + %4 = llvm.call @strncpy(%arg0, %arg1, %arg2) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + llvm.call @sink(%arg0, %4) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strncpy_chk-1.ll.mlir b/test/LLVMDialect/InstCombine/strncpy_chk-1.ll.mlir new file mode 100644 index 000000000..81c24c7d1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strncpy_chk-1.ll.mlir @@ -0,0 +1,58 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @a(dense<0> : tensor<60xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<60 x i8> + llvm.mlir.global common @b(dense<0> : tensor<60xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<60 x i8> + llvm.mlir.global private constant @".str"("abcdefghijk\00") {addr_space = 0 : i32, dso_local} + llvm.func @test_simplify1() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("abcdefghijk\00") : !llvm.array<12 x i8> + %4 = llvm.mlir.addressof @".str" : !llvm.ptr + %5 = llvm.mlir.constant(12 : i32) : i32 + %6 = llvm.mlir.constant(60 : i32) : i32 + %7 = llvm.call @__strncpy_chk(%2, %4, %5, %6) : (!llvm.ptr, !llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %7 : !llvm.ptr + } + llvm.func @test_simplify2() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("abcdefghijk\00") : !llvm.array<12 x i8> + %4 = llvm.mlir.addressof @".str" : !llvm.ptr + %5 = llvm.mlir.constant(12 : i32) : i32 + %6 = llvm.call @__strncpy_chk(%2, %4, %5, %5) : (!llvm.ptr, !llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @test_simplify3() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(12 : i32) : i32 + %5 = llvm.mlir.constant(60 : i32) : i32 + %6 = llvm.call @__strncpy_chk(%2, %3, %4, %5) : (!llvm.ptr, !llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @test_no_simplify1() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant("abcdefghijk\00") : !llvm.array<12 x i8> + %4 = llvm.mlir.addressof @".str" : !llvm.ptr + %5 = llvm.mlir.constant(8 : i32) : i32 + %6 = llvm.mlir.constant(4 : i32) : i32 + %7 = llvm.call @__strncpy_chk(%2, %4, %5, %6) : (!llvm.ptr, !llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %7 : !llvm.ptr + } + llvm.func @test_no_simplify2() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.addressof @b : !llvm.ptr + %4 = llvm.mlir.constant(8 : i32) : i32 + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.call @__strncpy_chk(%2, %3, %4, %5) : (!llvm.ptr, !llvm.ptr, i32, i32) -> !llvm.ptr + llvm.return %6 : !llvm.ptr + } + llvm.func @__strncpy_chk(!llvm.ptr, !llvm.ptr, i32, i32) -> !llvm.ptr +} diff --git a/test/LLVMDialect/InstCombine/strncpy_chk-2.ll.mlir b/test/LLVMDialect/InstCombine/strncpy_chk-2.ll.mlir new file mode 100644 index 000000000..2ddbaee10 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strncpy_chk-2.ll.mlir @@ -0,0 +1,16 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common @a(dense<0> : tensor<60xi16>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<60 x i16> + llvm.mlir.global common @b(dense<0> : tensor<60xi8>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<60 x i8> + llvm.func @test_no_simplify() { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : tensor<60xi16>) : !llvm.array<60 x i16> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.mlir.constant(dense<0> : tensor<60xi8>) : !llvm.array<60 x i8> + %5 = llvm.mlir.addressof @b : !llvm.ptr + %6 = llvm.mlir.constant(60 : i32) : i32 + %7 = llvm.call @__strncpy_chk(%2, %5, %6, %6) : (!llvm.ptr, !llvm.ptr, i32, i32) -> i16 + llvm.return + } + llvm.func @__strncpy_chk(!llvm.ptr, !llvm.ptr, i32, i32) -> i16 +} diff --git a/test/LLVMDialect/InstCombine/strndup.ll.mlir b/test/LLVMDialect/InstCombine/strndup.ll.mlir new file mode 100644 index 000000000..1cee67fbc --- /dev/null +++ b/test/LLVMDialect/InstCombine/strndup.ll.mlir @@ -0,0 +1,47 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.func @strndup(!llvm.ptr, i64) -> !llvm.ptr + llvm.func @test1() -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.call @strndup(%2, %3) : (!llvm.ptr, i64) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @test2() -> !llvm.ptr { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(4 : i64) : i64 + %3 = llvm.call @strndup(%1, %2) : (!llvm.ptr, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @test3() -> !llvm.ptr { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.call @strndup(%1, %2) : (!llvm.ptr, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @test4() -> !llvm.ptr { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(6 : i64) : i64 + %3 = llvm.call @strndup(%1, %2) : (!llvm.ptr, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @test5() -> !llvm.ptr { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(7 : i64) : i64 + %3 = llvm.call @strndup(%1, %2) : (!llvm.ptr, i64) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @test6(%arg0: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant("hello\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.call @strndup(%1, %arg0) : (!llvm.ptr, i64) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/strnlen-1.ll.mlir b/test/LLVMDialect/InstCombine/strnlen-1.ll.mlir index 70a2308de..c103ebd65 100644 --- a/test/LLVMDialect/InstCombine/strnlen-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/strnlen-1.ll.mlir @@ -1,113 +1,101 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "ax", type = !llvm.array<0 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "s5", type = !llvm.array<6 x i8>, value = "12345\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "s5_3", type = !llvm.array<9 x i8>, value = "12345\00xyz"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strnlen", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%0) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "no_access_strnlen_p_n", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %1 = "llvm.call"(%arg0, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%1) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "access_strnlen_p_2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.or"(%arg1, %0) : (i64, i64) -> i64 - %2 = "llvm.call"(%arg0, %1) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "access_strnlen_p_nz", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_ax_0", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_ax_1", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @s5} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_s5_0", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @s5} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_s5_4", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @s5} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_s5_5", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = -1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @s5} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_s5_m1", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 4 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @s5_3} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_s5_3_p4_5", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 5 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 5 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @s5_3} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_s5_3_p5_5", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 6 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @s5_3} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_s5_3_p6_3", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 6 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @s5_3} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%5) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "call_strnlen_s5_3_p6_4", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @ax() {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.mlir.global external constant @s5("12345\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s5_3("12345\00xyz") {addr_space = 0 : i32} + llvm.func @strnlen(!llvm.ptr, i64) -> i64 + llvm.func @no_access_strnlen_p_n(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.call @strnlen(%arg0, %arg1) : (!llvm.ptr, i64) -> i64 + llvm.return %0 : i64 + } + llvm.func @access_strnlen_p_2(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.call @strnlen(%arg0, %0) : (!llvm.ptr, i64) -> i64 + llvm.return %1 : i64 + } + llvm.func @access_strnlen_p_nz(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.or %arg1, %0 : i64 + %2 = llvm.call @strnlen(%arg0, %1) : (!llvm.ptr, i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @fold_strnlen_ax_0() -> i64 { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.call @strnlen(%0, %1) : (!llvm.ptr, i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @fold_strnlen_ax_1() -> i64 { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.call @strnlen(%0, %1) : (!llvm.ptr, i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @fold_strnlen_s5_0() -> i64 { + %0 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @s5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.call @strnlen(%1, %2) : (!llvm.ptr, i64) -> i64 + llvm.return %3 : i64 + } + llvm.func @fold_strnlen_s5_4() -> i64 { + %0 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @s5 : !llvm.ptr + %2 = llvm.mlir.constant(4 : i64) : i64 + %3 = llvm.call @strnlen(%1, %2) : (!llvm.ptr, i64) -> i64 + llvm.return %3 : i64 + } + llvm.func @fold_strnlen_s5_5() -> i64 { + %0 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @s5 : !llvm.ptr + %2 = llvm.mlir.constant(5 : i64) : i64 + %3 = llvm.call @strnlen(%1, %2) : (!llvm.ptr, i64) -> i64 + llvm.return %3 : i64 + } + llvm.func @fold_strnlen_s5_m1() -> i64 { + %0 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @s5 : !llvm.ptr + %2 = llvm.mlir.constant(-1 : i64) : i64 + %3 = llvm.call @strnlen(%1, %2) : (!llvm.ptr, i64) -> i64 + llvm.return %3 : i64 + } + llvm.func @fold_strnlen_s5_3_p4_5() -> i64 { + %0 = llvm.mlir.constant("12345\00xyz") : !llvm.array<9 x i8> + %1 = llvm.mlir.addressof @s5_3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(4 : i32) : i32 + %4 = llvm.mlir.constant(5 : i64) : i64 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<9 x i8> + %6 = llvm.call @strnlen(%5, %4) : (!llvm.ptr, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @fold_strnlen_s5_3_p5_5() -> i64 { + %0 = llvm.mlir.constant("12345\00xyz") : !llvm.array<9 x i8> + %1 = llvm.mlir.addressof @s5_3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(5 : i32) : i32 + %4 = llvm.mlir.constant(5 : i64) : i64 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<9 x i8> + %6 = llvm.call @strnlen(%5, %4) : (!llvm.ptr, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @fold_strnlen_s5_3_p6_3() -> i64 { + %0 = llvm.mlir.constant("12345\00xyz") : !llvm.array<9 x i8> + %1 = llvm.mlir.addressof @s5_3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(6 : i32) : i32 + %4 = llvm.mlir.constant(3 : i64) : i64 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<9 x i8> + %6 = llvm.call @strnlen(%5, %4) : (!llvm.ptr, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @call_strnlen_s5_3_p6_4() -> i64 { + %0 = llvm.mlir.constant("12345\00xyz") : !llvm.array<9 x i8> + %1 = llvm.mlir.addressof @s5_3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(6 : i32) : i32 + %4 = llvm.mlir.constant(4 : i64) : i64 + %5 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<9 x i8> + %6 = llvm.call @strnlen(%5, %4) : (!llvm.ptr, i64) -> i64 + llvm.return %6 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/strnlen-2.ll.mlir b/test/LLVMDialect/InstCombine/strnlen-2.ll.mlir new file mode 100644 index 000000000..5d8885add --- /dev/null +++ b/test/LLVMDialect/InstCombine/strnlen-2.ll.mlir @@ -0,0 +1,119 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @s3("123\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s5("12345\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s5_3("12345\00678\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s6("123456\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s7("1234567\00") {addr_space = 0 : i32} + llvm.func @strnlen(!llvm.ptr, i64) -> i64 + llvm.func @fold_strnlen_s3_s5_0(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant("123456\00") : !llvm.array<7 x i8> + %3 = llvm.mlir.addressof @s6 : !llvm.ptr + %4 = llvm.mlir.constant(0 : i64) : i64 + %5 = llvm.select %arg0, %1, %3 : i1, !llvm.ptr + %6 = llvm.call @strnlen(%5, %4) : (!llvm.ptr, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @fold_strnlen_s3_s5_1(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant("123456\00") : !llvm.array<7 x i8> + %3 = llvm.mlir.addressof @s6 : !llvm.ptr + %4 = llvm.mlir.constant(1 : i64) : i64 + %5 = llvm.select %arg0, %1, %3 : i1, !llvm.ptr + %6 = llvm.call @strnlen(%5, %4) : (!llvm.ptr, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @fold_strnlen_s3_s5_3(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant("123456\00") : !llvm.array<7 x i8> + %3 = llvm.mlir.addressof @s6 : !llvm.ptr + %4 = llvm.mlir.constant(3 : i64) : i64 + %5 = llvm.select %arg0, %1, %3 : i1, !llvm.ptr + %6 = llvm.call @strnlen(%5, %4) : (!llvm.ptr, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @fold_strnlen_s3_s5_4(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant("123456\00") : !llvm.array<7 x i8> + %3 = llvm.mlir.addressof @s6 : !llvm.ptr + %4 = llvm.mlir.constant(4 : i64) : i64 + %5 = llvm.select %arg0, %1, %3 : i1, !llvm.ptr + %6 = llvm.call @strnlen(%5, %4) : (!llvm.ptr, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @fold_strnlen_s3_s5_5(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant("123456\00") : !llvm.array<7 x i8> + %3 = llvm.mlir.addressof @s6 : !llvm.ptr + %4 = llvm.mlir.constant(5 : i64) : i64 + %5 = llvm.select %arg0, %1, %3 : i1, !llvm.ptr + %6 = llvm.call @strnlen(%5, %4) : (!llvm.ptr, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @fold_strnlen_s5_6(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @s5 : !llvm.ptr + %2 = llvm.mlir.constant("123456\00") : !llvm.array<7 x i8> + %3 = llvm.mlir.addressof @s6 : !llvm.ptr + %4 = llvm.mlir.constant(6 : i64) : i64 + %5 = llvm.select %arg0, %1, %3 : i1, !llvm.ptr + %6 = llvm.call @strnlen(%5, %4) : (!llvm.ptr, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @fold_strnlen_s3_s5_s7_4(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %3 = llvm.mlir.addressof @s5 : !llvm.ptr + %4 = llvm.mlir.constant("1234567\00") : !llvm.array<8 x i8> + %5 = llvm.mlir.addressof @s7 : !llvm.ptr + %6 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %7 = llvm.mlir.addressof @s3 : !llvm.ptr + %8 = llvm.mlir.constant(4 : i64) : i64 + %9 = llvm.icmp "eq" %arg0, %0 : i32 + %10 = llvm.icmp "eq" %arg0, %1 : i32 + %11 = llvm.select %10, %3, %5 : i1, !llvm.ptr + %12 = llvm.select %9, %7, %11 : i1, !llvm.ptr + %13 = llvm.call @strnlen(%12, %8) : (!llvm.ptr, i64) -> i64 + llvm.return %13 : i64 + } + llvm.func @fold_strnlen_s3_s5_s7_6(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %3 = llvm.mlir.addressof @s5 : !llvm.ptr + %4 = llvm.mlir.constant("1234567\00") : !llvm.array<8 x i8> + %5 = llvm.mlir.addressof @s7 : !llvm.ptr + %6 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %7 = llvm.mlir.addressof @s3 : !llvm.ptr + %8 = llvm.mlir.constant(6 : i64) : i64 + %9 = llvm.icmp "eq" %arg0, %0 : i32 + %10 = llvm.icmp "eq" %arg0, %1 : i32 + %11 = llvm.select %10, %3, %5 : i1, !llvm.ptr + %12 = llvm.select %9, %7, %11 : i1, !llvm.ptr + %13 = llvm.call @strnlen(%12, %8) : (!llvm.ptr, i64) -> i64 + llvm.return %13 : i64 + } + llvm.func @fold_strnlen_s3_s5_s7_8(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %3 = llvm.mlir.addressof @s5 : !llvm.ptr + %4 = llvm.mlir.constant("1234567\00") : !llvm.array<8 x i8> + %5 = llvm.mlir.addressof @s7 : !llvm.ptr + %6 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %7 = llvm.mlir.addressof @s3 : !llvm.ptr + %8 = llvm.mlir.constant(8 : i64) : i64 + %9 = llvm.icmp "eq" %arg0, %0 : i32 + %10 = llvm.icmp "eq" %arg0, %1 : i32 + %11 = llvm.select %10, %3, %5 : i1, !llvm.ptr + %12 = llvm.select %9, %7, %11 : i1, !llvm.ptr + %13 = llvm.call @strnlen(%12, %8) : (!llvm.ptr, i64) -> i64 + llvm.return %13 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/strnlen-3.ll.mlir b/test/LLVMDialect/InstCombine/strnlen-3.ll.mlir index 8cd4cf4cd..c1a47ec7e 100644 --- a/test/LLVMDialect/InstCombine/strnlen-3.ll.mlir +++ b/test/LLVMDialect/InstCombine/strnlen-3.ll.mlir @@ -1,143 +1,128 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "sx", type = !llvm.array<0 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "a3", type = !llvm.array<3 x i8>, value = "123"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "s3", type = !llvm.array<4 x i8>, value = "123\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "s5", type = !llvm.array<6 x i8>, value = "12345\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "s5_3", type = !llvm.array<10 x i8>, value = "12345\00abc\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strnlen", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @sx} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %arg0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%2, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_sx_pi_0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @sx} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %arg0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%2, %arg1) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "call_strnlen_sx_pi_n", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @a3} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %arg0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "call_strnlen_a3_pi_2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @a3} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %arg0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "call_strnlen_a3_pi_3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @s3} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %arg0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%2, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_s3_pi_0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @s5} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "call_strnlen_s5_pi_0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @s5_3} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %arg0) : (!llvm.ptr>, i32, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_s5_3_pi_0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @s5_3} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %arg0) : (!llvm.ptr>, i32, i64) -> !llvm.ptr - %3 = "llvm.call"(%2, %arg1) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "call_strnlen_s5_3_pi_n", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @a3} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%2, %arg0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_a3_n", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @s3} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%2, %arg0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_s3_n", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @a3} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %arg0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_a3_pi_2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @s3} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %arg0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_s3_pi_2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @s3} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %arg0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_s3_pi_3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @s3} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %arg0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%2, %arg1) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_s3_pi_n", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @s5_3} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %arg0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "call_strnlen_s5_3_pi_2", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @sx() {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.mlir.global external constant @a3("123") {addr_space = 0 : i32} + llvm.mlir.global external constant @s3("123\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s5("12345\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s5_3("12345\00abc\00") {addr_space = 0 : i32} + llvm.func @strnlen(!llvm.ptr, i64) -> i64 + llvm.func @fold_strnlen_sx_pi_0(%arg0: i64) -> i64 { + %0 = llvm.mlir.addressof @sx : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.getelementptr %0[%1, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i8> + %3 = llvm.call @strnlen(%2, %1) : (!llvm.ptr, i64) -> i64 + llvm.return %3 : i64 + } + llvm.func @call_strnlen_sx_pi_n(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.addressof @sx : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.getelementptr inbounds %0[%1, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i8> + %3 = llvm.call @strnlen(%2, %arg1) : (!llvm.ptr, i64) -> i64 + llvm.return %3 : i64 + } + llvm.func @call_strnlen_a3_pi_2(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant("123") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @a3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(2 : i64) : i64 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<3 x i8> + %5 = llvm.call @strnlen(%4, %3) : (!llvm.ptr, i64) -> i64 + llvm.return %5 : i64 + } + llvm.func @call_strnlen_a3_pi_3(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant("123") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @a3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(3 : i64) : i64 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<3 x i8> + %5 = llvm.call @strnlen(%4, %3) : (!llvm.ptr, i64) -> i64 + llvm.return %5 : i64 + } + llvm.func @fold_strnlen_s3_pi_0(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i8> + %4 = llvm.call @strnlen(%3, %2) : (!llvm.ptr, i64) -> i64 + llvm.return %4 : i64 + } + llvm.func @call_strnlen_s5_pi_0(%arg0: i64 {llvm.zeroext}) -> i64 { + %0 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @s5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.call @strnlen(%1, %2) : (!llvm.ptr, i64) -> i64 + llvm.return %3 : i64 + } + llvm.func @fold_strnlen_s5_3_pi_0(%arg0: i64 {llvm.zeroext}) -> i64 { + %0 = llvm.mlir.constant("12345\00abc\00") : !llvm.array<10 x i8> + %1 = llvm.mlir.addressof @s5_3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.getelementptr %1[%2, %arg0] : (!llvm.ptr, i32, i64) -> !llvm.ptr, !llvm.array<10 x i8> + %5 = llvm.call @strnlen(%4, %3) : (!llvm.ptr, i64) -> i64 + llvm.return %5 : i64 + } + llvm.func @call_strnlen_s5_3_pi_n(%arg0: i64 {llvm.zeroext}, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant("12345\00abc\00") : !llvm.array<10 x i8> + %1 = llvm.mlir.addressof @s5_3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i64) -> !llvm.ptr, !llvm.array<10 x i8> + %4 = llvm.call @strnlen(%3, %arg1) : (!llvm.ptr, i64) -> i64 + llvm.return %4 : i64 + } + llvm.func @fold_strnlen_a3_n(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant("123") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @a3 : !llvm.ptr + %2 = llvm.call @strnlen(%1, %arg0) : (!llvm.ptr, i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @fold_strnlen_s3_n(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.call @strnlen(%1, %arg0) : (!llvm.ptr, i64) -> i64 + llvm.return %2 : i64 + } + llvm.func @fold_strnlen_a3_pi_2(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant("123") : !llvm.array<3 x i8> + %1 = llvm.mlir.addressof @a3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(2 : i64) : i64 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<3 x i8> + %5 = llvm.call @strnlen(%4, %3) : (!llvm.ptr, i64) -> i64 + llvm.return %5 : i64 + } + llvm.func @fold_strnlen_s3_pi_2(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(2 : i64) : i64 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i8> + %5 = llvm.call @strnlen(%4, %3) : (!llvm.ptr, i64) -> i64 + llvm.return %5 : i64 + } + llvm.func @fold_strnlen_s3_pi_3(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(3 : i64) : i64 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i8> + %5 = llvm.call @strnlen(%4, %3) : (!llvm.ptr, i64) -> i64 + llvm.return %5 : i64 + } + llvm.func @fold_strnlen_s3_pi_n(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i8> + %4 = llvm.call @strnlen(%3, %arg1) : (!llvm.ptr, i64) -> i64 + llvm.return %4 : i64 + } + llvm.func @call_strnlen_s5_3_pi_2(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant("12345\00abc\00") : !llvm.array<10 x i8> + %1 = llvm.mlir.addressof @s5_3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(2 : i64) : i64 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<10 x i8> + %5 = llvm.call @strnlen(%4, %3) : (!llvm.ptr, i64) -> i64 + llvm.return %5 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/strnlen-4.ll.mlir b/test/LLVMDialect/InstCombine/strnlen-4.ll.mlir new file mode 100644 index 000000000..82548a196 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strnlen-4.ll.mlir @@ -0,0 +1,48 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @sx() {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.mlir.global external constant @s3("123\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s5("12345\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @s5_3("12345\00abc\00") {addr_space = 0 : i32} + llvm.func @strnlen(!llvm.ptr, i64) -> i64 + llvm.func @fold_strnlen_s3_pi_s5_n(%arg0: i1, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @s5 : !llvm.ptr + %5 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i8> + %6 = llvm.select %arg0, %5, %4 : i1, !llvm.ptr + %7 = llvm.call @strnlen(%6, %arg2) : (!llvm.ptr, i64) -> i64 + llvm.return %7 : i64 + } + llvm.func @call_strnlen_s3_pi_xbounds_s5_n(%arg0: i1, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %4 = llvm.mlir.addressof @s5 : !llvm.ptr + %5 = llvm.getelementptr %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i8> + %6 = llvm.select %arg0, %5, %4 : i1, !llvm.ptr + %7 = llvm.call @strnlen(%6, %arg2) : (!llvm.ptr, i64) -> i64 + llvm.return %7 : i64 + } + llvm.func @call_strnlen_s3_pi_sx_n(%arg0: i1, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %1 = llvm.mlir.addressof @s3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.addressof @sx : !llvm.ptr + %4 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i8> + %5 = llvm.select %arg0, %4, %3 : i1, !llvm.ptr + %6 = llvm.call @strnlen(%5, %arg2) : (!llvm.ptr, i64) -> i64 + llvm.return %6 : i64 + } + llvm.func @fold_strnlen_s3_s5_pi_n(%arg0: i1, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @s5 : !llvm.ptr + %2 = llvm.mlir.constant("123\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.addressof @s3 : !llvm.ptr + %4 = llvm.select %arg0, %1, %3 : i1, !llvm.ptr + %5 = llvm.call @strnlen(%4, %arg1) : (!llvm.ptr, i64) -> i64 + llvm.return %5 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/strnlen-5.ll.mlir b/test/LLVMDialect/InstCombine/strnlen-5.ll.mlir index 36b222d01..2e365fd16 100644 --- a/test/LLVMDialect/InstCombine/strnlen-5.ll.mlir +++ b/test/LLVMDialect/InstCombine/strnlen-5.ll.mlir @@ -1,134 +1,114 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "ax", type = !llvm.array<0 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "a5", type = !llvm.array<5 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "s5", type = !llvm.array<6 x i8>, value = "12345\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strnlen", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%2, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - %4 = "llvm.icmp"(%3, %0) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_ax_0_eqz", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%2, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - %4 = "llvm.icmp"(%3, %0) {predicate = 8 : i64} : (i64, i64) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_ax_0_gtz", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - %5 = "llvm.icmp"(%4, %1) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_ax_1_eqz", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - %5 = "llvm.icmp"(%4, %0) {predicate = 6 : i64} : (i64, i64) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_ax_1_lt1", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - %5 = "llvm.icmp"(%4, %1) {predicate = 1 : i64} : (i64, i64) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_ax_1_neqz", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - %5 = "llvm.icmp"(%4, %1) {predicate = 8 : i64} : (i64, i64) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_ax_1_gtz", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 9 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - %5 = "llvm.icmp"(%4, %1) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.return"(%5) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_ax_9_eqz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%2, %arg0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - %4 = "llvm.icmp"(%3, %0) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "call_strnlen_ax_n_eqz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %3 = "llvm.or"(%arg0, %2) : (i64, i64) -> i64 - %4 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%4, %3) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - %6 = "llvm.icmp"(%5, %0) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_ax_nz_eqz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @ax} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %3 = "llvm.or"(%arg0, %2) : (i64, i64) -> i64 - %4 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%4, %3) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - %6 = "llvm.icmp"(%5, %0) {predicate = 8 : i64} : (i64, i64) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_ax_nz_gtz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @a5} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %3 = "llvm.or"(%arg1, %2) : (i64, i64) -> i64 - %4 = "llvm.getelementptr"(%1, %0, %arg0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%4, %3) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - %6 = "llvm.icmp"(%5, %0) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_a5_pi_nz_eqz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @s5} : () -> !llvm.ptr> - %2 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %3 = "llvm.or"(%arg1, %2) : (i64, i64) -> i64 - %4 = "llvm.getelementptr"(%1, %0, %arg0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%4, %3) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - %6 = "llvm.icmp"(%5, %0) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.return"(%6) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "fold_strnlen_s5_pi_nz_eqz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64, %arg1: i64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @s5} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %arg0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%2, %arg1) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - %4 = "llvm.icmp"(%3, %0) {predicate = 0 : i64} : (i64, i64) -> i1 - "llvm.return"(%4) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "call_strnlen_s5_pi_n_eqz", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @ax() {addr_space = 0 : i32} : !llvm.array<0 x i8> + llvm.mlir.global external @a5() {addr_space = 0 : i32} : !llvm.array<5 x i8> + llvm.mlir.global external constant @s5("12345\00") {addr_space = 0 : i32} + llvm.func @strnlen(!llvm.ptr, i64) -> i64 + llvm.func @fold_strnlen_ax_0_eqz() -> i1 { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.call @strnlen(%0, %1) : (!llvm.ptr, i64) -> i64 + %3 = llvm.icmp "eq" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @fold_strnlen_ax_0_gtz() -> i1 { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.call @strnlen(%0, %1) : (!llvm.ptr, i64) -> i64 + %3 = llvm.icmp "ugt" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @fold_strnlen_ax_1_eqz() -> i1 { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.call @strnlen(%0, %1) : (!llvm.ptr, i64) -> i64 + %4 = llvm.icmp "eq" %3, %2 : i64 + llvm.return %4 : i1 + } + llvm.func @fold_strnlen_ax_1_lt1() -> i1 { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.call @strnlen(%0, %1) : (!llvm.ptr, i64) -> i64 + %3 = llvm.icmp "ult" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @fold_strnlen_ax_1_neqz() -> i1 { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.call @strnlen(%0, %1) : (!llvm.ptr, i64) -> i64 + %4 = llvm.icmp "ne" %3, %2 : i64 + llvm.return %4 : i1 + } + llvm.func @fold_strnlen_ax_1_gtz() -> i1 { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(1 : i64) : i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.call @strnlen(%0, %1) : (!llvm.ptr, i64) -> i64 + %4 = llvm.icmp "ugt" %3, %2 : i64 + llvm.return %4 : i1 + } + llvm.func @fold_strnlen_ax_9_eqz() -> i1 { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(9 : i64) : i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.call @strnlen(%0, %1) : (!llvm.ptr, i64) -> i64 + %4 = llvm.icmp "eq" %3, %2 : i64 + llvm.return %4 : i1 + } + llvm.func @call_strnlen_ax_n_eqz(%arg0: i64) -> i1 { + %0 = llvm.mlir.addressof @ax : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.call @strnlen(%0, %arg0) : (!llvm.ptr, i64) -> i64 + %3 = llvm.icmp "eq" %2, %1 : i64 + llvm.return %3 : i1 + } + llvm.func @fold_strnlen_ax_nz_eqz(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.addressof @ax : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.or %arg0, %0 : i64 + %4 = llvm.call @strnlen(%1, %3) : (!llvm.ptr, i64) -> i64 + %5 = llvm.icmp "eq" %4, %2 : i64 + llvm.return %5 : i1 + } + llvm.func @fold_strnlen_ax_nz_gtz(%arg0: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.addressof @ax : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.or %arg0, %0 : i64 + %4 = llvm.call @strnlen(%1, %3) : (!llvm.ptr, i64) -> i64 + %5 = llvm.icmp "ugt" %4, %2 : i64 + llvm.return %5 : i1 + } + llvm.func @fold_strnlen_a5_pi_nz_eqz(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.addressof @a5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.or %arg1, %0 : i64 + %4 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<5 x i8> + %5 = llvm.call @strnlen(%4, %3) : (!llvm.ptr, i64) -> i64 + %6 = llvm.icmp "eq" %5, %2 : i64 + llvm.return %6 : i1 + } + llvm.func @fold_strnlen_s5_pi_nz_eqz(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %2 = llvm.mlir.addressof @s5 : !llvm.ptr + %3 = llvm.mlir.constant(0 : i64) : i64 + %4 = llvm.or %arg1, %0 : i64 + %5 = llvm.getelementptr inbounds %2[%3, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<6 x i8> + %6 = llvm.call @strnlen(%5, %4) : (!llvm.ptr, i64) -> i64 + %7 = llvm.icmp "eq" %6, %3 : i64 + llvm.return %7 : i1 + } + llvm.func @call_strnlen_s5_pi_n_eqz(%arg0: i64, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant("12345\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @s5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<6 x i8> + %4 = llvm.call @strnlen(%3, %arg1) : (!llvm.ptr, i64) -> i64 + %5 = llvm.icmp "eq" %4, %2 : i64 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/strnlen-6.ll.mlir b/test/LLVMDialect/InstCombine/strnlen-6.ll.mlir index 5ece172ee..c0ce011d4 100644 --- a/test/LLVMDialect/InstCombine/strnlen-6.ll.mlir +++ b/test/LLVMDialect/InstCombine/strnlen-6.ll.mlir @@ -1,30 +1,25 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "ecp", type = !llvm.ptr} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strnlen", type = !llvm.func, i64)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 3 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @ecp} : () -> !llvm.ptr> - %2 = "llvm.load"(%1) : (!llvm.ptr>) -> !llvm.ptr - %3 = "llvm.call"(%2, %0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "deref_strnlen_ecp_3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @ecp} : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %2 = "llvm.or"(%arg0, %1) : (i64, i64) -> i64 - %3 = "llvm.load"(%0) : (!llvm.ptr>) -> !llvm.ptr - %4 = "llvm.call"(%3, %2) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "deref_strnlen_ecp_nz", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @ecp} : () -> !llvm.ptr> - %1 = "llvm.load"(%0) : (!llvm.ptr>) -> !llvm.ptr - %2 = "llvm.call"(%1, %arg0) {callee = @strnlen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i64) -> i64 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "noderef_strnlen_ecp_n", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @ecp() {addr_space = 0 : i32, alignment = 8 : i64} : !llvm.ptr + llvm.func @strnlen(!llvm.ptr, i64) -> i64 + llvm.func @deref_strnlen_ecp_3() -> i64 { + %0 = llvm.mlir.addressof @ecp : !llvm.ptr + %1 = llvm.mlir.constant(3 : i64) : i64 + %2 = llvm.load %0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %3 = llvm.call @strnlen(%2, %1) : (!llvm.ptr, i64) -> i64 + llvm.return %3 : i64 + } + llvm.func @deref_strnlen_ecp_nz(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.addressof @ecp : !llvm.ptr + %2 = llvm.or %arg0, %0 : i64 + %3 = llvm.load %1 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %4 = llvm.call @strnlen(%3, %2) : (!llvm.ptr, i64) -> i64 + llvm.return %4 : i64 + } + llvm.func @noderef_strnlen_ecp_n(%arg0: i64) -> i64 { + %0 = llvm.mlir.addressof @ecp : !llvm.ptr + %1 = llvm.load %0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %2 = llvm.call @strnlen(%1, %arg0) : (!llvm.ptr, i64) -> i64 + llvm.return %2 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/strpbrk-1.ll.mlir b/test/LLVMDialect/InstCombine/strpbrk-1.ll.mlir new file mode 100644 index 000000000..b8749fd86 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strpbrk-1.ll.mlir @@ -0,0 +1,38 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello world\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @w("w\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.func @strpbrk(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @test_simplify1(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @strpbrk(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @test_simplify2(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @strpbrk(%2, %arg0) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @test_simplify3() -> !llvm.ptr { + %0 = llvm.mlir.constant("hello world\00") : !llvm.array<12 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant("w\00") : !llvm.array<2 x i8> + %3 = llvm.mlir.addressof @w : !llvm.ptr + %4 = llvm.call @strpbrk(%1, %3) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @test_simplify4(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("w\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @w : !llvm.ptr + %2 = llvm.call @strpbrk(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @test_no_simplify1(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.call @strpbrk(%arg0, %arg1) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/strpbrk-2.ll.mlir b/test/LLVMDialect/InstCombine/strpbrk-2.ll.mlir index a3f333939..27076a7ee 100644 --- a/test/LLVMDialect/InstCombine/strpbrk-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/strpbrk-2.ll.mlir @@ -1,18 +1,13 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello", type = !llvm.array<12 x i8>, value = "hello world\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "w", type = !llvm.array<2 x i8>, value = "w\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strpbrk", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @w} : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.getelementptr"(%0, %1, %1) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%3, %4) {callee = @strpbrk, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i8 - "llvm.return"(%5) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello world\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @w("w\00") {addr_space = 0 : i32} + llvm.func @strpbrk(!llvm.ptr, !llvm.ptr) -> i8 + llvm.func @test_no_simplify1() -> i8 { + %0 = llvm.mlir.constant("hello world\00") : !llvm.array<12 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant("w\00") : !llvm.array<2 x i8> + %3 = llvm.mlir.addressof @w : !llvm.ptr + %4 = llvm.call @strpbrk(%1, %3) : (!llvm.ptr, !llvm.ptr) -> i8 + llvm.return %4 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/strrchr-1.ll.mlir b/test/LLVMDialect/InstCombine/strrchr-1.ll.mlir new file mode 100644 index 000000000..9d8d5c468 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strrchr-1.ll.mlir @@ -0,0 +1,67 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello world\\n\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external @chp() {addr_space = 0 : i32} : !llvm.ptr { + %0 = llvm.mlir.zero : !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @strrchr(!llvm.ptr, i32) -> !llvm.ptr + llvm.func @test_simplify1() { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(119 : i32) : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.mlir.addressof @chp : !llvm.ptr + %5 = llvm.call @strrchr(%1, %2) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.store %5, %4 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test_simplify2() { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.mlir.constant(119 : i32) : i32 + %4 = llvm.mlir.zero : !llvm.ptr + %5 = llvm.mlir.addressof @chp : !llvm.ptr + %6 = llvm.call @strrchr(%2, %3) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.store %6, %5 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test_simplify3() { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.mlir.addressof @chp : !llvm.ptr + %5 = llvm.call @strrchr(%1, %2) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.store %5, %4 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test_simplify4() { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(65280 : i32) : i32 + %3 = llvm.mlir.zero : !llvm.ptr + %4 = llvm.mlir.addressof @chp : !llvm.ptr + %5 = llvm.call @strrchr(%1, %2) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.store %5, %4 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test_xform_to_memrchr(%arg0: i32) { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.addressof @chp : !llvm.ptr + %4 = llvm.call @strrchr(%1, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.store %4, %3 {alignment = 4 : i64} : !llvm.ptr, !llvm.ptr + llvm.return + } + llvm.func @test1(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr { + %0 = llvm.call @strrchr(%arg0, %arg1) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test2(%arg0: !llvm.ptr, %arg1: i32) -> !llvm.ptr attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.call @strrchr(%arg0, %arg1) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/strrchr-2.ll.mlir b/test/LLVMDialect/InstCombine/strrchr-2.ll.mlir index cf99ed1a8..f1ed2cfdb 100644 --- a/test/LLVMDialect/InstCombine/strrchr-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/strrchr-2.ll.mlir @@ -1,19 +1,15 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello", type = !llvm.array<14 x i8>, value = "hello world\\n\00"} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "chr", type = i8, value = 0 : i8} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strrchr", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @chr} : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = 119 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %3 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %4 = "llvm.getelementptr"(%3, %2, %2) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %5 = "llvm.call"(%4, %1) {callee = @strrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> i8 - "llvm.store"(%5, %0) : (i8, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_nosimplify1", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello("hello world\\n\00") {addr_space = 0 : i32} + llvm.mlir.global external @chr(0 : i8) {addr_space = 0 : i32} : i8 + llvm.func @strrchr(!llvm.ptr, i32) -> i8 + llvm.func @test_nosimplify1() { + %0 = llvm.mlir.constant("hello world\\n\00") : !llvm.array<14 x i8> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(119 : i32) : i32 + %3 = llvm.mlir.constant(0 : i8) : i8 + %4 = llvm.mlir.addressof @chr : !llvm.ptr + %5 = llvm.call @strrchr(%1, %2) : (!llvm.ptr, i32) -> i8 + llvm.store %5, %4 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/strrchr-3.ll.mlir b/test/LLVMDialect/InstCombine/strrchr-3.ll.mlir index f38a48a2e..1889aeb6a 100644 --- a/test/LLVMDialect/InstCombine/strrchr-3.ll.mlir +++ b/test/LLVMDialect/InstCombine/strrchr-3.ll.mlir @@ -1,43 +1,40 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "s10", type = !llvm.array<11 x i8>, value = "0123456789\00"} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strrchr", type = !llvm.func (ptr, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @s10} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0) {callee = @strrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "fold_strrchr_sp10_x", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 9 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @s10} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0) {callee = @strrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_strrchr_sp9_x", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 2 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @s10} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0) {callee = @strrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_strrchr_sp2_x", type = !llvm.func (i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @s10} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %0) : (!llvm.ptr>, i32, i32) -> !llvm.ptr - %4 = "llvm.call"(%3, %arg0) {callee = @strrchr, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> !llvm.ptr - "llvm.return"(%4) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "call_strrchr_sp1_x", type = !llvm.func (i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @s10("0123456789\00") {addr_space = 0 : i32} + llvm.func @strrchr(!llvm.ptr, i32) -> !llvm.ptr + llvm.func @fold_strrchr_sp10_x(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("0123456789\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @s10 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<11 x i8> + %5 = llvm.call @strrchr(%4, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @call_strrchr_sp9_x(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("0123456789\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @s10 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(9 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<11 x i8> + %5 = llvm.call @strrchr(%4, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @call_strrchr_sp2_x(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("0123456789\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @s10 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<11 x i8> + %5 = llvm.call @strrchr(%4, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } + llvm.func @call_strrchr_sp1_x(%arg0: i32) -> !llvm.ptr { + %0 = llvm.mlir.constant("0123456789\00") : !llvm.array<11 x i8> + %1 = llvm.mlir.addressof @s10 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<11 x i8> + %5 = llvm.call @strrchr(%4, %arg0) : (!llvm.ptr, i32) -> !llvm.ptr + llvm.return %5 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/strspn-1.ll.mlir b/test/LLVMDialect/InstCombine/strspn-1.ll.mlir new file mode 100644 index 000000000..2e7d0ce06 --- /dev/null +++ b/test/LLVMDialect/InstCombine/strspn-1.ll.mlir @@ -0,0 +1,32 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @abcba("abcba\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @abc("abc\00") {addr_space = 0 : i32} + llvm.mlir.global external constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.func @strspn(!llvm.ptr, !llvm.ptr) -> i64 + llvm.func @test_simplify1(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @strspn(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> i64 + llvm.return %3 : i64 + } + llvm.func @test_simplify2(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @strspn(%2, %arg0) : (!llvm.ptr, !llvm.ptr) -> i64 + llvm.return %3 : i64 + } + llvm.func @test_simplify3() -> i64 { + %0 = llvm.mlir.constant("abcba\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @abcba : !llvm.ptr + %2 = llvm.mlir.constant("abc\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.addressof @abc : !llvm.ptr + %4 = llvm.call @strspn(%1, %3) : (!llvm.ptr, !llvm.ptr) -> i64 + llvm.return %4 : i64 + } + llvm.func @test_no_simplify1(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i64 { + %0 = llvm.call @strspn(%arg0, %arg1) : (!llvm.ptr, !llvm.ptr) -> i64 + llvm.return %0 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/strstr-1.ll.mlir b/test/LLVMDialect/InstCombine/strstr-1.ll.mlir new file mode 100644 index 000000000..59c1d3eec --- /dev/null +++ b/test/LLVMDialect/InstCombine/strstr-1.ll.mlir @@ -0,0 +1,45 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.mlir.global private constant @".str"(dense<0> : tensor<1xi8>) {addr_space = 0 : i32, dso_local} : !llvm.array<1 x i8> + llvm.mlir.global private constant @".str1"("a\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global private constant @".str2"("abcde\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global private constant @".str3"("bcd\00") {addr_space = 0 : i32, dso_local} + llvm.func @strstr(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @test_simplify1(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @".str" : !llvm.ptr + %3 = llvm.call @strstr(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @test_simplify2(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant("a\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @".str1" : !llvm.ptr + %2 = llvm.call @strstr(%arg0, %1) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %2 : !llvm.ptr + } + llvm.func @test_simplify3() -> !llvm.ptr { + %0 = llvm.mlir.constant("abcde\00") : !llvm.array<6 x i8> + %1 = llvm.mlir.addressof @".str2" : !llvm.ptr + %2 = llvm.mlir.constant("bcd\00") : !llvm.array<4 x i8> + %3 = llvm.mlir.addressof @".str3" : !llvm.ptr + %4 = llvm.call @strstr(%1, %3) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %4 : !llvm.ptr + } + llvm.func @test_simplify4(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.call @strstr(%arg0, %arg0) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test_simplify5(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.call @strstr(%arg0, %arg1) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + %1 = llvm.icmp "eq" %0, %arg0 : !llvm.ptr + llvm.return %1 : i1 + } + llvm.func @test1(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.call @strstr(%arg0, %arg1) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } + llvm.func @test2(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> !llvm.ptr attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.call @strstr(%arg0, %arg1) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return %0 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/strstr-2.ll.mlir b/test/LLVMDialect/InstCombine/strstr-2.ll.mlir new file mode 100644 index 000000000..e833d76bb --- /dev/null +++ b/test/LLVMDialect/InstCombine/strstr-2.ll.mlir @@ -0,0 +1,11 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global private constant @null(dense<0> : tensor<1xi8>) {addr_space = 0 : i32, dso_local} : !llvm.array<1 x i8> + llvm.func @strstr(!llvm.ptr, !llvm.ptr) -> i8 + llvm.func @test_no_simplify1(%arg0: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi8>) : !llvm.array<1 x i8> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @strstr(%arg0, %2) : (!llvm.ptr, !llvm.ptr) -> i8 + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/strto-1.ll.mlir b/test/LLVMDialect/InstCombine/strto-1.ll.mlir index a241fc8c0..e6ec05ea4 100644 --- a/test/LLVMDialect/InstCombine/strto-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/strto-1.ll.mlir @@ -1,69 +1,53 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtol", type = !llvm.func, ptr>, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtod", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtof", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtoul", type = !llvm.func, ptr>, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtoll", type = !llvm.func, ptr>, i32)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtold", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strtoull", type = !llvm.func, ptr>, i32)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.call"(%arg0, %1, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_simplify1", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr> - %1 = "llvm.call"(%arg0, %0) {callee = @strtod, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>) -> f64 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_simplify2", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr> - %1 = "llvm.call"(%arg0, %0) {callee = @strtof, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>) -> f32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_simplify3", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.call"(%arg0, %1, %0) {callee = @strtoul, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_simplify4", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.call"(%arg0, %1, %0) {callee = @strtoll, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_simplify5", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.null"() : () -> !llvm.ptr> - %1 = "llvm.call"(%arg0, %0) {callee = @strtold, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>) -> f64 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_simplify6", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.mlir.null"() : () -> !llvm.ptr> - %2 = "llvm.call"(%arg0, %1, %0) {callee = @strtoull, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i64 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_simplify7", type = !llvm.func, ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.call"(%arg0, %arg1, %0) {callee = @strtol, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr>, i32) -> i32 - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func, ptr>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @strtol(!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.func @strtod(!llvm.ptr, !llvm.ptr) -> f64 + llvm.func @strtof(!llvm.ptr, !llvm.ptr) -> f32 + llvm.func @strtoul(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @strtoll(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @strtold(!llvm.ptr, !llvm.ptr) -> f64 + llvm.func @strtoull(!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.func @test_simplify1(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.call @strtol(%arg0, %0, %1) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return + } + llvm.func @test_simplify2(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.call @strtod(%arg0, %0) : (!llvm.ptr, !llvm.ptr) -> f64 + llvm.return + } + llvm.func @test_simplify3(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.call @strtof(%arg0, %0) : (!llvm.ptr, !llvm.ptr) -> f32 + llvm.return + } + llvm.func @test_simplify4(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.call @strtoul(%arg0, %0, %1) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return + } + llvm.func @test_simplify5(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.call @strtoll(%arg0, %0, %1) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return + } + llvm.func @test_simplify6(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.call @strtold(%arg0, %0) : (!llvm.ptr, !llvm.ptr) -> f64 + llvm.return + } + llvm.func @test_simplify7(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.call @strtoull(%arg0, %0, %1) : (!llvm.ptr, !llvm.ptr, i32) -> i64 + llvm.return + } + llvm.func @test_no_simplify1(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.call @strtol(%arg0, %arg1, %0) : (!llvm.ptr, !llvm.ptr, i32) -> i32 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/struct-assign-tbaa-new.ll.mlir b/test/LLVMDialect/InstCombine/struct-assign-tbaa-new.ll.mlir index 4594e446d..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/struct-assign-tbaa-new.ll.mlir +++ b/test/LLVMDialect/InstCombine/struct-assign-tbaa-new.ll.mlir @@ -1,27 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memcpy.p0i8.p0i8.i64", type = !llvm.func, ptr, i64, i1)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %2 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %3 = "llvm.bitcast"(%arg1) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%2, %3, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func>, ptr>)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %3 = "llvm.mlir.undef"() : () -> !llvm.ptr - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.alloca"(%4) : (i32) -> !llvm.ptr, ptr, ptr)>>>)>> - %6 = "llvm.bitcast"(%5) : (!llvm.ptr, ptr, ptr)>>>)>>) -> !llvm.ptr - "llvm.call"(%6, %3, %2, %1) {callee = @llvm.memcpy.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - %7 = "llvm.getelementptr"(%5, %0, %0) : (!llvm.ptr, ptr, ptr)>>>)>>, i32, i32) -> !llvm.ptr, ptr, ptr)>>>> - %8 = "llvm.load"(%7) : (!llvm.ptr, ptr, ptr)>>>>) -> !llvm.ptr, ptr, ptr)>>> - "llvm.return"(%7) : (!llvm.ptr, ptr, ptr)>>>>) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func, ptr, ptr)>>>> ()>} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/struct-assign-tbaa.ll.mlir b/test/LLVMDialect/InstCombine/struct-assign-tbaa.ll.mlir index aca3d7860..30027542b 100644 --- a/test/LLVMDialect/InstCombine/struct-assign-tbaa.ll.mlir +++ b/test/LLVMDialect/InstCombine/struct-assign-tbaa.ll.mlir @@ -1,27 +1,31 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.memcpy.p0i8.p0i8.i64", type = !llvm.func, ptr, i64, i1)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>, %arg1: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %2 = "llvm.bitcast"(%arg0) : (!llvm.ptr>) -> !llvm.ptr - %3 = "llvm.bitcast"(%arg1) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%2, %3, %1, %0) {callee = @llvm.memcpy.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func>, ptr>)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = false} : () -> i1 - %2 = "llvm.mlir.constant"() {value = 8 : i64} : () -> i64 - %3 = "llvm.mlir.undef"() : () -> !llvm.ptr - %4 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %5 = "llvm.alloca"(%4) : (i32) -> !llvm.ptr, ptr, ptr)>>>)>> - %6 = "llvm.bitcast"(%5) : (!llvm.ptr, ptr, ptr)>>>)>>) -> !llvm.ptr - "llvm.call"(%6, %3, %2, %1) {callee = @llvm.memcpy.p0i8.p0i8.i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr, i64, i1) -> () - %7 = "llvm.getelementptr"(%5, %0, %0) : (!llvm.ptr, ptr, ptr)>>>)>>, i32, i32) -> !llvm.ptr, ptr, ptr)>>>> - %8 = "llvm.load"(%7) : (!llvm.ptr, ptr, ptr)>>>>) -> !llvm.ptr, ptr, ptr)>>> - "llvm.return"(%7) : (!llvm.ptr, ptr, ptr)>>>>) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func, ptr, ptr)>>>> ()>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @test1(%arg0: !llvm.ptr {llvm.nocapture}, %arg1: !llvm.ptr {llvm.nocapture}) { + %0 = llvm.mlir.constant(4 : i64) : i64 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } + llvm.func @test2() -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.ptr + %2 = llvm.mlir.constant(8 : i64) : i64 + %3 = llvm.alloca %0 x !llvm.struct<"struct.test2", (ptr)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + "llvm.intr.memcpy"(%3, %1, %2) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + %4 = llvm.load %3 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @test3_multiple_fields(%arg0: !llvm.ptr {llvm.nocapture}, %arg1: !llvm.ptr {llvm.nocapture}) { + %0 = llvm.mlir.constant(8 : i64) : i64 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } + llvm.func @test4_multiple_copy_first_field(%arg0: !llvm.ptr {llvm.nocapture}, %arg1: !llvm.ptr {llvm.nocapture}) { + %0 = llvm.mlir.constant(4 : i64) : i64 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } + llvm.func @test5_multiple_copy_more_than_first_field(%arg0: !llvm.ptr {llvm.nocapture}, %arg1: !llvm.ptr {llvm.nocapture}) { + %0 = llvm.mlir.constant(4 : i64) : i64 + "llvm.intr.memcpy"(%arg0, %arg1, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/sub-and-or-neg-xor.ll.mlir b/test/LLVMDialect/InstCombine/sub-and-or-neg-xor.ll.mlir index 86b6b5e32..31e3877d3 100644 --- a/test/LLVMDialect/InstCombine/sub-and-or-neg-xor.ll.mlir +++ b/test/LLVMDialect/InstCombine/sub-and-or-neg-xor.ll.mlir @@ -1,66 +1,56 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.and"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.and"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.call"(%2) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor_extra_use_sub", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.and"(%arg0, %arg1) : (i32, i32) -> i32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor_extra_use_and", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %1 = "llvm.and"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor_extra_use_or", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg1, %arg0) : (i32, i32) -> i32 - %1 = "llvm.and"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor_or_commuted", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.and"(%arg1, %arg0) : (i32, i32) -> i32 - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor_and_commuted", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %1 = "llvm.and"(%arg1, %arg0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.sub"(%1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor_vec", type = !llvm.func (vector<2xi32>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %1 = "llvm.and"(%arg0, %arg1) : (i32, i32) -> i32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor_extra_use_and_or", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @sub_to_xor(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.sub %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_xor_extra_use_sub(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.sub %1, %0 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %2 : i32 + } + llvm.func @sub_to_xor_extra_use_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.sub %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_xor_extra_use_or(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.sub %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_xor_or_commuted(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg1, %arg0 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.sub %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_xor_and_commuted(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.sub %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_xor_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.or %arg0, %arg1 : vector<2xi32> + %1 = llvm.and %arg1, %arg0 : vector<2xi32> + %2 = llvm.sub %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @sub_to_xor_extra_use_and_or(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.and %arg0, %arg1 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.sub %1, %0 : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sub-ashr-and-to-icmp-select.ll.mlir b/test/LLVMDialect/InstCombine/sub-ashr-and-to-icmp-select.ll.mlir new file mode 100644 index 000000000..d82efad2f --- /dev/null +++ b/test/LLVMDialect/InstCombine/sub-ashr-and-to-icmp-select.ll.mlir @@ -0,0 +1,120 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @sub_ashr_and_i8(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + %2 = llvm.ashr %1, %0 : i8 + %3 = llvm.and %2, %arg0 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_ashr_and_i16(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(15 : i16) : i16 + %1 = llvm.sub %arg1, %arg0 overflow : i16 + %2 = llvm.ashr %1, %0 : i16 + %3 = llvm.and %2, %arg0 : i16 + llvm.return %3 : i16 + } + llvm.func @sub_ashr_and_i32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @sub_ashr_and_i64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.sub %arg1, %arg0 overflow : i64 + %2 = llvm.ashr %1, %0 : i64 + %3 = llvm.and %2, %arg0 : i64 + llvm.return %3 : i64 + } + llvm.func @sub_ashr_and_i32_nuw_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @sub_ashr_and_i32_commute(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.and %arg0, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @sub_ashr_and_i32_vec(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sub %arg1, %arg0 overflow : vector<4xi32> + %2 = llvm.ashr %1, %0 : vector<4xi32> + %3 = llvm.and %2, %arg0 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @sub_ashr_and_i32_vec_nuw_nsw(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sub %arg1, %arg0 overflow : vector<4xi32> + %2 = llvm.ashr %1, %0 : vector<4xi32> + %3 = llvm.and %2, %arg0 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @sub_ashr_and_i32_vec_commute(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sub %arg1, %arg0 overflow : vector<4xi32> + %2 = llvm.ashr %1, %0 : vector<4xi32> + %3 = llvm.and %arg0, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @sub_ashr_and_i32_extra_use_sub(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + llvm.store %1, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @sub_ashr_and_i32_extra_use_and(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.store %3, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %3 : i32 + } + llvm.func @sub_ashr_and_i32_extra_use_ashr(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.ashr %1, %0 : i32 + llvm.store %2, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.and %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @sub_ashr_and_i32_no_nuw_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 : i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @sub_ashr_and_i32_vec_poison(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.sub %arg1, %arg0 overflow : vector<4xi32> + %12 = llvm.ashr %11, %10 : vector<4xi32> + %13 = llvm.and %12, %arg0 : vector<4xi32> + llvm.return %13 : vector<4xi32> + } + llvm.func @sub_ashr_and_i32_shift_wrong_bit(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sub-ashr-or-to-icmp-select.ll.mlir b/test/LLVMDialect/InstCombine/sub-ashr-or-to-icmp-select.ll.mlir new file mode 100644 index 000000000..e18dc87df --- /dev/null +++ b/test/LLVMDialect/InstCombine/sub-ashr-or-to-icmp-select.ll.mlir @@ -0,0 +1,204 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @clamp255_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.ashr %2, %1 : i32 + %4 = llvm.or %3, %arg0 : i32 + %5 = llvm.and %4, %0 : i32 + llvm.return %5 : i32 + } + llvm.func @sub_ashr_or_i8(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + %2 = llvm.ashr %1, %0 : i8 + %3 = llvm.or %2, %arg0 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_ashr_or_i16(%arg0: i16, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(15 : i16) : i16 + %1 = llvm.sub %arg1, %arg0 overflow : i16 + %2 = llvm.ashr %1, %0 : i16 + %3 = llvm.or %2, %arg0 : i16 + llvm.return %3 : i16 + } + llvm.func @sub_ashr_or_i32(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @sub_ashr_or_i64(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.sub %arg1, %arg0 overflow : i64 + %2 = llvm.ashr %1, %0 : i64 + %3 = llvm.or %2, %arg0 : i64 + llvm.return %3 : i64 + } + llvm.func @neg_or_ashr_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.ashr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @sub_ashr_or_i32_nuw_nsw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @sub_ashr_or_i32_commute(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.or %arg0, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @neg_or_ashr_i32_commute(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(31 : i32) : i32 + %3 = llvm.sdiv %0, %arg0 : i32 + %4 = llvm.sub %1, %3 : i32 + %5 = llvm.or %3, %4 : i32 + %6 = llvm.ashr %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @sub_ashr_or_i32_vec(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sub %arg1, %arg0 overflow : vector<4xi32> + %2 = llvm.ashr %1, %0 : vector<4xi32> + %3 = llvm.or %2, %arg0 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @sub_ashr_or_i32_vec_nuw_nsw(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sub %arg1, %arg0 overflow : vector<4xi32> + %2 = llvm.ashr %1, %0 : vector<4xi32> + %3 = llvm.or %2, %arg0 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @neg_or_ashr_i32_vec(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %3 = llvm.sub %1, %arg0 : vector<4xi32> + %4 = llvm.or %3, %arg0 : vector<4xi32> + %5 = llvm.ashr %4, %2 : vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @sub_ashr_or_i32_vec_commute(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %1 = llvm.sub %arg1, %arg0 overflow : vector<4xi32> + %2 = llvm.ashr %1, %0 : vector<4xi32> + %3 = llvm.or %arg0, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @neg_or_ashr_i32_vec_commute(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<42> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %3 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %4 = llvm.sdiv %0, %arg0 : vector<4xi32> + %5 = llvm.sub %2, %4 : vector<4xi32> + %6 = llvm.or %4, %5 : vector<4xi32> + %7 = llvm.ashr %6, %3 : vector<4xi32> + llvm.return %7 : vector<4xi32> + } + llvm.func @sub_ashr_or_i32_extra_use_sub(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + llvm.store %1, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @sub_ashr_or_i32_extra_use_or(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + llvm.store %3, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %3 : i32 + } + llvm.func @neg_extra_use_or_ashr_i32(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.ashr %3, %1 : i32 + llvm.store %2, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %4 : i32 + } + llvm.func @sub_ashr_or_i32_extra_use_ashr(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.ashr %1, %0 : i32 + llvm.store %2, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.or %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @sub_ashr_or_i32_no_nsw_nuw(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 : i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @neg_or_extra_use_ashr_i32(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.ashr %3, %1 : i32 + llvm.store %3, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %4 : i32 + } + llvm.func @sub_ashr_or_i32_vec_undef1(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %12 = llvm.sub %10, %arg0 : vector<4xi32> + %13 = llvm.ashr %12, %11 : vector<4xi32> + %14 = llvm.or %13, %arg0 : vector<4xi32> + llvm.return %14 : vector<4xi32> + } + llvm.func @sub_ashr_or_i32_vec_undef2(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<255> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.undef : i32 + %3 = llvm.mlir.undef : vector<4xi32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<4xi32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<4xi32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<4xi32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %1, %9[%10 : i32] : vector<4xi32> + %12 = llvm.sub %0, %arg0 overflow : vector<4xi32> + %13 = llvm.ashr %12, %11 : vector<4xi32> + %14 = llvm.or %13, %arg0 : vector<4xi32> + llvm.return %14 : vector<4xi32> + } + llvm.func @sub_ashr_or_i32_shift_wrong_bit(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(11 : i32) : i32 + %1 = llvm.sub %arg1, %arg0 overflow : i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.or %2, %arg0 : i32 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sub-from-sub.ll.mlir b/test/LLVMDialect/InstCombine/sub-from-sub.ll.mlir index 9a769b2b3..ce530749a 100644 --- a/test/LLVMDialect/InstCombine/sub-from-sub.ll.mlir +++ b/test/LLVMDialect/InstCombine/sub-from-sub.ll.mlir @@ -1,144 +1,153 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "g0", type = i8} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "g1", type = i8} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.sub"(%0, %arg2) : (i8, i8) -> i8 - "llvm.return"(%1) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.sub"(%0, %arg2) : (i8, i8) -> i8 - "llvm.return"(%1) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t1_flags", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.sub"(%0, %arg2) : (i8, i8) -> i8 - "llvm.return"(%1) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "n2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 42 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.sub"(%1, %arg1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t3_c0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 42 : i8} : () -> i8 - %1 = "llvm.sub"(%arg0, %0) : (i8, i8) -> i8 - %2 = "llvm.sub"(%1, %arg1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t4_c1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 42 : i8} : () -> i8 - %1 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %2 = "llvm.sub"(%1, %0) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t5_c2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 42 : i8} : () -> i8 - %1 = "llvm.sub"(%0, %arg0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.sub"(%1, %arg1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t6_c0_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 42 : i8} : () -> i8 - %1 = "llvm.sub"(%arg0, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.sub"(%1, %arg1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t7_c1_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 42 : i8} : () -> i8 - %1 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.sub"(%1, %0) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t8_c2_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 24 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 42 : i8} : () -> i8 - %2 = "llvm.sub"(%1, %arg0) : (i8, i8) -> i8 - %3 = "llvm.sub"(%2, %0) : (i8, i8) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t9_c0_c2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 24 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 42 : i8} : () -> i8 - %2 = "llvm.sub"(%arg0, %1) : (i8, i8) -> i8 - %3 = "llvm.sub"(%2, %0) : (i8, i8) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t10_c1_c2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 24 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 42 : i8} : () -> i8 - %2 = "llvm.sub"(%1, %arg0) : (i8, i8) -> i8 - "llvm.call"(%2) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %3 = "llvm.sub"(%2, %0) : (i8, i8) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t11_c0_c2_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 24 : i8} : () -> i8 - %1 = "llvm.mlir.constant"() {value = 42 : i8} : () -> i8 - %2 = "llvm.sub"(%arg0, %1) : (i8, i8) -> i8 - "llvm.call"(%2) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %3 = "llvm.sub"(%2, %0) : (i8, i8) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t12_c1_c2_exrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @g0} : () -> !llvm.ptr - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr) -> i32 - %3 = "llvm.add"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.sub"(%0, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "constantexpr0", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @g1} : () -> !llvm.ptr - %1 = "llvm.ptrtoint"(%0) : (!llvm.ptr) -> i32 - %2 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %3 = "llvm.add"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.sub"(%1, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "constantexpr1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @g1} : () -> !llvm.ptr - %1 = "llvm.ptrtoint"(%0) : (!llvm.ptr) -> i32 - %2 = "llvm.mlir.addressof"() {global_name = @g0} : () -> !llvm.ptr - %3 = "llvm.ptrtoint"(%2) : (!llvm.ptr) -> i32 - %4 = "llvm.add"(%arg0, %3) : (i32, i32) -> i32 - %5 = "llvm.sub"(%1, %4) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "constantexpr2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i64): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @g0} : () -> !llvm.ptr - %1 = "llvm.ptrtoint"(%0) : (!llvm.ptr) -> i64 - %2 = "llvm.mlir.constant"() {value = -1 : i64} : () -> i64 - %3 = "llvm.xor"(%arg0, %2) : (i64, i64) -> i64 - %4 = "llvm.add"(%3, %1) : (i64, i64) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "pr49870", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g0() {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.mlir.global external @g1() {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.func @use8(i8) + llvm.func @t0(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.sub %0, %arg2 : i8 + llvm.return %1 : i8 + } + llvm.func @t1_flags(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 overflow : i8 + %1 = llvm.sub %0, %arg2 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @t1_flags_nuw_only(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 overflow : i8 + %1 = llvm.sub %0, %arg2 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @t1_flags_sub_nsw_sub(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 overflow : i8 + %1 = llvm.sub %0, %arg2 : i8 + llvm.return %1 : i8 + } + llvm.func @t1_flags_nuw_first(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 overflow : i8 + %1 = llvm.sub %0, %arg2 : i8 + llvm.return %1 : i8 + } + llvm.func @t1_flags_nuw_second(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.sub %0, %arg2 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @t1_flags_nuw_nsw_first(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 overflow : i8 + %1 = llvm.sub %0, %arg2 : i8 + llvm.return %1 : i8 + } + llvm.func @t1_flags_nuw_nsw_second(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.sub %0, %arg2 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @n2(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sub %0, %arg2 : i8 + llvm.return %1 : i8 + } + llvm.func @t3_c0(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.sub %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @t4_c1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sub %arg0, %0 : i8 + %2 = llvm.sub %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @t5_c2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + %2 = llvm.sub %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @t6_c0_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @t7_c1_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sub %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @t8_c2_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @t9_c0_c2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(24 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.sub %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @t10_c1_c2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(24 : i8) : i8 + %2 = llvm.sub %arg0, %0 : i8 + %3 = llvm.sub %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @t11_c0_c2_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(24 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @t12_c1_c2_exrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(24 : i8) : i8 + %2 = llvm.sub %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func unnamed_addr @constantexpr0(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.addressof @g0 : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.add %arg0, %1 : i32 + %4 = llvm.sub %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func unnamed_addr @constantexpr1(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.addressof @g1 : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = llvm.sub %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func unnamed_addr @constantexpr2(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.addressof @g0 : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i32 + %2 = llvm.mlir.addressof @g1 : !llvm.ptr + %3 = llvm.ptrtoint %2 : !llvm.ptr to i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.sub %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @pr49870(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(-1 : i64) : i64 + %1 = llvm.mlir.addressof @g0 : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %3 = llvm.xor %arg0, %0 : i64 + %4 = llvm.add %3, %2 : i64 + llvm.return %4 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/sub-gep.ll.mlir b/test/LLVMDialect/InstCombine/sub-gep.ll.mlir new file mode 100644 index 000000000..c424f23ce --- /dev/null +++ b/test/LLVMDialect/InstCombine/sub-gep.ll.mlir @@ -0,0 +1,321 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry, dense<16> : vector<4xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @Arr() {addr_space = 0 : i32} : !llvm.array<42 x i16> + llvm.mlir.global external @Arr_as1() {addr_space = 1 : i32} : !llvm.array<42 x i16> + llvm.func @test_inbounds(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %2 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.sub %3, %2 : i64 + llvm.return %4 : i64 + } + llvm.func @test_partial_inbounds1(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.getelementptr %arg0[%0, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %2 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.sub %3, %2 : i64 + llvm.return %4 : i64 + } + llvm.func @test_partial_inbounds2(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %2 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.sub %3, %2 : i64 + llvm.return %4 : i64 + } + llvm.func @test_inbounds_nuw(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %2 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.sub %3, %2 overflow : i64 + llvm.return %4 : i64 + } + llvm.func @test_nuw(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.getelementptr %arg0[%0, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %2 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.sub %3, %2 overflow : i64 + llvm.return %4 : i64 + } + llvm.func @test_inbounds_nuw_trunc(%arg0: !llvm.ptr, %arg1: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %2 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.trunc %2 : i64 to i32 + %5 = llvm.trunc %3 : i64 to i32 + %6 = llvm.sub %5, %4 overflow : i32 + llvm.return %6 : i32 + } + llvm.func @test_inbounds_nuw_swapped(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %2 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %4 = llvm.sub %3, %2 overflow : i64 + llvm.return %4 : i64 + } + llvm.func @test_inbounds1_nuw_swapped(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.getelementptr %arg0[%0, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %2 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %4 = llvm.sub %3, %2 overflow : i64 + llvm.return %4 : i64 + } + llvm.func @test_inbounds2_nuw_swapped(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %2 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %4 = llvm.sub %3, %2 overflow : i64 + llvm.return %4 : i64 + } + llvm.func @test_inbounds_two_gep(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %2 = llvm.getelementptr inbounds %arg0[%0, %arg2] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.ptrtoint %2 : !llvm.ptr to i64 + %5 = llvm.sub %4, %3 : i64 + llvm.return %5 : i64 + } + llvm.func @test_inbounds_nsw_two_gep(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %2 = llvm.getelementptr inbounds %arg0[%0, %arg2] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.ptrtoint %2 : !llvm.ptr to i64 + %5 = llvm.sub %4, %3 overflow : i64 + llvm.return %5 : i64 + } + llvm.func @test_inbounds_nuw_two_gep(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %2 = llvm.getelementptr inbounds %arg0[%0, %arg2] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<0 x i32> + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.ptrtoint %2 : !llvm.ptr to i64 + %5 = llvm.sub %4, %3 overflow : i64 + llvm.return %5 : i64 + } + llvm.func @test_inbounds_nuw_multi_index(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%0, %arg1, %arg2] : (!llvm.ptr, i64, i64, i64) -> !llvm.ptr, !llvm.array<0 x array<2 x i32>> + %2 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.sub %3, %2 overflow : i64 + llvm.return %4 : i64 + } + llvm.func @test23(%arg0: !llvm.ptr, %arg1: i64) -> i32 { + %0 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %1 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %2 = llvm.trunc %1 : i64 to i32 + %3 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %4 = llvm.trunc %3 : i64 to i32 + %5 = llvm.sub %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test23_as1(%arg0: !llvm.ptr<1>, %arg1: i16) -> i8 { + %0 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr<1>, i16) -> !llvm.ptr<1>, i8 + %1 = llvm.ptrtoint %0 : !llvm.ptr<1> to i16 + %2 = llvm.trunc %1 : i16 to i8 + %3 = llvm.ptrtoint %arg0 : !llvm.ptr<1> to i16 + %4 = llvm.trunc %3 : i16 to i8 + %5 = llvm.sub %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @test24(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %1 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %2 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %3 = llvm.sub %1, %2 : i64 + llvm.return %3 : i64 + } + llvm.func @test24_as1(%arg0: !llvm.ptr<1>, %arg1: i16) -> i16 { + %0 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr<1>, i16) -> !llvm.ptr<1>, i8 + %1 = llvm.ptrtoint %0 : !llvm.ptr<1> to i16 + %2 = llvm.ptrtoint %arg0 : !llvm.ptr<1> to i16 + %3 = llvm.sub %1, %2 : i16 + llvm.return %3 : i16 + } + llvm.func @test24a(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %1 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %2 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %3 = llvm.sub %2, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @test24a_as1(%arg0: !llvm.ptr<1>, %arg1: i16) -> i16 { + %0 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr<1>, i16) -> !llvm.ptr<1>, i8 + %1 = llvm.ptrtoint %0 : !llvm.ptr<1> to i16 + %2 = llvm.ptrtoint %arg0 : !llvm.ptr<1> to i16 + %3 = llvm.sub %2, %1 : i16 + llvm.return %3 : i16 + } + llvm.func @test24b(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.mlir.addressof @Arr : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %3 = llvm.getelementptr inbounds %0[%1, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<42 x i16> + %4 = llvm.ptrtoint %3 : !llvm.ptr to i64 + %5 = llvm.sub %4, %2 : i64 + llvm.return %5 : i64 + } + llvm.func @test25(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.mlir.addressof @Arr : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.getelementptr inbounds %0[%2, %1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<42 x i16> + %4 = llvm.ptrtoint %3 : !llvm.ptr to i64 + %5 = llvm.getelementptr inbounds %0[%1, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<42 x i16> + %6 = llvm.ptrtoint %5 : !llvm.ptr to i64 + %7 = llvm.sub %6, %4 : i64 + llvm.return %7 : i64 + } + llvm.func @test25_as1(%arg0: !llvm.ptr<1>, %arg1: i64) -> i16 { + %0 = llvm.mlir.addressof @Arr_as1 : !llvm.ptr<1> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.getelementptr inbounds %0[%2, %1] : (!llvm.ptr<1>, i64, i64) -> !llvm.ptr<1>, !llvm.array<42 x i16> + %4 = llvm.ptrtoint %3 : !llvm.ptr<1> to i16 + %5 = llvm.getelementptr inbounds %0[%1, %arg1] : (!llvm.ptr<1>, i64, i64) -> !llvm.ptr<1>, !llvm.array<42 x i16> + %6 = llvm.ptrtoint %5 : !llvm.ptr<1> to i16 + %7 = llvm.sub %6, %4 : i16 + llvm.return %7 : i16 + } + llvm.func @test30(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %1 = llvm.getelementptr inbounds %arg0[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %2 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.sub %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @test30_as1(%arg0: !llvm.ptr<1>, %arg1: i16, %arg2: i16) -> i16 { + %0 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr<1>, i16) -> !llvm.ptr<1>, i32 + %1 = llvm.getelementptr inbounds %arg0[%arg2] : (!llvm.ptr<1>, i16) -> !llvm.ptr<1>, i8 + %2 = llvm.ptrtoint %0 : !llvm.ptr<1> to i16 + %3 = llvm.ptrtoint %1 : !llvm.ptr<1> to i16 + %4 = llvm.sub %2, %3 : i16 + llvm.return %4 : i16 + } + llvm.func @gep_diff_both_inbounds(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %1 = llvm.getelementptr inbounds %arg0[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %2 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.sub %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @gep_diff_first_inbounds(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %1 = llvm.getelementptr %arg0[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %2 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.sub %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @gep_diff_second_inbounds(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %1 = llvm.getelementptr inbounds %arg0[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %2 = llvm.ptrtoint %0 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %4 = llvm.sub %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @gep_diff_with_bitcast(%arg0: !llvm.ptr, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(5 : i64) : i64 + %1 = llvm.getelementptr inbounds %arg0[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i64> + %2 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %4 = llvm.sub %2, %3 overflow : i64 + %5 = llvm.lshr %4, %0 : i64 + llvm.return %5 : i64 + } + llvm.func @sub_scalable(%arg0: !llvm.ptr {llvm.noundef}) -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.vec + %2 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %3 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %4 = llvm.sub %2, %3 : i64 + llvm.return %4 : i64 + } + llvm.func @sub_scalable2(%arg0: !llvm.ptr {llvm.noundef}) -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.vec + %3 = llvm.ptrtoint %2 : !llvm.ptr to i64 + %4 = llvm.getelementptr %arg0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.vec + %5 = llvm.ptrtoint %4 : !llvm.ptr to i64 + %6 = llvm.sub %3, %5 : i64 + llvm.return %6 : i64 + } + llvm.func @nullptrtoint_scalable_c() -> i64 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(8 : i64) : i64 + %2 = llvm.getelementptr inbounds %0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.vec + %3 = llvm.ptrtoint %2 : !llvm.ptr to i64 + llvm.return %3 : i64 + } + llvm.func @nullptrtoint_scalable_x(%arg0: i64) -> i64 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.getelementptr inbounds %0[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.vec + %2 = llvm.ptrtoint %1 : !llvm.ptr to i64 + llvm.return %2 : i64 + } + llvm.func @_gep_phi1(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + llvm.cond_br %4, ^bb4(%1 : i64), ^bb1 + ^bb1: // pred: ^bb0 + %5 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %6 = llvm.icmp "eq" %5, %2 : i8 + llvm.cond_br %6, ^bb4(%1 : i64), ^bb2(%arg0 : !llvm.ptr) + ^bb2(%7: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + %8 = llvm.getelementptr inbounds %7[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %9 = llvm.load %8 {alignment = 1 : i64} : !llvm.ptr -> i8 + %10 = llvm.icmp "eq" %9, %2 : i8 + llvm.cond_br %10, ^bb3, ^bb2(%8 : !llvm.ptr) + ^bb3: // pred: ^bb2 + %11 = llvm.ptrtoint %8 : !llvm.ptr to i64 + %12 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %13 = llvm.sub %11, %12 : i64 + llvm.br ^bb4(%13 : i64) + ^bb4(%14: i64): // 3 preds: ^bb0, ^bb1, ^bb3 + %15 = llvm.icmp "ne" %14, %1 : i64 + llvm.return %15 : i1 + } + llvm.func @_gep_phi2(%arg0: !llvm.ptr, %arg1: i64) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.icmp "eq" %arg0, %0 : !llvm.ptr + llvm.cond_br %4, ^bb4(%1 : i64), ^bb1 + ^bb1: // pred: ^bb0 + %5 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %6 = llvm.icmp "eq" %5, %2 : i8 + llvm.cond_br %6, ^bb4(%1 : i64), ^bb2(%arg0 : !llvm.ptr) + ^bb2(%7: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + %8 = llvm.getelementptr inbounds %7[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i8 + %9 = llvm.load %8 {alignment = 1 : i64} : !llvm.ptr -> i8 + %10 = llvm.icmp "eq" %9, %2 : i8 + llvm.cond_br %10, ^bb3, ^bb2(%8 : !llvm.ptr) + ^bb3: // pred: ^bb2 + %11 = llvm.ptrtoint %8 : !llvm.ptr to i64 + %12 = llvm.ptrtoint %arg0 : !llvm.ptr to i64 + %13 = llvm.sub %11, %12 : i64 + llvm.br ^bb4(%13 : i64) + ^bb4(%14: i64): // 3 preds: ^bb0, ^bb1, ^bb3 + %15 = llvm.or %14, %arg1 : i64 + %16 = llvm.icmp "eq" %15, %1 : i64 + llvm.return %16 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/sub-lshr-or-to-icmp-select.ll.mlir b/test/LLVMDialect/InstCombine/sub-lshr-or-to-icmp-select.ll.mlir new file mode 100644 index 000000000..13dc94a13 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sub-lshr-or-to-icmp-select.ll.mlir @@ -0,0 +1,58 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @neg_or_lshr_i32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.lshr %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @neg_or_lshr_i32_commute(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(31 : i32) : i32 + %3 = llvm.sdiv %0, %arg0 : i32 + %4 = llvm.sub %1, %3 : i32 + %5 = llvm.or %3, %4 : i32 + %6 = llvm.lshr %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @neg_or_lshr_i32_vec(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %3 = llvm.sub %1, %arg0 : vector<4xi32> + %4 = llvm.or %3, %arg0 : vector<4xi32> + %5 = llvm.lshr %4, %2 : vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @neg_or_lshr_i32_vec_commute(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<42> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %3 = llvm.mlir.constant(dense<31> : vector<4xi32>) : vector<4xi32> + %4 = llvm.sdiv %0, %arg0 : vector<4xi32> + %5 = llvm.sub %2, %4 : vector<4xi32> + %6 = llvm.or %4, %5 : vector<4xi32> + %7 = llvm.lshr %6, %3 : vector<4xi32> + llvm.return %7 : vector<4xi32> + } + llvm.func @neg_extra_use_or_lshr_i32(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.lshr %3, %1 : i32 + llvm.store %2, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %4 : i32 + } + llvm.func @neg_or_extra_use_lshr_i32(%arg0: i32, %arg1: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.or %2, %arg0 : i32 + %4 = llvm.lshr %3, %1 : i32 + llvm.store %3, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sub-minmax.ll.mlir b/test/LLVMDialect/InstCombine/sub-minmax.ll.mlir new file mode 100644 index 000000000..650c261f2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sub-minmax.ll.mlir @@ -0,0 +1,561 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @max_na_b_minux_na(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.icmp "ult" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.sub %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @na_minus_max_na_b(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.icmp "ult" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @sub_umin(%arg0: i5, %arg1: i5) -> i5 { + %0 = llvm.intr.umin(%arg0, %arg1) : (i5, i5) -> i5 + %1 = llvm.sub %arg0, %0 : i5 + llvm.return %1 : i5 + } + llvm.func @sub_umin_commute_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.intr.umin(%arg1, %arg0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %1 = llvm.sub %arg1, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @sub_umin_uses(%arg0: i5, %arg1: i5, %arg2: !llvm.ptr) -> i5 { + %0 = llvm.intr.umin(%arg0, %arg1) : (i5, i5) -> i5 + llvm.store %0, %arg2 {alignment = 1 : i64} : i5, !llvm.ptr + %1 = llvm.sub %arg0, %0 : i5 + llvm.return %1 : i5 + } + llvm.func @sub_umin_no_common_op(%arg0: i5, %arg1: i5, %arg2: i5) -> i5 { + %0 = llvm.intr.umin(%arg0, %arg1) : (i5, i5) -> i5 + %1 = llvm.sub %arg2, %0 : i5 + llvm.return %1 : i5 + } + llvm.func @max_b_na_minus_na(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.icmp "ugt" %1, %arg1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.sub %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @na_minus_max_b_na(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.icmp "ugt" %1, %arg1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.sub %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @max_na_bi_minux_na(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + %5 = llvm.sub %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @na_minus_max_na_bi(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + %5 = llvm.sub %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @max_bi_na_minus_na(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + %4 = llvm.select %3, %1, %2 : i1, i32 + %5 = llvm.sub %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @na_minus_max_bi_na(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "ugt" %2, %1 : i32 + %4 = llvm.select %3, %1, %2 : i1, i32 + %5 = llvm.sub %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @max_na_bi_minux_na_use(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + %5 = llvm.sub %4, %2 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @na_minus_max_na_bi_use(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + %5 = llvm.sub %2, %4 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @max_bi_na_minus_na_use(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + %5 = llvm.sub %4, %1 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @na_minus_max_bi_na_use(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + %5 = llvm.sub %1, %4 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @max_na_bi_minux_na_use2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + %5 = llvm.sub %4, %2 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @na_minus_max_na_bi_use2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + %5 = llvm.sub %2, %4 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%2) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @max_bi_na_minus_na_use2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + %5 = llvm.sub %4, %1 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @na_minus_max_bi_na_use2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.icmp "ult" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + %5 = llvm.sub %1, %4 : i32 + llvm.call @use32(%4) : (i32) -> () + llvm.call @use32(%1) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @umin_not_sub(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.icmp "ult" %1, %2 : i8 + %4 = llvm.select %3, %1, %2 : i1, i8 + %5 = llvm.sub %1, %4 : i8 + %6 = llvm.sub %2, %4 : i8 + llvm.call @use8(%5) : (i8) -> () + llvm.call @use8(%6) : (i8) -> () + llvm.return %4 : i8 + } + llvm.func @umin_not_sub_rev(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.icmp "ult" %1, %2 : i8 + %4 = llvm.select %3, %1, %2 : i1, i8 + %5 = llvm.sub %4, %1 : i8 + %6 = llvm.sub %4, %2 : i8 + llvm.call @use8(%5) : (i8) -> () + llvm.call @use8(%6) : (i8) -> () + llvm.return %4 : i8 + } + llvm.func @umin3_not_all_ops_extra_uses_invert_subs(%arg0: i8, %arg1: i8, %arg2: i8) { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + %3 = llvm.xor %arg2, %0 : i8 + %4 = llvm.icmp "ult" %1, %3 : i8 + %5 = llvm.select %4, %1, %3 : i1, i8 + %6 = llvm.icmp "ult" %5, %2 : i8 + %7 = llvm.select %6, %5, %2 : i1, i8 + %8 = llvm.sub %1, %7 : i8 + %9 = llvm.sub %2, %7 : i8 + %10 = llvm.sub %3, %7 : i8 + llvm.call @use8(%7) : (i8) -> () + llvm.call @use8(%8) : (i8) -> () + llvm.call @use8(%9) : (i8) -> () + llvm.call @use8(%10) : (i8) -> () + llvm.return + } + llvm.func @umin_not_sub_intrinsic_commute0(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.intr.umin(%1, %2) : (i8, i8) -> i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.sub %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @umax_not_sub_intrinsic_commute1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.intr.umax(%2, %1) : (i8, i8) -> i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.sub %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @smin_not_sub_intrinsic_commute2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.intr.smin(%1, %2) : (i8, i8) -> i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.sub %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @smax_not_sub_intrinsic_commute3(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.intr.smax(%2, %1) : (i8, i8) -> i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.sub %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @umin_not_sub_intrinsic_uses(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.intr.umin(%1, %2) : (i8, i8) -> i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.sub %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @umax_sub_op0(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.umax(%arg1, %arg0) : (i8, i8) -> i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @umax_sub_op0_vec_commute(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.intr.umax(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %1 = llvm.sub %0, %arg1 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @umax_sub_op0_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.umax(%arg0, %arg1) : (i8, i8) -> i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sub %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @umax_sub_op1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.umax(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.sub %arg1, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @umax_sub_op1_vec_commute(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.intr.umax(%arg1, %arg0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %1 = llvm.sub %arg1, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @umax_sub_op1_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.umax(%arg0, %arg1) : (i8, i8) -> i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sub %arg1, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @umin_sub_op1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.umin(%arg1, %arg0) : (i8, i8) -> i8 + %1 = llvm.sub %arg1, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @umin_sub_op1_commute(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.umin(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.sub %arg1, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @umin_sub_op0(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.umin(%arg1, %arg0) : (i8, i8) -> i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @umin_sub_op0_commute(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.umin(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @umin_sub_op1_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.umin(%arg1, %arg0) : (i8, i8) -> i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sub %arg1, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @umin_sub_op0_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.umin(%arg1, %arg0) : (i8, i8) -> i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sub %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @diff_add_smin(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.intr.smin(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @diff_add_smax(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.intr.smax(%arg1, %arg0) : (i8, i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @diff_add_umin(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.intr.umin(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @diff_add_umax(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.intr.umax(%arg1, %arg0) : (i8, i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @diff_add_smin_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.intr.smin(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.call @use8(%1) : (i8) -> () + llvm.return %2 : i8 + } + llvm.func @diff_add_use_smax(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.intr.smax(%arg1, %arg0) : (i8, i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.call @use8(%0) : (i8) -> () + llvm.return %2 : i8 + } + llvm.func @diff_add_use_umin_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.intr.umin(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.call @use8(%0) : (i8) -> () + llvm.call @use8(%1) : (i8) -> () + llvm.return %2 : i8 + } + llvm.func @sub_add_umin(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.intr.umin(%arg1, %arg2) : (i8, i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sub_add_umin_commute_umin(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.intr.umin(%arg2, %arg1) : (i8, i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sub_add_umin_commute_add(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.add %arg1, %arg0 : i8 + %1 = llvm.intr.umin(%arg1, %arg2) : (i8, i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sub_add_umin_commute_add_umin(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.add %arg1, %arg0 : i8 + %1 = llvm.intr.umin(%arg2, %arg1) : (i8, i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sub_add_umin_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.add %arg0, %arg1 : vector<2xi8> + %1 = llvm.intr.umin(%arg1, %arg2) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %2 = llvm.sub %0, %1 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @sub_add_umin_mismatch(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.intr.umin(%arg3, %arg2) : (i8, i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sub_add_umin_use_a(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.intr.umin(%arg1, %arg2) : (i8, i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.call @use8(%0) : (i8) -> () + llvm.return %2 : i8 + } + llvm.func @sub_add_umin_use_m(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.intr.umin(%arg1, %arg2) : (i8, i8) -> i8 + %2 = llvm.sub %0, %1 : i8 + llvm.call @use8(%1) : (i8) -> () + llvm.return %2 : i8 + } + llvm.func @sub_smax0_sub_nsw(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.sub %arg0, %arg1 overflow : vector<2xi8> + %8 = llvm.intr.smax(%7, %6) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %9 = llvm.sub %arg0, %8 : vector<2xi8> + llvm.return %9 : vector<2xi8> + } + llvm.func @sub_smax0_sub_nsw_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 overflow : i8 + %2 = llvm.intr.smax(%1, %0) : (i8, i8) -> i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_smax0_sub(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + %2 = llvm.intr.smax(%1, %0) : (i8, i8) -> i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_smax0_sub_commute(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 overflow : i8 + %2 = llvm.intr.smax(%1, %0) : (i8, i8) -> i8 + %3 = llvm.sub %2, %arg0 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_smin0_sub_nsw_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 overflow : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.intr.smin(%1, %0) : (i8, i8) -> i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_smin0_sub_nsw(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %2 = llvm.sub %arg0, %arg1 overflow : vector<2xi8> + %3 = llvm.intr.smin(%2, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %4 = llvm.sub %arg0, %3 : vector<2xi8> + llvm.return %4 : vector<2xi8> + } + llvm.func @sub_smin0_sub(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + %2 = llvm.intr.smin(%1, %0) : (i8, i8) -> i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_smin0_sub_nsw_commute(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg1, %arg0 overflow : i8 + %2 = llvm.intr.smin(%1, %0) : (i8, i8) -> i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_max_min_nsw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.smin(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.intr.smax(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.sub %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @sub_max_min_nuw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.smin(%arg0, %arg1) : (i8, i8) -> i8 + %1 = llvm.intr.smax(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.sub %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @sub_max_min_nsw_commute(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.smin(%arg1, %arg0) : (i8, i8) -> i8 + %1 = llvm.intr.smax(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.sub %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @sub_max_min_nuw_commute(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.smin(%arg1, %arg0) : (i8, i8) -> i8 + %1 = llvm.intr.smax(%arg0, %arg1) : (i8, i8) -> i8 + %2 = llvm.sub %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @sub_max_min_vec_nsw(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.intr.smin(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %1 = llvm.intr.smax(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %2 = llvm.sub %1, %0 overflow : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @sub_max_min_vec_nuw(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.intr.smin(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %1 = llvm.intr.smax(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %2 = llvm.sub %1, %0 overflow : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @sub_max_min_vec_nsw_commute(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.intr.smin(%arg1, %arg0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %1 = llvm.intr.smax(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %2 = llvm.sub %1, %0 overflow : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @sub_max_min_vec_nuw_commute(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.intr.smin(%arg1, %arg0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %1 = llvm.intr.smax(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + %2 = llvm.sub %1, %0 overflow : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @sub_max_min_multi_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.intr.smin(%arg0, %arg1) : (i8, i8) -> i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.intr.smax(%arg0, %arg1) : (i8, i8) -> i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %1, %0 overflow : i8 + llvm.return %2 : i8 + } + llvm.func @sub_max_min_vec_multi_use(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.addressof @use8v2 : !llvm.ptr + %1 = llvm.intr.smin(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.call %0(%1) : !llvm.ptr, (vector<2xi8>) -> () + %2 = llvm.intr.smax(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> + llvm.call %0(%2) : !llvm.ptr, (vector<2xi8>) -> () + %3 = llvm.sub %2, %1 overflow : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @use8(i8) + llvm.func @use32(i32) + llvm.func @use8v2(i8) +} diff --git a/test/LLVMDialect/InstCombine/sub-not.ll.mlir b/test/LLVMDialect/InstCombine/sub-not.ll.mlir new file mode 100644 index 000000000..9632213a7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sub-not.ll.mlir @@ -0,0 +1,103 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i8) + llvm.func @sub_not(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @sub_not_extra_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + %2 = llvm.xor %1, %0 : i8 + llvm.call @use(%1) : (i8) -> () + llvm.return %2 : i8 + } + llvm.func @sub_not_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.sub %arg0, %arg1 : vector<2xi8> + %8 = llvm.xor %7, %6 : vector<2xi8> + llvm.return %8 : vector<2xi8> + } + llvm.func @dec_sub(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + %2 = llvm.add %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @dec_sub_extra_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.sub %arg0, %arg1 : i8 + %2 = llvm.add %1, %0 : i8 + llvm.call @use(%1) : (i8) -> () + llvm.return %2 : i8 + } + llvm.func @dec_sub_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.sub %arg0, %arg1 : vector<2xi8> + %8 = llvm.add %7, %6 : vector<2xi8> + llvm.return %8 : vector<2xi8> + } + llvm.func @sub_inc(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.sub %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sub_inc_extra_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.sub %arg1, %1 : i8 + llvm.call @use(%1) : (i8) -> () + llvm.return %2 : i8 + } + llvm.func @sub_inc_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.add %arg0, %6 : vector<2xi8> + %8 = llvm.sub %arg1, %7 : vector<2xi8> + llvm.return %8 : vector<2xi8> + } + llvm.func @sub_dec(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.sub %1, %arg1 : i8 + llvm.return %2 : i8 + } + llvm.func @sub_dec_extra_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.sub %1, %arg1 : i8 + llvm.call @use(%1) : (i8) -> () + llvm.return %2 : i8 + } + llvm.func @sub_dec_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.add %arg0, %6 : vector<2xi8> + %8 = llvm.sub %7, %arg1 : vector<2xi8> + llvm.return %8 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/sub-of-negatible-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/sub-of-negatible-inseltpoison.ll.mlir new file mode 100644 index 000000000..f6c0c6d36 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sub-of-negatible-inseltpoison.ll.mlir @@ -0,0 +1,808 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use4(i4) + llvm.func @use8(i8) + llvm.func @use_v2i4(vector<2xi4>) + llvm.func @use32gen1(i32) -> i1 + llvm.func @t0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @t1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @t2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @n2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @t3(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg2 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.shl %1, %arg1 : i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @n3(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg2 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.shl %1, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @t4(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.mlir.constant(44 : i8) : i8 + %2 = llvm.select %arg1, %0, %1 : i1, i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @n4(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.mlir.constant(44 : i8) : i8 + %2 = llvm.select %arg1, %0, %1 : i1, i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @n5(%arg0: i8, %arg1: i1, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.select %arg1, %0, %arg2 : i1, i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @t6(%arg0: i8, %arg1: i1, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-42 : i8) : i8 + %2 = llvm.sub %0, %arg2 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.select %arg1, %1, %2 : i1, i8 + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @t7(%arg0: i8, %arg1: i1, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %0, %arg2 : i8 + %3 = llvm.select %arg1, %1, %2 : i1, i8 + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @n8(%arg0: i8, %arg1: i1, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %0, %arg2 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.select %arg1, %1, %2 : i1, i8 + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @t9(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg1, %arg0 : i8 + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @n10(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg1, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @neg_of_sub_from_constant(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @neg_of_sub_from_constant_multi_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_from_constant_of_sub_from_constant(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_from_constant_of_sub_from_constant_multi_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_from_variable_of_sub_from_constant(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.sub %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sub_from_variable_of_sub_from_constant_multi_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @t12(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %0, %arg2 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %1, %2 : i8 + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @n13(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.add %1, %arg2 : i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @n14(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %0, %arg2 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %1, %2 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @neg_of_add_with_constant(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @neg_of_add_with_constant_multi_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_from_constant_of_add_with_constant(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_from_constant_of_add_with_constant_multi_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_from_variable_of_add_with_constant(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.sub %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sub_from_variable_of_add_with_constant_multi_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @t15(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.mul %1, %arg2 : i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @n16(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.mul %1, %arg2 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @t16(%arg0: i1, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.sub %1, %arg1 : i8 + llvm.br ^bb3(%2 : i8) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : i8) + ^bb3(%3: i8): // 2 preds: ^bb1, ^bb2 + %4 = llvm.sub %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @n17(%arg0: i1, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.sub %1, %arg1 : i8 + llvm.br ^bb3(%2 : i8) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : i8) + ^bb3(%3: i8): // 2 preds: ^bb1, ^bb2 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.sub %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @n19(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.sub %0, %arg1 : i8 + llvm.br ^bb3(%1 : i8) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%arg2 : i8) + ^bb3(%2: i8): // 2 preds: ^bb1, ^bb2 + %3 = llvm.sub %0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @phi_with_duplicate_incoming_basic_blocks(%arg0: i32, %arg1: i32, %arg2: i1, %arg3: i32) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(84 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + llvm.cond_br %arg2, ^bb1(%arg1 : i32), ^bb2(%1 : i32) + ^bb1(%4: i32): // 2 preds: ^bb0, ^bb2 + llvm.switch %4 : i32, ^bb3 [ + 0: ^bb2(%3 : i32), + 42: ^bb2(%3 : i32) + ] + ^bb2(%5: i32): // 3 preds: ^bb0, ^bb1, ^bb1 + %6 = llvm.sub %2, %5 : i32 + %7 = llvm.call @use32gen1(%6) : (i32) -> i1 + llvm.cond_br %7, ^bb1(%6 : i32), ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + llvm.return + } + llvm.func @t20(%arg0: i8, %arg1: i16) -> i8 { + %0 = llvm.mlir.constant(-42 : i16) : i16 + %1 = llvm.shl %0, %arg1 : i16 + %2 = llvm.trunc %1 : i16 to i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @n21(%arg0: i8, %arg1: i16) -> i8 { + %0 = llvm.mlir.constant(-42 : i16) : i16 + %1 = llvm.shl %0, %arg1 : i16 + %2 = llvm.trunc %1 : i16 to i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negate_xor(%arg0: i4) -> i4 { + %0 = llvm.mlir.constant(5 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.xor %arg0, %0 : i4 + %3 = llvm.sub %1, %2 : i4 + llvm.return %3 : i4 + } + llvm.func @negate_xor_vec(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-6 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.mlir.constant(dense<[5, -6]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.constant(0 : i4) : i4 + %4 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %5 = llvm.xor %arg0, %2 : vector<2xi4> + %6 = llvm.sub %4, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @negate_xor_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negate_shl_xor(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(5 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.xor %arg0, %0 : i4 + %3 = llvm.shl %2, %arg1 : i4 + %4 = llvm.sub %1, %3 : i4 + llvm.return %4 : i4 + } + llvm.func @negate_shl_not_uses(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.shl %2, %arg1 : i8 + %4 = llvm.sub %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_mul_not_uses_vec(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(0 : i4) : i4 + %3 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %4 = llvm.xor %arg0, %1 : vector<2xi4> + llvm.call @use_v2i4(%4) : (vector<2xi4>) -> () + %5 = llvm.mul %4, %arg1 : vector<2xi4> + %6 = llvm.sub %3, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @negate_sdiv(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sdiv %arg1, %0 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_sdiv_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sdiv %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_sdiv_extrause2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.sdiv %arg1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negate_ashr(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg1, %0 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_lshr(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.lshr %arg1, %0 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_ashr_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_lshr_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.lshr %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_ashr_wrongshift(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.ashr %arg1, %0 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_lshr_wrongshift(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.lshr %arg1, %0 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_sext(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @negate_zext(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.zext %arg1 : i1 to i8 + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @negate_sext_extrause(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @negate_zext_extrause(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.zext %arg1 : i1 to i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @negate_sext_wrongwidth(%arg0: i8, %arg1: i2) -> i8 { + %0 = llvm.sext %arg1 : i2 to i8 + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @negate_zext_wrongwidth(%arg0: i8, %arg1: i2) -> i8 { + %0 = llvm.zext %arg1 : i2 to i8 + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @negate_shufflevector_oneinput_reverse(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(5 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.mlir.constant(dense<[-6, 5]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.poison : vector<2xi4> + %4 = llvm.shl %2, %arg0 : vector<2xi4> + %5 = llvm.shufflevector %4, %3 [1, 0] : vector<2xi4> + %6 = llvm.sub %arg1, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @negate_shufflevector_oneinput_second_lane_is_undef(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(5 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.mlir.constant(dense<[-6, 5]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.poison : vector<2xi4> + %4 = llvm.shl %2, %arg0 : vector<2xi4> + %5 = llvm.shufflevector %4, %3 [0, 2] : vector<2xi4> + %6 = llvm.sub %arg1, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @negate_shufflevector_twoinputs(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(5 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.mlir.constant(dense<[-6, 5]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.constant(-1 : i4) : i4 + %4 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %5 = llvm.shl %2, %arg0 : vector<2xi4> + %6 = llvm.xor %arg1, %4 : vector<2xi4> + %7 = llvm.shufflevector %5, %6 [0, 3] : vector<2xi4> + %8 = llvm.sub %arg2, %7 : vector<2xi4> + llvm.return %8 : vector<2xi4> + } + llvm.func @negate_shufflevector_oneinput_extrause(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(5 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.mlir.constant(dense<[-6, 5]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.poison : vector<2xi4> + %4 = llvm.shl %2, %arg0 : vector<2xi4> + %5 = llvm.shufflevector %4, %3 [1, 0] : vector<2xi4> + llvm.call @use_v2i4(%5) : (vector<2xi4>) -> () + %6 = llvm.sub %arg1, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @negation_of_zeroext_of_nonnegative(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "sge" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.zext %2 : i8 to i16 + %5 = llvm.sub %1, %4 : i16 + llvm.return %5 : i16 + ^bb2: // pred: ^bb0 + llvm.return %1 : i16 + } + llvm.func @negation_of_zeroext_of_positive(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "sgt" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.zext %2 : i8 to i16 + %5 = llvm.sub %1, %4 : i16 + llvm.return %5 : i16 + ^bb2: // pred: ^bb0 + llvm.return %1 : i16 + } + llvm.func @negation_of_signext_of_negative(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "slt" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.sext %2 : i8 to i16 + %5 = llvm.sub %1, %4 : i16 + llvm.return %5 : i16 + ^bb2: // pred: ^bb0 + llvm.return %1 : i16 + } + llvm.func @negation_of_signext_of_nonpositive(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "sle" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.sext %2 : i8 to i16 + %5 = llvm.sub %1, %4 : i16 + llvm.return %5 : i16 + ^bb2: // pred: ^bb0 + llvm.return %1 : i16 + } + llvm.func @negation_of_signext_of_nonnegative__wrong_cast(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "sge" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.sext %2 : i8 to i16 + %5 = llvm.sub %1, %4 : i16 + llvm.return %5 : i16 + ^bb2: // pred: ^bb0 + llvm.return %1 : i16 + } + llvm.func @negation_of_zeroext_of_negative_wrongcast(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "slt" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.zext %2 : i8 to i16 + %5 = llvm.sub %1, %4 : i16 + llvm.return %5 : i16 + ^bb2: // pred: ^bb0 + llvm.return %1 : i16 + } + llvm.func @negation_of_increment_via_or_with_no_common_bits_set(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %arg1, %0 : i8 + %2 = llvm.or %1, %0 : i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negation_of_increment_via_or_with_no_common_bits_set_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %arg1, %0 : i8 + %2 = llvm.or %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negation_of_increment_via_or_common_bits_set(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.shl %arg1, %0 : i8 + %3 = llvm.or %2, %1 : i8 + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @add_via_or_with_no_common_bits_set(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.shl %3, %1 : i8 + %5 = llvm.or %4, %2 : i8 + %6 = llvm.sub %arg0, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @add_via_or_with_common_bit_maybe_set(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(4 : i8) : i8 + %3 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.shl %3, %1 : i8 + %5 = llvm.or %4, %2 : i8 + %6 = llvm.sub %arg0, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @add_via_or_with_no_common_bits_set_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.shl %3, %1 : i8 + %5 = llvm.or %4, %2 : i8 + llvm.call @use8(%5) : (i8) -> () + %6 = llvm.sub %arg0, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @negate_extractelement(%arg0: vector<2xi4>, %arg1: i32, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %2 = llvm.sub %1, %arg0 : vector<2xi4> + llvm.call @use_v2i4(%2) : (vector<2xi4>) -> () + %3 = llvm.extractelement %2[%arg1 : i32] : vector<2xi4> + %4 = llvm.sub %arg2, %3 : i4 + llvm.return %4 : i4 + } + llvm.func @negate_extractelement_extrause(%arg0: vector<2xi4>, %arg1: i32, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %2 = llvm.sub %1, %arg0 : vector<2xi4> + llvm.call @use_v2i4(%2) : (vector<2xi4>) -> () + %3 = llvm.extractelement %2[%arg1 : i32] : vector<2xi4> + llvm.call @use4(%3) : (i4) -> () + %4 = llvm.sub %arg2, %3 : i4 + llvm.return %4 : i4 + } + llvm.func @negate_insertelement(%arg0: vector<2xi4>, %arg1: i4, %arg2: i32, %arg3: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %2 = llvm.sub %1, %arg0 : vector<2xi4> + %3 = llvm.sub %0, %arg1 : i4 + %4 = llvm.insertelement %3, %2[%arg2 : i32] : vector<2xi4> + %5 = llvm.sub %arg3, %4 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @negate_insertelement_extrause(%arg0: vector<2xi4>, %arg1: i4, %arg2: i32, %arg3: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %2 = llvm.sub %1, %arg0 : vector<2xi4> + %3 = llvm.sub %0, %arg1 : i4 + %4 = llvm.insertelement %3, %2[%arg2 : i32] : vector<2xi4> + llvm.call @use_v2i4(%4) : (vector<2xi4>) -> () + %5 = llvm.sub %arg3, %4 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @negate_insertelement_nonnegatible_base(%arg0: vector<2xi4>, %arg1: i4, %arg2: i32, %arg3: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.sub %0, %arg1 : i4 + %2 = llvm.insertelement %1, %arg0[%arg2 : i32] : vector<2xi4> + %3 = llvm.sub %arg3, %2 : vector<2xi4> + llvm.return %3 : vector<2xi4> + } + llvm.func @negate_insertelement_nonnegatible_insert(%arg0: vector<2xi4>, %arg1: i4, %arg2: i32, %arg3: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %2 = llvm.sub %1, %arg0 : vector<2xi4> + %3 = llvm.insertelement %arg1, %2[%arg2 : i32] : vector<2xi4> + %4 = llvm.sub %arg3, %3 : vector<2xi4> + llvm.return %4 : vector<2xi4> + } + llvm.func @negate_left_shift_by_constant_prefer_keeping_shl(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.sub %0, %arg2 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.shl %2, %1 : i8 + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_left_shift_by_constant_prefer_keeping_shl_extrause(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.sub %0, %arg2 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.shl %2, %1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_left_shift_by_constant(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.sub %arg3, %arg2 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.shl %1, %0 : i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negate_left_shift_by_constant_extrause(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.sub %arg3, %arg2 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.shl %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negate_add_with_single_negatible_operand(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negate_add_with_single_negatible_operand_depth2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(21 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.mul %2, %arg1 : i8 + %4 = llvm.sub %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_add_with_single_negatible_operand_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negate_add_with_single_negatible_operand_non_negation(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.sub %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_abs(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "slt" %arg0, %0 : i8 + %3 = llvm.select %2, %1, %arg0 : i1, i8 + %4 = llvm.sub %arg1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_nabs(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "slt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %1 : i1, i8 + %4 = llvm.sub %arg1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_select_of_op_vs_negated_op(%arg0: i8, %arg1: i8, %arg2: i1) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.select %arg2, %1, %arg0 : i1, i8 + %3 = llvm.sub %arg1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @dont_negate_ordinary_select(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i1) -> i8 { + %0 = llvm.select %arg3, %arg0, %arg1 : i1, i8 + %1 = llvm.sub %arg2, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @negate_freeze(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.sub %arg0, %arg1 : i4 + %1 = llvm.freeze %0 : i4 + %2 = llvm.sub %arg2, %1 : i4 + llvm.return %2 : i4 + } + llvm.func @negate_freeze_extrause(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.sub %arg0, %arg1 : i4 + %1 = llvm.freeze %0 : i4 + llvm.call @use4(%1) : (i4) -> () + %2 = llvm.sub %arg2, %1 : i4 + llvm.return %2 : i4 + } + llvm.func @noncanonical_mul_with_constant_as_first_operand() { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.mlir.constant(0 : i32) : i32 + llvm.br ^bb1(%0 : i32) + ^bb1(%3: i32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.trunc %3 : i32 to i16 + %5 = llvm.mul %1, %4 overflow : i16 + %6 = llvm.sext %5 : i16 to i32 + %7 = llvm.sub %2, %6 overflow : i32 + llvm.br ^bb1(%7 : i32) + } +} diff --git a/test/LLVMDialect/InstCombine/sub-of-negatible.ll.mlir b/test/LLVMDialect/InstCombine/sub-of-negatible.ll.mlir new file mode 100644 index 000000000..6aa58f1e6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sub-of-negatible.ll.mlir @@ -0,0 +1,869 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external hidden @g() {addr_space = 0 : i32, dso_local} : !llvm.array<1 x array<1 x f64>> + llvm.func @use4(i4) + llvm.func @use8(i8) + llvm.func @use_v2i4(vector<2xi4>) + llvm.func @use32gen1(i32) -> i1 + llvm.func @t0(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @t1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @t2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @n2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.shl %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @t3(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg2 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.shl %1, %arg1 : i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @n3(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg2 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.shl %1, %arg1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @t4(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.mlir.constant(44 : i8) : i8 + %2 = llvm.select %arg1, %0, %1 : i1, i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @select_of_constants_multi_use(%arg0: i1) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.select %arg0, %0, %1 : i1, i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.sub %2, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @PR52261(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.sub %2, %3 overflow : i32 + %5 = llvm.and %3, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @n4(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.mlir.constant(44 : i8) : i8 + %2 = llvm.select %arg1, %0, %1 : i1, i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @n5(%arg0: i8, %arg1: i1, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.select %arg1, %0, %arg2 : i1, i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @t6(%arg0: i8, %arg1: i1, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(-42 : i8) : i8 + %2 = llvm.sub %0, %arg2 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.select %arg1, %1, %2 : i1, i8 + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @t7(%arg0: i8, %arg1: i1, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %0, %arg2 : i8 + %3 = llvm.select %arg1, %1, %2 : i1, i8 + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @n8(%arg0: i8, %arg1: i1, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.shl %0, %arg2 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.select %arg1, %1, %2 : i1, i8 + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @t9(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg1, %arg0 : i8 + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @n10(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %arg1, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @neg_of_sub_from_constant(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @neg_of_sub_from_constant_multi_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_from_constant_of_sub_from_constant(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_from_constant_of_sub_from_constant_multi_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.sub %0, %arg0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_from_variable_of_sub_from_constant(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + %2 = llvm.sub %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sub_from_variable_of_sub_from_constant_multi_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @t12(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %0, %arg2 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %1, %2 : i8 + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @n13(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.add %1, %arg2 : i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @n14(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %0, %arg2 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.add %1, %2 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @neg_of_add_with_constant(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @neg_of_add_with_constant_multi_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_from_constant_of_add_with_constant(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_from_constant_of_add_with_constant_multi_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @sub_from_variable_of_add_with_constant(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.sub %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @sub_from_variable_of_add_with_constant_multi_use(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @t15(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.mul %1, %arg2 : i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @n16(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.mul %1, %arg2 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @t16(%arg0: i1, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.sub %1, %arg1 : i8 + llvm.br ^bb3(%2 : i8) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : i8) + ^bb3(%3: i8): // 2 preds: ^bb1, ^bb2 + %4 = llvm.sub %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @n17(%arg0: i1, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.sub %1, %arg1 : i8 + llvm.br ^bb3(%2 : i8) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%0 : i8) + ^bb3(%3: i8): // 2 preds: ^bb1, ^bb2 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.sub %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @n19(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.sub %0, %arg1 : i8 + llvm.br ^bb3(%1 : i8) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%arg2 : i8) + ^bb3(%2: i8): // 2 preds: ^bb1, ^bb2 + %3 = llvm.sub %0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @phi_with_duplicate_incoming_basic_blocks(%arg0: i32, %arg1: i32, %arg2: i1, %arg3: i32) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(84 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + llvm.cond_br %arg2, ^bb1(%arg1 : i32), ^bb2(%1 : i32) + ^bb1(%4: i32): // 2 preds: ^bb0, ^bb2 + llvm.switch %4 : i32, ^bb3 [ + 0: ^bb2(%3 : i32), + 42: ^bb2(%3 : i32) + ] + ^bb2(%5: i32): // 3 preds: ^bb0, ^bb1, ^bb1 + %6 = llvm.sub %2, %5 : i32 + %7 = llvm.call @use32gen1(%6) : (i32) -> i1 + llvm.cond_br %7, ^bb1(%6 : i32), ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + llvm.return + } + llvm.func @t20(%arg0: i8, %arg1: i16) -> i8 { + %0 = llvm.mlir.constant(-42 : i16) : i16 + %1 = llvm.shl %0, %arg1 : i16 + %2 = llvm.trunc %1 : i16 to i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @n21(%arg0: i8, %arg1: i16) -> i8 { + %0 = llvm.mlir.constant(-42 : i16) : i16 + %1 = llvm.shl %0, %arg1 : i16 + %2 = llvm.trunc %1 : i16 to i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negate_xor(%arg0: i4) -> i4 { + %0 = llvm.mlir.constant(5 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.xor %arg0, %0 : i4 + %3 = llvm.sub %1, %2 : i4 + llvm.return %3 : i4 + } + llvm.func @negate_xor_vec(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-6 : i4) : i4 + %1 = llvm.mlir.constant(5 : i4) : i4 + %2 = llvm.mlir.constant(dense<[5, -6]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.constant(0 : i4) : i4 + %4 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %5 = llvm.xor %arg0, %2 : vector<2xi4> + %6 = llvm.sub %4, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @negate_xor_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negate_shl_xor(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(5 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.xor %arg0, %0 : i4 + %3 = llvm.shl %2, %arg1 : i4 + %4 = llvm.sub %1, %3 : i4 + llvm.return %4 : i4 + } + llvm.func @negate_shl_not_uses(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.shl %2, %arg1 : i8 + %4 = llvm.sub %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_mul_not_uses_vec(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(0 : i4) : i4 + %3 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %4 = llvm.xor %arg0, %1 : vector<2xi4> + llvm.call @use_v2i4(%4) : (vector<2xi4>) -> () + %5 = llvm.mul %4, %arg1 : vector<2xi4> + %6 = llvm.sub %3, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @negate_sdiv(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sdiv %arg1, %0 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_sdiv_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.sdiv %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_sdiv_extrause2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.sdiv %arg1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negate_ashr(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg1, %0 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_lshr(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.lshr %arg1, %0 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_ashr_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.ashr %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_lshr_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.lshr %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_ashr_wrongshift(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.ashr %arg1, %0 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_lshr_wrongshift(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.lshr %arg1, %0 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_sext(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @negate_zext(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.zext %arg1 : i1 to i8 + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @negate_sext_extrause(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @negate_zext_extrause(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.zext %arg1 : i1 to i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @negate_sext_wrongwidth(%arg0: i8, %arg1: i2) -> i8 { + %0 = llvm.sext %arg1 : i2 to i8 + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @negate_zext_wrongwidth(%arg0: i8, %arg1: i2) -> i8 { + %0 = llvm.zext %arg1 : i2 to i8 + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @negate_shufflevector_oneinput_reverse(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(5 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.mlir.constant(dense<[-6, 5]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.undef : vector<2xi4> + %4 = llvm.shl %2, %arg0 : vector<2xi4> + %5 = llvm.shufflevector %4, %3 [1, 0] : vector<2xi4> + %6 = llvm.sub %arg1, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @negate_shufflevector_oneinput_second_lane_is_undef(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(5 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.mlir.constant(dense<[-6, 5]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.undef : vector<2xi4> + %4 = llvm.shl %2, %arg0 : vector<2xi4> + %5 = llvm.shufflevector %4, %3 [0, 2] : vector<2xi4> + %6 = llvm.sub %arg1, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @negate_shufflevector_twoinputs(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(5 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.mlir.constant(dense<[-6, 5]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.constant(-1 : i4) : i4 + %4 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %5 = llvm.shl %2, %arg0 : vector<2xi4> + %6 = llvm.xor %arg1, %4 : vector<2xi4> + %7 = llvm.shufflevector %5, %6 [0, 3] : vector<2xi4> + %8 = llvm.sub %arg2, %7 : vector<2xi4> + llvm.return %8 : vector<2xi4> + } + llvm.func @negate_shufflevector_oneinput_extrause(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(5 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.mlir.constant(dense<[-6, 5]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.undef : vector<2xi4> + %4 = llvm.shl %2, %arg0 : vector<2xi4> + %5 = llvm.shufflevector %4, %3 [1, 0] : vector<2xi4> + llvm.call @use_v2i4(%5) : (vector<2xi4>) -> () + %6 = llvm.sub %arg1, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @negation_of_zeroext_of_nonnegative(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "sge" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.zext %2 : i8 to i16 + %5 = llvm.sub %1, %4 : i16 + llvm.return %5 : i16 + ^bb2: // pred: ^bb0 + llvm.return %1 : i16 + } + llvm.func @negation_of_zeroext_of_positive(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "sgt" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.zext %2 : i8 to i16 + %5 = llvm.sub %1, %4 : i16 + llvm.return %5 : i16 + ^bb2: // pred: ^bb0 + llvm.return %1 : i16 + } + llvm.func @negation_of_signext_of_negative(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "slt" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.sext %2 : i8 to i16 + %5 = llvm.sub %1, %4 : i16 + llvm.return %5 : i16 + ^bb2: // pred: ^bb0 + llvm.return %1 : i16 + } + llvm.func @negation_of_signext_of_nonpositive(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "sle" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.sext %2 : i8 to i16 + %5 = llvm.sub %1, %4 : i16 + llvm.return %5 : i16 + ^bb2: // pred: ^bb0 + llvm.return %1 : i16 + } + llvm.func @negation_of_signext_of_nonnegative__wrong_cast(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "sge" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.sext %2 : i8 to i16 + %5 = llvm.sub %1, %4 : i16 + llvm.return %5 : i16 + ^bb2: // pred: ^bb0 + llvm.return %1 : i16 + } + llvm.func @negation_of_zeroext_of_negative_wrongcast(%arg0: i8) -> i16 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.sub %0, %arg0 : i8 + %3 = llvm.icmp "slt" %2, %0 : i8 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %4 = llvm.zext %2 : i8 to i16 + %5 = llvm.sub %1, %4 : i16 + llvm.return %5 : i16 + ^bb2: // pred: ^bb0 + llvm.return %1 : i16 + } + llvm.func @negation_of_increment_via_or_with_no_common_bits_set(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %arg1, %0 : i8 + %2 = llvm.or %1, %0 : i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negation_of_increment_via_or_with_no_common_bits_set_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.shl %arg1, %0 : i8 + %2 = llvm.or %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negation_of_increment_via_or_common_bits_set(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.shl %arg1, %0 : i8 + %3 = llvm.or %2, %1 : i8 + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @negation_of_increment_via_or_disjoint(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.or %arg1, %0 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @add_via_or_with_no_common_bits_set(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.shl %3, %1 : i8 + %5 = llvm.or %4, %2 : i8 + %6 = llvm.sub %arg0, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @add_via_or_with_common_bit_maybe_set(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(4 : i8) : i8 + %3 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.shl %3, %1 : i8 + %5 = llvm.or %4, %2 : i8 + %6 = llvm.sub %arg0, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @add_via_or_with_no_common_bits_set_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.constant(3 : i8) : i8 + %3 = llvm.sub %0, %arg1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.shl %3, %1 : i8 + %5 = llvm.or %4, %2 : i8 + llvm.call @use8(%5) : (i8) -> () + %6 = llvm.sub %arg0, %5 : i8 + llvm.return %6 : i8 + } + llvm.func @negate_extractelement(%arg0: vector<2xi4>, %arg1: i32, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %2 = llvm.sub %1, %arg0 : vector<2xi4> + llvm.call @use_v2i4(%2) : (vector<2xi4>) -> () + %3 = llvm.extractelement %2[%arg1 : i32] : vector<2xi4> + %4 = llvm.sub %arg2, %3 : i4 + llvm.return %4 : i4 + } + llvm.func @negate_extractelement_extrause(%arg0: vector<2xi4>, %arg1: i32, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %2 = llvm.sub %1, %arg0 : vector<2xi4> + llvm.call @use_v2i4(%2) : (vector<2xi4>) -> () + %3 = llvm.extractelement %2[%arg1 : i32] : vector<2xi4> + llvm.call @use4(%3) : (i4) -> () + %4 = llvm.sub %arg2, %3 : i4 + llvm.return %4 : i4 + } + llvm.func @negate_insertelement(%arg0: vector<2xi4>, %arg1: i4, %arg2: i32, %arg3: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %2 = llvm.sub %1, %arg0 : vector<2xi4> + %3 = llvm.sub %0, %arg1 : i4 + %4 = llvm.insertelement %3, %2[%arg2 : i32] : vector<2xi4> + %5 = llvm.sub %arg3, %4 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @negate_insertelement_extrause(%arg0: vector<2xi4>, %arg1: i4, %arg2: i32, %arg3: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %2 = llvm.sub %1, %arg0 : vector<2xi4> + %3 = llvm.sub %0, %arg1 : i4 + %4 = llvm.insertelement %3, %2[%arg2 : i32] : vector<2xi4> + llvm.call @use_v2i4(%4) : (vector<2xi4>) -> () + %5 = llvm.sub %arg3, %4 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @negate_insertelement_nonnegatible_base(%arg0: vector<2xi4>, %arg1: i4, %arg2: i32, %arg3: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.sub %0, %arg1 : i4 + %2 = llvm.insertelement %1, %arg0[%arg2 : i32] : vector<2xi4> + %3 = llvm.sub %arg3, %2 : vector<2xi4> + llvm.return %3 : vector<2xi4> + } + llvm.func @negate_insertelement_nonnegatible_insert(%arg0: vector<2xi4>, %arg1: i4, %arg2: i32, %arg3: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %2 = llvm.sub %1, %arg0 : vector<2xi4> + %3 = llvm.insertelement %arg1, %2[%arg2 : i32] : vector<2xi4> + %4 = llvm.sub %arg3, %3 : vector<2xi4> + llvm.return %4 : vector<2xi4> + } + llvm.func @negate_left_shift_by_constant_prefer_keeping_shl(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.sub %0, %arg2 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.shl %2, %1 : i8 + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_left_shift_by_constant_prefer_keeping_shl_extrause(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.sub %0, %arg2 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.shl %2, %1 : i8 + llvm.call @use8(%3) : (i8) -> () + %4 = llvm.sub %arg0, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_left_shift_by_constant(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.sub %arg3, %arg2 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.shl %1, %0 : i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negate_left_shift_by_constant_extrause(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.sub %arg3, %arg2 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.shl %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negate_add_with_single_negatible_operand(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negate_add_with_single_negatible_operand_depth2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(21 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.mul %2, %arg1 : i8 + %4 = llvm.sub %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_add_with_single_negatible_operand_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @negate_add_with_single_negatible_operand_non_negation(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.sub %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @negate_abs(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "slt" %arg0, %0 : i8 + %3 = llvm.select %2, %1, %arg0 : i1, i8 + %4 = llvm.sub %arg1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_nabs(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "slt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %1 : i1, i8 + %4 = llvm.sub %arg1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @negate_select_of_op_vs_negated_op(%arg0: i8, %arg1: i8, %arg2: i1) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.sub %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.select %arg2, %1, %arg0 : i1, i8 + %3 = llvm.sub %arg1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @dont_negate_ordinary_select(%arg0: i8, %arg1: i8, %arg2: i8, %arg3: i1) -> i8 { + %0 = llvm.select %arg3, %arg0, %arg1 : i1, i8 + %1 = llvm.sub %arg2, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @negate_select_of_negation_poison(%arg0: vector<2xi1>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %8 = llvm.sub %6, %arg1 : vector<2xi32> + %9 = llvm.select %arg0, %8, %arg1 : vector<2xi1>, vector<2xi32> + %10 = llvm.sub %7, %9 : vector<2xi32> + llvm.return %10 : vector<2xi32> + } + llvm.func @negate_freeze(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.sub %arg0, %arg1 : i4 + %1 = llvm.freeze %0 : i4 + %2 = llvm.sub %arg2, %1 : i4 + llvm.return %2 : i4 + } + llvm.func @negate_freeze_extrause(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.sub %arg0, %arg1 : i4 + %1 = llvm.freeze %0 : i4 + llvm.call @use4(%1) : (i4) -> () + %2 = llvm.sub %arg2, %1 : i4 + llvm.return %2 : i4 + } + llvm.func @noncanonical_mul_with_constant_as_first_operand() { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(-1 : i16) : i16 + %2 = llvm.mlir.constant(0 : i32) : i32 + llvm.br ^bb1(%0 : i32) + ^bb1(%3: i32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.trunc %3 : i32 to i16 + %5 = llvm.mul %1, %4 overflow : i16 + %6 = llvm.sext %5 : i16 to i32 + %7 = llvm.sub %2, %6 overflow : i32 + llvm.br ^bb1(%7 : i32) + } + llvm.func @PR56601(%arg0: vector<1xi64>, %arg1: vector<1xi64>) -> vector<1xi64> { + %0 = llvm.mlir.constant(dense<42> : vector<1xi64>) : vector<1xi64> + %1 = llvm.mlir.constant(dense<12> : vector<1xi64>) : vector<1xi64> + %2 = llvm.mlir.constant(-4 : i64) : i64 + %3 = llvm.mlir.addressof @g : !llvm.ptr + %4 = llvm.ptrtoint %3 : !llvm.ptr to i64 + %5 = llvm.add %4, %2 : i64 + %6 = llvm.mlir.undef : vector<1xi64> + %7 = llvm.mlir.constant(0 : i32) : i32 + %8 = llvm.insertelement %5, %6[%7 : i32] : vector<1xi64> + %9 = llvm.mlir.constant(-3 : i64) : i64 + %10 = llvm.add %4, %9 : i64 + %11 = llvm.mlir.undef : vector<1xi64> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.insertelement %10, %11[%12 : i32] : vector<1xi64> + %14 = llvm.mul %arg0, %0 overflow : vector<1xi64> + %15 = llvm.mul %arg1, %1 overflow : vector<1xi64> + %16 = llvm.add %14, %8 : vector<1xi64> + %17 = llvm.add %15, %13 : vector<1xi64> + %18 = llvm.sub %16, %17 : vector<1xi64> + llvm.return %18 : vector<1xi64> + } +} diff --git a/test/LLVMDialect/InstCombine/sub-or-and-xor.ll.mlir b/test/LLVMDialect/InstCombine/sub-or-and-xor.ll.mlir index 9e055659a..a6492ff99 100644 --- a/test/LLVMDialect/InstCombine/sub-or-and-xor.ll.mlir +++ b/test/LLVMDialect/InstCombine/sub-or-and-xor.ll.mlir @@ -1,64 +1,54 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.and"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.sub"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.and"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.sub"(%0, %1) : (i32, i32) -> i32 - "llvm.call"(%2) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor_extra_use_sub", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.and"(%arg0, %arg1) : (i32, i32) -> i32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %2 = "llvm.sub"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor_extra_use_and", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %1 = "llvm.and"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.sub"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor_extra_use_or", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg1, %arg0) : (i32, i32) -> i32 - %1 = "llvm.and"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.sub"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor_or_commuted", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.and"(%arg1, %arg0) : (i32, i32) -> i32 - %2 = "llvm.sub"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor_and_commuted", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %1 = "llvm.and"(%arg1, %arg0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.sub"(%0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor_vec", type = !llvm.func (vector<2xi32>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.and"(%arg0, %arg2) : (i32, i32) -> i32 - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_xor_wrong_arg", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @sub_to_xor(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.sub %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_xor_extra_use_sub(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.sub %0, %1 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %2 : i32 + } + llvm.func @sub_to_xor_extra_use_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.sub %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_xor_extra_use_or(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.sub %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_xor_or_commuted(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg1, %arg0 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.sub %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_xor_and_commuted(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.sub %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_xor_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.or %arg0, %arg1 : vector<2xi32> + %1 = llvm.and %arg1, %arg0 : vector<2xi32> + %2 = llvm.sub %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @sub_to_xor_wrong_arg(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.and %arg0, %arg2 : i32 + %2 = llvm.sub %1, %0 : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sub-xor-cmp.ll.mlir b/test/LLVMDialect/InstCombine/sub-xor-cmp.ll.mlir new file mode 100644 index 000000000..010353f94 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sub-xor-cmp.ll.mlir @@ -0,0 +1,92 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @sext_xor_sub(%arg0: i64, %arg1: i1) -> i64 { + %0 = llvm.sext %arg1 : i1 to i64 + %1 = llvm.xor %arg0, %0 : i64 + %2 = llvm.sub %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @sext_xor_sub_1(%arg0: i64, %arg1: i1) -> i64 { + %0 = llvm.sext %arg1 : i1 to i64 + %1 = llvm.xor %0, %arg0 : i64 + %2 = llvm.sub %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @sext_xor_sub_2(%arg0: i64, %arg1: i1) -> i64 { + %0 = llvm.sext %arg1 : i1 to i64 + %1 = llvm.xor %arg0, %0 : i64 + %2 = llvm.sub %0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @sext_xor_sub_3(%arg0: i64, %arg1: i1) -> i64 { + %0 = llvm.sext %arg1 : i1 to i64 + %1 = llvm.xor %0, %arg0 : i64 + %2 = llvm.sub %0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @sext_non_bool_xor_sub(%arg0: i64, %arg1: i8) -> i64 { + %0 = llvm.sext %arg1 : i8 to i64 + %1 = llvm.xor %arg0, %0 : i64 + %2 = llvm.sub %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @sext_non_bool_xor_sub_1(%arg0: i64, %arg1: i8) -> i64 { + %0 = llvm.sext %arg1 : i8 to i64 + %1 = llvm.xor %0, %arg0 : i64 + %2 = llvm.sub %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @sext_diff_i1_xor_sub(%arg0: i64, %arg1: i1, %arg2: i1) -> i64 { + %0 = llvm.sext %arg1 : i1 to i64 + %1 = llvm.sext %arg2 : i1 to i64 + %2 = llvm.xor %arg0, %0 : i64 + %3 = llvm.sub %0, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @sext_diff_i1_xor_sub_1(%arg0: i64, %arg1: i1, %arg2: i1) -> i64 { + %0 = llvm.sext %arg1 : i1 to i64 + %1 = llvm.sext %arg2 : i1 to i64 + %2 = llvm.xor %0, %arg0 : i64 + %3 = llvm.sub %0, %1 : i64 + llvm.return %3 : i64 + } + llvm.func @sext_multi_uses(%arg0: i64, %arg1: i1, %arg2: i64) -> i64 { + %0 = llvm.sext %arg1 : i1 to i64 + %1 = llvm.xor %arg0, %0 : i64 + %2 = llvm.sub %1, %0 : i64 + %3 = llvm.mul %arg2, %0 : i64 + %4 = llvm.add %3, %2 : i64 + llvm.return %4 : i64 + } + llvm.func @xor_multi_uses(%arg0: i64, %arg1: i1, %arg2: i64) -> i64 { + %0 = llvm.sext %arg1 : i1 to i64 + %1 = llvm.xor %arg0, %0 : i64 + %2 = llvm.sub %1, %0 : i64 + %3 = llvm.mul %arg2, %1 : i64 + %4 = llvm.add %3, %2 : i64 + llvm.return %4 : i64 + } + llvm.func @absdiff(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i64 + %1 = llvm.sext %0 : i1 to i64 + %2 = llvm.sub %arg0, %arg1 : i64 + %3 = llvm.xor %1, %2 : i64 + %4 = llvm.sub %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @absdiff1(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i64 + %1 = llvm.sext %0 : i1 to i64 + %2 = llvm.sub %arg0, %arg1 : i64 + %3 = llvm.xor %2, %1 : i64 + %4 = llvm.sub %3, %1 : i64 + llvm.return %4 : i64 + } + llvm.func @absdiff2(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.icmp "ugt" %arg0, %arg1 : i64 + %1 = llvm.sext %0 : i1 to i64 + %2 = llvm.sub %arg1, %arg0 : i64 + %3 = llvm.xor %2, %1 : i64 + %4 = llvm.sub %3, %1 : i64 + llvm.return %4 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/sub-xor-or-neg-and.ll.mlir b/test/LLVMDialect/InstCombine/sub-xor-or-neg-and.ll.mlir index ff8d84130..286c09adb 100644 --- a/test/LLVMDialect/InstCombine/sub-xor-or-neg-and.ll.mlir +++ b/test/LLVMDialect/InstCombine/sub-xor-or-neg-and.ll.mlir @@ -1,66 +1,56 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.xor"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_and", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.xor"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.call"(%2) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_and_extra_use_sub", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.xor"(%arg0, %arg1) : (i32, i32) -> i32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_and_extra_use_and", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %1 = "llvm.xor"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_and_extra_use_or", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg1, %arg0) : (i32, i32) -> i32 - %1 = "llvm.xor"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_and_or_commuted", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.xor"(%arg1, %arg0) : (i32, i32) -> i32 - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_and_and_commuted", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %1 = "llvm.xor"(%arg1, %arg0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.sub"(%1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_and_vec", type = !llvm.func (vector<2xi32>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %1 = "llvm.xor"(%arg0, %arg1) : (i32, i32) -> i32 - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %2 = "llvm.sub"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "sub_to_and_extra_use_and_or", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @sub_to_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.xor %arg0, %arg1 : i32 + %2 = llvm.sub %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_and_extra_use_sub(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.xor %arg0, %arg1 : i32 + %2 = llvm.sub %1, %0 : i32 + llvm.call @use(%2) : (i32) -> () + llvm.return %2 : i32 + } + llvm.func @sub_to_and_extra_use_and(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.xor %arg0, %arg1 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.sub %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_and_extra_use_or(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.xor %arg0, %arg1 : i32 + %2 = llvm.sub %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_and_or_commuted(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg1, %arg0 : i32 + %1 = llvm.xor %arg0, %arg1 : i32 + %2 = llvm.sub %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_and_and_commuted(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.sub %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @sub_to_and_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.or %arg0, %arg1 : vector<2xi32> + %1 = llvm.xor %arg1, %arg0 : vector<2xi32> + %2 = llvm.sub %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @sub_to_and_extra_use_and_or(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + llvm.call @use(%0) : (i32) -> () + %1 = llvm.xor %arg0, %arg1 : i32 + llvm.call @use(%1) : (i32) -> () + %2 = llvm.sub %1, %0 : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sub-xor.ll.mlir b/test/LLVMDialect/InstCombine/sub-xor.ll.mlir new file mode 100644 index 000000000..4b86b3362 --- /dev/null +++ b/test/LLVMDialect/InstCombine/sub-xor.ll.mlir @@ -0,0 +1,119 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @low_mask_nsw_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(63 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.sub %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @low_mask_nsw_nuw_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<31> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<63> : vector<2xi32>) : vector<2xi32> + %2 = llvm.and %arg0, %0 : vector<2xi32> + %3 = llvm.sub %1, %2 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @arbitrary_mask_sub_i8(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @arbitrary_mask_sub_high_bit_dont_care_i8(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-93 : i8) : i8 + %1 = llvm.mlir.constant(39 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @arbitrary_mask_sub_nsw_high_bit_dont_care_i8(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-93 : i8) : i8 + %1 = llvm.mlir.constant(39 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.sub %1, %2 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @arbitrary_mask_sub_nuw_high_bit_dont_care_i8(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-93 : i8) : i8 + %1 = llvm.mlir.constant(39 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.sub %1, %2 overflow : i8 + llvm.return %3 : i8 + } + llvm.func @arbitrary_mask_sub_v2i5(%arg0: vector<2xi5>) -> vector<2xi5> { + %0 = llvm.mlir.constant(-8 : i5) : i5 + %1 = llvm.mlir.constant(dense<-8> : vector<2xi5>) : vector<2xi5> + %2 = llvm.mlir.constant(-6 : i5) : i5 + %3 = llvm.mlir.constant(dense<-6> : vector<2xi5>) : vector<2xi5> + %4 = llvm.and %arg0, %1 : vector<2xi5> + %5 = llvm.sub %3, %4 : vector<2xi5> + llvm.return %5 : vector<2xi5> + } + llvm.func @not_masked_sub_i8(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.sub %1, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @range_masked_sub(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = "llvm.intr.ctlz"(%arg0) <{is_zero_poison = true}> : (i32) -> i32 + %2 = llvm.sub %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_add(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @xor_add_extra_use(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(42 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.xor %2, %0 : i32 + llvm.call @use(%3) : (i32) -> () + %4 = llvm.add %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @xor_add_splat(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<24> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<63> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %3 = llvm.and %arg0, %0 : vector<2xi8> + %4 = llvm.xor %3, %1 : vector<2xi8> + %5 = llvm.add %4, %2 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @xor_add_splat_undef(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<24> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.undef : i8 + %2 = llvm.mlir.constant(63 : i8) : i8 + %3 = llvm.mlir.undef : vector<2xi8> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi8> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<2xi8> + %8 = llvm.mlir.constant(dense<42> : vector<2xi8>) : vector<2xi8> + %9 = llvm.and %arg0, %0 : vector<2xi8> + %10 = llvm.xor %9, %7 : vector<2xi8> + %11 = llvm.add %10, %8 : vector<2xi8> + llvm.return %11 : vector<2xi8> + } + llvm.func @xor_dominating_cond(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(256 : i32) : i32 + %1 = llvm.mlir.constant(255 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.sub %1, %arg0 : i32 + llvm.return %3 : i32 + ^bb2: // pred: ^bb0 + llvm.return %arg0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/sub.ll.mlir b/test/LLVMDialect/InstCombine/sub.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/subtract-from-one-hand-of-select.ll.mlir b/test/LLVMDialect/InstCombine/subtract-from-one-hand-of-select.ll.mlir new file mode 100644 index 000000000..33a10f579 --- /dev/null +++ b/test/LLVMDialect/InstCombine/subtract-from-one-hand-of-select.ll.mlir @@ -0,0 +1,29 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_sub_from_trueval(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, i8 + %1 = llvm.sub %arg1, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @t1_sub_from_falseval(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, i8 + %1 = llvm.sub %arg2, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @t2_vec(%arg0: i1, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, vector<2xi8> + %1 = llvm.sub %arg1, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @use8(i8) + llvm.func @n3_extrause(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sub %arg1, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @n4_wrong_hands(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, i8 + %1 = llvm.sub %arg3, %0 : i8 + llvm.return %1 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/subtract-of-one-hand-of-select.ll.mlir b/test/LLVMDialect/InstCombine/subtract-of-one-hand-of-select.ll.mlir new file mode 100644 index 000000000..481af9adb --- /dev/null +++ b/test/LLVMDialect/InstCombine/subtract-of-one-hand-of-select.ll.mlir @@ -0,0 +1,29 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_sub_of_trueval(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, i8 + %1 = llvm.sub %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @t1_sub_of_falseval(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, i8 + %1 = llvm.sub %0, %arg2 : i8 + llvm.return %1 : i8 + } + llvm.func @t2_vec(%arg0: i1, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, vector<2xi8> + %1 = llvm.sub %0, %arg1 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @use8(i8) + llvm.func @n3_extrause(%arg0: i1, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.sub %0, %arg1 : i8 + llvm.return %1 : i8 + } + llvm.func @n4_wrong_hands(%arg0: i1, %arg1: i8, %arg2: i8, %arg3: i8) -> i8 { + %0 = llvm.select %arg0, %arg1, %arg2 : i1, i8 + %1 = llvm.sub %0, %arg3 : i8 + llvm.return %1 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/swifterror-argument-bitcast-fold.ll.mlir b/test/LLVMDialect/InstCombine/swifterror-argument-bitcast-fold.ll.mlir index e00da11ab..0f0c3c913 100644 --- a/test/LLVMDialect/InstCombine/swifterror-argument-bitcast-fold.ll.mlir +++ b/test/LLVMDialect/InstCombine/swifterror-argument-bitcast-fold.ll.mlir @@ -1,12 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @widget} : () -> !llvm.ptr>)>> - %1 = "llvm.bitcast"(%0) : (!llvm.ptr>)>>) -> !llvm.ptr>)>> - "llvm.call"(%1, %arg0) : (!llvm.ptr>)>>, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "spam", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "widget", type = !llvm.func>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func swiftcc @spam(%arg0: !llvm.ptr) { + llvm.call swiftcc @widget(%arg0) : (!llvm.ptr) -> () + llvm.return + } + llvm.func swiftcc @widget(!llvm.ptr) +} diff --git a/test/LLVMDialect/InstCombine/switch-constant-expr.ll.mlir b/test/LLVMDialect/InstCombine/switch-constant-expr.ll.mlir new file mode 100644 index 000000000..70f3cc0c9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/switch-constant-expr.ll.mlir @@ -0,0 +1,33 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g(0 : i32) {addr_space = 0 : i32} : i32 + llvm.func @single_case() -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @g : !llvm.ptr + %3 = llvm.ptrtoint %2 : !llvm.ptr to i32 + %4 = llvm.add %3, %0 : i32 + llvm.switch %4 : i32, ^bb1 [ + ] + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + } + llvm.func @multiple_cases() -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.addressof @g : !llvm.ptr + %3 = llvm.ptrtoint %2 : !llvm.ptr to i32 + %4 = llvm.add %3, %0 : i32 + %5 = llvm.mlir.constant(2 : i32) : i32 + %6 = llvm.mlir.constant(1 : i32) : i32 + llvm.switch %4 : i32, ^bb1 [ + 1: ^bb2, + 2: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.return %1 : i32 + ^bb2: // pred: ^bb0 + llvm.return %6 : i32 + ^bb3: // pred: ^bb0 + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/switch-select.ll.mlir b/test/LLVMDialect/InstCombine/switch-select.ll.mlir new file mode 100644 index 000000000..364ec65b6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/switch-select.ll.mlir @@ -0,0 +1,89 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_ult_rhsc(%arg0: i8) { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.mlir.constant(6 : i8) : i8 + %3 = llvm.add %arg0, %0 overflow : i8 + %4 = llvm.icmp "ult" %3, %1 : i8 + %5 = llvm.select %4, %3, %2 : i1, i8 + llvm.switch %5 : i8, ^bb1 [ + 0: ^bb2, + 10: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.call @func1() : () -> () + llvm.unreachable + ^bb2: // pred: ^bb0 + llvm.call @func2() : () -> () + llvm.unreachable + ^bb3: // pred: ^bb0 + llvm.call @func3() : () -> () + llvm.unreachable + } + llvm.func @test_eq_lhsc(%arg0: i8) { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.select %2, %1, %arg0 : i1, i8 + llvm.switch %3 : i8, ^bb1 [ + 0: ^bb2, + 10: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.call @func1() : () -> () + llvm.unreachable + ^bb2: // pred: ^bb0 + llvm.call @func2() : () -> () + llvm.unreachable + ^bb3: // pred: ^bb0 + llvm.call @func3() : () -> () + llvm.unreachable + } + llvm.func @test_ult_rhsc_invalid_cond(%arg0: i8, %arg1: i8) { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.mlir.constant(6 : i8) : i8 + %3 = llvm.add %arg0, %0 overflow : i8 + %4 = llvm.icmp "ult" %arg1, %1 : i8 + %5 = llvm.select %4, %3, %2 : i1, i8 + llvm.switch %5 : i8, ^bb1 [ + 0: ^bb2, + 10: ^bb3, + 13: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.call @func1() : () -> () + llvm.unreachable + ^bb2: // pred: ^bb0 + llvm.call @func2() : () -> () + llvm.unreachable + ^bb3: // 2 preds: ^bb0, ^bb0 + llvm.call @func3() : () -> () + llvm.unreachable + } + llvm.func @test_ult_rhsc_fail(%arg0: i8) { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.mlir.constant(11 : i8) : i8 + %2 = llvm.mlir.constant(6 : i8) : i8 + %3 = llvm.add %arg0, %0 overflow : i8 + %4 = llvm.icmp "ult" %3, %1 : i8 + %5 = llvm.select %4, %3, %2 : i1, i8 + llvm.switch %5 : i8, ^bb1 [ + 0: ^bb2, + 10: ^bb3, + 13: ^bb3 + ] + ^bb1: // pred: ^bb0 + llvm.call @func1() : () -> () + llvm.unreachable + ^bb2: // pred: ^bb0 + llvm.call @func2() : () -> () + llvm.unreachable + ^bb3: // 2 preds: ^bb0, ^bb0 + llvm.call @func3() : () -> () + llvm.unreachable + } + llvm.func @func1() + llvm.func @func2() + llvm.func @func3() +} diff --git a/test/LLVMDialect/InstCombine/switch-shl.ll.mlir b/test/LLVMDialect/InstCombine/switch-shl.ll.mlir new file mode 100644 index 000000000..393faba69 --- /dev/null +++ b/test/LLVMDialect/InstCombine/switch-shl.ll.mlir @@ -0,0 +1,95 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_switch_with_shl_mask(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.shl %arg0, %0 : i32 + llvm.switch %3 : i32, ^bb2 [ + 0: ^bb1, + 16777216: ^bb1, + 2147483648: ^bb1 + ] + ^bb1: // 3 preds: ^bb0, ^bb0, ^bb0 + llvm.return %1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %2 : i1 + } + llvm.func @test_switch_with_shl_nuw_multiuse(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.shl %arg0, %0 overflow : i32 + llvm.call @use(%3) : (i32) -> () + llvm.switch %3 : i32, ^bb2 [ + 0: ^bb1, + 16777216: ^bb1, + 2147483648: ^bb1 + ] + ^bb1: // 3 preds: ^bb0, ^bb0, ^bb0 + llvm.return %1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %2 : i1 + } + llvm.func @test_switch_with_shl_nsw_multiuse(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.shl %arg0, %0 overflow : i32 + llvm.call @use(%3) : (i32) -> () + llvm.switch %3 : i32, ^bb2 [ + 0: ^bb1, + 16777216: ^bb1, + 2147483648: ^bb1 + ] + ^bb1: // 3 preds: ^bb0, ^bb0, ^bb0 + llvm.return %1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %2 : i1 + } + llvm.func @test_switch_with_shl_mask_multiuse(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(24 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.shl %arg0, %0 : i32 + llvm.call @use(%3) : (i32) -> () + llvm.switch %3 : i32, ^bb2 [ + 0: ^bb1, + 16777216: ^bb1, + 2147483648: ^bb1 + ] + ^bb1: // 3 preds: ^bb0, ^bb0, ^bb0 + llvm.return %1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %2 : i1 + } + llvm.func @test_switch_with_shl_mask_unknown_shamt(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.shl %arg0, %arg1 : i32 + llvm.switch %2 : i32, ^bb2 [ + 0: ^bb1, + 16777216: ^bb1, + 2147483648: ^bb1 + ] + ^bb1: // 3 preds: ^bb0, ^bb0, ^bb0 + llvm.return %0 : i1 + ^bb2: // pred: ^bb0 + llvm.return %1 : i1 + } + llvm.func @test_switch_with_shl_mask_poison(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.shl %arg0, %0 : i32 + llvm.switch %3 : i32, ^bb2 [ + 0: ^bb1, + 16777216: ^bb1, + 2147483648: ^bb1 + ] + ^bb1: // 3 preds: ^bb0, ^bb0, ^bb0 + llvm.return %1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %2 : i1 + } + llvm.func @use(i32) +} diff --git a/test/LLVMDialect/InstCombine/switch-sub.ll.mlir b/test/LLVMDialect/InstCombine/switch-sub.ll.mlir new file mode 100644 index 000000000..6ef2cf35b --- /dev/null +++ b/test/LLVMDialect/InstCombine/switch-sub.ll.mlir @@ -0,0 +1,46 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_switch_with_neg(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.sub %0, %arg0 : i32 + llvm.switch %3 : i32, ^bb2 [ + 37: ^bb1, + 38: ^bb1, + 39: ^bb1 + ] + ^bb1: // 3 preds: ^bb0, ^bb0, ^bb0 + llvm.return %1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %2 : i1 + } + llvm.func @test_switch_with_sub(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(37 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.sub %0, %arg0 : i32 + llvm.switch %3 : i32, ^bb2 [ + 37: ^bb1, + 38: ^bb1, + 39: ^bb1 + ] + ^bb1: // 3 preds: ^bb0, ^bb0, ^bb0 + llvm.return %1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %2 : i1 + } + llvm.func @test_switch_with_sub_nonconst(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.sub %arg1, %arg0 : i32 + llvm.switch %2 : i32, ^bb2 [ + 37: ^bb1, + 38: ^bb1, + 39: ^bb1 + ] + ^bb1: // 3 preds: ^bb0, ^bb0, ^bb0 + llvm.return %0 : i1 + ^bb2: // pred: ^bb0 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/switch-truncate-crash.ll.mlir b/test/LLVMDialect/InstCombine/switch-truncate-crash.ll.mlir new file mode 100644 index 000000000..c342ccaff --- /dev/null +++ b/test/LLVMDialect/InstCombine/switch-truncate-crash.ll.mlir @@ -0,0 +1,10 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test() { + %0 = llvm.mlir.constant(0 : i32) : i32 + llvm.switch %0 : i32, ^bb1 [ + 0: ^bb1 + ] + ^bb1: // 2 preds: ^bb0, ^bb0 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/switch-zext-sext.ll.mlir b/test/LLVMDialect/InstCombine/switch-zext-sext.ll.mlir new file mode 100644 index 000000000..e4bdb4922 --- /dev/null +++ b/test/LLVMDialect/InstCombine/switch-zext-sext.ll.mlir @@ -0,0 +1,52 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_switch_with_zext(%arg0: i16, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.zext %arg0 : i16 to i32 + llvm.switch %0 : i32, ^bb2 [ + 37: ^bb1, + 38: ^bb1, + 39: ^bb1 + ] + ^bb1: // 3 preds: ^bb0, ^bb0, ^bb0 + llvm.return %arg1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg2 : i1 + } + llvm.func @test_switch_with_sext(%arg0: i16, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.sext %arg0 : i16 to i32 + llvm.switch %0 : i32, ^bb2 [ + 37: ^bb1, + 38: ^bb1, + 39: ^bb1 + ] + ^bb1: // 3 preds: ^bb0, ^bb0, ^bb0 + llvm.return %arg1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg2 : i1 + } + llvm.func @test_switch_with_zext_unreachable_case(%arg0: i16, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.zext %arg0 : i16 to i32 + llvm.switch %0 : i32, ^bb2 [ + 37: ^bb1, + 38: ^bb1, + 39: ^bb1, + 65537: ^bb1 + ] + ^bb1: // 4 preds: ^bb0, ^bb0, ^bb0, ^bb0 + llvm.return %arg1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg2 : i1 + } + llvm.func @test_switch_with_sext_unreachable_case(%arg0: i16, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.sext %arg0 : i16 to i32 + llvm.switch %0 : i32, ^bb2 [ + 37: ^bb1, + 38: ^bb1, + 39: ^bb1, + 4294901759: ^bb1 + ] + ^bb1: // 4 preds: ^bb0, ^bb0, ^bb0, ^bb0 + llvm.return %arg1 : i1 + ^bb2: // pred: ^bb0 + llvm.return %arg2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/tan-nofastmath.ll.mlir b/test/LLVMDialect/InstCombine/tan-nofastmath.ll.mlir deleted file mode 100644 index 2391884b4..000000000 --- a/test/LLVMDialect/InstCombine/tan-nofastmath.ll.mlir +++ /dev/null @@ -1,13 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @atanf, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %1 = "llvm.call"(%0) {callee = @tanf, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "mytan", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "tanf", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atanf", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/tan.ll.mlir b/test/LLVMDialect/InstCombine/tan.ll.mlir deleted file mode 100644 index 892faa4a1..000000000 --- a/test/LLVMDialect/InstCombine/tan.ll.mlir +++ /dev/null @@ -1,19 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @atanf, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - %1 = "llvm.call"(%0) {callee = @tanf, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "mytan", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr>): // no predecessors - %0 = "llvm.call"(%arg0) : (!llvm.ptr>) -> f32 - %1 = "llvm.call"(%0) {callee = @tanf, fastmathFlags = #llvm.fastmath<>} : (f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "tanf", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atanf", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/tbaa-store-to-load.ll.mlir b/test/LLVMDialect/InstCombine/tbaa-store-to-load.ll.mlir index 9b4edaf1f..8e24e3ae3 100644 --- a/test/LLVMDialect/InstCombine/tbaa-store-to-load.ll.mlir +++ b/test/LLVMDialect/InstCombine/tbaa-store-to-load.ll.mlir @@ -1,10 +1,11 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i64 - "llvm.store"(%0, %arg1) : (i64, !llvm.ptr) -> () - %1 = "llvm.load"(%arg1) : (!llvm.ptr) -> i64 - "llvm.return"(%1) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +#tbaa_root = #llvm.tbaa_root +#tbaa_type_desc = #llvm.tbaa_type_desc}> +#tbaa_tag = #llvm.tbaa_tag +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i64 { + %0 = llvm.load %arg0 {alignment = 8 : i64, tbaa = [#tbaa_tag]} : !llvm.ptr -> i64 + llvm.store %0, %arg1 {alignment = 8 : i64} : i64, !llvm.ptr + %1 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> i64 + llvm.return %1 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/threadlocal_address.ll.mlir b/test/LLVMDialect/InstCombine/threadlocal_address.ll.mlir new file mode 100644 index 000000000..9ee6d1f45 --- /dev/null +++ b/test/LLVMDialect/InstCombine/threadlocal_address.ll.mlir @@ -0,0 +1,35 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external thread_local @tlsvar_a4(4 : i32) {addr_space = 0 : i32, alignment = 4 : i64} : i32 + llvm.mlir.global external thread_local @tlsvar_a32(5 : i32) {addr_space = 0 : i32, alignment = 32 : i64} : i32 + llvm.mlir.global external thread_local @tlsvar_a1(6 : i8) {addr_space = 0 : i32, alignment = 1 : i64} : i8 + llvm.func @func_increase_alignment() { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.addressof @tlsvar_a4 : !llvm.ptr + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = "llvm.intr.threadlocal.address"(%1) : (!llvm.ptr) -> !llvm.ptr + llvm.store %2, %3 {alignment = 2 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @func_add_alignment() -> i1 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.addressof @tlsvar_a32 : !llvm.ptr + %2 = llvm.mlir.constant(31 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = "llvm.intr.threadlocal.address"(%1) : (!llvm.ptr) -> !llvm.ptr + %5 = llvm.ptrtoint %4 : !llvm.ptr to i32 + %6 = llvm.and %5, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + llvm.return %7 : i1 + } + llvm.func @func_dont_reduce_alignment() -> i1 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.addressof @tlsvar_a1 : !llvm.ptr + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = "llvm.intr.threadlocal.address"(%1) : (!llvm.ptr) -> !llvm.ptr + %5 = llvm.ptrtoint %4 : !llvm.ptr to i32 + %6 = llvm.and %5, %2 : i32 + %7 = llvm.icmp "eq" %6, %3 : i32 + llvm.return %7 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/tmp-alloca-bypass.ll.mlir b/test/LLVMDialect/InstCombine/tmp-alloca-bypass.ll.mlir new file mode 100644 index 000000000..d7d811b12 --- /dev/null +++ b/test/LLVMDialect/InstCombine/tmp-alloca-bypass.ll.mlir @@ -0,0 +1,33 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @g0() {addr_space = 0 : i32} : !llvm.struct<"t0", (ptr, i64)> + llvm.mlir.global external constant @g1() {addr_space = 0 : i32} : !llvm.struct<"t0", (ptr, i64)> + llvm.func @test(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.addressof @g0 : !llvm.ptr + %2 = llvm.mlir.addressof @g1 : !llvm.ptr + %3 = llvm.mlir.constant(16 : i64) : i64 + %4 = llvm.alloca %0 x !llvm.struct<"t0", (ptr, i64)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %5 = llvm.call @get_cond() : () -> i1 + %6 = llvm.select %5, %1, %2 : i1, !llvm.ptr + "llvm.intr.memcpy"(%4, %6, %3) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + "llvm.intr.memcpy"(%arg0, %4, %3) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + llvm.return + } + llvm.func @test2() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.ptr + %2 = llvm.mlir.constant(2503 : i32) : i32 + %3 = llvm.mlir.addressof @g0 : !llvm.ptr + %4 = llvm.mlir.addressof @g1 : !llvm.ptr + %5 = llvm.mlir.constant(16 : i64) : i64 + %6 = llvm.alloca %0 x !llvm.struct<"t0", (ptr, i64)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %7 = llvm.call @func(%1) : (!llvm.ptr) -> i32 + %8 = llvm.icmp "eq" %7, %2 : i32 + %9 = llvm.select %8, %3, %4 : i1, !llvm.ptr + "llvm.intr.memcpy"(%6, %9, %5) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i64) -> () + %10 = llvm.call @func(%6) : (!llvm.ptr) -> i32 + llvm.unreachable + } + llvm.func @func(!llvm.ptr) -> i32 + llvm.func @get_cond() -> i1 +} diff --git a/test/LLVMDialect/InstCombine/toascii-1.ll.mlir b/test/LLVMDialect/InstCombine/toascii-1.ll.mlir index 586cf125d..06fdb59db 100644 --- a/test/LLVMDialect/InstCombine/toascii-1.ll.mlir +++ b/test/LLVMDialect/InstCombine/toascii-1.ll.mlir @@ -1,40 +1,37 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "toascii", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @toascii, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify1", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @toascii, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify2", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 127 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @toascii, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify3", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 128 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @toascii, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify4", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 255 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @toascii, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify5", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 256 : i32} : () -> i32 - %1 = "llvm.call"(%0) {callee = @toascii, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @toascii, fastmathFlags = #llvm.fastmath<>} : (i32) -> i32 - "llvm.return"(%0) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_simplify7", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @toascii(i32) -> i32 + llvm.func @test_simplify1() -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.call @toascii(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify2() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.call @toascii(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify3() -> i32 { + %0 = llvm.mlir.constant(127 : i32) : i32 + %1 = llvm.call @toascii(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify4() -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.call @toascii(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify5() -> i32 { + %0 = llvm.mlir.constant(255 : i32) : i32 + %1 = llvm.call @toascii(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify6() -> i32 { + %0 = llvm.mlir.constant(256 : i32) : i32 + %1 = llvm.call @toascii(%0) : (i32) -> i32 + llvm.return %1 : i32 + } + llvm.func @test_simplify7(%arg0: i32) -> i32 { + %0 = llvm.call @toascii(%arg0) : (i32) -> i32 + llvm.return %0 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/token.ll.mlir b/test/LLVMDialect/InstCombine/token.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/trig.ll.mlir b/test/LLVMDialect/InstCombine/trig.ll.mlir new file mode 100644 index 000000000..6a32dd827 --- /dev/null +++ b/test/LLVMDialect/InstCombine/trig.ll.mlir @@ -0,0 +1,65 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @tanAtanInverseFast(%arg0: f32) -> f32 { + %0 = llvm.call @atanf(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %1 = llvm.call @tanf(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @atanhTanhInverseFast(%arg0: f32) -> f32 { + %0 = llvm.call @tanhf(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %1 = llvm.call @atanhf(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @sinhAsinhInverseFast(%arg0: f32) -> f32 { + %0 = llvm.call @asinhf(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %1 = llvm.call @sinhf(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @asinhSinhInverseFast(%arg0: f32) -> f32 { + %0 = llvm.call @sinhf(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %1 = llvm.call @asinhf(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @coshAcoshInverseFast(%arg0: f32) -> f32 { + %0 = llvm.call @acoshf(%arg0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + %1 = llvm.call @coshf(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @indirectTanCall(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.call %arg0() {fastmathFlags = #llvm.fastmath} : !llvm.ptr, () -> f32 + %1 = llvm.call @tanf(%0) {fastmathFlags = #llvm.fastmath} : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @tanAtanInverse(%arg0: f32) -> f32 { + %0 = llvm.call @atanf(%arg0) : (f32) -> f32 + %1 = llvm.call @tanf(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @atanhTanhInverse(%arg0: f32) -> f32 { + %0 = llvm.call @tanhf(%arg0) : (f32) -> f32 + %1 = llvm.call @atanhf(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @sinhAsinhInverse(%arg0: f32) -> f32 { + %0 = llvm.call @asinhf(%arg0) : (f32) -> f32 + %1 = llvm.call @sinhf(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @asinhSinhInverse(%arg0: f32) -> f32 { + %0 = llvm.call @sinhf(%arg0) : (f32) -> f32 + %1 = llvm.call @asinhf(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @coshAcoshInverse(%arg0: f32) -> f32 { + %0 = llvm.call @acoshf(%arg0) : (f32) -> f32 + %1 = llvm.call @coshf(%0) : (f32) -> f32 + llvm.return %1 : f32 + } + llvm.func @asinhf(f32) -> f32 + llvm.func @sinhf(f32) -> f32 + llvm.func @acoshf(f32) -> f32 + llvm.func @coshf(f32) -> f32 + llvm.func @tanhf(f32) -> f32 + llvm.func @atanhf(f32) -> f32 + llvm.func @tanf(f32) -> f32 + llvm.func @atanf(f32) -> f32 +} diff --git a/test/LLVMDialect/InstCombine/trivial-dse-calls.ll.mlir b/test/LLVMDialect/InstCombine/trivial-dse-calls.ll.mlir index a39e3a053..cdfdc15f6 100644 --- a/test/LLVMDialect/InstCombine/trivial-dse-calls.ll.mlir +++ b/test/LLVMDialect/InstCombine/trivial-dse-calls.ll.mlir @@ -1,169 +1,133 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.lifetime.start.p0i8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.lifetime.end.p0i8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "unknown", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "f2", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "f3", type = !llvm.func (ptr, ptr)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%2) {callee = @f, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_dead", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - %3 = "llvm.bitcast"(%2) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%0, %3) {callee = @llvm.lifetime.start.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.call"(%3) {callee = @f, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.call"(%0, %3) {callee = @llvm.lifetime.end.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_lifetime", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 4 : i64} : () -> i64 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.alloca"(%1) : (i32) -> !llvm.ptr - %3 = "llvm.bitcast"(%2) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%0, %3) {callee = @llvm.lifetime.start.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.call"() {callee = @unknown, fastmathFlags = #llvm.fastmath<>} : () -> () - "llvm.call"(%3) {callee = @f, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.call"() {callee = @unknown, fastmathFlags = #llvm.fastmath<>} : () -> () - "llvm.call"(%0, %3) {callee = @llvm.lifetime.end.p0i8, fastmathFlags = #llvm.fastmath<>} : (i64, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_lifetime2", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%2) {callee = @f, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_dead_readwrite", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%2) {callee = @f, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - %3 = "llvm.load"(%1) : (!llvm.ptr) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_neg_read_after", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%2) {callee = @f, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_neg_infinite_loop", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%2) {callee = @f, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_neg_throw", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%2) {callee = @f, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_neg_extra_write", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %3 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - %4 = "llvm.bitcast"(%2) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%3, %4) {callee = @f2, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_neg_unmodeled_write", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr> - %3 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - %4 = "llvm.bitcast"(%2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.call"(%3, %4) {callee = @f2, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - %5 = "llvm.load"(%2) : (!llvm.ptr>) -> !llvm.ptr - %6 = "llvm.bitcast"(%5) : (!llvm.ptr) -> !llvm.ptr - %7 = "llvm.load"(%6) : (!llvm.ptr) -> i32 - "llvm.return"(%7) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_neg_captured_by_call", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr> - %3 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - %4 = "llvm.bitcast"(%2) : (!llvm.ptr>) -> !llvm.ptr - "llvm.store"(%3, %2) : (!llvm.ptr, !llvm.ptr>) -> () - "llvm.call"(%3) {callee = @f, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> () - %5 = "llvm.load"(%2) : (!llvm.ptr>) -> !llvm.ptr - %6 = "llvm.bitcast"(%5) : (!llvm.ptr) -> !llvm.ptr - %7 = "llvm.load"(%6) : (!llvm.ptr) -> i32 - "llvm.return"(%7) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test_neg_captured_before", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %3 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - %4 = "llvm.bitcast"(%2) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%3, %4) {callee = @f2, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_unreleated_read", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %3 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - %4 = "llvm.bitcast"(%2) : (!llvm.ptr) -> !llvm.ptr - %5 = "llvm.call"(%3, %4) {callee = @f3, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_unrelated_capture", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %3 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - %4 = "llvm.bitcast"(%2) : (!llvm.ptr) -> !llvm.ptr - %5 = "llvm.call"(%3, %4) {callee = @f3, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr - %6 = "llvm.load"(%5) : (!llvm.ptr) -> i8 - "llvm.return"(%6) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "test_neg_unrelated_capture_used_via_return", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr - %2 = "llvm.bitcast"(%1) : (!llvm.ptr) -> !llvm.ptr - "llvm.call"(%2, %2) {callee = @f2, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_self_read", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "removable_readnone", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "removable_ro", type = !llvm.func} : () -> () - "llvm.func"() ( { - "llvm.call"() {callee = @removable_readnone, fastmathFlags = #llvm.fastmath<>} : () -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_readnone", type = !llvm.func} : () -> () - "llvm.func"() ( { - "llvm.call"() {callee = @removable_readnone, fastmathFlags = #llvm.fastmath<>} : () -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_readnone_with_deopt", type = !llvm.func} : () -> () - "llvm.func"() ( { - "llvm.call"() {callee = @removable_ro, fastmathFlags = #llvm.fastmath<>} : () -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_readonly", type = !llvm.func} : () -> () - "llvm.func"() ( { - "llvm.call"() {callee = @removable_ro, fastmathFlags = #llvm.fastmath<>} : () -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "test_readonly_with_deopt", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @unknown() + llvm.func @f(!llvm.ptr) + llvm.func @f2(!llvm.ptr, !llvm.ptr) + llvm.func @f3(!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.func @test_dead() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @f(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test_lifetime() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 4, %1 : !llvm.ptr + llvm.call @f(%1) : (!llvm.ptr) -> () + llvm.intr.lifetime.end 4, %1 : !llvm.ptr + llvm.return + } + llvm.func @test_lifetime2() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 4, %1 : !llvm.ptr + llvm.call @unknown() : () -> () + llvm.call @f(%1) : (!llvm.ptr) -> () + llvm.call @unknown() : () -> () + llvm.intr.lifetime.end 4, %1 : !llvm.ptr + llvm.return + } + llvm.func @test_dead_readwrite() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @f(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test_neg_read_after() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @f(%1) : (!llvm.ptr) -> () + %2 = llvm.load %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %2 : i32 + } + llvm.func @test_neg_infinite_loop() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @f(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test_neg_throw() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @f(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test_neg_extra_write() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @f(%1) : (!llvm.ptr) -> () + llvm.return + } + llvm.func @test_neg_unmodeled_write() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @f2(%1, %2) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @test_neg_captured_by_call() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %2 = llvm.alloca %0 x !llvm.ptr {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @f2(%1, %2) : (!llvm.ptr, !llvm.ptr) -> () + %3 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %4 : i32 + } + llvm.func @test_neg_captured_before() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %2 = llvm.alloca %0 x !llvm.ptr {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.store %1, %2 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr + llvm.call @f(%1) : (!llvm.ptr) -> () + %3 = llvm.load %2 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %4 : i32 + } + llvm.func @test_unreleated_read() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @f2(%1, %2) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @test_unrelated_capture() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %3 = llvm.call @f3(%1, %2) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + llvm.return + } + llvm.func @test_neg_unrelated_capture_used_via_return() -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + %3 = llvm.call @f3(%1, %2) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + %4 = llvm.load %3 {alignment = 1 : i64} : !llvm.ptr -> i8 + llvm.return %4 : i8 + } + llvm.func @test_self_read() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr + llvm.call @f2(%1, %1) : (!llvm.ptr, !llvm.ptr) -> () + llvm.return + } + llvm.func @removable_readnone() attributes {memory = #llvm.memory_effects, passthrough = ["nounwind", "willreturn"]} + llvm.func @removable_ro() attributes {memory = #llvm.memory_effects, passthrough = ["nounwind", "willreturn"]} + llvm.func @test_readnone() { + llvm.call @removable_readnone() : () -> () + llvm.return + } + llvm.func @test_readnone_with_deopt() { + llvm.call @removable_readnone() : () -> () + llvm.return + } + llvm.func @test_readonly() { + llvm.call @removable_ro() : () -> () + llvm.return + } + llvm.func @test_readonly_with_deopt() { + llvm.call @removable_ro() : () -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/trunc-binop-ext.ll.mlir b/test/LLVMDialect/InstCombine/trunc-binop-ext.ll.mlir index 644468341..c1e9f658d 100644 --- a/test/LLVMDialect/InstCombine/trunc-binop-ext.ll.mlir +++ b/test/LLVMDialect/InstCombine/trunc-binop-ext.ll.mlir @@ -1,245 +1,215 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.sext"(%arg0) : (i16) -> i32 - %1 = "llvm.and"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i16 - "llvm.return"(%2) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "narrow_sext_and", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.zext"(%arg0) : (i16) -> i32 - %1 = "llvm.and"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i16 - "llvm.return"(%2) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_and", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.sext"(%arg0) : (i16) -> i32 - %1 = "llvm.or"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i16 - "llvm.return"(%2) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "narrow_sext_or", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.zext"(%arg0) : (i16) -> i32 - %1 = "llvm.or"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i16 - "llvm.return"(%2) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_or", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.sext"(%arg0) : (i16) -> i32 - %1 = "llvm.xor"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i16 - "llvm.return"(%2) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "narrow_sext_xor", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.zext"(%arg0) : (i16) -> i32 - %1 = "llvm.xor"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i16 - "llvm.return"(%2) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_xor", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.sext"(%arg0) : (i16) -> i32 - %1 = "llvm.add"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i16 - "llvm.return"(%2) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "narrow_sext_add", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.zext"(%arg0) : (i16) -> i32 - %1 = "llvm.add"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i16 - "llvm.return"(%2) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_add", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.sext"(%arg0) : (i16) -> i32 - %1 = "llvm.sub"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i16 - "llvm.return"(%2) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "narrow_sext_sub", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.zext"(%arg0) : (i16) -> i32 - %1 = "llvm.sub"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i16 - "llvm.return"(%2) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_sub", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.sext"(%arg0) : (i16) -> i32 - %1 = "llvm.mul"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i16 - "llvm.return"(%2) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "narrow_sext_mul", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16, %arg1: i32): // no predecessors - %0 = "llvm.zext"(%arg0) : (i16) -> i32 - %1 = "llvm.mul"(%0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.trunc"(%1) : (i32) -> i16 - "llvm.return"(%2) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_mul", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[7, -17]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sdiv"(%arg1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.sext"(%arg0) : (vector<2xi16>) -> vector<2xi32> - %3 = "llvm.and"(%1, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.trunc"(%3) : (vector<2xi32>) -> vector<2xi16> - "llvm.return"(%4) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "narrow_sext_and_commute", type = !llvm.func (vector<2xi16>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[7, -17]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sdiv"(%arg1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.zext"(%arg0) : (vector<2xi16>) -> vector<2xi32> - %3 = "llvm.and"(%1, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.trunc"(%3) : (vector<2xi32>) -> vector<2xi16> - "llvm.return"(%4) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_and_commute", type = !llvm.func (vector<2xi16>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[7, -17]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sdiv"(%arg1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.sext"(%arg0) : (vector<2xi16>) -> vector<2xi32> - %3 = "llvm.or"(%1, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.trunc"(%3) : (vector<2xi32>) -> vector<2xi16> - "llvm.return"(%4) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "narrow_sext_or_commute", type = !llvm.func (vector<2xi16>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[7, -17]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sdiv"(%arg1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.zext"(%arg0) : (vector<2xi16>) -> vector<2xi32> - %3 = "llvm.or"(%1, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.trunc"(%3) : (vector<2xi32>) -> vector<2xi16> - "llvm.return"(%4) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_or_commute", type = !llvm.func (vector<2xi16>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[7, -17]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sdiv"(%arg1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.sext"(%arg0) : (vector<2xi16>) -> vector<2xi32> - %3 = "llvm.xor"(%1, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.trunc"(%3) : (vector<2xi32>) -> vector<2xi16> - "llvm.return"(%4) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "narrow_sext_xor_commute", type = !llvm.func (vector<2xi16>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[7, -17]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sdiv"(%arg1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.zext"(%arg0) : (vector<2xi16>) -> vector<2xi32> - %3 = "llvm.xor"(%1, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.trunc"(%3) : (vector<2xi32>) -> vector<2xi16> - "llvm.return"(%4) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_xor_commute", type = !llvm.func (vector<2xi16>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[7, -17]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sdiv"(%arg1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.sext"(%arg0) : (vector<2xi16>) -> vector<2xi32> - %3 = "llvm.add"(%1, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.trunc"(%3) : (vector<2xi32>) -> vector<2xi16> - "llvm.return"(%4) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "narrow_sext_add_commute", type = !llvm.func (vector<2xi16>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[7, -17]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sdiv"(%arg1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.zext"(%arg0) : (vector<2xi16>) -> vector<2xi32> - %3 = "llvm.add"(%1, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.trunc"(%3) : (vector<2xi32>) -> vector<2xi16> - "llvm.return"(%4) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_add_commute", type = !llvm.func (vector<2xi16>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[7, -17]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sdiv"(%arg1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.sext"(%arg0) : (vector<2xi16>) -> vector<2xi32> - %3 = "llvm.sub"(%1, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.trunc"(%3) : (vector<2xi32>) -> vector<2xi16> - "llvm.return"(%4) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "narrow_sext_sub_commute", type = !llvm.func (vector<2xi16>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[7, -17]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sdiv"(%arg1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.zext"(%arg0) : (vector<2xi16>) -> vector<2xi32> - %3 = "llvm.sub"(%1, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.trunc"(%3) : (vector<2xi32>) -> vector<2xi16> - "llvm.return"(%4) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_sub_commute", type = !llvm.func (vector<2xi16>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[7, -17]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sdiv"(%arg1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.sext"(%arg0) : (vector<2xi16>) -> vector<2xi32> - %3 = "llvm.mul"(%1, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.trunc"(%3) : (vector<2xi32>) -> vector<2xi16> - "llvm.return"(%4) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "narrow_sext_mul_commute", type = !llvm.func (vector<2xi16>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi16>, %arg1: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[7, -17]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.sdiv"(%arg1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %2 = "llvm.zext"(%arg0) : (vector<2xi16>) -> vector<2xi32> - %3 = "llvm.mul"(%1, %2) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %4 = "llvm.trunc"(%3) : (vector<2xi32>) -> vector<2xi16> - "llvm.return"(%4) : (vector<2xi16>) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_mul_commute", type = !llvm.func (vector<2xi16>, vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.sext"(%arg0) : (i8) -> i32 - %2 = "llvm.sext"(%arg1) : (i8) -> i32 - %3 = "llvm.add"(%1, %2) : (i32, i32) -> i32 - %4 = "llvm.ashr"(%3, %0) : (i32, i32) -> i32 - %5 = "llvm.trunc"(%4) : (i32) -> i8 - "llvm.return"(%5) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_ashr_keep_trunc", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i9, %arg1: i9): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.sext"(%arg0) : (i9) -> i64 - %2 = "llvm.sext"(%arg1) : (i9) -> i64 - %3 = "llvm.add"(%1, %2) : (i64, i64) -> i64 - %4 = "llvm.ashr"(%3, %0) : (i64, i64) -> i64 - %5 = "llvm.trunc"(%4) : (i64) -> i8 - "llvm.return"(%5) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_ashr_keep_trunc2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64 - %1 = "llvm.sext"(%arg0) : (i8) -> i64 - %2 = "llvm.sext"(%arg1) : (i8) -> i64 - %3 = "llvm.add"(%1, %2) : (i64, i64) -> i64 - %4 = "llvm.ashr"(%3, %0) : (i64, i64) -> i64 - %5 = "llvm.trunc"(%4) : (i64) -> i7 - "llvm.return"(%5) : (i7) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_ashr_keep_trunc3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi8>, %arg1: vector<8xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<1> : vector<8xi32>} : () -> vector<8xi32> - %1 = "llvm.sext"(%arg0) : (vector<8xi8>) -> vector<8xi32> - %2 = "llvm.sext"(%arg1) : (vector<8xi8>) -> vector<8xi32> - %3 = "llvm.add"(%1, %2) : (vector<8xi32>, vector<8xi32>) -> vector<8xi32> - %4 = "llvm.ashr"(%3, %0) : (vector<8xi32>, vector<8xi32>) -> vector<8xi32> - %5 = "llvm.trunc"(%4) : (vector<8xi32>) -> vector<8xi8> - "llvm.return"(%5) : (vector<8xi8>) -> () - }) {linkage = 10 : i64, sym_name = "narrow_zext_ashr_keep_trunc_vector", type = !llvm.func (vector<8xi8>, vector<8xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i16} : () -> i16 - %1 = "llvm.sext"(%arg0) : (i8) -> i16 - %2 = "llvm.sext"(%arg1) : (i8) -> i16 - %3 = "llvm.add"(%1, %2) : (i16, i16) -> i16 - %4 = "llvm.ashr"(%3, %0) : (i16, i16) -> i16 - %5 = "llvm.trunc"(%4) : (i16) -> i8 - "llvm.return"(%5) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "dont_narrow_zext_ashr_keep_trunc", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @narrow_sext_and(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.and %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @narrow_zext_and(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.zext %arg0 : i16 to i32 + %1 = llvm.and %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @narrow_sext_or(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.or %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @narrow_zext_or(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.zext %arg0 : i16 to i32 + %1 = llvm.or %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @narrow_sext_xor(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.xor %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @narrow_zext_xor(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.zext %arg0 : i16 to i32 + %1 = llvm.xor %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @narrow_sext_add(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.add %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @narrow_zext_add(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.zext %arg0 : i16 to i32 + %1 = llvm.add %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @narrow_sext_sub(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @narrow_zext_sub(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.zext %arg0 : i16 to i32 + %1 = llvm.sub %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @narrow_sext_mul(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.mul %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @narrow_zext_mul(%arg0: i16, %arg1: i32) -> i16 { + %0 = llvm.zext %arg0 : i16 to i32 + %1 = llvm.mul %0, %arg1 : i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @narrow_sext_and_commute(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[7, -17]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg1, %0 : vector<2xi32> + %2 = llvm.sext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.and %1, %2 : vector<2xi32> + %4 = llvm.trunc %3 : vector<2xi32> to vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @narrow_zext_and_commute(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[7, -17]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg1, %0 : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.and %1, %2 : vector<2xi32> + %4 = llvm.trunc %3 : vector<2xi32> to vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @narrow_sext_or_commute(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[7, -17]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg1, %0 : vector<2xi32> + %2 = llvm.sext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.or %1, %2 : vector<2xi32> + %4 = llvm.trunc %3 : vector<2xi32> to vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @narrow_zext_or_commute(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[7, -17]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg1, %0 : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.or %1, %2 : vector<2xi32> + %4 = llvm.trunc %3 : vector<2xi32> to vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @narrow_sext_xor_commute(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[7, -17]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg1, %0 : vector<2xi32> + %2 = llvm.sext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.xor %1, %2 : vector<2xi32> + %4 = llvm.trunc %3 : vector<2xi32> to vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @narrow_zext_xor_commute(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[7, -17]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg1, %0 : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.xor %1, %2 : vector<2xi32> + %4 = llvm.trunc %3 : vector<2xi32> to vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @narrow_sext_add_commute(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[7, -17]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg1, %0 : vector<2xi32> + %2 = llvm.sext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.add %1, %2 : vector<2xi32> + %4 = llvm.trunc %3 : vector<2xi32> to vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @narrow_zext_add_commute(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[7, -17]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg1, %0 : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.add %1, %2 : vector<2xi32> + %4 = llvm.trunc %3 : vector<2xi32> to vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @narrow_sext_sub_commute(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[7, -17]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg1, %0 : vector<2xi32> + %2 = llvm.sext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.sub %1, %2 : vector<2xi32> + %4 = llvm.trunc %3 : vector<2xi32> to vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @narrow_zext_sub_commute(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[7, -17]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg1, %0 : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.sub %1, %2 : vector<2xi32> + %4 = llvm.trunc %3 : vector<2xi32> to vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @narrow_sext_mul_commute(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[7, -17]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg1, %0 : vector<2xi32> + %2 = llvm.sext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.mul %1, %2 : vector<2xi32> + %4 = llvm.trunc %3 : vector<2xi32> to vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @narrow_zext_mul_commute(%arg0: vector<2xi16>, %arg1: vector<2xi32>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[7, -17]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sdiv %arg1, %0 : vector<2xi32> + %2 = llvm.zext %arg0 : vector<2xi16> to vector<2xi32> + %3 = llvm.mul %1, %2 : vector<2xi32> + %4 = llvm.trunc %3 : vector<2xi32> to vector<2xi16> + llvm.return %4 : vector<2xi16> + } + llvm.func @narrow_zext_ashr_keep_trunc(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.sext %arg1 : i8 to i32 + %3 = llvm.add %1, %2 overflow : i32 + %4 = llvm.ashr %3, %0 : i32 + %5 = llvm.trunc %4 : i32 to i8 + llvm.return %5 : i8 + } + llvm.func @narrow_zext_ashr_keep_trunc2(%arg0: i9, %arg1: i9) -> i8 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.sext %arg0 : i9 to i64 + %2 = llvm.sext %arg1 : i9 to i64 + %3 = llvm.add %1, %2 overflow : i64 + %4 = llvm.ashr %3, %0 : i64 + %5 = llvm.trunc %4 : i64 to i8 + llvm.return %5 : i8 + } + llvm.func @narrow_zext_ashr_keep_trunc3(%arg0: i8, %arg1: i8) -> i7 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.sext %arg0 : i8 to i64 + %2 = llvm.sext %arg1 : i8 to i64 + %3 = llvm.add %1, %2 overflow : i64 + %4 = llvm.ashr %3, %0 : i64 + %5 = llvm.trunc %4 : i64 to i7 + llvm.return %5 : i7 + } + llvm.func @narrow_zext_ashr_keep_trunc_vector(%arg0: vector<8xi8>, %arg1: vector<8xi8>) -> vector<8xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<8xi32>) : vector<8xi32> + %1 = llvm.sext %arg0 : vector<8xi8> to vector<8xi32> + %2 = llvm.sext %arg1 : vector<8xi8> to vector<8xi32> + %3 = llvm.add %1, %2 overflow : vector<8xi32> + %4 = llvm.ashr %3, %0 : vector<8xi32> + %5 = llvm.trunc %4 : vector<8xi32> to vector<8xi8> + llvm.return %5 : vector<8xi8> + } + llvm.func @dont_narrow_zext_ashr_keep_trunc(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.sext %arg0 : i8 to i16 + %2 = llvm.sext %arg1 : i8 to i16 + %3 = llvm.add %1, %2 overflow : i16 + %4 = llvm.ashr %3, %0 : i16 + %5 = llvm.trunc %4 : i16 to i8 + llvm.return %5 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/trunc-demand.ll.mlir b/test/LLVMDialect/InstCombine/trunc-demand.ll.mlir new file mode 100644 index 000000000..4a8b3a4aa --- /dev/null +++ b/test/LLVMDialect/InstCombine/trunc-demand.ll.mlir @@ -0,0 +1,97 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use6(i6) + llvm.func @use8(i8) + llvm.func @trunc_lshr(%arg0: i8) -> i6 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(14 : i6) : i6 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.trunc %2 : i8 to i6 + %4 = llvm.and %3, %1 : i6 + llvm.return %4 : i6 + } + llvm.func @trunc_lshr_exact_mask(%arg0: i8) -> i6 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(15 : i6) : i6 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.trunc %2 : i8 to i6 + %4 = llvm.and %3, %1 : i6 + llvm.return %4 : i6 + } + llvm.func @trunc_lshr_big_mask(%arg0: i8) -> i6 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(31 : i6) : i6 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.trunc %2 : i8 to i6 + %4 = llvm.and %3, %1 : i6 + llvm.return %4 : i6 + } + llvm.func @trunc_lshr_use1(%arg0: i8) -> i6 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(15 : i6) : i6 + %2 = llvm.lshr %arg0, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.trunc %2 : i8 to i6 + %4 = llvm.and %3, %1 : i6 + llvm.return %4 : i6 + } + llvm.func @trunc_lshr_use2(%arg0: i8) -> i6 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.mlir.constant(15 : i6) : i6 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.trunc %2 : i8 to i6 + llvm.call @use6(%3) : (i6) -> () + %4 = llvm.and %3, %1 : i6 + llvm.return %4 : i6 + } + llvm.func @trunc_lshr_vec_splat(%arg0: vector<2xi16>) -> vector<2xi7> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(1 : i7) : i7 + %2 = llvm.mlir.constant(dense<1> : vector<2xi7>) : vector<2xi7> + %3 = llvm.lshr %arg0, %0 : vector<2xi16> + %4 = llvm.trunc %3 : vector<2xi16> to vector<2xi7> + %5 = llvm.and %4, %2 : vector<2xi7> + llvm.return %5 : vector<2xi7> + } + llvm.func @trunc_lshr_vec_splat_exact_mask(%arg0: vector<2xi16>) -> vector<2xi7> { + %0 = llvm.mlir.constant(dense<6> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(1 : i7) : i7 + %2 = llvm.mlir.constant(dense<1> : vector<2xi7>) : vector<2xi7> + %3 = llvm.lshr %arg0, %0 : vector<2xi16> + %4 = llvm.trunc %3 : vector<2xi16> to vector<2xi7> + %5 = llvm.and %4, %2 : vector<2xi7> + llvm.return %5 : vector<2xi7> + } + llvm.func @trunc_lshr_big_shift(%arg0: vector<2xi16>) -> vector<2xi7> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(1 : i7) : i7 + %2 = llvm.mlir.constant(dense<1> : vector<2xi7>) : vector<2xi7> + %3 = llvm.lshr %arg0, %0 : vector<2xi16> + %4 = llvm.trunc %3 : vector<2xi16> to vector<2xi7> + %5 = llvm.and %4, %2 : vector<2xi7> + llvm.return %5 : vector<2xi7> + } + llvm.func @or_trunc_lshr(%arg0: i8) -> i6 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(-32 : i6) : i6 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.trunc %2 : i8 to i6 + %4 = llvm.or %3, %1 : i6 + llvm.return %4 : i6 + } + llvm.func @or_trunc_lshr_more(%arg0: i8) -> i6 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(-4 : i6) : i6 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.trunc %2 : i8 to i6 + %4 = llvm.or %3, %1 : i6 + llvm.return %4 : i6 + } + llvm.func @or_trunc_lshr_small_mask(%arg0: i8) -> i6 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(-8 : i6) : i6 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.trunc %2 : i8 to i6 + %4 = llvm.or %3, %1 : i6 + llvm.return %4 : i6 + } +} diff --git a/test/LLVMDialect/InstCombine/trunc-extractelement-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/trunc-extractelement-inseltpoison.ll.mlir new file mode 100644 index 000000000..6f50d3fc2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/trunc-extractelement-inseltpoison.ll.mlir @@ -0,0 +1,80 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @shrinkExtractElt_i64_to_i32_0(%arg0: vector<3xi64>) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.extractelement %arg0[%0 : i32] : vector<3xi64> + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @vscale_shrinkExtractElt_i64_to_i32_0(%arg0: !llvm.vec) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.extractelement %arg0[%0 : i32] : !llvm.vec + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @shrinkExtractElt_i64_to_i32_1(%arg0: vector<3xi64>) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.extractelement %arg0[%0 : i32] : vector<3xi64> + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @shrinkExtractElt_i64_to_i32_2(%arg0: vector<3xi64>) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.extractelement %arg0[%0 : i32] : vector<3xi64> + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @shrinkExtractElt_i64_to_i16_0(%arg0: vector<3xi64>) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.extractelement %arg0[%0 : i16] : vector<3xi64> + %2 = llvm.trunc %1 : i64 to i16 + llvm.return %2 : i16 + } + llvm.func @shrinkExtractElt_i64_to_i16_1(%arg0: vector<3xi64>) -> i16 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.extractelement %arg0[%0 : i16] : vector<3xi64> + %2 = llvm.trunc %1 : i64 to i16 + llvm.return %2 : i16 + } + llvm.func @shrinkExtractElt_i64_to_i16_2(%arg0: vector<3xi64>) -> i16 { + %0 = llvm.mlir.constant(2 : i16) : i16 + %1 = llvm.extractelement %arg0[%0 : i16] : vector<3xi64> + %2 = llvm.trunc %1 : i64 to i16 + llvm.return %2 : i16 + } + llvm.func @shrinkExtractElt_i33_to_11_2(%arg0: vector<3xi33>) -> i11 { + %0 = llvm.mlir.constant(2 : i16) : i16 + %1 = llvm.extractelement %arg0[%0 : i16] : vector<3xi33> + %2 = llvm.trunc %1 : i33 to i11 + llvm.return %2 : i11 + } + llvm.func @shrinkExtractElt_i67_to_i13_2(%arg0: vector<3xi67>) -> i13 { + %0 = llvm.mlir.constant(2 : i459) : i459 + %1 = llvm.extractelement %arg0[%0 : i459] : vector<3xi67> + %2 = llvm.trunc %1 : i67 to i13 + llvm.return %2 : i13 + } + llvm.func @shrinkExtractElt_i40_to_i30_1(%arg0: vector<3xi40>) -> i30 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.extractelement %arg0[%0 : i32] : vector<3xi40> + %2 = llvm.trunc %1 : i40 to i30 + llvm.return %2 : i30 + } + llvm.func @use(i64) + llvm.func @shrinkExtractElt_i64_to_i16_2_extra_use(%arg0: vector<3xi64>) -> i16 { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.extractelement %arg0[%0 : i64] : vector<3xi64> + llvm.call @use(%1) : (i64) -> () + %2 = llvm.trunc %1 : i64 to i16 + llvm.return %2 : i16 + } + llvm.func @PR45314(%arg0: vector<4xi64>) -> vector<4xi64> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : vector<8xi32> + %2 = llvm.extractelement %arg0[%0 : i32] : vector<4xi64> + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.insertelement %3, %1[%0 : i32] : vector<8xi32> + %5 = llvm.shufflevector %4, %1 [0, 0, 0, 0, 0, 0, 0, 0] : vector<8xi32> + %6 = llvm.bitcast %5 : vector<8xi32> to vector<4xi64> + llvm.return %6 : vector<4xi64> + } +} diff --git a/test/LLVMDialect/InstCombine/trunc-extractelement.ll.mlir b/test/LLVMDialect/InstCombine/trunc-extractelement.ll.mlir new file mode 100644 index 000000000..8c3a2dfb2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/trunc-extractelement.ll.mlir @@ -0,0 +1,80 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @shrinkExtractElt_i64_to_i32_0(%arg0: vector<3xi64>) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.extractelement %arg0[%0 : i32] : vector<3xi64> + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @vscale_shrinkExtractElt_i64_to_i32_0(%arg0: !llvm.vec) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.extractelement %arg0[%0 : i32] : !llvm.vec + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @shrinkExtractElt_i64_to_i32_1(%arg0: vector<3xi64>) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.extractelement %arg0[%0 : i32] : vector<3xi64> + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @shrinkExtractElt_i64_to_i32_2(%arg0: vector<3xi64>) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.extractelement %arg0[%0 : i32] : vector<3xi64> + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @shrinkExtractElt_i64_to_i16_0(%arg0: vector<3xi64>) -> i16 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.extractelement %arg0[%0 : i16] : vector<3xi64> + %2 = llvm.trunc %1 : i64 to i16 + llvm.return %2 : i16 + } + llvm.func @shrinkExtractElt_i64_to_i16_1(%arg0: vector<3xi64>) -> i16 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.extractelement %arg0[%0 : i16] : vector<3xi64> + %2 = llvm.trunc %1 : i64 to i16 + llvm.return %2 : i16 + } + llvm.func @shrinkExtractElt_i64_to_i16_2(%arg0: vector<3xi64>) -> i16 { + %0 = llvm.mlir.constant(2 : i16) : i16 + %1 = llvm.extractelement %arg0[%0 : i16] : vector<3xi64> + %2 = llvm.trunc %1 : i64 to i16 + llvm.return %2 : i16 + } + llvm.func @shrinkExtractElt_i33_to_11_2(%arg0: vector<3xi33>) -> i11 { + %0 = llvm.mlir.constant(2 : i16) : i16 + %1 = llvm.extractelement %arg0[%0 : i16] : vector<3xi33> + %2 = llvm.trunc %1 : i33 to i11 + llvm.return %2 : i11 + } + llvm.func @shrinkExtractElt_i67_to_i13_2(%arg0: vector<3xi67>) -> i13 { + %0 = llvm.mlir.constant(2 : i459) : i459 + %1 = llvm.extractelement %arg0[%0 : i459] : vector<3xi67> + %2 = llvm.trunc %1 : i67 to i13 + llvm.return %2 : i13 + } + llvm.func @shrinkExtractElt_i40_to_i30_1(%arg0: vector<3xi40>) -> i30 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.extractelement %arg0[%0 : i32] : vector<3xi40> + %2 = llvm.trunc %1 : i40 to i30 + llvm.return %2 : i30 + } + llvm.func @use(i64) + llvm.func @shrinkExtractElt_i64_to_i16_2_extra_use(%arg0: vector<3xi64>) -> i16 { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.extractelement %arg0[%0 : i64] : vector<3xi64> + llvm.call @use(%1) : (i64) -> () + %2 = llvm.trunc %1 : i64 to i16 + llvm.return %2 : i16 + } + llvm.func @PR45314(%arg0: vector<4xi64>) -> vector<4xi64> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : vector<8xi32> + %2 = llvm.extractelement %arg0[%0 : i32] : vector<4xi64> + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.insertelement %3, %1[%0 : i32] : vector<8xi32> + %5 = llvm.shufflevector %4, %1 [0, 0, 0, 0, 0, 0, 0, 0] : vector<8xi32> + %6 = llvm.bitcast %5 : vector<8xi32> to vector<4xi64> + llvm.return %6 : vector<4xi64> + } +} diff --git a/test/LLVMDialect/InstCombine/trunc-fp-to-int.ll.mlir b/test/LLVMDialect/InstCombine/trunc-fp-to-int.ll.mlir new file mode 100644 index 000000000..aba1c5fbe --- /dev/null +++ b/test/LLVMDialect/InstCombine/trunc-fp-to-int.ll.mlir @@ -0,0 +1,119 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @half_fptoui_i17_i16(%arg0: f16) -> i16 { + %0 = llvm.fptoui %arg0 : f16 to i17 + %1 = llvm.trunc %0 : i17 to i16 + llvm.return %1 : i16 + } + llvm.func @half_fptoui_i17_i15(%arg0: f16) -> i15 { + %0 = llvm.fptoui %arg0 : f16 to i17 + %1 = llvm.trunc %0 : i17 to i15 + llvm.return %1 : i15 + } + llvm.func @half_fptoui_i32_i16(%arg0: f16) -> i16 { + %0 = llvm.fptoui %arg0 : f16 to i32 + %1 = llvm.trunc %0 : i32 to i16 + llvm.return %1 : i16 + } + llvm.func @half_fptoui_i32_i17(%arg0: f16) -> i17 { + %0 = llvm.fptoui %arg0 : f16 to i32 + %1 = llvm.trunc %0 : i32 to i17 + llvm.return %1 : i17 + } + llvm.func @half_fptoui_4xi32_4xi16(%arg0: vector<4xf16>) -> vector<4xi16> { + %0 = llvm.fptoui %arg0 : vector<4xf16> to vector<4xi32> + %1 = llvm.trunc %0 : vector<4xi32> to vector<4xi16> + llvm.return %1 : vector<4xi16> + } + llvm.func @bfloat_fptoui_i129_i128(%arg0: bf16) -> i128 { + %0 = llvm.fptoui %arg0 : bf16 to i129 + %1 = llvm.trunc %0 : i129 to i128 + llvm.return %1 : i128 + } + llvm.func @bfloat_fptoui_i128_i127(%arg0: bf16) -> i127 { + %0 = llvm.fptoui %arg0 : bf16 to i128 + %1 = llvm.trunc %0 : i128 to i127 + llvm.return %1 : i127 + } + llvm.func @float_fptoui_i129_i128(%arg0: f32) -> i128 { + %0 = llvm.fptoui %arg0 : f32 to i129 + %1 = llvm.trunc %0 : i129 to i128 + llvm.return %1 : i128 + } + llvm.func @use(i129) + llvm.func @float_fptoui_i129_i128_use(%arg0: f32) -> i128 { + %0 = llvm.fptoui %arg0 : f32 to i129 + llvm.call @use(%0) : (i129) -> () + %1 = llvm.trunc %0 : i129 to i128 + llvm.return %1 : i128 + } + llvm.func @float_fptoui_i128_i127(%arg0: f32) -> i127 { + %0 = llvm.fptoui %arg0 : f32 to i128 + %1 = llvm.trunc %0 : i128 to i127 + llvm.return %1 : i127 + } + llvm.func @double_fptoui_i1025_i1024(%arg0: f64) -> i1024 { + %0 = llvm.fptoui %arg0 : f64 to i1025 + %1 = llvm.trunc %0 : i1025 to i1024 + llvm.return %1 : i1024 + } + llvm.func @double_fptoui_i1024_i1023(%arg0: f64) -> i1023 { + %0 = llvm.fptoui %arg0 : f64 to i1024 + %1 = llvm.trunc %0 : i1024 to i1023 + llvm.return %1 : i1023 + } + llvm.func @half_fptosi_i17_i16(%arg0: f16) -> i16 { + %0 = llvm.fptosi %arg0 : f16 to i17 + %1 = llvm.trunc %0 : i17 to i16 + llvm.return %1 : i16 + } + llvm.func @half_fptosi_i18_i17(%arg0: f16) -> i17 { + %0 = llvm.fptosi %arg0 : f16 to i18 + %1 = llvm.trunc %0 : i18 to i17 + llvm.return %1 : i17 + } + llvm.func @half_fptosi_i32_i17(%arg0: f16) -> i17 { + %0 = llvm.fptosi %arg0 : f16 to i32 + %1 = llvm.trunc %0 : i32 to i17 + llvm.return %1 : i17 + } + llvm.func @half_fptosi_i32_i18(%arg0: f16) -> i18 { + %0 = llvm.fptosi %arg0 : f16 to i32 + %1 = llvm.trunc %0 : i32 to i18 + llvm.return %1 : i18 + } + llvm.func @half_fptosi_4xi32_4xi17(%arg0: vector<4xf16>) -> vector<4xi17> { + %0 = llvm.fptosi %arg0 : vector<4xf16> to vector<4xi32> + %1 = llvm.trunc %0 : vector<4xi32> to vector<4xi17> + llvm.return %1 : vector<4xi17> + } + llvm.func @bfloat_fptosi_i129_i128(%arg0: bf16) -> i128 { + %0 = llvm.fptosi %arg0 : bf16 to i129 + %1 = llvm.trunc %0 : i129 to i128 + llvm.return %1 : i128 + } + llvm.func @bfloat_fptosi_i130_i129(%arg0: bf16) -> i129 { + %0 = llvm.fptosi %arg0 : bf16 to i130 + %1 = llvm.trunc %0 : i130 to i129 + llvm.return %1 : i129 + } + llvm.func @float_fptosi_i130_i129(%arg0: f32) -> i129 { + %0 = llvm.fptosi %arg0 : f32 to i130 + %1 = llvm.trunc %0 : i130 to i129 + llvm.return %1 : i129 + } + llvm.func @float_fptosi_i129_i128(%arg0: f32) -> i128 { + %0 = llvm.fptosi %arg0 : f32 to i129 + %1 = llvm.trunc %0 : i129 to i128 + llvm.return %1 : i128 + } + llvm.func @double_fptosi_i1026_i1025(%arg0: f64) -> i1025 { + %0 = llvm.fptosi %arg0 : f64 to i1026 + %1 = llvm.trunc %0 : i1026 to i1025 + llvm.return %1 : i1025 + } + llvm.func @double_fptosi_i1025_i1024(%arg0: f64) -> i1024 { + %0 = llvm.fptosi %arg0 : f64 to i1025 + %1 = llvm.trunc %0 : i1025 to i1024 + llvm.return %1 : i1024 + } +} diff --git a/test/LLVMDialect/InstCombine/trunc-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/trunc-inseltpoison.ll.mlir new file mode 100644 index 000000000..66d69f5c5 --- /dev/null +++ b/test/LLVMDialect/InstCombine/trunc-inseltpoison.ll.mlir @@ -0,0 +1,620 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @use_vec(vector<2xi32>) + llvm.func @test1(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.trunc %arg0 : i64 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use(%1) : (i32) -> () + llvm.return %3 : i64 + } + llvm.func @test1_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<15> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %2 = llvm.and %1, %0 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + llvm.call @use_vec(%1) : (vector<2xi32>) -> () + llvm.return %3 : vector<2xi64> + } + llvm.func @test1_vec_nonuniform(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[15, 7]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %2 = llvm.and %1, %0 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + llvm.call @use_vec(%1) : (vector<2xi32>) -> () + llvm.return %3 : vector<2xi64> + } + llvm.func @test1_vec_poison(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %8 = llvm.and %7, %6 : vector<2xi32> + %9 = llvm.zext %8 : vector<2xi32> to vector<2xi64> + llvm.call @use_vec(%7) : (vector<2xi32>) -> () + llvm.return %9 : vector<2xi64> + } + llvm.func @test2(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.trunc %arg0 : i64 to i32 + %2 = llvm.shl %1, %0 : i32 + %3 = llvm.ashr %2, %0 : i32 + %4 = llvm.sext %3 : i32 to i64 + llvm.call @use(%1) : (i32) -> () + llvm.return %4 : i64 + } + llvm.func @test2_vec(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %2 = llvm.shl %1, %0 : vector<2xi32> + %3 = llvm.ashr %2, %0 : vector<2xi32> + %4 = llvm.sext %3 : vector<2xi32> to vector<2xi64> + llvm.call @use_vec(%1) : (vector<2xi32>) -> () + llvm.return %4 : vector<2xi64> + } + llvm.func @test2_vec_nonuniform(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[4, 5]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %2 = llvm.shl %1, %0 : vector<2xi32> + %3 = llvm.ashr %2, %0 : vector<2xi32> + %4 = llvm.sext %3 : vector<2xi32> to vector<2xi64> + llvm.call @use_vec(%1) : (vector<2xi32>) -> () + llvm.return %4 : vector<2xi64> + } + llvm.func @test2_vec_poison(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %8 = llvm.shl %7, %6 : vector<2xi32> + %9 = llvm.ashr %8, %6 : vector<2xi32> + %10 = llvm.sext %9 : vector<2xi32> to vector<2xi64> + llvm.call @use_vec(%7) : (vector<2xi32>) -> () + llvm.return %10 : vector<2xi64> + } + llvm.func @test3(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.trunc %arg0 : i64 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use(%1) : (i32) -> () + llvm.return %3 : i64 + } + llvm.func @test4(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.trunc %arg0 : i64 to i32 + %2 = llvm.and %1, %0 : i32 + %3 = llvm.xor %2, %0 : i32 + %4 = llvm.zext %3 : i32 to i64 + llvm.call @use(%1) : (i32) -> () + llvm.return %4 : i64 + } + llvm.func @test5(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(16 : i128) : i128 + %1 = llvm.zext %arg0 : i32 to i128 + %2 = llvm.lshr %1, %0 : i128 + %3 = llvm.trunc %2 : i128 to i32 + llvm.return %3 : i32 + } + llvm.func @test6(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(32 : i128) : i128 + %1 = llvm.zext %arg0 : i64 to i128 + %2 = llvm.lshr %1, %0 : i128 + %3 = llvm.trunc %2 : i128 to i32 + llvm.return %3 : i32 + } + llvm.func @ashr_mul_sign_bits(%arg0: i8, %arg1: i8) -> i16 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = llvm.sext %arg1 : i8 to i32 + %3 = llvm.mul %1, %2 : i32 + %4 = llvm.ashr %3, %0 : i32 + %5 = llvm.trunc %4 : i32 to i16 + llvm.return %5 : i16 + } + llvm.func @ashr_mul(%arg0: i8, %arg1: i8) -> i16 { + %0 = llvm.mlir.constant(8 : i20) : i20 + %1 = llvm.sext %arg0 : i8 to i20 + %2 = llvm.sext %arg1 : i8 to i20 + %3 = llvm.mul %1, %2 : i20 + %4 = llvm.ashr %3, %0 : i20 + %5 = llvm.trunc %4 : i20 to i16 + llvm.return %5 : i16 + } + llvm.func @trunc_ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483648 : i36) : i36 + %1 = llvm.mlir.constant(8 : i36) : i36 + %2 = llvm.zext %arg0 : i32 to i36 + %3 = llvm.or %2, %0 : i36 + %4 = llvm.ashr %3, %1 : i36 + %5 = llvm.trunc %4 : i36 to i32 + llvm.return %5 : i32 + } + llvm.func @trunc_ashr_vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(-2147483648 : i36) : i36 + %1 = llvm.mlir.constant(dense<-2147483648> : vector<2xi36>) : vector<2xi36> + %2 = llvm.mlir.constant(8 : i36) : i36 + %3 = llvm.mlir.constant(dense<8> : vector<2xi36>) : vector<2xi36> + %4 = llvm.zext %arg0 : vector<2xi32> to vector<2xi36> + %5 = llvm.or %4, %1 : vector<2xi36> + %6 = llvm.ashr %5, %3 : vector<2xi36> + %7 = llvm.trunc %6 : vector<2xi36> to vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @test7(%arg0: i64) -> i92 { + %0 = llvm.mlir.constant(32 : i128) : i128 + %1 = llvm.zext %arg0 : i64 to i128 + %2 = llvm.lshr %1, %0 : i128 + %3 = llvm.trunc %2 : i128 to i92 + llvm.return %3 : i92 + } + llvm.func @test8(%arg0: i32, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(32 : i128) : i128 + %1 = llvm.zext %arg0 : i32 to i128 + %2 = llvm.zext %arg1 : i32 to i128 + %3 = llvm.shl %2, %0 : i128 + %4 = llvm.or %3, %1 : i128 + %5 = llvm.trunc %4 : i128 to i64 + llvm.return %5 : i64 + } + llvm.func @test8_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(32 : i128) : i128 + %1 = llvm.mlir.constant(dense<32> : vector<2xi128>) : vector<2xi128> + %2 = llvm.zext %arg0 : vector<2xi32> to vector<2xi128> + %3 = llvm.zext %arg1 : vector<2xi32> to vector<2xi128> + %4 = llvm.shl %3, %1 : vector<2xi128> + %5 = llvm.or %4, %2 : vector<2xi128> + %6 = llvm.trunc %5 : vector<2xi128> to vector<2xi64> + llvm.return %6 : vector<2xi64> + } + llvm.func @test8_vec_nonuniform(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(48 : i128) : i128 + %1 = llvm.mlir.constant(32 : i128) : i128 + %2 = llvm.mlir.constant(dense<[32, 48]> : vector<2xi128>) : vector<2xi128> + %3 = llvm.zext %arg0 : vector<2xi32> to vector<2xi128> + %4 = llvm.zext %arg1 : vector<2xi32> to vector<2xi128> + %5 = llvm.shl %4, %2 : vector<2xi128> + %6 = llvm.or %5, %3 : vector<2xi128> + %7 = llvm.trunc %6 : vector<2xi128> to vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @test8_vec_poison(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.poison : i128 + %1 = llvm.mlir.constant(32 : i128) : i128 + %2 = llvm.mlir.undef : vector<2xi128> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi128> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi128> + %7 = llvm.zext %arg0 : vector<2xi32> to vector<2xi128> + %8 = llvm.zext %arg1 : vector<2xi32> to vector<2xi128> + %9 = llvm.shl %8, %6 : vector<2xi128> + %10 = llvm.or %9, %7 : vector<2xi128> + %11 = llvm.trunc %10 : vector<2xi128> to vector<2xi64> + llvm.return %11 : vector<2xi64> + } + llvm.func @test9(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.trunc %1 : i32 to i8 + llvm.return %2 : i8 + } + llvm.func @test10(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.trunc %arg0 : i32 to i8 + %2 = llvm.and %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @test11(%arg0: i32, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(31 : i128) : i128 + %1 = llvm.zext %arg0 : i32 to i128 + %2 = llvm.zext %arg1 : i32 to i128 + %3 = llvm.and %2, %0 : i128 + %4 = llvm.shl %1, %3 : i128 + %5 = llvm.trunc %4 : i128 to i64 + llvm.return %5 : i64 + } + llvm.func @test11_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(31 : i128) : i128 + %1 = llvm.mlir.constant(dense<31> : vector<2xi128>) : vector<2xi128> + %2 = llvm.zext %arg0 : vector<2xi32> to vector<2xi128> + %3 = llvm.zext %arg1 : vector<2xi32> to vector<2xi128> + %4 = llvm.and %3, %1 : vector<2xi128> + %5 = llvm.shl %2, %4 : vector<2xi128> + %6 = llvm.trunc %5 : vector<2xi128> to vector<2xi64> + llvm.return %6 : vector<2xi64> + } + llvm.func @test11_vec_nonuniform(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(15 : i128) : i128 + %1 = llvm.mlir.constant(31 : i128) : i128 + %2 = llvm.mlir.constant(dense<[31, 15]> : vector<2xi128>) : vector<2xi128> + %3 = llvm.zext %arg0 : vector<2xi32> to vector<2xi128> + %4 = llvm.zext %arg1 : vector<2xi32> to vector<2xi128> + %5 = llvm.and %4, %2 : vector<2xi128> + %6 = llvm.shl %3, %5 : vector<2xi128> + %7 = llvm.trunc %6 : vector<2xi128> to vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @test11_vec_poison(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.poison : i128 + %1 = llvm.mlir.constant(31 : i128) : i128 + %2 = llvm.mlir.undef : vector<2xi128> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi128> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi128> + %7 = llvm.zext %arg0 : vector<2xi32> to vector<2xi128> + %8 = llvm.zext %arg1 : vector<2xi32> to vector<2xi128> + %9 = llvm.and %8, %6 : vector<2xi128> + %10 = llvm.shl %7, %9 : vector<2xi128> + %11 = llvm.trunc %10 : vector<2xi128> to vector<2xi64> + llvm.return %11 : vector<2xi64> + } + llvm.func @test12(%arg0: i32, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(31 : i128) : i128 + %1 = llvm.zext %arg0 : i32 to i128 + %2 = llvm.zext %arg1 : i32 to i128 + %3 = llvm.and %2, %0 : i128 + %4 = llvm.lshr %1, %3 : i128 + %5 = llvm.trunc %4 : i128 to i64 + llvm.return %5 : i64 + } + llvm.func @test12_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(31 : i128) : i128 + %1 = llvm.mlir.constant(dense<31> : vector<2xi128>) : vector<2xi128> + %2 = llvm.zext %arg0 : vector<2xi32> to vector<2xi128> + %3 = llvm.zext %arg1 : vector<2xi32> to vector<2xi128> + %4 = llvm.and %3, %1 : vector<2xi128> + %5 = llvm.lshr %2, %4 : vector<2xi128> + %6 = llvm.trunc %5 : vector<2xi128> to vector<2xi64> + llvm.return %6 : vector<2xi64> + } + llvm.func @test12_vec_nonuniform(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(15 : i128) : i128 + %1 = llvm.mlir.constant(31 : i128) : i128 + %2 = llvm.mlir.constant(dense<[31, 15]> : vector<2xi128>) : vector<2xi128> + %3 = llvm.zext %arg0 : vector<2xi32> to vector<2xi128> + %4 = llvm.zext %arg1 : vector<2xi32> to vector<2xi128> + %5 = llvm.and %4, %2 : vector<2xi128> + %6 = llvm.lshr %3, %5 : vector<2xi128> + %7 = llvm.trunc %6 : vector<2xi128> to vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @test12_vec_poison(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.poison : i128 + %1 = llvm.mlir.constant(31 : i128) : i128 + %2 = llvm.mlir.undef : vector<2xi128> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi128> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi128> + %7 = llvm.zext %arg0 : vector<2xi32> to vector<2xi128> + %8 = llvm.zext %arg1 : vector<2xi32> to vector<2xi128> + %9 = llvm.and %8, %6 : vector<2xi128> + %10 = llvm.lshr %7, %9 : vector<2xi128> + %11 = llvm.trunc %10 : vector<2xi128> to vector<2xi64> + llvm.return %11 : vector<2xi64> + } + llvm.func @test13(%arg0: i32, %arg1: i32) -> i64 { + %0 = llvm.mlir.constant(31 : i128) : i128 + %1 = llvm.sext %arg0 : i32 to i128 + %2 = llvm.zext %arg1 : i32 to i128 + %3 = llvm.and %2, %0 : i128 + %4 = llvm.ashr %1, %3 : i128 + %5 = llvm.trunc %4 : i128 to i64 + llvm.return %5 : i64 + } + llvm.func @test13_vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(31 : i128) : i128 + %1 = llvm.mlir.constant(dense<31> : vector<2xi128>) : vector<2xi128> + %2 = llvm.sext %arg0 : vector<2xi32> to vector<2xi128> + %3 = llvm.zext %arg1 : vector<2xi32> to vector<2xi128> + %4 = llvm.and %3, %1 : vector<2xi128> + %5 = llvm.ashr %2, %4 : vector<2xi128> + %6 = llvm.trunc %5 : vector<2xi128> to vector<2xi64> + llvm.return %6 : vector<2xi64> + } + llvm.func @test13_vec_nonuniform(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(15 : i128) : i128 + %1 = llvm.mlir.constant(31 : i128) : i128 + %2 = llvm.mlir.constant(dense<[31, 15]> : vector<2xi128>) : vector<2xi128> + %3 = llvm.sext %arg0 : vector<2xi32> to vector<2xi128> + %4 = llvm.zext %arg1 : vector<2xi32> to vector<2xi128> + %5 = llvm.and %4, %2 : vector<2xi128> + %6 = llvm.ashr %3, %5 : vector<2xi128> + %7 = llvm.trunc %6 : vector<2xi128> to vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @test13_vec_poison(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi64> { + %0 = llvm.mlir.poison : i128 + %1 = llvm.mlir.constant(31 : i128) : i128 + %2 = llvm.mlir.undef : vector<2xi128> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi128> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi128> + %7 = llvm.sext %arg0 : vector<2xi32> to vector<2xi128> + %8 = llvm.zext %arg1 : vector<2xi32> to vector<2xi128> + %9 = llvm.and %8, %6 : vector<2xi128> + %10 = llvm.ashr %7, %9 : vector<2xi128> + %11 = llvm.trunc %10 : vector<2xi128> to vector<2xi64> + llvm.return %11 : vector<2xi64> + } + llvm.func @trunc_bitcast1(%arg0: vector<4xi32>) -> i32 { + %0 = llvm.mlir.constant(32 : i128) : i128 + %1 = llvm.bitcast %arg0 : vector<4xi32> to i128 + %2 = llvm.lshr %1, %0 : i128 + %3 = llvm.trunc %2 : i128 to i32 + llvm.return %3 : i32 + } + llvm.func @trunc_bitcast2(%arg0: vector<2xi64>) -> i32 { + %0 = llvm.mlir.constant(64 : i128) : i128 + %1 = llvm.bitcast %arg0 : vector<2xi64> to i128 + %2 = llvm.lshr %1, %0 : i128 + %3 = llvm.trunc %2 : i128 to i32 + llvm.return %3 : i32 + } + llvm.func @trunc_bitcast3(%arg0: vector<4xi32>) -> i32 { + %0 = llvm.bitcast %arg0 : vector<4xi32> to i128 + %1 = llvm.trunc %0 : i128 to i32 + llvm.return %1 : i32 + } + llvm.func @trunc_shl_31_i32_i64(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(31 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @trunc_shl_nsw_31_i32_i64(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(31 : i64) : i64 + %1 = llvm.shl %arg0, %0 overflow : i64 + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @trunc_shl_nuw_31_i32_i64(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(31 : i64) : i64 + %1 = llvm.shl %arg0, %0 overflow : i64 + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @trunc_shl_nsw_nuw_31_i32_i64(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(31 : i64) : i64 + %1 = llvm.shl %arg0, %0 overflow : i64 + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @trunc_shl_15_i16_i64(%arg0: i64) -> i16 { + %0 = llvm.mlir.constant(15 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i16 + llvm.return %2 : i16 + } + llvm.func @trunc_shl_15_i16_i32(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.shl %arg0, %0 : i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @trunc_shl_7_i8_i64(%arg0: i64) -> i8 { + %0 = llvm.mlir.constant(7 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i8 + llvm.return %2 : i8 + } + llvm.func @trunc_shl_1_i2_i64(%arg0: i64) -> i2 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i2 + llvm.return %2 : i2 + } + llvm.func @trunc_shl_1_i32_i64(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @trunc_shl_16_i32_i64(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @trunc_shl_33_i32_i64(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(33 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @trunc_shl_32_i32_i64(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i32 + llvm.return %2 : i32 + } + llvm.func @trunc_shl_16_v2i32_v2i64(%arg0: vector<2xi64>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<16> : vector<2xi64>) : vector<2xi64> + %1 = llvm.shl %arg0, %0 : vector<2xi64> + %2 = llvm.trunc %1 : vector<2xi64> to vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @trunc_shl_nosplat_v2i32_v2i64(%arg0: vector<2xi64>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[15, 16]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.shl %arg0, %0 : vector<2xi64> + %2 = llvm.trunc %1 : vector<2xi64> to vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @trunc_shl_31_i32_i64_multi_use(%arg0: i64, %arg1: !llvm.ptr<1>, %arg2: !llvm.ptr<1>) { + %0 = llvm.mlir.constant(31 : i64) : i64 + %1 = llvm.shl %arg0, %0 : i64 + %2 = llvm.trunc %1 : i64 to i32 + llvm.store volatile %2, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr<1> + llvm.store volatile %1, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr<1> + llvm.return + } + llvm.func @trunc_shl_lshr_infloop(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.lshr %arg0, %0 : i64 + %3 = llvm.shl %2, %1 : i64 + %4 = llvm.trunc %3 : i64 to i32 + llvm.return %4 : i32 + } + llvm.func @trunc_shl_v2i32_v2i64_uniform(%arg0: vector<2xi64>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<31> : vector<2xi64>) : vector<2xi64> + %1 = llvm.shl %arg0, %0 : vector<2xi64> + %2 = llvm.trunc %1 : vector<2xi64> to vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @trunc_shl_v2i32_v2i64_poison(%arg0: vector<2xi64>) -> vector<2xi32> { + %0 = llvm.mlir.poison : i64 + %1 = llvm.mlir.constant(31 : i64) : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.shl %arg0, %6 : vector<2xi64> + %8 = llvm.trunc %7 : vector<2xi64> to vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @trunc_shl_v2i32_v2i64_nonuniform(%arg0: vector<2xi64>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[31, 12]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.shl %arg0, %0 : vector<2xi64> + %2 = llvm.trunc %1 : vector<2xi64> to vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @trunc_shl_v2i32_v2i64_outofrange(%arg0: vector<2xi64>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[31, 33]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.shl %arg0, %0 : vector<2xi64> + %2 = llvm.trunc %1 : vector<2xi64> to vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @trunc_shl_ashr_infloop(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(3 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.ashr %arg0, %0 : i64 + %3 = llvm.shl %2, %1 : i64 + %4 = llvm.trunc %3 : i64 to i32 + llvm.return %4 : i32 + } + llvm.func @trunc_shl_shl_infloop(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.constant(2 : i64) : i64 + %2 = llvm.shl %arg0, %0 : i64 + %3 = llvm.shl %2, %1 : i64 + %4 = llvm.trunc %3 : i64 to i32 + llvm.return %4 : i32 + } + llvm.func @trunc_shl_lshr_var(%arg0: i64, %arg1: i64) -> i32 { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.lshr %arg0, %arg1 : i64 + %2 = llvm.shl %1, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + llvm.return %3 : i32 + } + llvm.func @trunc_shl_ashr_var(%arg0: i64, %arg1: i64) -> i32 { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.ashr %arg0, %arg1 : i64 + %2 = llvm.shl %1, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + llvm.return %3 : i32 + } + llvm.func @trunc_shl_shl_var(%arg0: i64, %arg1: i64) -> i32 { + %0 = llvm.mlir.constant(2 : i64) : i64 + %1 = llvm.shl %arg0, %arg1 : i64 + %2 = llvm.shl %1, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + llvm.return %3 : i32 + } + llvm.func @trunc_shl_v8i15_v8i32_15(%arg0: vector<8xi32>) -> vector<8xi16> { + %0 = llvm.mlir.constant(dense<15> : vector<8xi32>) : vector<8xi32> + %1 = llvm.shl %arg0, %0 : vector<8xi32> + %2 = llvm.trunc %1 : vector<8xi32> to vector<8xi16> + llvm.return %2 : vector<8xi16> + } + llvm.func @trunc_shl_v8i16_v8i32_16(%arg0: vector<8xi32>) -> vector<8xi16> { + %0 = llvm.mlir.constant(dense<16> : vector<8xi32>) : vector<8xi32> + %1 = llvm.shl %arg0, %0 : vector<8xi32> + %2 = llvm.trunc %1 : vector<8xi32> to vector<8xi16> + llvm.return %2 : vector<8xi16> + } + llvm.func @trunc_shl_v8i16_v8i32_17(%arg0: vector<8xi32>) -> vector<8xi16> { + %0 = llvm.mlir.constant(dense<17> : vector<8xi32>) : vector<8xi32> + %1 = llvm.shl %arg0, %0 : vector<8xi32> + %2 = llvm.trunc %1 : vector<8xi32> to vector<8xi16> + llvm.return %2 : vector<8xi16> + } + llvm.func @trunc_shl_v8i16_v8i32_4(%arg0: vector<8xi32>) -> vector<8xi16> { + %0 = llvm.mlir.constant(dense<4> : vector<8xi32>) : vector<8xi32> + %1 = llvm.shl %arg0, %0 : vector<8xi32> + %2 = llvm.trunc %1 : vector<8xi32> to vector<8xi16> + llvm.return %2 : vector<8xi16> + } + llvm.func @wide_shuf(%arg0: vector<4xi32>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<[35, 3634, 90, -1]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [1, 5, 6, 2] : vector<4xi32> + %2 = llvm.trunc %1 : vector<4xi32> to vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @wide_splat1(%arg0: vector<4xi32>) -> vector<4xi8> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [2, 2, 2, 2] : vector<4xi32> + %2 = llvm.trunc %1 : vector<4xi32> to vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @wide_splat2(%arg0: vector<3xi33>) -> vector<3xi31> { + %0 = llvm.mlir.poison : vector<3xi33> + %1 = llvm.shufflevector %arg0, %0 [1, 1, 1] : vector<3xi33> + %2 = llvm.trunc %1 : vector<3xi33> to vector<3xi31> + llvm.return %2 : vector<3xi31> + } + llvm.func @wide_splat3(%arg0: vector<3xi33>) -> vector<3xi31> { + %0 = llvm.mlir.poison : vector<3xi33> + %1 = llvm.shufflevector %arg0, %0 [-1, 1, 1] : vector<3xi33> + %2 = llvm.trunc %1 : vector<3xi33> to vector<3xi31> + llvm.return %2 : vector<3xi31> + } + llvm.func @wide_lengthening_splat(%arg0: vector<4xi16>) -> vector<8xi8> { + %0 = llvm.shufflevector %arg0, %arg0 [0, 0, 0, 0, 0, 0, 0, 0] : vector<4xi16> + %1 = llvm.trunc %0 : vector<8xi16> to vector<8xi8> + llvm.return %1 : vector<8xi8> + } + llvm.func @narrow_add_vec_constant(%arg0: vector<2xi32>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[256, -129]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.add %arg0, %0 : vector<2xi32> + %2 = llvm.trunc %1 : vector<2xi32> to vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @narrow_mul_vec_constant(%arg0: vector<2xi32>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[256, -129]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mul %arg0, %0 : vector<2xi32> + %2 = llvm.trunc %1 : vector<2xi32> to vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @narrow_sub_vec_constant(%arg0: vector<2xi32>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[256, -129]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.sub %0, %arg0 : vector<2xi32> + %2 = llvm.trunc %1 : vector<2xi32> to vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @PR44545(%arg0: i32, %arg1: i32) -> i16 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.add %arg0, %0 overflow : i32 + %4 = llvm.icmp "eq" %arg1, %1 : i32 + %5 = llvm.select %4, %1, %3 : i1, i32 + %6 = llvm.trunc %5 : i32 to i16 + %7 = llvm.add %6, %2 overflow : i16 + llvm.return %7 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/trunc-load.ll.mlir b/test/LLVMDialect/InstCombine/trunc-load.ll.mlir index 926169a50..3eea85934 100644 --- a/test/LLVMDialect/InstCombine/trunc-load.ll.mlir +++ b/test/LLVMDialect/InstCombine/trunc-load.ll.mlir @@ -1,54 +1,44 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i64 - %1 = "llvm.trunc"(%0) : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "truncload_no_deref", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i64 - %1 = "llvm.trunc"(%0) : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "truncload_small_deref", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i64 - %1 = "llvm.trunc"(%0) : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "truncload_deref", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %1 = "llvm.trunc"(%0) : (i32) -> i16 - "llvm.return"(%1) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "truncload_align", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i64 - "llvm.call"(%0) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (i64) -> () - %1 = "llvm.trunc"(%0) : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "truncload_extra_use", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i64 - %1 = "llvm.trunc"(%0) : (i64) -> i8 - "llvm.return"(%1) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "truncload_type", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i64 - %1 = "llvm.trunc"(%0) : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "truncload_volatile", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i64 - %1 = "llvm.trunc"(%0) : (i64) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "truncload_address_space", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @truncload_no_deref(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i64 + %1 = llvm.trunc %0 : i64 to i32 + llvm.return %1 : i32 + } + llvm.func @truncload_small_deref(%arg0: !llvm.ptr {llvm.dereferenceable = 7 : i64}) -> i32 { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i64 + %1 = llvm.trunc %0 : i64 to i32 + llvm.return %1 : i32 + } + llvm.func @truncload_deref(%arg0: !llvm.ptr {llvm.dereferenceable = 8 : i64}) -> i32 { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> i64 + %1 = llvm.trunc %0 : i64 to i32 + llvm.return %1 : i32 + } + llvm.func @truncload_align(%arg0: !llvm.ptr {llvm.dereferenceable = 14 : i64}) -> i16 { + %0 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> i32 + %1 = llvm.trunc %0 : i32 to i16 + llvm.return %1 : i16 + } + llvm.func @use(i64) + llvm.func @truncload_extra_use(%arg0: !llvm.ptr {llvm.dereferenceable = 100 : i64}) -> i32 { + %0 = llvm.load %arg0 {alignment = 2 : i64} : !llvm.ptr -> i64 + llvm.call @use(%0) : (i64) -> () + %1 = llvm.trunc %0 : i64 to i32 + llvm.return %1 : i32 + } + llvm.func @truncload_type(%arg0: !llvm.ptr {llvm.dereferenceable = 9 : i64}) -> i8 { + %0 = llvm.load %arg0 {alignment = 2 : i64} : !llvm.ptr -> i64 + %1 = llvm.trunc %0 : i64 to i8 + llvm.return %1 : i8 + } + llvm.func @truncload_volatile(%arg0: !llvm.ptr {llvm.dereferenceable = 8 : i64}) -> i32 { + %0 = llvm.load volatile %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + %1 = llvm.trunc %0 : i64 to i32 + llvm.return %1 : i32 + } + llvm.func @truncload_address_space(%arg0: !llvm.ptr<1> {llvm.dereferenceable = 8 : i64}) -> i32 { + %0 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr<1> -> i64 + %1 = llvm.trunc %0 : i64 to i32 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/trunc-shift-trunc.ll.mlir b/test/LLVMDialect/InstCombine/trunc-shift-trunc.ll.mlir new file mode 100644 index 000000000..809cb08db --- /dev/null +++ b/test/LLVMDialect/InstCombine/trunc-shift-trunc.ll.mlir @@ -0,0 +1,121 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @trunc_lshr_trunc(%arg0: i64) -> i8 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.trunc %arg0 : i64 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_shl_trunc(%arg0: vector<2xi64>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[9, 7]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %2 = llvm.shl %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_trunc_uniform(%arg0: vector<2xi64>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_trunc_nonuniform(%arg0: vector<2xi64>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[8, 2]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_lshr_trunc_uniform_poison(%arg0: vector<2xi64>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(24 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %8 = llvm.lshr %7, %6 : vector<2xi32> + %9 = llvm.trunc %8 : vector<2xi32> to vector<2xi8> + llvm.return %9 : vector<2xi8> + } + llvm.func @trunc_lshr_trunc_outofrange(%arg0: i64) -> i8 { + %0 = llvm.mlir.constant(25 : i32) : i32 + %1 = llvm.trunc %arg0 : i64 to i32 + %2 = llvm.lshr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_lshr_trunc_nonuniform_outofrange(%arg0: vector<2xi64>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[8, 25]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %2 = llvm.lshr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_ashr_trunc(%arg0: i64) -> i8 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.trunc %arg0 : i64 to i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_ashr_trunc_exact(%arg0: i64) -> i8 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.trunc %arg0 : i64 to i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_ashr_trunc_uniform(%arg0: vector<2xi64>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<8> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %2 = llvm.ashr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_ashr_trunc_nonuniform(%arg0: vector<2xi64>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[0, 23]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %2 = llvm.ashr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_ashr_trunc_uniform_poison(%arg0: vector<2xi64>) -> vector<2xi8> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %8 = llvm.ashr %7, %6 : vector<2xi32> + %9 = llvm.trunc %8 : vector<2xi32> to vector<2xi8> + llvm.return %9 : vector<2xi8> + } + llvm.func @trunc_ashr_trunc_outofrange(%arg0: i64) -> i8 { + %0 = llvm.mlir.constant(25 : i32) : i32 + %1 = llvm.trunc %arg0 : i64 to i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @trunc_ashr_trunc_nonuniform_outofrange(%arg0: vector<2xi64>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<[8, 25]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %2 = llvm.ashr %1, %0 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @trunc_ashr_trunc_multiuse(%arg0: i64) -> i8 { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.trunc %arg0 : i64 to i32 + %2 = llvm.ashr %1, %0 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.call @use(%2) : (i32) -> () + llvm.return %3 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/trunc-shl-zext.ll.mlir b/test/LLVMDialect/InstCombine/trunc-shl-zext.ll.mlir new file mode 100644 index 000000000..75704b516 --- /dev/null +++ b/test/LLVMDialect/InstCombine/trunc-shl-zext.ll.mlir @@ -0,0 +1,16 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @trunc_shl_zext_32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i16) : i16 + %1 = llvm.trunc %arg0 : i32 to i16 + %2 = llvm.shl %1, %0 : i16 + %3 = llvm.zext %2 : i16 to i32 + llvm.return %3 : i32 + } + llvm.func @trunc_shl_zext_64(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.trunc %arg0 : i64 to i8 + %2 = llvm.shl %1, %0 : i8 + %3 = llvm.zext %2 : i8 to i64 + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/trunc.ll.mlir b/test/LLVMDialect/InstCombine/trunc.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/truncating-saturate.ll.mlir b/test/LLVMDialect/InstCombine/truncating-saturate.ll.mlir new file mode 100644 index 000000000..091264a4d --- /dev/null +++ b/test/LLVMDialect/InstCombine/truncating-saturate.ll.mlir @@ -0,0 +1,463 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i32) + llvm.func @use16(i16) + llvm.func @use1(i1) + llvm.func @testi16i8(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(15 : i16) : i16 + %3 = llvm.mlir.constant(127 : i8) : i8 + %4 = llvm.lshr %arg0, %0 : i16 + %5 = llvm.trunc %4 : i16 to i8 + %6 = llvm.trunc %arg0 : i16 to i8 + %7 = llvm.ashr %6, %1 : i8 + %8 = llvm.icmp "eq" %7, %5 : i8 + %9 = llvm.ashr %arg0, %2 : i16 + %10 = llvm.trunc %9 : i16 to i8 + %11 = llvm.xor %10, %3 : i8 + %12 = llvm.select %8, %6, %11 : i1, i8 + llvm.return %12 : i8 + } + llvm.func @testi64i32(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.constant(63 : i64) : i64 + %3 = llvm.mlir.constant(2147483647 : i32) : i32 + %4 = llvm.lshr %arg0, %0 : i64 + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.trunc %arg0 : i64 to i32 + %7 = llvm.ashr %6, %1 : i32 + %8 = llvm.icmp "eq" %7, %5 : i32 + %9 = llvm.ashr %arg0, %2 : i64 + %10 = llvm.trunc %9 : i64 to i32 + %11 = llvm.xor %10, %3 : i32 + %12 = llvm.select %8, %6, %11 : i1, i32 + llvm.return %12 : i32 + } + llvm.func @testi32i16i8(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(256 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(127 : i16) : i16 + %4 = llvm.mlir.constant(-128 : i16) : i16 + %5 = llvm.add %arg0, %0 : i32 + %6 = llvm.icmp "ult" %5, %1 : i32 + %7 = llvm.trunc %arg0 : i32 to i16 + %8 = llvm.icmp "sgt" %arg0, %2 : i32 + %9 = llvm.select %8, %3, %4 : i1, i16 + %10 = llvm.select %6, %7, %9 : i1, i16 + llvm.return %10 : i16 + } + llvm.func @testv4i32i16i8(%arg0: vector<4xi32>) -> vector<4xi16> { + %0 = llvm.mlir.constant(dense<128> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<256> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %3 = llvm.mlir.constant(dense<127> : vector<4xi16>) : vector<4xi16> + %4 = llvm.mlir.constant(dense<-128> : vector<4xi16>) : vector<4xi16> + %5 = llvm.add %arg0, %0 : vector<4xi32> + %6 = llvm.icmp "ult" %5, %1 : vector<4xi32> + %7 = llvm.trunc %arg0 : vector<4xi32> to vector<4xi16> + %8 = llvm.icmp "sgt" %arg0, %2 : vector<4xi32> + %9 = llvm.select %8, %3, %4 : vector<4xi1>, vector<4xi16> + %10 = llvm.select %6, %7, %9 : vector<4xi1>, vector<4xi16> + llvm.return %10 : vector<4xi16> + } + llvm.func @testi32i32i8(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(256 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.mlir.constant(127 : i32) : i32 + %4 = llvm.mlir.constant(-128 : i32) : i32 + %5 = llvm.add %arg0, %0 : i32 + %6 = llvm.icmp "ult" %5, %1 : i32 + %7 = llvm.icmp "sgt" %arg0, %2 : i32 + %8 = llvm.select %7, %3, %4 : i1, i32 + %9 = llvm.select %6, %arg0, %8 : i1, i32 + llvm.return %9 : i32 + } + llvm.func @test_truncfirst(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(128 : i16) : i16 + %1 = llvm.mlir.constant(256 : i16) : i16 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.mlir.constant(127 : i16) : i16 + %4 = llvm.mlir.constant(-128 : i16) : i16 + %5 = llvm.trunc %arg0 : i32 to i16 + %6 = llvm.add %5, %0 : i16 + %7 = llvm.icmp "ult" %6, %1 : i16 + %8 = llvm.icmp "sgt" %5, %2 : i16 + %9 = llvm.select %8, %3, %4 : i1, i16 + %10 = llvm.select %7, %5, %9 : i1, i16 + llvm.return %10 : i16 + } + llvm.func @testtrunclowhigh(%arg0: i32, %arg1: i16, %arg2: i16) -> i16 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(256 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = llvm.icmp "ult" %3, %1 : i32 + %5 = llvm.trunc %arg0 : i32 to i16 + %6 = llvm.icmp "sgt" %arg0, %2 : i32 + %7 = llvm.select %6, %arg2, %arg1 : i1, i16 + %8 = llvm.select %4, %5, %7 : i1, i16 + llvm.return %8 : i16 + } + llvm.func @testi64i32addsat(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.constant(63 : i64) : i64 + %3 = llvm.mlir.constant(2147483647 : i32) : i32 + %4 = llvm.sext %arg0 : i32 to i64 + %5 = llvm.sext %arg1 : i32 to i64 + %6 = llvm.add %4, %5 : i64 + %7 = llvm.lshr %6, %0 : i64 + %8 = llvm.trunc %7 : i64 to i32 + %9 = llvm.trunc %6 : i64 to i32 + %10 = llvm.ashr %9, %1 : i32 + %11 = llvm.icmp "eq" %10, %8 : i32 + %12 = llvm.ashr %6, %2 : i64 + %13 = llvm.trunc %12 : i64 to i32 + %14 = llvm.xor %13, %3 : i32 + %15 = llvm.select %11, %9, %14 : i1, i32 + llvm.return %15 : i32 + } + llvm.func @testv4i16i8(%arg0: vector<4xi16>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi16>) : vector<4xi16> + %1 = llvm.mlir.constant(dense<7> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(dense<15> : vector<4xi16>) : vector<4xi16> + %3 = llvm.mlir.constant(dense<127> : vector<4xi8>) : vector<4xi8> + %4 = llvm.lshr %arg0, %0 : vector<4xi16> + %5 = llvm.trunc %4 : vector<4xi16> to vector<4xi8> + %6 = llvm.trunc %arg0 : vector<4xi16> to vector<4xi8> + %7 = llvm.ashr %6, %1 : vector<4xi8> + %8 = llvm.icmp "eq" %7, %5 : vector<4xi8> + %9 = llvm.ashr %arg0, %2 : vector<4xi16> + %10 = llvm.trunc %9 : vector<4xi16> to vector<4xi8> + %11 = llvm.xor %10, %3 : vector<4xi8> + %12 = llvm.select %8, %6, %11 : vector<4xi1>, vector<4xi8> + llvm.return %12 : vector<4xi8> + } + llvm.func @testv4i16i8add(%arg0: vector<4xi8>, %arg1: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi16>) : vector<4xi16> + %1 = llvm.mlir.constant(dense<7> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(dense<15> : vector<4xi16>) : vector<4xi16> + %3 = llvm.mlir.constant(dense<127> : vector<4xi8>) : vector<4xi8> + %4 = llvm.sext %arg0 : vector<4xi8> to vector<4xi16> + %5 = llvm.sext %arg1 : vector<4xi8> to vector<4xi16> + %6 = llvm.add %4, %5 : vector<4xi16> + %7 = llvm.lshr %6, %0 : vector<4xi16> + %8 = llvm.trunc %7 : vector<4xi16> to vector<4xi8> + %9 = llvm.trunc %6 : vector<4xi16> to vector<4xi8> + %10 = llvm.ashr %9, %1 : vector<4xi8> + %11 = llvm.icmp "eq" %10, %8 : vector<4xi8> + %12 = llvm.ashr %6, %2 : vector<4xi16> + %13 = llvm.trunc %12 : vector<4xi16> to vector<4xi8> + %14 = llvm.xor %13, %3 : vector<4xi8> + %15 = llvm.select %11, %9, %14 : vector<4xi1>, vector<4xi8> + llvm.return %15 : vector<4xi8> + } + llvm.func @testi16i8_revcmp(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(15 : i16) : i16 + %3 = llvm.mlir.constant(127 : i8) : i8 + %4 = llvm.lshr %arg0, %0 : i16 + %5 = llvm.trunc %4 : i16 to i8 + %6 = llvm.trunc %arg0 : i16 to i8 + %7 = llvm.ashr %6, %1 : i8 + %8 = llvm.icmp "eq" %5, %7 : i8 + %9 = llvm.ashr %arg0, %2 : i16 + %10 = llvm.trunc %9 : i16 to i8 + %11 = llvm.xor %10, %3 : i8 + %12 = llvm.select %8, %6, %11 : i1, i8 + llvm.return %12 : i8 + } + llvm.func @testi16i8_revselect(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(15 : i16) : i16 + %3 = llvm.mlir.constant(127 : i8) : i8 + %4 = llvm.lshr %arg0, %0 : i16 + %5 = llvm.trunc %4 : i16 to i8 + %6 = llvm.trunc %arg0 : i16 to i8 + %7 = llvm.ashr %6, %1 : i8 + %8 = llvm.icmp "ne" %5, %7 : i8 + %9 = llvm.ashr %arg0, %2 : i16 + %10 = llvm.trunc %9 : i16 to i8 + %11 = llvm.xor %10, %3 : i8 + %12 = llvm.select %8, %11, %6 : i1, i8 + llvm.return %12 : i8 + } + llvm.func @testi32i8(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(8 : i32) : i32 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(15 : i32) : i32 + %3 = llvm.mlir.constant(127 : i8) : i8 + %4 = llvm.lshr %arg0, %0 : i32 + %5 = llvm.trunc %4 : i32 to i8 + %6 = llvm.trunc %arg0 : i32 to i8 + %7 = llvm.ashr %6, %1 : i8 + %8 = llvm.icmp "eq" %7, %5 : i8 + %9 = llvm.ashr %arg0, %2 : i32 + %10 = llvm.trunc %9 : i32 to i8 + %11 = llvm.xor %10, %3 : i8 + %12 = llvm.select %8, %6, %11 : i1, i8 + llvm.return %12 : i8 + } + llvm.func @differentconsts(%arg0: i32, %arg1: i16, %arg2: i16) -> i16 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(256 : i16) : i16 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.mlir.constant(16 : i32) : i32 + %4 = llvm.mlir.constant(144 : i32) : i32 + %5 = llvm.icmp "slt" %arg0, %0 : i32 + %6 = llvm.select %5, %1, %2 : i1, i16 + %7 = llvm.add %arg0, %3 : i32 + %8 = llvm.icmp "ult" %7, %4 : i32 + %9 = llvm.trunc %arg0 : i32 to i16 + %10 = llvm.select %8, %9, %6 : i1, i16 + llvm.return %10 : i16 + } + llvm.func @badimm1(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(9 : i16) : i16 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(15 : i16) : i16 + %3 = llvm.mlir.constant(127 : i8) : i8 + %4 = llvm.lshr %arg0, %0 : i16 + %5 = llvm.trunc %4 : i16 to i8 + %6 = llvm.trunc %arg0 : i16 to i8 + %7 = llvm.ashr %6, %1 : i8 + %8 = llvm.icmp "eq" %7, %5 : i8 + %9 = llvm.ashr %arg0, %2 : i16 + %10 = llvm.trunc %9 : i16 to i8 + %11 = llvm.xor %10, %3 : i8 + %12 = llvm.select %8, %6, %11 : i1, i8 + llvm.return %12 : i8 + } + llvm.func @badimm2(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(6 : i8) : i8 + %2 = llvm.mlir.constant(15 : i16) : i16 + %3 = llvm.mlir.constant(127 : i8) : i8 + %4 = llvm.lshr %arg0, %0 : i16 + %5 = llvm.trunc %4 : i16 to i8 + %6 = llvm.trunc %arg0 : i16 to i8 + %7 = llvm.ashr %6, %1 : i8 + %8 = llvm.icmp "eq" %7, %5 : i8 + %9 = llvm.ashr %arg0, %2 : i16 + %10 = llvm.trunc %9 : i16 to i8 + %11 = llvm.xor %10, %3 : i8 + %12 = llvm.select %8, %6, %11 : i1, i8 + llvm.return %12 : i8 + } + llvm.func @badimm3(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(14 : i16) : i16 + %3 = llvm.mlir.constant(127 : i8) : i8 + %4 = llvm.lshr %arg0, %0 : i16 + %5 = llvm.trunc %4 : i16 to i8 + %6 = llvm.trunc %arg0 : i16 to i8 + %7 = llvm.ashr %6, %1 : i8 + %8 = llvm.icmp "eq" %7, %5 : i8 + %9 = llvm.ashr %arg0, %2 : i16 + %10 = llvm.trunc %9 : i16 to i8 + %11 = llvm.xor %10, %3 : i8 + %12 = llvm.select %8, %6, %11 : i1, i8 + llvm.return %12 : i8 + } + llvm.func @badimm4(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(8 : i16) : i16 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(15 : i16) : i16 + %3 = llvm.mlir.constant(126 : i8) : i8 + %4 = llvm.lshr %arg0, %0 : i16 + %5 = llvm.trunc %4 : i16 to i8 + %6 = llvm.trunc %arg0 : i16 to i8 + %7 = llvm.ashr %6, %1 : i8 + %8 = llvm.icmp "eq" %7, %5 : i8 + %9 = llvm.ashr %arg0, %2 : i16 + %10 = llvm.trunc %9 : i16 to i8 + %11 = llvm.xor %10, %3 : i8 + %12 = llvm.select %8, %6, %11 : i1, i8 + llvm.return %12 : i8 + } + llvm.func @oneusexor(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.constant(63 : i64) : i64 + %3 = llvm.mlir.constant(2147483647 : i32) : i32 + %4 = llvm.lshr %arg0, %0 : i64 + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.trunc %arg0 : i64 to i32 + %7 = llvm.ashr %6, %1 : i32 + %8 = llvm.icmp "eq" %7, %5 : i32 + %9 = llvm.ashr %arg0, %2 : i64 + %10 = llvm.trunc %9 : i64 to i32 + %11 = llvm.xor %10, %3 : i32 + %12 = llvm.select %8, %6, %11 : i1, i32 + llvm.call @use(%11) : (i32) -> () + llvm.return %12 : i32 + } + llvm.func @oneuseconv(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.constant(63 : i64) : i64 + %3 = llvm.mlir.constant(2147483647 : i32) : i32 + %4 = llvm.lshr %arg0, %0 : i64 + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.trunc %arg0 : i64 to i32 + %7 = llvm.ashr %6, %1 : i32 + %8 = llvm.icmp "eq" %7, %5 : i32 + %9 = llvm.ashr %arg0, %2 : i64 + %10 = llvm.trunc %9 : i64 to i32 + %11 = llvm.xor %10, %3 : i32 + %12 = llvm.select %8, %6, %11 : i1, i32 + llvm.call @use(%6) : (i32) -> () + llvm.return %12 : i32 + } + llvm.func @oneusecmp(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.constant(63 : i64) : i64 + %3 = llvm.mlir.constant(2147483647 : i32) : i32 + %4 = llvm.lshr %arg0, %0 : i64 + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.trunc %arg0 : i64 to i32 + %7 = llvm.ashr %6, %1 : i32 + %8 = llvm.icmp "eq" %7, %5 : i32 + %9 = llvm.ashr %arg0, %2 : i64 + %10 = llvm.trunc %9 : i64 to i32 + %11 = llvm.xor %10, %3 : i32 + %12 = llvm.select %8, %6, %11 : i1, i32 + llvm.call @use1(%8) : (i1) -> () + llvm.return %12 : i32 + } + llvm.func @oneuseboth(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.constant(63 : i64) : i64 + %3 = llvm.mlir.constant(2147483647 : i32) : i32 + %4 = llvm.lshr %arg0, %0 : i64 + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.trunc %arg0 : i64 to i32 + %7 = llvm.ashr %6, %1 : i32 + %8 = llvm.icmp "eq" %7, %5 : i32 + %9 = llvm.ashr %arg0, %2 : i64 + %10 = llvm.trunc %9 : i64 to i32 + %11 = llvm.xor %10, %3 : i32 + %12 = llvm.select %8, %6, %11 : i1, i32 + llvm.call @use(%11) : (i32) -> () + llvm.call @use(%6) : (i32) -> () + llvm.return %12 : i32 + } + llvm.func @oneusethree(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(32 : i64) : i64 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.mlir.constant(63 : i64) : i64 + %3 = llvm.mlir.constant(2147483647 : i32) : i32 + %4 = llvm.lshr %arg0, %0 : i64 + %5 = llvm.trunc %4 : i64 to i32 + %6 = llvm.trunc %arg0 : i64 to i32 + %7 = llvm.ashr %6, %1 : i32 + %8 = llvm.icmp "eq" %7, %5 : i32 + %9 = llvm.ashr %arg0, %2 : i64 + %10 = llvm.trunc %9 : i64 to i32 + %11 = llvm.xor %10, %3 : i32 + %12 = llvm.select %8, %6, %11 : i1, i32 + llvm.call @use(%11) : (i32) -> () + llvm.call @use(%6) : (i32) -> () + llvm.call @use1(%8) : (i1) -> () + llvm.return %12 : i32 + } + llvm.func @differentconsts_usetrunc(%arg0: i32, %arg1: i16, %arg2: i16) -> i16 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(256 : i16) : i16 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.mlir.constant(16 : i32) : i32 + %4 = llvm.mlir.constant(144 : i32) : i32 + %5 = llvm.icmp "slt" %arg0, %0 : i32 + %6 = llvm.select %5, %1, %2 : i1, i16 + %7 = llvm.add %arg0, %3 : i32 + %8 = llvm.icmp "ult" %7, %4 : i32 + %9 = llvm.trunc %arg0 : i32 to i16 + %10 = llvm.select %8, %9, %6 : i1, i16 + llvm.call @use16(%9) : (i16) -> () + llvm.return %10 : i16 + } + llvm.func @differentconsts_useadd(%arg0: i32, %arg1: i16, %arg2: i16) -> i16 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(256 : i16) : i16 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.mlir.constant(16 : i32) : i32 + %4 = llvm.mlir.constant(144 : i32) : i32 + %5 = llvm.icmp "slt" %arg0, %0 : i32 + %6 = llvm.select %5, %1, %2 : i1, i16 + %7 = llvm.add %arg0, %3 : i32 + %8 = llvm.icmp "ult" %7, %4 : i32 + %9 = llvm.trunc %arg0 : i32 to i16 + %10 = llvm.select %8, %9, %6 : i1, i16 + llvm.call @use(%7) : (i32) -> () + llvm.return %10 : i16 + } + llvm.func @differentconsts_useaddtrunc(%arg0: i32, %arg1: i16, %arg2: i16) -> i16 { + %0 = llvm.mlir.constant(128 : i32) : i32 + %1 = llvm.mlir.constant(256 : i16) : i16 + %2 = llvm.mlir.constant(-1 : i16) : i16 + %3 = llvm.mlir.constant(16 : i32) : i32 + %4 = llvm.mlir.constant(144 : i32) : i32 + %5 = llvm.icmp "slt" %arg0, %0 : i32 + %6 = llvm.select %5, %1, %2 : i1, i16 + %7 = llvm.add %arg0, %3 : i32 + %8 = llvm.icmp "ult" %7, %4 : i32 + %9 = llvm.trunc %arg0 : i32 to i16 + %10 = llvm.select %8, %9, %6 : i1, i16 + llvm.call @use16(%9) : (i16) -> () + llvm.call @use(%7) : (i32) -> () + llvm.return %10 : i16 + } + llvm.func @C0zero(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.mlir.constant(10 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(-10 : i8) : i8 + %3 = llvm.add %arg0, %0 : i8 + %4 = llvm.icmp "ult" %3, %1 : i8 + %5 = llvm.icmp "slt" %arg0, %2 : i8 + %6 = llvm.select %5, %arg1, %arg2 : i1, i8 + %7 = llvm.select %4, %arg0, %6 : i1, i8 + llvm.return %7 : i8 + } + llvm.func @C0zeroV(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.mlir.constant(dense<-10> : vector<2xi8>) : vector<2xi8> + %4 = llvm.add %arg0, %0 : vector<2xi8> + %5 = llvm.icmp "ult" %4, %2 : vector<2xi8> + %6 = llvm.icmp "slt" %arg0, %3 : vector<2xi8> + %7 = llvm.select %6, %arg1, %arg2 : vector<2xi1>, vector<2xi8> + %8 = llvm.select %5, %arg0, %7 : vector<2xi1>, vector<2xi8> + llvm.return %8 : vector<2xi8> + } + llvm.func @C0zeroVu(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<10> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<[0, 10]> : vector<2xi8>) : vector<2xi8> + %2 = llvm.mlir.constant(dense<-10> : vector<2xi8>) : vector<2xi8> + %3 = llvm.add %arg0, %0 : vector<2xi8> + %4 = llvm.icmp "ult" %3, %1 : vector<2xi8> + %5 = llvm.icmp "slt" %arg0, %2 : vector<2xi8> + %6 = llvm.select %5, %arg1, %arg2 : vector<2xi1>, vector<2xi8> + %7 = llvm.select %4, %arg0, %6 : vector<2xi1>, vector<2xi8> + llvm.return %7 : vector<2xi8> + } + llvm.func @f(%arg0: i32, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(256 : i32) : i32 + %3 = llvm.icmp "slt" %arg0, %0 : i32 + %4 = llvm.select %3, %arg1, %1 : i1, i8 + %5 = llvm.icmp "ult" %arg0, %2 : i32 + %6 = llvm.trunc %arg0 : i32 to i8 + %7 = llvm.select %5, %6, %4 : i1, i8 + llvm.return %7 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/type_pun-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/type_pun-inseltpoison.ll.mlir new file mode 100644 index 000000000..118c308ec --- /dev/null +++ b/test/LLVMDialect/InstCombine/type_pun-inseltpoison.ll.mlir @@ -0,0 +1,68 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @type_pun_zeroth(%arg0: vector<16xi8>) -> i32 { + %0 = llvm.mlir.poison : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.return %2 : i32 + } + llvm.func @type_pun_first(%arg0: vector<16xi8>) -> i32 { + %0 = llvm.mlir.poison : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [4, 5, 6, 7] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.return %2 : i32 + } + llvm.func @type_pun_misaligned(%arg0: vector<16xi8>) -> i32 { + %0 = llvm.mlir.poison : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [6, 7, 8, 9] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.return %2 : i32 + } + llvm.func @type_pun_pointer(%arg0: vector<16xi8>) -> !llvm.ptr { + %0 = llvm.mlir.poison : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + %3 = llvm.inttoptr %2 : i32 to !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @type_pun_float(%arg0: vector<16xi8>) -> f32 { + %0 = llvm.mlir.poison : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to f32 + llvm.return %2 : f32 + } + llvm.func @type_pun_double(%arg0: vector<16xi8>) -> f64 { + %0 = llvm.mlir.poison : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3, 4, 5, 6, 7] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<8xi8> to f64 + llvm.return %2 : f64 + } + llvm.func @type_pun_float_i32(%arg0: vector<16xi8>) -> !llvm.struct<(f32, i32)> { + %0 = llvm.mlir.poison : vector<16xi8> + %1 = llvm.mlir.poison : !llvm.struct<(f32, i32)> + %2 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3] : vector<16xi8> + %3 = llvm.bitcast %2 : vector<4xi8> to f32 + %4 = llvm.bitcast %2 : vector<4xi8> to i32 + %5 = llvm.insertvalue %3, %1[0] : !llvm.struct<(f32, i32)> + %6 = llvm.insertvalue %4, %5[1] : !llvm.struct<(f32, i32)> + llvm.return %6 : !llvm.struct<(f32, i32)> + } + llvm.func @type_pun_i32_ctrl(%arg0: vector<16xi8>, %arg1: i1) -> i32 { + %0 = llvm.mlir.poison : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3] : vector<16xi8> + llvm.cond_br %arg1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.br ^bb3(%2 : i32) + ^bb2: // pred: ^bb0 + %3 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.br ^bb3(%3 : i32) + ^bb3(%4: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %4 : i32 + } + llvm.func @type_pun_unhandled(%arg0: vector<16xi8>) -> i40 { + %0 = llvm.mlir.poison : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [4, 5, 6, 7, 8] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<5xi8> to i40 + llvm.return %2 : i40 + } +} diff --git a/test/LLVMDialect/InstCombine/type_pun.ll.mlir b/test/LLVMDialect/InstCombine/type_pun.ll.mlir new file mode 100644 index 000000000..d47a50075 --- /dev/null +++ b/test/LLVMDialect/InstCombine/type_pun.ll.mlir @@ -0,0 +1,68 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @type_pun_zeroth(%arg0: vector<16xi8>) -> i32 { + %0 = llvm.mlir.undef : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.return %2 : i32 + } + llvm.func @type_pun_first(%arg0: vector<16xi8>) -> i32 { + %0 = llvm.mlir.undef : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [4, 5, 6, 7] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.return %2 : i32 + } + llvm.func @type_pun_misaligned(%arg0: vector<16xi8>) -> i32 { + %0 = llvm.mlir.undef : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [6, 7, 8, 9] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.return %2 : i32 + } + llvm.func @type_pun_pointer(%arg0: vector<16xi8>) -> !llvm.ptr { + %0 = llvm.mlir.undef : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + %3 = llvm.inttoptr %2 : i32 to !llvm.ptr + llvm.return %3 : !llvm.ptr + } + llvm.func @type_pun_float(%arg0: vector<16xi8>) -> f32 { + %0 = llvm.mlir.undef : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<4xi8> to f32 + llvm.return %2 : f32 + } + llvm.func @type_pun_double(%arg0: vector<16xi8>) -> f64 { + %0 = llvm.mlir.undef : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3, 4, 5, 6, 7] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<8xi8> to f64 + llvm.return %2 : f64 + } + llvm.func @type_pun_float_i32(%arg0: vector<16xi8>) -> !llvm.struct<(f32, i32)> { + %0 = llvm.mlir.undef : vector<16xi8> + %1 = llvm.mlir.undef : !llvm.struct<(f32, i32)> + %2 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3] : vector<16xi8> + %3 = llvm.bitcast %2 : vector<4xi8> to f32 + %4 = llvm.bitcast %2 : vector<4xi8> to i32 + %5 = llvm.insertvalue %3, %1[0] : !llvm.struct<(f32, i32)> + %6 = llvm.insertvalue %4, %5[1] : !llvm.struct<(f32, i32)> + llvm.return %6 : !llvm.struct<(f32, i32)> + } + llvm.func @type_pun_i32_ctrl(%arg0: vector<16xi8>, %arg1: i1) -> i32 { + %0 = llvm.mlir.undef : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [0, 1, 2, 3] : vector<16xi8> + llvm.cond_br %arg1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.br ^bb3(%2 : i32) + ^bb2: // pred: ^bb0 + %3 = llvm.bitcast %1 : vector<4xi8> to i32 + llvm.br ^bb3(%3 : i32) + ^bb3(%4: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %4 : i32 + } + llvm.func @type_pun_unhandled(%arg0: vector<16xi8>) -> i40 { + %0 = llvm.mlir.undef : vector<16xi8> + %1 = llvm.shufflevector %arg0, %0 [4, 5, 6, 7, 8] : vector<16xi8> + %2 = llvm.bitcast %1 : vector<5xi8> to i40 + llvm.return %2 : i40 + } +} diff --git a/test/LLVMDialect/InstCombine/uadd-with-overflow.ll.mlir b/test/LLVMDialect/InstCombine/uadd-with-overflow.ll.mlir new file mode 100644 index 000000000..3ecb1bf48 --- /dev/null +++ b/test/LLVMDialect/InstCombine/uadd-with-overflow.ll.mlir @@ -0,0 +1,98 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @simple_fold(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(13 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = "llvm.intr.uadd.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @fold_on_constant_add_no_overflow(%arg0: i8) -> !llvm.struct<(i8, i1)> { + %0 = llvm.mlir.constant(-56 : i8) : i8 + %1 = llvm.mlir.constant(55 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = "llvm.intr.uadd.with.overflow"(%2, %1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.return %3 : !llvm.struct<(i8, i1)> + } + llvm.func @no_fold_on_constant_add_overflow(%arg0: i8) -> !llvm.struct<(i8, i1)> { + %0 = llvm.mlir.constant(-56 : i8) : i8 + %1 = llvm.mlir.constant(56 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = "llvm.intr.uadd.with.overflow"(%2, %1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.return %3 : !llvm.struct<(i8, i1)> + } + llvm.func @no_fold_vector_no_overflow(%arg0: vector<2xi8>) -> !llvm.struct<(vector<2xi8>, vector<2xi1>)> { + %0 = llvm.mlir.constant(dense<[-57, -56]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<55> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = "llvm.intr.uadd.with.overflow"(%2, %1) : (vector<2xi8>, vector<2xi8>) -> !llvm.struct<(vector<2xi8>, vector<2xi1>)> + llvm.return %3 : !llvm.struct<(vector<2xi8>, vector<2xi1>)> + } + llvm.func @no_fold_vector_overflow(%arg0: vector<2xi8>) -> !llvm.struct<(vector<2xi8>, vector<2xi1>)> { + %0 = llvm.mlir.constant(dense<[-56, -55]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<55> : vector<2xi8>) : vector<2xi8> + %2 = llvm.add %arg0, %0 overflow : vector<2xi8> + %3 = "llvm.intr.uadd.with.overflow"(%2, %1) : (vector<2xi8>, vector<2xi8>) -> !llvm.struct<(vector<2xi8>, vector<2xi1>)> + llvm.return %3 : !llvm.struct<(vector<2xi8>, vector<2xi1>)> + } + llvm.func @fold_simple_splat_constant(%arg0: vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> { + %0 = llvm.mlir.constant(dense<12> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<30> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %arg0, %0 overflow : vector<2xi32> + %3 = "llvm.intr.uadd.with.overflow"(%2, %1) : (vector<2xi32>, vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> + llvm.return %3 : !llvm.struct<(vector<2xi32>, vector<2xi1>)> + } + llvm.func @no_fold_splat_undef_constant(%arg0: vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(12 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.mlir.constant(dense<30> : vector<2xi32>) : vector<2xi32> + %8 = llvm.add %arg0, %6 overflow : vector<2xi32> + %9 = "llvm.intr.uadd.with.overflow"(%8, %7) : (vector<2xi32>, vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> + llvm.return %9 : !llvm.struct<(vector<2xi32>, vector<2xi1>)> + } + llvm.func @no_fold_splat_not_constant(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> { + %0 = llvm.mlir.constant(dense<30> : vector<2xi32>) : vector<2xi32> + %1 = llvm.add %arg0, %arg1 overflow : vector<2xi32> + %2 = "llvm.intr.uadd.with.overflow"(%1, %0) : (vector<2xi32>, vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> + llvm.return %2 : !llvm.struct<(vector<2xi32>, vector<2xi1>)> + } + llvm.func @fold_nuwnsw(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = "llvm.intr.uadd.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @no_fold_nsw(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.add %arg0, %0 overflow : i32 + %3 = "llvm.intr.uadd.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @no_fold_wrapped_add(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = "llvm.intr.uadd.with.overflow"(%1, %2) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @fold_simple_splat_with_disjoint_or_constant(%arg0: vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> { + %0 = llvm.mlir.constant(dense<12> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<30> : vector<2xi32>) : vector<2xi32> + %2 = llvm.or %arg0, %0 : vector<2xi32> + %3 = "llvm.intr.uadd.with.overflow"(%2, %1) : (vector<2xi32>, vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> + llvm.return %3 : !llvm.struct<(vector<2xi32>, vector<2xi1>)> + } + llvm.func @fold_simple_splat_constant_with_or_fail(%arg0: vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> { + %0 = llvm.mlir.constant(dense<12> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<30> : vector<2xi32>) : vector<2xi32> + %2 = llvm.or %arg0, %0 : vector<2xi32> + %3 = "llvm.intr.uadd.with.overflow"(%2, %1) : (vector<2xi32>, vector<2xi32>) -> !llvm.struct<(vector<2xi32>, vector<2xi1>)> + llvm.return %3 : !llvm.struct<(vector<2xi32>, vector<2xi1>)> + } +} diff --git a/test/LLVMDialect/InstCombine/uaddo.ll.mlir b/test/LLVMDialect/InstCombine/uaddo.ll.mlir new file mode 100644 index 000000000..1ff33a7dd --- /dev/null +++ b/test/LLVMDialect/InstCombine/uaddo.ll.mlir @@ -0,0 +1,96 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @uaddo_commute1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.add %arg0, %arg1 : i32 + %3 = llvm.icmp "ugt" %arg0, %1 : i32 + %4 = llvm.select %3, %arg2, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uaddo_commute2(%arg0: vector<2xi32>, %arg1: vector<2xi32>, %arg2: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.xor %arg1, %0 : vector<2xi32> + %2 = llvm.add %arg1, %arg0 : vector<2xi32> + %3 = llvm.icmp "ugt" %arg0, %1 : vector<2xi32> + %4 = llvm.select %3, %arg2, %2 : vector<2xi1>, vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @uaddo_commute3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.add %arg0, %arg1 : i32 + %3 = llvm.icmp "ult" %1, %arg0 : i32 + %4 = llvm.select %3, %arg2, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uaddo_commute4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.add %arg1, %arg0 : i32 + %3 = llvm.icmp "ult" %1, %arg0 : i32 + %4 = llvm.select %3, %arg2, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uaddo_commute5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.add %arg0, %arg1 : i32 + %3 = llvm.icmp "ugt" %arg0, %1 : i32 + %4 = llvm.select %3, %2, %arg2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uaddo_commute6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.add %arg1, %arg0 : i32 + %3 = llvm.icmp "ugt" %arg0, %1 : i32 + %4 = llvm.select %3, %2, %arg2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uaddo_commute7(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.add %arg0, %arg1 : i32 + %3 = llvm.icmp "ult" %1, %arg0 : i32 + %4 = llvm.select %3, %2, %arg2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uaddo_commute8(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.add %arg1, %arg0 : i32 + %3 = llvm.icmp "ult" %1, %arg0 : i32 + %4 = llvm.select %3, %2, %arg2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uaddo_wrong_pred1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.add %arg0, %arg1 : i32 + %3 = llvm.icmp "ult" %arg0, %1 : i32 + %4 = llvm.select %3, %arg2, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uaddo_wrong_pred2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.add %arg0, %arg1 : i32 + %3 = llvm.icmp "uge" %arg0, %1 : i32 + %4 = llvm.select %3, %arg2, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @uaddo_1(%arg0: i8, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + llvm.store %1, %arg1 {alignment = 1 : i64} : i8, !llvm.ptr + %2 = llvm.icmp "ult" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @uaddo_neg1(%arg0: i8, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + llvm.store %1, %arg1 {alignment = 1 : i64} : i8, !llvm.ptr + %2 = llvm.icmp "ne" %1, %0 : i8 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/uaddo2.ll.mlir b/test/LLVMDialect/InstCombine/uaddo2.ll.mlir new file mode 100644 index 000000000..77948e733 --- /dev/null +++ b/test/LLVMDialect/InstCombine/uaddo2.ll.mlir @@ -0,0 +1,55 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_generic(%arg0: i64, %arg1: i64) -> i1 { + %0 = "llvm.intr.uadd.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i64, i1)> + llvm.return %1 : i1 + } + llvm.func @test_constant0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant127(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant128(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant255(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/ucmp.ll.mlir b/test/LLVMDialect/InstCombine/ucmp.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/udiv-pow2-vscale-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/udiv-pow2-vscale-inseltpoison.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/udiv-pow2-vscale.ll.mlir b/test/LLVMDialect/InstCombine/udiv-pow2-vscale.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/udiv-simplify.ll.mlir b/test/LLVMDialect/InstCombine/udiv-simplify.ll.mlir index aa72ac987..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/udiv-simplify.ll.mlir +++ b/test/LLVMDialect/InstCombine/udiv-simplify.ll.mlir @@ -1,83 +0,0 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "b", type = !llvm.array<1 x i16>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.udiv"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.sext"(%3) : (i32) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %2 = "llvm.lshr"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.udiv"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.sext"(%3) : (i32) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 30 : i32} : () -> i32 - %1 = "llvm.lshr"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.udiv"(%1, %arg1) : (i32, i32) -> i32 - %3 = "llvm.sext"(%2) : (i32) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test1_PR2274", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 31 : i32} : () -> i32 - %1 = "llvm.lshr"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.udiv"(%1, %arg1) : (i32, i32) -> i32 - %3 = "llvm.sext"(%2) : (i32) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test2_PR2274", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i1): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @b} : () -> !llvm.ptr> - %1 = "llvm.ptrtoint"(%0) : (!llvm.ptr>) -> i16 - %2 = "llvm.mlir.constant"() {value = 1 : i16} : () -> i16 - %3 = "llvm.shl"(%2, %1) : (i16, i16) -> i16 - %4 = "llvm.zext"(%3) : (i16) -> i32 - %5 = "llvm.zext"(%arg0) : (i1) -> i32 - %6 = "llvm.udiv"(%5, %4) : (i32, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "PR30366", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i177, %arg1: i177): // no predecessors - %0 = "llvm.mlir.undef"() : () -> !llvm.ptr - %1 = "llvm.mlir.constant"() {value = -1 : i177} : () -> i177 - %2 = "llvm.udiv"(%arg1, %1) : (i177, i177) -> i177 - %3 = "llvm.add"(%2, %1) : (i177, i177) -> i177 - %4 = "llvm.add"(%3, %1) : (i177, i177) -> i177 - %5 = "llvm.mul"(%2, %4) : (i177, i177) -> i177 - %6 = "llvm.add"(%4, %4) : (i177, i177) -> i177 - %7 = "llvm.xor"(%3, %6) : (i177, i177) -> i177 - %8 = "llvm.ashr"(%arg1, %4) : (i177, i177) -> i177 - %9 = "llvm.add"(%7, %8) : (i177, i177) -> i177 - %10 = "llvm.udiv"(%2, %5) : (i177, i177) -> i177 - %11 = "llvm.icmp"(%arg1, %9) {predicate = 6 : i64} : (i177, i177) -> i1 - "llvm.store"(%11, %0) : (i1, !llvm.ptr) -> () - "llvm.return"(%10) : (i177) -> () - }) {linkage = 10 : i64, sym_name = "ossfuzz_4857", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 12 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 3 : i32} : () -> i32 - %2 = "llvm.or"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.udiv"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "udiv_demanded", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 12 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -3 : i32} : () -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.udiv"(%2, %0) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "udiv_exact_demanded", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/udiv_select_to_select_shift.ll.mlir b/test/LLVMDialect/InstCombine/udiv_select_to_select_shift.ll.mlir new file mode 100644 index 000000000..3e6ad2929 --- /dev/null +++ b/test/LLVMDialect/InstCombine/udiv_select_to_select_shift.ll.mlir @@ -0,0 +1,25 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: i64, %arg1: i1) -> i64 { + %0 = llvm.mlir.constant(16 : i64) : i64 + %1 = llvm.mlir.constant(8 : i64) : i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.select %arg1, %0, %1 : i1, i64 + %4 = llvm.udiv %arg0, %3 : i64 + %5 = llvm.select %arg1, %1, %2 : i1, i64 + %6 = llvm.udiv %arg0, %5 : i64 + %7 = llvm.add %4, %6 : i64 + llvm.return %7 : i64 + } + llvm.func @PR34856(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<-7> : vector<2xi32>) : vector<2xi32> + %4 = llvm.icmp "eq" %arg0, %0 : vector<2xi32> + %5 = llvm.zext %4 : vector<2xi1> to vector<2xi32> + %6 = llvm.select %4, %2, %3 : vector<2xi1>, vector<2xi32> + %7 = llvm.udiv %arg1, %6 : vector<2xi32> + %8 = llvm.add %7, %5 : vector<2xi32> + llvm.return %8 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/udivrem-change-width.ll.mlir b/test/LLVMDialect/InstCombine/udivrem-change-width.ll.mlir index bc4a56242..6cb9a2d1a 100644 --- a/test/LLVMDialect/InstCombine/udivrem-change-width.ll.mlir +++ b/test/LLVMDialect/InstCombine/udivrem-change-width.ll.mlir @@ -1,222 +1,189 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "b", type = !llvm.array<1 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "g1", type = !llvm.array<1 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "g2", type = !llvm.array<1 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "g3", type = !llvm.array<1 x i8>} : () -> () - "llvm.mlir.global"() ( { - }) {linkage = 10 : i64, sym_name = "g4", type = !llvm.array<1 x i8>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.udiv"(%0, %1) : (i32, i32) -> i32 - %3 = "llvm.trunc"(%2) : (i32) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "udiv_i8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi32> - %1 = "llvm.zext"(%arg1) : (vector<2xi8>) -> vector<2xi32> - %2 = "llvm.udiv"(%0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.trunc"(%2) : (vector<2xi32>) -> vector<2xi8> - "llvm.return"(%3) : (vector<2xi8>) -> () - }) {linkage = 10 : i64, sym_name = "udiv_i8_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.urem"(%0, %1) : (i32, i32) -> i32 - %3 = "llvm.trunc"(%2) : (i32) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "urem_i8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi32> - %1 = "llvm.zext"(%arg1) : (vector<2xi8>) -> vector<2xi32> - %2 = "llvm.urem"(%0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.trunc"(%2) : (vector<2xi32>) -> vector<2xi8> - "llvm.return"(%3) : (vector<2xi8>) -> () - }) {linkage = 10 : i64, sym_name = "urem_i8_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.udiv"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "udiv_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi32> - %1 = "llvm.zext"(%arg1) : (vector<2xi8>) -> vector<2xi32> - %2 = "llvm.udiv"(%0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "udiv_i32_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.udiv"(%0, %1) : (i32, i32) -> i32 - %3 = "llvm.add"(%0, %1) : (i32, i32) -> i32 - %4 = "llvm.mul"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "udiv_i32_multiuse", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i9, %arg1: i9): // no predecessors - %0 = "llvm.zext"(%arg0) : (i9) -> i32 - %1 = "llvm.zext"(%arg1) : (i9) -> i32 - %2 = "llvm.udiv"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "udiv_illegal_type", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.urem"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "urem_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi32> - %1 = "llvm.zext"(%arg1) : (vector<2xi8>) -> vector<2xi32> - %2 = "llvm.urem"(%0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "urem_i32_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.zext"(%arg0) : (i8) -> i32 - %1 = "llvm.zext"(%arg1) : (i8) -> i32 - %2 = "llvm.urem"(%0, %1) : (i32, i32) -> i32 - %3 = "llvm.add"(%0, %1) : (i32, i32) -> i32 - %4 = "llvm.mul"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "urem_i32_multiuse", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i9, %arg1: i9): // no predecessors - %0 = "llvm.zext"(%arg0) : (i9) -> i32 - %1 = "llvm.zext"(%arg1) : (i9) -> i32 - %2 = "llvm.urem"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "urem_illegal_type", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i8) -> i32 - %2 = "llvm.udiv"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "udiv_i32_c", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[10, 17]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi32> - %2 = "llvm.udiv"(%1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "udiv_i32_c_vec", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i8) -> i32 - %2 = "llvm.udiv"(%1, %0) : (i32, i32) -> i32 - %3 = "llvm.add"(%1, %2) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "udiv_i32_c_multiuse", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i9): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i9) -> i32 - %2 = "llvm.udiv"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "udiv_illegal_type_c", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i8) -> i32 - %2 = "llvm.urem"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "urem_i32_c", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[10, 17]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi32> - %2 = "llvm.urem"(%1, %0) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - "llvm.return"(%2) : (vector<2xi32>) -> () - }) {linkage = 10 : i64, sym_name = "urem_i32_c_vec", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i8) -> i32 - %2 = "llvm.urem"(%1, %0) : (i32, i32) -> i32 - %3 = "llvm.add"(%1, %2) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "urem_i32_c_multiuse", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i9): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i9) -> i32 - %2 = "llvm.urem"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "urem_illegal_type_c", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i8) -> i32 - %2 = "llvm.udiv"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "udiv_c_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 10 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i8) -> i32 - %2 = "llvm.urem"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "urem_c_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @b} : () -> !llvm.ptr> - %1 = "llvm.ptrtoint"(%0) : (!llvm.ptr>) -> i8 - %2 = "llvm.zext"(%1) : (i8) -> i32 - %3 = "llvm.zext"(%arg0) : (i8) -> i32 - %4 = "llvm.udiv"(%3, %2) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "udiv_constexpr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @g1} : () -> !llvm.ptr> - %1 = "llvm.ptrtoint"(%0) : (!llvm.ptr>) -> i8 - %2 = "llvm.zext"(%1) : (i8) -> i32 - %3 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %4 = "llvm.udiv"(%3, %2) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "udiv_const_constexpr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.addressof"() {global_name = @g2} : () -> !llvm.ptr> - %1 = "llvm.ptrtoint"(%0) : (!llvm.ptr>) -> i8 - %2 = "llvm.zext"(%1) : (i8) -> i32 - %3 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %4 = "llvm.urem"(%3, %2) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "urem_const_constexpr", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @g3} : () -> !llvm.ptr> - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr>) -> i8 - %3 = "llvm.zext"(%2) : (i8) -> i32 - %4 = "llvm.udiv"(%3, %0) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "udiv_constexpr_const", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 42 : i32} : () -> i32 - %1 = "llvm.mlir.addressof"() {global_name = @g4} : () -> !llvm.ptr> - %2 = "llvm.ptrtoint"(%1) : (!llvm.ptr>) -> i8 - %3 = "llvm.zext"(%2) : (i8) -> i32 - %4 = "llvm.urem"(%3, %0) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "urem_constexpr_const", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @b() {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external @g1() {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external @g2() {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external @g3() {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.mlir.global external @g4() {addr_space = 0 : i32} : !llvm.array<1 x i8> + llvm.func @udiv_i8(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.udiv %0, %1 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @udiv_i8_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + %1 = llvm.zext %arg1 : vector<2xi8> to vector<2xi32> + %2 = llvm.udiv %0, %1 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @urem_i8(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.urem %0, %1 : i32 + %3 = llvm.trunc %2 : i32 to i8 + llvm.return %3 : i8 + } + llvm.func @urem_i8_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + %1 = llvm.zext %arg1 : vector<2xi8> to vector<2xi32> + %2 = llvm.urem %0, %1 : vector<2xi32> + %3 = llvm.trunc %2 : vector<2xi32> to vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @udiv_i32(%arg0: i8, %arg1: i8) -> i32 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.udiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @udiv_i32_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi32> { + %0 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + %1 = llvm.zext %arg1 : vector<2xi8> to vector<2xi32> + %2 = llvm.udiv %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @udiv_i32_multiuse(%arg0: i8, %arg1: i8) -> i32 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.udiv %0, %1 : i32 + %3 = llvm.add %0, %1 : i32 + %4 = llvm.mul %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @udiv_illegal_type(%arg0: i9, %arg1: i9) -> i32 { + %0 = llvm.zext %arg0 : i9 to i32 + %1 = llvm.zext %arg1 : i9 to i32 + %2 = llvm.udiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @urem_i32(%arg0: i8, %arg1: i8) -> i32 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.urem %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @urem_i32_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi32> { + %0 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + %1 = llvm.zext %arg1 : vector<2xi8> to vector<2xi32> + %2 = llvm.urem %0, %1 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @urem_i32_multiuse(%arg0: i8, %arg1: i8) -> i32 { + %0 = llvm.zext %arg0 : i8 to i32 + %1 = llvm.zext %arg1 : i8 to i32 + %2 = llvm.urem %0, %1 : i32 + %3 = llvm.add %0, %1 : i32 + %4 = llvm.mul %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @urem_illegal_type(%arg0: i9, %arg1: i9) -> i32 { + %0 = llvm.zext %arg0 : i9 to i32 + %1 = llvm.zext %arg1 : i9 to i32 + %2 = llvm.urem %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @udiv_i32_c(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.udiv %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @udiv_i32_c_vec(%arg0: vector<2xi8>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[10, 17]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.udiv %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @udiv_i32_c_multiuse(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.udiv %1, %0 : i32 + %3 = llvm.add %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @udiv_illegal_type_c(%arg0: i9) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.zext %arg0 : i9 to i32 + %2 = llvm.udiv %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @urem_i32_c(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.urem %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @urem_i32_c_vec(%arg0: vector<2xi8>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[10, 17]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi8> to vector<2xi32> + %2 = llvm.urem %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @urem_i32_c_multiuse(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.urem %1, %0 : i32 + %3 = llvm.add %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @urem_illegal_type_c(%arg0: i9) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.zext %arg0 : i9 to i32 + %2 = llvm.urem %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @udiv_c_i32(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.udiv %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @urem_c_i32(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.urem %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @udiv_constexpr(%arg0: i8) -> i32 { + %0 = llvm.mlir.addressof @b : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i8 + %2 = llvm.zext %arg0 : i8 to i32 + %3 = llvm.zext %1 : i8 to i32 + %4 = llvm.udiv %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @udiv_const_constexpr(%arg0: i8) -> i32 { + %0 = llvm.mlir.addressof @g1 : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i8 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.zext %1 : i8 to i32 + %4 = llvm.udiv %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @urem_const_constexpr(%arg0: i8) -> i32 { + %0 = llvm.mlir.addressof @g2 : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i8 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.zext %1 : i8 to i32 + %4 = llvm.urem %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @udiv_constexpr_const(%arg0: i8) -> i32 { + %0 = llvm.mlir.addressof @g3 : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i8 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.zext %1 : i8 to i32 + %4 = llvm.udiv %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @urem_constexpr_const(%arg0: i8) -> i32 { + %0 = llvm.mlir.addressof @g4 : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i8 + %2 = llvm.mlir.constant(42 : i32) : i32 + %3 = llvm.zext %1 : i8 to i32 + %4 = llvm.urem %3, %2 : i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/umax-icmp.ll.mlir b/test/LLVMDialect/InstCombine/umax-icmp.ll.mlir new file mode 100644 index 000000000..51b2b8cc1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/umax-icmp.ll.mlir @@ -0,0 +1,405 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @eq_umax1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "eq" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @eq_umax2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ugt" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "eq" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @eq_umax3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ugt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "eq" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @eq_umax4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ugt" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "eq" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @ule_umax1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "ule" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ule_umax2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ugt" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "ule" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ule_umax3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ugt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "uge" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @ule_umax4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ugt" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "uge" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @ne_umax1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "ne" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ne_umax2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ugt" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "ne" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ne_umax3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ugt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @ne_umax4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ugt" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @ugt_umax1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "ugt" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ugt_umax2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ugt" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "ugt" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ugt_umax3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ugt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "ult" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @ugt_umax4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ugt" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "ult" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @use(i1) + llvm.func @eq_umax_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "eq" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umax(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @eq_umax_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "eq" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umax(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @ult_umax_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "ult" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umax(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @ult_umax_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "ult" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umax(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @ule_umax_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "ule" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umax(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @ule_umax_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "ule" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umax(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @ugt_umax_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "ugt" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umax(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @ugt_umax_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "ugt" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umax(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @uge_umax_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "uge" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umax(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @uge_umax_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "uge" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umax(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/umin-icmp.ll.mlir b/test/LLVMDialect/InstCombine/umin-icmp.ll.mlir new file mode 100644 index 000000000..a0c8a3dbf --- /dev/null +++ b/test/LLVMDialect/InstCombine/umin-icmp.ll.mlir @@ -0,0 +1,405 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @eq_umin1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "eq" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @eq_umin2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "eq" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @eq_umin3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ult" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "eq" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @eq_umin4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ult" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "eq" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @uge_umin1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "uge" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @uge_umin2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "uge" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @uge_umin3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ult" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "ule" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @uge_umin4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ult" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "ule" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @ne_umin1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "ne" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ne_umin2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "ne" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ne_umin3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ult" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @ne_umin4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ult" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "ne" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @ult_umin1(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i32 + %1 = llvm.select %0, %arg0, %arg1 : i1, i32 + %2 = llvm.icmp "ult" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ult_umin2(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.icmp "ult" %arg1, %arg0 : i32 + %1 = llvm.select %0, %arg1, %arg0 : i1, i32 + %2 = llvm.icmp "ult" %1, %arg0 : i32 + llvm.return %2 : i1 + } + llvm.func @ult_umin3(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ult" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.icmp "ugt" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @ult_umin4(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.add %arg0, %0 : i32 + %2 = llvm.icmp "ult" %arg1, %1 : i32 + %3 = llvm.select %2, %arg1, %1 : i1, i32 + %4 = llvm.icmp "ugt" %1, %3 : i32 + llvm.return %4 : i1 + } + llvm.func @use(i1) + llvm.func @eq_umin_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "eq" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @eq_umin_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "eq" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umin(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @ult_umin_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "ult" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @ult_umin_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "ult" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umin(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @ule_umin_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "ule" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @ule_umin_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "ule" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umin(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @ugt_umin_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "ugt" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @ugt_umin_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "ugt" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umin(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @uge_umin_contextual(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "uge" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umin(%arg0, %arg1) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } + llvm.func @uge_umin_contextual_commuted(%arg0: i32, %arg1: i32, %arg2: i32) { + %0 = llvm.icmp "uge" %arg0, %arg2 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %1 = llvm.intr.umin(%arg1, %arg0) : (i32, i32) -> i32 + %2 = llvm.icmp "slt" %1, %arg2 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "sle" %1, %arg2 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.icmp "sgt" %1, %arg2 : i32 + llvm.call @use(%4) : (i1) -> () + %5 = llvm.icmp "sge" %1, %arg2 : i32 + llvm.call @use(%5) : (i1) -> () + %6 = llvm.icmp "ult" %1, %arg2 : i32 + llvm.call @use(%6) : (i1) -> () + %7 = llvm.icmp "ule" %1, %arg2 : i32 + llvm.call @use(%7) : (i1) -> () + %8 = llvm.icmp "ugt" %1, %arg2 : i32 + llvm.call @use(%8) : (i1) -> () + %9 = llvm.icmp "uge" %1, %arg2 : i32 + llvm.call @use(%9) : (i1) -> () + %10 = llvm.icmp "eq" %1, %arg2 : i32 + llvm.call @use(%10) : (i1) -> () + %11 = llvm.icmp "ne" %1, %arg2 : i32 + llvm.call @use(%11) : (i1) -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/umul-sign-check.ll.mlir b/test/LLVMDialect/InstCombine/umul-sign-check.ll.mlir new file mode 100644 index 000000000..28bdea0c1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/umul-sign-check.ll.mlir @@ -0,0 +1,189 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i64, i1)> + %4 = llvm.icmp "ne" %3, %0 : i64 + %5 = llvm.or %2, %4 : i1 + llvm.store %3, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @test1_logical(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(true) : i1 + %2 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i64, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i64, i1)> + %5 = llvm.icmp "ne" %4, %0 : i64 + %6 = llvm.select %3, %1, %5 : i1, i1 + llvm.store %4, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %6 : i1 + } + llvm.func @test1_or_ops_swapped(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i64, i1)> + %4 = llvm.icmp "ne" %3, %0 : i64 + %5 = llvm.or %4, %2 : i1 + llvm.store %3, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @test1_or_ops_swapped_logical(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(true) : i1 + %2 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i64, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i64, i1)> + %5 = llvm.icmp "ne" %4, %0 : i64 + %6 = llvm.select %5, %1, %3 : i1, i1 + llvm.store %4, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %6 : i1 + } + llvm.func @test2(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i64, i1)> + %4 = llvm.icmp "ne" %3, %0 : i64 + %5 = llvm.or %2, %4 : i1 + %6 = llvm.sub %0, %3 : i64 + llvm.store %6, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @test2_logical(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(true) : i1 + %2 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i64, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i64, i1)> + %5 = llvm.icmp "ne" %4, %0 : i64 + %6 = llvm.select %3, %1, %5 : i1, i1 + %7 = llvm.sub %0, %4 : i64 + llvm.store %7, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %6 : i1 + } + llvm.func @use(i1) + llvm.func @test3_multiple_overflow_users(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i64, i1)> + %4 = llvm.icmp "ne" %3, %0 : i64 + %5 = llvm.or %2, %4 : i1 + llvm.call @use(%2) : (i1) -> () + llvm.return %5 : i1 + } + llvm.func @test3_multiple_overflow_users_logical(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(true) : i1 + %2 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i64, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i64, i1)> + %5 = llvm.icmp "ne" %4, %0 : i64 + %6 = llvm.select %3, %1, %5 : i1, i1 + llvm.call @use(%3) : (i1) -> () + llvm.return %6 : i1 + } + llvm.func @test3_multiple_overflow_and_mul_users(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i64, i1)> + %4 = llvm.icmp "ne" %3, %0 : i64 + %5 = llvm.or %2, %4 : i1 + %6 = llvm.sub %0, %3 : i64 + llvm.store %6, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.call @use(%2) : (i1) -> () + llvm.return %5 : i1 + } + llvm.func @test3_multiple_overflow_and_mul_users_logical(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(true) : i1 + %2 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i64, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i64, i1)> + %5 = llvm.icmp "ne" %4, %0 : i64 + %6 = llvm.select %3, %1, %5 : i1, i1 + %7 = llvm.sub %0, %4 : i64 + llvm.store %7, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.call @use(%3) : (i1) -> () + llvm.return %6 : i1 + } + llvm.func @use.2(!llvm.struct<(i64, i1)>) + llvm.func @test3_multiple_res_users(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i64, i1)> + %4 = llvm.icmp "ne" %3, %0 : i64 + %5 = llvm.or %2, %4 : i1 + %6 = llvm.sub %0, %3 : i64 + llvm.store %6, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.call @use.2(%1) : (!llvm.struct<(i64, i1)>) -> () + llvm.return %5 : i1 + } + llvm.func @test3_multiple_res_users_logical(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(true) : i1 + %2 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i64, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i64, i1)> + %5 = llvm.icmp "ne" %4, %0 : i64 + %6 = llvm.select %3, %1, %5 : i1, i1 + %7 = llvm.sub %0, %4 : i64 + llvm.store %7, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.call @use.2(%2) : (!llvm.struct<(i64, i1)>) -> () + llvm.return %6 : i1 + } + llvm.func @use.3(i64) + llvm.func @test3_multiple_mul_users(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i64, i1)> + %4 = llvm.icmp "ne" %3, %0 : i64 + %5 = llvm.or %2, %4 : i1 + %6 = llvm.sub %0, %3 : i64 + llvm.store %6, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.call @use.3(%3) : (i64) -> () + llvm.return %5 : i1 + } + llvm.func @test3_multiple_mul_users_logical(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(true) : i1 + %2 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i64, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i64, i1)> + %5 = llvm.icmp "ne" %4, %0 : i64 + %6 = llvm.select %3, %1, %5 : i1, i1 + %7 = llvm.sub %0, %4 : i64 + llvm.store %7, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.call @use.3(%4) : (i64) -> () + llvm.return %6 : i1 + } + llvm.func @test4_no_icmp_ne(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i64, i1)> + %4 = llvm.icmp "sgt" %3, %0 : i64 + %5 = llvm.or %2, %4 : i1 + %6 = llvm.sub %0, %3 : i64 + llvm.store %6, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %5 : i1 + } + llvm.func @test4_no_icmp_ne_logical(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(true) : i1 + %2 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i64, i1)> + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i64, i1)> + %5 = llvm.icmp "sgt" %4, %0 : i64 + %6 = llvm.select %3, %1, %5 : i1, i1 + %7 = llvm.sub %0, %4 : i64 + llvm.store %7, %arg2 {alignment = 8 : i64} : i64, !llvm.ptr + llvm.return %6 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/umulo-square.ll.mlir b/test/LLVMDialect/InstCombine/umulo-square.ll.mlir new file mode 100644 index 000000000..8a307994d --- /dev/null +++ b/test/LLVMDialect/InstCombine/umulo-square.ll.mlir @@ -0,0 +1,30 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @umulov_square_i32(%arg0: i32) -> i1 { + %0 = "llvm.intr.umul.with.overflow"(%arg0, %arg0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i32, i1)> + llvm.return %1 : i1 + } + llvm.func @umulov_square_i16(%arg0: i16) -> i1 { + %0 = "llvm.intr.umul.with.overflow"(%arg0, %arg0) : (i16, i16) -> !llvm.struct<(i16, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i16, i1)> + llvm.return %1 : i1 + } + llvm.func @umulov_square_i13(%arg0: i13) -> i1 { + %0 = "llvm.intr.umul.with.overflow"(%arg0, %arg0) : (i13, i13) -> !llvm.struct<(i13, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i13, i1)> + llvm.return %1 : i1 + } + llvm.func @umulov_square_i32_multiuse(%arg0: i32) -> i1 { + %0 = "llvm.intr.umul.with.overflow"(%arg0, %arg0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i32, i1)> + %2 = llvm.extractvalue %0[0] : !llvm.struct<(i32, i1)> + llvm.call @use(%2) : (i32) -> () + llvm.return %1 : i1 + } + llvm.func @smulov_square_i32(%arg0: i32) -> i1 { + %0 = "llvm.intr.smul.with.overflow"(%arg0, %arg0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i32, i1)> + llvm.return %1 : i1 + } + llvm.func @use(i32) +} diff --git a/test/LLVMDialect/InstCombine/umulo.ll.mlir b/test/LLVMDialect/InstCombine/umulo.ll.mlir new file mode 100644 index 000000000..10a8e4937 --- /dev/null +++ b/test/LLVMDialect/InstCombine/umulo.ll.mlir @@ -0,0 +1,101 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_generic(%arg0: i64, %arg1: i64) -> i1 { + %0 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i64, i1)> + llvm.return %1 : i1 + } + llvm.func @test_constant0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant127(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant128(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant255(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @i1_res(%arg0: i1, %arg1: i1) -> i1 { + %0 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i1, i1) -> !llvm.struct<(i1, i1)> + %1 = llvm.extractvalue %0[0] : !llvm.struct<(i1, i1)> + llvm.return %1 : i1 + } + llvm.func @v2i1_res(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (vector<2xi1>, vector<2xi1>) -> !llvm.struct<(vector<2xi1>, vector<2xi1>)> + %1 = llvm.extractvalue %0[0] : !llvm.struct<(vector<2xi1>, vector<2xi1>)> + llvm.return %1 : vector<2xi1> + } + llvm.func @i1_res_by_one(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i1, i1) -> !llvm.struct<(i1, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i1, i1)> + llvm.return %2 : i1 + } + llvm.func @v2i1_res_by_one(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = "llvm.intr.umul.with.overflow"(%arg0, %1) : (vector<2xi1>, vector<2xi1>) -> !llvm.struct<(vector<2xi1>, vector<2xi1>)> + %3 = llvm.extractvalue %2[0] : !llvm.struct<(vector<2xi1>, vector<2xi1>)> + llvm.return %3 : vector<2xi1> + } + llvm.func @i1_ov(%arg0: i1, %arg1: i1) -> i1 { + %0 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (i1, i1) -> !llvm.struct<(i1, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i1, i1)> + llvm.return %1 : i1 + } + llvm.func @v2i1_ov(%arg0: vector<2xi1>, %arg1: vector<2xi1>) -> vector<2xi1> { + %0 = "llvm.intr.umul.with.overflow"(%arg0, %arg1) : (vector<2xi1>, vector<2xi1>) -> !llvm.struct<(vector<2xi1>, vector<2xi1>)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(vector<2xi1>, vector<2xi1>)> + llvm.return %1 : vector<2xi1> + } + llvm.func @i1_ov_by_one(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i1, i1) -> !llvm.struct<(i1, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i1, i1)> + llvm.return %2 : i1 + } + llvm.func @v2i1_ov_by_one(%arg0: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = "llvm.intr.umul.with.overflow"(%arg0, %1) : (vector<2xi1>, vector<2xi1>) -> !llvm.struct<(vector<2xi1>, vector<2xi1>)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(vector<2xi1>, vector<2xi1>)> + llvm.return %3 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/unavailable-debug.ll.mlir b/test/LLVMDialect/InstCombine/unavailable-debug.ll.mlir new file mode 100644 index 000000000..c954ea34d --- /dev/null +++ b/test/LLVMDialect/InstCombine/unavailable-debug.ll.mlir @@ -0,0 +1,52 @@ +#di_basic_type = #llvm.di_basic_type +#di_basic_type1 = #llvm.di_basic_type +#di_file = #llvm.di_file<"a.c" in "/Users/davide/llvm/build/bin"> +#tbaa_root = #llvm.tbaa_root +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C99, file = #di_file, producer = "clang version 9.0.0 (https://github.com/llvm/llvm-project b306ef12f046353ea5bda4b3b77759e57909a0db)", isOptimized = true, emissionKind = Full> +#di_derived_type = #llvm.di_derived_type +#di_subroutine_type = #llvm.di_subroutine_type +#di_subroutine_type1 = #llvm.di_subroutine_type +#di_global_variable = #llvm.di_global_variable +#di_global_variable1 = #llvm.di_global_variable +#di_global_variable2 = #llvm.di_global_variable +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "b", file = #di_file, line = 4, scopeLine = 4, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#di_subprogram1 = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "main", file = #di_file, line = 5, scopeLine = 5, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type1> +#tbaa_type_desc = #llvm.tbaa_type_desc}> +#di_global_variable_expression = #llvm.di_global_variable_expression> +#di_global_variable_expression1 = #llvm.di_global_variable_expression> +#di_global_variable_expression2 = #llvm.di_global_variable_expression> +#di_local_variable = #llvm.di_local_variable +#di_local_variable1 = #llvm.di_local_variable +#tbaa_tag = #llvm.tbaa_tag +#tbaa_type_desc1 = #llvm.tbaa_type_desc}> +#tbaa_tag1 = #llvm.tbaa_tag +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global common local_unnamed_addr @e(0 : i8) {addr_space = 0 : i32, alignment = 1 : i64, dbg_expr = #di_global_variable_expression} : i8 + llvm.mlir.global common local_unnamed_addr @c(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64, dbg_expr = #di_global_variable_expression1} : i32 + llvm.mlir.global common local_unnamed_addr @d(0 : i32) {addr_space = 0 : i32, alignment = 4 : i64, dbg_expr = #di_global_variable_expression2} : i32 + llvm.func local_unnamed_addr @b(%arg0: i32) -> (i8 {llvm.signext}) { + llvm.intr.dbg.value #di_local_variable = %arg0 : i32 + %0 = llvm.trunc %arg0 : i32 to i8 + llvm.return %0 : i8 + } + llvm.func local_unnamed_addr @main() -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.addressof @e : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.addressof @c : !llvm.ptr + %4 = llvm.mlir.constant(6 : i32) : i32 + %5 = llvm.mlir.addressof @d : !llvm.ptr + %6 = llvm.mlir.constant(-1372423381 : i32) : i32 + llvm.intr.dbg.value #di_local_variable1 = %6 : i32 + %7 = llvm.load %1 {alignment = 1 : i64, tbaa = [#tbaa_tag]} : !llvm.ptr -> i8 + %8 = llvm.sext %7 : i8 to i32 + llvm.store %8, %3 {alignment = 4 : i64, tbaa = [#tbaa_tag1]} : i32, !llvm.ptr + %9 = llvm.call @b(%4) : (i32) -> i8 + %10 = llvm.sext %9 : i8 to i32 + llvm.intr.dbg.value #di_local_variable1 = %10 : i32 + %11 = llvm.load %5 {alignment = 4 : i64, tbaa = [#tbaa_tag1]} : !llvm.ptr -> i32 + %12 = llvm.call @optimize_me_not() vararg(!llvm.func) : () -> i32 + llvm.return %2 : i32 + } + llvm.func local_unnamed_addr @optimize_me_not(...) -> i32 +} diff --git a/test/LLVMDialect/InstCombine/unfold-masked-merge-with-const-mask-scalar.ll.mlir b/test/LLVMDialect/InstCombine/unfold-masked-merge-with-const-mask-scalar.ll.mlir index b369a0234..6fb5d124a 100644 --- a/test/LLVMDialect/InstCombine/unfold-masked-merge-with-const-mask-scalar.ll.mlir +++ b/test/LLVMDialect/InstCombine/unfold-masked-merge-with-const-mask-scalar.ll.mlir @@ -1,171 +1,151 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %2 = "llvm.and"(%1, %0) : (i4, i4) -> i4 - %3 = "llvm.xor"(%2, %arg1) : (i4, i4) -> i4 - "llvm.return"(%3) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "scalar0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %2 = "llvm.and"(%1, %0) : (i4, i4) -> i4 - %3 = "llvm.xor"(%2, %arg1) : (i4, i4) -> i4 - "llvm.return"(%3) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "scalar1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %2 = "llvm.xor"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %0) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %1) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "in_constant_varx_mone", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %2 = "llvm.xor"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %0) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %1) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "in_constant_varx_14", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = -1 : i4} : () -> i4 - %2 = "llvm.xor"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %0) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %arg0) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "in_constant_mone_vary", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %2 = "llvm.xor"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %0) : (i4, i4) -> i4 - %4 = "llvm.xor"(%3, %arg0) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "in_constant_14_vary", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.xor"(%arg1, %arg0) : (i4, i4) -> i4 - %2 = "llvm.and"(%1, %0) : (i4, i4) -> i4 - %3 = "llvm.xor"(%2, %arg1) : (i4, i4) -> i4 - "llvm.return"(%3) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "c_1_0_0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %2 = "llvm.and"(%1, %0) : (i4, i4) -> i4 - %3 = "llvm.xor"(%2, %arg0) : (i4, i4) -> i4 - "llvm.return"(%3) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "c_0_1_0", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.call"() {callee = @gen4, fastmathFlags = #llvm.fastmath<>} : () -> i4 - %2 = "llvm.call"() {callee = @gen4, fastmathFlags = #llvm.fastmath<>} : () -> i4 - %3 = "llvm.xor"(%1, %2) : (i4, i4) -> i4 - %4 = "llvm.and"(%3, %0) : (i4, i4) -> i4 - %5 = "llvm.xor"(%2, %4) : (i4, i4) -> i4 - "llvm.return"(%5) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "c_0_0_1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.xor"(%arg1, %arg0) : (i4, i4) -> i4 - %2 = "llvm.and"(%1, %0) : (i4, i4) -> i4 - %3 = "llvm.xor"(%2, %arg0) : (i4, i4) -> i4 - "llvm.return"(%3) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "c_1_1_0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.call"() {callee = @gen4, fastmathFlags = #llvm.fastmath<>} : () -> i4 - %2 = "llvm.xor"(%1, %arg0) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %0) : (i4, i4) -> i4 - %4 = "llvm.xor"(%1, %3) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "c_1_0_1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.call"() {callee = @gen4, fastmathFlags = #llvm.fastmath<>} : () -> i4 - %2 = "llvm.xor"(%1, %arg0) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %0) : (i4, i4) -> i4 - %4 = "llvm.xor"(%1, %3) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "c_0_1_1", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.call"() {callee = @gen4, fastmathFlags = #llvm.fastmath<>} : () -> i4 - %2 = "llvm.call"() {callee = @gen4, fastmathFlags = #llvm.fastmath<>} : () -> i4 - %3 = "llvm.xor"(%2, %1) : (i4, i4) -> i4 - %4 = "llvm.and"(%3, %0) : (i4, i4) -> i4 - %5 = "llvm.xor"(%1, %4) : (i4, i4) -> i4 - "llvm.return"(%5) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "c_1_1_1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i4} : () -> i4 - %1 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %2 = "llvm.xor"(%arg0, %1) : (i4, i4) -> i4 - %3 = "llvm.and"(%2, %0) : (i4, i4) -> i4 - %4 = "llvm.xor"(%arg0, %3) : (i4, i4) -> i4 - "llvm.return"(%4) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "commutativity_constant_14_vary", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %2 = "llvm.and"(%1, %0) : (i4, i4) -> i4 - %3 = "llvm.xor"(%2, %arg1) : (i4, i4) -> i4 - "llvm.call"(%1) {callee = @use4, fastmathFlags = #llvm.fastmath<>} : (i4) -> () - "llvm.return"(%3) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "n_oneuse_D", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %2 = "llvm.and"(%1, %0) : (i4, i4) -> i4 - %3 = "llvm.xor"(%2, %arg1) : (i4, i4) -> i4 - "llvm.call"(%2) {callee = @use4, fastmathFlags = #llvm.fastmath<>} : (i4) -> () - "llvm.return"(%3) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "n_oneuse_A", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %2 = "llvm.and"(%1, %0) : (i4, i4) -> i4 - %3 = "llvm.xor"(%2, %arg1) : (i4, i4) -> i4 - "llvm.call"(%1) {callee = @use4, fastmathFlags = #llvm.fastmath<>} : (i4) -> () - "llvm.call"(%2) {callee = @use4, fastmathFlags = #llvm.fastmath<>} : (i4) -> () - "llvm.return"(%3) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "n_oneuse_AD", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4, %arg2: i4): // no predecessors - %0 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %1 = "llvm.and"(%0, %arg2) : (i4, i4) -> i4 - %2 = "llvm.xor"(%1, %arg1) : (i4, i4) -> i4 - "llvm.return"(%2) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "n_var_mask", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i4, %arg1: i4, %arg2: i4): // no predecessors - %0 = "llvm.mlir.constant"() {value = -2 : i4} : () -> i4 - %1 = "llvm.xor"(%arg0, %arg1) : (i4, i4) -> i4 - %2 = "llvm.and"(%1, %0) : (i4, i4) -> i4 - %3 = "llvm.xor"(%2, %arg2) : (i4, i4) -> i4 - "llvm.return"(%3) : (i4) -> () - }) {linkage = 10 : i64, sym_name = "n_third_var", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @scalar0(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.xor %arg0, %arg1 : i4 + %2 = llvm.and %1, %0 : i4 + %3 = llvm.xor %2, %arg1 : i4 + llvm.return %3 : i4 + } + llvm.func @scalar1(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.xor %arg0, %arg1 : i4 + %2 = llvm.and %1, %0 : i4 + %3 = llvm.xor %2, %arg1 : i4 + llvm.return %3 : i4 + } + llvm.func @in_constant_varx_mone(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.xor %arg0, %0 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %0 : i4 + llvm.return %4 : i4 + } + llvm.func @in_constant_varx_14(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.xor %arg0, %0 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %0 : i4 + llvm.return %4 : i4 + } + llvm.func @in_constant_mone_vary(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.xor %arg0, %0 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %arg0 : i4 + llvm.return %4 : i4 + } + llvm.func @in_constant_14_vary(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.xor %arg0, %0 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %3, %arg0 : i4 + llvm.return %4 : i4 + } + llvm.func @gen4() -> i4 + llvm.func @c_1_0_0(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.xor %arg1, %arg0 : i4 + %2 = llvm.and %1, %0 : i4 + %3 = llvm.xor %2, %arg1 : i4 + llvm.return %3 : i4 + } + llvm.func @c_0_1_0(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.xor %arg0, %arg1 : i4 + %2 = llvm.and %1, %0 : i4 + %3 = llvm.xor %2, %arg0 : i4 + llvm.return %3 : i4 + } + llvm.func @c_0_0_1() -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.call @gen4() : () -> i4 + %2 = llvm.call @gen4() : () -> i4 + %3 = llvm.xor %1, %2 : i4 + %4 = llvm.and %3, %0 : i4 + %5 = llvm.xor %2, %4 : i4 + llvm.return %5 : i4 + } + llvm.func @c_1_1_0(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.xor %arg1, %arg0 : i4 + %2 = llvm.and %1, %0 : i4 + %3 = llvm.xor %2, %arg0 : i4 + llvm.return %3 : i4 + } + llvm.func @c_1_0_1(%arg0: i4) -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.call @gen4() : () -> i4 + %2 = llvm.xor %1, %arg0 : i4 + %3 = llvm.and %2, %0 : i4 + %4 = llvm.xor %1, %3 : i4 + llvm.return %4 : i4 + } + llvm.func @c_0_1_1(%arg0: i4) -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.call @gen4() : () -> i4 + %2 = llvm.xor %1, %arg0 : i4 + %3 = llvm.and %2, %0 : i4 + %4 = llvm.xor %1, %3 : i4 + llvm.return %4 : i4 + } + llvm.func @c_1_1_1() -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.call @gen4() : () -> i4 + %2 = llvm.call @gen4() : () -> i4 + %3 = llvm.xor %2, %1 : i4 + %4 = llvm.and %3, %0 : i4 + %5 = llvm.xor %1, %4 : i4 + llvm.return %5 : i4 + } + llvm.func @commutativity_constant_14_vary(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(1 : i4) : i4 + %2 = llvm.xor %arg0, %0 : i4 + %3 = llvm.and %2, %1 : i4 + %4 = llvm.xor %arg0, %3 : i4 + llvm.return %4 : i4 + } + llvm.func @use4(i4) + llvm.func @n_oneuse_D(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.xor %arg0, %arg1 : i4 + %2 = llvm.and %1, %0 : i4 + %3 = llvm.xor %2, %arg1 : i4 + llvm.call @use4(%1) : (i4) -> () + llvm.return %3 : i4 + } + llvm.func @n_oneuse_A(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.xor %arg0, %arg1 : i4 + %2 = llvm.and %1, %0 : i4 + %3 = llvm.xor %2, %arg1 : i4 + llvm.call @use4(%2) : (i4) -> () + llvm.return %3 : i4 + } + llvm.func @n_oneuse_AD(%arg0: i4, %arg1: i4) -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.xor %arg0, %arg1 : i4 + %2 = llvm.and %1, %0 : i4 + %3 = llvm.xor %2, %arg1 : i4 + llvm.call @use4(%1) : (i4) -> () + llvm.call @use4(%2) : (i4) -> () + llvm.return %3 : i4 + } + llvm.func @n_var_mask(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.xor %arg0, %arg1 : i4 + %1 = llvm.and %0, %arg2 : i4 + %2 = llvm.xor %1, %arg1 : i4 + llvm.return %2 : i4 + } + llvm.func @n_third_var(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.xor %arg0, %arg1 : i4 + %2 = llvm.and %1, %0 : i4 + %3 = llvm.xor %2, %arg2 : i4 + llvm.return %3 : i4 + } +} diff --git a/test/LLVMDialect/InstCombine/unfold-masked-merge-with-const-mask-vector.ll.mlir b/test/LLVMDialect/InstCombine/unfold-masked-merge-with-const-mask-vector.ll.mlir new file mode 100644 index 000000000..71a3cd03f --- /dev/null +++ b/test/LLVMDialect/InstCombine/unfold-masked-merge-with-const-mask-vector.ll.mlir @@ -0,0 +1,264 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @splat(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(dense<-2> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg0, %arg1 : vector<2xi4> + %3 = llvm.and %2, %1 : vector<2xi4> + %4 = llvm.xor %3, %arg1 : vector<2xi4> + llvm.return %4 : vector<2xi4> + } + llvm.func @splat_undef(%arg0: vector<3xi4>, %arg1: vector<3xi4>) -> vector<3xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.undef : i4 + %2 = llvm.mlir.undef : vector<3xi4> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi4> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi4> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi4> + %9 = llvm.xor %arg0, %arg1 : vector<3xi4> + %10 = llvm.and %9, %8 : vector<3xi4> + %11 = llvm.xor %10, %arg1 : vector<3xi4> + llvm.return %11 : vector<3xi4> + } + llvm.func @nonsplat(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.mlir.constant(dense<[-2, 1]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.xor %arg0, %arg1 : vector<2xi4> + %4 = llvm.and %3, %2 : vector<2xi4> + %5 = llvm.xor %4, %arg1 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @in_constant_varx_mone(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(1 : i4) : i4 + %3 = llvm.mlir.constant(dense<1> : vector<2xi4>) : vector<2xi4> + %4 = llvm.xor %arg0, %1 : vector<2xi4> + %5 = llvm.and %4, %3 : vector<2xi4> + %6 = llvm.xor %5, %1 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @in_constant_varx_14(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(dense<-2> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(1 : i4) : i4 + %3 = llvm.mlir.constant(dense<1> : vector<2xi4>) : vector<2xi4> + %4 = llvm.xor %arg0, %1 : vector<2xi4> + %5 = llvm.and %4, %3 : vector<2xi4> + %6 = llvm.xor %5, %1 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @in_constant_varx_14_nonsplat(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(7 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.mlir.constant(dense<[-2, 7]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.constant(1 : i4) : i4 + %4 = llvm.mlir.constant(dense<1> : vector<2xi4>) : vector<2xi4> + %5 = llvm.xor %arg0, %2 : vector<2xi4> + %6 = llvm.and %5, %4 : vector<2xi4> + %7 = llvm.xor %6, %2 : vector<2xi4> + llvm.return %7 : vector<2xi4> + } + llvm.func @in_constant_varx_14_undef(%arg0: vector<3xi4>, %arg1: vector<3xi4>) -> vector<3xi4> { + %0 = llvm.mlir.constant(7 : i4) : i4 + %1 = llvm.mlir.undef : i4 + %2 = llvm.mlir.constant(-2 : i4) : i4 + %3 = llvm.mlir.undef : vector<3xi4> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi4> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi4> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi4> + %10 = llvm.mlir.constant(1 : i4) : i4 + %11 = llvm.mlir.undef : vector<3xi4> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.insertelement %10, %11[%12 : i32] : vector<3xi4> + %14 = llvm.mlir.constant(1 : i32) : i32 + %15 = llvm.insertelement %1, %13[%14 : i32] : vector<3xi4> + %16 = llvm.mlir.constant(2 : i32) : i32 + %17 = llvm.insertelement %10, %15[%16 : i32] : vector<3xi4> + %18 = llvm.xor %arg0, %9 : vector<3xi4> + %19 = llvm.and %18, %17 : vector<3xi4> + %20 = llvm.xor %19, %9 : vector<3xi4> + llvm.return %20 : vector<3xi4> + } + llvm.func @in_constant_mone_vary(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(1 : i4) : i4 + %3 = llvm.mlir.constant(dense<1> : vector<2xi4>) : vector<2xi4> + %4 = llvm.xor %arg0, %1 : vector<2xi4> + %5 = llvm.and %4, %3 : vector<2xi4> + %6 = llvm.xor %5, %arg0 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @in_constant_14_vary(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(dense<-2> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(1 : i4) : i4 + %3 = llvm.mlir.constant(dense<1> : vector<2xi4>) : vector<2xi4> + %4 = llvm.xor %arg0, %1 : vector<2xi4> + %5 = llvm.and %4, %3 : vector<2xi4> + %6 = llvm.xor %5, %arg0 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @in_constant_14_vary_nonsplat(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(7 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.mlir.constant(dense<[-2, 7]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.constant(1 : i4) : i4 + %4 = llvm.mlir.constant(dense<1> : vector<2xi4>) : vector<2xi4> + %5 = llvm.xor %arg0, %2 : vector<2xi4> + %6 = llvm.and %5, %4 : vector<2xi4> + %7 = llvm.xor %6, %arg0 : vector<2xi4> + llvm.return %7 : vector<2xi4> + } + llvm.func @in_constant_14_vary_undef(%arg0: vector<3xi4>, %arg1: vector<3xi4>) -> vector<3xi4> { + %0 = llvm.mlir.constant(7 : i4) : i4 + %1 = llvm.mlir.undef : i4 + %2 = llvm.mlir.constant(-2 : i4) : i4 + %3 = llvm.mlir.undef : vector<3xi4> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<3xi4> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %1, %5[%6 : i32] : vector<3xi4> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : vector<3xi4> + %10 = llvm.mlir.constant(1 : i4) : i4 + %11 = llvm.mlir.undef : vector<3xi4> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.insertelement %10, %11[%12 : i32] : vector<3xi4> + %14 = llvm.mlir.constant(1 : i32) : i32 + %15 = llvm.insertelement %1, %13[%14 : i32] : vector<3xi4> + %16 = llvm.mlir.constant(2 : i32) : i32 + %17 = llvm.insertelement %10, %15[%16 : i32] : vector<3xi4> + %18 = llvm.xor %arg0, %9 : vector<3xi4> + %19 = llvm.and %18, %17 : vector<3xi4> + %20 = llvm.xor %19, %arg0 : vector<3xi4> + llvm.return %20 : vector<3xi4> + } + llvm.func @gen4() -> vector<2xi4> + llvm.func @c_1_0_0(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(dense<-2> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg1, %arg0 : vector<2xi4> + %3 = llvm.and %2, %1 : vector<2xi4> + %4 = llvm.xor %3, %arg1 : vector<2xi4> + llvm.return %4 : vector<2xi4> + } + llvm.func @c_0_1_0(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(dense<-2> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg0, %arg1 : vector<2xi4> + %3 = llvm.and %2, %1 : vector<2xi4> + %4 = llvm.xor %3, %arg0 : vector<2xi4> + llvm.return %4 : vector<2xi4> + } + llvm.func @c_0_0_1() -> vector<2xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(dense<-2> : vector<2xi4>) : vector<2xi4> + %2 = llvm.call @gen4() : () -> vector<2xi4> + %3 = llvm.call @gen4() : () -> vector<2xi4> + %4 = llvm.xor %2, %3 : vector<2xi4> + %5 = llvm.and %4, %1 : vector<2xi4> + %6 = llvm.xor %3, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @c_1_1_0(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(dense<-2> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg1, %arg0 : vector<2xi4> + %3 = llvm.and %2, %1 : vector<2xi4> + %4 = llvm.xor %3, %arg0 : vector<2xi4> + llvm.return %4 : vector<2xi4> + } + llvm.func @c_1_0_1(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(dense<-2> : vector<2xi4>) : vector<2xi4> + %2 = llvm.call @gen4() : () -> vector<2xi4> + %3 = llvm.xor %2, %arg0 : vector<2xi4> + %4 = llvm.and %3, %1 : vector<2xi4> + %5 = llvm.xor %2, %4 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @c_0_1_1(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(dense<-2> : vector<2xi4>) : vector<2xi4> + %2 = llvm.call @gen4() : () -> vector<2xi4> + %3 = llvm.xor %2, %arg0 : vector<2xi4> + %4 = llvm.and %3, %1 : vector<2xi4> + %5 = llvm.xor %2, %4 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @c_1_1_1() -> vector<2xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(dense<-2> : vector<2xi4>) : vector<2xi4> + %2 = llvm.call @gen4() : () -> vector<2xi4> + %3 = llvm.call @gen4() : () -> vector<2xi4> + %4 = llvm.xor %3, %2 : vector<2xi4> + %5 = llvm.and %4, %1 : vector<2xi4> + %6 = llvm.xor %2, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @commutativity_constant_14_vary(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(dense<-2> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(1 : i4) : i4 + %3 = llvm.mlir.constant(dense<1> : vector<2xi4>) : vector<2xi4> + %4 = llvm.xor %arg0, %1 : vector<2xi4> + %5 = llvm.and %4, %3 : vector<2xi4> + %6 = llvm.xor %arg0, %5 : vector<2xi4> + llvm.return %6 : vector<2xi4> + } + llvm.func @use4(vector<2xi4>) + llvm.func @n_oneuse_D(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(dense<-2> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg0, %arg1 : vector<2xi4> + %3 = llvm.and %2, %1 : vector<2xi4> + %4 = llvm.xor %3, %arg1 : vector<2xi4> + llvm.call @use4(%2) : (vector<2xi4>) -> () + llvm.return %4 : vector<2xi4> + } + llvm.func @n_oneuse_A(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(dense<-2> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg0, %arg1 : vector<2xi4> + %3 = llvm.and %2, %1 : vector<2xi4> + %4 = llvm.xor %3, %arg1 : vector<2xi4> + llvm.call @use4(%3) : (vector<2xi4>) -> () + llvm.return %4 : vector<2xi4> + } + llvm.func @n_oneuse_AD(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-2 : i4) : i4 + %1 = llvm.mlir.constant(dense<-2> : vector<2xi4>) : vector<2xi4> + %2 = llvm.xor %arg0, %arg1 : vector<2xi4> + %3 = llvm.and %2, %1 : vector<2xi4> + %4 = llvm.xor %3, %arg1 : vector<2xi4> + llvm.call @use4(%2) : (vector<2xi4>) -> () + llvm.call @use4(%3) : (vector<2xi4>) -> () + llvm.return %4 : vector<2xi4> + } + llvm.func @n_var_mask(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.xor %arg0, %arg1 : vector<2xi4> + %1 = llvm.and %0, %arg2 : vector<2xi4> + %2 = llvm.xor %1, %arg1 : vector<2xi4> + llvm.return %2 : vector<2xi4> + } + llvm.func @n_differenty(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(7 : i4) : i4 + %1 = llvm.mlir.constant(-2 : i4) : i4 + %2 = llvm.mlir.constant(dense<[-2, 7]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.constant(1 : i4) : i4 + %4 = llvm.mlir.constant(dense<1> : vector<2xi4>) : vector<2xi4> + %5 = llvm.mlir.constant(dense<[7, -2]> : vector<2xi4>) : vector<2xi4> + %6 = llvm.xor %arg0, %2 : vector<2xi4> + %7 = llvm.and %6, %4 : vector<2xi4> + %8 = llvm.xor %7, %5 : vector<2xi4> + llvm.return %8 : vector<2xi4> + } +} diff --git a/test/LLVMDialect/InstCombine/unordered-compare-and-ordered.ll.mlir b/test/LLVMDialect/InstCombine/unordered-compare-and-ordered.ll.mlir new file mode 100644 index 000000000..7971b8754 --- /dev/null +++ b/test/LLVMDialect/InstCombine/unordered-compare-and-ordered.ll.mlir @@ -0,0 +1,268 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fcmp_ord_and_uno(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + %2 = llvm.fcmp "uno" %arg0, %arg1 : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_ueq(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_ugt(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + %2 = llvm.fcmp "ugt" %arg0, %arg1 : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_uge(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + %2 = llvm.fcmp "uge" %arg0, %arg1 : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_ult(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + %2 = llvm.fcmp "ult" %arg0, %arg1 : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_ule(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + %2 = llvm.fcmp "ule" %arg0, %arg1 : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_une(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + %2 = llvm.fcmp "une" %arg0, %arg1 : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_true(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "_true" %arg0, %0 : f16 + %2 = llvm.fcmp "une" %arg0, %arg1 : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_ueq_vector(%arg0: vector<2xf16>, %arg1: vector<2xf16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf16>) : vector<2xf16> + %2 = llvm.fcmp "ord" %arg0, %1 : vector<2xf16> + %3 = llvm.fcmp "ueq" %arg0, %arg1 : vector<2xf16> + %4 = llvm.and %2, %3 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @fcmp_ord_and_ueq_different_value0(%arg0: f16, %arg1: f16, %arg2: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + %2 = llvm.fcmp "ueq" %arg2, %arg1 : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_ueq_different_value1(%arg0: f16, %arg1: f16, %arg2: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + %2 = llvm.fcmp "ueq" %arg1, %arg2 : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @foo() -> f16 + llvm.func @fcmp_ord_and_ueq_commute0() -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.call @foo() : () -> f16 + %2 = llvm.call @foo() : () -> f16 + %3 = llvm.fcmp "ord" %1, %0 : f16 + %4 = llvm.fcmp "ueq" %1, %2 : f16 + %5 = llvm.and %4, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @fcmp_ord_and_ueq_commute1() -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.call @foo() : () -> f16 + %2 = llvm.call @foo() : () -> f16 + %3 = llvm.fcmp "ord" %1, %0 : f16 + %4 = llvm.fcmp "ueq" %1, %2 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @fcmp_oeq_x_x_and_ult(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.fcmp "oeq" %arg0, %arg0 : f16 + %1 = llvm.fcmp "ult" %arg0, %arg1 : f16 + %2 = llvm.and %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @fcmp_ord_and_ueq_preserve_flags(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f16 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_ueq_preserve_subset_flags0(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f16 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_ueq_preserve_subset_flags1(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f16 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_ueq_flags_lhs(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 {fastmathFlags = #llvm.fastmath} : f16 + %2 = llvm.fcmp "ueq" %arg0, %arg1 : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_ueq_flags_rhs(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fcmp "ord" %arg0, %0 : f16 + %2 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f16 + %3 = llvm.and %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @fcmp_ord_and_fabs_ueq(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %2 = llvm.fcmp "ord" %arg0, %0 : f16 + %3 = llvm.fcmp "ueq" %1, %arg1 : f16 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @fcmp_ord_fabs_and_ueq(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %2 = llvm.fcmp "ord" %1, %0 : f16 + %3 = llvm.fcmp "ueq" %arg0, %arg1 : f16 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @fcmp_ord_and_fabs_ueq_commute0() -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.call @foo() : () -> f16 + %2 = llvm.call @foo() : () -> f16 + %3 = llvm.intr.fabs(%1) : (f16) -> f16 + %4 = llvm.fcmp "ord" %1, %0 : f16 + %5 = llvm.fcmp "ueq" %2, %3 : f16 + %6 = llvm.and %4, %5 : i1 + llvm.return %6 : i1 + } + llvm.func @fcmp_ord_and_fabs_ueq_commute1() -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.call @foo() : () -> f16 + %2 = llvm.call @foo() : () -> f16 + %3 = llvm.intr.fabs(%1) : (f16) -> f16 + %4 = llvm.fcmp "ord" %1, %0 : f16 + %5 = llvm.fcmp "ueq" %2, %3 : f16 + %6 = llvm.and %5, %4 : i1 + llvm.return %6 : i1 + } + llvm.func @fcmp_ord_and_fabs_ueq_vector(%arg0: vector<2xf16>, %arg1: vector<2xf16>) -> vector<2xi1> { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<2xf16>) : vector<2xf16> + %2 = llvm.intr.fabs(%arg0) : (vector<2xf16>) -> vector<2xf16> + %3 = llvm.fcmp "ord" %arg0, %1 : vector<2xf16> + %4 = llvm.fcmp "ueq" %2, %arg1 : vector<2xf16> + %5 = llvm.and %3, %4 : vector<2xi1> + llvm.return %5 : vector<2xi1> + } + llvm.func @fcmp_ord_fabs_and_fabs_ueq(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %2 = llvm.fcmp "ord" %1, %0 : f16 + %3 = llvm.fcmp "ueq" %1, %arg1 : f16 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @fcmp_ord_and_fneg_ueq(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fneg %arg0 : f16 + %2 = llvm.fcmp "ord" %arg0, %0 : f16 + %3 = llvm.fcmp "ueq" %1, %arg1 : f16 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @fcmp_ord_fneg_and_ueq(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fneg %arg0 : f16 + %2 = llvm.fcmp "ord" %1, %0 : f16 + %3 = llvm.fcmp "ueq" %arg0, %arg1 : f16 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @fcmp_ord_fneg_and_fneg_ueq(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fneg %arg0 : f16 + %2 = llvm.fcmp "ord" %1, %0 : f16 + %3 = llvm.fcmp "ueq" %1, %arg1 : f16 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @fcmp_ord_and_fneg_fabs_ueq(%arg0: f16, %arg1: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.intr.fabs(%arg0) : (f16) -> f16 + %2 = llvm.fneg %1 : f16 + %3 = llvm.fcmp "ord" %arg0, %0 : f16 + %4 = llvm.fcmp "ueq" %2, %arg1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @fcmp_ord_and_copysign_ueq(%arg0: f16, %arg1: f16, %arg2: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.intr.copysign(%arg0, %arg2) : (f16, f16) -> f16 + %2 = llvm.fcmp "ord" %arg0, %0 : f16 + %3 = llvm.fcmp "ueq" %1, %arg1 : f16 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @fcmp_copysign_ord_and_ueq(%arg0: f16, %arg1: f16, %arg2: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.intr.copysign(%arg0, %arg2) : (f16, f16) -> f16 + %2 = llvm.fcmp "ord" %1, %0 : f16 + %3 = llvm.fcmp "ueq" %arg0, %arg1 : f16 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @fcmp_ord_and_copysign_ueq_commute(%arg0: f16, %arg1: f16, %arg2: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.intr.copysign(%arg0, %arg2) : (f16, f16) -> f16 + %2 = llvm.fcmp "ord" %arg0, %0 : f16 + %3 = llvm.fcmp "ueq" %arg1, %1 : f16 + %4 = llvm.and %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @fcmp_ord_and_copysign_fneg_ueq(%arg0: f16, %arg1: f16, %arg2: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.fneg %arg0 : f16 + %2 = llvm.intr.copysign(%1, %arg2) : (f16, f16) -> f16 + %3 = llvm.fcmp "ord" %arg0, %0 : f16 + %4 = llvm.fcmp "ueq" %2, %arg1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @fcmp_ord_and_fneg_copysign_ueq(%arg0: f16, %arg1: f16, %arg2: f16) -> i1 { + %0 = llvm.mlir.constant(0.000000e+00 : f16) : f16 + %1 = llvm.intr.copysign(%arg0, %arg2) : (f16, f16) -> f16 + %2 = llvm.fneg %1 : f16 + %3 = llvm.fcmp "ord" %arg0, %0 : f16 + %4 = llvm.fcmp "ueq" %2, %arg1 : f16 + %5 = llvm.and %3, %4 : i1 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/unordered-fcmp-select.ll.mlir b/test/LLVMDialect/InstCombine/unordered-fcmp-select.ll.mlir new file mode 100644 index 000000000..4750adf1a --- /dev/null +++ b/test/LLVMDialect/InstCombine/unordered-fcmp-select.ll.mlir @@ -0,0 +1,65 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @select_max_ugt(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_max_uge(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_min_ugt(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %0, %arg1, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_min_uge(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %0, %arg1, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_max_ult(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %0, %arg1, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_max_ule(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %0, %arg1, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_min_ult(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "ult" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_min_ule(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "ule" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_fcmp_une(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "une" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_fcmp_ueq(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "ueq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @foo(i1) + llvm.func @select_max_ugt_2_use_cmp(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "ugt" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @foo(%0) : (i1) -> () + %1 = llvm.select %0, %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } + llvm.func @select_min_uge_2_use_cmp(%arg0: f32, %arg1: f32) -> f32 { + %0 = llvm.fcmp "uge" %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + llvm.call @foo(%0) : (i1) -> () + %1 = llvm.select %0, %arg1, %arg0 {fastmathFlags = #llvm.fastmath} : i1, f32 + llvm.return %1 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/unpack-fca.ll.mlir b/test/LLVMDialect/InstCombine/unpack-fca.ll.mlir new file mode 100644 index 000000000..a2b75b316 --- /dev/null +++ b/test/LLVMDialect/InstCombine/unpack-fca.ll.mlir @@ -0,0 +1,160 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @A__vtblZ() {addr_space = 0 : i32} : !llvm.struct<"A__vtbl", (ptr, ptr)> { + %0 = llvm.mlir.addressof @A.foo : !llvm.ptr + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.struct<"A__vtbl", (ptr, ptr)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"A__vtbl", (ptr, ptr)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"A__vtbl", (ptr, ptr)> + llvm.return %4 : !llvm.struct<"A__vtbl", (ptr, ptr)> + } + llvm.func @A.foo(!llvm.ptr {llvm.nocapture}) -> i32 + llvm.func @storeA(%arg0: !llvm.ptr) { + %0 = llvm.mlir.addressof @A.foo : !llvm.ptr + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.struct<"A__vtbl", (ptr, ptr)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"A__vtbl", (ptr, ptr)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"A__vtbl", (ptr, ptr)> + %5 = llvm.mlir.addressof @A__vtblZ : !llvm.ptr + %6 = llvm.mlir.undef : !llvm.struct<"A", (ptr)> + %7 = llvm.insertvalue %5, %6[0] : !llvm.struct<"A", (ptr)> + llvm.store %7, %arg0 {alignment = 8 : i64} : !llvm.struct<"A", (ptr)>, !llvm.ptr + llvm.return + } + llvm.func @storeB(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.struct<"B", (ptr, i64)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"B", (ptr, i64)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"B", (ptr, i64)> + llvm.store %4, %arg0 {alignment = 8 : i64} : !llvm.struct<"B", (ptr, i64)>, !llvm.ptr + llvm.return + } + llvm.func @storeStructOfA(%arg0: !llvm.ptr) { + %0 = llvm.mlir.addressof @A.foo : !llvm.ptr + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.struct<"A__vtbl", (ptr, ptr)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"A__vtbl", (ptr, ptr)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"A__vtbl", (ptr, ptr)> + %5 = llvm.mlir.addressof @A__vtblZ : !llvm.ptr + %6 = llvm.mlir.undef : !llvm.struct<"A", (ptr)> + %7 = llvm.insertvalue %5, %6[0] : !llvm.struct<"A", (ptr)> + %8 = llvm.mlir.undef : !llvm.struct<(struct<"A", (ptr)>)> + %9 = llvm.insertvalue %7, %8[0] : !llvm.struct<(struct<"A", (ptr)>)> + llvm.store %9, %arg0 {alignment = 8 : i64} : !llvm.struct<(struct<"A", (ptr)>)>, !llvm.ptr + llvm.return + } + llvm.func @storeArrayOfA(%arg0: !llvm.ptr) { + %0 = llvm.mlir.addressof @A.foo : !llvm.ptr + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.struct<"A__vtbl", (ptr, ptr)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"A__vtbl", (ptr, ptr)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"A__vtbl", (ptr, ptr)> + %5 = llvm.mlir.addressof @A__vtblZ : !llvm.ptr + %6 = llvm.mlir.undef : !llvm.struct<"A", (ptr)> + %7 = llvm.insertvalue %5, %6[0] : !llvm.struct<"A", (ptr)> + %8 = llvm.mlir.undef : !llvm.array<1 x struct<"A", (ptr)>> + %9 = llvm.insertvalue %7, %8[0] : !llvm.array<1 x struct<"A", (ptr)>> + llvm.store %9, %arg0 {alignment = 8 : i64} : !llvm.array<1 x struct<"A", (ptr)>>, !llvm.ptr + llvm.return + } + llvm.func @storeLargeArrayOfA(%arg0: !llvm.ptr) { + %0 = llvm.mlir.poison : !llvm.array<2000 x struct<"A", (ptr)>> + %1 = llvm.mlir.addressof @A.foo : !llvm.ptr + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.mlir.undef : !llvm.struct<"A__vtbl", (ptr, ptr)> + %4 = llvm.insertvalue %2, %3[0] : !llvm.struct<"A__vtbl", (ptr, ptr)> + %5 = llvm.insertvalue %1, %4[1] : !llvm.struct<"A__vtbl", (ptr, ptr)> + %6 = llvm.mlir.addressof @A__vtblZ : !llvm.ptr + %7 = llvm.mlir.undef : !llvm.struct<"A", (ptr)> + %8 = llvm.insertvalue %6, %7[0] : !llvm.struct<"A", (ptr)> + %9 = llvm.insertvalue %8, %0[1] : !llvm.array<2000 x struct<"A", (ptr)>> + llvm.store %9, %arg0 {alignment = 8 : i64} : !llvm.array<2000 x struct<"A", (ptr)>>, !llvm.ptr + llvm.return + } + llvm.func @storeStructOfArrayOfA(%arg0: !llvm.ptr) { + %0 = llvm.mlir.addressof @A.foo : !llvm.ptr + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.struct<"A__vtbl", (ptr, ptr)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"A__vtbl", (ptr, ptr)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"A__vtbl", (ptr, ptr)> + %5 = llvm.mlir.addressof @A__vtblZ : !llvm.ptr + %6 = llvm.mlir.undef : !llvm.struct<"A", (ptr)> + %7 = llvm.insertvalue %5, %6[0] : !llvm.struct<"A", (ptr)> + %8 = llvm.mlir.undef : !llvm.array<1 x struct<"A", (ptr)>> + %9 = llvm.insertvalue %7, %8[0] : !llvm.array<1 x struct<"A", (ptr)>> + %10 = llvm.mlir.undef : !llvm.struct<(array<1 x struct<"A", (ptr)>>)> + %11 = llvm.insertvalue %9, %10[0] : !llvm.struct<(array<1 x struct<"A", (ptr)>>)> + llvm.store %11, %arg0 {alignment = 8 : i64} : !llvm.struct<(array<1 x struct<"A", (ptr)>>)>, !llvm.ptr + llvm.return + } + llvm.func @storeArrayOfB(%arg0: !llvm.ptr, %arg1: !llvm.array<2 x struct<"B", (ptr, i64)>>) { + llvm.store %arg1, %arg0 {alignment = 8 : i64} : !llvm.array<2 x struct<"B", (ptr, i64)>>, !llvm.ptr + llvm.return + } + llvm.func @loadA(%arg0: !llvm.ptr) -> !llvm.struct<"A", (ptr)> { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.struct<"A", (ptr)> + llvm.return %0 : !llvm.struct<"A", (ptr)> + } + llvm.func @loadB(%arg0: !llvm.ptr) -> !llvm.struct<"B", (ptr, i64)> { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.struct<"B", (ptr, i64)> + llvm.return %0 : !llvm.struct<"B", (ptr, i64)> + } + llvm.func @loadStructOfA(%arg0: !llvm.ptr) -> !llvm.struct<(struct<"A", (ptr)>)> { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.struct<(struct<"A", (ptr)>)> + llvm.return %0 : !llvm.struct<(struct<"A", (ptr)>)> + } + llvm.func @loadArrayOfA(%arg0: !llvm.ptr) -> !llvm.array<1 x struct<"A", (ptr)>> { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.array<1 x struct<"A", (ptr)>> + llvm.return %0 : !llvm.array<1 x struct<"A", (ptr)>> + } + llvm.func @loadStructOfArrayOfA(%arg0: !llvm.ptr) -> !llvm.struct<(array<1 x struct<"A", (ptr)>>)> { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.struct<(array<1 x struct<"A", (ptr)>>)> + llvm.return %0 : !llvm.struct<(array<1 x struct<"A", (ptr)>>)> + } + llvm.func @structOfA(%arg0: !llvm.ptr) -> !llvm.struct<(struct<"A", (ptr)>)> { + %0 = llvm.mlir.addressof @A.foo : !llvm.ptr + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.struct<"A__vtbl", (ptr, ptr)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"A__vtbl", (ptr, ptr)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"A__vtbl", (ptr, ptr)> + %5 = llvm.mlir.addressof @A__vtblZ : !llvm.ptr + %6 = llvm.mlir.undef : !llvm.struct<"A", (ptr)> + %7 = llvm.insertvalue %5, %6[0] : !llvm.struct<"A", (ptr)> + %8 = llvm.mlir.undef : !llvm.struct<(struct<"A", (ptr)>)> + %9 = llvm.insertvalue %7, %8[0] : !llvm.struct<(struct<"A", (ptr)>)> + llvm.store %9, %arg0 {alignment = 8 : i64} : !llvm.struct<(struct<"A", (ptr)>)>, !llvm.ptr + %10 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.struct<(struct<"A", (ptr)>)> + llvm.return %10 : !llvm.struct<(struct<"A", (ptr)>)> + } + llvm.func @structB(%arg0: !llvm.ptr) -> !llvm.struct<"B", (ptr, i64)> { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.mlir.zero : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.struct<"B", (ptr, i64)> + %3 = llvm.insertvalue %1, %2[0] : !llvm.struct<"B", (ptr, i64)> + %4 = llvm.insertvalue %0, %3[1] : !llvm.struct<"B", (ptr, i64)> + llvm.store %4, %arg0 {alignment = 8 : i64} : !llvm.struct<"B", (ptr, i64)>, !llvm.ptr + %5 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.struct<"B", (ptr, i64)> + llvm.return %5 : !llvm.struct<"B", (ptr, i64)> + } + llvm.func @loadArrayOfB(%arg0: !llvm.ptr) -> !llvm.array<2 x struct<"B", (ptr, i64)>> { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.array<2 x struct<"B", (ptr, i64)>> + llvm.return %0 : !llvm.array<2 x struct<"B", (ptr, i64)>> + } + llvm.func @loadLargeArrayOfB(%arg0: !llvm.ptr) -> !llvm.array<2000 x struct<"B", (ptr, i64)>> { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.array<2000 x struct<"B", (ptr, i64)>> + llvm.return %0 : !llvm.array<2000 x struct<"B", (ptr, i64)>> + } + llvm.func @packed_alignment(%arg0: !llvm.ptr {llvm.dereferenceable = 9 : i64}) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.getelementptr inbounds %arg0[%0, 1] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.S", packed (i8, struct<"struct.T", (i32, i32)>)> + %3 = llvm.load %2 {alignment = 1 : i64} : !llvm.ptr -> !llvm.struct<"struct.T", (i32, i32)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<"struct.T", (i32, i32)> + llvm.return %4 : i32 + } + llvm.func @check_alignment(%arg0: !llvm.ptr, %arg1: !llvm.ptr) { + %0 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> !llvm.struct<"struct.U", (i8, i8, i8, i8, i8, i8, i8, i8, i64)> + llvm.store %0, %arg1 {alignment = 8 : i64} : !llvm.struct<"struct.U", (i8, i8, i8, i8, i8, i8, i8, i8, i64)>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/unreachable-code.ll.mlir b/test/LLVMDialect/InstCombine/unreachable-code.ll.mlir new file mode 100644 index 000000000..072e4ffce --- /dev/null +++ b/test/LLVMDialect/InstCombine/unreachable-code.ll.mlir @@ -0,0 +1,292 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @dummy() + llvm.func @br_true(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.or %arg0, %0 : i1 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb3(%2 : i32) + ^bb2: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb3(%1 : i32) + ^bb3(%4: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %4 : i32 + } + llvm.func @br_false(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.and %arg0, %0 : i1 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb3(%2 : i32) + ^bb2: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb3(%1 : i32) + ^bb3(%4: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %4 : i32 + } + llvm.func @br_undef(%arg0: i1) -> i32 { + %0 = llvm.mlir.undef : i1 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.xor %arg0, %0 : i1 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb3(%2 : i32) + ^bb2: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb3(%1 : i32) + ^bb3(%4: i32): // 2 preds: ^bb1, ^bb2 + llvm.return %4 : i32 + } + llvm.func @br_true_phi_with_repeated_preds(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.or %arg0, %0 : i1 + llvm.cond_br %4, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb3(%3 : i32) + ^bb2: // pred: ^bb0 + llvm.cond_br %2, ^bb3(%1 : i32), ^bb3(%1 : i32) + ^bb3(%5: i32): // 3 preds: ^bb1, ^bb2, ^bb2 + llvm.return %5 : i32 + } + llvm.func @br_true_const_phi_direct_edge(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(2 : i32) : i32 + llvm.cond_br %1, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%2 : i32) + ^bb2(%3: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %3 : i32 + } + llvm.func @br_true_var_phi_direct_edge(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.or %arg0, %0 : i1 + llvm.cond_br %3, ^bb1, ^bb2(%1 : i32) + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2(%2 : i32) + ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @switch_case(%arg0: i32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + llvm.switch %1 : i32, ^bb2 [ + 0: ^bb1 + ] + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.return + } + llvm.func @switch_default(%arg0: i32) { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %0 : i32 + llvm.switch %1 : i32, ^bb2 [ + 0: ^bb1 + ] + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.return + } + llvm.func @switch_undef(%arg0: i32) { + %0 = llvm.mlir.undef : i32 + %1 = llvm.xor %arg0, %0 : i32 + llvm.switch %1 : i32, ^bb2 [ + 0: ^bb1 + ] + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.return + } + llvm.func @non_term_unreachable() { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.poison : !llvm.ptr + llvm.call @dummy() : () -> () + llvm.call @dummy() : () -> () + llvm.store %0, %1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.call @dummy() : () -> () + llvm.return + } + llvm.func @non_term_unreachable_phi(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.poison : !llvm.ptr + %3 = llvm.mlir.constant(1 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + llvm.store %1, %2 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.call @dummy() : () -> () + llvm.br ^bb2(%3 : i32) + ^bb2(%4: i32): // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @non_term_unreachable_following_blocks() { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.poison : !llvm.ptr + llvm.call @dummy() : () -> () + llvm.store %0, %1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.call @dummy() : () -> () + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb1, ^bb2 + llvm.call @dummy() : () -> () + llvm.br ^bb2 + } + llvm.func @br_not_into_loop(%arg0: i1) { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.or %arg0, %0 : i1 + llvm.cond_br %1, ^bb2, ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb1 + llvm.call @dummy() : () -> () + llvm.br ^bb1 + ^bb2: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.return + } + llvm.func @br_into_loop(%arg0: i1) { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.or %arg0, %0 : i1 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // 2 preds: ^bb0, ^bb1 + llvm.call @dummy() : () -> () + llvm.br ^bb1 + ^bb2: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.return + } + llvm.func @two_br_not_into_loop(%arg0: i1) { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.or %arg0, %0 : i1 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.or %arg0, %0 : i1 + llvm.cond_br %2, ^bb3, ^bb2 + ^bb2: // 3 preds: ^bb0, ^bb1, ^bb2 + llvm.call @dummy() : () -> () + llvm.br ^bb2 + ^bb3: // pred: ^bb1 + llvm.call @dummy() : () -> () + llvm.return + } + llvm.func @one_br_into_loop_one_not(%arg0: i1, %arg1: i1) { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.or %arg0, %0 : i1 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.cond_br %arg1, ^bb3, ^bb2 + ^bb2: // 3 preds: ^bb0, ^bb1, ^bb2 + llvm.call @dummy() : () -> () + llvm.br ^bb2 + ^bb3: // pred: ^bb1 + llvm.call @dummy() : () -> () + llvm.return + } + llvm.func @two_br_not_into_loop_with_split(%arg0: i1) { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.or %arg0, %0 : i1 + llvm.cond_br %1, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %2 = llvm.or %arg0, %0 : i1 + llvm.cond_br %2, ^bb5, ^bb3 + ^bb2: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.br ^bb4 + ^bb3: // pred: ^bb1 + llvm.call @dummy() : () -> () + llvm.br ^bb4 + ^bb4: // 3 preds: ^bb2, ^bb3, ^bb4 + llvm.call @dummy() : () -> () + llvm.br ^bb4 + ^bb5: // pred: ^bb1 + llvm.call @dummy() : () -> () + llvm.return + } + llvm.func @irreducible() { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(true) : i1 + llvm.cond_br %0, ^bb2, ^bb1 + ^bb1: // 2 preds: ^bb0, ^bb2 + llvm.call @dummy() : () -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.call @dummy() : () -> () + llvm.cond_br %1, ^bb3, ^bb1 + ^bb3: // pred: ^bb2 + llvm.call @dummy() : () -> () + llvm.return + } + llvm.func @really_unreachable() { + llvm.return + } + llvm.func @really_unreachable_predecessor() { + %0 = llvm.mlir.constant(false) : i1 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.return + ^bb2: // pred: ^bb0 + llvm.call @dummy() : () -> () + llvm.return + } + llvm.func @pr64235() -> i32 { + %0 = llvm.mlir.constant(false) : i1 + llvm.cond_br %0, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + "llvm.intr.assume"(%0) : (i1) -> () + llvm.br ^bb3 + ^bb2: // 2 preds: ^bb0, ^bb3 + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + "llvm.intr.assume"(%0) : (i1) -> () + llvm.br ^bb2 + } + llvm.func @invoke(!llvm.ptr) + llvm.func @__gxx_personality_v0(...) -> i32 + llvm.func @test(%arg0: i1) attributes {personality = @__gxx_personality_v0} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.ptr + %2 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.cond_br %arg0, ^bb1, ^bb5 + ^bb1: // pred: ^bb0 + llvm.store %0, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.invoke @invoke(%2) to ^bb2 unwind ^bb3 : (!llvm.ptr) -> () + ^bb2: // pred: ^bb1 + llvm.invoke @invoke(%2) to ^bb5 unwind ^bb4 : (!llvm.ptr) -> () + ^bb3: // pred: ^bb1 + %3 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)> + llvm.br ^bb5 + ^bb4: // pred: ^bb2 + %4 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)> + llvm.br ^bb6 + ^bb5: // 3 preds: ^bb0, ^bb2, ^bb3 + llvm.return + ^bb6: // pred: ^bb4 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/unreachable-dbg-info-modified.ll.mlir b/test/LLVMDialect/InstCombine/unreachable-dbg-info-modified.ll.mlir new file mode 100644 index 000000000..c527cd95e --- /dev/null +++ b/test/LLVMDialect/InstCombine/unreachable-dbg-info-modified.ll.mlir @@ -0,0 +1,18 @@ +#di_basic_type = #llvm.di_basic_type +#di_file = #llvm.di_file<"foo.c" in "/"> +#di_compile_unit = #llvm.di_compile_unit, sourceLanguage = DW_LANG_C99, file = #di_file, producer = "clang version 12.0.0", isOptimized = true, emissionKind = Full> +#di_subroutine_type = #llvm.di_subroutine_type +#di_subprogram = #llvm.di_subprogram, compileUnit = #di_compile_unit, scope = #di_file, name = "foo", file = #di_file, line = 1, scopeLine = 1, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type> +#di_local_variable = #llvm.di_local_variable +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo() -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.undef : i32 + llvm.intr.dbg.value #di_local_variable = %1 : i32 + llvm.cond_br %0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/unrecognized_three-way-comparison.ll.mlir b/test/LLVMDialect/InstCombine/unrecognized_three-way-comparison.ll.mlir new file mode 100644 index 000000000..6d26f3300 --- /dev/null +++ b/test/LLVMDialect/InstCombine/unrecognized_three-way-comparison.ll.mlir @@ -0,0 +1,430 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(i32) + llvm.func @compare_against_arbitrary_value(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %arg1 : i32 + %5 = llvm.icmp "slt" %arg0, %arg1 : i32 + %6 = llvm.select %5, %0, %1 : i1, i32 + %7 = llvm.select %4, %2, %6 : i1, i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + llvm.cond_br %8, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%7) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %3 : i32 + } + llvm.func @compare_against_zero(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %0 : i32 + %5 = llvm.icmp "slt" %arg0, %0 : i32 + %6 = llvm.select %5, %1, %2 : i1, i32 + %7 = llvm.select %4, %0, %6 : i1, i32 + %8 = llvm.icmp "sgt" %7, %0 : i32 + llvm.cond_br %8, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%7) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %3 : i32 + } + llvm.func @compare_against_one(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %0 : i32 + %5 = llvm.icmp "slt" %arg0, %0 : i32 + %6 = llvm.select %5, %1, %0 : i1, i32 + %7 = llvm.select %4, %2, %6 : i1, i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + llvm.cond_br %8, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%7) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %3 : i32 + } + llvm.func @compare_against_two(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(42 : i32) : i32 + %5 = llvm.icmp "eq" %arg0, %0 : i32 + %6 = llvm.icmp "slt" %arg0, %0 : i32 + %7 = llvm.select %6, %1, %2 : i1, i32 + %8 = llvm.select %5, %3, %7 : i1, i32 + %9 = llvm.icmp "sgt" %8, %3 : i32 + llvm.cond_br %9, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%8) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @compare_against_three(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(42 : i32) : i32 + %5 = llvm.icmp "eq" %arg0, %0 : i32 + %6 = llvm.icmp "slt" %arg0, %0 : i32 + %7 = llvm.select %6, %1, %2 : i1, i32 + %8 = llvm.select %5, %3, %7 : i1, i32 + %9 = llvm.icmp "sgt" %8, %3 : i32 + llvm.cond_br %9, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%8) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @compare_against_four(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(42 : i32) : i32 + %5 = llvm.icmp "eq" %arg0, %0 : i32 + %6 = llvm.icmp "slt" %arg0, %0 : i32 + %7 = llvm.select %6, %1, %2 : i1, i32 + %8 = llvm.select %5, %3, %7 : i1, i32 + %9 = llvm.icmp "sgt" %8, %3 : i32 + llvm.cond_br %9, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%8) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @compare_against_five(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(42 : i32) : i32 + %5 = llvm.icmp "eq" %arg0, %0 : i32 + %6 = llvm.icmp "slt" %arg0, %0 : i32 + %7 = llvm.select %6, %1, %2 : i1, i32 + %8 = llvm.select %5, %3, %7 : i1, i32 + %9 = llvm.icmp "sgt" %8, %3 : i32 + llvm.cond_br %9, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%8) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @compare_against_six(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(6 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(42 : i32) : i32 + %5 = llvm.icmp "eq" %arg0, %0 : i32 + %6 = llvm.icmp "slt" %arg0, %0 : i32 + %7 = llvm.select %6, %1, %2 : i1, i32 + %8 = llvm.select %5, %3, %7 : i1, i32 + %9 = llvm.icmp "sgt" %8, %3 : i32 + llvm.cond_br %9, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%8) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @compare_against_arbitrary_value_non_idiomatic_1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-6 : i32) : i32 + %1 = llvm.mlir.constant(425 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %arg1 : i32 + %5 = llvm.icmp "slt" %arg0, %arg1 : i32 + %6 = llvm.select %5, %0, %1 : i1, i32 + %7 = llvm.select %4, %2, %6 : i1, i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + llvm.cond_br %8, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%7) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %3 : i32 + } + llvm.func @compare_against_zero_non_idiomatic_add(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-6 : i32) : i32 + %2 = llvm.mlir.constant(425 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %0 : i32 + %5 = llvm.icmp "slt" %arg0, %0 : i32 + %6 = llvm.select %5, %1, %2 : i1, i32 + %7 = llvm.select %4, %0, %6 : i1, i32 + %8 = llvm.icmp "sgt" %7, %0 : i32 + llvm.cond_br %8, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%7) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %3 : i32 + } + llvm.func @compare_against_arbitrary_value_non_idiomatic_2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-5 : i32) : i32 + %1 = llvm.mlir.constant(425 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %arg1 : i32 + %5 = llvm.icmp "slt" %arg0, %arg1 : i32 + %6 = llvm.select %5, %0, %1 : i1, i32 + %7 = llvm.select %4, %2, %6 : i1, i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + llvm.cond_br %8, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%7) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %3 : i32 + } + llvm.func @compare_against_zero_non_idiomatic_or(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-5 : i32) : i32 + %2 = llvm.mlir.constant(425 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %0 : i32 + %5 = llvm.icmp "slt" %arg0, %0 : i32 + %6 = llvm.select %5, %1, %2 : i1, i32 + %7 = llvm.select %4, %0, %6 : i1, i32 + %8 = llvm.icmp "sgt" %7, %0 : i32 + llvm.cond_br %8, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%7) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %3 : i32 + } + llvm.func @compare_against_arbitrary_value_type_mismatch(%arg0: i64, %arg1: i64) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %arg1 : i64 + %5 = llvm.icmp "slt" %arg0, %arg1 : i64 + %6 = llvm.select %5, %0, %1 : i1, i32 + %7 = llvm.select %4, %2, %6 : i1, i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + llvm.cond_br %8, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%7) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %3 : i32 + } + llvm.func @compare_against_zero_type_mismatch_idiomatic(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(42 : i32) : i32 + %5 = llvm.icmp "eq" %arg0, %0 : i64 + %6 = llvm.icmp "slt" %arg0, %0 : i64 + %7 = llvm.select %6, %1, %2 : i1, i32 + %8 = llvm.select %5, %3, %7 : i1, i32 + %9 = llvm.icmp "sgt" %8, %3 : i32 + llvm.cond_br %9, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%8) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @compare_against_zero_type_mismatch_non_idiomatic_1(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(-7 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(42 : i32) : i32 + %5 = llvm.icmp "eq" %arg0, %0 : i64 + %6 = llvm.icmp "slt" %arg0, %0 : i64 + %7 = llvm.select %6, %1, %2 : i1, i32 + %8 = llvm.select %5, %3, %7 : i1, i32 + %9 = llvm.icmp "sgt" %8, %3 : i32 + llvm.cond_br %9, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%8) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @compare_against_zero_type_mismatch_non_idiomatic_2(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(-6 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(42 : i32) : i32 + %5 = llvm.icmp "eq" %arg0, %0 : i64 + %6 = llvm.icmp "slt" %arg0, %0 : i64 + %7 = llvm.select %6, %1, %2 : i1, i32 + %8 = llvm.select %5, %3, %7 : i1, i32 + %9 = llvm.icmp "sgt" %8, %3 : i32 + llvm.cond_br %9, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%8) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @use1(i1) + llvm.func @compare_against_fortytwo_commutatibility_0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(84 : i32) : i32 + %5 = llvm.icmp "eq" %arg0, %0 : i32 + %6 = llvm.icmp "slt" %arg0, %0 : i32 + %7 = llvm.select %6, %1, %2 : i1, i32 + %8 = llvm.select %5, %3, %7 : i1, i32 + %9 = llvm.icmp "sgt" %8, %3 : i32 + llvm.cond_br %9, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%8) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @compare_against_fortytwo_commutatibility_1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(84 : i32) : i32 + %5 = llvm.icmp "ne" %arg0, %0 : i32 + llvm.call @use1(%5) : (i1) -> () + %6 = llvm.icmp "slt" %arg0, %0 : i32 + %7 = llvm.select %6, %1, %2 : i1, i32 + %8 = llvm.select %5, %7, %3 : i1, i32 + %9 = llvm.icmp "sgt" %8, %3 : i32 + llvm.cond_br %9, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%8) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %4 : i32 + } + llvm.func @compare_against_fortytwo_commutatibility_2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(41 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(-1 : i32) : i32 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(84 : i32) : i32 + %6 = llvm.icmp "eq" %arg0, %0 : i32 + %7 = llvm.icmp "sgt" %arg0, %1 : i32 + %8 = llvm.select %7, %2, %3 : i1, i32 + %9 = llvm.select %6, %4, %8 : i1, i32 + %10 = llvm.icmp "sgt" %9, %4 : i32 + llvm.cond_br %10, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%9) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %5 : i32 + } + llvm.func @compare_against_fortytwo_commutatibility_3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(41 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(-1 : i32) : i32 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(84 : i32) : i32 + %6 = llvm.icmp "ne" %arg0, %0 : i32 + llvm.call @use1(%6) : (i1) -> () + %7 = llvm.icmp "sgt" %arg0, %1 : i32 + %8 = llvm.select %7, %2, %3 : i1, i32 + %9 = llvm.select %6, %8, %4 : i1, i32 + %10 = llvm.icmp "sgt" %9, %4 : i32 + llvm.cond_br %10, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%9) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %5 : i32 + } + llvm.func @compare_against_arbitrary_value_commutativity0(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %arg1 : i32 + %5 = llvm.icmp "slt" %arg0, %arg1 : i32 + %6 = llvm.select %5, %0, %1 : i1, i32 + %7 = llvm.select %4, %2, %6 : i1, i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + llvm.cond_br %8, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%7) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %3 : i32 + } + llvm.func @compare_against_arbitrary_value_commutativity1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.icmp "eq" %arg0, %arg1 : i32 + %5 = llvm.icmp "sgt" %arg1, %arg0 : i32 + %6 = llvm.select %5, %0, %1 : i1, i32 + %7 = llvm.select %4, %2, %6 : i1, i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + llvm.cond_br %8, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%7) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %3 : i32 + } + llvm.func @compare_against_arbitrary_value_commutativity2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.icmp "ne" %arg0, %arg1 : i32 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.icmp "slt" %arg0, %arg1 : i32 + %6 = llvm.select %5, %0, %1 : i1, i32 + %7 = llvm.select %4, %6, %2 : i1, i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + llvm.cond_br %8, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%7) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %3 : i32 + } + llvm.func @compare_against_arbitrary_value_commutativity3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(42 : i32) : i32 + %4 = llvm.icmp "ne" %arg0, %arg1 : i32 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.icmp "sgt" %arg1, %arg0 : i32 + %6 = llvm.select %5, %0, %1 : i1, i32 + %7 = llvm.select %4, %6, %2 : i1, i32 + %8 = llvm.icmp "sgt" %7, %2 : i32 + llvm.cond_br %8, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.call @foo(%7) : (i32) -> () + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.return %3 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/unsigned-add-lack-of-overflow-check-via-add.ll.mlir b/test/LLVMDialect/InstCombine/unsigned-add-lack-of-overflow-check-via-add.ll.mlir index 85ce025e9..7cff59c74 100644 --- a/test/LLVMDialect/InstCombine/unsigned-add-lack-of-overflow-check-via-add.ll.mlir +++ b/test/LLVMDialect/InstCombine/unsigned-add-lack-of-overflow-check-via-add.ll.mlir @@ -1,123 +1,104 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use2x8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0_basic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.call"(%0) {callee = @use2x8, fastmathFlags = #llvm.fastmath<>} : (vector<2xi8>) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 9 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t1_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg0) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t2_symmetry", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.add"(%0, %arg0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %0) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t3_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %2 = "llvm.add"(%0, %1) : (i8, i8) -> i8 - "llvm.call"(%2) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %3 = "llvm.icmp"(%1, %2) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t4_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.add"(%0, %arg0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%0, %1) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t5_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t6_no_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg2) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n7_different_y", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n8_wrong_pred0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n9_wrong_pred1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n10_wrong_pred2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n11_wrong_pred3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n12_wrong_pred4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 3 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n13_wrong_pred5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n14_wrong_pred6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 5 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n15_wrong_pred7", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use2x8(vector<2xi8>) + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "uge" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @t1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.add %arg0, %arg1 : vector<2xi8> + llvm.call @use2x8(%0) : (vector<2xi8>) -> () + %1 = llvm.icmp "uge" %0, %arg1 : vector<2xi8> + llvm.return %1 : vector<2xi1> + } + llvm.func @t2_symmetry(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "uge" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @gen8() -> i8 + llvm.func @t3_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.add %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "uge" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @t4_commutative() -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.call @gen8() : () -> i8 + %2 = llvm.add %0, %1 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ule" %1, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @t5_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.add %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ule" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @t6_no_extrause(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "uge" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n7_different_y(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "uge" %0, %arg2 : i8 + llvm.return %1 : i1 + } + llvm.func @n8_wrong_pred0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "ule" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n9_wrong_pred1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "ugt" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n10_wrong_pred2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "eq" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n11_wrong_pred3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "ne" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n12_wrong_pred4(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "slt" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n13_wrong_pred5(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "sle" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n14_wrong_pred6(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "sgt" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n15_wrong_pred7(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "sge" %0, %arg1 : i8 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/unsigned-add-lack-of-overflow-check-via-xor.ll.mlir b/test/LLVMDialect/InstCombine/unsigned-add-lack-of-overflow-check-via-xor.ll.mlir index a36fbe3cb..f23dc55d9 100644 --- a/test/LLVMDialect/InstCombine/unsigned-add-lack-of-overflow-check-via-xor.ll.mlir +++ b/test/LLVMDialect/InstCombine/unsigned-add-lack-of-overflow-check-via-xor.ll.mlir @@ -1,113 +1,96 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use2x8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0_basic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-1> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.xor"(%arg1, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.call"(%1) {callee = @use2x8, fastmathFlags = #llvm.fastmath<>} : (vector<2xi8>) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 9 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t1_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg0, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %3 = "llvm.icmp"(%2, %1) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t2_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg0) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t3_no_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n4_wrong_pred0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n5_wrong_pred1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n6_wrong_pred2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n7_wrong_pred3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n8_wrong_pred4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 3 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n9_wrong_pred5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n10_wrong_pred6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 5 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n11_wrong_pred7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[-1, -2]> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.xor"(%arg1, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.call"(%1) {callee = @use2x8, fastmathFlags = #llvm.fastmath<>} : (vector<2xi8>) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 9 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n12_vec_nonsplat", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use2x8(vector<2xi8>) + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "uge" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @t1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg1, %0 : vector<2xi8> + llvm.call @use2x8(%1) : (vector<2xi8>) -> () + %2 = llvm.icmp "uge" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @gen8() -> i8 + llvm.func @t2_commutative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.icmp "ule" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @t3_no_extrause(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + %2 = llvm.icmp "uge" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n4_wrong_pred0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ule" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n5_wrong_pred1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ugt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n6_wrong_pred2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "eq" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n7_wrong_pred3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n8_wrong_pred4(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "slt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n9_wrong_pred5(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "sle" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n10_wrong_pred6(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "sgt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n11_wrong_pred7(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "sge" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n12_vec_nonsplat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-1, -2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg1, %0 : vector<2xi8> + llvm.call @use2x8(%1) : (vector<2xi8>) -> () + %2 = llvm.icmp "uge" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/unsigned-add-lack-of-overflow-check.ll.mlir b/test/LLVMDialect/InstCombine/unsigned-add-lack-of-overflow-check.ll.mlir new file mode 100644 index 000000000..646952704 --- /dev/null +++ b/test/LLVMDialect/InstCombine/unsigned-add-lack-of-overflow-check.ll.mlir @@ -0,0 +1,179 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "uge" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @t1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.add %arg0, %arg1 : vector<2xi8> + %1 = llvm.icmp "uge" %0, %arg1 : vector<2xi8> + llvm.return %1 : vector<2xi1> + } + llvm.func @t2_symmetry(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "uge" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @gen8() -> i8 + llvm.func @t3_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.add %0, %arg0 : i8 + %2 = llvm.icmp "uge" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @t4_commutative(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "ule" %arg1, %0 : i8 + llvm.return %1 : i1 + } + llvm.func @t5_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.add %0, %arg0 : i8 + %2 = llvm.icmp "ule" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @use8(i8) + llvm.func @t6_extrause(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "uge" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n7_different_y(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "uge" %0, %arg2 : i8 + llvm.return %1 : i1 + } + llvm.func @n8_wrong_pred0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "ule" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n9_wrong_pred1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "ugt" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n10_wrong_pred2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "eq" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n11_wrong_pred3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "ne" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n12_wrong_pred4(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "slt" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n13_wrong_pred5(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "sle" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n14_wrong_pred6(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "sgt" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n15_wrong_pred7(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "sge" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @low_bitmask_ult(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(31 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "ult" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @low_bitmask_uge(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(15 : i8) : i8 + %2 = llvm.mlir.undef : vector<2xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi8> + %7 = llvm.mlir.constant(dense<15> : vector<2xi8>) : vector<2xi8> + %8 = llvm.add %arg0, %6 : vector<2xi8> + %9 = llvm.and %8, %7 : vector<2xi8> + %10 = llvm.icmp "uge" %9, %arg0 : vector<2xi8> + llvm.return %10 : vector<2xi1> + } + llvm.func @low_bitmask_ugt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mul %arg0, %arg0 : i8 + %2 = llvm.add %1, %0 : i8 + %3 = llvm.and %2, %0 : i8 + %4 = llvm.icmp "ugt" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @low_bitmask_ule(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<3> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mul %arg0, %arg0 : vector<2xi8> + %2 = llvm.add %1, %0 : vector<2xi8> + %3 = llvm.and %2, %0 : vector<2xi8> + %4 = llvm.icmp "ule" %1, %3 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @low_bitmask_ult_use(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.and %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.icmp "ult" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @low_bitmask_ugt_use(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mul %arg0, %arg0 : i8 + %2 = llvm.add %1, %0 : i8 + llvm.call @use8(%2) : (i8) -> () + %3 = llvm.and %2, %0 : i8 + %4 = llvm.icmp "ugt" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @low_bitmask_ult_wrong_mask1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(30 : i8) : i8 + %1 = llvm.mlir.constant(31 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "ult" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @low_bitmask_uge_wrong_mask2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(31 : i8) : i8 + %1 = llvm.mlir.constant(63 : i8) : i8 + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.and %2, %1 : i8 + %4 = llvm.icmp "uge" %3, %arg0 : i8 + llvm.return %4 : i1 + } + llvm.func @low_bitmask_ugt_swapped(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "ugt" %2, %arg0 : i8 + llvm.return %3 : i1 + } + llvm.func @low_bitmask_sgt(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mul %arg0, %arg0 : i8 + %2 = llvm.add %1, %0 : i8 + %3 = llvm.and %2, %0 : i8 + %4 = llvm.icmp "sgt" %1, %3 : i8 + llvm.return %4 : i1 + } + llvm.func @low_bitmask_ult_specific_op(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(31 : i8) : i8 + %1 = llvm.add %arg0, %0 : i8 + %2 = llvm.and %1, %0 : i8 + %3 = llvm.icmp "ult" %2, %arg1 : i8 + llvm.return %3 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/unsigned-add-overflow-check-via-add.ll.mlir b/test/LLVMDialect/InstCombine/unsigned-add-overflow-check-via-add.ll.mlir index d5da807b3..ba884f791 100644 --- a/test/LLVMDialect/InstCombine/unsigned-add-overflow-check-via-add.ll.mlir +++ b/test/LLVMDialect/InstCombine/unsigned-add-overflow-check-via-add.ll.mlir @@ -1,122 +1,102 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use2x8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0_basic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.call"(%0) {callee = @use2x8, fastmathFlags = #llvm.fastmath<>} : (vector<2xi8>) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 6 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t1_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t2_symmetry", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.add"(%0, %arg0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t3_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%arg1, %0) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t4_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.add"(%0, %arg0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%0, %1) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t5_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t6_no_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg2) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n7_different_y", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n8_wrong_pred0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n9_wrong_pred1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n10_wrong_pred2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n11_wrong_pred3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n12_wrong_pred4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 3 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n13_wrong_pred5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n14_wrong_pred6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 5 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n15_wrong_pred7", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use2x8(vector<2xi8>) + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "ult" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @t1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.add %arg0, %arg1 : vector<2xi8> + llvm.call @use2x8(%0) : (vector<2xi8>) -> () + %1 = llvm.icmp "ult" %0, %arg1 : vector<2xi8> + llvm.return %1 : vector<2xi1> + } + llvm.func @t2_symmetry(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "ult" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @gen8() -> i8 + llvm.func @t3_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.add %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ult" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @t4_commutative(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "ugt" %arg1, %0 : i8 + llvm.return %1 : i1 + } + llvm.func @t5_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.add %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ugt" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @t6_no_extrause(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "ult" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n7_different_y(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "ult" %0, %arg2 : i8 + llvm.return %1 : i1 + } + llvm.func @n8_wrong_pred0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "ule" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n9_wrong_pred1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "ugt" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n10_wrong_pred2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "eq" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n11_wrong_pred3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "ne" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n12_wrong_pred4(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "slt" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n13_wrong_pred5(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "sle" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n14_wrong_pred6(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "sgt" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n15_wrong_pred7(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "sge" %0, %arg1 : i8 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/unsigned-add-overflow-check-via-xor.ll.mlir b/test/LLVMDialect/InstCombine/unsigned-add-overflow-check-via-xor.ll.mlir index 5737cf4c1..08d11818f 100644 --- a/test/LLVMDialect/InstCombine/unsigned-add-overflow-check-via-xor.ll.mlir +++ b/test/LLVMDialect/InstCombine/unsigned-add-overflow-check-via-xor.ll.mlir @@ -1,113 +1,96 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use2x8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0_basic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-1> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.xor"(%arg1, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.call"(%1) {callee = @use2x8, fastmathFlags = #llvm.fastmath<>} : (vector<2xi8>) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 6 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t1_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg0, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %3 = "llvm.icmp"(%2, %1) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t2_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t3_no_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n4_wrong_pred0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n5_wrong_pred1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n6_wrong_pred2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n7_wrong_pred3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n8_wrong_pred4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 3 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n9_wrong_pred5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n10_wrong_pred6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 5 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n11_wrong_pred7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[-1, -2]> : vector<2xi8>} : () -> vector<2xi8> - %1 = "llvm.xor"(%arg1, %0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.call"(%1) {callee = @use2x8, fastmathFlags = #llvm.fastmath<>} : (vector<2xi8>) -> () - %2 = "llvm.icmp"(%1, %arg0) {predicate = 6 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n12_vec_nonsplat", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use2x8(vector<2xi8>) + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ult" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @t1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg1, %0 : vector<2xi8> + llvm.call @use2x8(%1) : (vector<2xi8>) -> () + %2 = llvm.icmp "ult" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @gen8() -> i8 + llvm.func @t2_commutative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.icmp "ule" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @t3_no_extrause(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + %2 = llvm.icmp "ult" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n4_wrong_pred0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ule" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n5_wrong_pred1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ugt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n6_wrong_pred2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "eq" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n7_wrong_pred3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n8_wrong_pred4(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "slt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n9_wrong_pred5(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "sle" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n10_wrong_pred6(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "sgt" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n11_wrong_pred7(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.xor %arg1, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "sge" %1, %arg0 : i8 + llvm.return %2 : i1 + } + llvm.func @n12_vec_nonsplat(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<[-1, -2]> : vector<2xi8>) : vector<2xi8> + %1 = llvm.xor %arg1, %0 : vector<2xi8> + llvm.call @use2x8(%1) : (vector<2xi8>) -> () + %2 = llvm.icmp "ult" %1, %arg0 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } +} diff --git a/test/LLVMDialect/InstCombine/unsigned-add-overflow-check.ll.mlir b/test/LLVMDialect/InstCombine/unsigned-add-overflow-check.ll.mlir index efedf7db1..b437413ed 100644 --- a/test/LLVMDialect/InstCombine/unsigned-add-overflow-check.ll.mlir +++ b/test/LLVMDialect/InstCombine/unsigned-add-overflow-check.ll.mlir @@ -1,106 +1,87 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0_basic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %1 = "llvm.icmp"(%0, %arg1) {predicate = 6 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t1_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t2_symmetry", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.add"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t3_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%arg1, %0) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t4_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.add"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%0, %1) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t5_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg1) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t6_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg2) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n7_different_y", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n8_wrong_pred0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n9_wrong_pred1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n10_wrong_pred2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n11_wrong_pred3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n12_wrong_pred4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 3 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n13_wrong_pred5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n14_wrong_pred6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.add"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 5 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n15_wrong_pred7", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "ult" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @t1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.add %arg0, %arg1 : vector<2xi8> + %1 = llvm.icmp "ult" %0, %arg1 : vector<2xi8> + llvm.return %1 : vector<2xi1> + } + llvm.func @t2_symmetry(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "ult" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @gen8() -> i8 + llvm.func @t3_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.add %0, %arg0 : i8 + %2 = llvm.icmp "ult" %1, %0 : i8 + llvm.return %2 : i1 + } + llvm.func @t4_commutative(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "ugt" %arg1, %0 : i8 + llvm.return %1 : i1 + } + llvm.func @t5_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.add %0, %arg0 : i8 + %2 = llvm.icmp "ugt" %0, %1 : i8 + llvm.return %2 : i1 + } + llvm.func @use8(i8) + llvm.func @t6_extrause(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "ult" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n7_different_y(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "ult" %0, %arg2 : i8 + llvm.return %1 : i1 + } + llvm.func @n8_wrong_pred0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "ule" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n9_wrong_pred1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "ugt" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n10_wrong_pred2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "eq" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n11_wrong_pred3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "ne" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n12_wrong_pred4(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "slt" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n13_wrong_pred5(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "sle" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n14_wrong_pred6(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "sgt" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n15_wrong_pred7(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.add %arg0, %arg1 : i8 + %1 = llvm.icmp "sge" %0, %arg1 : i8 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/unsigned-mul-lack-of-overflow-check-via-mul-udiv.ll.mlir b/test/LLVMDialect/InstCombine/unsigned-mul-lack-of-overflow-check-via-mul-udiv.ll.mlir index 9a8b3cc4c..34a297a26 100644 --- a/test/LLVMDialect/InstCombine/unsigned-mul-lack-of-overflow-check-via-mul-udiv.ll.mlir +++ b/test/LLVMDialect/InstCombine/unsigned-mul-lack-of-overflow-check-via-mul-udiv.ll.mlir @@ -1,91 +1,77 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.udiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg1) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0_basic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %1 = "llvm.udiv"(%0, %arg0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %2 = "llvm.icmp"(%1, %arg1) {predicate = 0 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t1_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.mul"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.udiv"(%1, %arg0) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t2_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.mul"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.udiv"(%1, %arg0) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t3_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.mul"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.udiv"(%1, %arg0) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%0, %2) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t4_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.udiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg1) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t5_extrause0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.udiv"(%0, %arg0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg1) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t6_extrause1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.udiv"(%0, %arg0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg1) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t7_extrause2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg2) : (i8, i8) -> i8 - %1 = "llvm.udiv"(%0, %arg1) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg2) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n8_different_x", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.udiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg2) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n9_different_y", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.udiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg1) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n10_wrong_pred", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "eq" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @t1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mul %arg0, %arg1 : vector<2xi8> + %1 = llvm.udiv %0, %arg0 : vector<2xi8> + %2 = llvm.icmp "eq" %1, %arg1 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @gen8() -> i8 + llvm.func @t2_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.mul %0, %arg0 : i8 + %2 = llvm.udiv %1, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %0 : i8 + llvm.return %3 : i1 + } + llvm.func @t3_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.mul %0, %arg0 : i8 + %2 = llvm.udiv %1, %arg0 : i8 + %3 = llvm.icmp "eq" %2, %0 : i8 + llvm.return %3 : i1 + } + llvm.func @t4_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.mul %0, %arg0 : i8 + %2 = llvm.udiv %1, %arg0 : i8 + %3 = llvm.icmp "eq" %0, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @use8(i8) + llvm.func @t5_extrause0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "eq" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @t6_extrause1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.udiv %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "eq" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @t7_extrause2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.udiv %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "eq" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @n8_different_x(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mul %arg0, %arg2 : i8 + %1 = llvm.udiv %0, %arg1 : i8 + %2 = llvm.icmp "eq" %1, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @n9_different_y(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "eq" %1, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @n10_wrong_pred(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "ult" %1, %arg1 : i8 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/unsigned-mul-lack-of-overflow-check-via-udiv-of-allones.ll.mlir b/test/LLVMDialect/InstCombine/unsigned-mul-lack-of-overflow-check-via-udiv-of-allones.ll.mlir new file mode 100644 index 000000000..e030a69b1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/unsigned-mul-lack-of-overflow-check-via-udiv-of-allones.ll.mlir @@ -0,0 +1,62 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "uge" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @t1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.udiv %0, %arg0 : vector<2xi8> + %2 = llvm.icmp "uge" %1, %arg1 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @t2_vec_poison(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.udiv %8, %arg0 : vector<3xi8> + %10 = llvm.icmp "uge" %9, %arg1 : vector<3xi8> + llvm.return %10 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @t3_commutative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.icmp "ule" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @use8(i8) + llvm.func @n4_extrause(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.udiv %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "uge" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @n5_not_negone(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "uge" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @n6_wrong_pred0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "ule" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @n6_wrong_pred1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "ugt" %1, %arg1 : i8 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/unsigned-mul-overflow-check-via-mul-udiv.ll.mlir b/test/LLVMDialect/InstCombine/unsigned-mul-overflow-check-via-mul-udiv.ll.mlir index 00294807a..42693f31c 100644 --- a/test/LLVMDialect/InstCombine/unsigned-mul-overflow-check-via-mul-udiv.ll.mlir +++ b/test/LLVMDialect/InstCombine/unsigned-mul-overflow-check-via-mul-udiv.ll.mlir @@ -1,91 +1,77 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.udiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg1) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0_basic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %1 = "llvm.udiv"(%0, %arg0) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %2 = "llvm.icmp"(%1, %arg1) {predicate = 1 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t1_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.mul"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.udiv"(%1, %arg0) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t2_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.mul"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.udiv"(%1, %arg0) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%2, %0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t3_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.mul"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.udiv"(%1, %arg0) : (i8, i8) -> i8 - %3 = "llvm.icmp"(%0, %2) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t4_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.udiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg1) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t5_extrause0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.udiv"(%0, %arg0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg1) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t6_extrause1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.udiv"(%0, %arg0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.icmp"(%1, %arg1) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t7_extrause2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg2) : (i8, i8) -> i8 - %1 = "llvm.udiv"(%0, %arg1) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg2) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n8_different_x", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.udiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg2) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n9_different_y", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mul"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.udiv"(%0, %arg0) : (i8, i8) -> i8 - %2 = "llvm.icmp"(%1, %arg1) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%2) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n10_wrong_pred", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "ne" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @t1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mul %arg0, %arg1 : vector<2xi8> + %1 = llvm.udiv %0, %arg0 : vector<2xi8> + %2 = llvm.icmp "ne" %1, %arg1 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @gen8() -> i8 + llvm.func @t2_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.mul %0, %arg0 : i8 + %2 = llvm.udiv %1, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %0 : i8 + llvm.return %3 : i1 + } + llvm.func @t3_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.mul %0, %arg0 : i8 + %2 = llvm.udiv %1, %arg0 : i8 + %3 = llvm.icmp "ne" %2, %0 : i8 + llvm.return %3 : i1 + } + llvm.func @t4_commutative(%arg0: i8) -> i1 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.mul %0, %arg0 : i8 + %2 = llvm.udiv %1, %arg0 : i8 + %3 = llvm.icmp "ne" %0, %2 : i8 + llvm.return %3 : i1 + } + llvm.func @use8(i8) + llvm.func @t5_extrause0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "ne" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @t6_extrause1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.udiv %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @t7_extrause2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.udiv %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ne" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @n8_different_x(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mul %arg0, %arg2 : i8 + %1 = llvm.udiv %0, %arg1 : i8 + %2 = llvm.icmp "ne" %1, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @n9_different_y(%arg0: i8, %arg1: i8, %arg2: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "ne" %1, %arg2 : i8 + llvm.return %2 : i1 + } + llvm.func @n10_wrong_pred(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mul %arg0, %arg1 : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "ugt" %1, %arg1 : i8 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/unsigned-mul-overflow-check-via-udiv-of-allones.ll.mlir b/test/LLVMDialect/InstCombine/unsigned-mul-overflow-check-via-udiv-of-allones.ll.mlir new file mode 100644 index 000000000..4cdbd85c8 --- /dev/null +++ b/test/LLVMDialect/InstCombine/unsigned-mul-overflow-check-via-udiv-of-allones.ll.mlir @@ -0,0 +1,62 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "ult" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @t1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.udiv %0, %arg0 : vector<2xi8> + %2 = llvm.icmp "ult" %1, %arg1 : vector<2xi8> + llvm.return %2 : vector<2xi1> + } + llvm.func @t2_vec_poison(%arg0: vector<3xi8>, %arg1: vector<3xi8>) -> vector<3xi1> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<3xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi8> + %9 = llvm.udiv %8, %arg0 : vector<3xi8> + %10 = llvm.icmp "ult" %9, %arg1 : vector<3xi8> + llvm.return %10 : vector<3xi1> + } + llvm.func @gen8() -> i8 + llvm.func @t3_commutative(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.call @gen8() : () -> i8 + %3 = llvm.icmp "ugt" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @use8(i8) + llvm.func @n4_extrause(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.udiv %0, %arg0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.icmp "ult" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @n5_not_negone(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "ult" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @n6_wrong_pred0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "ule" %1, %arg1 : i8 + llvm.return %2 : i1 + } + llvm.func @n6_wrong_pred1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.udiv %0, %arg0 : i8 + %2 = llvm.icmp "ugt" %1, %arg1 : i8 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/unsigned-sub-lack-of-overflow-check.ll.mlir b/test/LLVMDialect/InstCombine/unsigned-sub-lack-of-overflow-check.ll.mlir index 3b230dc05..56aa6bb00 100644 --- a/test/LLVMDialect/InstCombine/unsigned-sub-lack-of-overflow-check.ll.mlir +++ b/test/LLVMDialect/InstCombine/unsigned-sub-lack-of-overflow-check.ll.mlir @@ -1,84 +1,69 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0_basic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %1 = "llvm.icmp"(%0, %arg0) {predicate = 7 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t1_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t2_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg0) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t3_extrause0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 7 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n4_not_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n5_wrong_pred0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n6_wrong_pred1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n7_wrong_pred2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n8_wrong_pred3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n9_wrong_pred4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 3 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n10_wrong_pred5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n11_wrong_pred6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 5 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n12_wrong_pred7", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "ule" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @t1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.sub %arg0, %arg1 : vector<2xi8> + %1 = llvm.icmp "ule" %0, %arg0 : vector<2xi8> + llvm.return %1 : vector<2xi1> + } + llvm.func @t2_commutative(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "uge" %arg0, %0 : i8 + llvm.return %1 : i1 + } + llvm.func @use8(i8) + llvm.func @t3_extrause0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "ule" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n4_not_commutative(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "ule" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n5_wrong_pred0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "ult" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n6_wrong_pred1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "uge" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n7_wrong_pred2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "eq" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n8_wrong_pred3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "ne" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n9_wrong_pred4(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "slt" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n10_wrong_pred5(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "sle" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n11_wrong_pred6(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "sgt" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n12_wrong_pred7(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "sge" %0, %arg0 : i8 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/unsigned-sub-overflow-check.ll.mlir b/test/LLVMDialect/InstCombine/unsigned-sub-overflow-check.ll.mlir index 083dc286e..da2076afb 100644 --- a/test/LLVMDialect/InstCombine/unsigned-sub-overflow-check.ll.mlir +++ b/test/LLVMDialect/InstCombine/unsigned-sub-overflow-check.ll.mlir @@ -1,84 +1,69 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t0_basic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %1 = "llvm.icmp"(%0, %arg0) {predicate = 8 : i64} : (vector<2xi8>, vector<2xi8>) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t1_vec", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%arg0, %0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t2_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.icmp"(%0, %arg0) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "t3_extrause0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg1) {predicate = 8 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n4_not_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 9 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n5_wrong_pred0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 6 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n6_wrong_pred1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 0 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n7_wrong_pred2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 1 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n8_wrong_pred3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 2 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n9_wrong_pred4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 3 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n10_wrong_pred5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 4 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n11_wrong_pred6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.sub"(%arg0, %arg1) : (i8, i8) -> i8 - %1 = "llvm.icmp"(%0, %arg0) {predicate = 5 : i64} : (i8, i8) -> i1 - "llvm.return"(%1) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "n12_wrong_pred7", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "ugt" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @t1_vec(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.sub %arg0, %arg1 : vector<2xi8> + %1 = llvm.icmp "ugt" %0, %arg0 : vector<2xi8> + llvm.return %1 : vector<2xi1> + } + llvm.func @t2_commutative(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "ult" %arg0, %0 : i8 + llvm.return %1 : i1 + } + llvm.func @use8(i8) + llvm.func @t3_extrause0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.icmp "ugt" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n4_not_commutative(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "ugt" %0, %arg1 : i8 + llvm.return %1 : i1 + } + llvm.func @n5_wrong_pred0(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "uge" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n6_wrong_pred1(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "ult" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n7_wrong_pred2(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "eq" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n8_wrong_pred3(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "ne" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n9_wrong_pred4(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "slt" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n10_wrong_pred5(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "sle" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n11_wrong_pred6(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "sgt" %0, %arg0 : i8 + llvm.return %1 : i1 + } + llvm.func @n12_wrong_pred7(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.sub %arg0, %arg1 : i8 + %1 = llvm.icmp "sge" %0, %arg0 : i8 + llvm.return %1 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/unsigned_saturated_sub.ll.mlir b/test/LLVMDialect/InstCombine/unsigned_saturated_sub.ll.mlir new file mode 100644 index 000000000..d42d63515 --- /dev/null +++ b/test/LLVMDialect/InstCombine/unsigned_saturated_sub.ll.mlir @@ -0,0 +1,338 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i64) + llvm.func @usei32(i32) + llvm.func @usei1(i1) + llvm.func @usub_sat_C1_C2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(14 : i32) : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.intr.usub.sat(%2, %1) : (i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @usub_sat_C1_C2_produce_0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(14 : i32) : i32 + %1 = llvm.sub %0, %arg0 overflow : i32 + %2 = llvm.intr.usub.sat(%1, %0) : (i32, i32) -> i32 + llvm.return %2 : i32 + } + llvm.func @usub_sat_C1_C2_produce_0_too(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(14 : i32) : i32 + %2 = llvm.sub %0, %arg0 overflow : i32 + %3 = llvm.intr.usub.sat(%2, %1) : (i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @usub_sat_C1_C2_splat(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<64> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<14> : vector<2xi16>) : vector<2xi16> + %2 = llvm.sub %0, %arg0 overflow : vector<2xi16> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @usub_sat_C1_C2_non_splat(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[50, 64]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<[20, 14]> : vector<2xi16>) : vector<2xi16> + %2 = llvm.sub %0, %arg0 overflow : vector<2xi16> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @usub_sat_C1_C2_splat_produce_0(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<14> : vector<2xi16>) : vector<2xi16> + %1 = llvm.sub %0, %arg0 overflow : vector<2xi16> + %2 = llvm.intr.usub.sat(%1, %0) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> + llvm.return %2 : vector<2xi16> + } + llvm.func @usub_sat_C1_C2_splat_produce_0_too(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<12> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<14> : vector<2xi16>) : vector<2xi16> + %2 = llvm.sub %0, %arg0 overflow : vector<2xi16> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @usub_sat_C1_C2_non_splat_produce_0_too(%arg0: vector<2xi16>) -> vector<2xi16> { + %0 = llvm.mlir.constant(dense<[12, 13]> : vector<2xi16>) : vector<2xi16> + %1 = llvm.mlir.constant(dense<[14, 15]> : vector<2xi16>) : vector<2xi16> + %2 = llvm.sub %0, %arg0 overflow : vector<2xi16> + %3 = llvm.intr.usub.sat(%2, %1) : (vector<2xi16>, vector<2xi16>) -> vector<2xi16> + llvm.return %3 : vector<2xi16> + } + llvm.func @usub_sat_C1_C2_without_nuw(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(12 : i32) : i32 + %1 = llvm.mlir.constant(14 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.intr.usub.sat(%2, %1) : (i32, i32) -> i32 + llvm.return %3 : i32 + } + llvm.func @max_sub_ugt(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i64 + %2 = llvm.sub %arg0, %arg1 : i64 + %3 = llvm.select %1, %2, %0 : i1, i64 + llvm.return %3 : i64 + } + llvm.func @max_sub_uge(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "uge" %arg0, %arg1 : i64 + %2 = llvm.sub %arg0, %arg1 : i64 + %3 = llvm.select %1, %2, %0 : i1, i64 + llvm.return %3 : i64 + } + llvm.func @max_sub_uge_extrause1(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "uge" %arg0, %arg1 : i64 + %2 = llvm.sub %arg0, %arg1 : i64 + %3 = llvm.select %1, %2, %0 : i1, i64 + llvm.call @use(%2) : (i64) -> () + llvm.return %3 : i64 + } + llvm.func @max_sub_uge_extrause2(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "uge" %arg0, %arg1 : i64 + %2 = llvm.sub %arg0, %arg1 : i64 + %3 = llvm.select %1, %2, %0 : i1, i64 + llvm.call @usei1(%1) : (i1) -> () + llvm.return %3 : i64 + } + llvm.func @max_sub_uge_extrause3(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "uge" %arg0, %arg1 : i64 + %2 = llvm.sub %arg0, %arg1 : i64 + %3 = llvm.select %1, %2, %0 : i1, i64 + llvm.call @use(%2) : (i64) -> () + llvm.call @usei1(%1) : (i1) -> () + llvm.return %3 : i64 + } + llvm.func @max_sub_ugt_vec(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.icmp "ugt" %arg0, %arg1 : vector<4xi32> + %3 = llvm.sub %arg0, %arg1 : vector<4xi32> + %4 = llvm.select %2, %3, %1 : vector<4xi1>, vector<4xi32> + llvm.return %4 : vector<4xi32> + } + llvm.func @max_sub_ult(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "ult" %arg1, %arg0 : i64 + %2 = llvm.sub %arg0, %arg1 : i64 + %3 = llvm.select %1, %2, %0 : i1, i64 + %4 = llvm.sub %arg1, %arg0 : i64 + llvm.call @use(%4) : (i64) -> () + llvm.return %3 : i64 + } + llvm.func @max_sub_ugt_sel_swapped(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "ugt" %arg1, %arg0 : i64 + %2 = llvm.sub %arg0, %arg1 : i64 + %3 = llvm.select %1, %0, %2 : i1, i64 + %4 = llvm.sub %arg1, %arg0 : i64 + llvm.call @use(%4) : (i64) -> () + llvm.return %3 : i64 + } + llvm.func @max_sub_ult_sel_swapped(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "ult" %arg0, %arg1 : i64 + %2 = llvm.sub %arg0, %arg1 : i64 + %3 = llvm.select %1, %0, %2 : i1, i64 + llvm.return %3 : i64 + } + llvm.func @neg_max_sub_ugt(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i64 + %2 = llvm.sub %arg1, %arg0 : i64 + %3 = llvm.select %1, %2, %0 : i1, i64 + %4 = llvm.sub %arg0, %arg1 : i64 + llvm.call @use(%4) : (i64) -> () + llvm.return %3 : i64 + } + llvm.func @neg_max_sub_ult(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "ult" %arg1, %arg0 : i64 + %2 = llvm.sub %arg1, %arg0 : i64 + %3 = llvm.select %1, %2, %0 : i1, i64 + llvm.return %3 : i64 + } + llvm.func @neg_max_sub_ugt_sel_swapped(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "ugt" %arg1, %arg0 : i64 + %2 = llvm.sub %arg1, %arg0 : i64 + %3 = llvm.select %1, %0, %2 : i1, i64 + llvm.return %3 : i64 + } + llvm.func @neg_max_sub_ugt_sel_swapped_extrause1(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "ugt" %arg1, %arg0 : i64 + %2 = llvm.sub %arg1, %arg0 : i64 + %3 = llvm.select %1, %0, %2 : i1, i64 + llvm.call @usei1(%1) : (i1) -> () + llvm.return %3 : i64 + } + llvm.func @neg_max_sub_ugt_sel_swapped_extrause2(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "ugt" %arg1, %arg0 : i64 + %2 = llvm.sub %arg1, %arg0 : i64 + %3 = llvm.select %1, %0, %2 : i1, i64 + llvm.call @use(%2) : (i64) -> () + llvm.return %3 : i64 + } + llvm.func @neg_max_sub_ugt_sel_swapped_extrause3(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "ugt" %arg1, %arg0 : i64 + %2 = llvm.sub %arg1, %arg0 : i64 + %3 = llvm.select %1, %0, %2 : i1, i64 + llvm.call @use(%2) : (i64) -> () + llvm.call @usei1(%1) : (i1) -> () + llvm.return %3 : i64 + } + llvm.func @neg_max_sub_ult_sel_swapped(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.icmp "ult" %arg0, %arg1 : i64 + %2 = llvm.sub %arg1, %arg0 : i64 + %3 = llvm.select %1, %0, %2 : i1, i64 + %4 = llvm.sub %arg0, %arg1 : i64 + llvm.call @use(%4) : (i64) -> () + llvm.return %3 : i64 + } + llvm.func @max_sub_ugt_c1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @max_sub_ugt_c01(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %0 : i32 + %3 = llvm.add %arg0, %1 : i32 + %4 = llvm.select %2, %3, %0 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @max_sub_ugt_c10(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(10 : i32) : i32 + %1 = llvm.mlir.constant(-10 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @max_sub_ugt_c910(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.mlir.constant(-10 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @max_sub_ugt_c1110(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(11 : i32) : i32 + %1 = llvm.mlir.constant(-10 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @max_sub_ugt_c0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %0 : i32 + %3 = llvm.add %arg0, %1 : i32 + %4 = llvm.select %2, %3, %1 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @max_sub_ugt_cmiss(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ugt" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @max_sub_ult_c1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @max_sub_ult_c2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @max_sub_ult_c2_oneuseicmp(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.call @usei1(%3) : (i1) -> () + llvm.return %5 : i32 + } + llvm.func @max_sub_ult_c2_oneusesub(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.call @usei32(%4) : (i32) -> () + llvm.return %5 : i32 + } + llvm.func @max_sub_ult_c32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @max_sub_ugt_c32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ugt" %0, %arg0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @max_sub_uge_c32(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "uge" %0, %arg0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @max_sub_ult_c12(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(-2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ult" %arg0, %0 : i32 + %4 = llvm.add %arg0, %1 : i32 + %5 = llvm.select %3, %4, %2 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @max_sub_ult_c0(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.icmp "ult" %arg0, %0 : i32 + %3 = llvm.add %arg0, %1 : i32 + %4 = llvm.select %2, %3, %0 : i1, i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/unused-nonnull.ll.mlir b/test/LLVMDialect/InstCombine/unused-nonnull.ll.mlir new file mode 100644 index 000000000..68e69398b --- /dev/null +++ b/test/LLVMDialect/InstCombine/unused-nonnull.ll.mlir @@ -0,0 +1,23 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @main(%arg0: i32, %arg1: !llvm.ptr) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.zero : !llvm.ptr + %3 = llvm.load %arg1 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr + %4 = llvm.call @compute(%3, %arg0) : (!llvm.ptr, i32) -> i32 + %5 = llvm.icmp "slt" %arg0, %0 : i32 + llvm.cond_br %5, ^bb3(%1 : i32), ^bb1 + ^bb1: // pred: ^bb0 + %6 = llvm.icmp "eq" %3, %2 : !llvm.ptr + llvm.cond_br %6, ^bb2, ^bb3(%4 : i32) + ^bb2: // pred: ^bb1 + llvm.call @call_if_null(%3) : (!llvm.ptr) -> () + llvm.br ^bb3(%4 : i32) + ^bb3(%7: i32): // 3 preds: ^bb0, ^bb1, ^bb2 + llvm.return %7 : i32 + } + llvm.func @compute(%arg0: !llvm.ptr {llvm.nonnull, llvm.noundef}, %arg1: i32) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["noinline", "nounwind"]} { + llvm.return %arg1 : i32 + } + llvm.func @call_if_null(!llvm.ptr) attributes {passthrough = ["nounwind"]} +} diff --git a/test/LLVMDialect/InstCombine/unwind-inline-asm.ll.mlir b/test/LLVMDialect/InstCombine/unwind-inline-asm.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/update-bpi.ll.mlir b/test/LLVMDialect/InstCombine/update-bpi.ll.mlir new file mode 100644 index 000000000..126fadef1 --- /dev/null +++ b/test/LLVMDialect/InstCombine/update-bpi.ll.mlir @@ -0,0 +1,13 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @invert_cond(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "ne" %arg0, %0 : !llvm.ptr + llvm.cond_br %3 weights([1, 20]), ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %2 : i32 + ^bb2: // pred: ^bb0 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/urem-simplify-bug.ll.mlir b/test/LLVMDialect/InstCombine/urem-simplify-bug.ll.mlir new file mode 100644 index 000000000..0363cea48 --- /dev/null +++ b/test/LLVMDialect/InstCombine/urem-simplify-bug.ll.mlir @@ -0,0 +1,33 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal constant @".str"("foo\0A\00") {addr_space = 0 : i32, dso_local} + llvm.mlir.global internal constant @".str1"("bar\0A\00") {addr_space = 0 : i32, dso_local} + llvm.func @main() -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-5 : i32) : i32 + %1 = llvm.mlir.constant(251 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(95 : i32) : i32 + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.mlir.constant("foo\0A\00") : !llvm.array<5 x i8> + %6 = llvm.mlir.addressof @".str" : !llvm.ptr + %7 = llvm.mlir.constant("bar\0A\00") : !llvm.array<5 x i8> + %8 = llvm.mlir.addressof @".str1" : !llvm.ptr + %9 = llvm.call @func_11() : () -> i32 + %10 = llvm.or %9, %0 : i32 + %11 = llvm.urem %1, %10 : i32 + %12 = llvm.icmp "ne" %11, %2 : i32 + %13 = llvm.zext %12 : i1 to i32 + %14 = llvm.urem %13, %3 : i32 + %15 = llvm.and %14, %4 : i32 + %16 = llvm.icmp "eq" %15, %2 : i32 + llvm.cond_br %16, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb3(%6 : !llvm.ptr) + ^bb2: // pred: ^bb0 + llvm.br ^bb3(%8 : !llvm.ptr) + ^bb3(%17: !llvm.ptr): // 2 preds: ^bb1, ^bb2 + %18 = llvm.call @printf(%17) vararg(!llvm.func) : (!llvm.ptr) -> i32 + llvm.return %2 : i32 + } + llvm.func @func_11() -> i32 + llvm.func @printf(!llvm.ptr, ...) -> i32 attributes {passthrough = ["nounwind"]} +} diff --git a/test/LLVMDialect/InstCombine/urem-via-cmp-select.ll.mlir b/test/LLVMDialect/InstCombine/urem-via-cmp-select.ll.mlir new file mode 100644 index 000000000..9a81ec782 --- /dev/null +++ b/test/LLVMDialect/InstCombine/urem-via-cmp-select.ll.mlir @@ -0,0 +1,85 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @urem_assume(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.icmp "ult" %arg0, %arg1 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %0 overflow : i8 + %3 = llvm.urem %2, %arg1 : i8 + llvm.return %3 : i8 + } + llvm.func @urem_assume_without_nuw(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.icmp "ult" %arg0, %arg1 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.urem %2, %arg1 : i8 + llvm.return %3 : i8 + } + llvm.func @urem_assume_eq(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.icmp "eq" %arg0, %arg1 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.urem %2, %arg1 : i8 + llvm.return %3 : i8 + } + llvm.func @urem_assume_ne(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.icmp "ne" %arg0, %arg1 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.urem %2, %arg1 : i8 + llvm.return %3 : i8 + } + llvm.func @urem_assume_with_unexpected_const(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = llvm.icmp "ult" %arg0, %arg1 : i8 + "llvm.intr.assume"(%1) : (i1) -> () + %2 = llvm.add %arg0, %0 : i8 + %3 = llvm.urem %2, %arg1 : i8 + llvm.return %3 : i8 + } + llvm.func @urem_without_assume(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.urem %arg0, %arg1 : i8 + %2 = llvm.add %1, %0 : i8 + %3 = llvm.urem %2, %arg1 : i8 + llvm.return %3 : i8 + } + llvm.func @urem_with_dominating_condition(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.icmp "ult" %arg0, %arg1 : i8 + llvm.cond_br %2, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + %3 = llvm.add %arg0, %1 : i8 + %4 = llvm.urem %3, %arg1 : i8 + llvm.return %4 : i8 + ^bb2: // pred: ^bb0 + llvm.return %0 : i8 + } + llvm.func @urem_with_dominating_condition_false(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.icmp "uge" %arg0, %arg1 : i8 + llvm.cond_br %2, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + %3 = llvm.add %arg0, %0 : i8 + %4 = llvm.urem %3, %arg1 : i8 + llvm.return %4 : i8 + ^bb2: // pred: ^bb0 + llvm.return %1 : i8 + } + llvm.func @urem_with_opposite_condition(%arg0: i8, %arg1: i8) -> (i8 {llvm.noundef}) { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.icmp "ult" %arg0, %arg1 : i8 + llvm.cond_br %2, ^bb2, ^bb1 + ^bb1: // pred: ^bb0 + %3 = llvm.add %arg0, %0 : i8 + %4 = llvm.urem %3, %arg1 : i8 + llvm.return %4 : i8 + ^bb2: // pred: ^bb0 + llvm.return %1 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/urem-via-udiv-mul-sub.ll.mlir b/test/LLVMDialect/InstCombine/urem-via-udiv-mul-sub.ll.mlir index f88d793c9..be00590dd 100644 --- a/test/LLVMDialect/InstCombine/urem-via-udiv-mul-sub.ll.mlir +++ b/test/LLVMDialect/InstCombine/urem-via-udiv-mul-sub.ll.mlir @@ -1,59 +1,49 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use8", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use2xi8", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.udiv"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.mul"(%0, %arg1) : (i8, i8) -> i8 - %2 = "llvm.sub"(%arg0, %1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t0_basic", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>, %arg1: vector<2xi8>): // no predecessors - %0 = "llvm.udiv"(%arg0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.call"(%0) {callee = @use2xi8, fastmathFlags = #llvm.fastmath<>} : (vector<2xi8>) -> () - %1 = "llvm.mul"(%0, %arg1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - %2 = "llvm.sub"(%arg0, %1) : (vector<2xi8>, vector<2xi8>) -> vector<2xi8> - "llvm.return"(%2) : (vector<2xi8>) -> () - }) {linkage = 10 : i64, sym_name = "t1_vector", type = !llvm.func (vector<2xi8>, vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.udiv"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.mul"(%0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.sub"(%arg0, %1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t4_extrause", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "gen8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.call"() {callee = @gen8, fastmathFlags = #llvm.fastmath<>} : () -> i8 - %1 = "llvm.udiv"(%arg0, %0) : (i8, i8) -> i8 - "llvm.call"(%1) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %2 = "llvm.mul"(%0, %1) : (i8, i8) -> i8 - %3 = "llvm.sub"(%arg0, %2) : (i8, i8) -> i8 - "llvm.return"(%3) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "t5_commutative", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.udiv"(%arg0, %arg2) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.mul"(%0, %arg2) : (i8, i8) -> i8 - %2 = "llvm.sub"(%arg1, %1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "n6_different_x", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8, %arg2: i8): // no predecessors - %0 = "llvm.udiv"(%arg0, %arg1) : (i8, i8) -> i8 - "llvm.call"(%0) {callee = @use8, fastmathFlags = #llvm.fastmath<>} : (i8) -> () - %1 = "llvm.mul"(%0, %arg2) : (i8, i8) -> i8 - %2 = "llvm.sub"(%arg0, %1) : (i8, i8) -> i8 - "llvm.return"(%2) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "n6_different_y", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use8(i8) + llvm.func @use2xi8(vector<2xi8>) + llvm.func @t0_basic(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.udiv %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.mul %0, %arg1 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @t1_vector(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.udiv %arg0, %arg1 : vector<2xi8> + llvm.call @use2xi8(%0) : (vector<2xi8>) -> () + %1 = llvm.mul %0, %arg1 : vector<2xi8> + %2 = llvm.sub %arg0, %1 : vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @t4_extrause(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.udiv %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.mul %0, %arg1 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @gen8() -> i8 + llvm.func @t5_commutative(%arg0: i8) -> i8 { + %0 = llvm.call @gen8() : () -> i8 + %1 = llvm.udiv %arg0, %0 : i8 + llvm.call @use8(%1) : (i8) -> () + %2 = llvm.mul %0, %1 : i8 + %3 = llvm.sub %arg0, %2 : i8 + llvm.return %3 : i8 + } + llvm.func @n6_different_x(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.udiv %arg0, %arg2 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.mul %0, %arg2 : i8 + %2 = llvm.sub %arg1, %1 : i8 + llvm.return %2 : i8 + } + llvm.func @n6_different_y(%arg0: i8, %arg1: i8, %arg2: i8) -> i8 { + %0 = llvm.udiv %arg0, %arg1 : i8 + llvm.call @use8(%0) : (i8) -> () + %1 = llvm.mul %0, %arg2 : i8 + %2 = llvm.sub %arg0, %1 : i8 + llvm.return %2 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/usub-overflow-known-by-implied-cond.ll.mlir b/test/LLVMDialect/InstCombine/usub-overflow-known-by-implied-cond.ll.mlir new file mode 100644 index 000000000..4317bf277 --- /dev/null +++ b/test/LLVMDialect/InstCombine/usub-overflow-known-by-implied-cond.ll.mlir @@ -0,0 +1,238 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "uge" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %2 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %4, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.return %3 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %0 : i32 + } + llvm.func @test2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "uge" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %2 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %4, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %3 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %0 : i32 + } + llvm.func @test3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %2 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %4, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + llvm.return %3 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %0 : i32 + } + llvm.func @test4(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %2 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %4, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %3 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %0 : i32 + } + llvm.func @test5(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "eq" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %2 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %4, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %3 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %0 : i32 + } + llvm.func @test6(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ult" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %2 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %4, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %3 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %0 : i32 + } + llvm.func @test7(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "slt" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %2 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %4, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %3 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %0 : i32 + } + llvm.func @test8(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ne" %arg0, %arg1 : i32 + llvm.cond_br %1, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %2 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %4, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %3 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %0 : i32 + } + llvm.func @test9(%arg0: i32, %arg1: i32, %arg2: i1) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %2 = llvm.and %1, %arg2 : i1 + llvm.cond_br %2, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %3 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %3[0] : !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %3[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %5, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %4 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %0 : i32 + } + llvm.func @test9_logical(%arg0: i32, %arg1: i32, %arg2: i1) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %3 = llvm.select %2, %arg2, %0 : i1, i1 + llvm.cond_br %3, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %4 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %4[0] : !llvm.struct<(i32, i1)> + %6 = llvm.extractvalue %4[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %6, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %5 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %1 : i32 + } + llvm.func @test10(%arg0: i32, %arg1: i32, %arg2: i1) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %2 = llvm.and %1, %arg2 : i1 + llvm.cond_br %2, ^bb3, ^bb1 + ^bb1: // pred: ^bb0 + %3 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %3[0] : !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %3[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %5, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %4 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %0 : i32 + } + llvm.func @test10_logical(%arg0: i32, %arg1: i32, %arg2: i1) -> i32 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %3 = llvm.select %2, %arg2, %0 : i1, i1 + llvm.cond_br %3, ^bb3, ^bb1 + ^bb1: // pred: ^bb0 + %4 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %4[0] : !llvm.struct<(i32, i1)> + %6 = llvm.extractvalue %4[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %6, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %5 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %1 : i32 + } + llvm.func @test11(%arg0: i32, %arg1: i32, %arg2: i1) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %2 = llvm.or %1, %arg2 : i1 + llvm.cond_br %2, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %3 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %3[0] : !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %3[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %5, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %4 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %0 : i32 + } + llvm.func @test11_logical(%arg0: i32, %arg1: i32, %arg2: i1) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %3 = llvm.select %2, %0, %arg2 : i1, i1 + llvm.cond_br %3, ^bb1, ^bb3 + ^bb1: // pred: ^bb0 + %4 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %4[0] : !llvm.struct<(i32, i1)> + %6 = llvm.extractvalue %4[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %6, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %5 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %1 : i32 + } + llvm.func @test12(%arg0: i32, %arg1: i32, %arg2: i1) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %2 = llvm.or %1, %arg2 : i1 + llvm.cond_br %2, ^bb3, ^bb1 + ^bb1: // pred: ^bb0 + %3 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %3[0] : !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %3[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %5, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %4 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %0 : i32 + } + llvm.func @test12_logical(%arg0: i32, %arg1: i32, %arg2: i1) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %arg1 : i32 + %3 = llvm.select %2, %0, %arg2 : i1, i1 + llvm.cond_br %3, ^bb3, ^bb1 + ^bb1: // pred: ^bb0 + %4 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %4[0] : !llvm.struct<(i32, i1)> + %6 = llvm.extractvalue %4[1] : !llvm.struct<(i32, i1)> + llvm.cond_br %6, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + llvm.return %5 : i32 + ^bb3: // 2 preds: ^bb0, ^bb1 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/usubo.ll.mlir b/test/LLVMDialect/InstCombine/usubo.ll.mlir new file mode 100644 index 000000000..1673e2962 --- /dev/null +++ b/test/LLVMDialect/InstCombine/usubo.ll.mlir @@ -0,0 +1,92 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(i1) + llvm.func @test_generic(%arg0: i64, %arg1: i64) -> i1 { + %0 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i64, i64) -> !llvm.struct<(i64, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i64, i1)> + llvm.return %1 : i1 + } + llvm.func @test_constant0(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.usub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant1(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = "llvm.intr.usub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant2(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = "llvm.intr.usub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant3(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = "llvm.intr.usub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant4(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = "llvm.intr.usub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant127(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = "llvm.intr.usub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant128(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = "llvm.intr.usub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @test_constant255(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = "llvm.intr.usub.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @sub_eq0(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.call @use(%2) : (i1) -> () + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %4 = llvm.icmp "eq" %3, %0 : i8 + llvm.return %4 : i1 + } + llvm.func @sub_ne0(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.call @use(%2) : (i1) -> () + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %4 = llvm.icmp "ne" %3, %0 : i8 + llvm.return %4 : i1 + } + llvm.func @sub_eq1(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.call @use(%2) : (i1) -> () + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %4 = llvm.icmp "eq" %3, %0 : i8 + llvm.return %4 : i1 + } + llvm.func @sub_sgt0(%arg0: i8, %arg1: i8, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.usub.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.call @use(%2) : (i1) -> () + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %4 = llvm.icmp "sgt" %3, %0 : i8 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/vararg.ll.mlir b/test/LLVMDialect/InstCombine/vararg.ll.mlir new file mode 100644 index 000000000..aea99d248 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vararg.ll.mlir @@ -0,0 +1,17 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @func(%arg0: !llvm.ptr {llvm.nocapture, llvm.readnone}, ...) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.alloca %0 x !llvm.struct<"struct.__va_list", (ptr, ptr, ptr, i32, i32)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + %3 = llvm.alloca %0 x !llvm.struct<"struct.__va_list", (ptr, ptr, ptr, i32, i32)> {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.intr.lifetime.start 32, %2 : !llvm.ptr + llvm.intr.vastart %2 : !llvm.ptr + llvm.intr.lifetime.start 32, %3 : !llvm.ptr + llvm.intr.vacopy %2 to %3 : !llvm.ptr, !llvm.ptr + llvm.intr.vaend %3 : !llvm.ptr + llvm.intr.lifetime.end 32, %3 : !llvm.ptr + llvm.intr.vaend %2 : !llvm.ptr + llvm.intr.lifetime.end 32, %2 : !llvm.ptr + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/variable-signext-of-variable-high-bit-extraction.ll.mlir b/test/LLVMDialect/InstCombine/variable-signext-of-variable-high-bit-extraction.ll.mlir new file mode 100644 index 000000000..6e1796ca6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/variable-signext-of-variable-high-bit-extraction.ll.mlir @@ -0,0 +1,345 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use16(i16) + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @t0(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.lshr %arg0, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + %8 = llvm.ashr %7, %6 : i32 + llvm.return %8 : i32 + } + llvm.func @t0_zext_of_nbits(%arg0: i64, %arg1: i8) -> i32 { + %0 = llvm.mlir.constant(64 : i16) : i16 + %1 = llvm.mlir.constant(32 : i16) : i16 + %2 = llvm.zext %arg1 : i8 to i16 + llvm.call @use16(%2) : (i16) -> () + %3 = llvm.sub %0, %2 : i16 + llvm.call @use16(%3) : (i16) -> () + %4 = llvm.zext %3 : i16 to i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.lshr %arg0, %4 : i64 + llvm.call @use64(%5) : (i64) -> () + %6 = llvm.trunc %5 : i64 to i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.sub %1, %2 : i16 + llvm.call @use16(%7) : (i16) -> () + %8 = llvm.zext %7 : i16 to i32 + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.shl %6, %8 : i32 + %10 = llvm.ashr %9, %8 : i32 + llvm.return %10 : i32 + } + llvm.func @t0_exact(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.lshr %arg0, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + %8 = llvm.ashr %7, %6 : i32 + llvm.return %8 : i32 + } + llvm.func @t1_redundant_sext(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.ashr %arg0, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.ashr %7, %6 : i32 + llvm.return %8 : i32 + } + llvm.func @t2_notrunc(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.sub %0, %arg1 : i64 + llvm.call @use64(%1) : (i64) -> () + %2 = llvm.lshr %arg0, %1 : i64 + llvm.call @use64(%2) : (i64) -> () + %3 = llvm.sub %0, %arg1 : i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.shl %2, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.ashr %4, %3 : i64 + llvm.return %5 : i64 + } + llvm.func @t3_notrunc_redundant_sext(%arg0: i64, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(64 : i64) : i64 + %1 = llvm.sub %0, %arg1 : i64 + llvm.call @use64(%1) : (i64) -> () + %2 = llvm.ashr %arg0, %1 : i64 + llvm.call @use64(%2) : (i64) -> () + %3 = llvm.sub %0, %arg1 : i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.shl %2, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.ashr %4, %3 : i64 + llvm.return %5 : i64 + } + llvm.func @t4_vec(%arg0: vector<2xi64>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<64> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<32> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %0, %arg1 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + %4 = llvm.lshr %arg0, %3 : vector<2xi64> + %5 = llvm.trunc %4 : vector<2xi64> to vector<2xi32> + %6 = llvm.sub %1, %arg1 : vector<2xi32> + %7 = llvm.shl %5, %6 : vector<2xi32> + %8 = llvm.ashr %7, %6 : vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @t5_vec_poison(%arg0: vector<3xi64>, %arg1: vector<3xi32>) -> vector<3xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(64 : i32) : i32 + %2 = llvm.mlir.undef : vector<3xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<3xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi32> + %9 = llvm.mlir.constant(32 : i32) : i32 + %10 = llvm.mlir.undef : vector<3xi32> + %11 = llvm.mlir.constant(0 : i32) : i32 + %12 = llvm.insertelement %9, %10[%11 : i32] : vector<3xi32> + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %9, %12[%13 : i32] : vector<3xi32> + %15 = llvm.mlir.constant(2 : i32) : i32 + %16 = llvm.insertelement %0, %14[%15 : i32] : vector<3xi32> + %17 = llvm.mlir.undef : vector<3xi32> + %18 = llvm.mlir.constant(0 : i32) : i32 + %19 = llvm.insertelement %0, %17[%18 : i32] : vector<3xi32> + %20 = llvm.mlir.constant(1 : i32) : i32 + %21 = llvm.insertelement %9, %19[%20 : i32] : vector<3xi32> + %22 = llvm.mlir.constant(2 : i32) : i32 + %23 = llvm.insertelement %9, %21[%22 : i32] : vector<3xi32> + %24 = llvm.sub %8, %arg1 : vector<3xi32> + %25 = llvm.zext %24 : vector<3xi32> to vector<3xi64> + %26 = llvm.lshr %arg0, %25 : vector<3xi64> + %27 = llvm.trunc %26 : vector<3xi64> to vector<3xi32> + %28 = llvm.sub %16, %arg1 : vector<3xi32> + %29 = llvm.sub %23, %arg1 : vector<3xi32> + %30 = llvm.shl %27, %28 : vector<3xi32> + %31 = llvm.ashr %30, %29 : vector<3xi32> + llvm.return %31 : vector<3xi32> + } + llvm.func @t6_extrause_good0(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.lshr %arg0, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + %8 = llvm.ashr %7, %6 : i32 + llvm.return %8 : i32 + } + llvm.func @t7_extrause_good1(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.lshr %arg0, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.sub %1, %arg1 : i32 + %8 = llvm.shl %5, %6 : i32 + llvm.call @use32(%8) : (i32) -> () + %9 = llvm.ashr %8, %7 : i32 + llvm.return %9 : i32 + } + llvm.func @n8_extrause_bad(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.lshr %arg0, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.ashr %7, %6 : i32 + llvm.return %8 : i32 + } + llvm.func @n9(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(63 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.lshr %arg0, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + %8 = llvm.ashr %7, %6 : i32 + llvm.return %8 : i32 + } + llvm.func @n10(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.lshr %arg0, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + %8 = llvm.ashr %7, %6 : i32 + llvm.return %8 : i32 + } + llvm.func @n11(%arg0: i64, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.lshr %arg0, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.sub %1, %arg2 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + %8 = llvm.ashr %7, %6 : i32 + llvm.return %8 : i32 + } + llvm.func @n12(%arg0: i64, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.lshr %arg0, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.sub %1, %arg1 : i32 + %7 = llvm.sub %1, %arg2 : i32 + llvm.call @use32(%6) : (i32) -> () + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.shl %5, %6 : i32 + %9 = llvm.ashr %8, %7 : i32 + llvm.return %9 : i32 + } + llvm.func @n13(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.lshr %arg0, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + %8 = llvm.lshr %7, %6 : i32 + llvm.return %8 : i32 + } + llvm.func @n13_extrause(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.lshr %arg0, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.lshr %7, %6 : i32 + llvm.return %8 : i32 + } + llvm.func @n14(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.ashr %arg0, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + %8 = llvm.lshr %7, %6 : i32 + llvm.return %8 : i32 + } + llvm.func @n14_extrause(%arg0: i64, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(64 : i32) : i32 + %1 = llvm.mlir.constant(32 : i32) : i32 + %2 = llvm.sub %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.call @use64(%3) : (i64) -> () + %4 = llvm.ashr %arg0, %3 : i64 + llvm.call @use64(%4) : (i64) -> () + %5 = llvm.trunc %4 : i64 to i32 + llvm.call @use32(%5) : (i32) -> () + %6 = llvm.sub %1, %arg1 : i32 + llvm.call @use32(%6) : (i32) -> () + %7 = llvm.shl %5, %6 : i32 + llvm.call @use32(%7) : (i32) -> () + %8 = llvm.lshr %7, %6 : i32 + llvm.return %8 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/vec-binop-select-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/vec-binop-select-inseltpoison.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/vec-binop-select.ll.mlir b/test/LLVMDialect/InstCombine/vec-binop-select.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/vec_demanded_elts-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/vec_demanded_elts-inseltpoison.ll.mlir new file mode 100644 index 000000000..66f8805f2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vec_demanded_elts-inseltpoison.ll.mlir @@ -0,0 +1,633 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global internal @GLOBAL(0 : i32) {addr_space = 0 : i32, dso_local} : i32 + llvm.mlir.global external @global() {addr_space = 0 : i32, alignment = 4 : i64} : !llvm.array<0 x i32> + llvm.func @test2(%arg0: f32) -> i32 { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.fmul %arg0, %arg0 : f32 + %7 = llvm.insertelement %6, %0[%1 : i32] : vector<4xf32> + %8 = llvm.insertelement %2, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %2, %8[%4 : i32] : vector<4xf32> + %10 = llvm.insertelement %2, %9[%5 : i32] : vector<4xf32> + %11 = llvm.bitcast %10 : vector<4xf32> to vector<4xi32> + %12 = llvm.extractelement %11[%1 : i32] : vector<4xi32> + llvm.return %12 : i32 + } + llvm.func @get_image() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<100xi8>) : vector<100xi8> + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(80 : i8) : i8 + %6 = llvm.call @fgetc(%0) : (!llvm.ptr) -> i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.insertelement %7, %2[%3 : i32] : vector<100xi8> + %9 = llvm.extractelement %8[%4 : i32] : vector<100xi8> + %10 = llvm.icmp "eq" %9, %5 : i8 + llvm.cond_br %10, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.unreachable + } + llvm.func @vac(%arg0: !llvm.ptr {llvm.nocapture}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> vector<4xf32> + %6 = llvm.insertelement %0, %5[%1 : i32] : vector<4xf32> + %7 = llvm.insertelement %0, %6[%2 : i32] : vector<4xf32> + %8 = llvm.insertelement %0, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %0, %8[%4 : i32] : vector<4xf32> + llvm.store %9, %arg0 {alignment = 16 : i64} : vector<4xf32>, !llvm.ptr + llvm.return + } + llvm.func @fgetc(!llvm.ptr) -> i32 + llvm.func @dead_shuffle_elt(%arg0: vector<4xf32>, %arg1: vector<2xf32>) -> vector<4xf32> attributes {passthrough = ["nounwind"]} { + %0 = llvm.shufflevector %arg1, %arg1 [0, 1, 0, 1] : vector<2xf32> + %1 = llvm.shufflevector %arg0, %0 [4, 5, 2, 3] : vector<4xf32> + llvm.return %1 : vector<4xf32> + } + llvm.func @test_fptrunc(%arg0: f64) -> vector<2xf32> { + %0 = llvm.mlir.poison : vector<4xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.mlir.poison : vector<4xf32> + %7 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf64> + %8 = llvm.insertelement %2, %7[%3 : i32] : vector<4xf64> + %9 = llvm.insertelement %2, %8[%4 : i32] : vector<4xf64> + %10 = llvm.insertelement %2, %9[%5 : i32] : vector<4xf64> + %11 = llvm.fptrunc %10 : vector<4xf64> to vector<4xf32> + %12 = llvm.shufflevector %11, %6 [0, 1] : vector<4xf32> + llvm.return %12 : vector<2xf32> + } + llvm.func @test_fpext(%arg0: f32) -> vector<2xf64> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.mlir.poison : vector<4xf64> + %7 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %8 = llvm.insertelement %2, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %2, %8[%4 : i32] : vector<4xf32> + %10 = llvm.insertelement %2, %9[%5 : i32] : vector<4xf32> + %11 = llvm.fpext %10 : vector<4xf32> to vector<4xf64> + %12 = llvm.shufflevector %11, %6 [0, 1] : vector<4xf64> + llvm.return %12 : vector<2xf64> + } + llvm.func @test_shuffle(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.undef : f64 + %1 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %2 = llvm.mlir.undef : vector<4xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xf64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xf64> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xf64> + %11 = llvm.shufflevector %arg0, %10 [0, 1, 2, 5] : vector<4xf64> + llvm.return %11 : vector<4xf64> + } + llvm.func @test_select(%arg0: f32, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %5 = llvm.mlir.constant(2 : i32) : i32 + %6 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %7 = llvm.mlir.constant(3 : i32) : i32 + %8 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %9 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %10 = llvm.mlir.constant(6.000000e+00 : f32) : f32 + %11 = llvm.mlir.constant(true) : i1 + %12 = llvm.mlir.constant(false) : i1 + %13 = llvm.mlir.constant(dense<[true, false, false, true]> : vector<4xi1>) : vector<4xi1> + %14 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %15 = llvm.insertelement %2, %14[%3 : i32] : vector<4xf32> + %16 = llvm.insertelement %4, %15[%5 : i32] : vector<4xf32> + %17 = llvm.insertelement %6, %16[%7 : i32] : vector<4xf32> + %18 = llvm.insertelement %arg1, %0[%1 : i32] : vector<4xf32> + %19 = llvm.insertelement %8, %18[%3 : i32] : vector<4xf32> + %20 = llvm.insertelement %9, %19[%5 : i32] : vector<4xf32> + %21 = llvm.insertelement %10, %20[%7 : i32] : vector<4xf32> + %22 = llvm.select %13, %17, %21 : vector<4xi1>, vector<4xf32> + llvm.return %22 : vector<4xf32> + } + llvm.func @PR24922(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.addressof @PR24922 : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i1 + %3 = llvm.mlir.undef : vector<2xi1> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi1> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %0, %5[%6 : i32] : vector<2xi1> + %8 = llvm.mlir.constant(0 : i64) : i64 + %9 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %10 = llvm.select %7, %arg0, %9 : vector<2xi1>, vector<2xi64> + llvm.return %10 : vector<2xi64> + } + llvm.func @inselt_shuf_no_demand(%arg0: f32, %arg1: f32, %arg2: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %arg1, %4[%2 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg2, %5[%3 : i32] : vector<4xf32> + %7 = llvm.shufflevector %6, %0 [0, -1, -1, -1] : vector<4xf32> + llvm.return %7 : vector<4xf32> + } + llvm.func @inselt_shuf_no_demand_commute(%arg0: f32, %arg1: f32, %arg2: f32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.undef : vector<4xf32> + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg2, %6[%3 : i32] : vector<4xf32> + %8 = llvm.shufflevector %4, %7 [4, -1, -1, -1] : vector<4xf32> + llvm.return %8 : vector<4xf32> + } + llvm.func @inselt_shuf_no_demand_multiuse(%arg0: i32, %arg1: i32, %arg2: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi32> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<4xi32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xi32> + %8 = llvm.add %7, %arg2 : vector<4xi32> + %9 = llvm.insertelement %arg1, %8[%4 : i32] : vector<4xi32> + %10 = llvm.shufflevector %9, %0 [0, 1, -1, -1] : vector<4xi32> + llvm.return %10 : vector<4xi32> + } + llvm.func @inselt_shuf_no_demand_bogus_insert_index_in_chain(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: i32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %4 = llvm.insertelement %arg1, %3[%arg3 : i32] : vector<4xf32> + %5 = llvm.insertelement %arg2, %4[%2 : i32] : vector<4xf32> + %6 = llvm.shufflevector %5, %0 [0, -1, -1, -1] : vector<4xf32> + llvm.return %6 : vector<4xf32> + } + llvm.func @shuf_add(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.add %arg0, %0 overflow : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [1, -1, 2] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_sub(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.sub %0, %arg0 overflow : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [0, -1, 2] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_mul(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.mul %arg0, %0 overflow : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [0, 2, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_and(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.and %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [1, 1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_or(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.or %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [1, -1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_xor(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.xor %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, -1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_lshr_const_op0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.lshr %0, %arg0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, 1, -1] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_lshr_const_op1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.lshr %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, 1, -1] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_ashr_const_op0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.ashr %0, %arg0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [0, -1, 1] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_ashr_const_op1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.ashr %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [0, -1, 1] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_shl_const_op0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.shl %0, %arg0 overflow : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, -1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_shl_const_op1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.shl %arg0, %0 overflow : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, -1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_sdiv_const_op0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.sdiv %0, %arg0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [0, -1, 1] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_sdiv_const_op1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.sdiv %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [1, -1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_srem_const_op0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.srem %0, %arg0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [1, -1, 2] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_srem_const_op1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.srem %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, -1, 1] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_udiv_const_op0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.udiv %0, %arg0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, -1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_udiv_const_op1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.udiv %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, -1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_urem_const_op0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.urem %0, %arg0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, 1, -1] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_urem_const_op1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.poison : vector<3xi8> + %2 = llvm.urem %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [-1, 1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_fadd(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.poison : vector<3xf32> + %2 = llvm.fadd %arg0, %0 : vector<3xf32> + %3 = llvm.shufflevector %2, %1 [-1, 1, 0] : vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @shuf_fsub(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.poison : vector<3xf32> + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<3xf32> + %3 = llvm.shufflevector %2, %1 [-1, 0, 2] : vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @shuf_fmul(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.poison : vector<3xf32> + %2 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<3xf32> + %3 = llvm.shufflevector %2, %1 [-1, 1, 0] : vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @shuf_fdiv_const_op0(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.poison : vector<3xf32> + %2 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<3xf32> + %3 = llvm.shufflevector %2, %1 [-1, 0, 2] : vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @shuf_fdiv_const_op1(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.poison : vector<3xf32> + %2 = llvm.fdiv %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<3xf32> + %3 = llvm.shufflevector %2, %1 [-1, 1, 0] : vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @shuf_frem_const_op0(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.poison : vector<3xf32> + %2 = llvm.frem %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<3xf32> + %3 = llvm.shufflevector %2, %1 [-1, 2, 0] : vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @shuf_frem_const_op1(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.poison : vector<3xf32> + %2 = llvm.frem %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<3xf32> + %3 = llvm.shufflevector %2, %1 [1, -1, 2] : vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @gep_vbase_w_s_idx(%arg0: !llvm.vec<2 x ptr>, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.getelementptr %arg0[%arg1] : (!llvm.vec<2 x ptr>, i64) -> !llvm.vec<2 x ptr>, i32 + %2 = llvm.extractelement %1[%0 : i32] : !llvm.vec<2 x ptr> + llvm.return %2 : !llvm.ptr + } + llvm.func @gep_splat_base_w_s_idx(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.poison : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.shufflevector %4, %0 [0, 0] : !llvm.vec<2 x ptr> + %6 = llvm.getelementptr %5[%2] : (!llvm.vec<2 x ptr>, i64) -> !llvm.vec<2 x ptr>, i32 + %7 = llvm.extractelement %6[%3 : i32] : !llvm.vec<2 x ptr> + llvm.return %7 : !llvm.ptr + } + llvm.func @gep_splat_base_w_cv_idx(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.poison : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.shufflevector %4, %0 [0, 0] : !llvm.vec<2 x ptr> + %6 = llvm.getelementptr %5[%2] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %7 = llvm.extractelement %6[%3 : i32] : !llvm.vec<2 x ptr> + llvm.return %7 : !llvm.ptr + } + llvm.func @gep_splat_base_w_vidx(%arg0: !llvm.ptr, %arg1: vector<2xi64>) -> !llvm.ptr { + %0 = llvm.mlir.poison : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %4 = llvm.shufflevector %3, %0 [0, 0] : !llvm.vec<2 x ptr> + %5 = llvm.getelementptr %4[%arg1] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %6 = llvm.extractelement %5[%2 : i32] : !llvm.vec<2 x ptr> + llvm.return %6 : !llvm.ptr + } + llvm.func @gep_cvbase_w_s_idx(%arg0: !llvm.vec<2 x ptr>, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @GLOBAL : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : !llvm.vec<2 x ptr> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.getelementptr %6[%arg1] : (!llvm.vec<2 x ptr>, i64) -> !llvm.vec<2 x ptr>, i32 + %9 = llvm.extractelement %8[%7 : i32] : !llvm.vec<2 x ptr> + llvm.return %9 : !llvm.ptr + } + llvm.func @gep_cvbase_w_cv_idx(%arg0: !llvm.vec<2 x ptr>, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @GLOBAL : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : !llvm.vec<2 x ptr> + %7 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.getelementptr %6[%7] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %10 = llvm.extractelement %9[%8 : i32] : !llvm.vec<2 x ptr> + llvm.return %10 : !llvm.ptr + } + llvm.func @gep_sbase_w_cv_idx(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %3 = llvm.extractelement %2[%1 : i32] : !llvm.vec<2 x ptr> + llvm.return %3 : !llvm.ptr + } + llvm.func @gep_sbase_w_splat_idx(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.poison : vector<2xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg1, %0[%1 : i32] : vector<2xi64> + %4 = llvm.shufflevector %3, %0 [0, 0] : vector<2xi64> + %5 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %6 = llvm.extractelement %5[%2 : i32] : !llvm.vec<2 x ptr> + llvm.return %6 : !llvm.ptr + } + llvm.func @gep_splat_both(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.poison : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.poison : vector<2xi64> + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.shufflevector %4, %0 [0, 0] : !llvm.vec<2 x ptr> + %6 = llvm.insertelement %arg1, %2[%1 : i32] : vector<2xi64> + %7 = llvm.shufflevector %6, %2 [0, 0] : vector<2xi64> + %8 = llvm.getelementptr %5[%7] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %9 = llvm.extractelement %8[%3 : i32] : !llvm.vec<2 x ptr> + llvm.return %9 : !llvm.ptr + } + llvm.func @gep_all_lanes_undef(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.vec<2 x ptr> { + %0 = llvm.mlir.poison : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.poison : vector<2xi64> + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.insertelement %arg1, %2[%3 : i32] : vector<2xi64> + %6 = llvm.getelementptr %4[%5] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + llvm.return %6 : !llvm.vec<2 x ptr> + } + llvm.func @gep_demanded_lane_undef(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.poison : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.poison : vector<2xi64> + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.insertelement %arg1, %2[%3 : i32] : vector<2xi64> + %6 = llvm.getelementptr %4[%5] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %7 = llvm.extractelement %6[%3 : i32] : !llvm.vec<2 x ptr> + llvm.return %7 : !llvm.ptr + } + llvm.func @PR41624(%arg0: !llvm.vec<2 x ptr>) -> !llvm.ptr { + %0 = llvm.mlir.constant(dense<5> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.getelementptr %arg0[%0, 0] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, !llvm.struct<(i32, i32)> + %4 = llvm.extractelement %3[%1 : i32] : !llvm.vec<2 x ptr> + llvm.return %4 : !llvm.ptr + } + llvm.func @zero_sized_type_extract(%arg0: vector<4xi64>, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.addressof @global : !llvm.ptr + %1 = llvm.mlir.undef : !llvm.vec<4 x ptr> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec<4 x ptr> + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec<4 x ptr> + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.insertelement %0, %5[%6 : i32] : !llvm.vec<4 x ptr> + %8 = llvm.mlir.constant(3 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : !llvm.vec<4 x ptr> + %10 = llvm.mlir.constant(0 : i64) : i64 + %11 = llvm.mlir.constant(dense<0> : vector<4xi64>) : vector<4xi64> + %12 = llvm.getelementptr inbounds %9[%11, %arg0] : (!llvm.vec<4 x ptr>, vector<4xi64>, vector<4xi64>) -> !llvm.vec<4 x ptr>, !llvm.array<0 x i32> + %13 = llvm.extractelement %12[%10 : i64] : !llvm.vec<4 x ptr> + llvm.return %13 : !llvm.ptr + } + llvm.func @select_cond_with_eq_true_false_elts(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi1>) -> vector<4xi8> { + %0 = llvm.mlir.poison : vector<4xi1> + %1 = llvm.shufflevector %arg0, %arg1 [0, 5, 6, 7] : vector<4xi8> + %2 = llvm.shufflevector %arg2, %0 [0, 0, 0, 0] : vector<4xi1> + %3 = llvm.select %2, %1, %arg1 : vector<4xi1>, vector<4xi8> + llvm.return %3 : vector<4xi8> + } + llvm.func @select_cond_with_eq_true_false_elts2(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi1>) -> vector<4xi8> { + %0 = llvm.mlir.poison : vector<4xi1> + %1 = llvm.shufflevector %arg0, %arg1 [0, 5, 6, 7] : vector<4xi8> + %2 = llvm.shufflevector %arg2, %0 [0, 1, 0, 1] : vector<4xi1> + %3 = llvm.select %2, %1, %arg0 : vector<4xi1>, vector<4xi8> + llvm.return %3 : vector<4xi8> + } + llvm.func @select_cond_with_eq_true_false_elts3(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: vector<4xi1>) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xi1> + %1 = llvm.shufflevector %arg0, %arg1 [1, 3, 5, -1] : vector<4xf32> + %2 = llvm.shufflevector %arg1, %arg0 [0, 7, 6, -1] : vector<4xf32> + %3 = llvm.shufflevector %arg2, %0 [-1, 1, 2, 3] : vector<4xi1> + %4 = llvm.select %3, %1, %2 : vector<4xi1>, vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @select_cond_with_undef_true_false_elts(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi1>) -> vector<4xi8> { + %0 = llvm.mlir.poison : vector<4xi1> + %1 = llvm.shufflevector %arg0, %arg1 [-1, 5, 6, 7] : vector<4xi8> + %2 = llvm.shufflevector %arg2, %0 [0, 1, 0, 1] : vector<4xi1> + %3 = llvm.select %2, %1, %arg0 : vector<4xi1>, vector<4xi8> + llvm.return %3 : vector<4xi8> + } + llvm.func @select_cond_(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi1>, %arg3: i1) -> vector<4xi8> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.insertelement %arg3, %arg2[%0 : i32] : vector<4xi1> + %2 = llvm.shufflevector %arg0, %arg1 [0, 5, 6, 7] : vector<4xi8> + %3 = llvm.select %1, %2, %arg0 : vector<4xi1>, vector<4xi8> + llvm.return %3 : vector<4xi8> + } + llvm.func @ins_of_ext(%arg0: vector<4xf32>, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : vector<4xf32> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.extractelement %arg0[%0 : i32] : vector<4xf32> + %6 = llvm.insertelement %5, %1[%0 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg1, %6[%2 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg1, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg1, %8[%4 : i32] : vector<4xf32> + llvm.return %9 : vector<4xf32> + } + llvm.func @ins_of_ext_twice(%arg0: vector<4xf32>, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : vector<4xf32> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.extractelement %arg0[%0 : i32] : vector<4xf32> + %6 = llvm.insertelement %5, %1[%0 : i32] : vector<4xf32> + %7 = llvm.extractelement %arg0[%2 : i32] : vector<4xf32> + %8 = llvm.insertelement %7, %6[%2 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg1, %8[%3 : i32] : vector<4xf32> + %10 = llvm.insertelement %arg1, %9[%4 : i32] : vector<4xf32> + llvm.return %10 : vector<4xf32> + } + llvm.func @ins_of_ext_wrong_demand(%arg0: vector<4xf32>, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : vector<4xf32> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.extractelement %arg0[%0 : i32] : vector<4xf32> + %5 = llvm.insertelement %4, %1[%0 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg1, %6[%3 : i32] : vector<4xf32> + llvm.return %7 : vector<4xf32> + } + llvm.func @ins_of_ext_wrong_type(%arg0: vector<5xf32>, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : vector<4xf32> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.extractelement %arg0[%0 : i32] : vector<5xf32> + %6 = llvm.insertelement %5, %1[%0 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg1, %6[%2 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg1, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg1, %8[%4 : i32] : vector<4xf32> + llvm.return %9 : vector<4xf32> + } + llvm.func @ins_of_ext_undef_elts_propagation(%arg0: vector<4xi4>, %arg1: vector<4xi4>, %arg2: i4) -> vector<4xi4> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : vector<4xi4> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.extractelement %arg0[%0 : i32] : vector<4xi4> + %4 = llvm.insertelement %3, %1[%0 : i32] : vector<4xi4> + %5 = llvm.insertelement %arg2, %4[%2 : i32] : vector<4xi4> + %6 = llvm.shufflevector %5, %arg1 [0, 6, 2, 7] : vector<4xi4> + llvm.return %6 : vector<4xi4> + } + llvm.func @ins_of_ext_undef_elts_propagation2(%arg0: vector<8xi4>, %arg1: vector<8xi4>, %arg2: i4) -> vector<8xi4> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : vector<8xi4> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.extractelement %arg0[%0 : i32] : vector<8xi4> + %5 = llvm.insertelement %4, %1[%0 : i32] : vector<8xi4> + %6 = llvm.extractelement %arg0[%2 : i32] : vector<8xi4> + %7 = llvm.insertelement %6, %5[%2 : i32] : vector<8xi4> + %8 = llvm.insertelement %arg2, %7[%3 : i32] : vector<8xi4> + %9 = llvm.shufflevector %8, %arg1 [0, 1, 2, 11, 10, 9, 8, -1] : vector<8xi4> + %10 = llvm.shufflevector %9, %arg0 [0, 1, 2, 3, 4, 5, 6, 15] : vector<8xi4> + llvm.return %10 : vector<8xi4> + } +} diff --git a/test/LLVMDialect/InstCombine/vec_demanded_elts.ll.mlir b/test/LLVMDialect/InstCombine/vec_demanded_elts.ll.mlir new file mode 100644 index 000000000..c294a7c71 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vec_demanded_elts.ll.mlir @@ -0,0 +1,854 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.mlir.global internal @GLOBAL(0 : i32) {addr_space = 0 : i32, dso_local} : i32 + llvm.mlir.global external @global() {addr_space = 0 : i32, alignment = 4 : i64} : !llvm.array<0 x i32> + llvm.func @use(vector<2xi4>) + llvm.func @use_fp(vector<2xf32>) + llvm.func @test2(%arg0: f32) -> i32 { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.fmul %arg0, %arg0 : f32 + %7 = llvm.insertelement %6, %0[%1 : i32] : vector<4xf32> + %8 = llvm.insertelement %2, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %2, %8[%4 : i32] : vector<4xf32> + %10 = llvm.insertelement %2, %9[%5 : i32] : vector<4xf32> + %11 = llvm.bitcast %10 : vector<4xf32> to vector<4xi32> + %12 = llvm.extractelement %11[%1 : i32] : vector<4xi32> + llvm.return %12 : i32 + } + llvm.func @get_image() attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<100xi8>) : vector<100xi8> + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(80 : i8) : i8 + %6 = llvm.call @fgetc(%0) : (!llvm.ptr) -> i32 + %7 = llvm.trunc %6 : i32 to i8 + %8 = llvm.insertelement %7, %2[%3 : i32] : vector<100xi8> + %9 = llvm.extractelement %8[%4 : i32] : vector<100xi8> + %10 = llvm.icmp "eq" %9, %5 : i8 + llvm.cond_br %10, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.br ^bb2 + ^bb2: // 2 preds: ^bb0, ^bb1 + llvm.unreachable + } + llvm.func @vac(%arg0: !llvm.ptr {llvm.nocapture}) attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> vector<4xf32> + %6 = llvm.insertelement %0, %5[%1 : i32] : vector<4xf32> + %7 = llvm.insertelement %0, %6[%2 : i32] : vector<4xf32> + %8 = llvm.insertelement %0, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %0, %8[%4 : i32] : vector<4xf32> + llvm.store %9, %arg0 {alignment = 16 : i64} : vector<4xf32>, !llvm.ptr + llvm.return + } + llvm.func @fgetc(!llvm.ptr) -> i32 + llvm.func @dead_shuffle_elt(%arg0: vector<4xf32>, %arg1: vector<2xf32>) -> vector<4xf32> attributes {passthrough = ["nounwind"]} { + %0 = llvm.shufflevector %arg1, %arg1 [0, 1, 0, 1] : vector<2xf32> + %1 = llvm.shufflevector %arg0, %0 [4, 5, 2, 3] : vector<4xf32> + llvm.return %1 : vector<4xf32> + } + llvm.func @test_fptrunc(%arg0: f64) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<4xf64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.mlir.undef : vector<4xf32> + %7 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf64> + %8 = llvm.insertelement %2, %7[%3 : i32] : vector<4xf64> + %9 = llvm.insertelement %2, %8[%4 : i32] : vector<4xf64> + %10 = llvm.insertelement %2, %9[%5 : i32] : vector<4xf64> + %11 = llvm.fptrunc %10 : vector<4xf64> to vector<4xf32> + %12 = llvm.shufflevector %11, %6 [0, 1] : vector<4xf32> + llvm.return %12 : vector<2xf32> + } + llvm.func @test_fpext(%arg0: f32) -> vector<2xf64> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(3 : i32) : i32 + %6 = llvm.mlir.undef : vector<4xf64> + %7 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %8 = llvm.insertelement %2, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %2, %8[%4 : i32] : vector<4xf32> + %10 = llvm.insertelement %2, %9[%5 : i32] : vector<4xf32> + %11 = llvm.fpext %10 : vector<4xf32> to vector<4xf64> + %12 = llvm.shufflevector %11, %6 [0, 1] : vector<4xf64> + llvm.return %12 : vector<2xf64> + } + llvm.func @test_shuffle(%arg0: vector<4xf64>) -> vector<4xf64> { + %0 = llvm.mlir.undef : f64 + %1 = llvm.mlir.constant(1.000000e+00 : f64) : f64 + %2 = llvm.mlir.undef : vector<4xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xf64> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xf64> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xf64> + %11 = llvm.shufflevector %arg0, %10 [0, 1, 2, 5] : vector<4xf64> + llvm.return %11 : vector<4xf64> + } + llvm.func @test_select(%arg0: f32, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %5 = llvm.mlir.constant(2 : i32) : i32 + %6 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %7 = llvm.mlir.constant(3 : i32) : i32 + %8 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %9 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %10 = llvm.mlir.constant(6.000000e+00 : f32) : f32 + %11 = llvm.mlir.constant(true) : i1 + %12 = llvm.mlir.constant(false) : i1 + %13 = llvm.mlir.constant(dense<[true, false, false, true]> : vector<4xi1>) : vector<4xi1> + %14 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %15 = llvm.insertelement %2, %14[%3 : i32] : vector<4xf32> + %16 = llvm.insertelement %4, %15[%5 : i32] : vector<4xf32> + %17 = llvm.insertelement %6, %16[%7 : i32] : vector<4xf32> + %18 = llvm.insertelement %arg1, %0[%1 : i32] : vector<4xf32> + %19 = llvm.insertelement %8, %18[%3 : i32] : vector<4xf32> + %20 = llvm.insertelement %9, %19[%5 : i32] : vector<4xf32> + %21 = llvm.insertelement %10, %20[%7 : i32] : vector<4xf32> + %22 = llvm.select %13, %17, %21 : vector<4xi1>, vector<4xf32> + llvm.return %22 : vector<4xf32> + } + llvm.func @PR24922(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.addressof @PR24922 : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i1 + %3 = llvm.mlir.undef : vector<2xi1> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %2, %3[%4 : i32] : vector<2xi1> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %0, %5[%6 : i32] : vector<2xi1> + %8 = llvm.mlir.constant(0 : i64) : i64 + %9 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %10 = llvm.select %7, %arg0, %9 : vector<2xi1>, vector<2xi64> + llvm.return %10 : vector<2xi64> + } + llvm.func @inselt_shuf_no_demand(%arg0: f32, %arg1: f32, %arg2: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %arg1, %4[%2 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg2, %5[%3 : i32] : vector<4xf32> + %7 = llvm.shufflevector %6, %0 [0, -1, -1, -1] : vector<4xf32> + llvm.return %7 : vector<4xf32> + } + llvm.func @inselt_shuf_no_demand_commute(%arg0: f32, %arg1: f32, %arg2: f32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %arg1, %4[%2 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg2, %5[%3 : i32] : vector<4xf32> + %7 = llvm.shufflevector %0, %6 [4, -1, -1, -1] : vector<4xf32> + llvm.return %7 : vector<4xf32> + } + llvm.func @inselt_shuf_no_demand_multiuse(%arg0: i32, %arg1: i32, %arg2: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.undef : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi32> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<4xi32> + %7 = llvm.insertelement %arg0, %6[%3 : i32] : vector<4xi32> + %8 = llvm.add %7, %arg2 : vector<4xi32> + %9 = llvm.insertelement %arg1, %8[%4 : i32] : vector<4xi32> + %10 = llvm.shufflevector %9, %0 [0, 1, -1, -1] : vector<4xi32> + llvm.return %10 : vector<4xi32> + } + llvm.func @inselt_shuf_no_demand_bogus_insert_index_in_chain(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: i32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xf32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xf32> + %4 = llvm.insertelement %arg1, %3[%arg3 : i32] : vector<4xf32> + %5 = llvm.insertelement %arg2, %4[%2 : i32] : vector<4xf32> + %6 = llvm.shufflevector %5, %0 [0, -1, -1, -1] : vector<4xf32> + llvm.return %6 : vector<4xf32> + } + llvm.func @shuf_add(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.add %arg0, %0 overflow : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [1, -1, 2] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_sub(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.sub %0, %arg0 overflow : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [0, -1, 2] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_mul(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.mul %arg0, %0 overflow : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [0, 2, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_and(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.and %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [1, 1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_or(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.or %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [1, -1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_xor(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.xor %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, -1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_lshr_const_op0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.lshr %0, %arg0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, 1, -1] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_lshr_const_op1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.lshr %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, 1, -1] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_ashr_const_op0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.ashr %0, %arg0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [0, -1, 1] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_ashr_const_op1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.ashr %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [0, -1, 1] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_shl_const_op0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.shl %0, %arg0 overflow : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, -1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_shl_const_op1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.shl %arg0, %0 overflow : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, -1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_sdiv_const_op0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.sdiv %0, %arg0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [0, -1, 1] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_sdiv_const_op1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.sdiv %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [1, -1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_srem_const_op0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.srem %0, %arg0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [1, -1, 2] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_srem_const_op1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.srem %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, -1, 1] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_udiv_const_op0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.udiv %0, %arg0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, -1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_udiv_const_op1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.udiv %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, -1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_urem_const_op0(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.urem %0, %arg0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [2, 1, -1] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_urem_const_op1(%arg0: vector<3xi8>) -> vector<3xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 3]> : vector<3xi8>) : vector<3xi8> + %1 = llvm.mlir.undef : vector<3xi8> + %2 = llvm.urem %arg0, %0 : vector<3xi8> + %3 = llvm.shufflevector %2, %1 [-1, 1, 0] : vector<3xi8> + llvm.return %3 : vector<3xi8> + } + llvm.func @shuf_fadd(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.undef : vector<3xf32> + %2 = llvm.fadd %arg0, %0 : vector<3xf32> + %3 = llvm.shufflevector %2, %1 [-1, 1, 0] : vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @shuf_fsub(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.undef : vector<3xf32> + %2 = llvm.fsub %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<3xf32> + %3 = llvm.shufflevector %2, %1 [-1, 0, 2] : vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @shuf_fmul(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.undef : vector<3xf32> + %2 = llvm.fmul %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<3xf32> + %3 = llvm.shufflevector %2, %1 [-1, 1, 0] : vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @shuf_fdiv_const_op0(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.undef : vector<3xf32> + %2 = llvm.fdiv %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<3xf32> + %3 = llvm.shufflevector %2, %1 [-1, 0, 2] : vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @shuf_fdiv_const_op1(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.undef : vector<3xf32> + %2 = llvm.fdiv %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<3xf32> + %3 = llvm.shufflevector %2, %1 [-1, 1, 0] : vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @shuf_frem_const_op0(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.undef : vector<3xf32> + %2 = llvm.frem %0, %arg0 {fastmathFlags = #llvm.fastmath} : vector<3xf32> + %3 = llvm.shufflevector %2, %1 [-1, 2, 0] : vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @shuf_frem_const_op1(%arg0: vector<3xf32>) -> vector<3xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00]> : vector<3xf32>) : vector<3xf32> + %1 = llvm.mlir.undef : vector<3xf32> + %2 = llvm.frem %arg0, %0 {fastmathFlags = #llvm.fastmath} : vector<3xf32> + %3 = llvm.shufflevector %2, %1 [1, -1, 2] : vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @gep_vbase_w_s_idx(%arg0: !llvm.vec<2 x ptr>, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.getelementptr %arg0[%arg1] : (!llvm.vec<2 x ptr>, i64) -> !llvm.vec<2 x ptr>, i32 + %2 = llvm.extractelement %1[%0 : i32] : !llvm.vec<2 x ptr> + llvm.return %2 : !llvm.ptr + } + llvm.func @gep_splat_base_w_s_idx(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i64) : i64 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.shufflevector %4, %0 [0, 0] : !llvm.vec<2 x ptr> + %6 = llvm.getelementptr %5[%2] : (!llvm.vec<2 x ptr>, i64) -> !llvm.vec<2 x ptr>, i32 + %7 = llvm.extractelement %6[%3 : i32] : !llvm.vec<2 x ptr> + llvm.return %7 : !llvm.ptr + } + llvm.func @gep_splat_base_w_cv_idx(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.shufflevector %4, %0 [0, 0] : !llvm.vec<2 x ptr> + %6 = llvm.getelementptr %5[%2] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %7 = llvm.extractelement %6[%3 : i32] : !llvm.vec<2 x ptr> + llvm.return %7 : !llvm.ptr + } + llvm.func @gep_splat_base_w_vidx(%arg0: !llvm.ptr, %arg1: vector<2xi64>) -> !llvm.ptr { + %0 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %4 = llvm.shufflevector %3, %0 [0, 0] : !llvm.vec<2 x ptr> + %5 = llvm.getelementptr %4[%arg1] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %6 = llvm.extractelement %5[%2 : i32] : !llvm.vec<2 x ptr> + llvm.return %6 : !llvm.ptr + } + llvm.func @gep_cvbase_w_s_idx(%arg0: !llvm.vec<2 x ptr>, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @GLOBAL : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : !llvm.vec<2 x ptr> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.getelementptr %6[%arg1] : (!llvm.vec<2 x ptr>, i64) -> !llvm.vec<2 x ptr>, i32 + %9 = llvm.extractelement %8[%7 : i32] : !llvm.vec<2 x ptr> + llvm.return %9 : !llvm.ptr + } + llvm.func @gep_cvbase_w_cv_idx(%arg0: !llvm.vec<2 x ptr>, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @GLOBAL : !llvm.ptr + %2 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : !llvm.vec<2 x ptr> + %7 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %8 = llvm.mlir.constant(1 : i32) : i32 + %9 = llvm.getelementptr %6[%7] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %10 = llvm.extractelement %9[%8 : i32] : !llvm.vec<2 x ptr> + llvm.return %10 : !llvm.ptr + } + llvm.func @gep_sbase_w_cv_idx(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %3 = llvm.extractelement %2[%1 : i32] : !llvm.vec<2 x ptr> + llvm.return %3 : !llvm.ptr + } + llvm.func @gep_sbase_w_splat_idx(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.undef : vector<2xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.insertelement %arg1, %0[%1 : i32] : vector<2xi64> + %4 = llvm.shufflevector %3, %0 [0, 0] : vector<2xi64> + %5 = llvm.getelementptr %arg0[%4] : (!llvm.ptr, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %6 = llvm.extractelement %5[%2 : i32] : !llvm.vec<2 x ptr> + llvm.return %6 : !llvm.ptr + } + llvm.func @gep_splat_both(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.shufflevector %4, %0 [0, 0] : !llvm.vec<2 x ptr> + %6 = llvm.insertelement %arg1, %2[%1 : i32] : vector<2xi64> + %7 = llvm.shufflevector %6, %2 [0, 0] : vector<2xi64> + %8 = llvm.getelementptr %5[%7] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %9 = llvm.extractelement %8[%3 : i32] : !llvm.vec<2 x ptr> + llvm.return %9 : !llvm.ptr + } + llvm.func @gep_all_lanes_undef(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.vec<2 x ptr> { + %0 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.insertelement %arg1, %2[%3 : i32] : vector<2xi64> + %6 = llvm.getelementptr %4[%5] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + llvm.return %6 : !llvm.vec<2 x ptr> + } + llvm.func @gep_demanded_lane_undef(%arg0: !llvm.ptr, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.undef : !llvm.vec<2 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<2 x ptr> + %5 = llvm.insertelement %arg1, %2[%3 : i32] : vector<2xi64> + %6 = llvm.getelementptr %4[%5] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, i32 + %7 = llvm.extractelement %6[%3 : i32] : !llvm.vec<2 x ptr> + llvm.return %7 : !llvm.ptr + } + llvm.func @PR41624(%arg0: !llvm.vec<2 x ptr>) -> !llvm.ptr { + %0 = llvm.mlir.constant(dense<5> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.getelementptr %arg0[%0, 0] : (!llvm.vec<2 x ptr>, vector<2xi64>) -> !llvm.vec<2 x ptr>, !llvm.struct<(i32, i32)> + %4 = llvm.extractelement %3[%1 : i32] : !llvm.vec<2 x ptr> + llvm.return %4 : !llvm.ptr + } + llvm.func @zero_sized_type_extract(%arg0: vector<4xi64>, %arg1: i64) -> !llvm.ptr { + %0 = llvm.mlir.addressof @global : !llvm.ptr + %1 = llvm.mlir.undef : !llvm.vec<4 x ptr> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec<4 x ptr> + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec<4 x ptr> + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.insertelement %0, %5[%6 : i32] : !llvm.vec<4 x ptr> + %8 = llvm.mlir.constant(3 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : !llvm.vec<4 x ptr> + %10 = llvm.mlir.constant(0 : i64) : i64 + %11 = llvm.mlir.constant(dense<0> : vector<4xi64>) : vector<4xi64> + %12 = llvm.getelementptr inbounds %9[%11, %arg0] : (!llvm.vec<4 x ptr>, vector<4xi64>, vector<4xi64>) -> !llvm.vec<4 x ptr>, !llvm.array<0 x i32> + %13 = llvm.extractelement %12[%10 : i64] : !llvm.vec<4 x ptr> + llvm.return %13 : !llvm.ptr + } + llvm.func @select_cond_with_eq_true_false_elts(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi1>) -> vector<4xi8> { + %0 = llvm.mlir.undef : vector<4xi1> + %1 = llvm.shufflevector %arg0, %arg1 [0, 5, 6, 7] : vector<4xi8> + %2 = llvm.shufflevector %arg2, %0 [0, 0, 0, 0] : vector<4xi1> + %3 = llvm.select %2, %1, %arg1 : vector<4xi1>, vector<4xi8> + llvm.return %3 : vector<4xi8> + } + llvm.func @select_cond_with_eq_true_false_elts2(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi1>) -> vector<4xi8> { + %0 = llvm.mlir.undef : vector<4xi1> + %1 = llvm.shufflevector %arg0, %arg1 [0, 5, 6, 7] : vector<4xi8> + %2 = llvm.shufflevector %arg2, %0 [0, 1, 0, 1] : vector<4xi1> + %3 = llvm.select %2, %1, %arg0 : vector<4xi1>, vector<4xi8> + llvm.return %3 : vector<4xi8> + } + llvm.func @select_cond_with_eq_true_false_elts3(%arg0: vector<4xf32>, %arg1: vector<4xf32>, %arg2: vector<4xi1>) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xi1> + %1 = llvm.shufflevector %arg0, %arg1 [1, 3, 5, -1] : vector<4xf32> + %2 = llvm.shufflevector %arg1, %arg0 [0, 7, 6, -1] : vector<4xf32> + %3 = llvm.shufflevector %arg2, %0 [-1, 1, 2, 3] : vector<4xi1> + %4 = llvm.select %3, %1, %2 : vector<4xi1>, vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @select_cond_with_undef_true_false_elts(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi1>) -> vector<4xi8> { + %0 = llvm.mlir.undef : vector<4xi1> + %1 = llvm.shufflevector %arg0, %arg1 [-1, 5, 6, 7] : vector<4xi8> + %2 = llvm.shufflevector %arg2, %0 [0, 1, 0, 1] : vector<4xi1> + %3 = llvm.select %2, %1, %arg0 : vector<4xi1>, vector<4xi8> + llvm.return %3 : vector<4xi8> + } + llvm.func @select_cond_(%arg0: vector<4xi8>, %arg1: vector<4xi8>, %arg2: vector<4xi1>, %arg3: i1) -> vector<4xi8> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.insertelement %arg3, %arg2[%0 : i32] : vector<4xi1> + %2 = llvm.shufflevector %arg0, %arg1 [0, 5, 6, 7] : vector<4xi8> + %3 = llvm.select %1, %2, %arg0 : vector<4xi1>, vector<4xi8> + llvm.return %3 : vector<4xi8> + } + llvm.func @ins_of_ext(%arg0: vector<4xf32>, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xf32> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.extractelement %arg0[%0 : i32] : vector<4xf32> + %6 = llvm.insertelement %5, %1[%0 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg1, %6[%2 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg1, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg1, %8[%4 : i32] : vector<4xf32> + llvm.return %9 : vector<4xf32> + } + llvm.func @ins_of_ext_twice(%arg0: vector<4xf32>, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xf32> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.extractelement %arg0[%0 : i32] : vector<4xf32> + %6 = llvm.insertelement %5, %1[%0 : i32] : vector<4xf32> + %7 = llvm.extractelement %arg0[%2 : i32] : vector<4xf32> + %8 = llvm.insertelement %7, %6[%2 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg1, %8[%3 : i32] : vector<4xf32> + %10 = llvm.insertelement %arg1, %9[%4 : i32] : vector<4xf32> + llvm.return %10 : vector<4xf32> + } + llvm.func @ins_of_ext_wrong_demand(%arg0: vector<4xf32>, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xf32> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.extractelement %arg0[%0 : i32] : vector<4xf32> + %5 = llvm.insertelement %4, %1[%0 : i32] : vector<4xf32> + %6 = llvm.insertelement %arg1, %5[%2 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg1, %6[%3 : i32] : vector<4xf32> + llvm.return %7 : vector<4xf32> + } + llvm.func @ins_of_ext_wrong_type(%arg0: vector<5xf32>, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xf32> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.extractelement %arg0[%0 : i32] : vector<5xf32> + %6 = llvm.insertelement %5, %1[%0 : i32] : vector<4xf32> + %7 = llvm.insertelement %arg1, %6[%2 : i32] : vector<4xf32> + %8 = llvm.insertelement %arg1, %7[%3 : i32] : vector<4xf32> + %9 = llvm.insertelement %arg1, %8[%4 : i32] : vector<4xf32> + llvm.return %9 : vector<4xf32> + } + llvm.func @ins_of_ext_undef_elts_propagation(%arg0: vector<4xi4>, %arg1: vector<4xi4>, %arg2: i4) -> vector<4xi4> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : vector<4xi4> + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.extractelement %arg0[%0 : i32] : vector<4xi4> + %4 = llvm.insertelement %3, %1[%0 : i32] : vector<4xi4> + %5 = llvm.insertelement %arg2, %4[%2 : i32] : vector<4xi4> + %6 = llvm.shufflevector %5, %arg1 [0, 6, 2, 7] : vector<4xi4> + llvm.return %6 : vector<4xi4> + } + llvm.func @ins_of_ext_undef_elts_propagation2(%arg0: vector<8xi4>, %arg1: vector<8xi4>, %arg2: i4) -> vector<8xi4> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : vector<8xi4> + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.extractelement %arg0[%0 : i32] : vector<8xi4> + %5 = llvm.insertelement %4, %1[%0 : i32] : vector<8xi4> + %6 = llvm.extractelement %arg0[%2 : i32] : vector<8xi4> + %7 = llvm.insertelement %6, %5[%2 : i32] : vector<8xi4> + %8 = llvm.insertelement %arg2, %7[%3 : i32] : vector<8xi4> + %9 = llvm.shufflevector %8, %arg1 [0, 1, 2, 11, 10, 9, 8, -1] : vector<8xi4> + %10 = llvm.shufflevector %9, %arg0 [0, 1, 2, 3, 4, 5, 6, 15] : vector<8xi4> + llvm.return %10 : vector<8xi4> + } + llvm.func @common_binop_demand_via_splat_op0(%arg0: vector<2xi4>, %arg1: vector<2xi4>) { + %0 = llvm.mlir.poison : vector<2xi4> + %1 = llvm.shufflevector %arg0, %0 [0, 0] : vector<2xi4> + %2 = llvm.mul %1, %arg1 : vector<2xi4> + %3 = llvm.mul %arg0, %arg1 : vector<2xi4> + %4 = llvm.shufflevector %3, %0 [0, 0] : vector<2xi4> + llvm.call @use(%2) : (vector<2xi4>) -> () + llvm.call @use(%4) : (vector<2xi4>) -> () + llvm.return + } + llvm.func @common_binop_demand_via_splat_op1(%arg0: vector<2xi4>, %arg1: vector<2xi4>) { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.poison : vector<2xi4> + %4 = llvm.sub %2, %arg0 : vector<2xi4> + %5 = llvm.shufflevector %arg1, %3 [0, 0] : vector<2xi4> + %6 = llvm.mul %4, %5 : vector<2xi4> + %7 = llvm.mul %4, %arg1 : vector<2xi4> + %8 = llvm.shufflevector %7, %3 [0, 0] : vector<2xi4> + llvm.call @use(%8) : (vector<2xi4>) -> () + llvm.call @use(%6) : (vector<2xi4>) -> () + llvm.return + } + llvm.func @common_binop_demand_via_splat_op0_commute(%arg0: vector<2xi4>, %arg1: vector<2xi4>) { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.constant(2 : i4) : i4 + %4 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi4>) : vector<2xi4> + %5 = llvm.mlir.poison : vector<2xi4> + %6 = llvm.sub %2, %arg0 : vector<2xi4> + %7 = llvm.sub %4, %arg1 : vector<2xi4> + %8 = llvm.shufflevector %6, %5 [0, 0] : vector<2xi4> + %9 = llvm.mul %7, %8 : vector<2xi4> + %10 = llvm.mul %6, %7 : vector<2xi4> + %11 = llvm.shufflevector %10, %5 [0, 0] : vector<2xi4> + llvm.call @use(%11) : (vector<2xi4>) -> () + llvm.call @use(%9) : (vector<2xi4>) -> () + llvm.return + } + llvm.func @common_binop_demand_via_splat_op1_commute(%arg0: vector<2xi4>, %arg1: vector<2xi4>) { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.constant(3 : i4) : i4 + %4 = llvm.mlir.constant(2 : i4) : i4 + %5 = llvm.mlir.constant(dense<[2, 3]> : vector<2xi4>) : vector<2xi4> + %6 = llvm.mlir.poison : vector<2xi4> + %7 = llvm.sub %2, %arg0 : vector<2xi4> + %8 = llvm.sub %5, %arg1 : vector<2xi4> + %9 = llvm.shufflevector %8, %6 [0, 0] : vector<2xi4> + %10 = llvm.mul %9, %7 : vector<2xi4> + %11 = llvm.mul %7, %8 : vector<2xi4> + %12 = llvm.shufflevector %11, %6 [0, 0] : vector<2xi4> + llvm.call @use(%12) : (vector<2xi4>) -> () + llvm.call @use(%10) : (vector<2xi4>) -> () + llvm.return + } + llvm.func @common_binop_demand_via_splat_op0_wrong_commute(%arg0: vector<2xi4>, %arg1: vector<2xi4>) { + %0 = llvm.mlir.poison : vector<2xi4> + %1 = llvm.shufflevector %arg0, %0 [0, 0] : vector<2xi4> + %2 = llvm.sub %arg1, %1 : vector<2xi4> + %3 = llvm.sub %arg0, %arg1 : vector<2xi4> + %4 = llvm.shufflevector %3, %0 [0, 0] : vector<2xi4> + llvm.call @use(%4) : (vector<2xi4>) -> () + llvm.call @use(%2) : (vector<2xi4>) -> () + llvm.return + } + llvm.func @common_binop_demand_via_splat_op0_not_dominated1(%arg0: vector<2xi4>, %arg1: vector<2xi4>) { + %0 = llvm.mlir.poison : vector<2xi4> + %1 = llvm.mul %arg0, %arg1 : vector<2xi4> + %2 = llvm.shufflevector %arg0, %0 [0, 0] : vector<2xi4> + %3 = llvm.mul %2, %arg1 : vector<2xi4> + %4 = llvm.shufflevector %1, %0 [0, 0] : vector<2xi4> + llvm.call @use(%3) : (vector<2xi4>) -> () + llvm.call @use(%4) : (vector<2xi4>) -> () + llvm.return + } + llvm.func @common_binop_demand_via_splat_op0_not_dominated2(%arg0: vector<2xi4>, %arg1: vector<2xi4>) { + %0 = llvm.mlir.poison : vector<2xi4> + %1 = llvm.mul %arg0, %arg1 : vector<2xi4> + %2 = llvm.shufflevector %1, %0 [0, 0] : vector<2xi4> + %3 = llvm.shufflevector %arg0, %0 [0, 0] : vector<2xi4> + %4 = llvm.mul %3, %arg1 : vector<2xi4> + llvm.call @use(%4) : (vector<2xi4>) -> () + llvm.call @use(%2) : (vector<2xi4>) -> () + llvm.return + } + llvm.func @common_binop_demand_via_extelt_op0(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> i4 { + %0 = llvm.mlir.poison : vector<2xi4> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shufflevector %arg0, %0 [0, 0] : vector<2xi4> + %3 = llvm.sub %2, %arg1 : vector<2xi4> + %4 = llvm.sub %arg0, %arg1 overflow : vector<2xi4> + %5 = llvm.extractelement %4[%1 : i32] : vector<2xi4> + llvm.call @use(%3) : (vector<2xi4>) -> () + llvm.return %5 : i4 + } + llvm.func @common_binop_demand_via_extelt_op1(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> f32 { + %0 = llvm.mlir.constant(dense<[0.000000e+00, 1.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.poison : vector<2xf32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.fsub %0, %arg0 : vector<2xf32> + %4 = llvm.shufflevector %arg1, %1 [0, 0] : vector<2xf32> + %5 = llvm.fdiv %3, %4 : vector<2xf32> + %6 = llvm.fdiv %3, %arg1 : vector<2xf32> + %7 = llvm.extractelement %6[%2 : i32] : vector<2xf32> + llvm.call @use_fp(%5) : (vector<2xf32>) -> () + llvm.return %7 : f32 + } + llvm.func @common_binop_demand_via_extelt_op0_commute(%arg0: vector<2xf32>, %arg1: vector<2xf32>) -> f32 { + %0 = llvm.mlir.constant(dense<[0.000000e+00, 1.000000e+00]> : vector<2xf32>) : vector<2xf32> + %1 = llvm.mlir.constant(dense<[3.000000e+00, 2.000000e+00]> : vector<2xf32>) : vector<2xf32> + %2 = llvm.mlir.poison : vector<2xf32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.fsub %0, %arg0 : vector<2xf32> + %5 = llvm.fsub %1, %arg1 : vector<2xf32> + %6 = llvm.shufflevector %4, %2 [0, 0] : vector<2xf32> + %7 = llvm.fmul %5, %6 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %8 = llvm.fmul %4, %5 {fastmathFlags = #llvm.fastmath} : vector<2xf32> + %9 = llvm.extractelement %8[%3 : i32] : vector<2xf32> + llvm.call @use_fp(%7) : (vector<2xf32>) -> () + llvm.return %9 : f32 + } + llvm.func @common_binop_demand_via_extelt_op1_commute(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> i4 { + %0 = llvm.mlir.constant(1 : i4) : i4 + %1 = llvm.mlir.constant(0 : i4) : i4 + %2 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.constant(3 : i4) : i4 + %4 = llvm.mlir.constant(2 : i4) : i4 + %5 = llvm.mlir.constant(dense<[2, 3]> : vector<2xi4>) : vector<2xi4> + %6 = llvm.mlir.poison : vector<2xi4> + %7 = llvm.mlir.constant(0 : i32) : i32 + %8 = llvm.sub %2, %arg0 : vector<2xi4> + %9 = llvm.sub %5, %arg1 : vector<2xi4> + %10 = llvm.shufflevector %9, %6 [0, 0] : vector<2xi4> + %11 = llvm.or %10, %8 : vector<2xi4> + %12 = llvm.or %8, %9 : vector<2xi4> + %13 = llvm.extractelement %12[%7 : i32] : vector<2xi4> + llvm.call @use(%11) : (vector<2xi4>) -> () + llvm.return %13 : i4 + } + llvm.func @common_binop_demand_via_extelt_op0_wrong_commute(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> i4 { + %0 = llvm.mlir.poison : vector<2xi4> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shufflevector %arg0, %0 [0, 0] : vector<2xi4> + %3 = llvm.sub %arg1, %2 : vector<2xi4> + %4 = llvm.sub %arg0, %arg1 : vector<2xi4> + %5 = llvm.extractelement %4[%1 : i32] : vector<2xi4> + llvm.call @use(%3) : (vector<2xi4>) -> () + llvm.return %5 : i4 + } + llvm.func @common_binop_demand_via_extelt_op0_not_dominated1(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> i4 { + %0 = llvm.mlir.poison : vector<2xi4> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.xor %arg0, %arg1 : vector<2xi4> + %3 = llvm.shufflevector %arg0, %0 [0, 0] : vector<2xi4> + %4 = llvm.xor %3, %arg1 : vector<2xi4> + %5 = llvm.extractelement %2[%1 : i32] : vector<2xi4> + llvm.call @use(%4) : (vector<2xi4>) -> () + llvm.return %5 : i4 + } + llvm.func @common_binop_demand_via_extelt_op0_not_dominated2(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> i4 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.poison : vector<2xi4> + %2 = llvm.mul %arg0, %arg1 : vector<2xi4> + %3 = llvm.extractelement %2[%0 : i32] : vector<2xi4> + %4 = llvm.shufflevector %arg0, %1 [0, 0] : vector<2xi4> + %5 = llvm.mul %4, %arg1 : vector<2xi4> + llvm.call @use(%5) : (vector<2xi4>) -> () + llvm.return %3 : i4 + } + llvm.func @common_binop_demand_via_extelt_op0_mismatch_elt0(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> i4 { + %0 = llvm.mlir.poison : vector<2xi4> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shufflevector %arg0, %0 [1, 1] : vector<2xi4> + %3 = llvm.sub %2, %arg1 : vector<2xi4> + %4 = llvm.sub %arg0, %arg1 overflow : vector<2xi4> + %5 = llvm.extractelement %4[%1 : i32] : vector<2xi4> + llvm.call @use(%3) : (vector<2xi4>) -> () + llvm.return %5 : i4 + } + llvm.func @common_binop_demand_via_extelt_op0_mismatch_elt1(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> i4 { + %0 = llvm.mlir.poison : vector<2xi4> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.shufflevector %arg0, %0 [0, 0] : vector<2xi4> + %3 = llvm.sub %2, %arg1 : vector<2xi4> + %4 = llvm.sub %arg0, %arg1 overflow : vector<2xi4> + %5 = llvm.extractelement %4[%1 : i32] : vector<2xi4> + llvm.call @use(%3) : (vector<2xi4>) -> () + llvm.return %5 : i4 + } + llvm.func @common_binop_demand_via_splat_mask_poison(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.shufflevector %arg1, %0 [0, -1] : vector<2xi8> + %2 = llvm.add %arg0, %1 : vector<2xi8> + %3 = llvm.add %arg0, %arg1 : vector<2xi8> + %4 = llvm.shufflevector %3, %0 [0, 0] : vector<2xi8> + %5 = llvm.add %2, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @common_binop_demand_via_splat_mask_poison_2(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.shufflevector %arg1, %0 [-1, 0] : vector<2xi8> + %2 = llvm.add %arg0, %1 : vector<2xi8> + %3 = llvm.add %arg0, %arg1 : vector<2xi8> + %4 = llvm.shufflevector %3, %arg1 [0, 2] : vector<2xi8> + %5 = llvm.add %2, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @common_binop_demand_via_splat_mask_poison_3(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.poison : vector<2xi8> + %1 = llvm.shufflevector %arg1, %0 [-1, 0] : vector<2xi8> + %2 = llvm.add %arg0, %1 : vector<2xi8> + %3 = llvm.add %arg0, %arg1 : vector<2xi8> + %4 = llvm.shufflevector %3, %0 [0, 0] : vector<2xi8> + %5 = llvm.add %2, %4 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/vec_extract_2elts.ll.mlir b/test/LLVMDialect/InstCombine/vec_extract_2elts.ll.mlir new file mode 100644 index 000000000..f2491b232 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vec_extract_2elts.ll.mlir @@ -0,0 +1,10 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: vector<4xi32>, %arg1: !llvm.ptr, %arg2: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.zext %arg0 : vector<4xi32> to vector<4xi64> + %2 = llvm.extractelement %1[%0 : i32] : vector<4xi64> + llvm.store %2, %arg1 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.store %2, %arg2 {alignment = 4 : i64} : i64, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/vec_extract_var_elt-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/vec_extract_var_elt-inseltpoison.ll.mlir new file mode 100644 index 000000000..f5fdbad6e --- /dev/null +++ b/test/LLVMDialect/InstCombine/vec_extract_var_elt-inseltpoison.ll.mlir @@ -0,0 +1,24 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: f32, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.poison : vector<8xi32> + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.load %arg1 {alignment = 32 : i64} : !llvm.ptr -> vector<8xf32> + %4 = llvm.bitcast %3 : vector<8xf32> to vector<8xi32> + %5 = llvm.bitcast %4 : vector<8xi32> to vector<8xf32> + %6 = llvm.fptosi %5 : vector<8xf32> to vector<8xi32> + %7 = llvm.fptosi %arg0 : f32 to i32 + %8 = llvm.add %7, %0 : i32 + %9 = llvm.extractelement %6[%8 : i32] : vector<8xi32> + %10 = llvm.insertelement %9, %1[%2 : i32] : vector<8xi32> + %11 = llvm.sitofp %10 : vector<8xi32> to vector<8xf32> + llvm.store %11, %arg1 {alignment = 32 : i64} : vector<8xf32>, !llvm.ptr + llvm.return + } + llvm.func @test2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.bitcast %0 : vector<2xi64> to vector<4xi32> + %2 = llvm.extractelement %1[%arg0 : i32] : vector<4xi32> + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/vec_extract_var_elt.ll.mlir b/test/LLVMDialect/InstCombine/vec_extract_var_elt.ll.mlir new file mode 100644 index 000000000..ea45a3067 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vec_extract_var_elt.ll.mlir @@ -0,0 +1,24 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test(%arg0: f32, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.undef : vector<8xi32> + %2 = llvm.mlir.constant(7 : i32) : i32 + %3 = llvm.load %arg1 {alignment = 32 : i64} : !llvm.ptr -> vector<8xf32> + %4 = llvm.bitcast %3 : vector<8xf32> to vector<8xi32> + %5 = llvm.bitcast %4 : vector<8xi32> to vector<8xf32> + %6 = llvm.fptosi %5 : vector<8xf32> to vector<8xi32> + %7 = llvm.fptosi %arg0 : f32 to i32 + %8 = llvm.add %7, %0 : i32 + %9 = llvm.extractelement %6[%8 : i32] : vector<8xi32> + %10 = llvm.insertelement %9, %1[%2 : i32] : vector<8xi32> + %11 = llvm.sitofp %10 : vector<8xi32> to vector<8xf32> + llvm.store %11, %arg1 {alignment = 32 : i64} : vector<8xf32>, !llvm.ptr + llvm.return + } + llvm.func @test2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.bitcast %0 : vector<2xi64> to vector<4xi32> + %2 = llvm.extractelement %1[%arg0 : i32] : vector<4xi32> + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/vec_gep_scalar_arg-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/vec_gep_scalar_arg-inseltpoison.ll.mlir new file mode 100644 index 000000000..4fcfab183 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vec_gep_scalar_arg-inseltpoison.ll.mlir @@ -0,0 +1,13 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @PR41270(%arg0: !llvm.ptr) -> !llvm.vec<4 x ptr> { + %0 = llvm.mlir.poison : !llvm.vec<4 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<4 x ptr> + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : !llvm.vec<4 x ptr> + %5 = llvm.getelementptr inbounds %4[%1, %2] : (!llvm.vec<4 x ptr>, i32, i32) -> !llvm.vec<4 x ptr>, !llvm.array<4 x i16> + %6 = llvm.extractelement %5[%2 : i32] : !llvm.vec<4 x ptr> + %7 = llvm.insertelement %6, %0[%1 : i32] : !llvm.vec<4 x ptr> + llvm.return %7 : !llvm.vec<4 x ptr> + } +} diff --git a/test/LLVMDialect/InstCombine/vec_gep_scalar_arg.ll.mlir b/test/LLVMDialect/InstCombine/vec_gep_scalar_arg.ll.mlir new file mode 100644 index 000000000..28870d345 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vec_gep_scalar_arg.ll.mlir @@ -0,0 +1,13 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @PR41270(%arg0: !llvm.ptr) -> !llvm.vec<4 x ptr> { + %0 = llvm.mlir.undef : !llvm.vec<4 x ptr> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(3 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec<4 x ptr> + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : !llvm.vec<4 x ptr> + %5 = llvm.getelementptr inbounds %4[%1, %2] : (!llvm.vec<4 x ptr>, i32, i32) -> !llvm.vec<4 x ptr>, !llvm.array<4 x i16> + %6 = llvm.extractelement %5[%2 : i32] : !llvm.vec<4 x ptr> + %7 = llvm.insertelement %6, %0[%1 : i32] : !llvm.vec<4 x ptr> + llvm.return %7 : !llvm.vec<4 x ptr> + } +} diff --git a/test/LLVMDialect/InstCombine/vec_phi_extract-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/vec_phi_extract-inseltpoison.ll.mlir new file mode 100644 index 000000000..c8b740251 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vec_phi_extract-inseltpoison.ll.mlir @@ -0,0 +1,93 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f(%arg0: i64, %arg1: i32, %arg2: !llvm.ptr) { + %0 = llvm.mlir.poison : vector<16xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]> : vector<16xi64>) : vector<16xi64> + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.mlir.constant(dense<16> : vector<16xi32>) : vector<16xi32> + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<16xi64> + %6 = llvm.shufflevector %5, %0 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] : vector<16xi64> + %7 = llvm.add %6, %2 : vector<16xi64> + %8 = llvm.trunc %7 : vector<16xi64> to vector<16xi32> + llvm.br ^bb1(%8 : vector<16xi32>) + ^bb1(%9: vector<16xi32>): // 2 preds: ^bb0, ^bb1 + %10 = llvm.extractelement %9[%1 : i32] : vector<16xi32> + %11 = llvm.icmp "ult" %10, %arg1 : i32 + %12 = llvm.add %3, %10 : i32 + %13 = llvm.sext %10 : i32 to i64 + %14 = llvm.getelementptr %arg2[%13] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %12, %14 {alignment = 4 : i64} : i32, !llvm.ptr + %15 = llvm.add %9, %4 : vector<16xi32> + llvm.cond_br %11, ^bb1(%15 : vector<16xi32>), ^bb2 + ^bb2: // pred: ^bb1 + llvm.return + } + llvm.func @copy(%arg0: i64, %arg1: i32, %arg2: !llvm.ptr) { + %0 = llvm.mlir.poison : vector<16xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]> : vector<16xi64>) : vector<16xi64> + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.mlir.constant(dense<16> : vector<16xi32>) : vector<16xi32> + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<16xi64> + %6 = llvm.shufflevector %5, %0 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] : vector<16xi64> + %7 = llvm.add %6, %2 : vector<16xi64> + %8 = llvm.trunc %7 : vector<16xi64> to vector<16xi32> + llvm.br ^bb1(%8 : vector<16xi32>) + ^bb1(%9: vector<16xi32>): // 2 preds: ^bb0, ^bb1 + %10 = llvm.extractelement %9[%1 : i32] : vector<16xi32> + %11 = llvm.extractelement %9[%1 : i32] : vector<16xi32> + %12 = llvm.icmp "ult" %10, %arg1 : i32 + %13 = llvm.add %3, %11 : i32 + %14 = llvm.sext %10 : i32 to i64 + %15 = llvm.getelementptr %arg2[%14] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %13, %15 {alignment = 4 : i64} : i32, !llvm.ptr + %16 = llvm.add %9, %4 : vector<16xi32> + llvm.cond_br %12, ^bb1(%16 : vector<16xi32>), ^bb2 + ^bb2: // pred: ^bb1 + llvm.return + } + llvm.func @nocopy(%arg0: i64, %arg1: i32, %arg2: !llvm.ptr) { + %0 = llvm.mlir.poison : vector<16xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]> : vector<16xi64>) : vector<16xi64> + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(10 : i32) : i32 + %5 = llvm.mlir.constant(dense<16> : vector<16xi32>) : vector<16xi32> + %6 = llvm.insertelement %arg0, %0[%1 : i32] : vector<16xi64> + %7 = llvm.shufflevector %6, %0 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] : vector<16xi64> + %8 = llvm.add %7, %2 : vector<16xi64> + %9 = llvm.trunc %8 : vector<16xi64> to vector<16xi32> + llvm.br ^bb1(%9 : vector<16xi32>) + ^bb1(%10: vector<16xi32>): // 2 preds: ^bb0, ^bb1 + %11 = llvm.extractelement %10[%1 : i32] : vector<16xi32> + %12 = llvm.extractelement %10[%3 : i32] : vector<16xi32> + %13 = llvm.icmp "ult" %11, %arg1 : i32 + %14 = llvm.add %4, %12 : i32 + %15 = llvm.sext %11 : i32 to i64 + %16 = llvm.getelementptr %arg2[%15] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %14, %16 {alignment = 4 : i64} : i32, !llvm.ptr + %17 = llvm.add %10, %5 : vector<16xi32> + llvm.cond_br %13, ^bb1(%17 : vector<16xi32>), ^bb2 + ^bb2: // pred: ^bb1 + llvm.return + } + llvm.func @g(%arg0: vector<3xi32>, %arg1: i1) -> i1 { + %0 = llvm.mlir.poison : vector<3xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<3xi32>) : vector<3xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + llvm.br ^bb1(%arg0, %0 : vector<3xi32>, vector<3xi32>) + ^bb1(%4: vector<3xi32>, %5: vector<3xi32>): // 2 preds: ^bb0, ^bb2 + llvm.cond_br %arg1, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + %6 = llvm.add %5, %1 : vector<3xi32> + %7 = llvm.sub %1, %6 : vector<3xi32> + %8 = llvm.sdiv %4, %7 : vector<3xi32> + llvm.br ^bb1(%8, %6 : vector<3xi32>, vector<3xi32>) + ^bb3: // pred: ^bb1 + %9 = llvm.extractelement %4[%2 : i32] : vector<3xi32> + %10 = llvm.select %3, %2, %9 : i1, i32 + %11 = llvm.icmp "eq" %10, %2 : i32 + llvm.return %11 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/vec_phi_extract.ll.mlir b/test/LLVMDialect/InstCombine/vec_phi_extract.ll.mlir new file mode 100644 index 000000000..7dd1d07b0 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vec_phi_extract.ll.mlir @@ -0,0 +1,93 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f(%arg0: i64, %arg1: i32, %arg2: !llvm.ptr) { + %0 = llvm.mlir.undef : vector<16xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]> : vector<16xi64>) : vector<16xi64> + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.mlir.constant(dense<16> : vector<16xi32>) : vector<16xi32> + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<16xi64> + %6 = llvm.shufflevector %5, %0 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] : vector<16xi64> + %7 = llvm.add %6, %2 : vector<16xi64> + %8 = llvm.trunc %7 : vector<16xi64> to vector<16xi32> + llvm.br ^bb1(%8 : vector<16xi32>) + ^bb1(%9: vector<16xi32>): // 2 preds: ^bb0, ^bb1 + %10 = llvm.extractelement %9[%1 : i32] : vector<16xi32> + %11 = llvm.icmp "ult" %10, %arg1 : i32 + %12 = llvm.add %3, %10 : i32 + %13 = llvm.sext %10 : i32 to i64 + %14 = llvm.getelementptr %arg2[%13] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %12, %14 {alignment = 4 : i64} : i32, !llvm.ptr + %15 = llvm.add %9, %4 : vector<16xi32> + llvm.cond_br %11, ^bb1(%15 : vector<16xi32>), ^bb2 + ^bb2: // pred: ^bb1 + llvm.return + } + llvm.func @copy(%arg0: i64, %arg1: i32, %arg2: !llvm.ptr) { + %0 = llvm.mlir.undef : vector<16xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]> : vector<16xi64>) : vector<16xi64> + %3 = llvm.mlir.constant(10 : i32) : i32 + %4 = llvm.mlir.constant(dense<16> : vector<16xi32>) : vector<16xi32> + %5 = llvm.insertelement %arg0, %0[%1 : i32] : vector<16xi64> + %6 = llvm.shufflevector %5, %0 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] : vector<16xi64> + %7 = llvm.add %6, %2 : vector<16xi64> + %8 = llvm.trunc %7 : vector<16xi64> to vector<16xi32> + llvm.br ^bb1(%8 : vector<16xi32>) + ^bb1(%9: vector<16xi32>): // 2 preds: ^bb0, ^bb1 + %10 = llvm.extractelement %9[%1 : i32] : vector<16xi32> + %11 = llvm.extractelement %9[%1 : i32] : vector<16xi32> + %12 = llvm.icmp "ult" %10, %arg1 : i32 + %13 = llvm.add %3, %11 : i32 + %14 = llvm.sext %10 : i32 to i64 + %15 = llvm.getelementptr %arg2[%14] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %13, %15 {alignment = 4 : i64} : i32, !llvm.ptr + %16 = llvm.add %9, %4 : vector<16xi32> + llvm.cond_br %12, ^bb1(%16 : vector<16xi32>), ^bb2 + ^bb2: // pred: ^bb1 + llvm.return + } + llvm.func @nocopy(%arg0: i64, %arg1: i32, %arg2: !llvm.ptr) { + %0 = llvm.mlir.undef : vector<16xi64> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]> : vector<16xi64>) : vector<16xi64> + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.constant(10 : i32) : i32 + %5 = llvm.mlir.constant(dense<16> : vector<16xi32>) : vector<16xi32> + %6 = llvm.insertelement %arg0, %0[%1 : i32] : vector<16xi64> + %7 = llvm.shufflevector %6, %0 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] : vector<16xi64> + %8 = llvm.add %7, %2 : vector<16xi64> + %9 = llvm.trunc %8 : vector<16xi64> to vector<16xi32> + llvm.br ^bb1(%9 : vector<16xi32>) + ^bb1(%10: vector<16xi32>): // 2 preds: ^bb0, ^bb1 + %11 = llvm.extractelement %10[%1 : i32] : vector<16xi32> + %12 = llvm.extractelement %10[%3 : i32] : vector<16xi32> + %13 = llvm.icmp "ult" %11, %arg1 : i32 + %14 = llvm.add %4, %12 : i32 + %15 = llvm.sext %11 : i32 to i64 + %16 = llvm.getelementptr %arg2[%15] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + llvm.store %14, %16 {alignment = 4 : i64} : i32, !llvm.ptr + %17 = llvm.add %10, %5 : vector<16xi32> + llvm.cond_br %13, ^bb1(%17 : vector<16xi32>), ^bb2 + ^bb2: // pred: ^bb1 + llvm.return + } + llvm.func @g(%arg0: vector<3xi32>, %arg1: i1) -> i1 { + %0 = llvm.mlir.poison : vector<3xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<3xi32>) : vector<3xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(false) : i1 + llvm.br ^bb1(%arg0, %0 : vector<3xi32>, vector<3xi32>) + ^bb1(%4: vector<3xi32>, %5: vector<3xi32>): // 2 preds: ^bb0, ^bb2 + llvm.cond_br %arg1, ^bb3, ^bb2 + ^bb2: // pred: ^bb1 + %6 = llvm.add %5, %1 : vector<3xi32> + %7 = llvm.sub %1, %6 : vector<3xi32> + %8 = llvm.sdiv %4, %7 : vector<3xi32> + llvm.br ^bb1(%8, %6 : vector<3xi32>, vector<3xi32>) + ^bb3: // pred: ^bb1 + %9 = llvm.extractelement %4[%2 : i32] : vector<3xi32> + %10 = llvm.select %3, %2, %9 : i1, i32 + %11 = llvm.icmp "eq" %10, %2 : i32 + llvm.return %11 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/vec_sext.ll.mlir b/test/LLVMDialect/InstCombine/vec_sext.ll.mlir new file mode 100644 index 000000000..0af2b669e --- /dev/null +++ b/test/LLVMDialect/InstCombine/vec_sext.ll.mlir @@ -0,0 +1,56 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @vec_select(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %3 = llvm.icmp "slt" %arg1, %1 : vector<4xi32> + %4 = llvm.sext %3 : vector<4xi1> to vector<4xi32> + %5 = llvm.sub %1, %arg0 overflow : vector<4xi32> + %6 = llvm.icmp "slt" %4, %1 : vector<4xi32> + %7 = llvm.sext %6 : vector<4xi1> to vector<4xi32> + %8 = llvm.xor %7, %2 : vector<4xi32> + %9 = llvm.and %arg0, %8 : vector<4xi32> + %10 = llvm.and %7, %5 : vector<4xi32> + %11 = llvm.or %9, %10 : vector<4xi32> + llvm.return %11 : vector<4xi32> + } + llvm.func @vec_select_alternate_sign_bit_test(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %3 = llvm.icmp "sgt" %arg1, %0 : vector<4xi32> + %4 = llvm.sext %3 : vector<4xi1> to vector<4xi32> + %5 = llvm.sub %2, %arg0 overflow : vector<4xi32> + %6 = llvm.icmp "slt" %4, %2 : vector<4xi32> + %7 = llvm.sext %6 : vector<4xi1> to vector<4xi32> + %8 = llvm.xor %7, %0 : vector<4xi32> + %9 = llvm.and %arg0, %8 : vector<4xi32> + %10 = llvm.and %7, %5 : vector<4xi32> + %11 = llvm.or %9, %10 : vector<4xi32> + llvm.return %11 : vector<4xi32> + } + llvm.func @is_negative_poison_elt(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.icmp "slt" %arg0, %6 : vector<2xi32> + %8 = llvm.sext %7 : vector<2xi1> to vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @is_positive_poison_elt(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.undef : vector<2xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi32> + %7 = llvm.icmp "sgt" %arg0, %6 : vector<2xi32> + %8 = llvm.sext %7 : vector<2xi1> to vector<2xi32> + llvm.return %8 : vector<2xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/vec_shuffle-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/vec_shuffle-inseltpoison.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/vec_shuffle.ll.mlir b/test/LLVMDialect/InstCombine/vec_shuffle.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/vec_udiv_to_shift.ll.mlir b/test/LLVMDialect/InstCombine/vec_udiv_to_shift.ll.mlir index ecb9ced9d..4ec9fe024 100644 --- a/test/LLVMDialect/InstCombine/vec_udiv_to_shift.ll.mlir +++ b/test/LLVMDialect/InstCombine/vec_udiv_to_shift.ll.mlir @@ -1,15 +1,12 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi16>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<32> : vector<8xi16>} : () -> vector<8xi16> - %1 = "llvm.udiv"(%arg0, %0) : (vector<8xi16>, vector<8xi16>) -> vector<8xi16> - "llvm.return"(%1) : (vector<8xi16>) -> () - }) {linkage = 10 : i64, sym_name = "udiv_vec8x16", type = !llvm.func (vector<8xi16>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<16> : vector<4xi32>} : () -> vector<4xi32> - %1 = "llvm.udiv"(%arg0, %0) : (vector<4xi32>, vector<4xi32>) -> vector<4xi32> - "llvm.return"(%1) : (vector<4xi32>) -> () - }) {linkage = 10 : i64, sym_name = "udiv_vec4x32", type = !llvm.func (vector<4xi32>)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @udiv_vec8x16(%arg0: vector<8xi16>) -> vector<8xi16> { + %0 = llvm.mlir.constant(dense<32> : vector<8xi16>) : vector<8xi16> + %1 = llvm.udiv %arg0, %0 : vector<8xi16> + llvm.return %1 : vector<8xi16> + } + llvm.func @udiv_vec4x32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<16> : vector<4xi32>) : vector<4xi32> + %1 = llvm.udiv %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/vector-casts-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/vector-casts-inseltpoison.ll.mlir new file mode 100644 index 000000000..5d0c0b04a --- /dev/null +++ b/test/LLVMDialect/InstCombine/vector-casts-inseltpoison.ll.mlir @@ -0,0 +1,251 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @trunc(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @and_cmp_is_trunc(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.and %arg0, %0 : vector<2xi64> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi64> + llvm.return %4 : vector<2xi1> + } + llvm.func @and_cmp_is_trunc_even_with_poison_elt(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.mlir.constant(0 : i64) : i64 + %8 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %9 = llvm.and %arg0, %6 : vector<2xi64> + %10 = llvm.icmp "ne" %9, %8 : vector<2xi64> + llvm.return %10 : vector<2xi1> + } + llvm.func @and_cmp_is_trunc_even_with_poison_elts(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.mlir.constant(0 : i64) : i64 + %8 = llvm.mlir.undef : vector<2xi64> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<2xi64> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %7, %10[%11 : i32] : vector<2xi64> + %13 = llvm.and %arg0, %6 : vector<2xi64> + %14 = llvm.icmp "ne" %13, %12 : vector<2xi64> + llvm.return %14 : vector<2xi1> + } + llvm.func @test2(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<65535> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<1> : vector<2xi64>) : vector<2xi64> + %2 = llvm.and %arg0, %0 : vector<2xi64> + %3 = llvm.ashr %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @test3(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fcmp "ord" %arg0, %1 : vector<4xf32> + %3 = llvm.sext %2 : vector<4xi1> to vector<4xi32> + %4 = llvm.fcmp "ord" %arg1, %1 : vector<4xf32> + %5 = llvm.sext %4 : vector<4xi1> to vector<4xi32> + %6 = llvm.and %3, %5 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @test4(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fcmp "uno" %arg0, %1 : vector<4xf32> + %3 = llvm.sext %2 : vector<4xi1> to vector<4xi32> + %4 = llvm.fcmp "uno" %arg1, %1 : vector<4xf32> + %5 = llvm.sext %4 : vector<4xi1> to vector<4xi32> + %6 = llvm.or %3, %5 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @test5(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fcmp "ult" %arg0, %1 : vector<4xf32> + %3 = llvm.sext %2 : vector<4xi1> to vector<4xi32> + %4 = llvm.fcmp "ult" %arg1, %1 : vector<4xf32> + %5 = llvm.sext %4 : vector<4xi1> to vector<4xi32> + %6 = llvm.and %3, %5 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @test6(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fcmp "ult" %arg0, %1 : vector<4xf32> + %3 = llvm.sext %2 : vector<4xi1> to vector<4xi32> + %4 = llvm.fcmp "ult" %arg1, %1 : vector<4xf32> + %5 = llvm.sext %4 : vector<4xi1> to vector<4xi32> + %6 = llvm.or %3, %5 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @test7(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fcmp "ult" %arg0, %1 : vector<4xf32> + %3 = llvm.sext %2 : vector<4xi1> to vector<4xi32> + %4 = llvm.fcmp "ult" %arg1, %1 : vector<4xf32> + %5 = llvm.sext %4 : vector<4xi1> to vector<4xi32> + %6 = llvm.xor %3, %5 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @convert(%arg0: !llvm.ptr, %arg1: vector<2xi64>) { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg1 : vector<2xi64> to vector<2xi32> + %2 = llvm.add %1, %0 : vector<2xi32> + llvm.store %2, %arg0 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + llvm.return + } + llvm.func @foo(%arg0: vector<2xi64>) -> vector<2xi65> { + %0 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %1 = llvm.zext %0 : vector<2xi32> to vector<2xi65> + llvm.return %1 : vector<2xi65> + } + llvm.func @bar(%arg0: vector<2xi65>) -> vector<2xi64> { + %0 = llvm.trunc %arg0 : vector<2xi65> to vector<2xi32> + %1 = llvm.zext %0 : vector<2xi32> to vector<2xi64> + llvm.return %1 : vector<2xi64> + } + llvm.func @bars(%arg0: vector<2xi65>) -> vector<2xi64> { + %0 = llvm.trunc %arg0 : vector<2xi65> to vector<2xi32> + %1 = llvm.sext %0 : vector<2xi32> to vector<2xi64> + llvm.return %1 : vector<2xi64> + } + llvm.func @quxs(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %1 = llvm.sext %0 : vector<2xi32> to vector<2xi64> + llvm.return %1 : vector<2xi64> + } + llvm.func @quxt(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi64>) : vector<2xi64> + %1 = llvm.shl %arg0, %0 : vector<2xi64> + %2 = llvm.ashr %1, %0 : vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @fa(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.fptrunc %arg0 : vector<2xf64> to vector<2xf32> + %1 = llvm.fpext %0 : vector<2xf32> to vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fb(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.fptoui %arg0 : vector<2xf64> to vector<2xi64> + %1 = llvm.uitofp %0 : vector<2xi64> to vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fc(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.fptosi %arg0 : vector<2xf64> to vector<2xi64> + %1 = llvm.sitofp %0 : vector<2xi64> to vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @f(%arg0: i32) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.mlir.zero : !llvm.ptr + %6 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %7 = llvm.mlir.undef : vector<4xi32> + %8 = llvm.mlir.undef : vector<4xf32> + %9 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi32> + %10 = llvm.insertelement %arg0, %9[%2 : i32] : vector<4xi32> + %11 = llvm.insertelement %arg0, %10[%3 : i32] : vector<4xi32> + %12 = llvm.insertelement %arg0, %11[%4 : i32] : vector<4xi32> + %13 = llvm.getelementptr %5[%2] : (!llvm.ptr, i32) -> !llvm.ptr, vector<4xf32> + %14 = llvm.ptrtoint %13 : !llvm.ptr to i64 + %15 = llvm.trunc %14 : i64 to i32 + %16 = llvm.insertelement %15, %0[%1 : i32] : vector<4xi32> + %17 = llvm.insertelement %15, %16[%2 : i32] : vector<4xi32> + %18 = llvm.insertelement %15, %17[%3 : i32] : vector<4xi32> + %19 = llvm.insertelement %15, %18[%4 : i32] : vector<4xi32> + %20 = llvm.mul %12, %19 : vector<4xi32> + %21 = llvm.add %6, %20 : vector<4xi32> + %22 = llvm.add %21, %7 : vector<4xi32> + llvm.return %8 : vector<4xf32> + } + llvm.func @pr24458(%arg0: vector<8xf32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fcmp "une" %arg0, %1 : vector<8xf32> + %3 = llvm.fcmp "ueq" %arg0, %1 : vector<8xf32> + %4 = llvm.sext %2 : vector<8xi1> to vector<8xi32> + %5 = llvm.sext %3 : vector<8xi1> to vector<8xi32> + %6 = llvm.or %4, %5 : vector<8xi32> + llvm.return %6 : vector<8xi32> + } + llvm.func @trunc_inselt_undef(%arg0: i32) -> vector<3xi16> { + %0 = llvm.mlir.poison : vector<3xi32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<3xi32> + %3 = llvm.trunc %2 : vector<3xi32> to vector<3xi16> + llvm.return %3 : vector<3xi16> + } + llvm.func @fptrunc_inselt_undef(%arg0: f64, %arg1: i32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.insertelement %arg0, %0[%arg1 : i32] : vector<2xf64> + %2 = llvm.fptrunc %1 : vector<2xf64> to vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @trunc_inselt1(%arg0: i32) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<[3, -2, 65536]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<3xi32> + %3 = llvm.trunc %2 : vector<3xi32> to vector<3xi16> + llvm.return %3 : vector<3xi16> + } + llvm.func @fptrunc_inselt1(%arg0: f64, %arg1: i32) -> vector<2xf32> { + %0 = llvm.mlir.constant(3.000000e+00 : f64) : f64 + %1 = llvm.mlir.undef : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.insertelement %arg0, %6[%arg1 : i32] : vector<2xf64> + %8 = llvm.fptrunc %7 : vector<2xf64> to vector<2xf32> + llvm.return %8 : vector<2xf32> + } + llvm.func @trunc_inselt2(%arg0: vector<8xi32>, %arg1: i32) -> vector<8xi16> { + %0 = llvm.mlir.constant(1048576 : i32) : i32 + %1 = llvm.insertelement %0, %arg0[%arg1 : i32] : vector<8xi32> + %2 = llvm.trunc %1 : vector<8xi32> to vector<8xi16> + llvm.return %2 : vector<8xi16> + } + llvm.func @fptrunc_inselt2(%arg0: vector<3xf64>) -> vector<3xf32> { + %0 = llvm.mlir.constant(4.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%1 : i32] : vector<3xf64> + %3 = llvm.fptrunc %2 : vector<3xf64> to vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @sext_less_casting_with_wideop(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %1 = llvm.trunc %arg1 : vector<2xi64> to vector<2xi32> + %2 = llvm.mul %0, %1 : vector<2xi32> + %3 = llvm.sext %2 : vector<2xi32> to vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @zext_less_casting_with_wideop(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %1 = llvm.trunc %arg1 : vector<2xi64> to vector<2xi32> + %2 = llvm.mul %0, %1 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + llvm.return %3 : vector<2xi64> + } +} diff --git a/test/LLVMDialect/InstCombine/vector-casts.ll.mlir b/test/LLVMDialect/InstCombine/vector-casts.ll.mlir new file mode 100644 index 000000000..6f553344a --- /dev/null +++ b/test/LLVMDialect/InstCombine/vector-casts.ll.mlir @@ -0,0 +1,318 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @trunc(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi1> + llvm.return %0 : vector<2xi1> + } + llvm.func @and_cmp_is_trunc(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %3 = llvm.and %arg0, %0 : vector<2xi64> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi64> + llvm.return %4 : vector<2xi1> + } + llvm.func @and_cmp_is_trunc_even_with_poison_elt(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.mlir.constant(0 : i64) : i64 + %8 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %9 = llvm.and %arg0, %6 : vector<2xi64> + %10 = llvm.icmp "ne" %9, %8 : vector<2xi64> + llvm.return %10 : vector<2xi1> + } + llvm.func @and_cmp_is_trunc_even_with_poison_elts(%arg0: vector<2xi64>) -> vector<2xi1> { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.mlir.constant(0 : i64) : i64 + %8 = llvm.mlir.undef : vector<2xi64> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<2xi64> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %7, %10[%11 : i32] : vector<2xi64> + %13 = llvm.and %arg0, %6 : vector<2xi64> + %14 = llvm.icmp "ne" %13, %12 : vector<2xi64> + llvm.return %14 : vector<2xi1> + } + llvm.func @test2(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<65535> : vector<2xi64>) : vector<2xi64> + %1 = llvm.mlir.constant(dense<1> : vector<2xi64>) : vector<2xi64> + %2 = llvm.and %arg0, %0 : vector<2xi64> + %3 = llvm.ashr %2, %1 : vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @test3(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fcmp "ord" %arg0, %1 : vector<4xf32> + %3 = llvm.sext %2 : vector<4xi1> to vector<4xi32> + %4 = llvm.fcmp "ord" %arg1, %1 : vector<4xf32> + %5 = llvm.sext %4 : vector<4xi1> to vector<4xi32> + %6 = llvm.and %3, %5 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @test4(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fcmp "uno" %arg0, %1 : vector<4xf32> + %3 = llvm.sext %2 : vector<4xi1> to vector<4xi32> + %4 = llvm.fcmp "uno" %arg1, %1 : vector<4xf32> + %5 = llvm.sext %4 : vector<4xi1> to vector<4xi32> + %6 = llvm.or %3, %5 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @test5(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fcmp "ult" %arg0, %1 : vector<4xf32> + %3 = llvm.sext %2 : vector<4xi1> to vector<4xi32> + %4 = llvm.fcmp "ult" %arg1, %1 : vector<4xf32> + %5 = llvm.sext %4 : vector<4xi1> to vector<4xi32> + %6 = llvm.and %3, %5 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @test6(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fcmp "ult" %arg0, %1 : vector<4xf32> + %3 = llvm.sext %2 : vector<4xi1> to vector<4xi32> + %4 = llvm.fcmp "ult" %arg1, %1 : vector<4xf32> + %5 = llvm.sext %4 : vector<4xi1> to vector<4xi32> + %6 = llvm.or %3, %5 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @test7(%arg0: vector<4xf32>, %arg1: vector<4xf32>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf32>) : vector<4xf32> + %2 = llvm.fcmp "ult" %arg0, %1 : vector<4xf32> + %3 = llvm.sext %2 : vector<4xi1> to vector<4xi32> + %4 = llvm.fcmp "ult" %arg1, %1 : vector<4xf32> + %5 = llvm.sext %4 : vector<4xi1> to vector<4xi32> + %6 = llvm.xor %3, %5 : vector<4xi32> + %7 = llvm.bitcast %6 : vector<4xi32> to vector<2xi64> + llvm.return %7 : vector<2xi64> + } + llvm.func @convert(%arg0: !llvm.ptr, %arg1: vector<2xi64>) { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg1 : vector<2xi64> to vector<2xi32> + %2 = llvm.add %1, %0 : vector<2xi32> + llvm.store %2, %arg0 {alignment = 8 : i64} : vector<2xi32>, !llvm.ptr + llvm.return + } + llvm.func @foo(%arg0: vector<2xi64>) -> vector<2xi65> { + %0 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %1 = llvm.zext %0 : vector<2xi32> to vector<2xi65> + llvm.return %1 : vector<2xi65> + } + llvm.func @bar(%arg0: vector<2xi65>) -> vector<2xi64> { + %0 = llvm.trunc %arg0 : vector<2xi65> to vector<2xi32> + %1 = llvm.zext %0 : vector<2xi32> to vector<2xi64> + llvm.return %1 : vector<2xi64> + } + llvm.func @bars(%arg0: vector<2xi65>) -> vector<2xi64> { + %0 = llvm.trunc %arg0 : vector<2xi65> to vector<2xi32> + %1 = llvm.sext %0 : vector<2xi32> to vector<2xi64> + llvm.return %1 : vector<2xi64> + } + llvm.func @quxs(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %1 = llvm.sext %0 : vector<2xi32> to vector<2xi64> + llvm.return %1 : vector<2xi64> + } + llvm.func @quxt(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<32> : vector<2xi64>) : vector<2xi64> + %1 = llvm.shl %arg0, %0 : vector<2xi64> + %2 = llvm.ashr %1, %0 : vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @fa(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.fptrunc %arg0 : vector<2xf64> to vector<2xf32> + %1 = llvm.fpext %0 : vector<2xf32> to vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fb(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.fptoui %arg0 : vector<2xf64> to vector<2xi64> + %1 = llvm.uitofp %0 : vector<2xi64> to vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @fc(%arg0: vector<2xf64>) -> vector<2xf64> { + %0 = llvm.fptosi %arg0 : vector<2xf64> to vector<2xi64> + %1 = llvm.sitofp %0 : vector<2xi64> to vector<2xf64> + llvm.return %1 : vector<2xf64> + } + llvm.func @f(%arg0: i32) -> vector<4xf32> { + %0 = llvm.mlir.undef : vector<4xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.mlir.zero : !llvm.ptr + %6 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %7 = llvm.mlir.undef : vector<4xf32> + %8 = llvm.insertelement %arg0, %0[%1 : i32] : vector<4xi32> + %9 = llvm.insertelement %arg0, %8[%2 : i32] : vector<4xi32> + %10 = llvm.insertelement %arg0, %9[%3 : i32] : vector<4xi32> + %11 = llvm.insertelement %arg0, %10[%4 : i32] : vector<4xi32> + %12 = llvm.getelementptr %5[%2] : (!llvm.ptr, i32) -> !llvm.ptr, vector<4xf32> + %13 = llvm.ptrtoint %12 : !llvm.ptr to i64 + %14 = llvm.trunc %13 : i64 to i32 + %15 = llvm.insertelement %14, %0[%1 : i32] : vector<4xi32> + %16 = llvm.insertelement %14, %15[%2 : i32] : vector<4xi32> + %17 = llvm.insertelement %14, %16[%3 : i32] : vector<4xi32> + %18 = llvm.insertelement %14, %17[%4 : i32] : vector<4xi32> + %19 = llvm.mul %11, %18 : vector<4xi32> + %20 = llvm.add %6, %19 : vector<4xi32> + %21 = llvm.add %20, %0 : vector<4xi32> + llvm.return %7 : vector<4xf32> + } + llvm.func @pr24458(%arg0: vector<8xf32>) -> vector<8xi32> { + %0 = llvm.mlir.constant(0.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(dense<0.000000e+00> : vector<8xf32>) : vector<8xf32> + %2 = llvm.fcmp "une" %arg0, %1 : vector<8xf32> + %3 = llvm.fcmp "ueq" %arg0, %1 : vector<8xf32> + %4 = llvm.sext %2 : vector<8xi1> to vector<8xi32> + %5 = llvm.sext %3 : vector<8xi1> to vector<8xi32> + %6 = llvm.or %4, %5 : vector<8xi32> + llvm.return %6 : vector<8xi32> + } + llvm.func @trunc_inselt_undef(%arg0: i32) -> vector<3xi16> { + %0 = llvm.mlir.undef : vector<3xi32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<3xi32> + %3 = llvm.trunc %2 : vector<3xi32> to vector<3xi16> + llvm.return %3 : vector<3xi16> + } + llvm.func @fptrunc_inselt_undef(%arg0: f64, %arg1: i32) -> vector<2xf32> { + %0 = llvm.mlir.undef : vector<2xf64> + %1 = llvm.insertelement %arg0, %0[%arg1 : i32] : vector<2xf64> + %2 = llvm.fptrunc %1 : vector<2xf64> to vector<2xf32> + llvm.return %2 : vector<2xf32> + } + llvm.func @trunc_inselt1(%arg0: i32) -> vector<3xi16> { + %0 = llvm.mlir.constant(dense<[3, -2, 65536]> : vector<3xi32>) : vector<3xi32> + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : vector<3xi32> + %3 = llvm.trunc %2 : vector<3xi32> to vector<3xi16> + llvm.return %3 : vector<3xi16> + } + llvm.func @fptrunc_inselt1(%arg0: f64, %arg1: i32) -> vector<2xf32> { + %0 = llvm.mlir.constant(3.000000e+00 : f64) : f64 + %1 = llvm.mlir.undef : f64 + %2 = llvm.mlir.undef : vector<2xf64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xf64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xf64> + %7 = llvm.insertelement %arg0, %6[%arg1 : i32] : vector<2xf64> + %8 = llvm.fptrunc %7 : vector<2xf64> to vector<2xf32> + llvm.return %8 : vector<2xf32> + } + llvm.func @trunc_inselt2(%arg0: vector<8xi32>, %arg1: i32) -> vector<8xi16> { + %0 = llvm.mlir.constant(1048576 : i32) : i32 + %1 = llvm.insertelement %0, %arg0[%arg1 : i32] : vector<8xi32> + %2 = llvm.trunc %1 : vector<8xi32> to vector<8xi16> + llvm.return %2 : vector<8xi16> + } + llvm.func @fptrunc_inselt2(%arg0: vector<3xf64>) -> vector<3xf32> { + %0 = llvm.mlir.constant(4.000000e+00 : f64) : f64 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%1 : i32] : vector<3xf64> + %3 = llvm.fptrunc %2 : vector<3xf64> to vector<3xf32> + llvm.return %3 : vector<3xf32> + } + llvm.func @sext_less_casting_with_wideop(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %1 = llvm.trunc %arg1 : vector<2xi64> to vector<2xi32> + %2 = llvm.mul %0, %1 : vector<2xi32> + %3 = llvm.sext %2 : vector<2xi32> to vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @zext_less_casting_with_wideop(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %1 = llvm.trunc %arg1 : vector<2xi64> to vector<2xi32> + %2 = llvm.mul %0, %1 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @sitofp_shuf(%arg0: vector<4xi32>) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [1, 2, 3, -1] : vector<4xi32> + %2 = llvm.sitofp %1 : vector<4xi32> to vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @uitofp_shuf(%arg0: vector<3xi16>) -> vector<3xf16> { + %0 = llvm.mlir.poison : vector<3xi16> + %1 = llvm.shufflevector %arg0, %0 [2, -1, 0] : vector<3xi16> + %2 = llvm.uitofp %1 : vector<3xi16> to vector<3xf16> + llvm.return %2 : vector<3xf16> + } + llvm.func @fptosi_shuf(%arg0: vector<4xf64>) -> vector<4xi64> { + %0 = llvm.mlir.poison : vector<4xf64> + %1 = llvm.shufflevector %arg0, %0 [-1, 2, 3, -1] : vector<4xf64> + %2 = llvm.fptosi %1 : vector<4xf64> to vector<4xi64> + llvm.return %2 : vector<4xi64> + } + llvm.func @fptoui_shuf(%arg0: vector<2xf32>) -> vector<2xi32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.shufflevector %arg0, %0 [1, 1] : vector<2xf32> + %2 = llvm.fptoui %1 : vector<2xf32> to vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @narrowing_sitofp_shuf(%arg0: vector<4xi32>) -> vector<4xf16> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [1, 2, 3, -1] : vector<4xi32> + %2 = llvm.sitofp %1 : vector<4xi32> to vector<4xf16> + llvm.return %2 : vector<4xf16> + } + llvm.func @widening_uitofp_shuf(%arg0: vector<4xi32>) -> vector<4xf64> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [1, 2, 3, -1] : vector<4xi32> + %2 = llvm.uitofp %1 : vector<4xi32> to vector<4xf64> + llvm.return %2 : vector<4xf64> + } + llvm.func @fptosi_narrowing_shuf(%arg0: vector<4xf64>) -> vector<3xi64> { + %0 = llvm.mlir.poison : vector<4xf64> + %1 = llvm.shufflevector %arg0, %0 [-1, 2, 3] : vector<4xf64> + %2 = llvm.fptosi %1 : vector<3xf64> to vector<3xi64> + llvm.return %2 : vector<3xi64> + } + llvm.func @fptoui_widening_shuf(%arg0: vector<2xf32>) -> vector<3xi32> { + %0 = llvm.mlir.poison : vector<2xf32> + %1 = llvm.shufflevector %arg0, %0 [1, 1, 0] : vector<2xf32> + %2 = llvm.fptoui %1 : vector<3xf32> to vector<3xi32> + llvm.return %2 : vector<3xi32> + } + llvm.func @narrowing_sitofp_widening_shuf(%arg0: vector<2xi32>) -> vector<4xf16> { + %0 = llvm.mlir.poison : vector<2xi32> + %1 = llvm.shufflevector %arg0, %0 [1, 0, 0, -1] : vector<2xi32> + %2 = llvm.sitofp %1 : vector<4xi32> to vector<4xf16> + llvm.return %2 : vector<4xf16> + } + llvm.func @use(vector<4xi32>) + llvm.func @sitofp_shuf_extra_use(%arg0: vector<4xi32>) -> vector<4xf32> { + %0 = llvm.mlir.poison : vector<4xi32> + %1 = llvm.shufflevector %arg0, %0 [1, 2, 3, -1] : vector<4xi32> + llvm.call @use(%1) : (vector<4xi32>) -> () + %2 = llvm.sitofp %1 : vector<4xi32> to vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @sitofp_shuf_scalable(%arg0: !llvm.vec) -> !llvm.vec { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.shufflevector %arg0, %0 [0, 0, 0, 0] : !llvm.vec + %2 = llvm.sitofp %1 : vector<[4]xi32> to !llvm.vec + llvm.return %2 : !llvm.vec + } +} diff --git a/test/LLVMDialect/InstCombine/vector-concat-binop-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/vector-concat-binop-inseltpoison.ll.mlir new file mode 100644 index 000000000..0bdefc5f4 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vector-concat-binop-inseltpoison.ll.mlir @@ -0,0 +1,124 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @add(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xi8> + %2 = llvm.and %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @sub(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xi8> + %2 = llvm.sub %0, %1 overflow : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @mul(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xi8> + %2 = llvm.mul %0, %1 overflow : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @and(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [-1, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xi8> + %2 = llvm.and %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @or(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, -1, 2, 3] : vector<2xi8> + %2 = llvm.or %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @xor(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, -1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, -1, 3] : vector<2xi8> + %2 = llvm.xor %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @shl(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, -1, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, -1, 3] : vector<2xi8> + %2 = llvm.shl %0, %1 overflow : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @lshr(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, -1, -1, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, -1, -1, 3] : vector<2xi8> + %2 = llvm.lshr %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @use(vector<4xi8>) + llvm.func @ashr(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xi8> + llvm.call @use(%0) : (vector<4xi8>) -> () + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xi8> + %2 = llvm.ashr %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @sdiv(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, -1, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, -1, 3] : vector<2xi8> + %2 = llvm.sdiv %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @srem(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xi8> + %2 = llvm.srem %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @udiv(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xi8> + %2 = llvm.udiv %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @urem(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [-1, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [-1, 1, 2, 3] : vector<2xi8> + %2 = llvm.urem %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @fadd(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>, %arg3: vector<2xf32>) -> vector<4xf32> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xf32> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xf32> + %2 = llvm.fadd %0, %1 : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @fsub(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>, %arg3: vector<2xf32>) -> vector<4xf32> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, -1, 3] : vector<2xf32> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, -1, 3] : vector<2xf32> + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @use2(vector<4xf32>) + llvm.func @fmul(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>, %arg3: vector<2xf32>) -> vector<4xf32> { + %0 = llvm.shufflevector %arg0, %arg1 [-1, 1, -1, 3] : vector<2xf32> + %1 = llvm.shufflevector %arg2, %arg3 [-1, 1, -1, 3] : vector<2xf32> + llvm.call @use2(%1) : (vector<4xf32>) -> () + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @fdiv(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>, %arg3: vector<2xf32>) -> vector<4xf32> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xf32> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xf32> + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @frem(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>, %arg3: vector<2xf32>) -> vector<4xf32> { + %0 = llvm.shufflevector %arg0, %arg1 [0, -1, 2, 3] : vector<2xf32> + %1 = llvm.shufflevector %arg2, %arg3 [0, -1, 2, 3] : vector<2xf32> + %2 = llvm.frem %0, %1 : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @PR33026(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi32>, %arg3: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.poison : vector<8xi32> + %1 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3, 4, 5, 6, 7] : vector<4xi32> + %2 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3, 4, 5, 6, 7] : vector<4xi32> + %3 = llvm.and %1, %2 : vector<8xi32> + %4 = llvm.shufflevector %3, %0 [0, 1, 2, 3] : vector<8xi32> + %5 = llvm.shufflevector %3, %0 [4, 5, 6, 7] : vector<8xi32> + %6 = llvm.sub %4, %5 : vector<4xi32> + llvm.return %6 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/vector-concat-binop.ll.mlir b/test/LLVMDialect/InstCombine/vector-concat-binop.ll.mlir new file mode 100644 index 000000000..1d6720f4a --- /dev/null +++ b/test/LLVMDialect/InstCombine/vector-concat-binop.ll.mlir @@ -0,0 +1,124 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @add(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xi8> + %2 = llvm.and %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @sub(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xi8> + %2 = llvm.sub %0, %1 overflow : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @mul(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xi8> + %2 = llvm.mul %0, %1 overflow : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @and(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [-1, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xi8> + %2 = llvm.and %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @or(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, -1, 2, 3] : vector<2xi8> + %2 = llvm.or %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @xor(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, -1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, -1, 3] : vector<2xi8> + %2 = llvm.xor %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @shl(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, -1, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, -1, 3] : vector<2xi8> + %2 = llvm.shl %0, %1 overflow : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @lshr(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, -1, -1, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, -1, -1, 3] : vector<2xi8> + %2 = llvm.lshr %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @use(vector<4xi8>) + llvm.func @ashr(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xi8> + llvm.call @use(%0) : (vector<4xi8>) -> () + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xi8> + %2 = llvm.ashr %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @sdiv(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, -1, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, -1, 3] : vector<2xi8> + %2 = llvm.sdiv %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @srem(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xi8> + %2 = llvm.srem %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @udiv(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xi8> + %2 = llvm.udiv %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @urem(%arg0: vector<2xi8>, %arg1: vector<2xi8>, %arg2: vector<2xi8>, %arg3: vector<2xi8>) -> vector<4xi8> { + %0 = llvm.shufflevector %arg0, %arg1 [-1, 1, 2, 3] : vector<2xi8> + %1 = llvm.shufflevector %arg2, %arg3 [-1, 1, 2, 3] : vector<2xi8> + %2 = llvm.urem %0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @fadd(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>, %arg3: vector<2xf32>) -> vector<4xf32> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xf32> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xf32> + %2 = llvm.fadd %0, %1 : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @fsub(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>, %arg3: vector<2xf32>) -> vector<4xf32> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, -1, 3] : vector<2xf32> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, -1, 3] : vector<2xf32> + %2 = llvm.fsub %0, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @use2(vector<4xf32>) + llvm.func @fmul(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>, %arg3: vector<2xf32>) -> vector<4xf32> { + %0 = llvm.shufflevector %arg0, %arg1 [-1, 1, -1, 3] : vector<2xf32> + %1 = llvm.shufflevector %arg2, %arg3 [-1, 1, -1, 3] : vector<2xf32> + llvm.call @use2(%1) : (vector<4xf32>) -> () + %2 = llvm.fmul %0, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @fdiv(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>, %arg3: vector<2xf32>) -> vector<4xf32> { + %0 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3] : vector<2xf32> + %1 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3] : vector<2xf32> + %2 = llvm.fdiv %0, %1 {fastmathFlags = #llvm.fastmath} : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @frem(%arg0: vector<2xf32>, %arg1: vector<2xf32>, %arg2: vector<2xf32>, %arg3: vector<2xf32>) -> vector<4xf32> { + %0 = llvm.shufflevector %arg0, %arg1 [0, -1, 2, 3] : vector<2xf32> + %1 = llvm.shufflevector %arg2, %arg3 [0, -1, 2, 3] : vector<2xf32> + %2 = llvm.frem %0, %1 : vector<4xf32> + llvm.return %2 : vector<4xf32> + } + llvm.func @PR33026(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi32>, %arg3: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.undef : vector<8xi32> + %1 = llvm.shufflevector %arg0, %arg1 [0, 1, 2, 3, 4, 5, 6, 7] : vector<4xi32> + %2 = llvm.shufflevector %arg2, %arg3 [0, 1, 2, 3, 4, 5, 6, 7] : vector<4xi32> + %3 = llvm.and %1, %2 : vector<8xi32> + %4 = llvm.shufflevector %3, %0 [0, 1, 2, 3] : vector<8xi32> + %5 = llvm.shufflevector %3, %0 [4, 5, 6, 7] : vector<8xi32> + %6 = llvm.sub %4, %5 : vector<4xi32> + llvm.return %6 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/vector-logical-reductions.ll.mlir b/test/LLVMDialect/InstCombine/vector-logical-reductions.ll.mlir index 821169f9e..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/vector-logical-reductions.ll.mlir +++ b/test/LLVMDialect/InstCombine/vector-logical-reductions.ll.mlir @@ -1,17 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi1>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.vector.reduce.or.v4i1, fastmathFlags = #llvm.fastmath<>} : (vector<4xi1>) -> i1 - "llvm.return"(%0) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "reduction_logical_or", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi1>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.vector.reduce.and.v4i1, fastmathFlags = #llvm.fastmath<>} : (vector<4xi1>) -> i1 - "llvm.return"(%0) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "reduction_logical_and", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.reduce.or.v4i1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.reduce.and.v4i1", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/vector-mul.ll.mlir b/test/LLVMDialect/InstCombine/vector-mul.ll.mlir new file mode 100644 index 000000000..79856ff63 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vector-mul.ll.mlir @@ -0,0 +1,214 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @Zero_i8(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mul %arg0, %1 : vector<4xi8> + llvm.return %2 : vector<4xi8> + } + llvm.func @Identity_i8(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mul %arg0, %0 : vector<4xi8> + llvm.return %1 : vector<4xi8> + } + llvm.func @AddToSelf_i8(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<2> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mul %arg0, %0 : vector<4xi8> + llvm.return %1 : vector<4xi8> + } + llvm.func @SplatPow2Test1_i8(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<4> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mul %arg0, %0 : vector<4xi8> + llvm.return %1 : vector<4xi8> + } + llvm.func @SplatPow2Test2_i8(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mul %arg0, %0 : vector<4xi8> + llvm.return %1 : vector<4xi8> + } + llvm.func @MulTest1_i8(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<[1, 2, 4, 8]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mul %arg0, %0 : vector<4xi8> + llvm.return %1 : vector<4xi8> + } + llvm.func @MulTest2_i8(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mul %arg0, %0 : vector<4xi8> + llvm.return %1 : vector<4xi8> + } + llvm.func @MulTest3_i8(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<[4, 4, 2, 2]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mul %arg0, %0 : vector<4xi8> + llvm.return %1 : vector<4xi8> + } + llvm.func @MulTest4_i8(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<[4, 4, 0, 1]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mul %arg0, %0 : vector<4xi8> + llvm.return %1 : vector<4xi8> + } + llvm.func @Zero_i16(%arg0: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : vector<4xi16>) : vector<4xi16> + %2 = llvm.mul %arg0, %1 : vector<4xi16> + llvm.return %2 : vector<4xi16> + } + llvm.func @Identity_i16(%arg0: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(dense<1> : vector<4xi16>) : vector<4xi16> + %1 = llvm.mul %arg0, %0 : vector<4xi16> + llvm.return %1 : vector<4xi16> + } + llvm.func @AddToSelf_i16(%arg0: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(dense<2> : vector<4xi16>) : vector<4xi16> + %1 = llvm.mul %arg0, %0 : vector<4xi16> + llvm.return %1 : vector<4xi16> + } + llvm.func @SplatPow2Test1_i16(%arg0: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(dense<4> : vector<4xi16>) : vector<4xi16> + %1 = llvm.mul %arg0, %0 : vector<4xi16> + llvm.return %1 : vector<4xi16> + } + llvm.func @SplatPow2Test2_i16(%arg0: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi16>) : vector<4xi16> + %1 = llvm.mul %arg0, %0 : vector<4xi16> + llvm.return %1 : vector<4xi16> + } + llvm.func @MulTest1_i16(%arg0: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(dense<[1, 2, 4, 8]> : vector<4xi16>) : vector<4xi16> + %1 = llvm.mul %arg0, %0 : vector<4xi16> + llvm.return %1 : vector<4xi16> + } + llvm.func @MulTest2_i16(%arg0: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi16>) : vector<4xi16> + %1 = llvm.mul %arg0, %0 : vector<4xi16> + llvm.return %1 : vector<4xi16> + } + llvm.func @MulTest3_i16(%arg0: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(dense<[4, 4, 2, 2]> : vector<4xi16>) : vector<4xi16> + %1 = llvm.mul %arg0, %0 : vector<4xi16> + llvm.return %1 : vector<4xi16> + } + llvm.func @MulTest4_i16(%arg0: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(dense<[4, 4, 0, 2]> : vector<4xi16>) : vector<4xi16> + %1 = llvm.mul %arg0, %0 : vector<4xi16> + llvm.return %1 : vector<4xi16> + } + llvm.func @Zero_i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : vector<4xi32>) : vector<4xi32> + %2 = llvm.mul %arg0, %1 : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @Identity_i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mul %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @AddToSelf_i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mul %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @SplatPow2Test1_i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mul %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @SplatPow2Test2_i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mul %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @MulTest1_i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 4, 8]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mul %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @MulTest2_i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mul %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @MulTest3_i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[4, 4, 2, 2]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mul %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @MulTest4_i32(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[4, 4, 0, 1]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mul %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @Zero_i64(%arg0: vector<4xi64>) -> vector<4xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<4xi64>) : vector<4xi64> + %2 = llvm.mul %arg0, %1 : vector<4xi64> + llvm.return %2 : vector<4xi64> + } + llvm.func @Identity_i64(%arg0: vector<4xi64>) -> vector<4xi64> { + %0 = llvm.mlir.constant(dense<1> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mul %arg0, %0 : vector<4xi64> + llvm.return %1 : vector<4xi64> + } + llvm.func @AddToSelf_i64(%arg0: vector<4xi64>) -> vector<4xi64> { + %0 = llvm.mlir.constant(dense<2> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mul %arg0, %0 : vector<4xi64> + llvm.return %1 : vector<4xi64> + } + llvm.func @SplatPow2Test1_i64(%arg0: vector<4xi64>) -> vector<4xi64> { + %0 = llvm.mlir.constant(dense<4> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mul %arg0, %0 : vector<4xi64> + llvm.return %1 : vector<4xi64> + } + llvm.func @SplatPow2Test2_i64(%arg0: vector<4xi64>) -> vector<4xi64> { + %0 = llvm.mlir.constant(dense<8> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mul %arg0, %0 : vector<4xi64> + llvm.return %1 : vector<4xi64> + } + llvm.func @MulTest1_i64(%arg0: vector<4xi64>) -> vector<4xi64> { + %0 = llvm.mlir.constant(dense<[1, 2, 4, 8]> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mul %arg0, %0 : vector<4xi64> + llvm.return %1 : vector<4xi64> + } + llvm.func @MulTest2_i64(%arg0: vector<4xi64>) -> vector<4xi64> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mul %arg0, %0 : vector<4xi64> + llvm.return %1 : vector<4xi64> + } + llvm.func @MulTest3_i64(%arg0: vector<4xi64>) -> vector<4xi64> { + %0 = llvm.mlir.constant(dense<[4, 4, 2, 2]> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mul %arg0, %0 : vector<4xi64> + llvm.return %1 : vector<4xi64> + } + llvm.func @MulTest4_i64(%arg0: vector<4xi64>) -> vector<4xi64> { + %0 = llvm.mlir.constant(dense<[4, 4, 0, 1]> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mul %arg0, %0 : vector<4xi64> + llvm.return %1 : vector<4xi64> + } + llvm.func @ShiftMulTest1(%arg0: vector<4xi8>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<2> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<3> : vector<4xi8>) : vector<4xi8> + %2 = llvm.shl %arg0, %0 : vector<4xi8> + %3 = llvm.mul %2, %1 : vector<4xi8> + llvm.return %3 : vector<4xi8> + } + llvm.func @ShiftMulTest2(%arg0: vector<4xi16>) -> vector<4xi16> { + %0 = llvm.mlir.constant(dense<2> : vector<4xi16>) : vector<4xi16> + %1 = llvm.mlir.constant(dense<3> : vector<4xi16>) : vector<4xi16> + %2 = llvm.shl %arg0, %0 : vector<4xi16> + %3 = llvm.mul %2, %1 : vector<4xi16> + llvm.return %3 : vector<4xi16> + } + llvm.func @ShiftMulTest3(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<3> : vector<4xi32>) : vector<4xi32> + %2 = llvm.shl %arg0, %0 : vector<4xi32> + %3 = llvm.mul %2, %1 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @ShiftMulTest4(%arg0: vector<4xi64>) -> vector<4xi64> { + %0 = llvm.mlir.constant(dense<2> : vector<4xi64>) : vector<4xi64> + %1 = llvm.mlir.constant(dense<3> : vector<4xi64>) : vector<4xi64> + %2 = llvm.shl %arg0, %0 : vector<4xi64> + %3 = llvm.mul %2, %1 : vector<4xi64> + llvm.return %3 : vector<4xi64> + } +} diff --git a/test/LLVMDialect/InstCombine/vector-reduce-min-max-known.ll.mlir b/test/LLVMDialect/InstCombine/vector-reduce-min-max-known.ll.mlir new file mode 100644 index 000000000..0dcb4911f --- /dev/null +++ b/test/LLVMDialect/InstCombine/vector-reduce-min-max-known.ll.mlir @@ -0,0 +1,186 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @vec_reduce_umax_non_zero(%arg0: vector<4xi8>) -> i1 { + %0 = llvm.mlir.constant(dense<[0, 1, 0, 0]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : vector<4xi8> + %3 = "llvm.intr.vector.reduce.umax"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @vec_reduce_umax_non_zero_fail(%arg0: vector<4xi8>) -> i1 { + %0 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : vector<4xi8> + %3 = "llvm.intr.vector.reduce.umax"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @vec_reduce_umin_non_zero(%arg0: vector<4xi8>) -> i1 { + %0 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : vector<4xi8> + %3 = "llvm.intr.vector.reduce.umin"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @vec_reduce_umin_non_zero_fail(%arg0: vector<4xi8>) -> i1 { + %0 = llvm.mlir.constant(dense<[0, 1, 1, 1]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : vector<4xi8> + %3 = "llvm.intr.vector.reduce.umin"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @vec_reduce_smax_non_zero0(%arg0: vector<4xi8>) -> i1 { + %0 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : vector<4xi8> + %3 = "llvm.intr.vector.reduce.smax"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @vec_reduce_smax_non_zero1(%arg0: vector<4xi8>) -> i1 { + %0 = llvm.mlir.constant(dense<[127, -1, -1, -1]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<[1, 0, 0, 0]> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.and %arg0, %0 : vector<4xi8> + %4 = llvm.or %3, %1 : vector<4xi8> + %5 = "llvm.intr.vector.reduce.smax"(%4) : (vector<4xi8>) -> i8 + %6 = llvm.icmp "eq" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @vec_reduce_smax_non_zero_fail(%arg0: vector<4xi8>) -> i1 { + %0 = llvm.mlir.constant(dense<[127, -1, -1, -1]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<[1, 0, 0, 0]> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.and %arg0, %0 : vector<4xi8> + %4 = llvm.add %3, %1 overflow : vector<4xi8> + %5 = "llvm.intr.vector.reduce.smax"(%4) : (vector<4xi8>) -> i8 + %6 = llvm.icmp "eq" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @vec_reduce_smin_non_zero0(%arg0: vector<4xi8>) -> i1 { + %0 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.add %arg0, %0 overflow : vector<4xi8> + %3 = "llvm.intr.vector.reduce.smin"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @vec_reduce_smin_non_zero1(%arg0: vector<4xi8>) -> i1 { + %0 = llvm.mlir.constant(dense<[0, 0, 0, -128]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.or %arg0, %0 : vector<4xi8> + %3 = "llvm.intr.vector.reduce.smin"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + llvm.return %4 : i1 + } + llvm.func @vec_reduce_smin_non_zero_fail(%arg0: vector<4xi8>) -> i1 { + %0 = llvm.mlir.constant(dense<[0, 0, 0, -128]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<[0, 0, 0, 1]> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(0 : i8) : i8 + %3 = llvm.or %arg0, %0 : vector<4xi8> + %4 = llvm.add %3, %1 : vector<4xi8> + %5 = "llvm.intr.vector.reduce.smin"(%4) : (vector<4xi8>) -> i8 + %6 = llvm.icmp "eq" %5, %2 : i8 + llvm.return %6 : i1 + } + llvm.func @vec_reduce_umax_known0(%arg0: vector<4xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.or %arg0, %0 : vector<4xi8> + %3 = "llvm.intr.vector.reduce.umax"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @vec_reduce_umax_known1(%arg0: vector<4xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<[1, 1, 1, -128]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.or %arg0, %0 : vector<4xi8> + %3 = "llvm.intr.vector.reduce.umax"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @vec_reduce_umax_known_fail0(%arg0: vector<4xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<[1, 1, 1, -128]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.or %arg0, %0 : vector<4xi8> + %3 = "llvm.intr.vector.reduce.umax"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @vec_reduce_umax_known_fail1(%arg0: vector<4xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<[1, 2, 4, 8]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.or %arg0, %0 : vector<4xi8> + %3 = "llvm.intr.vector.reduce.umax"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @vec_reduce_umin_known0(%arg0: vector<4xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.or %arg0, %0 : vector<4xi8> + %3 = "llvm.intr.vector.reduce.umin"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @vec_reduce_umin_known1(%arg0: vector<4xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<[127, -1, -1, -1]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.and %arg0, %0 : vector<4xi8> + %3 = "llvm.intr.vector.reduce.umin"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @vec_reduce_umin_known_fail0(%arg0: vector<4xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<[127, -1, -1, -1]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<[1, 0, 0, 0]> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.and %arg0, %0 : vector<4xi8> + %4 = llvm.or %arg0, %1 : vector<4xi8> + %5 = "llvm.intr.vector.reduce.umin"(%4) : (vector<4xi8>) -> i8 + %6 = llvm.and %5, %2 : i8 + llvm.return %6 : i8 + } + llvm.func @vec_reduce_umin_known_fail1(%arg0: vector<4xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<[1, 2, 4, 8]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(1 : i8) : i8 + %2 = llvm.or %arg0, %0 : vector<4xi8> + %3 = "llvm.intr.vector.reduce.umin"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @vec_reduce_smax_known(%arg0: vector<4xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<[4, 4, 4, 5]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.or %arg0, %0 : vector<4xi8> + %3 = "llvm.intr.vector.reduce.smax"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @vec_reduce_smax_known_fail(%arg0: vector<4xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<[4, 4, 8, 5]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.or %arg0, %0 : vector<4xi8> + %3 = "llvm.intr.vector.reduce.umax"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @vec_reduce_smin_known(%arg0: vector<4xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<[8, 24, 56, 9]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(8 : i8) : i8 + %2 = llvm.or %arg0, %0 : vector<4xi8> + %3 = "llvm.intr.vector.reduce.smin"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @vec_reduce_smin_known_fail(%arg0: vector<4xi8>) -> i8 { + %0 = llvm.mlir.constant(dense<[8, 23, 56, 9]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(8 : i8) : i8 + %2 = llvm.or %arg0, %0 : vector<4xi8> + %3 = "llvm.intr.vector.reduce.smin"(%2) : (vector<4xi8>) -> i8 + %4 = llvm.and %3, %1 : i8 + llvm.return %4 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/vector-reductions.ll.mlir b/test/LLVMDialect/InstCombine/vector-reductions.ll.mlir index 98ffbc667..e69de29bb 100644 --- a/test/LLVMDialect/InstCombine/vector-reductions.ll.mlir +++ b/test/LLVMDialect/InstCombine/vector-reductions.ll.mlir @@ -1,82 +0,0 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use_f32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.reduce.add.v4i32", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.reduce.add.v8i32", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: vector<4xf32>, %arg2: f32, %arg3: vector<4xf32>): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.vector.reduce.fadd.v4f32, fastmathFlags = #llvm.fastmath<>} : (f32, vector<4xf32>) -> f32 - %1 = "llvm.call"(%arg2, %arg3) {callee = @llvm.vector.reduce.fadd.v4f32, fastmathFlags = #llvm.fastmath<>} : (f32, vector<4xf32>) -> f32 - %2 = "llvm.fsub"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "diff_of_sums_v4f32", type = !llvm.func, f32, vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: vector<4xf32>, %arg2: f32, %arg3: vector<4xf32>): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.vector.reduce.fadd.v4f32, fastmathFlags = #llvm.fastmath<>} : (f32, vector<4xf32>) -> f32 - %1 = "llvm.call"(%arg2, %arg3) {callee = @llvm.vector.reduce.fadd.v4f32, fastmathFlags = #llvm.fastmath<>} : (f32, vector<4xf32>) -> f32 - %2 = "llvm.fsub"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "diff_of_sums_v4f32_fmf", type = !llvm.func, f32, vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: vector<4xf32>, %arg2: f32, %arg3: vector<4xf32>): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.vector.reduce.fadd.v4f32, fastmathFlags = #llvm.fastmath<>} : (f32, vector<4xf32>) -> f32 - "llvm.call"(%0) {callee = @use_f32, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - %1 = "llvm.call"(%arg2, %arg3) {callee = @llvm.vector.reduce.fadd.v4f32, fastmathFlags = #llvm.fastmath<>} : (f32, vector<4xf32>) -> f32 - %2 = "llvm.fsub"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "diff_of_sums_extra_use1", type = !llvm.func, f32, vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: vector<4xf32>, %arg2: f32, %arg3: vector<4xf32>): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.vector.reduce.fadd.v4f32, fastmathFlags = #llvm.fastmath<>} : (f32, vector<4xf32>) -> f32 - %1 = "llvm.call"(%arg2, %arg3) {callee = @llvm.vector.reduce.fadd.v4f32, fastmathFlags = #llvm.fastmath<>} : (f32, vector<4xf32>) -> f32 - "llvm.call"(%1) {callee = @use_f32, fastmathFlags = #llvm.fastmath<>} : (f32) -> () - %2 = "llvm.fsub"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "diff_of_sums_extra_use2", type = !llvm.func, f32, vector<4xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: vector<4xf32>, %arg2: f32, %arg3: vector<8xf32>): // no predecessors - %0 = "llvm.call"(%arg0, %arg1) {callee = @llvm.vector.reduce.fadd.v4f32, fastmathFlags = #llvm.fastmath<>} : (f32, vector<4xf32>) -> f32 - %1 = "llvm.call"(%arg2, %arg3) {callee = @llvm.vector.reduce.fadd.v8f32, fastmathFlags = #llvm.fastmath<>} : (f32, vector<8xf32>) -> f32 - %2 = "llvm.fsub"(%0, %1) : (f32, f32) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "diff_of_sums_type_mismatch", type = !llvm.func, f32, vector<8xf32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi32>, %arg1: vector<4xi32>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.vector.reduce.add.v4i32, fastmathFlags = #llvm.fastmath<>} : (vector<4xi32>) -> i32 - %1 = "llvm.call"(%arg1) {callee = @llvm.vector.reduce.add.v4i32, fastmathFlags = #llvm.fastmath<>} : (vector<4xi32>) -> i32 - %2 = "llvm.sub"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "diff_of_sums_v4i32", type = !llvm.func, vector<4xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi32>, %arg1: vector<4xi32>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.vector.reduce.add.v4i32, fastmathFlags = #llvm.fastmath<>} : (vector<4xi32>) -> i32 - "llvm.call"(%0) {callee = @use_i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %1 = "llvm.call"(%arg1) {callee = @llvm.vector.reduce.add.v4i32, fastmathFlags = #llvm.fastmath<>} : (vector<4xi32>) -> i32 - %2 = "llvm.sub"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "diff_of_sums_v4i32_extra_use1", type = !llvm.func, vector<4xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<4xi32>, %arg1: vector<4xi32>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.vector.reduce.add.v4i32, fastmathFlags = #llvm.fastmath<>} : (vector<4xi32>) -> i32 - %1 = "llvm.call"(%arg1) {callee = @llvm.vector.reduce.add.v4i32, fastmathFlags = #llvm.fastmath<>} : (vector<4xi32>) -> i32 - "llvm.call"(%1) {callee = @use_i32, fastmathFlags = #llvm.fastmath<>} : (i32) -> () - %2 = "llvm.sub"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "diff_of_sums_v4i32_extra_use2", type = !llvm.func, vector<4xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<8xi32>, %arg1: vector<4xi32>): // no predecessors - %0 = "llvm.call"(%arg0) {callee = @llvm.vector.reduce.add.v8i32, fastmathFlags = #llvm.fastmath<>} : (vector<8xi32>) -> i32 - %1 = "llvm.call"(%arg1) {callee = @llvm.vector.reduce.add.v4i32, fastmathFlags = #llvm.fastmath<>} : (vector<4xi32>) -> i32 - %2 = "llvm.sub"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "diff_of_sums_type_mismatch2", type = !llvm.func, vector<4xi32>)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.reduce.fadd.v4f32", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.vector.reduce.fadd.v8f32", type = !llvm.func)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () diff --git a/test/LLVMDialect/InstCombine/vector-reverse.ll.mlir b/test/LLVMDialect/InstCombine/vector-reverse.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/vector-trunc.ll.mlir b/test/LLVMDialect/InstCombine/vector-trunc.ll.mlir new file mode 100644 index 000000000..bdf82e557 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vector-trunc.ll.mlir @@ -0,0 +1,26 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @trunc_add_nsw(%arg0: vector<4xi32>) -> vector<4xi16> { + %0 = llvm.mlir.constant(dense<17> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<1> : vector<4xi16>) : vector<4xi16> + %2 = llvm.ashr %arg0, %0 : vector<4xi32> + %3 = llvm.trunc %2 : vector<4xi32> to vector<4xi16> + %4 = llvm.add %3, %1 : vector<4xi16> + llvm.return %4 : vector<4xi16> + } + llvm.func @trunc_add_no_nsw(%arg0: vector<4xi32>) -> vector<4xi16> { + %0 = llvm.mlir.constant(dense<16> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<1> : vector<4xi16>) : vector<4xi16> + %2 = llvm.ashr %arg0, %0 : vector<4xi32> + %3 = llvm.trunc %2 : vector<4xi32> to vector<4xi16> + %4 = llvm.add %3, %1 : vector<4xi16> + llvm.return %4 : vector<4xi16> + } + llvm.func @trunc_add_mixed(%arg0: vector<4xi32>) -> vector<4xi16> { + %0 = llvm.mlir.constant(dense<[17, 16, 17, 16]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<1> : vector<4xi16>) : vector<4xi16> + %2 = llvm.ashr %arg0, %0 : vector<4xi32> + %3 = llvm.trunc %2 : vector<4xi32> to vector<4xi16> + %4 = llvm.add %3, %1 : vector<4xi16> + llvm.return %4 : vector<4xi16> + } +} diff --git a/test/LLVMDialect/InstCombine/vector-type.ll.mlir b/test/LLVMDialect/InstCombine/vector-type.ll.mlir new file mode 100644 index 000000000..df5580253 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vector-type.ll.mlir @@ -0,0 +1,13 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @vselect1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : vector<2xi16>) : vector<2xi16> + %2 = llvm.bitcast %arg0 : i32 to vector<2xi16> + %3 = llvm.bitcast %arg1 : i32 to vector<2xi16> + %4 = llvm.bitcast %arg2 : i32 to vector<2xi16> + %5 = llvm.icmp "sge" %4, %1 : vector<2xi16> + %6 = llvm.select %5, %2, %3 : vector<2xi1>, vector<2xi16> + %7 = llvm.bitcast %6 : vector<2xi16> to i32 + llvm.return %7 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/vector-udiv.ll.mlir b/test/LLVMDialect/InstCombine/vector-udiv.ll.mlir new file mode 100644 index 000000000..f76dc6b8b --- /dev/null +++ b/test/LLVMDialect/InstCombine/vector-udiv.ll.mlir @@ -0,0 +1,65 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_v4i32_splatconst_pow2(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %1 = llvm.udiv %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @test_v4i32_const_pow2(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 4, 8]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.udiv %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @test_v4i32_negconstsplat(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-3> : vector<4xi32>) : vector<4xi32> + %1 = llvm.udiv %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @test_v4i32_negconst(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[-3, -5, -7, -9]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.udiv %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @test_v4i32_negconst_undef(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.undef : i32 + %1 = llvm.mlir.constant(-7 : i32) : i32 + %2 = llvm.mlir.constant(-5 : i32) : i32 + %3 = llvm.mlir.constant(-3 : i32) : i32 + %4 = llvm.mlir.undef : vector<4xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xi32> + %13 = llvm.udiv %arg0, %12 : vector<4xi32> + llvm.return %13 : vector<4xi32> + } + llvm.func @test_v4i32_shl_splatconst_pow2(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shl %0, %arg1 : vector<4xi32> + %2 = llvm.udiv %arg0, %1 : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @test_v4i32_shl_const_pow2(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[4, 8, 16, 32]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.shl %0, %arg1 : vector<4xi32> + %2 = llvm.udiv %arg0, %1 : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @test_v4i32_zext_shl_splatconst_pow2(%arg0: vector<4xi32>, %arg1: vector<4xi16>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<4> : vector<4xi16>) : vector<4xi16> + %1 = llvm.shl %0, %arg1 : vector<4xi16> + %2 = llvm.zext %1 : vector<4xi16> to vector<4xi32> + %3 = llvm.udiv %arg0, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_v4i32_zext_shl_const_pow2(%arg0: vector<4xi32>, %arg1: vector<4xi16>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[4, 8, 16, 32]> : vector<4xi16>) : vector<4xi16> + %1 = llvm.shl %0, %arg1 : vector<4xi16> + %2 = llvm.zext %1 : vector<4xi16> to vector<4xi32> + %3 = llvm.udiv %arg0, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/vector-urem.ll.mlir b/test/LLVMDialect/InstCombine/vector-urem.ll.mlir new file mode 100644 index 000000000..039e92955 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vector-urem.ll.mlir @@ -0,0 +1,76 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_v4i32_splatconst_pow2(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<2> : vector<4xi32>) : vector<4xi32> + %1 = llvm.urem %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @test_v4i32_const_pow2(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[1, 2, 4, 8]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.urem %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @test_v4i32_const_pow2_poison(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.undef : vector<4xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xi32> + %13 = llvm.urem %arg0, %12 : vector<4xi32> + llvm.return %13 : vector<4xi32> + } + llvm.func @test_v4i32_one(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.urem %0, %arg0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @test_v4i32_one_poison(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.urem %10, %arg0 : vector<4xi32> + llvm.return %11 : vector<4xi32> + } + llvm.func @test_v4i32_negconstsplat(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-3> : vector<4xi32>) : vector<4xi32> + %1 = llvm.urem %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @test_v4i32_negconst(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[-3, -5, -7, -9]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.urem %arg0, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @test_v4i32_negconst_poison(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(-7 : i32) : i32 + %2 = llvm.mlir.constant(-5 : i32) : i32 + %3 = llvm.mlir.constant(-3 : i32) : i32 + %4 = llvm.mlir.undef : vector<4xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xi32> + %13 = llvm.urem %arg0, %12 : vector<4xi32> + llvm.return %13 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/vector-xor.ll.mlir b/test/LLVMDialect/InstCombine/vector-xor.ll.mlir new file mode 100644 index 000000000..3d0e56fc6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vector-xor.ll.mlir @@ -0,0 +1,300 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test_v4i32_xor_repeated_and_0(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.and %arg0, %arg1 : vector<4xi32> + %1 = llvm.and %arg0, %arg2 : vector<4xi32> + %2 = llvm.xor %0, %1 : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @test_v4i32_xor_repeated_and_1(%arg0: vector<4xi32>, %arg1: vector<4xi32>, %arg2: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.and %arg0, %arg1 : vector<4xi32> + %1 = llvm.and %arg2, %arg0 : vector<4xi32> + %2 = llvm.xor %0, %1 : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @test_v4i32_xor_bswap_splatconst(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<255> : vector<4xi32>) : vector<4xi32> + %1 = llvm.intr.bswap(%arg0) : (vector<4xi32>) -> vector<4xi32> + %2 = llvm.xor %1, %0 : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @test_v4i32_xor_bswap_const(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[0, -16777216, 2, 3]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.intr.bswap(%arg0) : (vector<4xi32>) -> vector<4xi32> + %2 = llvm.xor %1, %0 : vector<4xi32> + llvm.return %2 : vector<4xi32> + } + llvm.func @test_v4i32_xor_bswap_const_poison(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.poison : i32 + %4 = llvm.mlir.undef : vector<4xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xi32> + %13 = llvm.intr.bswap(%arg0) : (vector<4xi32>) -> vector<4xi32> + %14 = llvm.xor %13, %12 : vector<4xi32> + llvm.return %14 : vector<4xi32> + } + llvm.func @test_v4i32_demorgan_and(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.xor %0, %arg0 : vector<4xi32> + %2 = llvm.and %1, %arg1 : vector<4xi32> + %3 = llvm.xor %0, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_v4i32_demorgan_or(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.xor %0, %arg0 : vector<4xi32> + %2 = llvm.or %1, %arg1 : vector<4xi32> + %3 = llvm.xor %0, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_v4i32_not_ashr_not(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.xor %0, %arg0 : vector<4xi32> + %2 = llvm.ashr %1, %arg1 : vector<4xi32> + %3 = llvm.xor %0, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_v4i32_not_ashr_not_poison(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.undef : vector<4xi32> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<4xi32> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.undef : vector<4xi32> + %12 = llvm.mlir.constant(0 : i32) : i32 + %13 = llvm.insertelement %1, %11[%12 : i32] : vector<4xi32> + %14 = llvm.mlir.constant(1 : i32) : i32 + %15 = llvm.insertelement %1, %13[%14 : i32] : vector<4xi32> + %16 = llvm.mlir.constant(2 : i32) : i32 + %17 = llvm.insertelement %0, %15[%16 : i32] : vector<4xi32> + %18 = llvm.mlir.constant(3 : i32) : i32 + %19 = llvm.insertelement %1, %17[%18 : i32] : vector<4xi32> + %20 = llvm.xor %10, %arg0 : vector<4xi32> + %21 = llvm.ashr %20, %arg1 : vector<4xi32> + %22 = llvm.xor %19, %21 : vector<4xi32> + llvm.return %22 : vector<4xi32> + } + llvm.func @test_v4i32_not_ashr_negative_splatconst(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-3> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %2 = llvm.ashr %0, %arg0 : vector<4xi32> + %3 = llvm.xor %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_v4i32_not_ashr_negative_const(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[-3, -5, -7, -9]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %2 = llvm.ashr %0, %arg0 : vector<4xi32> + %3 = llvm.xor %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_v4i32_not_ashr_negative_const_poison(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(-9 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.constant(-5 : i32) : i32 + %3 = llvm.mlir.constant(-3 : i32) : i32 + %4 = llvm.mlir.undef : vector<4xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xi32> + %13 = llvm.mlir.constant(-1 : i32) : i32 + %14 = llvm.mlir.undef : vector<4xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %13, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %13, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %13, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.insertelement %1, %20[%21 : i32] : vector<4xi32> + %23 = llvm.ashr %12, %arg0 : vector<4xi32> + %24 = llvm.xor %22, %23 : vector<4xi32> + llvm.return %24 : vector<4xi32> + } + llvm.func @test_v4i32_not_lshr_nonnegative_splatconst(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %2 = llvm.lshr %0, %arg0 : vector<4xi32> + %3 = llvm.xor %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_v4i32_not_lshr_nonnegative_const(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[3, 5, 7, 9]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %2 = llvm.lshr %0, %arg0 : vector<4xi32> + %3 = llvm.xor %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_v4i32_not_lshr_nonnegative_const_poison(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(9 : i32) : i32 + %1 = llvm.mlir.poison : i32 + %2 = llvm.mlir.constant(5 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.undef : vector<4xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xi32> + %13 = llvm.mlir.constant(-1 : i32) : i32 + %14 = llvm.mlir.undef : vector<4xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %13, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %13, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %13, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.insertelement %1, %20[%21 : i32] : vector<4xi32> + %23 = llvm.lshr %12, %arg0 : vector<4xi32> + %24 = llvm.xor %22, %23 : vector<4xi32> + llvm.return %24 : vector<4xi32> + } + llvm.func @test_v4i32_not_sub_splatconst(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.xor %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_v4i32_not_sub_const(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[3, 5, -1, 15]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.xor %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_v4i32_not_sub_const_poison(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.undef : vector<4xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xi32> + %13 = llvm.mlir.undef : vector<4xi32> + %14 = llvm.mlir.constant(0 : i32) : i32 + %15 = llvm.insertelement %1, %13[%14 : i32] : vector<4xi32> + %16 = llvm.mlir.constant(1 : i32) : i32 + %17 = llvm.insertelement %1, %15[%16 : i32] : vector<4xi32> + %18 = llvm.mlir.constant(2 : i32) : i32 + %19 = llvm.insertelement %1, %17[%18 : i32] : vector<4xi32> + %20 = llvm.mlir.constant(3 : i32) : i32 + %21 = llvm.insertelement %2, %19[%20 : i32] : vector<4xi32> + %22 = llvm.sub %12, %arg0 : vector<4xi32> + %23 = llvm.xor %21, %22 : vector<4xi32> + llvm.return %23 : vector<4xi32> + } + llvm.func @test_v4i32_xor_signmask_sub_splatconst(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-2147483648> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.xor %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_v4i32_xor_signmask_sub_const(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[3, 5, -1, 15]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-2147483648> : vector<4xi32>) : vector<4xi32> + %2 = llvm.sub %0, %arg0 : vector<4xi32> + %3 = llvm.xor %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_v4i32_xor_signmask_sub_const_poison(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.undef : vector<4xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xi32> + %13 = llvm.mlir.constant(-2147483648 : i32) : i32 + %14 = llvm.mlir.undef : vector<4xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %13, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %13, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %13, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.insertelement %2, %20[%21 : i32] : vector<4xi32> + %23 = llvm.sub %12, %arg0 : vector<4xi32> + %24 = llvm.xor %22, %23 : vector<4xi32> + llvm.return %24 : vector<4xi32> + } + llvm.func @test_v4i32_xor_signmask_add_splatconst(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<3> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-2147483648> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %0, %arg0 : vector<4xi32> + %3 = llvm.xor %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_v4i32_xor_signmask_add_const(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<[3, 5, -1, 15]> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-2147483648> : vector<4xi32>) : vector<4xi32> + %2 = llvm.add %0, %arg0 : vector<4xi32> + %3 = llvm.xor %1, %2 : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @test_v4i32_xor_signmask_add_const_poison(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.mlir.poison : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.mlir.undef : vector<4xi32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xi32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xi32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xi32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xi32> + %13 = llvm.mlir.constant(-2147483648 : i32) : i32 + %14 = llvm.mlir.undef : vector<4xi32> + %15 = llvm.mlir.constant(0 : i32) : i32 + %16 = llvm.insertelement %13, %14[%15 : i32] : vector<4xi32> + %17 = llvm.mlir.constant(1 : i32) : i32 + %18 = llvm.insertelement %13, %16[%17 : i32] : vector<4xi32> + %19 = llvm.mlir.constant(2 : i32) : i32 + %20 = llvm.insertelement %13, %18[%19 : i32] : vector<4xi32> + %21 = llvm.mlir.constant(3 : i32) : i32 + %22 = llvm.insertelement %2, %20[%21 : i32] : vector<4xi32> + %23 = llvm.add %12, %arg0 : vector<4xi32> + %24 = llvm.xor %22, %23 : vector<4xi32> + llvm.return %24 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/vector_gep1-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/vector_gep1-inseltpoison.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/vector_gep1.ll.mlir b/test/LLVMDialect/InstCombine/vector_gep1.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/vector_gep2.ll.mlir b/test/LLVMDialect/InstCombine/vector_gep2.ll.mlir index f0c528d93..887e3d3ee 100644 --- a/test/LLVMDialect/InstCombine/vector_gep2.ll.mlir +++ b/test/LLVMDialect/InstCombine/vector_gep2.ll.mlir @@ -1,24 +1,19 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec<2 x ptr>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<[0, 1]> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.getelementptr"(%arg0, %0) : (!llvm.vec<2 x ptr>, vector<2xi32>) -> !llvm.vec<2 x ptr> - "llvm.return"(%1) : (!llvm.vec<2 x ptr>) -> () - }) {linkage = 10 : i64, sym_name = "testa", type = !llvm.func> (vec<2 x ptr>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: vector<8xi64>): // no predecessors - %0 = "llvm.getelementptr"(%arg0, %arg1) : (!llvm.ptr, vector<8xi64>) -> !llvm.vec<8 x ptr> - "llvm.return"(%0) : (!llvm.vec<8 x ptr>) -> () - }) {linkage = 10 : i64, sym_name = "vgep_s_v8i64", type = !llvm.func> (ptr, vector<8xi64>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr, %arg1: vector<8xi32>): // no predecessors - %0 = "llvm.getelementptr"(%arg0, %arg1) : (!llvm.ptr, vector<8xi32>) -> !llvm.vec<8 x ptr> - "llvm.return"(%0) : (!llvm.vec<8 x ptr>) -> () - }) {linkage = 10 : i64, sym_name = "vgep_s_v8i32", type = !llvm.func> (ptr, vector<8xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec<8 x ptr>, %arg1: i32): // no predecessors - %0 = "llvm.getelementptr"(%arg0, %arg1) : (!llvm.vec<8 x ptr>, i32) -> !llvm.vec<8 x ptr> - "llvm.return"(%0) : (!llvm.vec<8 x ptr>) -> () - }) {linkage = 10 : i64, sym_name = "vgep_v8iPtr_i32", type = !llvm.func> (vec<8 x ptr>, i32)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @testa(%arg0: !llvm.vec<2 x ptr>) -> !llvm.vec<2 x ptr> { + %0 = llvm.mlir.constant(dense<[0, 1]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.getelementptr %arg0[%0] : (!llvm.vec<2 x ptr>, vector<2xi32>) -> !llvm.vec<2 x ptr>, i8 + llvm.return %1 : !llvm.vec<2 x ptr> + } + llvm.func @vgep_s_v8i64(%arg0: !llvm.ptr, %arg1: vector<8xi64>) -> !llvm.vec<8 x ptr> { + %0 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, vector<8xi64>) -> !llvm.vec<8 x ptr>, f64 + llvm.return %0 : !llvm.vec<8 x ptr> + } + llvm.func @vgep_s_v8i32(%arg0: !llvm.ptr, %arg1: vector<8xi32>) -> !llvm.vec<8 x ptr> { + %0 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, vector<8xi32>) -> !llvm.vec<8 x ptr>, f64 + llvm.return %0 : !llvm.vec<8 x ptr> + } + llvm.func @vgep_v8iPtr_i32(%arg0: !llvm.vec<8 x ptr>, %arg1: i32) -> !llvm.vec<8 x ptr> { + %0 = llvm.getelementptr %arg0[%arg1] : (!llvm.vec<8 x ptr>, i32) -> !llvm.vec<8 x ptr>, i8 + llvm.return %0 : !llvm.vec<8 x ptr> + } +} diff --git a/test/LLVMDialect/InstCombine/vector_insertelt_shuffle-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/vector_insertelt_shuffle-inseltpoison.ll.mlir new file mode 100644 index 000000000..1f42cab1a --- /dev/null +++ b/test/LLVMDialect/InstCombine/vector_insertelt_shuffle-inseltpoison.ll.mlir @@ -0,0 +1,91 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %2, %4[%3 : i32] : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @bar(%arg0: vector<4xf32>, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.insertelement %arg1, %arg0[%0 : i32] : vector<4xf32> + %4 = llvm.insertelement %1, %3[%2 : i32] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @baz(%arg0: vector<4xf32>, %arg1: i32) -> vector<4xf32> { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %3 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + %4 = llvm.insertelement %2, %3[%arg1 : i32] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @bazz(%arg0: vector<4xf32>, %arg1: i32) -> vector<4xf32> { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %7 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %8 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + %9 = llvm.insertelement %2, %8[%arg1 : i32] : vector<4xf32> + %10 = llvm.insertelement %3, %9[%4 : i32] : vector<4xf32> + %11 = llvm.insertelement %0, %10[%5 : i32] : vector<4xf32> + %12 = llvm.insertelement %6, %11[%4 : i32] : vector<4xf32> + %13 = llvm.insertelement %7, %12[%arg1 : i32] : vector<4xf32> + llvm.return %13 : vector<4xf32> + } + llvm.func @bazzz(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %2, %4[%3 : i32] : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @bazzzz(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %2, %4[%3 : i32] : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @bazzzzz() -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(1.000000e+01 : f32) : f32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.insertelement %1, %0[%2 : i32] : vector<4xf32> + %6 = llvm.insertelement %3, %5[%4 : i32] : vector<4xf32> + llvm.return %6 : vector<4xf32> + } + llvm.func @bazzzzzz(%arg0: vector<4xf32>, %arg1: i32) -> vector<4xf32> { + %0 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %1 = llvm.mlir.undef : f32 + %2 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %3 = llvm.mlir.poison : f32 + %4 = llvm.mlir.undef : vector<4xf32> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<4xf32> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<4xf32> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %1, %8[%9 : i32] : vector<4xf32> + %11 = llvm.mlir.constant(3 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<4xf32> + %13 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %14 = llvm.mlir.constant(1 : i32) : i32 + %15 = llvm.insertelement %13, %12[%14 : i32] : vector<4xf32> + llvm.return %15 : vector<4xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/vector_insertelt_shuffle.ll.mlir b/test/LLVMDialect/InstCombine/vector_insertelt_shuffle.ll.mlir new file mode 100644 index 000000000..b2cc3d910 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vector_insertelt_shuffle.ll.mlir @@ -0,0 +1,90 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @foo(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %2, %4[%3 : i32] : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @bar(%arg0: vector<4xf32>, %arg1: f32) -> vector<4xf32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.insertelement %arg1, %arg0[%0 : i32] : vector<4xf32> + %4 = llvm.insertelement %1, %3[%2 : i32] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @baz(%arg0: vector<4xf32>, %arg1: i32) -> vector<4xf32> { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %3 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + %4 = llvm.insertelement %2, %3[%arg1 : i32] : vector<4xf32> + llvm.return %4 : vector<4xf32> + } + llvm.func @bazz(%arg0: vector<4xf32>, %arg1: i32) -> vector<4xf32> { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(3.000000e+00 : f32) : f32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %7 = llvm.mlir.constant(7.000000e+00 : f32) : f32 + %8 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + %9 = llvm.insertelement %2, %8[%arg1 : i32] : vector<4xf32> + %10 = llvm.insertelement %3, %9[%4 : i32] : vector<4xf32> + %11 = llvm.insertelement %0, %10[%5 : i32] : vector<4xf32> + %12 = llvm.insertelement %6, %11[%4 : i32] : vector<4xf32> + %13 = llvm.insertelement %7, %12[%arg1 : i32] : vector<4xf32> + llvm.return %13 : vector<4xf32> + } + llvm.func @bazzz(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %2, %4[%3 : i32] : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @bazzzz(%arg0: vector<4xf32>) -> vector<4xf32> { + %0 = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %1 = llvm.mlir.undef : i32 + %2 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.insertelement %0, %arg0[%1 : i32] : vector<4xf32> + %5 = llvm.insertelement %2, %4[%3 : i32] : vector<4xf32> + llvm.return %5 : vector<4xf32> + } + llvm.func @bazzzzz() -> vector<4xf32> { + %0 = llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>) : vector<4xf32> + %1 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(1.000000e+01 : f32) : f32 + %4 = llvm.mlir.constant(2 : i32) : i32 + %5 = llvm.insertelement %1, %0[%2 : i32] : vector<4xf32> + %6 = llvm.insertelement %3, %5[%4 : i32] : vector<4xf32> + llvm.return %6 : vector<4xf32> + } + llvm.func @bazzzzzz(%arg0: vector<4xf32>, %arg1: i32) -> vector<4xf32> { + %0 = llvm.mlir.constant(4.000000e+00 : f32) : f32 + %1 = llvm.mlir.undef : f32 + %2 = llvm.mlir.constant(2.000000e+00 : f32) : f32 + %3 = llvm.mlir.undef : vector<4xf32> + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.insertelement %1, %3[%4 : i32] : vector<4xf32> + %6 = llvm.mlir.constant(1 : i32) : i32 + %7 = llvm.insertelement %2, %5[%6 : i32] : vector<4xf32> + %8 = llvm.mlir.constant(2 : i32) : i32 + %9 = llvm.insertelement %1, %7[%8 : i32] : vector<4xf32> + %10 = llvm.mlir.constant(3 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : vector<4xf32> + %12 = llvm.mlir.constant(5.000000e+00 : f32) : f32 + %13 = llvm.mlir.constant(1 : i32) : i32 + %14 = llvm.insertelement %12, %11[%13 : i32] : vector<4xf32> + llvm.return %14 : vector<4xf32> + } +} diff --git a/test/LLVMDialect/InstCombine/volatile_load_cast.ll.mlir b/test/LLVMDialect/InstCombine/volatile_load_cast.ll.mlir index 015464384..ae53a8bdd 100644 --- a/test/LLVMDialect/InstCombine/volatile_load_cast.ll.mlir +++ b/test/LLVMDialect/InstCombine/volatile_load_cast.ll.mlir @@ -1,33 +1,27 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i32 - %1 = "llvm.bitcast"(%0) : (i32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_load", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> f32 - %1 = "llvm.bitcast"(%0) : (f32) -> i32 - "llvm.return"(%1) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "i32_load", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i64 - %1 = "llvm.bitcast"(%0) : (i64) -> f64 - "llvm.return"(%1) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "double_load", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> f64 - %1 = "llvm.bitcast"(%0) : (f64) -> i64 - "llvm.return"(%1) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "i64_load", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.ptr): // no predecessors - %0 = "llvm.load"(%arg0) : (!llvm.ptr) -> i64 - %1 = "llvm.inttoptr"(%0) : (i64) -> !llvm.ptr - "llvm.return"(%1) : (!llvm.ptr) -> () - }) {linkage = 10 : i64, sym_name = "ptr_load", type = !llvm.func (ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @float_load(%arg0: !llvm.ptr) -> f32 { + %0 = llvm.load volatile %arg0 {alignment = 4 : i64} : !llvm.ptr -> i32 + %1 = llvm.bitcast %0 : i32 to f32 + llvm.return %1 : f32 + } + llvm.func @i32_load(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.load volatile %arg0 {alignment = 4 : i64} : !llvm.ptr -> f32 + %1 = llvm.bitcast %0 : f32 to i32 + llvm.return %1 : i32 + } + llvm.func @double_load(%arg0: !llvm.ptr) -> f64 { + %0 = llvm.load volatile %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + %1 = llvm.bitcast %0 : i64 to f64 + llvm.return %1 : f64 + } + llvm.func @i64_load(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.load volatile %arg0 {alignment = 8 : i64} : !llvm.ptr -> f64 + %1 = llvm.bitcast %0 : f64 to i64 + llvm.return %1 : i64 + } + llvm.func @ptr_load(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.load volatile %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + %1 = llvm.inttoptr %0 : i64 to !llvm.ptr + llvm.return %1 : !llvm.ptr + } +} diff --git a/test/LLVMDialect/InstCombine/volatile_store.ll.mlir b/test/LLVMDialect/InstCombine/volatile_store.ll.mlir new file mode 100644 index 000000000..d82be7ec3 --- /dev/null +++ b/test/LLVMDialect/InstCombine/volatile_store.ll.mlir @@ -0,0 +1,21 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global weak @x(0 : i32) {addr_space = 0 : i32} : i32 + llvm.func @self_assign_1() { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @x : !llvm.ptr + %2 = llvm.load volatile %1 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.store volatile %2, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb1 + ^bb1: // pred: ^bb0 + llvm.return + } + llvm.func @volatile_store_before_unreachable(%arg0: i1, %arg1: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + llvm.cond_br %arg0, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.store volatile %0, %arg1 {alignment = 1 : i64} : i8, !llvm.ptr + llvm.unreachable + ^bb2: // pred: ^bb0 + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/vscale.ll.mlir b/test/LLVMDialect/InstCombine/vscale.ll.mlir new file mode 100644 index 000000000..ac1c5b4e2 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vscale.ll.mlir @@ -0,0 +1,21 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.func @promote_vscale_i32_to_i64() -> i64 { + %0 = "llvm.intr.vscale"() : () -> i32 + %1 = llvm.zext %0 : i32 to i64 + llvm.return %1 : i64 + } + llvm.func @pomote_zext_shl_vscale_i32_to_i64() -> i64 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = "llvm.intr.vscale"() : () -> i32 + %2 = llvm.shl %1, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @free_zext_vscale_shl_i32_to_i64() -> i64 vscale_range(1, 16) { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = "llvm.intr.vscale"() : () -> i32 + %2 = llvm.shl %1, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/vscale_alloca.ll.mlir b/test/LLVMDialect/InstCombine/vscale_alloca.ll.mlir index b9ae32c95..bb45071d9 100644 --- a/test/LLVMDialect/InstCombine/vscale_alloca.ll.mlir +++ b/test/LLVMDialect/InstCombine/vscale_alloca.ll.mlir @@ -1,28 +1,24 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr> - "llvm.store"(%arg0, %1) : (!llvm.vec, !llvm.ptr>) -> () - %2 = "llvm.load"(%1) : (!llvm.ptr>) -> !llvm.vec - "llvm.return"(%2) : (!llvm.vec) -> () - }) {linkage = 10 : i64, sym_name = "alloca", type = !llvm.func (vec)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr> - "llvm.store"(%arg0, %1) : (!llvm.vec, !llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "alloca_dead_store", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr> - "llvm.call"(%1) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>) -> () - %2 = "llvm.alloca"(%0) : (i32) -> !llvm.ptr> - "llvm.call"(%2) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr>) -> () - "llvm.return"() : () -> () - }) {linkage = 10 : i64, sym_name = "alloca_zero_byte_move_first_inst", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @alloca(%arg0: !llvm.vec) -> !llvm.vec { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.vec {alignment = 16 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %1 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + %2 = llvm.load %1 {alignment = 16 : i64} : !llvm.ptr -> !llvm.vec + llvm.return %2 : !llvm.vec + } + llvm.func @alloca_dead_store(%arg0: !llvm.vec) { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.vec {alignment = 16 : i64} : (i32) -> !llvm.ptr + llvm.store %arg0, %1 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + llvm.return + } + llvm.func @use(...) + llvm.func @alloca_zero_byte_move_first_inst() { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.alloca %0 x !llvm.vec {alignment = 16 : i64} : (i32) -> !llvm.ptr + llvm.call @use(%1) vararg(!llvm.func) : (!llvm.ptr) -> () + %2 = llvm.alloca %0 x !llvm.struct<()> {alignment = 8 : i64} : (i32) -> !llvm.ptr + llvm.call @use(%2) vararg(!llvm.func) : (!llvm.ptr) -> () + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/vscale_cmp.ll.mlir b/test/LLVMDialect/InstCombine/vscale_cmp.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/vscale_extractelement-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/vscale_extractelement-inseltpoison.ll.mlir new file mode 100644 index 000000000..ca1f3fae7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vscale_extractelement-inseltpoison.ll.mlir @@ -0,0 +1,129 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use_vscale_2_i32(!llvm.vec) + llvm.func @use_vscale_8_i8(!llvm.vec) + llvm.func @extractelement_in_range(%arg0: !llvm.vec) -> i32 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.extractelement %arg0[%0 : i64] : !llvm.vec + llvm.return %1 : i32 + } + llvm.func @extractelement_maybe_out_of_range(%arg0: !llvm.vec) -> i32 { + %0 = llvm.mlir.constant(4 : i64) : i64 + %1 = llvm.extractelement %arg0[%0 : i64] : !llvm.vec + llvm.return %1 : i32 + } + llvm.func @extractelement_bitcast(%arg0: f32) -> i32 { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec + %3 = llvm.bitcast %2 : !llvm.vec to !llvm.vec + %4 = llvm.extractelement %3[%1 : i32] : !llvm.vec + llvm.return %4 : i32 + } + llvm.func @extractelement_bitcast_to_trunc(%arg0: !llvm.vec, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.insertelement %arg1, %arg0[%0 : i32] : !llvm.vec + %3 = llvm.bitcast %2 : !llvm.vec to !llvm.vec + %4 = llvm.extractelement %3[%1 : i32] : !llvm.vec + llvm.return %4 : i8 + } + llvm.func @extractelement_bitcast_useless_insert(%arg0: !llvm.vec, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg1, %arg0[%0 : i32] : !llvm.vec + %3 = llvm.bitcast %2 : !llvm.vec to !llvm.vec + %4 = llvm.extractelement %3[%1 : i32] : !llvm.vec + llvm.return %4 : i8 + } + llvm.func @extractelement_bitcast_insert_extra_use_insert(%arg0: !llvm.vec, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg1, %arg0[%0 : i32] : !llvm.vec + llvm.call @use_vscale_2_i32(%2) : (!llvm.vec) -> () + %3 = llvm.bitcast %2 : !llvm.vec to !llvm.vec + %4 = llvm.extractelement %3[%1 : i32] : !llvm.vec + llvm.return %4 : i8 + } + llvm.func @extractelement_bitcast_insert_extra_use_bitcast(%arg0: !llvm.vec, %arg1: i32) -> i8 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %arg1, %arg0[%0 : i32] : !llvm.vec + %3 = llvm.bitcast %2 : !llvm.vec to !llvm.vec + llvm.call @use_vscale_8_i8(%3) : (!llvm.vec) -> () + %4 = llvm.extractelement %3[%1 : i32] : !llvm.vec + llvm.return %4 : i8 + } + llvm.func @extractelement_shuffle_maybe_out_of_range(%arg0: i32) -> i32 { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : !llvm.vec + %5 = llvm.extractelement %4[%2 : i32] : vector<[4]xi32> + llvm.return %5 : i32 + } + llvm.func @extractelement_shuffle_invalid_index(%arg0: i32) -> i32 { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec + %4 = llvm.shufflevector %3, %0 [0, 0, 0, 0] : !llvm.vec + %5 = llvm.extractelement %4[%2 : i32] : vector<[4]xi32> + llvm.return %5 : i32 + } + llvm.func @extractelement_insertelement_same_positions(%arg0: !llvm.vec) -> !llvm.vec { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.mlir.constant(3 : i32) : i32 + %4 = llvm.extractelement %arg0[%0 : i32] : !llvm.vec + %5 = llvm.extractelement %arg0[%1 : i32] : !llvm.vec + %6 = llvm.extractelement %arg0[%2 : i32] : !llvm.vec + %7 = llvm.extractelement %arg0[%3 : i32] : !llvm.vec + %8 = llvm.insertelement %4, %arg0[%0 : i32] : !llvm.vec + %9 = llvm.insertelement %5, %8[%1 : i32] : !llvm.vec + %10 = llvm.insertelement %6, %9[%2 : i32] : !llvm.vec + %11 = llvm.insertelement %7, %10[%3 : i32] : !llvm.vec + llvm.return %11 : !llvm.vec + } + llvm.func @extractelement_insertelement_diff_positions(%arg0: !llvm.vec) -> !llvm.vec { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.mlir.constant(6 : i32) : i32 + %3 = llvm.mlir.constant(7 : i32) : i32 + %4 = llvm.mlir.constant(0 : i32) : i32 + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.mlir.constant(3 : i32) : i32 + %8 = llvm.extractelement %arg0[%0 : i32] : !llvm.vec + %9 = llvm.extractelement %arg0[%1 : i32] : !llvm.vec + %10 = llvm.extractelement %arg0[%2 : i32] : !llvm.vec + %11 = llvm.extractelement %arg0[%3 : i32] : !llvm.vec + %12 = llvm.insertelement %8, %arg0[%4 : i32] : !llvm.vec + %13 = llvm.insertelement %9, %12[%5 : i32] : !llvm.vec + %14 = llvm.insertelement %10, %13[%6 : i32] : !llvm.vec + %15 = llvm.insertelement %11, %14[%7 : i32] : !llvm.vec + llvm.return %15 : !llvm.vec + } + llvm.func @bitcast_of_extractelement(%arg0: !llvm.vec) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.extractelement %arg0[%0 : i32] : !llvm.vec + %2 = llvm.bitcast %1 : f32 to i32 + llvm.return %2 : i32 + } + llvm.func @extractelement_is_zero(%arg0: !llvm.vec, %arg1: i1, %arg2: i32) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.extractelement %arg0[%0 : i32] : !llvm.vec + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @ossfuzz_25272(%arg0: f32) -> i32 { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2147483647 : i32) : i32 + %3 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec + %4 = llvm.bitcast %3 : !llvm.vec to !llvm.vec + %5 = llvm.extractelement %4[%2 : i32] : !llvm.vec + llvm.return %5 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/vscale_extractelement.ll.mlir b/test/LLVMDialect/InstCombine/vscale_extractelement.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/vscale_gep.ll.mlir b/test/LLVMDialect/InstCombine/vscale_gep.ll.mlir new file mode 100644 index 000000000..28dbb86ae --- /dev/null +++ b/test/LLVMDialect/InstCombine/vscale_gep.ll.mlir @@ -0,0 +1,70 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @gep_index_type_is_scalable(%arg0: !llvm.ptr) -> !llvm.vec { + %0 = llvm.mlir.undef : !llvm.vec + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, !llvm.vec) -> !llvm.vec, i8 + llvm.return %1 : !llvm.vec + } + llvm.func @gep_num_of_indices_1(%arg0: !llvm.ptr) -> !llvm.ptr { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.vec + llvm.return %1 : !llvm.ptr + } + llvm.func @gep_bitcast(%arg0: !llvm.ptr) { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.undef : !llvm.vec + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.insertelement %0, %5[%6 : i32] : !llvm.vec + %8 = llvm.mlir.constant(3 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : !llvm.vec + %10 = llvm.mlir.constant(4 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : !llvm.vec + %12 = llvm.mlir.constant(5 : i32) : i32 + %13 = llvm.insertelement %0, %11[%12 : i32] : !llvm.vec + %14 = llvm.mlir.constant(6 : i32) : i32 + %15 = llvm.insertelement %0, %13[%14 : i32] : !llvm.vec + %16 = llvm.mlir.constant(7 : i32) : i32 + %17 = llvm.insertelement %0, %15[%16 : i32] : !llvm.vec + %18 = llvm.mlir.constant(8 : i32) : i32 + %19 = llvm.insertelement %0, %17[%18 : i32] : !llvm.vec + %20 = llvm.mlir.constant(9 : i32) : i32 + %21 = llvm.insertelement %0, %19[%20 : i32] : !llvm.vec + %22 = llvm.mlir.constant(10 : i32) : i32 + %23 = llvm.insertelement %0, %21[%22 : i32] : !llvm.vec + %24 = llvm.mlir.constant(11 : i32) : i32 + %25 = llvm.insertelement %0, %23[%24 : i32] : !llvm.vec + %26 = llvm.mlir.constant(12 : i32) : i32 + %27 = llvm.insertelement %0, %25[%26 : i32] : !llvm.vec + %28 = llvm.mlir.constant(13 : i32) : i32 + %29 = llvm.insertelement %0, %27[%28 : i32] : !llvm.vec + %30 = llvm.mlir.constant(14 : i32) : i32 + %31 = llvm.insertelement %0, %29[%30 : i32] : !llvm.vec + %32 = llvm.mlir.constant(15 : i32) : i32 + %33 = llvm.insertelement %0, %31[%32 : i32] : !llvm.vec + %34 = llvm.mlir.constant(1 : i64) : i64 + llvm.store %33, %arg0 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + %35 = llvm.getelementptr %arg0[%34] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.vec + llvm.store %33, %35 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + llvm.return + } + llvm.func @gep_alloca_inbounds_vscale_zero() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(2 : i32) : i32 + %3 = llvm.alloca %0 x !llvm.vec {alignment = 16 : i64} : (i32) -> !llvm.ptr + %4 = llvm.getelementptr %3[%1, %2] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.vec + %5 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %5 : i32 + } + llvm.func @gep_alloca_inbounds_vscale_nonzero() -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.alloca %0 x !llvm.vec {alignment = 16 : i64} : (i32) -> !llvm.ptr + %3 = llvm.getelementptr %2[%0, %1] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.vec + %4 = llvm.load %3 {alignment = 4 : i64} : !llvm.ptr -> i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/vscale_insertelement-inseltpoison.ll.mlir b/test/LLVMDialect/InstCombine/vscale_insertelement-inseltpoison.ll.mlir new file mode 100644 index 000000000..22c48be4c --- /dev/null +++ b/test/LLVMDialect/InstCombine/vscale_insertelement-inseltpoison.ll.mlir @@ -0,0 +1,53 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @insertelement_bitcast(%arg0: !llvm.vec, %arg1: i32) -> !llvm.vec { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg1 : i32 to f32 + %2 = llvm.bitcast %arg0 : !llvm.vec to !llvm.vec + %3 = llvm.insertelement %1, %2[%0 : i32] : !llvm.vec + llvm.return %3 : !llvm.vec + } + llvm.func @insertelement_extractelement(%arg0: !llvm.vec, %arg1: !llvm.vec) -> !llvm.vec { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.extractelement %arg0[%0 : i32] : !llvm.vec + %3 = llvm.insertelement %2, %arg1[%1 : i32] : !llvm.vec + llvm.return %3 : !llvm.vec + } + llvm.func @insertelement_extractelement_fixed_vec_extract_from_scalable(%arg0: !llvm.vec, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.extractelement %arg0[%0 : i32] : !llvm.vec + %3 = llvm.insertelement %2, %arg1[%1 : i32] : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @insertelement_insertelement(%arg0: !llvm.vec) -> !llvm.vec { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%0 : i32] : !llvm.vec + %3 = llvm.insertelement %1, %2[%1 : i32] : !llvm.vec + llvm.return %3 : !llvm.vec + } + llvm.func @insertelement_sequene_may_not_be_splat(%arg0: f32) -> !llvm.vec { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec + %6 = llvm.insertelement %arg0, %5[%2 : i32] : !llvm.vec + %7 = llvm.insertelement %arg0, %6[%3 : i32] : !llvm.vec + %8 = llvm.insertelement %arg0, %7[%4 : i32] : !llvm.vec + llvm.return %8 : !llvm.vec + } + llvm.func @ossfuzz_27416(%arg0: i32, %arg1: !llvm.ptr) { + %0 = llvm.mlir.poison : !llvm.vec + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i32 + %3 = llvm.mlir.constant(-128 : i8) : i8 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec + %5 = llvm.shufflevector %4, %0 [0, 0, 0, 0] : !llvm.vec + %6 = llvm.insertelement %2, %5[%3 : i8] : vector<[4]xi32> + llvm.store %6, %arg1 {alignment = 16 : i64} : vector<[4]xi32>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/vscale_insertelement.ll.mlir b/test/LLVMDialect/InstCombine/vscale_insertelement.ll.mlir new file mode 100644 index 000000000..8e2f235a9 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vscale_insertelement.ll.mlir @@ -0,0 +1,53 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @insertelement_bitcast(%arg0: !llvm.vec, %arg1: i32) -> !llvm.vec { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.bitcast %arg1 : i32 to f32 + %2 = llvm.bitcast %arg0 : !llvm.vec to !llvm.vec + %3 = llvm.insertelement %1, %2[%0 : i32] : !llvm.vec + llvm.return %3 : !llvm.vec + } + llvm.func @insertelement_extractelement(%arg0: !llvm.vec, %arg1: !llvm.vec) -> !llvm.vec { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.extractelement %arg0[%0 : i32] : !llvm.vec + %3 = llvm.insertelement %2, %arg1[%1 : i32] : !llvm.vec + llvm.return %3 : !llvm.vec + } + llvm.func @insertelement_extractelement_fixed_vec_extract_from_scalable(%arg0: !llvm.vec, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.extractelement %arg0[%0 : i32] : !llvm.vec + %3 = llvm.insertelement %2, %arg1[%1 : i32] : vector<4xi32> + llvm.return %3 : vector<4xi32> + } + llvm.func @insertelement_insertelement(%arg0: !llvm.vec) -> !llvm.vec { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.insertelement %0, %arg0[%0 : i32] : !llvm.vec + %3 = llvm.insertelement %1, %2[%1 : i32] : !llvm.vec + llvm.return %3 : !llvm.vec + } + llvm.func @insertelement_sequene_may_not_be_splat(%arg0: f32) -> !llvm.vec { + %0 = llvm.mlir.undef : !llvm.vec + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.mlir.constant(2 : i32) : i32 + %4 = llvm.mlir.constant(3 : i32) : i32 + %5 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec + %6 = llvm.insertelement %arg0, %5[%2 : i32] : !llvm.vec + %7 = llvm.insertelement %arg0, %6[%3 : i32] : !llvm.vec + %8 = llvm.insertelement %arg0, %7[%4 : i32] : !llvm.vec + llvm.return %8 : !llvm.vec + } + llvm.func @ossfuzz_27416(%arg0: i32, %arg1: !llvm.ptr) { + %0 = llvm.mlir.undef : !llvm.vec + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.undef : i32 + %3 = llvm.mlir.constant(-128 : i8) : i8 + %4 = llvm.insertelement %arg0, %0[%1 : i32] : !llvm.vec + %5 = llvm.shufflevector %4, %0 [0, 0, 0, 0] : !llvm.vec + %6 = llvm.insertelement %2, %5[%3 : i8] : vector<[4]xi32> + llvm.store %6, %arg1 {alignment = 16 : i64} : vector<[4]xi32>, !llvm.ptr + llvm.return + } +} diff --git a/test/LLVMDialect/InstCombine/vscale_load.ll.mlir b/test/LLVMDialect/InstCombine/vscale_load.ll.mlir new file mode 100644 index 000000000..901f9946b --- /dev/null +++ b/test/LLVMDialect/InstCombine/vscale_load.ll.mlir @@ -0,0 +1,80 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @constprop_load_bitcast(%arg0: !llvm.ptr) -> vector<2xi8> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.undef : !llvm.vec + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.insertelement %0, %5[%6 : i32] : !llvm.vec + %8 = llvm.mlir.constant(3 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : !llvm.vec + %10 = llvm.mlir.constant(4 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : !llvm.vec + %12 = llvm.mlir.constant(5 : i32) : i32 + %13 = llvm.insertelement %0, %11[%12 : i32] : !llvm.vec + %14 = llvm.mlir.constant(6 : i32) : i32 + %15 = llvm.insertelement %0, %13[%14 : i32] : !llvm.vec + %16 = llvm.mlir.constant(7 : i32) : i32 + %17 = llvm.insertelement %0, %15[%16 : i32] : !llvm.vec + %18 = llvm.mlir.constant(8 : i32) : i32 + %19 = llvm.insertelement %0, %17[%18 : i32] : !llvm.vec + %20 = llvm.mlir.constant(9 : i32) : i32 + %21 = llvm.insertelement %0, %19[%20 : i32] : !llvm.vec + %22 = llvm.mlir.constant(10 : i32) : i32 + %23 = llvm.insertelement %0, %21[%22 : i32] : !llvm.vec + %24 = llvm.mlir.constant(11 : i32) : i32 + %25 = llvm.insertelement %0, %23[%24 : i32] : !llvm.vec + %26 = llvm.mlir.constant(12 : i32) : i32 + %27 = llvm.insertelement %0, %25[%26 : i32] : !llvm.vec + %28 = llvm.mlir.constant(13 : i32) : i32 + %29 = llvm.insertelement %0, %27[%28 : i32] : !llvm.vec + %30 = llvm.mlir.constant(14 : i32) : i32 + %31 = llvm.insertelement %0, %29[%30 : i32] : !llvm.vec + %32 = llvm.mlir.constant(15 : i32) : i32 + %33 = llvm.insertelement %0, %31[%32 : i32] : !llvm.vec + llvm.store %33, %arg0 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + %34 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> vector<2xi8> + llvm.return %34 : vector<2xi8> + } + llvm.func @constprop_load_bitcast_neg(%arg0: !llvm.ptr) -> vector<8xi8> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.undef : !llvm.vec + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.insertelement %0, %1[%2 : i32] : !llvm.vec + %4 = llvm.mlir.constant(1 : i32) : i32 + %5 = llvm.insertelement %0, %3[%4 : i32] : !llvm.vec + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.insertelement %0, %5[%6 : i32] : !llvm.vec + %8 = llvm.mlir.constant(3 : i32) : i32 + %9 = llvm.insertelement %0, %7[%8 : i32] : !llvm.vec + %10 = llvm.mlir.constant(4 : i32) : i32 + %11 = llvm.insertelement %0, %9[%10 : i32] : !llvm.vec + %12 = llvm.mlir.constant(5 : i32) : i32 + %13 = llvm.insertelement %0, %11[%12 : i32] : !llvm.vec + %14 = llvm.mlir.constant(6 : i32) : i32 + %15 = llvm.insertelement %0, %13[%14 : i32] : !llvm.vec + %16 = llvm.mlir.constant(7 : i32) : i32 + %17 = llvm.insertelement %0, %15[%16 : i32] : !llvm.vec + %18 = llvm.mlir.constant(8 : i32) : i32 + %19 = llvm.insertelement %0, %17[%18 : i32] : !llvm.vec + %20 = llvm.mlir.constant(9 : i32) : i32 + %21 = llvm.insertelement %0, %19[%20 : i32] : !llvm.vec + %22 = llvm.mlir.constant(10 : i32) : i32 + %23 = llvm.insertelement %0, %21[%22 : i32] : !llvm.vec + %24 = llvm.mlir.constant(11 : i32) : i32 + %25 = llvm.insertelement %0, %23[%24 : i32] : !llvm.vec + %26 = llvm.mlir.constant(12 : i32) : i32 + %27 = llvm.insertelement %0, %25[%26 : i32] : !llvm.vec + %28 = llvm.mlir.constant(13 : i32) : i32 + %29 = llvm.insertelement %0, %27[%28 : i32] : !llvm.vec + %30 = llvm.mlir.constant(14 : i32) : i32 + %31 = llvm.insertelement %0, %29[%30 : i32] : !llvm.vec + %32 = llvm.mlir.constant(15 : i32) : i32 + %33 = llvm.insertelement %0, %31[%32 : i32] : !llvm.vec + llvm.store %33, %arg0 {alignment = 16 : i64} : !llvm.vec, !llvm.ptr + %34 = llvm.load %arg0 {alignment = 16 : i64} : !llvm.ptr -> vector<8xi8> + llvm.return %34 : vector<8xi8> + } +} diff --git a/test/LLVMDialect/InstCombine/vscale_sext_and_zext.ll.mlir b/test/LLVMDialect/InstCombine/vscale_sext_and_zext.ll.mlir new file mode 100644 index 000000000..8c82ae404 --- /dev/null +++ b/test/LLVMDialect/InstCombine/vscale_sext_and_zext.ll.mlir @@ -0,0 +1,37 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @vscale_SExt_i8toi32() -> i32 vscale_range(1, 64) { + %0 = "llvm.intr.vscale"() : () -> i8 + %1 = llvm.sext %0 : i8 to i32 + llvm.return %1 : i32 + } + llvm.func @vscale_SExt_i8toi32_poison() -> i32 vscale_range(1, 128) { + %0 = "llvm.intr.vscale"() : () -> i8 + %1 = llvm.sext %0 : i8 to i32 + llvm.return %1 : i32 + } + llvm.func @vscale_ZExt_i8toi32() -> i32 vscale_range(1, 128) { + %0 = "llvm.intr.vscale"() : () -> i8 + %1 = llvm.zext %0 : i8 to i32 + llvm.return %1 : i32 + } + llvm.func @vscale_ZExt_i8toi32_poison() -> i32 vscale_range(1, 256) { + %0 = "llvm.intr.vscale"() : () -> i8 + %1 = llvm.zext %0 : i8 to i32 + llvm.return %1 : i32 + } + llvm.func @vscale_ZExt_i8toi32_unknown() -> i32 { + %0 = "llvm.intr.vscale"() : () -> i8 + %1 = llvm.zext %0 : i8 to i32 + llvm.return %1 : i32 + } + llvm.func @vscale_SExt_i8toi32_unbounded() -> i32 vscale_range(1, 0) { + %0 = "llvm.intr.vscale"() : () -> i8 + %1 = llvm.sext %0 : i8 to i32 + llvm.return %1 : i32 + } + llvm.func @vscale_ZExt_i8toi32_unbounded() -> i32 vscale_range(1, 0) { + %0 = "llvm.intr.vscale"() : () -> i8 + %1 = llvm.zext %0 : i8 to i32 + llvm.return %1 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/vscale_trunc.ll.mlir b/test/LLVMDialect/InstCombine/vscale_trunc.ll.mlir new file mode 100644 index 000000000..10d5dde7e --- /dev/null +++ b/test/LLVMDialect/InstCombine/vscale_trunc.ll.mlir @@ -0,0 +1,17 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @vscale_trunc_i32toi8() -> i8 vscale_range(1, 128) { + %0 = "llvm.intr.vscale"() : () -> i32 + %1 = llvm.trunc %0 : i32 to i8 + llvm.return %1 : i8 + } + llvm.func @vscale_trunc_i32toi8_poison() -> i8 vscale_range(1, 256) { + %0 = "llvm.intr.vscale"() : () -> i32 + %1 = llvm.trunc %0 : i32 to i8 + llvm.return %1 : i8 + } + llvm.func @vscale_trunc_i32toi8_noAttr() -> i8 { + %0 = "llvm.intr.vscale"() : () -> i32 + %1 = llvm.trunc %0 : i32 to i8 + llvm.return %1 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/vscale_zero.ll.mlir b/test/LLVMDialect/InstCombine/vscale_zero.ll.mlir new file mode 100644 index 000000000..0204edb2a --- /dev/null +++ b/test/LLVMDialect/InstCombine/vscale_zero.ll.mlir @@ -0,0 +1,14 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @iszero() -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = "llvm.intr.vscale"() : () -> i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } + llvm.func @iszero_range() -> i1 vscale_range(1, 16) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = "llvm.intr.vscale"() : () -> i32 + %2 = llvm.icmp "eq" %1, %0 : i32 + llvm.return %2 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/wcslen-1.ll.mlir b/test/LLVMDialect/InstCombine/wcslen-1.ll.mlir new file mode 100644 index 000000000..cc4d9eefe --- /dev/null +++ b/test/LLVMDialect/InstCombine/wcslen-1.ll.mlir @@ -0,0 +1,170 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} { + llvm.mlir.global external constant @hello(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi32>) {addr_space = 0 : i32} : !llvm.array<6 x i32> + llvm.mlir.global external constant @longer(dense<[108, 111, 110, 103, 101, 114, 0]> : tensor<7xi32>) {addr_space = 0 : i32} : !llvm.array<7 x i32> + llvm.mlir.global external constant @null(dense<0> : tensor<1xi32>) {addr_space = 0 : i32} : !llvm.array<1 x i32> + llvm.mlir.global external constant @null_hello(dense<[0, 104, 101, 108, 108, 111, 0]> : tensor<7xi32>) {addr_space = 0 : i32} : !llvm.array<7 x i32> + llvm.mlir.global external constant @nullstring(0 : i32) {addr_space = 0 : i32} : i32 + llvm.mlir.global common @a(dense<0> : tensor<32xi32>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i32> + llvm.mlir.global external constant @null_hello_mid(dense<[104, 101, 108, 108, 111, 32, 119, 111, 114, 0, 108, 100, 0]> : tensor<13xi32>) {addr_space = 0 : i32} : !llvm.array<13 x i32> + llvm.mlir.global external constant @str16(dense<0> : tensor<1xi16>) {addr_space = 0 : i32} : !llvm.array<1 x i16> + llvm.mlir.global external constant @ws(dense<[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]> : tensor<10xi32>) {addr_space = 0 : i32} : !llvm.array<10 x i32> + llvm.mlir.global external constant @s8("\09\08\07\06\05\04\03\02\01\00") {addr_space = 0 : i32} + llvm.func @wcslen(!llvm.ptr) -> i64 + llvm.func @test_simplify1() -> i64 { + %0 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi32>) : !llvm.array<6 x i32> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.call @wcslen(%1) : (!llvm.ptr) -> i64 + llvm.return %2 : i64 + } + llvm.func @test_simplify2() -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi32>) : !llvm.array<1 x i32> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @wcslen(%2) : (!llvm.ptr) -> i64 + llvm.return %3 : i64 + } + llvm.func @test_simplify3() -> i64 { + %0 = llvm.mlir.constant(dense<[0, 104, 101, 108, 108, 111, 0]> : tensor<7xi32>) : !llvm.array<7 x i32> + %1 = llvm.mlir.addressof @null_hello : !llvm.ptr + %2 = llvm.call @wcslen(%1) : (!llvm.ptr) -> i64 + llvm.return %2 : i64 + } + llvm.func @test_simplify4() -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @nullstring : !llvm.ptr + %2 = llvm.call @wcslen(%1) : (!llvm.ptr) -> i64 + llvm.return %2 : i64 + } + llvm.func @test_simplify5() -> i1 { + %0 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi32>) : !llvm.array<6 x i32> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.call @wcslen(%1) : (!llvm.ptr) -> i64 + %4 = llvm.icmp "eq" %3, %2 : i64 + llvm.return %4 : i1 + } + llvm.func @test_simplify6(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @wcslen(%arg0) : (!llvm.ptr) -> i64 + %2 = llvm.icmp "eq" %1, %0 : i64 + llvm.return %2 : i1 + } + llvm.func @test_simplify7() -> i1 { + %0 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi32>) : !llvm.array<6 x i32> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.call @wcslen(%1) : (!llvm.ptr) -> i64 + %4 = llvm.icmp "ne" %3, %2 : i64 + llvm.return %4 : i1 + } + llvm.func @test_simplify8(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @wcslen(%arg0) : (!llvm.ptr) -> i64 + %2 = llvm.icmp "ne" %1, %0 : i64 + llvm.return %2 : i1 + } + llvm.func @test_simplify9(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi32>) : !llvm.array<6 x i32> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(dense<[108, 111, 110, 103, 101, 114, 0]> : tensor<7xi32>) : !llvm.array<7 x i32> + %3 = llvm.mlir.addressof @longer : !llvm.ptr + %4 = llvm.select %arg0, %1, %3 : i1, !llvm.ptr + %5 = llvm.call @wcslen(%4) : (!llvm.ptr) -> i64 + llvm.return %5 : i64 + } + llvm.func @test_simplify10(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi32>) : !llvm.array<6 x i32> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<6 x i32> + %4 = llvm.call @wcslen(%3) : (!llvm.ptr) -> i64 + llvm.return %4 : i64 + } + llvm.func @test_simplify11(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 32, 119, 111, 114, 0, 108, 100, 0]> : tensor<13xi32>) : !llvm.array<13 x i32> + %2 = llvm.mlir.addressof @null_hello_mid : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.getelementptr inbounds %2[%3, %4] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<13 x i32> + %6 = llvm.call @wcslen(%5) : (!llvm.ptr) -> i64 + llvm.return %6 : i64 + } + llvm.func @test_no_simplify1() -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi32>) : !llvm.array<32 x i32> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.call @wcslen(%2) : (!llvm.ptr) -> i64 + llvm.return %3 : i64 + } + llvm.func @test_no_simplify2(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(dense<[0, 104, 101, 108, 108, 111, 0]> : tensor<7xi32>) : !llvm.array<7 x i32> + %1 = llvm.mlir.addressof @null_hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<7 x i32> + %4 = llvm.call @wcslen(%3) : (!llvm.ptr) -> i64 + llvm.return %4 : i64 + } + llvm.func @test_no_simplify2_no_null_opt(%arg0: i32) -> i64 attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.constant(dense<[0, 104, 101, 108, 108, 111, 0]> : tensor<7xi32>) : !llvm.array<7 x i32> + %1 = llvm.mlir.addressof @null_hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<7 x i32> + %4 = llvm.call @wcslen(%3) : (!llvm.ptr) -> i64 + llvm.return %4 : i64 + } + llvm.func @test_no_simplify3(%arg0: i32) -> i64 { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 32, 119, 111, 114, 0, 108, 100, 0]> : tensor<13xi32>) : !llvm.array<13 x i32> + %2 = llvm.mlir.addressof @null_hello_mid : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.getelementptr inbounds %2[%3, %4] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<13 x i32> + %6 = llvm.call @wcslen(%5) : (!llvm.ptr) -> i64 + llvm.return %6 : i64 + } + llvm.func @test_no_simplify3_no_null_opt(%arg0: i32) -> i64 attributes {passthrough = ["null_pointer_is_valid"]} { + %0 = llvm.mlir.constant(15 : i32) : i32 + %1 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 32, 119, 111, 114, 0, 108, 100, 0]> : tensor<13xi32>) : !llvm.array<13 x i32> + %2 = llvm.mlir.addressof @null_hello_mid : !llvm.ptr + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.and %arg0, %0 : i32 + %5 = llvm.getelementptr inbounds %2[%3, %4] : (!llvm.ptr, i32, i32) -> !llvm.ptr, !llvm.array<13 x i32> + %6 = llvm.call @wcslen(%5) : (!llvm.ptr) -> i64 + llvm.return %6 : i64 + } + llvm.func @test_simplify12() -> i64 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi16>) : !llvm.array<1 x i16> + %2 = llvm.mlir.addressof @str16 : !llvm.ptr + %3 = llvm.call @wcslen(%2) : (!llvm.ptr) -> i64 + llvm.return %3 : i64 + } + llvm.func @fold_wcslen_1() -> i64 { + %0 = llvm.mlir.constant(dense<[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]> : tensor<10xi32>) : !llvm.array<10 x i32> + %1 = llvm.mlir.addressof @ws : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(2 : i64) : i64 + %4 = llvm.getelementptr inbounds %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<10 x i32> + %5 = llvm.call @wcslen(%4) : (!llvm.ptr) -> i64 + llvm.return %5 : i64 + } + llvm.func @no_fold_wcslen_1() -> i64 { + %0 = llvm.mlir.constant(dense<[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]> : tensor<10xi32>) : !llvm.array<10 x i32> + %1 = llvm.mlir.addressof @ws : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(3 : i64) : i64 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<15 x i8> + %5 = llvm.call @wcslen(%4) : (!llvm.ptr) -> i64 + llvm.return %5 : i64 + } + llvm.func @no_fold_wcslen_2() -> i64 { + %0 = llvm.mlir.constant("\09\08\07\06\05\04\03\02\01\00") : !llvm.array<10 x i8> + %1 = llvm.mlir.addressof @s8 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(3 : i64) : i64 + %4 = llvm.getelementptr %1[%2, %3] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<10 x i8> + %5 = llvm.call @wcslen(%4) : (!llvm.ptr) -> i64 + llvm.return %5 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/wcslen-2.ll.mlir b/test/LLVMDialect/InstCombine/wcslen-2.ll.mlir index 9bddeabbf..dc249f7f6 100644 --- a/test/LLVMDialect/InstCombine/wcslen-2.ll.mlir +++ b/test/LLVMDialect/InstCombine/wcslen-2.ll.mlir @@ -1,15 +1,11 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello", type = !llvm.array<6 x i32>, value = dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi32>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "wcslen", type = !llvm.func, i32)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 187 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.call"(%3, %0) {callee = @wcslen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, i32) -> i64 - "llvm.return"(%4) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi32>) {addr_space = 0 : i32} : !llvm.array<6 x i32> + llvm.func @wcslen(!llvm.ptr, i32) -> i64 + llvm.func @test_no_simplify1() -> i64 { + %0 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi32>) : !llvm.array<6 x i32> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(187 : i32) : i32 + %3 = llvm.call @wcslen(%1, %2) : (!llvm.ptr, i32) -> i64 + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/wcslen-3.ll.mlir b/test/LLVMDialect/InstCombine/wcslen-3.ll.mlir new file mode 100644 index 000000000..71b1fbbec --- /dev/null +++ b/test/LLVMDialect/InstCombine/wcslen-3.ll.mlir @@ -0,0 +1,123 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi16>) {addr_space = 0 : i32} : !llvm.array<6 x i16> + llvm.mlir.global external constant @longer(dense<[108, 111, 110, 103, 101, 114, 0]> : tensor<7xi16>) {addr_space = 0 : i32} : !llvm.array<7 x i16> + llvm.mlir.global external constant @null(dense<0> : tensor<1xi16>) {addr_space = 0 : i32} : !llvm.array<1 x i16> + llvm.mlir.global external constant @null_hello(dense<[0, 104, 101, 108, 108, 111, 0]> : tensor<7xi16>) {addr_space = 0 : i32} : !llvm.array<7 x i16> + llvm.mlir.global external constant @nullstring(0 : i16) {addr_space = 0 : i32} : i16 + llvm.mlir.global common @a(dense<0> : tensor<32xi16>) {addr_space = 0 : i32, alignment = 1 : i64} : !llvm.array<32 x i16> + llvm.mlir.global external constant @null_hello_mid(dense<[104, 101, 108, 108, 111, 32, 119, 111, 114, 0, 108, 100, 0]> : tensor<13xi16>) {addr_space = 0 : i32} : !llvm.array<13 x i16> + llvm.mlir.global external constant @str32(dense<0> : tensor<1xi32>) {addr_space = 0 : i32} : !llvm.array<1 x i32> + llvm.func @wcslen(!llvm.ptr) -> i64 + llvm.func @test_simplify1() -> i64 { + %0 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi16>) : !llvm.array<6 x i16> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.call @wcslen(%1) : (!llvm.ptr) -> i64 + llvm.return %2 : i64 + } + llvm.func @test_simplify2() -> i64 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi16>) : !llvm.array<1 x i16> + %2 = llvm.mlir.addressof @null : !llvm.ptr + %3 = llvm.call @wcslen(%2) : (!llvm.ptr) -> i64 + llvm.return %3 : i64 + } + llvm.func @test_simplify3() -> i64 { + %0 = llvm.mlir.constant(dense<[0, 104, 101, 108, 108, 111, 0]> : tensor<7xi16>) : !llvm.array<7 x i16> + %1 = llvm.mlir.addressof @null_hello : !llvm.ptr + %2 = llvm.call @wcslen(%1) : (!llvm.ptr) -> i64 + llvm.return %2 : i64 + } + llvm.func @test_simplify4() -> i64 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.addressof @nullstring : !llvm.ptr + %2 = llvm.call @wcslen(%1) : (!llvm.ptr) -> i64 + llvm.return %2 : i64 + } + llvm.func @test_simplify5() -> i1 { + %0 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi16>) : !llvm.array<6 x i16> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.call @wcslen(%1) : (!llvm.ptr) -> i64 + %4 = llvm.icmp "eq" %3, %2 : i64 + llvm.return %4 : i1 + } + llvm.func @test_simplify6(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @wcslen(%arg0) : (!llvm.ptr) -> i64 + %2 = llvm.icmp "eq" %1, %0 : i64 + llvm.return %2 : i1 + } + llvm.func @test_simplify7() -> i1 { + %0 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi16>) : !llvm.array<6 x i16> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.call @wcslen(%1) : (!llvm.ptr) -> i64 + %4 = llvm.icmp "ne" %3, %2 : i64 + llvm.return %4 : i1 + } + llvm.func @test_simplify8(%arg0: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.call @wcslen(%arg0) : (!llvm.ptr) -> i64 + %2 = llvm.icmp "ne" %1, %0 : i64 + llvm.return %2 : i1 + } + llvm.func @test_simplify9(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi16>) : !llvm.array<6 x i16> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(dense<[108, 111, 110, 103, 101, 114, 0]> : tensor<7xi16>) : !llvm.array<7 x i16> + %3 = llvm.mlir.addressof @longer : !llvm.ptr + %4 = llvm.select %arg0, %1, %3 : i1, !llvm.ptr + %5 = llvm.call @wcslen(%4) : (!llvm.ptr) -> i64 + llvm.return %5 : i64 + } + llvm.func @test_simplify10(%arg0: i16) -> i64 { + %0 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi16>) : !llvm.array<6 x i16> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i16) : i16 + %3 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i16, i16) -> !llvm.ptr, !llvm.array<6 x i16> + %4 = llvm.call @wcslen(%3) : (!llvm.ptr) -> i64 + llvm.return %4 : i64 + } + llvm.func @test_simplify11(%arg0: i16) -> i64 { + %0 = llvm.mlir.constant(7 : i16) : i16 + %1 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 32, 119, 111, 114, 0, 108, 100, 0]> : tensor<13xi16>) : !llvm.array<13 x i16> + %2 = llvm.mlir.addressof @null_hello_mid : !llvm.ptr + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.and %arg0, %0 : i16 + %5 = llvm.getelementptr inbounds %2[%3, %4] : (!llvm.ptr, i16, i16) -> !llvm.ptr, !llvm.array<13 x i16> + %6 = llvm.call @wcslen(%5) : (!llvm.ptr) -> i64 + llvm.return %6 : i64 + } + llvm.func @test_no_simplify1() -> i64 { + %0 = llvm.mlir.constant(0 : i16) : i16 + %1 = llvm.mlir.constant(dense<0> : tensor<32xi16>) : !llvm.array<32 x i16> + %2 = llvm.mlir.addressof @a : !llvm.ptr + %3 = llvm.call @wcslen(%2) : (!llvm.ptr) -> i64 + llvm.return %3 : i64 + } + llvm.func @test_no_simplify2(%arg0: i16) -> i64 { + %0 = llvm.mlir.constant(dense<[0, 104, 101, 108, 108, 111, 0]> : tensor<7xi16>) : !llvm.array<7 x i16> + %1 = llvm.mlir.addressof @null_hello : !llvm.ptr + %2 = llvm.mlir.constant(0 : i16) : i16 + %3 = llvm.getelementptr inbounds %1[%2, %arg0] : (!llvm.ptr, i16, i16) -> !llvm.ptr, !llvm.array<7 x i16> + %4 = llvm.call @wcslen(%3) : (!llvm.ptr) -> i64 + llvm.return %4 : i64 + } + llvm.func @test_no_simplify3(%arg0: i16) -> i64 { + %0 = llvm.mlir.constant(15 : i16) : i16 + %1 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 32, 119, 111, 114, 0, 108, 100, 0]> : tensor<13xi16>) : !llvm.array<13 x i16> + %2 = llvm.mlir.addressof @null_hello_mid : !llvm.ptr + %3 = llvm.mlir.constant(0 : i16) : i16 + %4 = llvm.and %arg0, %0 : i16 + %5 = llvm.getelementptr inbounds %2[%3, %4] : (!llvm.ptr, i16, i16) -> !llvm.ptr, !llvm.array<13 x i16> + %6 = llvm.call @wcslen(%5) : (!llvm.ptr) -> i64 + llvm.return %6 : i64 + } + llvm.func @test_no_simplify4() -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(dense<0> : tensor<1xi32>) : !llvm.array<1 x i32> + %2 = llvm.mlir.addressof @str32 : !llvm.ptr + %3 = llvm.call @wcslen(%2) : (!llvm.ptr) -> i64 + llvm.return %3 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/wcslen-4.ll.mlir b/test/LLVMDialect/InstCombine/wcslen-4.ll.mlir index 52e1f043e..4d0c3b3ea 100644 --- a/test/LLVMDialect/InstCombine/wcslen-4.ll.mlir +++ b/test/LLVMDialect/InstCombine/wcslen-4.ll.mlir @@ -1,14 +1,10 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 10 : i64, sym_name = "hello", type = !llvm.array<6 x i32>, value = dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi32>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "wcslen", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %1 = "llvm.mlir.addressof"() {global_name = @hello} : () -> !llvm.ptr> - %2 = "llvm.getelementptr"(%1, %0, %0) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %3 = "llvm.call"(%2) {callee = @wcslen, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr) -> i64 - "llvm.return"(%3) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "test_no_simplify1", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @hello(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi32>) {addr_space = 0 : i32} : !llvm.array<6 x i32> + llvm.func @wcslen(!llvm.ptr) -> i64 + llvm.func @test_no_simplify1() -> i64 { + %0 = llvm.mlir.constant(dense<[104, 101, 108, 108, 111, 0]> : tensor<6xi32>) : !llvm.array<6 x i32> + %1 = llvm.mlir.addressof @hello : !llvm.ptr + %2 = llvm.call @wcslen(%1) : (!llvm.ptr) -> i64 + llvm.return %2 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/wcslen-5.ll.mlir b/test/LLVMDialect/InstCombine/wcslen-5.ll.mlir new file mode 100644 index 000000000..c8d00a53b --- /dev/null +++ b/test/LLVMDialect/InstCombine/wcslen-5.ll.mlir @@ -0,0 +1,86 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @ws3(dense<[1, 2, 3, 0]> : tensor<4xi32>) {addr_space = 0 : i32} : !llvm.array<4 x i32> + llvm.mlir.global external constant @ws5(dense<[1, 2, 3, 4, 5, 0]> : tensor<6xi32>) {addr_space = 0 : i32} : !llvm.array<6 x i32> + llvm.mlir.global external constant @ws5_3(dense<[1, 2, 3, 4, 5, 0, 6, 7, 8, 0]> : tensor<10xi32>) {addr_space = 0 : i32} : !llvm.array<10 x i32> + llvm.func @wcslen(!llvm.ptr) -> i64 + llvm.func @fold_wcslen_s3_pi_s5(%arg0: i1 {llvm.zeroext}, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 0]> : tensor<4xi32>) : !llvm.array<4 x i32> + %1 = llvm.mlir.addressof @ws3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(dense<[1, 2, 3, 4, 5, 0]> : tensor<6xi32>) : !llvm.array<6 x i32> + %4 = llvm.mlir.addressof @ws5 : !llvm.ptr + %5 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i32> + %6 = llvm.select %arg0, %5, %4 : i1, !llvm.ptr + %7 = llvm.call @wcslen(%6) : (!llvm.ptr) -> i64 + llvm.return %7 : i64 + } + llvm.func @fold_wcslen_s3_pi_p1_s5(%arg0: i1 {llvm.zeroext}, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 0]> : tensor<4xi32>) : !llvm.array<4 x i32> + %1 = llvm.mlir.addressof @ws3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(1 : i64) : i64 + %4 = llvm.mlir.constant(dense<[1, 2, 3, 4, 5, 0]> : tensor<6xi32>) : !llvm.array<6 x i32> + %5 = llvm.mlir.addressof @ws5 : !llvm.ptr + %6 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i32> + %7 = llvm.getelementptr inbounds %6[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i32 + %8 = llvm.select %arg0, %7, %5 : i1, !llvm.ptr + %9 = llvm.call @wcslen(%8) : (!llvm.ptr) -> i64 + llvm.return %9 : i64 + } + llvm.func @call_wcslen_s5_3_pi_s5(%arg0: i1 {llvm.zeroext}, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4, 5, 0, 6, 7, 8, 0]> : tensor<10xi32>) : !llvm.array<10 x i32> + %1 = llvm.mlir.addressof @ws5_3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(dense<[1, 2, 3, 4, 5, 0]> : tensor<6xi32>) : !llvm.array<6 x i32> + %4 = llvm.mlir.addressof @ws5 : !llvm.ptr + %5 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<10 x i32> + %6 = llvm.select %arg0, %5, %4 : i1, !llvm.ptr + %7 = llvm.call @wcslen(%6) : (!llvm.ptr) -> i64 + llvm.return %7 : i64 + } + llvm.func @call_wcslen_s5_3_s5_pj(%arg0: i1 {llvm.zeroext}, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4, 5, 0]> : tensor<6xi32>) : !llvm.array<6 x i32> + %1 = llvm.mlir.addressof @ws5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(dense<[1, 2, 3, 4, 5, 0, 6, 7, 8, 0]> : tensor<10xi32>) : !llvm.array<10 x i32> + %4 = llvm.mlir.addressof @ws5_3 : !llvm.ptr + %5 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<6 x i32> + %6 = llvm.select %arg0, %4, %5 : i1, !llvm.ptr + %7 = llvm.call @wcslen(%6) : (!llvm.ptr) -> i64 + llvm.return %7 : i64 + } + llvm.func @fold_wcslen_s3_s5_pj(%arg0: i1 {llvm.zeroext}, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4, 5, 0]> : tensor<6xi32>) : !llvm.array<6 x i32> + %1 = llvm.mlir.addressof @ws5 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(dense<[1, 2, 3, 0]> : tensor<4xi32>) : !llvm.array<4 x i32> + %4 = llvm.mlir.addressof @ws3 : !llvm.ptr + %5 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<6 x i32> + %6 = llvm.select %arg0, %4, %5 : i1, !llvm.ptr + %7 = llvm.call @wcslen(%6) : (!llvm.ptr) -> i64 + llvm.return %7 : i64 + } + llvm.func @call_wcslen_s3_s5_3_pj(%arg0: i1 {llvm.zeroext}, %arg1: i64) -> i64 { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4, 5, 0, 6, 7, 8, 0]> : tensor<10xi32>) : !llvm.array<10 x i32> + %1 = llvm.mlir.addressof @ws5_3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(dense<[1, 2, 3, 0]> : tensor<4xi32>) : !llvm.array<4 x i32> + %4 = llvm.mlir.addressof @ws3 : !llvm.ptr + %5 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<10 x i32> + %6 = llvm.select %arg0, %4, %5 : i1, !llvm.ptr + %7 = llvm.call @wcslen(%6) : (!llvm.ptr) -> i64 + llvm.return %7 : i64 + } + llvm.func @fold_wcslen_s3_pi_s5_pj(%arg0: i1 {llvm.zeroext}, %arg1: i64, %arg2: i64) -> i64 { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 0]> : tensor<4xi32>) : !llvm.array<4 x i32> + %1 = llvm.mlir.addressof @ws3 : !llvm.ptr + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(dense<[1, 2, 3, 4, 5, 0]> : tensor<6xi32>) : !llvm.array<6 x i32> + %4 = llvm.mlir.addressof @ws5 : !llvm.ptr + %5 = llvm.getelementptr inbounds %1[%2, %arg1] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<4 x i32> + %6 = llvm.getelementptr inbounds %4[%2, %arg2] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<6 x i32> + %7 = llvm.select %arg0, %5, %6 : i1, !llvm.ptr + %8 = llvm.call @wcslen(%7) : (!llvm.ptr) -> i64 + llvm.return %8 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/wcslen-6.ll.mlir b/test/LLVMDialect/InstCombine/wcslen-6.ll.mlir new file mode 100644 index 000000000..4ebc8daf6 --- /dev/null +++ b/test/LLVMDialect/InstCombine/wcslen-6.ll.mlir @@ -0,0 +1,44 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external constant @af(dense<[1.231200e+00, 0.000000e+00]> : tensor<2xf32>) {addr_space = 0 : i32} : !llvm.array<2 x f32> + llvm.mlir.global external constant @aS() {addr_space = 0 : i32} : !llvm.array<3 x struct<"struct.S", (i32)>> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.struct<"struct.S", (i32)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<"struct.S", (i32)> + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"struct.S", (i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.S", (i32)> + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.mlir.undef : !llvm.struct<"struct.S", (i32)> + %8 = llvm.insertvalue %6, %7[0] : !llvm.struct<"struct.S", (i32)> + %9 = llvm.mlir.undef : !llvm.array<3 x struct<"struct.S", (i32)>> + %10 = llvm.insertvalue %8, %9[0] : !llvm.array<3 x struct<"struct.S", (i32)>> + %11 = llvm.insertvalue %5, %10[1] : !llvm.array<3 x struct<"struct.S", (i32)>> + %12 = llvm.insertvalue %2, %11[2] : !llvm.array<3 x struct<"struct.S", (i32)>> + llvm.return %12 : !llvm.array<3 x struct<"struct.S", (i32)>> + } + llvm.func @wcslen(!llvm.ptr) -> i64 + llvm.func @fold_af() -> i64 { + %0 = llvm.mlir.constant(dense<[1.231200e+00, 0.000000e+00]> : tensor<2xf32>) : !llvm.array<2 x f32> + %1 = llvm.mlir.addressof @af : !llvm.ptr + %2 = llvm.call @wcslen(%1) : (!llvm.ptr) -> i64 + llvm.return %2 : i64 + } + llvm.func @fold_aS() -> i64 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.undef : !llvm.struct<"struct.S", (i32)> + %2 = llvm.insertvalue %0, %1[0] : !llvm.struct<"struct.S", (i32)> + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.mlir.undef : !llvm.struct<"struct.S", (i32)> + %5 = llvm.insertvalue %3, %4[0] : !llvm.struct<"struct.S", (i32)> + %6 = llvm.mlir.constant(2 : i32) : i32 + %7 = llvm.mlir.undef : !llvm.struct<"struct.S", (i32)> + %8 = llvm.insertvalue %6, %7[0] : !llvm.struct<"struct.S", (i32)> + %9 = llvm.mlir.undef : !llvm.array<3 x struct<"struct.S", (i32)>> + %10 = llvm.insertvalue %8, %9[0] : !llvm.array<3 x struct<"struct.S", (i32)>> + %11 = llvm.insertvalue %5, %10[1] : !llvm.array<3 x struct<"struct.S", (i32)>> + %12 = llvm.insertvalue %2, %11[2] : !llvm.array<3 x struct<"struct.S", (i32)>> + %13 = llvm.mlir.addressof @aS : !llvm.ptr + %14 = llvm.call @wcslen(%13) : (!llvm.ptr) -> i64 + llvm.return %14 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/weak-symbols.ll.mlir b/test/LLVMDialect/InstCombine/weak-symbols.ll.mlir index ac9446fea..57d47598e 100644 --- a/test/LLVMDialect/InstCombine/weak-symbols.ll.mlir +++ b/test/LLVMDialect/InstCombine/weak-symbols.ll.mlir @@ -1,29 +1,20 @@ -"module"() ( { - "llvm.mlir.global"() ( { - }) {constant, linkage = 9 : i64, sym_name = "real_init", type = !llvm.array<2 x i8>, value = "y\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 4 : i64, sym_name = "fake_init", type = !llvm.array<2 x i8>, value = "y\00"} : () -> () - "llvm.mlir.global"() ( { - }) {constant, linkage = 0 : i64, sym_name = ".str", type = !llvm.array<2 x i8>, value = "y\00"} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @fake_init} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.getelementptr"(%0, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%3, %4) {callee = @strcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "foo", type = !llvm.func} : () -> () - "llvm.func"() ( { - %0 = "llvm.mlir.addressof"() {global_name = @".str"} : () -> !llvm.ptr> - %1 = "llvm.mlir.constant"() {value = 0 : i64} : () -> i64 - %2 = "llvm.mlir.addressof"() {global_name = @real_init} : () -> !llvm.ptr> - %3 = "llvm.getelementptr"(%2, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %4 = "llvm.getelementptr"(%0, %1, %1) : (!llvm.ptr>, i64, i64) -> !llvm.ptr - %5 = "llvm.call"(%3, %4) {callee = @strcmp, fastmathFlags = #llvm.fastmath<>} : (!llvm.ptr, !llvm.ptr) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "bar", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "strcmp", type = !llvm.func, ptr)>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global weak_odr constant @real_init("y\00") {addr_space = 0 : i32} + llvm.mlir.global weak constant @fake_init("y\00") {addr_space = 0 : i32} + llvm.mlir.global private constant @".str"("y\00") {addr_space = 0 : i32, dso_local} + llvm.func @foo() -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant("y\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @fake_init : !llvm.ptr + %2 = llvm.mlir.addressof @".str" : !llvm.ptr + %3 = llvm.call @strcmp(%1, %2) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %3 : i32 + } + llvm.func @bar() -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant("y\00") : !llvm.array<2 x i8> + %1 = llvm.mlir.addressof @real_init : !llvm.ptr + %2 = llvm.mlir.addressof @".str" : !llvm.ptr + %3 = llvm.call @strcmp(%1, %2) : (!llvm.ptr, !llvm.ptr) -> i32 + llvm.return %3 : i32 + } + llvm.func @strcmp(!llvm.ptr, !llvm.ptr) -> i32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} +} diff --git a/test/LLVMDialect/InstCombine/widenable-conditions.ll.mlir b/test/LLVMDialect/InstCombine/widenable-conditions.ll.mlir new file mode 100644 index 000000000..e69de29bb diff --git a/test/LLVMDialect/InstCombine/win-math.ll.mlir b/test/LLVMDialect/InstCombine/win-math.ll.mlir index e6ccc3ff8..6660f9d3e 100644 --- a/test/LLVMDialect/InstCombine/win-math.ll.mlir +++ b/test/LLVMDialect/InstCombine/win-math.ll.mlir @@ -1,205 +1,160 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "acos", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @acos, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_acos", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "asin", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @asin, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_asin", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atan", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @atan, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_atan", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "atan2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.fpext"(%arg1) : (f32) -> f64 - %2 = "llvm.call"(%0, %1) {callee = @atan2, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %3 = "llvm.fptrunc"(%2) : (f64) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_atan2", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "ceil", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @ceil, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_ceil", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "_copysign", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @_copysign, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_copysign", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "cos", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @cos, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_cos", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "cosh", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @cosh, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_cosh", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "exp", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.fpext"(%arg1) : (f32) -> f64 - %2 = "llvm.call"(%0, %1) {callee = @exp, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %3 = "llvm.fptrunc"(%2) : (f64) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_exp", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fabs", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.fpext"(%arg1) : (f32) -> f64 - %2 = "llvm.call"(%0, %1) {callee = @fabs, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %3 = "llvm.fptrunc"(%2) : (f64) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_fabs", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "floor", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @floor, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_floor", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fmod", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.fpext"(%arg1) : (f32) -> f64 - %2 = "llvm.call"(%0, %1) {callee = @fmod, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %3 = "llvm.fptrunc"(%2) : (f64) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_fmod", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "log", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @log, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_log", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "logb", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @logb, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_logb", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "pow", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32, %arg1: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.fpext"(%arg1) : (f32) -> f64 - %2 = "llvm.call"(%0, %1) {callee = @pow, fastmathFlags = #llvm.fastmath<>} : (f64, f64) -> f64 - %3 = "llvm.fptrunc"(%2) : (f64) -> f32 - "llvm.return"(%3) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_pow", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sin", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @sin, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_sin", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sinh", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @sinh, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_sinh", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "sqrt", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @sqrt, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_sqrt", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "tan", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @tan, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_tan", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "tanh", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @tanh, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_tanh", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "round", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.fpext"(%arg0) : (f32) -> f64 - %1 = "llvm.call"(%0) {callee = @round, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fptrunc"(%1) : (f64) -> f32 - "llvm.return"(%2) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_round", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "powf", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 5.000000e-01 : f32} : () -> f32 - %1 = "llvm.call"(%arg0, %0) {callee = @powf, fastmathFlags = #llvm.fastmath<>} : (f32, f32) -> f32 - "llvm.return"(%1) : (f32) -> () - }) {linkage = 10 : i64, sym_name = "float_powsqrt", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @acos(f64) -> f64 + llvm.func @float_acos(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @acos(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @asin(f64) -> f64 + llvm.func @float_asin(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @asin(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @atan(f64) -> f64 + llvm.func @float_atan(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @atan(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @atan2(f64, f64) -> f64 + llvm.func @float_atan2(%arg0: f32, %arg1: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @atan2(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @ceil(f64) -> f64 + llvm.func @float_ceil(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @ceil(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @_copysign(f64) -> f64 + llvm.func @float_copysign(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @_copysign(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @cos(f64) -> f64 + llvm.func @float_cos(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @cos(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @cosh(f64) -> f64 + llvm.func @float_cosh(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @cosh(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @exp(f64, f64) -> f64 + llvm.func @float_exp(%arg0: f32, %arg1: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @exp(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @fabs(f64, f64) -> f64 + llvm.func @float_fabs(%arg0: f32, %arg1: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @fabs(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @floor(f64) -> f64 + llvm.func @float_floor(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @floor(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @fmod(f64, f64) -> f64 + llvm.func @float_fmod(%arg0: f32, %arg1: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @fmod(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @log(f64) -> f64 + llvm.func @float_log(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @log(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @logb(f64) -> f64 + llvm.func @float_logb(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @logb(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @pow(f64, f64) -> f64 + llvm.func @float_pow(%arg0: f32, %arg1: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.fpext %arg1 : f32 to f64 + %2 = llvm.call @pow(%0, %1) : (f64, f64) -> f64 + %3 = llvm.fptrunc %2 : f64 to f32 + llvm.return %3 : f32 + } + llvm.func @sin(f64) -> f64 + llvm.func @float_sin(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @sin(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @sinh(f64) -> f64 + llvm.func @float_sinh(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @sinh(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @sqrt(f64) -> f64 + llvm.func @float_sqrt(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @sqrt(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @tan(f64) -> f64 + llvm.func @float_tan(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @tan(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @tanh(f64) -> f64 + llvm.func @float_tanh(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @tanh(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @round(f64) -> f64 + llvm.func @float_round(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.fpext %arg0 : f32 to f64 + %1 = llvm.call @round(%0) : (f64) -> f64 + %2 = llvm.fptrunc %1 : f64 to f32 + llvm.return %2 : f32 + } + llvm.func @powf(f32, f32) -> f32 + llvm.func @float_powsqrt(%arg0: f32) -> f32 attributes {memory = #llvm.memory_effects, passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(5.000000e-01 : f32) : f32 + %1 = llvm.call @powf(%arg0, %0) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + llvm.return %1 : f32 + } +} diff --git a/test/LLVMDialect/InstCombine/with_overflow.ll.mlir b/test/LLVMDialect/InstCombine/with_overflow.ll.mlir new file mode 100644 index 000000000..da79203d7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/with_overflow.ll.mlir @@ -0,0 +1,673 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @uaddtest1(%arg0: i8, %arg1: i8) -> i8 { + %0 = "llvm.intr.uadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %1 = llvm.extractvalue %0[0] : !llvm.struct<(i8, i1)> + llvm.return %1 : i8 + } + llvm.func @uaddtest2(%arg0: i8, %arg1: i8, %arg2: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.and %arg1, %0 : i8 + %3 = "llvm.intr.uadd.with.overflow"(%1, %2) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + llvm.store %5, %arg2 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %4 : i8 + } + llvm.func @uaddtest3(%arg0: i8, %arg1: i8, %arg2: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.or %arg0, %0 : i8 + %2 = llvm.or %arg1, %0 : i8 + %3 = "llvm.intr.uadd.with.overflow"(%1, %2) : (i8, i8) -> !llvm.struct<(i8, i1)> + %4 = llvm.extractvalue %3[0] : !llvm.struct<(i8, i1)> + %5 = llvm.extractvalue %3[1] : !llvm.struct<(i8, i1)> + llvm.store %5, %arg2 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %4 : i8 + } + llvm.func @uaddtest4(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.undef : i8 + %1 = "llvm.intr.uadd.with.overflow"(%0, %arg0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @uaddtest5(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.uadd.with.overflow"(%0, %arg0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @uaddtest6(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.mlir.constant(-4 : i8) : i8 + %1 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.return %2 : i1 + } + llvm.func @uaddtest7(%arg0: i8, %arg1: i8) -> i8 { + %0 = "llvm.intr.uadd.with.overflow"(%arg0, %arg1) : (i8, i8) -> !llvm.struct<(i8, i1)> + %1 = llvm.extractvalue %0[0] : !llvm.struct<(i8, i1)> + llvm.return %1 : i8 + } + llvm.func @saddtest_nsw(%arg0: i8, %arg1: i8) -> !llvm.struct<(i32, i1)> { + %0 = llvm.sext %arg0 : i8 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = "llvm.intr.sadd.with.overflow"(%0, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %2 : !llvm.struct<(i32, i1)> + } + llvm.func @uaddtest_nuw(%arg0: i32, %arg1: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(2147483647 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = "llvm.intr.uadd.with.overflow"(%1, %2) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @ssubtest_nsw(%arg0: i8, %arg1: i8) -> !llvm.struct<(i32, i1)> { + %0 = llvm.sext %arg0 : i8 to i32 + %1 = llvm.sext %arg1 : i8 to i32 + %2 = "llvm.intr.ssub.with.overflow"(%0, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %2 : !llvm.struct<(i32, i1)> + } + llvm.func @usubtest_nuw(%arg0: i32, %arg1: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(2147483647 : i32) : i32 + %2 = llvm.or %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = "llvm.intr.usub.with.overflow"(%2, %3) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %4 : !llvm.struct<(i32, i1)> + } + llvm.func @smultest1_nsw(%arg0: i32, %arg1: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(4095 : i32) : i32 + %1 = llvm.mlir.constant(524287 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = "llvm.intr.smul.with.overflow"(%2, %3) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %4 : !llvm.struct<(i32, i1)> + } + llvm.func @smultest2_nsw(%arg0: i32, %arg1: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.ashr %arg0, %0 : i32 + %2 = llvm.ashr %arg1, %0 : i32 + %3 = "llvm.intr.smul.with.overflow"(%1, %2) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @smultest3_sw(%arg0: i32, %arg1: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(16 : i32) : i32 + %1 = llvm.mlir.constant(15 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.ashr %arg1, %1 : i32 + %4 = "llvm.intr.smul.with.overflow"(%2, %3) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %4 : !llvm.struct<(i32, i1)> + } + llvm.func @umultest_nuw(%arg0: i32, %arg1: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(65535 : i32) : i32 + %1 = llvm.and %arg0, %0 : i32 + %2 = llvm.and %arg1, %0 : i32 + %3 = "llvm.intr.umul.with.overflow"(%1, %2) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @umultest1(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%0, %arg0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @umultest2(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%0, %arg0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @umultest3(%arg0: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = "llvm.intr.umul.with.overflow"(%3, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %4[1] : !llvm.struct<(i32, i1)> + %6 = llvm.extractvalue %4[0] : !llvm.struct<(i32, i1)> + %7 = llvm.select %5, %2, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @umultest4(%arg0: i32) -> i32 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(4 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.lshr %arg0, %0 : i32 + %4 = "llvm.intr.umul.with.overflow"(%3, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %5 = llvm.extractvalue %4[1] : !llvm.struct<(i32, i1)> + %6 = llvm.extractvalue %4[0] : !llvm.struct<(i32, i1)> + %7 = llvm.select %5, %2, %6 : i1, i32 + llvm.return %7 : i32 + } + llvm.func @umultest5(%arg0: i32, %arg1: i32) -> !llvm.struct<(i32, i1)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.or %arg0, %0 : i32 + %2 = llvm.or %arg1, %0 : i32 + %3 = "llvm.intr.umul.with.overflow"(%1, %2) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %3 : !llvm.struct<(i32, i1)> + } + llvm.func @overflow_div_add(%arg0: i32, %arg1: i32) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.sdiv %arg0, %0 : i32 + %3 = "llvm.intr.sadd.with.overflow"(%2, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %4 = llvm.extractvalue %3[1] : !llvm.struct<(i32, i1)> + llvm.return %4 : i1 + } + llvm.func @overflow_div_sub(%arg0: i32, %arg1: i32) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(18 : i32) : i32 + %1 = llvm.mlir.constant(65536 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.ashr %arg0, %0 : i32 + %4 = llvm.sdiv %3, %1 : i32 + %5 = "llvm.intr.ssub.with.overflow"(%4, %2) : (i32, i32) -> !llvm.struct<(i32, i1)> + %6 = llvm.extractvalue %5[1] : !llvm.struct<(i32, i1)> + llvm.return %6 : i1 + } + llvm.func @overflow_mod_mul(%arg0: i32, %arg1: i32) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1000 : i32) : i32 + %1 = llvm.srem %arg0, %0 : i32 + %2 = "llvm.intr.smul.with.overflow"(%1, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + llvm.return %3 : i1 + } + llvm.func @overflow_mod_overflow_mul(%arg0: i32, %arg1: i32) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(65537 : i32) : i32 + %1 = llvm.srem %arg0, %0 : i32 + %2 = "llvm.intr.smul.with.overflow"(%1, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + llvm.return %3 : i1 + } + llvm.func @overflow_mod_mul2(%arg0: i16, %arg1: i32) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.sext %arg0 : i16 to i32 + %1 = llvm.srem %0, %arg1 : i32 + %2 = "llvm.intr.smul.with.overflow"(%1, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + llvm.return %3 : i1 + } + llvm.func @ssubtest_reorder(%arg0: i8) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.sext %arg0 : i8 to i32 + %2 = "llvm.intr.ssub.with.overflow"(%0, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %2 : !llvm.struct<(i32, i1)> + } + llvm.func @never_overflows_ssub_test0(%arg0: i32) -> !llvm.struct<(i32, i1)> { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = "llvm.intr.ssub.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %1 : !llvm.struct<(i32, i1)> + } + llvm.func @uadd_res_ult_x(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = "llvm.intr.uadd.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i32, i1)> + llvm.store %1, %arg2 {alignment = 1 : i64} : i1, !llvm.ptr + %2 = llvm.extractvalue %0[0] : !llvm.struct<(i32, i1)> + %3 = llvm.icmp "ult" %2, %arg0 : i32 + llvm.return %3 : i1 + } + llvm.func @uadd_res_ult_y(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = "llvm.intr.uadd.with.overflow"(%arg0, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %1 = llvm.extractvalue %0[1] : !llvm.struct<(i32, i1)> + llvm.store %1, %arg2 {alignment = 1 : i64} : i1, !llvm.ptr + %2 = llvm.extractvalue %0[0] : !llvm.struct<(i32, i1)> + %3 = llvm.icmp "ult" %2, %arg1 : i32 + llvm.return %3 : i1 + } + llvm.func @uadd_res_ugt_x(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.urem %0, %arg0 : i32 + %2 = "llvm.intr.uadd.with.overflow"(%1, %arg1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + llvm.store %3, %arg2 {alignment = 1 : i64} : i1, !llvm.ptr + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %5 = llvm.icmp "ugt" %1, %4 : i32 + llvm.return %5 : i1 + } + llvm.func @uadd_res_ugt_y(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.urem %0, %arg1 : i32 + %2 = "llvm.intr.uadd.with.overflow"(%arg0, %1) : (i32, i32) -> !llvm.struct<(i32, i1)> + %3 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i1)> + llvm.store %3, %arg2 {alignment = 1 : i64} : i1, !llvm.ptr + %4 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i1)> + %5 = llvm.icmp "ugt" %1, %4 : i32 + llvm.return %5 : i1 + } + llvm.func @uadd_res_ult_const(%arg0: i32, %arg1: !llvm.ptr) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i32, i1)> + llvm.store %2, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i32, i1)> + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @uadd_res_ult_const_one(%arg0: i32, %arg1: !llvm.ptr) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i32, i1)> + llvm.store %2, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i32, i1)> + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @uadd_res_ult_const_minus_one(%arg0: i32, %arg1: !llvm.ptr) -> i1 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = "llvm.intr.uadd.with.overflow"(%arg0, %0) : (i32, i32) -> !llvm.struct<(i32, i1)> + %2 = llvm.extractvalue %1[1] : !llvm.struct<(i32, i1)> + llvm.store %2, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + %3 = llvm.extractvalue %1[0] : !llvm.struct<(i32, i1)> + %4 = llvm.icmp "ult" %3, %0 : i32 + llvm.return %4 : i1 + } + llvm.func @sadd_canonicalize_constant_arg0(%arg0: i32) -> !llvm.struct<(i32, i1)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = "llvm.intr.sadd.with.overflow"(%0, %arg0) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %1 : !llvm.struct<(i32, i1)> + } + llvm.func @uadd_canonicalize_constant_arg0(%arg0: i32) -> !llvm.struct<(i32, i1)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = "llvm.intr.uadd.with.overflow"(%0, %arg0) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %1 : !llvm.struct<(i32, i1)> + } + llvm.func @ssub_no_canonicalize_constant_arg0(%arg0: i32) -> !llvm.struct<(i32, i1)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = "llvm.intr.ssub.with.overflow"(%0, %arg0) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %1 : !llvm.struct<(i32, i1)> + } + llvm.func @usub_no_canonicalize_constant_arg0(%arg0: i32) -> !llvm.struct<(i32, i1)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = "llvm.intr.usub.with.overflow"(%0, %arg0) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %1 : !llvm.struct<(i32, i1)> + } + llvm.func @smul_canonicalize_constant_arg0(%arg0: i32) -> !llvm.struct<(i32, i1)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = "llvm.intr.smul.with.overflow"(%0, %arg0) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %1 : !llvm.struct<(i32, i1)> + } + llvm.func @umul_canonicalize_constant_arg0(%arg0: i32) -> !llvm.struct<(i32, i1)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = "llvm.intr.umul.with.overflow"(%0, %arg0) : (i32, i32) -> !llvm.struct<(i32, i1)> + llvm.return %1 : !llvm.struct<(i32, i1)> + } + llvm.func @uadd_always_overflow(%arg0: i8) -> !llvm.struct<(i8, i1)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-64 : i8) : i8 + %1 = llvm.mlir.constant(64 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = "llvm.intr.uadd.with.overflow"(%2, %1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.return %3 : !llvm.struct<(i8, i1)> + } + llvm.func @usub_always_overflow(%arg0: i8) -> !llvm.struct<(i8, i1)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(64 : i8) : i8 + %1 = llvm.mlir.constant(63 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = "llvm.intr.usub.with.overflow"(%1, %2) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.return %3 : !llvm.struct<(i8, i1)> + } + llvm.func @umul_always_overflow(%arg0: i8) -> !llvm.struct<(i8, i1)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = "llvm.intr.umul.with.overflow"(%2, %1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.return %3 : !llvm.struct<(i8, i1)> + } + llvm.func @sadd_always_overflow(%arg0: i8) -> !llvm.struct<(i8, i1)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(28 : i8) : i8 + %2 = llvm.icmp "sgt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = "llvm.intr.sadd.with.overflow"(%3, %1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.return %4 : !llvm.struct<(i8, i1)> + } + llvm.func @ssub_always_overflow(%arg0: i8) -> !llvm.struct<(i8, i1)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(29 : i8) : i8 + %1 = llvm.mlir.constant(-100 : i8) : i8 + %2 = llvm.icmp "sgt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = "llvm.intr.ssub.with.overflow"(%1, %3) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.return %4 : !llvm.struct<(i8, i1)> + } + llvm.func @smul_always_overflow(%arg0: i8) -> !llvm.struct<(i8, i1)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(100 : i8) : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.icmp "sgt" %arg0, %0 : i8 + %3 = llvm.select %2, %arg0, %0 : i1, i8 + %4 = "llvm.intr.smul.with.overflow"(%3, %1) : (i8, i8) -> !llvm.struct<(i8, i1)> + llvm.return %4 : !llvm.struct<(i8, i1)> + } + llvm.func @always_sadd_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<127> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %2 = "llvm.intr.sadd.with.overflow"(%0, %1) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %2 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @always_uadd_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %2 = "llvm.intr.uadd.with.overflow"(%0, %1) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %2 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @always_ssub_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<-128> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %2 = "llvm.intr.ssub.with.overflow"(%0, %1) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %2 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @always_usub_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(dense<0> : vector<4xi8>) : vector<4xi8> + %2 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %3 = "llvm.intr.usub.with.overflow"(%1, %2) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %3 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @always_smul_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<127> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<3> : vector<4xi8>) : vector<4xi8> + %2 = "llvm.intr.smul.with.overflow"(%0, %1) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %2 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @always_umul_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<3> : vector<4xi8>) : vector<4xi8> + %2 = "llvm.intr.umul.with.overflow"(%0, %1) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %2 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @never_sadd_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<[-10, -20, 30, 40]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<[-40, 10, -30, 20]> : vector<4xi8>) : vector<4xi8> + %2 = "llvm.intr.sadd.with.overflow"(%0, %1) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %2 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @never_uadd_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<[0, 32, 64, 16]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<32> : vector<4xi8>) : vector<4xi8> + %2 = "llvm.intr.uadd.with.overflow"(%0, %1) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %2 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @never_ssub_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<-10> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<[-10, -20, -30, -40]> : vector<4xi8>) : vector<4xi8> + %2 = "llvm.intr.ssub.with.overflow"(%0, %1) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %2 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @never_usub_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<[-128, 0, -1, 1]> : vector<4xi8>) : vector<4xi8> + %2 = "llvm.intr.usub.with.overflow"(%0, %1) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %2 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @never_smul_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<-6> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<[9, 3, 10, 15]> : vector<4xi8>) : vector<4xi8> + %2 = "llvm.intr.smul.with.overflow"(%0, %1) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %2 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @never_umul_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<15> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<[15, 8, 4, 2]> : vector<4xi8>) : vector<4xi8> + %2 = "llvm.intr.umul.with.overflow"(%0, %1) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %2 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @neutral_sadd_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<4xi8>) : vector<4xi8> + %3 = "llvm.intr.sadd.with.overflow"(%0, %2) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %3 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @neutral_uadd_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<4xi8>) : vector<4xi8> + %3 = "llvm.intr.uadd.with.overflow"(%0, %2) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %3 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @neutral_ssub_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<4xi8>) : vector<4xi8> + %3 = "llvm.intr.ssub.with.overflow"(%0, %2) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %3 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @neutral_usub_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<4xi8>) : vector<4xi8> + %3 = "llvm.intr.usub.with.overflow"(%0, %2) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %3 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @neutral_smul_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %2 = "llvm.intr.smul.with.overflow"(%0, %1) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %2 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @neutral_umul_const_vector() -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(dense<[1, 2, 3, 4]> : vector<4xi8>) : vector<4xi8> + %1 = llvm.mlir.constant(dense<1> : vector<4xi8>) : vector<4xi8> + %2 = "llvm.intr.umul.with.overflow"(%0, %1) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %2 : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + } + llvm.func @smul_neg1(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @smul_neg1_vec(%arg0: vector<4xi8>, %arg1: !llvm.ptr) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi8>) : vector<4xi8> + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.store %3, %arg1 {alignment = 1 : i64} : vector<4xi1>, !llvm.ptr + llvm.return %2 : vector<4xi8> + } + llvm.func @smul_neg1_vec_poison(%arg0: vector<4xi8>, %arg1: !llvm.ptr) -> vector<4xi8> { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<4xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi8> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi8> + %11 = "llvm.intr.smul.with.overflow"(%arg0, %10) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + %12 = llvm.extractvalue %11[0] : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + %13 = llvm.extractvalue %11[1] : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.store %13, %arg1 {alignment = 1 : i64} : vector<4xi1>, !llvm.ptr + llvm.return %12 : vector<4xi8> + } + llvm.func @smul_neg2(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-2 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @umul_neg1(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @umul_neg1_vec(%arg0: vector<4xi8>, %arg1: !llvm.ptr) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi8>) : vector<4xi8> + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.store %3, %arg1 {alignment = 1 : i64} : vector<4xi1>, !llvm.ptr + llvm.return %2 : vector<4xi8> + } + llvm.func @umul_neg1_vec_poison(%arg0: vector<4xi8>, %arg1: !llvm.ptr) -> vector<4xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.mlir.undef : vector<4xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi8> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi8> + %11 = "llvm.intr.umul.with.overflow"(%arg0, %10) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + %12 = llvm.extractvalue %11[0] : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + %13 = llvm.extractvalue %11[1] : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.store %13, %arg1 {alignment = 1 : i64} : vector<4xi1>, !llvm.ptr + llvm.return %12 : vector<4xi8> + } + llvm.func @smul_not_neg1_vec(%arg0: vector<4xi8>) -> vector<4xi1> { + %0 = llvm.mlir.constant(-3 : i8) : i8 + %1 = llvm.mlir.poison : i8 + %2 = llvm.mlir.undef : vector<4xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<4xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi8> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi8> + %11 = "llvm.intr.smul.with.overflow"(%arg0, %10) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + %12 = llvm.extractvalue %11[1] : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.return %12 : vector<4xi1> + } + llvm.func @umul_neg1_select(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + %4 = llvm.select %3, %0, %2 : i1, i8 + llvm.return %4 : i8 + } + llvm.func @umul_2(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(2 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @umul_8(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(8 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @umul_64(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(64 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @umul_256(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @umul_4_vec_poison(%arg0: vector<4xi8>, %arg1: !llvm.ptr) -> vector<4xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.mlir.undef : vector<4xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi8> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi8> + %11 = "llvm.intr.umul.with.overflow"(%arg0, %10) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + %12 = llvm.extractvalue %11[0] : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + %13 = llvm.extractvalue %11[1] : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.store %13, %arg1 {alignment = 1 : i64} : vector<4xi1>, !llvm.ptr + llvm.return %12 : vector<4xi8> + } + llvm.func @umul_3(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = "llvm.intr.umul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @smul_4(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @smul_16(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(16 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @smul_32(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(32 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @smul_128(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-128 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } + llvm.func @smul_2_vec_poison(%arg0: vector<4xi8>, %arg1: !llvm.ptr) -> vector<4xi8> { + %0 = llvm.mlir.poison : i8 + %1 = llvm.mlir.constant(2 : i8) : i8 + %2 = llvm.mlir.undef : vector<4xi8> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi8> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi8> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %1, %6[%7 : i32] : vector<4xi8> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi8> + %11 = "llvm.intr.smul.with.overflow"(%arg0, %10) : (vector<4xi8>, vector<4xi8>) -> !llvm.struct<(vector<4xi8>, vector<4xi1>)> + %12 = llvm.extractvalue %11[0] : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + %13 = llvm.extractvalue %11[1] : !llvm.struct<(vector<4xi8>, vector<4xi1>)> + llvm.store %13, %arg1 {alignment = 1 : i64} : vector<4xi1>, !llvm.ptr + llvm.return %12 : vector<4xi8> + } + llvm.func @smul_7(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = "llvm.intr.smul.with.overflow"(%arg0, %0) : (i8, i8) -> !llvm.struct<(i8, i1)> + %2 = llvm.extractvalue %1[0] : !llvm.struct<(i8, i1)> + %3 = llvm.extractvalue %1[1] : !llvm.struct<(i8, i1)> + llvm.store %3, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.return %2 : i8 + } +} diff --git a/test/LLVMDialect/InstCombine/xor-and-or.ll.mlir b/test/LLVMDialect/InstCombine/xor-and-or.ll.mlir new file mode 100644 index 000000000..88740f679 --- /dev/null +++ b/test/LLVMDialect/InstCombine/xor-and-or.ll.mlir @@ -0,0 +1,178 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @xor_logic_and_logic_or1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg0, %0, %arg2 : i1, i1 + %3 = llvm.select %arg0, %arg1, %1 : i1, i1 + %4 = llvm.xor %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_logic_and_logic_or2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg2, %0, %arg0 : i1, i1 + %3 = llvm.select %arg0, %arg1, %1 : i1, i1 + %4 = llvm.xor %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_logic_and_logic_or3(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg2, %0, %arg0 : i1, i1 + %3 = llvm.select %arg1, %arg0, %1 : i1, i1 + %4 = llvm.xor %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_logic_and_logic_or4(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.select %arg0, %0, %arg2 : i1, i1 + %3 = llvm.select %arg1, %arg0, %1 : i1, i1 + %4 = llvm.xor %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_logic_and_logic_or_vector1(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %4 = llvm.select %arg0, %1, %arg2 : vector<3xi1>, vector<3xi1> + %5 = llvm.select %arg0, %arg1, %3 : vector<3xi1>, vector<3xi1> + %6 = llvm.xor %5, %4 : vector<3xi1> + llvm.return %6 : vector<3xi1> + } + llvm.func @xor_logic_and_logic_or_vector2(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %4 = llvm.select %arg2, %1, %arg0 : vector<3xi1>, vector<3xi1> + %5 = llvm.select %arg1, %arg0, %3 : vector<3xi1>, vector<3xi1> + %6 = llvm.xor %5, %4 : vector<3xi1> + llvm.return %6 : vector<3xi1> + } + llvm.func @xor_logic_and_logic_or_vector_poison1(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.poison : i1 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.undef : vector<3xi1> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<3xi1> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi1> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi1> + %9 = llvm.mlir.constant(false) : i1 + %10 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %11 = llvm.select %arg0, %8, %arg2 : vector<3xi1>, vector<3xi1> + %12 = llvm.select %arg0, %arg1, %10 : vector<3xi1>, vector<3xi1> + %13 = llvm.xor %12, %11 : vector<3xi1> + llvm.return %13 : vector<3xi1> + } + llvm.func @xor_logic_and_logic_or_vector_poison2(%arg0: vector<3xi1>, %arg1: vector<3xi1>, %arg2: vector<3xi1>) -> vector<3xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> + %2 = llvm.mlir.constant(false) : i1 + %3 = llvm.mlir.poison : i1 + %4 = llvm.mlir.undef : vector<3xi1> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %2, %4[%5 : i32] : vector<3xi1> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %3, %6[%7 : i32] : vector<3xi1> + %9 = llvm.mlir.constant(2 : i32) : i32 + %10 = llvm.insertelement %2, %8[%9 : i32] : vector<3xi1> + %11 = llvm.select %arg0, %1, %arg2 : vector<3xi1>, vector<3xi1> + %12 = llvm.select %arg0, %arg1, %10 : vector<3xi1>, vector<3xi1> + %13 = llvm.xor %12, %11 : vector<3xi1> + llvm.return %13 : vector<3xi1> + } + llvm.func @xor_and_logic_or1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg0, %0, %arg2 : i1, i1 + %2 = llvm.and %arg0, %arg1 : i1 + %3 = llvm.xor %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @xor_and_logic_or2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.select %arg2, %0, %arg0 : i1, i1 + %2 = llvm.and %arg1, %arg0 : i1 + %3 = llvm.xor %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @xor_and_logic_or_vector(%arg0: vector<2xi1>, %arg1: vector<2xi1>, %arg2: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.select %arg0, %1, %arg2 : vector<2xi1>, vector<2xi1> + %3 = llvm.and %arg0, %arg1 : vector<2xi1> + %4 = llvm.xor %3, %2 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @xor_and_logic_or_vector_poison(%arg0: vector<2xi1>, %arg1: vector<2xi1>, %arg2: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.poison : i1 + %2 = llvm.mlir.undef : vector<2xi1> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi1> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi1> + %7 = llvm.select %arg0, %6, %arg2 : vector<2xi1>, vector<2xi1> + %8 = llvm.and %arg0, %arg1 : vector<2xi1> + %9 = llvm.xor %8, %7 : vector<2xi1> + llvm.return %9 : vector<2xi1> + } + llvm.func @xor_logic_and_or1(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.or %arg2, %arg0 : i1 + %2 = llvm.select %arg0, %arg1, %0 : i1, i1 + %3 = llvm.xor %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @xor_logic_and_or2(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.or %arg0, %arg2 : i1 + %2 = llvm.select %arg1, %arg0, %0 : i1, i1 + %3 = llvm.xor %2, %1 : i1 + llvm.return %3 : i1 + } + llvm.func @xor_logic_and_or_vector(%arg0: vector<2xi1>, %arg1: vector<2xi1>, %arg2: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.or %arg2, %arg0 : vector<2xi1> + %3 = llvm.select %arg0, %arg1, %1 : vector<2xi1>, vector<2xi1> + %4 = llvm.xor %3, %2 : vector<2xi1> + llvm.return %4 : vector<2xi1> + } + llvm.func @xor_logic_and_or_vector_poison(%arg0: vector<2xi1>, %arg1: vector<2xi1>, %arg2: vector<2xi1>) -> vector<2xi1> { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.mlir.poison : i1 + %2 = llvm.mlir.undef : vector<2xi1> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi1> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi1> + %7 = llvm.or %arg2, %arg0 : vector<2xi1> + %8 = llvm.select %arg0, %arg1, %6 : vector<2xi1>, vector<2xi1> + %9 = llvm.xor %8, %7 : vector<2xi1> + llvm.return %9 : vector<2xi1> + } + llvm.func @xor_and_or(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.or %arg2, %arg0 : i1 + %1 = llvm.and %arg0, %arg1 : i1 + %2 = llvm.xor %1, %0 : i1 + llvm.return %2 : i1 + } + llvm.func @xor_and_or_vector(%arg0: vector<4xi1>, %arg1: vector<4xi1>, %arg2: vector<4xi1>) -> vector<4xi1> { + %0 = llvm.or %arg2, %arg0 : vector<4xi1> + %1 = llvm.and %arg0, %arg1 : vector<4xi1> + %2 = llvm.xor %1, %0 : vector<4xi1> + llvm.return %2 : vector<4xi1> + } + llvm.func @xor_and_or_negative_oneuse(%arg0: i1, %arg1: i1, %arg2: i1) -> i1 { + %0 = llvm.or %arg2, %arg0 : i1 + %1 = llvm.and %arg0, %arg1 : i1 + %2 = llvm.xor %1, %0 : i1 + llvm.call @use(%0) : (i1) -> () + llvm.return %2 : i1 + } + llvm.func @use(i1) +} diff --git a/test/LLVMDialect/InstCombine/xor-ashr.ll.mlir b/test/LLVMDialect/InstCombine/xor-ashr.ll.mlir new file mode 100644 index 000000000..30dcbd147 --- /dev/null +++ b/test/LLVMDialect/InstCombine/xor-ashr.ll.mlir @@ -0,0 +1,113 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use16(i16) + llvm.func @use32(i32) + llvm.func @testi8i8(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(127 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @testi16i8(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(15 : i16) : i16 + %1 = llvm.mlir.constant(27 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i16 + %3 = llvm.trunc %2 : i16 to i8 + %4 = llvm.xor %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @testi64i32(%arg0: i64) -> i32 { + %0 = llvm.mlir.constant(63 : i64) : i64 + %1 = llvm.mlir.constant(127 : i32) : i32 + %2 = llvm.ashr %arg0, %0 : i64 + %3 = llvm.trunc %2 : i64 to i32 + %4 = llvm.xor %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @testi128i128(%arg0: i128) -> i128 { + %0 = llvm.mlir.constant(127 : i128) : i128 + %1 = llvm.mlir.constant(27 : i128) : i128 + %2 = llvm.ashr %arg0, %0 : i128 + %3 = llvm.xor %2, %1 : i128 + llvm.return %3 : i128 + } + llvm.func @testv4i16i8(%arg0: vector<4xi16>) -> vector<4xi8> { + %0 = llvm.mlir.constant(dense<15> : vector<4xi16>) : vector<4xi16> + %1 = llvm.mlir.constant(dense<27> : vector<4xi8>) : vector<4xi8> + %2 = llvm.ashr %arg0, %0 : vector<4xi16> + %3 = llvm.trunc %2 : vector<4xi16> to vector<4xi8> + %4 = llvm.xor %3, %1 : vector<4xi8> + llvm.return %4 : vector<4xi8> + } + llvm.func @testv4i16i8_poison(%arg0: vector<4xi16>) -> vector<4xi8> { + %0 = llvm.mlir.constant(15 : i16) : i16 + %1 = llvm.mlir.poison : i16 + %2 = llvm.mlir.undef : vector<4xi16> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<4xi16> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<4xi16> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<4xi16> + %9 = llvm.mlir.constant(3 : i32) : i32 + %10 = llvm.insertelement %0, %8[%9 : i32] : vector<4xi16> + %11 = llvm.mlir.constant(27 : i8) : i8 + %12 = llvm.mlir.poison : i8 + %13 = llvm.mlir.undef : vector<4xi8> + %14 = llvm.mlir.constant(0 : i32) : i32 + %15 = llvm.insertelement %11, %13[%14 : i32] : vector<4xi8> + %16 = llvm.mlir.constant(1 : i32) : i32 + %17 = llvm.insertelement %11, %15[%16 : i32] : vector<4xi8> + %18 = llvm.mlir.constant(2 : i32) : i32 + %19 = llvm.insertelement %12, %17[%18 : i32] : vector<4xi8> + %20 = llvm.mlir.constant(3 : i32) : i32 + %21 = llvm.insertelement %11, %19[%20 : i32] : vector<4xi8> + %22 = llvm.ashr %arg0, %10 : vector<4xi16> + %23 = llvm.trunc %22 : vector<4xi16> to vector<4xi8> + %24 = llvm.xor %23, %21 : vector<4xi8> + llvm.return %24 : vector<4xi8> + } + llvm.func @wrongimm(%arg0: i16) -> i8 { + %0 = llvm.mlir.constant(14 : i16) : i16 + %1 = llvm.mlir.constant(27 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i16 + %3 = llvm.trunc %2 : i16 to i8 + %4 = llvm.xor %3, %1 : i8 + llvm.return %4 : i8 + } + llvm.func @vectorpoison(%arg0: vector<6xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<6xi32>) : vector<6xi32> + %1 = llvm.mlir.constant(dense<31> : vector<6xi32>) : vector<6xi32> + %2 = llvm.mlir.poison : vector<6xi32> + %3 = llvm.xor %arg0, %0 : vector<6xi32> + %4 = llvm.ashr %3, %1 : vector<6xi32> + %5 = llvm.shufflevector %4, %2 [0, 1, 0, 2] : vector<6xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @extrause(%arg0: i16) -> i16 { + %0 = llvm.mlir.constant(15 : i16) : i16 + %1 = llvm.mlir.constant(27 : i16) : i16 + %2 = llvm.ashr %arg0, %0 : i16 + %3 = llvm.xor %2, %1 : i16 + llvm.call @use16(%2) : (i16) -> () + llvm.return %3 : i16 + } + llvm.func @extrause_trunc1(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(127 : i16) : i16 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i16 + llvm.call @use32(%2) : (i32) -> () + %4 = llvm.xor %3, %1 : i16 + llvm.return %4 : i16 + } + llvm.func @extrause_trunc2(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(31 : i32) : i32 + %1 = llvm.mlir.constant(127 : i16) : i16 + %2 = llvm.ashr %arg0, %0 : i32 + %3 = llvm.trunc %2 : i32 to i16 + llvm.call @use16(%3) : (i16) -> () + %4 = llvm.xor %3, %1 : i16 + llvm.return %4 : i16 + } +} diff --git a/test/LLVMDialect/InstCombine/xor-icmps.ll.mlir b/test/LLVMDialect/InstCombine/xor-icmps.ll.mlir new file mode 100644 index 000000000..696a625d7 --- /dev/null +++ b/test/LLVMDialect/InstCombine/xor-icmps.ll.mlir @@ -0,0 +1,204 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @eq_zero(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.icmp "eq" %arg0, %0 : i4 + %2 = llvm.icmp "eq" %arg1, %0 : i4 + %3 = llvm.xor %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @ne_zero(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.icmp "ne" %arg0, %0 : i4 + %2 = llvm.icmp "ne" %arg1, %0 : i4 + %3 = llvm.xor %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @eq_ne_zero(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.icmp "eq" %arg0, %0 : i4 + %2 = llvm.icmp "ne" %arg1, %0 : i4 + %3 = llvm.xor %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_zero(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.icmp "slt" %arg0, %0 : i4 + %2 = llvm.icmp "slt" %arg1, %0 : i4 + %3 = llvm.xor %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @use(i1) + llvm.func @slt_zero_extra_uses(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.icmp "slt" %arg0, %0 : i4 + %2 = llvm.icmp "slt" %arg1, %0 : i4 + %3 = llvm.xor %1, %2 : i1 + llvm.call @use(%1) : (i1) -> () + llvm.call @use(%2) : (i1) -> () + llvm.return %3 : i1 + } + llvm.func @sgt_zero(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.icmp "sgt" %arg0, %0 : i4 + %2 = llvm.icmp "sgt" %arg1, %0 : i4 + %3 = llvm.xor %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @sgt_minus1(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.icmp "sgt" %arg0, %0 : i4 + %2 = llvm.icmp "sgt" %arg1, %0 : i4 + %3 = llvm.xor %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @slt_zero_sgt_minus1(%arg0: i4, %arg1: i4) -> i1 { + %0 = llvm.mlir.constant(0 : i4) : i4 + %1 = llvm.mlir.constant(-1 : i4) : i4 + %2 = llvm.icmp "slt" %arg0, %0 : i4 + %3 = llvm.icmp "sgt" %arg1, %1 : i4 + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @sgt_minus1_slt_zero_sgt(%arg0: vector<2xi4>, %arg1: vector<2xi4>) -> vector<2xi1> { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.mlir.constant(dense<-1> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(0 : i4) : i4 + %3 = llvm.mlir.constant(dense<0> : vector<2xi4>) : vector<2xi4> + %4 = llvm.icmp "sgt" %arg0, %1 : vector<2xi4> + %5 = llvm.icmp "slt" %arg1, %3 : vector<2xi4> + %6 = llvm.xor %5, %4 : vector<2xi1> + llvm.return %6 : vector<2xi1> + } + llvm.func @different_type_cmp_ops(%arg0: i32, %arg1: i64) -> i1 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.icmp "slt" %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg1, %1 : i64 + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @test13(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.icmp "ult" %arg0, %arg1 : i8 + %1 = llvm.icmp "ugt" %arg0, %arg1 : i8 + %2 = llvm.xor %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @test14(%arg0: i8, %arg1: i8) -> i1 { + %0 = llvm.icmp "eq" %arg0, %arg1 : i8 + %1 = llvm.icmp "ne" %arg1, %arg0 : i8 + %2 = llvm.xor %0, %1 : i1 + llvm.return %2 : i1 + } + llvm.func @xor_icmp_ptr(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.zero : !llvm.ptr + %1 = llvm.icmp "slt" %arg0, %0 : !llvm.ptr + %2 = llvm.icmp "slt" %arg1, %0 : !llvm.ptr + %3 = llvm.xor %1, %2 : i1 + llvm.return %3 : i1 + } + llvm.func @xor_icmp_true_signed(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_icmp_true_signed_multiuse1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_icmp_true_signed_multiuse2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "slt" %arg0, %1 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_icmp_true_signed_commuted(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.xor %3, %2 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_icmp_true_unsigned(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(5 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "ugt" %arg0, %0 : i32 + %3 = llvm.icmp "ult" %arg0, %1 : i32 + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_icmp_to_ne(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_icmp_to_ne_multiuse1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_icmp_to_icmp_add(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_icmp_invalid_range(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.icmp "eq" %arg0, %0 : i8 + %3 = llvm.icmp "ne" %arg0, %1 : i8 + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_icmp_to_ne_multiuse2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "slt" %arg0, %1 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_icmp_to_icmp_add_multiuse1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "slt" %arg0, %1 : i32 + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } + llvm.func @xor_icmp_to_icmp_add_multiuse2(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(6 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.call @use(%2) : (i1) -> () + %3 = llvm.icmp "slt" %arg0, %1 : i32 + llvm.call @use(%3) : (i1) -> () + %4 = llvm.xor %2, %3 : i1 + llvm.return %4 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/xor-of-icmps-with-extra-uses.ll.mlir b/test/LLVMDialect/InstCombine/xor-of-icmps-with-extra-uses.ll.mlir new file mode 100644 index 000000000..aa84ac880 --- /dev/null +++ b/test/LLVMDialect/InstCombine/xor-of-icmps-with-extra-uses.ll.mlir @@ -0,0 +1,95 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @v0_select_of_consts(%arg0: i32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.select %2, %0, %1 : i1, i32 + llvm.store %4, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.xor %2, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @v1_select_of_var_and_const(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.select %2, %arg1, %1 : i1, i32 + llvm.store %4, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.xor %2, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @v2_select_of_const_and_var(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.select %2, %0, %arg1 : i1, i32 + llvm.store %4, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.xor %2, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @v3_branch(%arg0: i32, %arg1: !llvm.ptr, %arg2: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.icmp "sgt" %arg0, %1 : i32 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.store %2, %arg1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 + ^bb2: // pred: ^bb0 + llvm.store %2, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.br ^bb3 + ^bb3: // 2 preds: ^bb1, ^bb2 + %5 = llvm.xor %3, %4 : i1 + llvm.return %5 : i1 + } + llvm.func @v4_not_store(%arg0: i32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(true) : i1 + %2 = llvm.mlir.constant(-32768 : i32) : i32 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.xor %3, %1 : i1 + llvm.store %4, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + %5 = llvm.icmp "sgt" %arg0, %2 : i32 + %6 = llvm.select %3, %0, %2 : i1, i32 + %7 = llvm.xor %3, %5 : i1 + llvm.return %7 : i1 + } + llvm.func @v5_select_and_not(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.icmp "sgt" %arg0, %0 : i32 + %4 = llvm.icmp "sgt" %arg0, %1 : i32 + %5 = llvm.select %3, %0, %arg1 : i1, i32 + %6 = llvm.xor %3, %2 : i1 + llvm.store %6, %arg3 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.store %5, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %7 = llvm.xor %3, %4 : i1 + llvm.return %7 : i1 + } + llvm.func @n6_select_and_not(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr, %arg3: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.select %2, %0, %arg1 : i1, i32 + llvm.store %2, %arg3 {alignment = 1 : i64} : i1, !llvm.ptr + llvm.store %4, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.xor %2, %3 : i1 + llvm.return %5 : i1 + } + llvm.func @n7_store(%arg0: i32, %arg1: !llvm.ptr) -> i1 { + %0 = llvm.mlir.constant(32767 : i32) : i32 + %1 = llvm.mlir.constant(-32768 : i32) : i32 + %2 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.store %2, %arg1 {alignment = 1 : i64} : i1, !llvm.ptr + %3 = llvm.icmp "sgt" %arg0, %1 : i32 + %4 = llvm.select %2, %0, %1 : i1, i32 + %5 = llvm.xor %2, %3 : i1 + llvm.return %5 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/xor-of-or.ll.mlir b/test/LLVMDialect/InstCombine/xor-of-or.ll.mlir new file mode 100644 index 000000000..767544d88 --- /dev/null +++ b/test/LLVMDialect/InstCombine/xor-of-or.ll.mlir @@ -0,0 +1,160 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @G() {addr_space = 0 : i32} : i32 + llvm.mlir.global external @G2() {addr_space = 0 : i32} : i32 + llvm.func @t0(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.or %arg0, %arg1 : i4 + %1 = llvm.xor %0, %arg2 : i4 + llvm.return %1 : i4 + } + llvm.func @t1(%arg0: i4) -> i4 { + %0 = llvm.mlir.constant(-4 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.or %arg0, %0 : i4 + %3 = llvm.xor %2, %1 : i4 + llvm.return %3 : i4 + } + llvm.func @t2(%arg0: i4) -> i4 { + %0 = llvm.mlir.constant(-4 : i4) : i4 + %1 = llvm.mlir.constant(-6 : i4) : i4 + %2 = llvm.or %arg0, %0 : i4 + llvm.call @use(%2) : (i4) -> () + %3 = llvm.xor %2, %1 : i4 + llvm.return %3 : i4 + } + llvm.func @t3(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-4 : i4) : i4 + %1 = llvm.mlir.constant(dense<-4> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.constant(-6 : i4) : i4 + %3 = llvm.mlir.constant(dense<-6> : vector<2xi4>) : vector<2xi4> + %4 = llvm.or %arg0, %1 : vector<2xi4> + %5 = llvm.xor %4, %3 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @t4(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-6 : i4) : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.mlir.constant(dense<[-4, -6]> : vector<2xi4>) : vector<2xi4> + %3 = llvm.mlir.constant(dense<[-6, -4]> : vector<2xi4>) : vector<2xi4> + %4 = llvm.or %arg0, %2 : vector<2xi4> + %5 = llvm.xor %4, %3 : vector<2xi4> + llvm.return %5 : vector<2xi4> + } + llvm.func @t5(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-4 : i4) : i4 + %1 = llvm.mlir.constant(dense<-4> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.undef : i4 + %3 = llvm.mlir.constant(-6 : i4) : i4 + %4 = llvm.mlir.undef : vector<2xi4> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi4> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi4> + %9 = llvm.or %arg0, %1 : vector<2xi4> + %10 = llvm.xor %9, %8 : vector<2xi4> + llvm.return %10 : vector<2xi4> + } + llvm.func @t6(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.undef : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.mlir.undef : vector<2xi4> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi4> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi4> + %7 = llvm.mlir.constant(-6 : i4) : i4 + %8 = llvm.mlir.constant(dense<-6> : vector<2xi4>) : vector<2xi4> + %9 = llvm.or %arg0, %6 : vector<2xi4> + %10 = llvm.xor %9, %8 : vector<2xi4> + llvm.return %10 : vector<2xi4> + } + llvm.func @t7(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.undef : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.mlir.undef : vector<2xi4> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi4> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi4> + %7 = llvm.mlir.constant(-6 : i4) : i4 + %8 = llvm.mlir.undef : vector<2xi4> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi4> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi4> + %13 = llvm.or %arg0, %6 : vector<2xi4> + %14 = llvm.xor %13, %12 : vector<2xi4> + llvm.return %14 : vector<2xi4> + } + llvm.func @t8(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.constant(-4 : i4) : i4 + %1 = llvm.mlir.constant(dense<-4> : vector<2xi4>) : vector<2xi4> + %2 = llvm.mlir.poison : i4 + %3 = llvm.mlir.constant(-6 : i4) : i4 + %4 = llvm.mlir.undef : vector<2xi4> + %5 = llvm.mlir.constant(0 : i32) : i32 + %6 = llvm.insertelement %3, %4[%5 : i32] : vector<2xi4> + %7 = llvm.mlir.constant(1 : i32) : i32 + %8 = llvm.insertelement %2, %6[%7 : i32] : vector<2xi4> + %9 = llvm.or %arg0, %1 : vector<2xi4> + %10 = llvm.xor %9, %8 : vector<2xi4> + llvm.return %10 : vector<2xi4> + } + llvm.func @t9(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.poison : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.mlir.undef : vector<2xi4> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi4> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi4> + %7 = llvm.mlir.constant(-6 : i4) : i4 + %8 = llvm.mlir.constant(dense<-6> : vector<2xi4>) : vector<2xi4> + %9 = llvm.or %arg0, %6 : vector<2xi4> + %10 = llvm.xor %9, %8 : vector<2xi4> + llvm.return %10 : vector<2xi4> + } + llvm.func @t10(%arg0: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.mlir.poison : i4 + %1 = llvm.mlir.constant(-4 : i4) : i4 + %2 = llvm.mlir.undef : vector<2xi4> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi4> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi4> + %7 = llvm.mlir.constant(-6 : i4) : i4 + %8 = llvm.mlir.undef : vector<2xi4> + %9 = llvm.mlir.constant(0 : i32) : i32 + %10 = llvm.insertelement %7, %8[%9 : i32] : vector<2xi4> + %11 = llvm.mlir.constant(1 : i32) : i32 + %12 = llvm.insertelement %0, %10[%11 : i32] : vector<2xi4> + %13 = llvm.or %arg0, %6 : vector<2xi4> + %14 = llvm.xor %13, %12 : vector<2xi4> + llvm.return %14 : vector<2xi4> + } + llvm.func @t11(%arg0: i4) -> i4 { + %0 = llvm.mlir.constant(-4 : i4) : i4 + %1 = llvm.mlir.addressof @G2 : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i4 + %3 = llvm.or %arg0, %0 : i4 + %4 = llvm.xor %3, %2 : i4 + llvm.return %4 : i4 + } + llvm.func @t12(%arg0: i4) -> i4 { + %0 = llvm.mlir.addressof @G : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i4 + %2 = llvm.mlir.constant(-6 : i4) : i4 + %3 = llvm.or %arg0, %1 : i4 + %4 = llvm.xor %3, %2 : i4 + llvm.return %4 : i4 + } + llvm.func @t13(%arg0: i4) -> i4 { + %0 = llvm.mlir.addressof @G : !llvm.ptr + %1 = llvm.ptrtoint %0 : !llvm.ptr to i4 + %2 = llvm.mlir.addressof @G2 : !llvm.ptr + %3 = llvm.ptrtoint %2 : !llvm.ptr to i4 + %4 = llvm.or %arg0, %1 : i4 + %5 = llvm.xor %4, %3 : i4 + llvm.return %5 : i4 + } + llvm.func @use(i4) +} diff --git a/test/LLVMDialect/InstCombine/xor-undef.ll.mlir b/test/LLVMDialect/InstCombine/xor-undef.ll.mlir index a9686f9ec..fbf9db76e 100644 --- a/test/LLVMDialect/InstCombine/xor-undef.ll.mlir +++ b/test/LLVMDialect/InstCombine/xor-undef.ll.mlir @@ -1,8 +1,7 @@ -"module"() ( { - "llvm.func"() ( { - %0 = "llvm.mlir.undef"() : () -> vector<2xi64> - %1 = "llvm.xor"(%0, %0) : (vector<2xi64>, vector<2xi64>) -> vector<2xi64> - "llvm.return"(%1) : (vector<2xi64>) -> () - }) {linkage = 10 : i64, sym_name = "f", type = !llvm.func ()>} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @f() -> vector<2xi64> { + %0 = llvm.mlir.undef : vector<2xi64> + %1 = llvm.xor %0, %0 : vector<2xi64> + llvm.return %1 : vector<2xi64> + } +} diff --git a/test/LLVMDialect/InstCombine/xor.ll.mlir b/test/LLVMDialect/InstCombine/xor.ll.mlir new file mode 100644 index 000000000..547b65f5c --- /dev/null +++ b/test/LLVMDialect/InstCombine/xor.ll.mlir @@ -0,0 +1,866 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @G1(0 : i32) {addr_space = 0 : i32} : i32 + llvm.mlir.global external @G2(0 : i32) {addr_space = 0 : i32} : i32 + llvm.func @use(i8) + llvm.func @test0(%arg0: i1) -> i1 { + %0 = llvm.mlir.constant(false) : i1 + %1 = llvm.xor %arg0, %0 : i1 + llvm.return %1 : i1 + } + llvm.func @test1(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @test2(%arg0: i1) -> i1 { + %0 = llvm.xor %arg0, %arg0 : i1 + llvm.return %0 : i1 + } + llvm.func @test3(%arg0: i32) -> i32 { + %0 = llvm.xor %arg0, %arg0 : i32 + llvm.return %0 : i32 + } + llvm.func @test4(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %0, %arg0 : i32 + %2 = llvm.xor %arg0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test5(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(123 : i32) : i32 + %1 = llvm.or %arg0, %0 : i32 + %2 = llvm.xor %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @test6(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(17 : i8) : i8 + %1 = llvm.xor %arg0, %0 : i8 + %2 = llvm.xor %1, %0 : i8 + llvm.return %2 : i8 + } + llvm.func @test7(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(7 : i32) : i32 + %1 = llvm.mlir.constant(128 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.and %arg1, %1 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test8(%arg0: i1) -> i8 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.mlir.constant(1 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i1 + llvm.cond_br %3, ^bb1, ^bb2 + ^bb1: // pred: ^bb0 + llvm.return %2 : i8 + ^bb2: // pred: ^bb0 + llvm.return %1 : i8 + } + llvm.func @test9(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(123 : i8) : i8 + %1 = llvm.mlir.constant(34 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @test9vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<123> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<34> : vector<2xi8>) : vector<2xi8> + %2 = llvm.xor %arg0, %0 : vector<2xi8> + %3 = llvm.icmp "eq" %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi1> + } + llvm.func @test10(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(3 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @test11(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(12 : i8) : i8 + %1 = llvm.mlir.constant(4 : i8) : i8 + %2 = llvm.or %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @test12(%arg0: i8) -> i1 { + %0 = llvm.mlir.constant(4 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.icmp "ne" %2, %1 : i8 + llvm.return %3 : i1 + } + llvm.func @test12vec(%arg0: vector<2xi8>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<4> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(dense<0> : vector<2xi8>) : vector<2xi8> + %3 = llvm.xor %arg0, %0 : vector<2xi8> + %4 = llvm.icmp "ne" %3, %2 : vector<2xi8> + llvm.return %4 : vector<2xi1> + } + llvm.func @test18(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(123 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.sub %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test19(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.xor %arg0, %arg1 : i32 + %1 = llvm.xor %0, %arg0 : i32 + llvm.return %1 : i32 + } + llvm.func @test20(%arg0: i32, %arg1: i32) { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.addressof @G1 : !llvm.ptr + %2 = llvm.mlir.addressof @G2 : !llvm.ptr + %3 = llvm.xor %arg1, %arg0 : i32 + %4 = llvm.xor %3, %arg1 : i32 + %5 = llvm.xor %4, %3 : i32 + llvm.store %5, %1 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.store %4, %2 {alignment = 4 : i64} : i32, !llvm.ptr + llvm.return + } + llvm.func @test22(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.xor %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @fold_zext_xor_sandwich(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i1 + %3 = llvm.zext %2 : i1 to i32 + %4 = llvm.xor %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @fold_zext_xor_sandwich_vec(%arg0: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %3 = llvm.xor %arg0, %1 : vector<2xi1> + %4 = llvm.zext %3 : vector<2xi1> to vector<2xi32> + %5 = llvm.xor %4, %2 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test23(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.xor %arg1, %arg0 : i32 + %1 = llvm.icmp "eq" %0, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @test24(%arg0: i32, %arg1: i32) -> i1 { + %0 = llvm.xor %arg1, %arg0 : i32 + %1 = llvm.icmp "ne" %0, %arg0 : i32 + llvm.return %1 : i1 + } + llvm.func @test25(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.xor %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @test27(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg2, %arg0 : i32 + %1 = llvm.xor %arg2, %arg1 : i32 + %2 = llvm.icmp "eq" %0, %1 : i32 + %3 = llvm.zext %2 : i1 to i32 + llvm.return %3 : i32 + } + llvm.func @test28(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483647 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.xor %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test28vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-2147483647> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %arg0, %0 : vector<2xi32> + %3 = llvm.xor %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @test28_sub(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2147483647 : i32) : i32 + %1 = llvm.mlir.constant(-2147483648 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.xor %2, %1 : i32 + llvm.return %3 : i32 + } + llvm.func @test28_subvec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-2147483647> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %2 = llvm.sub %0, %arg0 : vector<2xi32> + %3 = llvm.xor %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @test29(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1000 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.constant(123 : i32) : i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.xor %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @test29vec(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1000> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<123> : vector<2xi32>) : vector<2xi32> + %3 = llvm.select %arg0, %0, %1 : i1, vector<2xi32> + %4 = llvm.xor %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test29vec2(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[1000, 2500]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[10, 30]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[123, 333]> : vector<2xi32>) : vector<2xi32> + %3 = llvm.select %arg0, %0, %1 : i1, vector<2xi32> + %4 = llvm.xor %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test30(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(1000 : i32) : i32 + %1 = llvm.mlir.constant(10 : i32) : i32 + %2 = llvm.mlir.constant(123 : i32) : i32 + llvm.cond_br %arg0, ^bb2(%0 : i32), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : i32) + ^bb2(%3: i32): // 2 preds: ^bb0, ^bb1 + %4 = llvm.xor %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @test30vec(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1000> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<10> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<123> : vector<2xi32>) : vector<2xi32> + llvm.cond_br %arg0, ^bb2(%0 : vector<2xi32>), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : vector<2xi32>) + ^bb2(%3: vector<2xi32>): // 2 preds: ^bb0, ^bb1 + %4 = llvm.xor %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @test30vec2(%arg0: i1) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[1000, 2500]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<[10, 30]> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(dense<[123, 333]> : vector<2xi32>) : vector<2xi32> + llvm.cond_br %arg0, ^bb2(%0 : vector<2xi32>), ^bb1 + ^bb1: // pred: ^bb0 + llvm.br ^bb2(%1 : vector<2xi32>) + ^bb2(%3: vector<2xi32>): // 2 preds: ^bb0, ^bb1 + %4 = llvm.xor %3, %2 : vector<2xi32> + llvm.return %4 : vector<2xi32> + } + llvm.func @or_xor_commute1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.udiv %0, %arg0 : i32 + %2 = llvm.udiv %0, %arg1 : i32 + %3 = llvm.or %2, %1 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @or_xor_commute2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.udiv %0, %arg0 : i32 + %2 = llvm.udiv %0, %arg1 : i32 + %3 = llvm.or %1, %2 : i32 + %4 = llvm.xor %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @or_xor_commute3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.udiv %0, %arg0 : i32 + %2 = llvm.udiv %0, %arg1 : i32 + %3 = llvm.or %2, %1 : i32 + %4 = llvm.xor %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @or_xor_commute4(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.udiv %0, %arg0 : i32 + %2 = llvm.udiv %0, %arg1 : i32 + %3 = llvm.or %1, %2 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @or_xor_extra_use(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.or %arg0, %arg1 : i32 + llvm.store %0, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %1 = llvm.xor %arg1, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @and_xor_commute1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.udiv %0, %arg0 : i32 + %2 = llvm.udiv %0, %arg1 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @and_xor_commute2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.udiv %0, %arg0 : i32 + %2 = llvm.udiv %0, %arg1 : i32 + %3 = llvm.and %1, %2 : i32 + %4 = llvm.xor %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @and_xor_commute3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.udiv %0, %arg0 : i32 + %2 = llvm.udiv %0, %arg1 : i32 + %3 = llvm.and %2, %1 : i32 + %4 = llvm.xor %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @and_xor_commute4(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.udiv %0, %arg0 : i32 + %2 = llvm.udiv %0, %arg1 : i32 + %3 = llvm.and %1, %2 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @and_xor_extra_use(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.and %arg0, %arg1 : i32 + llvm.store %0, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %1 = llvm.xor %arg1, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @xor_or_not(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(12 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + llvm.store %3, %arg1 {alignment = 1 : i64} : i8, !llvm.ptr + %4 = llvm.or %3, %1 : i8 + %5 = llvm.xor %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @xor_or_not_uses(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.mlir.constant(12 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.or %3, %1 : i8 + llvm.store %4, %arg1 {alignment = 1 : i64} : i8, !llvm.ptr + %5 = llvm.xor %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @xor_and_not(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(42 : i8) : i8 + %2 = llvm.mlir.constant(31 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + llvm.store %3, %arg1 {alignment = 1 : i64} : i8, !llvm.ptr + %4 = llvm.and %3, %1 : i8 + %5 = llvm.xor %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @xor_and_not_uses(%arg0: i8, %arg1: !llvm.ptr) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(42 : i8) : i8 + %2 = llvm.mlir.constant(31 : i8) : i8 + %3 = llvm.xor %arg0, %0 : i8 + %4 = llvm.and %3, %1 : i8 + llvm.store %4, %arg1 {alignment = 1 : i64} : i8, !llvm.ptr + %5 = llvm.xor %4, %2 : i8 + llvm.return %5 : i8 + } + llvm.func @test39(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mlir.constant(-256 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + %5 = llvm.xor %4, %0 : i32 + llvm.return %5 : i32 + } + llvm.func @test40(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.icmp "sgt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.xor %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @test41(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.icmp "slt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.xor %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @test42(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.icmp "ugt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.xor %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @test43(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.icmp "ult" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.xor %3, %0 : i32 + llvm.return %4 : i32 + } + llvm.func @test44(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.add %arg1, %0 : i32 + %3 = llvm.xor %arg0, %1 : i32 + %4 = llvm.icmp "ult" %2, %3 : i32 + %5 = llvm.select %4, %2, %3 : i1, i32 + %6 = llvm.xor %5, %1 : i32 + llvm.return %6 : i32 + } + llvm.func @test45(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "ult" %1, %2 : i32 + %4 = llvm.select %3, %1, %2 : i1, i32 + %5 = llvm.xor %4, %0 : i32 + llvm.return %5 : i32 + } + llvm.func @test46(%arg0: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<4xi32>) : vector<4xi32> + %1 = llvm.mlir.constant(dense<-256> : vector<4xi32>) : vector<4xi32> + %2 = llvm.xor %arg0, %0 : vector<4xi32> + %3 = llvm.icmp "sgt" %2, %1 : vector<4xi32> + %4 = llvm.select %3, %2, %1 : vector<4xi1>, vector<4xi32> + %5 = llvm.xor %4, %0 : vector<4xi32> + llvm.return %5 : vector<4xi32> + } + llvm.func @test47(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.icmp "ugt" %1, %arg1 : i32 + %3 = llvm.select %2, %1, %arg1 : i1, i32 + %4 = llvm.xor %3, %0 : i32 + %5 = llvm.add %3, %arg2 : i32 + %6 = llvm.mul %4, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @test48(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(-1 : i32) : i32 + %3 = llvm.sub %0, %arg0 : i32 + %4 = llvm.icmp "sgt" %3, %1 : i32 + %5 = llvm.select %4, %3, %1 : i1, i32 + %6 = llvm.xor %5, %2 : i32 + llvm.return %6 : i32 + } + llvm.func @test48vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %4 = llvm.sub %0, %arg0 : vector<2xi32> + %5 = llvm.icmp "sgt" %4, %2 : vector<2xi32> + %6 = llvm.select %5, %4, %2 : vector<2xi1>, vector<2xi32> + %7 = llvm.xor %6, %3 : vector<2xi32> + llvm.return %7 : vector<2xi32> + } + llvm.func @test49(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + %4 = llvm.select %3, %2, %1 : i1, i32 + %5 = llvm.xor %4, %1 : i32 + llvm.return %5 : i32 + } + llvm.func @test49vec(%arg0: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %arg0, %0 : vector<2xi32> + %3 = llvm.icmp "slt" %2, %1 : vector<2xi32> + %4 = llvm.select %3, %2, %1 : vector<2xi1>, vector<2xi32> + %5 = llvm.xor %4, %1 : vector<2xi32> + llvm.return %5 : vector<2xi32> + } + llvm.func @test50(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-2 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.icmp "slt" %2, %3 : i32 + %5 = llvm.select %4, %2, %3 : i1, i32 + %6 = llvm.xor %5, %1 : i32 + llvm.return %6 : i32 + } + llvm.func @test50vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %arg0, %0 : vector<2xi32> + %3 = llvm.sub %0, %arg1 : vector<2xi32> + %4 = llvm.icmp "slt" %2, %3 : vector<2xi32> + %5 = llvm.select %4, %2, %3 : vector<2xi1>, vector<2xi32> + %6 = llvm.xor %5, %1 : vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @test51(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.add %arg0, %0 : i32 + %3 = llvm.sub %0, %arg1 : i32 + %4 = llvm.icmp "sgt" %2, %3 : i32 + %5 = llvm.select %4, %2, %3 : i1, i32 + %6 = llvm.xor %5, %1 : i32 + llvm.return %6 : i32 + } + llvm.func @test51vec(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<2> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.add %arg0, %0 : vector<2xi32> + %3 = llvm.sub %0, %arg1 : vector<2xi32> + %4 = llvm.icmp "sgt" %2, %3 : vector<2xi32> + %5 = llvm.select %4, %2, %3 : vector<2xi1>, vector<2xi32> + %6 = llvm.xor %5, %1 : vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @or_or_xor(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.or %arg2, %arg0 : i4 + %1 = llvm.or %arg2, %arg1 : i4 + %2 = llvm.xor %0, %1 : i4 + llvm.return %2 : i4 + } + llvm.func @or_or_xor_commute1(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.or %arg0, %arg2 : i4 + %1 = llvm.or %arg2, %arg1 : i4 + %2 = llvm.xor %0, %1 : i4 + llvm.return %2 : i4 + } + llvm.func @or_or_xor_commute2(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.or %arg2, %arg0 : i4 + %1 = llvm.or %arg1, %arg2 : i4 + %2 = llvm.xor %0, %1 : i4 + llvm.return %2 : i4 + } + llvm.func @or_or_xor_commute3(%arg0: vector<2xi4>, %arg1: vector<2xi4>, %arg2: vector<2xi4>) -> vector<2xi4> { + %0 = llvm.or %arg0, %arg2 : vector<2xi4> + %1 = llvm.or %arg1, %arg2 : vector<2xi4> + %2 = llvm.xor %0, %1 : vector<2xi4> + llvm.return %2 : vector<2xi4> + } + llvm.func @or_or_xor_use1(%arg0: i4, %arg1: i4, %arg2: i4, %arg3: !llvm.ptr) -> i4 { + %0 = llvm.or %arg2, %arg0 : i4 + llvm.store %0, %arg3 {alignment = 1 : i64} : i4, !llvm.ptr + %1 = llvm.or %arg2, %arg1 : i4 + %2 = llvm.xor %0, %1 : i4 + llvm.return %2 : i4 + } + llvm.func @or_or_xor_use2(%arg0: i4, %arg1: i4, %arg2: i4, %arg3: !llvm.ptr) -> i4 { + %0 = llvm.or %arg2, %arg0 : i4 + %1 = llvm.or %arg2, %arg1 : i4 + llvm.store %1, %arg3 {alignment = 1 : i64} : i4, !llvm.ptr + %2 = llvm.xor %0, %1 : i4 + llvm.return %2 : i4 + } + llvm.func @not_is_canonical(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1073741823 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.add %2, %arg1 : i32 + %4 = llvm.shl %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @not_shl(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_shl_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<5> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-32> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %arg0, %0 : vector<2xi8> + %3 = llvm.xor %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @not_shl_extra_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_shl_wrong_const(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(6 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.shl %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_lshr(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_lshr_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.lshr %arg0, %0 : vector<2xi8> + %3 = llvm.xor %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @not_lshr_extra_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(7 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_lshr_wrong_const(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(3 : i8) : i8 + %2 = llvm.lshr %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @ashr_not(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.mlir.constant(5 : i8) : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.ashr %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_ashr(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_ashr_vec(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi8>) : vector<2xi8> + %2 = llvm.ashr %arg0, %0 : vector<2xi8> + %3 = llvm.xor %2, %1 : vector<2xi8> + llvm.return %3 : vector<2xi8> + } + llvm.func @not_ashr_extra_use(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + llvm.call @use(%2) : (i8) -> () + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @not_ashr_wrong_const(%arg0: i8) -> i8 { + %0 = llvm.mlir.constant(5 : i8) : i8 + %1 = llvm.mlir.constant(-2 : i8) : i8 + %2 = llvm.ashr %arg0, %0 : i8 + %3 = llvm.xor %2, %1 : i8 + llvm.return %3 : i8 + } + llvm.func @xor_andn_commute1(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.xor %arg0, %0 : vector<2xi32> + %2 = llvm.and %1, %arg1 : vector<2xi32> + %3 = llvm.xor %2, %arg0 : vector<2xi32> + llvm.return %3 : vector<2xi32> + } + llvm.func @xor_andn_commute2(%arg0: i33, %arg1: i33) -> i33 { + %0 = llvm.mlir.constant(42 : i33) : i33 + %1 = llvm.mlir.constant(-1 : i33) : i33 + %2 = llvm.udiv %0, %arg1 : i33 + %3 = llvm.xor %arg0, %1 : i33 + %4 = llvm.and %2, %3 : i33 + %5 = llvm.xor %4, %arg0 : i33 + llvm.return %5 : i33 + } + llvm.func @xor_andn_commute3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.xor %2, %1 : i32 + %4 = llvm.and %3, %arg1 : i32 + %5 = llvm.xor %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @xor_andn_commute4(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.udiv %0, %arg0 : i32 + %3 = llvm.udiv %0, %arg1 : i32 + %4 = llvm.xor %2, %1 : i32 + %5 = llvm.and %3, %4 : i32 + %6 = llvm.xor %2, %5 : i32 + llvm.return %6 : i32 + } + llvm.func @xor_orn(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi64>) : vector<2xi64> + %1 = llvm.xor %arg0, %0 : vector<2xi64> + %2 = llvm.or %1, %arg1 : vector<2xi64> + %3 = llvm.xor %2, %arg0 : vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @xor_orn_commute1(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(42 : i8) : i8 + %1 = llvm.mlir.constant(-1 : i8) : i8 + %2 = llvm.udiv %0, %arg0 : i8 + %3 = llvm.xor %2, %1 : i8 + %4 = llvm.or %3, %arg1 : i8 + %5 = llvm.xor %2, %4 : i8 + llvm.return %5 : i8 + } + llvm.func @xor_orn_commute2(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.udiv %0, %arg1 : i32 + %3 = llvm.xor %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i32 + %5 = llvm.xor %4, %arg0 : i32 + llvm.return %5 : i32 + } + llvm.func @xor_orn_commute2_1use(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.udiv %0, %arg1 : i32 + %3 = llvm.xor %arg0, %1 : i32 + %4 = llvm.or %2, %3 : i32 + llvm.store %3, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %5 = llvm.xor %4, %arg0 : i32 + llvm.return %5 : i32 + } + llvm.func @xor_orn_commute3(%arg0: i67, %arg1: i67, %arg2: !llvm.ptr) -> i67 { + %0 = llvm.mlir.constant(42 : i67) : i67 + %1 = llvm.mlir.constant(-1 : i67) : i67 + %2 = llvm.udiv %0, %arg0 : i67 + %3 = llvm.udiv %0, %arg1 : i67 + %4 = llvm.xor %2, %1 : i67 + %5 = llvm.or %3, %4 : i67 + %6 = llvm.xor %2, %5 : i67 + llvm.return %6 : i67 + } + llvm.func @xor_orn_commute3_1use(%arg0: i67, %arg1: i67, %arg2: !llvm.ptr) -> i67 { + %0 = llvm.mlir.constant(42 : i67) : i67 + %1 = llvm.mlir.constant(-1 : i67) : i67 + %2 = llvm.udiv %0, %arg0 : i67 + %3 = llvm.udiv %0, %arg1 : i67 + %4 = llvm.xor %2, %1 : i67 + %5 = llvm.or %3, %4 : i67 + llvm.store %5, %arg2 {alignment = 4 : i64} : i67, !llvm.ptr + %6 = llvm.xor %2, %5 : i67 + llvm.return %6 : i67 + } + llvm.func @xor_orn_2use(%arg0: i32, %arg1: i32, %arg2: !llvm.ptr, %arg3: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + llvm.store %1, %arg2 {alignment = 4 : i64} : i32, !llvm.ptr + %2 = llvm.or %1, %arg1 : i32 + llvm.store %2, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %3 = llvm.xor %2, %arg0 : i32 + llvm.return %3 : i32 + } + llvm.func @ctlz_pow2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = true}> : (i32) -> i32 + %5 = llvm.xor %4, %1 : i32 + llvm.return %5 : i32 + } + llvm.func @cttz_pow2(%arg0: vector<2xi8>, %arg1: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi8>) : vector<2xi8> + %1 = llvm.mlir.constant(dense<7> : vector<2xi8>) : vector<2xi8> + %2 = llvm.shl %0, %arg0 : vector<2xi8> + %3 = llvm.udiv %2, %arg1 : vector<2xi8> + %4 = "llvm.intr.cttz"(%3) <{is_zero_poison = true}> : (vector<2xi8>) -> vector<2xi8> + %5 = llvm.xor %4, %1 : vector<2xi8> + llvm.return %5 : vector<2xi8> + } + llvm.func @ctlz_pow2_or_zero(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(31 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = false}> : (i32) -> i32 + %5 = llvm.xor %4, %1 : i32 + llvm.return %5 : i32 + } + llvm.func @ctlz_pow2_wrong_const(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(30 : i32) : i32 + %2 = llvm.sub %0, %arg0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = "llvm.intr.ctlz"(%3) <{is_zero_poison = true}> : (i32) -> i32 + %5 = llvm.xor %4, %1 : i32 + llvm.return %5 : i32 + } + llvm.func @tryFactorization_xor_ashr_lshr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.ashr %0, %arg0 : i32 + %3 = llvm.lshr %1, %arg0 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @tryFactorization_xor_lshr_ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.ashr %0, %arg0 : i32 + %3 = llvm.lshr %1, %arg0 : i32 + %4 = llvm.xor %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @tryFactorization_xor_ashr_lshr_negative_lhs(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(-5 : i32) : i32 + %2 = llvm.ashr %0, %arg0 : i32 + %3 = llvm.lshr %1, %arg0 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @tryFactorization_xor_lshr_lshr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(5 : i32) : i32 + %2 = llvm.lshr %0, %arg0 : i32 + %3 = llvm.lshr %1, %arg0 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @tryFactorization_xor_ashr_ashr(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(-5 : i32) : i32 + %2 = llvm.ashr %0, %arg0 : i32 + %3 = llvm.ashr %1, %arg0 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @PR96857_xor_with_noundef(%arg0: i4, %arg1: i4, %arg2: i4 {llvm.noundef}) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.and %arg2, %arg0 : i4 + %2 = llvm.xor %arg2, %0 : i4 + %3 = llvm.and %2, %arg1 : i4 + %4 = llvm.xor %1, %3 : i4 + llvm.return %4 : i4 + } + llvm.func @PR96857_xor_without_noundef(%arg0: i4, %arg1: i4, %arg2: i4) -> i4 { + %0 = llvm.mlir.constant(-1 : i4) : i4 + %1 = llvm.and %arg2, %arg0 : i4 + %2 = llvm.xor %arg2, %0 : i4 + %3 = llvm.and %2, %arg1 : i4 + %4 = llvm.xor %1, %3 : i4 + llvm.return %4 : i4 + } +} diff --git a/test/LLVMDialect/InstCombine/xor2.ll.mlir b/test/LLVMDialect/InstCombine/xor2.ll.mlir index ef0fb9ac9..7f2cb4141 100644 --- a/test/LLVMDialect/InstCombine/xor2.ll.mlir +++ b/test/LLVMDialect/InstCombine/xor2.ll.mlir @@ -1,304 +1,400 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = -2147483648 : i32} : () -> i32 - %2 = "llvm.xor"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (i32, i32) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test0", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi32>): // no predecessors - %0 = "llvm.mlir.constant"() {value = dense<-1> : vector<2xi32>} : () -> vector<2xi32> - %1 = "llvm.mlir.constant"() {value = dense<-2147483648> : vector<2xi32>} : () -> vector<2xi32> - %2 = "llvm.xor"(%arg0, %1) : (vector<2xi32>, vector<2xi32>) -> vector<2xi32> - %3 = "llvm.icmp"(%2, %0) {predicate = 4 : i64} : (vector<2xi32>, vector<2xi32>) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test0vec", type = !llvm.func (vector<2xi32>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 12345 : i32} : () -> i32 - %2 = "llvm.xor"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.icmp"(%2, %0) {predicate = 2 : i64} : (i32, i32) -> i1 - "llvm.return"(%3) : (i1) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 153 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 145 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 32 : i32} : () -> i32 - %3 = "llvm.and"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.add"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.xor"(%4, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 153 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 177 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 145 : i32} : () -> i32 - %3 = "llvm.or"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.and"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.xor"(%4, %0) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 8 : i32} : () -> i32 - %2 = "llvm.mlir.constant"() {value = 1234 : i32} : () -> i32 - %3 = "llvm.xor"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.lshr"(%3, %1) : (i32, i32) -> i32 - %5 = "llvm.xor"(%4, %0) : (i32, i32) -> i32 - %6 = "llvm.add"(%5, %3) : (i32, i32) -> i32 - "llvm.return"(%6) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = 16 : i32} : () -> i32 - %1 = "llvm.mlir.constant"() {value = 1234 : i32} : () -> i32 - %2 = "llvm.xor"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.lshr"(%2, %0) : (i32, i32) -> i32 - %4 = "llvm.add"(%3, %2) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.xor"(%arg0, %0) : (i32, i32) -> i32 - %3 = "llvm.xor"(%1, %2) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.xor"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %3 = "llvm.xor"(%1, %2) : (i32, i32) -> i32 - "llvm.return"(%3) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.and"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.xor"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.xor"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test9", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.and"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.xor"(%arg1, %arg0) : (i32, i32) -> i32 - %2 = "llvm.xor"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test9b", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.xor"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.and"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.xor"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test10", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.xor"(%arg0, %arg1) : (i32, i32) -> i32 - %1 = "llvm.and"(%arg1, %arg0) : (i32, i32) -> i32 - %2 = "llvm.xor"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test10b", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.xor"(%arg1, %arg0) : (i32, i32) -> i32 - %2 = "llvm.xor"(%arg0, %0) : (i32, i32) -> i32 - %3 = "llvm.xor"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.and"(%1, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test11", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.xor"(%arg1, %arg0) : (i32, i32) -> i32 - %2 = "llvm.xor"(%arg0, %0) : (i32, i32) -> i32 - %3 = "llvm.xor"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.and"(%3, %1) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test11b", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.xor"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.xor"(%arg0, %0) : (i32, i32) -> i32 - %3 = "llvm.xor"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.and"(%1, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test11c", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.xor"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.xor"(%arg0, %0) : (i32, i32) -> i32 - %3 = "llvm.xor"(%2, %arg1) : (i32, i32) -> i32 - %4 = "llvm.and"(%3, %1) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test11d", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mul"(%arg1, %arg2) : (i32, i32) -> i32 - %2 = "llvm.xor"(%1, %arg0) : (i32, i32) -> i32 - %3 = "llvm.xor"(%arg0, %0) : (i32, i32) -> i32 - %4 = "llvm.xor"(%1, %3) : (i32, i32) -> i32 - %5 = "llvm.and"(%2, %4) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test11e", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.mul"(%arg1, %arg2) : (i32, i32) -> i32 - %2 = "llvm.xor"(%1, %arg0) : (i32, i32) -> i32 - %3 = "llvm.xor"(%arg0, %0) : (i32, i32) -> i32 - %4 = "llvm.xor"(%1, %3) : (i32, i32) -> i32 - %5 = "llvm.and"(%4, %2) : (i32, i32) -> i32 - "llvm.return"(%5) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test11f", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.xor"(%arg1, %0) : (i32, i32) -> i32 - %2 = "llvm.and"(%arg0, %1) : (i32, i32) -> i32 - %3 = "llvm.xor"(%arg0, %0) : (i32, i32) -> i32 - %4 = "llvm.xor"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test12", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.xor"(%arg1, %0) : (i32, i32) -> i32 - %2 = "llvm.and"(%1, %arg0) : (i32, i32) -> i32 - %3 = "llvm.xor"(%arg0, %0) : (i32, i32) -> i32 - %4 = "llvm.xor"(%2, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test12commuted", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.xor"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.xor"(%arg1, %0) : (i32, i32) -> i32 - %3 = "llvm.and"(%arg0, %2) : (i32, i32) -> i32 - %4 = "llvm.xor"(%1, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test13", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32): // no predecessors - %0 = "llvm.mlir.constant"() {value = -1 : i32} : () -> i32 - %1 = "llvm.xor"(%arg0, %0) : (i32, i32) -> i32 - %2 = "llvm.xor"(%arg1, %0) : (i32, i32) -> i32 - %3 = "llvm.and"(%2, %arg0) : (i32, i32) -> i32 - %4 = "llvm.xor"(%1, %3) : (i32, i32) -> i32 - "llvm.return"(%4) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test13commuted", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.xor"(%arg0, %arg2) : (i32, i32) -> i32 - %1 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.xor"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_or_xor_common_op_commute1", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.xor"(%arg2, %arg0) : (i32, i32) -> i32 - %1 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.xor"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_or_xor_common_op_commute2", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.xor"(%arg0, %arg2) : (i32, i32) -> i32 - %1 = "llvm.or"(%arg1, %arg0) : (i32, i32) -> i32 - %2 = "llvm.xor"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_or_xor_common_op_commute3", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.xor"(%arg2, %arg0) : (i32, i32) -> i32 - %1 = "llvm.or"(%arg1, %arg0) : (i32, i32) -> i32 - %2 = "llvm.xor"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_or_xor_common_op_commute4", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.xor"(%arg0, %arg2) : (i32, i32) -> i32 - %1 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.xor"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_or_xor_common_op_commute5", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.xor"(%arg2, %arg0) : (i32, i32) -> i32 - %1 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.xor"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_or_xor_common_op_commute6", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.xor"(%arg0, %arg2) : (i32, i32) -> i32 - %1 = "llvm.or"(%arg1, %arg0) : (i32, i32) -> i32 - %2 = "llvm.xor"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_or_xor_common_op_commute7", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32): // no predecessors - %0 = "llvm.xor"(%arg2, %arg0) : (i32, i32) -> i32 - %1 = "llvm.or"(%arg1, %arg0) : (i32, i32) -> i32 - %2 = "llvm.xor"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_or_xor_common_op_commute8", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr): // no predecessors - %0 = "llvm.xor"(%arg0, %arg2) : (i32, i32) -> i32 - "llvm.store"(%0, %arg3) : (i32, !llvm.ptr) -> () - %1 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - %2 = "llvm.xor"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_or_xor_common_op_extra_use1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr): // no predecessors - %0 = "llvm.xor"(%arg0, %arg2) : (i32, i32) -> i32 - %1 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - "llvm.store"(%1, %arg3) : (i32, !llvm.ptr) -> () - %2 = "llvm.xor"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_or_xor_common_op_extra_use2", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr, %arg4: !llvm.ptr): // no predecessors - %0 = "llvm.xor"(%arg0, %arg2) : (i32, i32) -> i32 - "llvm.store"(%0, %arg3) : (i32, !llvm.ptr) -> () - %1 = "llvm.or"(%arg0, %arg1) : (i32, i32) -> i32 - "llvm.store"(%1, %arg4) : (i32, !llvm.ptr) -> () - %2 = "llvm.xor"(%0, %1) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "xor_or_xor_common_op_extra_use3", type = !llvm.func, ptr)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 33 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %arg0) : (i8, i8) -> i8 - %2 = "llvm.xor"(%arg0, %0) : (i8, i8) -> i8 - %3 = "llvm.xor"(%2, %arg1) : (i8, i8) -> i8 - %4 = "llvm.and"(%1, %3) : (i8, i8) -> i8 - %5 = "llvm.mul"(%4, %3) : (i8, i8) -> i8 - "llvm.return"(%5) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "test15", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i8, %arg1: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 33 : i8} : () -> i8 - %1 = "llvm.xor"(%arg1, %arg0) : (i8, i8) -> i8 - %2 = "llvm.xor"(%arg0, %0) : (i8, i8) -> i8 - %3 = "llvm.xor"(%2, %arg1) : (i8, i8) -> i8 - %4 = "llvm.and"(%3, %1) : (i8, i8) -> i8 - %5 = "llvm.mul"(%4, %3) : (i8, i8) -> i8 - "llvm.return"(%5) : (i8) -> () - }) {linkage = 10 : i64, sym_name = "test16", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test0(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(-2147483648 : i32) : i32 + %1 = llvm.mlir.constant(-1 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "sgt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test0vec(%arg0: vector<2xi32>) -> vector<2xi1> { + %0 = llvm.mlir.constant(dense<-2147483648> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.xor %arg0, %0 : vector<2xi32> + %3 = llvm.icmp "sgt" %2, %1 : vector<2xi32> + llvm.return %3 : vector<2xi1> + } + llvm.func @test1(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(12345 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.icmp "slt" %2, %1 : i32 + llvm.return %3 : i1 + } + llvm.func @test2(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(32 : i32) : i32 + %1 = llvm.mlir.constant(145 : i32) : i32 + %2 = llvm.mlir.constant(153 : i32) : i32 + %3 = llvm.and %arg0, %0 : i32 + %4 = llvm.add %3, %1 : i32 + %5 = llvm.xor %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test3(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(145 : i32) : i32 + %1 = llvm.mlir.constant(177 : i32) : i32 + %2 = llvm.mlir.constant(153 : i32) : i32 + %3 = llvm.or %arg0, %0 : i32 + %4 = llvm.and %3, %1 : i32 + %5 = llvm.xor %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test5(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1234 : i32) : i32 + %1 = llvm.mlir.constant(8 : i32) : i32 + %2 = llvm.mlir.constant(1 : i32) : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.lshr %3, %1 : i32 + %5 = llvm.xor %4, %2 : i32 + %6 = llvm.add %5, %3 : i32 + llvm.return %6 : i32 + } + llvm.func @test6(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(1234 : i32) : i32 + %1 = llvm.mlir.constant(16 : i32) : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.lshr %2, %1 : i32 + %4 = llvm.add %3, %2 : i32 + llvm.return %4 : i32 + } + llvm.func @test7(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test8(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.or %arg0, %arg1 : i32 + %3 = llvm.xor %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @test9(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.and %arg0, %arg1 : i32 + %1 = llvm.xor %arg0, %arg1 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test9b(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.and %arg0, %arg1 : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test10(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.xor %arg0, %arg1 : i32 + %1 = llvm.and %arg0, %arg1 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test10b(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.xor %arg0, %arg1 : i32 + %1 = llvm.and %arg1, %arg0 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test11(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %2, %arg1 : i32 + %4 = llvm.and %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test11b(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %arg0 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %2, %arg1 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @test11c(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %arg1 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %2, %arg1 : i32 + %4 = llvm.and %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test11d(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %arg1 : i32 + %2 = llvm.xor %arg0, %0 : i32 + %3 = llvm.xor %2, %arg1 : i32 + %4 = llvm.and %3, %1 : i32 + llvm.return %4 : i32 + } + llvm.func @test11e(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mul %arg1, %arg2 : i32 + %2 = llvm.xor %1, %arg0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.xor %1, %3 : i32 + %5 = llvm.and %2, %4 : i32 + llvm.return %5 : i32 + } + llvm.func @test11f(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.mul %arg1, %arg2 : i32 + %2 = llvm.xor %1, %arg0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.xor %1, %3 : i32 + %5 = llvm.and %4, %2 : i32 + llvm.return %5 : i32 + } + llvm.func @test12(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.and %arg0, %1 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test12commuted(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg1, %0 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.xor %arg0, %0 : i32 + %4 = llvm.xor %2, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test13(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.and %arg0, %2 : i32 + %4 = llvm.xor %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @test13commuted(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.xor %arg0, %0 : i32 + %2 = llvm.xor %arg1, %0 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.xor %1, %3 : i32 + llvm.return %4 : i32 + } + llvm.func @xor_or_xor_common_op_commute1(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg0, %arg2 : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_or_xor_common_op_commute2(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg2, %arg0 : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_or_xor_common_op_commute3(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg0, %arg2 : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_or_xor_common_op_commute4(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg2, %arg0 : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_or_xor_common_op_commute5(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg0, %arg2 : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_or_xor_common_op_commute6(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg2, %arg0 : i32 + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_or_xor_common_op_commute7(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg0, %arg2 : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_or_xor_common_op_commute8(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.xor %arg2, %arg0 : i32 + %1 = llvm.or %arg1, %arg0 : i32 + %2 = llvm.xor %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_or_xor_common_op_extra_use1(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i32 { + %0 = llvm.xor %arg0, %arg2 : i32 + llvm.store %0, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %1 = llvm.or %arg0, %arg1 : i32 + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_or_xor_common_op_extra_use2(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> i32 { + %0 = llvm.xor %arg0, %arg2 : i32 + %1 = llvm.or %arg0, %arg1 : i32 + llvm.store %1, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @xor_or_xor_common_op_extra_use3(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr, %arg4: !llvm.ptr) -> i32 { + %0 = llvm.xor %arg0, %arg2 : i32 + llvm.store %0, %arg3 {alignment = 4 : i64} : i32, !llvm.ptr + %1 = llvm.or %arg0, %arg1 : i32 + llvm.store %1, %arg4 {alignment = 4 : i64} : i32, !llvm.ptr + %2 = llvm.xor %0, %1 : i32 + llvm.return %2 : i32 + } + llvm.func @test15(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(33 : i8) : i8 + %1 = llvm.xor %arg1, %arg0 : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.xor %2, %arg1 : i8 + %4 = llvm.and %1, %3 : i8 + %5 = llvm.mul %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @test16(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(33 : i8) : i8 + %1 = llvm.xor %arg1, %arg0 : i8 + %2 = llvm.xor %arg0, %0 : i8 + %3 = llvm.xor %2, %arg1 : i8 + %4 = llvm.and %3, %1 : i8 + %5 = llvm.mul %4, %3 : i8 + llvm.return %5 : i8 + } + llvm.func @not_xor_to_or_not1(%arg0: i3, %arg1: i3, %arg2: i3) -> i3 { + %0 = llvm.mlir.constant(-1 : i3) : i3 + %1 = llvm.or %arg1, %arg2 : i3 + %2 = llvm.and %arg0, %arg2 : i3 + %3 = llvm.xor %2, %1 : i3 + %4 = llvm.xor %3, %0 : i3 + llvm.return %4 : i3 + } + llvm.func @not_xor_to_or_not2(%arg0: i3, %arg1: i3, %arg2: i3) -> i3 { + %0 = llvm.mlir.constant(-1 : i3) : i3 + %1 = llvm.or %arg2, %arg1 : i3 + %2 = llvm.and %arg0, %arg2 : i3 + %3 = llvm.xor %2, %1 : i3 + %4 = llvm.xor %3, %0 : i3 + llvm.return %4 : i3 + } + llvm.func @not_xor_to_or_not3(%arg0: i3, %arg1: i3, %arg2: i3) -> i3 { + %0 = llvm.mlir.constant(-1 : i3) : i3 + %1 = llvm.or %arg2, %arg1 : i3 + %2 = llvm.and %arg2, %arg0 : i3 + %3 = llvm.xor %2, %1 : i3 + %4 = llvm.xor %3, %0 : i3 + llvm.return %4 : i3 + } + llvm.func @not_xor_to_or_not4(%arg0: i3, %arg1: i3, %arg2: i3) -> i3 { + %0 = llvm.mlir.constant(-1 : i3) : i3 + %1 = llvm.or %arg1, %arg2 : i3 + %2 = llvm.and %arg2, %arg0 : i3 + %3 = llvm.xor %2, %1 : i3 + %4 = llvm.xor %3, %0 : i3 + llvm.return %4 : i3 + } + llvm.func @not_xor_to_or_not_vector(%arg0: vector<3xi5>, %arg1: vector<3xi5>, %arg2: vector<3xi5>) -> vector<3xi5> { + %0 = llvm.mlir.constant(-1 : i5) : i5 + %1 = llvm.mlir.constant(dense<-1> : vector<3xi5>) : vector<3xi5> + %2 = llvm.or %arg1, %arg2 : vector<3xi5> + %3 = llvm.and %arg0, %arg2 : vector<3xi5> + %4 = llvm.xor %2, %3 : vector<3xi5> + %5 = llvm.xor %4, %1 : vector<3xi5> + llvm.return %5 : vector<3xi5> + } + llvm.func @not_xor_to_or_not_vector_poison(%arg0: vector<3xi5>, %arg1: vector<3xi5>, %arg2: vector<3xi5>) -> vector<3xi5> { + %0 = llvm.mlir.constant(-1 : i5) : i5 + %1 = llvm.mlir.poison : i5 + %2 = llvm.mlir.undef : vector<3xi5> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<3xi5> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<3xi5> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi5> + %9 = llvm.or %arg1, %arg2 : vector<3xi5> + %10 = llvm.and %arg0, %arg2 : vector<3xi5> + %11 = llvm.xor %9, %10 : vector<3xi5> + %12 = llvm.xor %11, %8 : vector<3xi5> + llvm.return %12 : vector<3xi5> + } + llvm.func @not_xor_to_or_not_2use(%arg0: i3, %arg1: i3, %arg2: i3) -> i3 { + %0 = llvm.mlir.constant(-1 : i3) : i3 + %1 = llvm.or %arg1, %arg2 : i3 + %2 = llvm.and %arg0, %arg2 : i3 + %3 = llvm.xor %2, %1 : i3 + %4 = llvm.xor %3, %0 : i3 + llvm.call @use3(%3) : (i3) -> () + llvm.return %4 : i3 + } + llvm.func @xor_notand_to_or_not1(%arg0: i3, %arg1: i3, %arg2: i3) -> i3 { + %0 = llvm.mlir.constant(-1 : i3) : i3 + %1 = llvm.or %arg1, %arg2 : i3 + %2 = llvm.and %arg0, %arg2 : i3 + %3 = llvm.xor %2, %0 : i3 + %4 = llvm.xor %3, %1 : i3 + llvm.return %4 : i3 + } + llvm.func @xor_notand_to_or_not2(%arg0: i3, %arg1: i3, %arg2: i3) -> i3 { + %0 = llvm.mlir.constant(-1 : i3) : i3 + %1 = llvm.or %arg2, %arg1 : i3 + %2 = llvm.and %arg0, %arg2 : i3 + %3 = llvm.xor %2, %0 : i3 + %4 = llvm.xor %3, %1 : i3 + llvm.return %4 : i3 + } + llvm.func @xor_notand_to_or_not3(%arg0: i3, %arg1: i3, %arg2: i3) -> i3 { + %0 = llvm.mlir.constant(-1 : i3) : i3 + %1 = llvm.or %arg2, %arg1 : i3 + %2 = llvm.and %arg2, %arg0 : i3 + %3 = llvm.xor %2, %0 : i3 + %4 = llvm.xor %3, %1 : i3 + llvm.return %4 : i3 + } + llvm.func @xor_notand_to_or_not4(%arg0: i3, %arg1: i3, %arg2: i3) -> i3 { + %0 = llvm.mlir.constant(-1 : i3) : i3 + %1 = llvm.or %arg1, %arg2 : i3 + %2 = llvm.and %arg2, %arg0 : i3 + %3 = llvm.xor %2, %0 : i3 + %4 = llvm.xor %3, %1 : i3 + llvm.return %4 : i3 + } + llvm.func @xor_notand_to_or_not_vector(%arg0: vector<3xi5>, %arg1: vector<3xi5>, %arg2: vector<3xi5>) -> vector<3xi5> { + %0 = llvm.mlir.constant(-1 : i5) : i5 + %1 = llvm.mlir.constant(dense<-1> : vector<3xi5>) : vector<3xi5> + %2 = llvm.or %arg1, %arg2 : vector<3xi5> + %3 = llvm.and %arg0, %arg2 : vector<3xi5> + %4 = llvm.xor %3, %1 : vector<3xi5> + %5 = llvm.xor %4, %2 : vector<3xi5> + llvm.return %5 : vector<3xi5> + } + llvm.func @xor_notand_to_or_not_vector_poison(%arg0: vector<3xi5>, %arg1: vector<3xi5>, %arg2: vector<3xi5>) -> vector<3xi5> { + %0 = llvm.mlir.constant(-1 : i5) : i5 + %1 = llvm.mlir.poison : i5 + %2 = llvm.mlir.undef : vector<3xi5> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %0, %2[%3 : i32] : vector<3xi5> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %1, %4[%5 : i32] : vector<3xi5> + %7 = llvm.mlir.constant(2 : i32) : i32 + %8 = llvm.insertelement %0, %6[%7 : i32] : vector<3xi5> + %9 = llvm.or %arg1, %arg2 : vector<3xi5> + %10 = llvm.and %arg0, %arg2 : vector<3xi5> + %11 = llvm.xor %10, %8 : vector<3xi5> + %12 = llvm.xor %11, %9 : vector<3xi5> + llvm.return %12 : vector<3xi5> + } + llvm.func @xor_notand_to_or_not_2use(%arg0: i3, %arg1: i3, %arg2: i3) -> i3 { + %0 = llvm.mlir.constant(-1 : i3) : i3 + %1 = llvm.or %arg1, %arg2 : i3 + %2 = llvm.and %arg0, %arg2 : i3 + %3 = llvm.xor %2, %0 : i3 + %4 = llvm.xor %3, %1 : i3 + llvm.call @use3(%3) : (i3) -> () + llvm.return %4 : i3 + } + llvm.func @use3(i3) +} diff --git a/test/LLVMDialect/InstCombine/zero-point-zero-add.ll.mlir b/test/LLVMDialect/InstCombine/zero-point-zero-add.ll.mlir index 93c584cd1..3c4971424 100644 --- a/test/LLVMDialect/InstCombine/zero-point-zero-add.ll.mlir +++ b/test/LLVMDialect/InstCombine/zero-point-zero-add.ll.mlir @@ -1,19 +1,15 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "fabs", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.000000e+00 : f64} : () -> f64 - %1 = "llvm.fadd"(%arg0, %0) : (f64, f64) -> f64 - %2 = "llvm.fadd"(%1, %0) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: f64): // no predecessors - %0 = "llvm.mlir.constant"() {value = 0.000000e+00 : f64} : () -> f64 - %1 = "llvm.call"(%arg0) {callee = @fabs, fastmathFlags = #llvm.fastmath<>} : (f64) -> f64 - %2 = "llvm.fadd"(%1, %0) : (f64, f64) -> f64 - "llvm.return"(%2) : (f64) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @fabs(f64) -> f64 attributes {memory = #llvm.memory_effects} + llvm.func @test(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.fadd %arg0, %0 : f64 + %2 = llvm.fadd %1, %0 : f64 + llvm.return %2 : f64 + } + llvm.func @test1(%arg0: f64) -> f64 { + %0 = llvm.mlir.constant(0.000000e+00 : f64) : f64 + %1 = llvm.call @fabs(%arg0) : (f64) -> f64 + %2 = llvm.fadd %1, %0 : f64 + llvm.return %2 : f64 + } +} diff --git a/test/LLVMDialect/InstCombine/zeroext-and-reduce.ll.mlir b/test/LLVMDialect/InstCombine/zeroext-and-reduce.ll.mlir index 5c08f4e44..cc710f3a0 100644 --- a/test/LLVMDialect/InstCombine/zeroext-and-reduce.ll.mlir +++ b/test/LLVMDialect/InstCombine/zeroext-and-reduce.ll.mlir @@ -1,10 +1,8 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i8): // no predecessors - %0 = "llvm.mlir.constant"() {value = 65544 : i32} : () -> i32 - %1 = "llvm.zext"(%arg0) : (i8) -> i32 - %2 = "llvm.and"(%1, %0) : (i32, i32) -> i32 - "llvm.return"(%2) : (i32) -> () - }) {linkage = 10 : i64, sym_name = "test1", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test1(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(65544 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.and %1, %0 : i32 + llvm.return %2 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/zext-bool-add-sub.ll.mlir b/test/LLVMDialect/InstCombine/zext-bool-add-sub.ll.mlir new file mode 100644 index 000000000..7dd471e8d --- /dev/null +++ b/test/LLVMDialect/InstCombine/zext-bool-add-sub.ll.mlir @@ -0,0 +1,240 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @a(%arg0: i1 {llvm.zeroext}, %arg1: i1 {llvm.zeroext}) -> i32 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.zext %arg0 : i1 to i32 + %3 = llvm.zext %arg1 : i1 to i32 + %4 = llvm.sub %0, %3 : i32 + %5 = llvm.add %2, %1 : i32 + %6 = llvm.add %5, %4 : i32 + llvm.return %6 : i32 + } + llvm.func @PR30273_select(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.mlir.constant(2 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.zext %arg0 : i1 to i32 + %3 = llvm.select %arg0, %0, %1 : i1, i32 + %4 = llvm.select %arg1, %3, %2 : i1, i32 + llvm.return %4 : i32 + } + llvm.func @PR30273_zext_add(%arg0: i1, %arg1: i1) -> i32 { + %0 = llvm.zext %arg0 : i1 to i32 + %1 = llvm.zext %arg1 : i1 to i32 + %2 = llvm.add %1, %0 overflow : i32 + llvm.return %2 : i32 + } + llvm.func @PR30273_three_bools(%arg0: i1, %arg1: i1, %arg2: i1) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.add %1, %0 overflow : i32 + %3 = llvm.select %arg1, %2, %1 : i1, i32 + %4 = llvm.add %3, %0 overflow : i32 + %5 = llvm.select %arg2, %4, %3 : i1, i32 + llvm.return %5 : i32 + } + llvm.func @zext_add_scalar(%arg0: i1) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.add %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @zext_add_vec_splat(%arg0: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<42> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.add %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @zext_add_vec(%arg0: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 23]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.add %1, %0 : vector<2xi32> + llvm.return %2 : vector<2xi32> + } + llvm.func @use(i64) + llvm.func @zext_negate(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.zext %arg0 : i1 to i64 + %2 = llvm.sub %0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @zext_negate_extra_use(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.zext %arg0 : i1 to i64 + %2 = llvm.sub %0, %1 : i64 + llvm.call @use(%1) : (i64) -> () + llvm.return %2 : i64 + } + llvm.func @zext_negate_vec(%arg0: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.zext %arg0 : vector<2xi1> to vector<2xi64> + %3 = llvm.sub %1, %2 : vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @zext_negate_vec_poison_elt(%arg0: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.poison : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.zext %arg0 : vector<2xi1> to vector<2xi64> + %8 = llvm.sub %6, %7 : vector<2xi64> + llvm.return %8 : vector<2xi64> + } + llvm.func @zext_sub_const(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.zext %arg0 : i1 to i64 + %2 = llvm.sub %0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @zext_sub_const_extra_use(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.zext %arg0 : i1 to i64 + %2 = llvm.sub %0, %1 : i64 + llvm.call @use(%1) : (i64) -> () + llvm.return %2 : i64 + } + llvm.func @zext_sub_const_vec(%arg0: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[42, 3]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi64> + %2 = llvm.sub %0, %1 : vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @zext_sub_const_vec_poison_elt(%arg0: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.poison : i64 + %1 = llvm.mlir.constant(42 : i64) : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.zext %arg0 : vector<2xi1> to vector<2xi64> + %8 = llvm.sub %6, %7 : vector<2xi64> + llvm.return %8 : vector<2xi64> + } + llvm.func @sext_negate(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sext %arg0 : i1 to i64 + %2 = llvm.sub %0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @sext_negate_extra_use(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.sext %arg0 : i1 to i64 + %2 = llvm.sub %0, %1 : i64 + llvm.call @use(%1) : (i64) -> () + llvm.return %2 : i64 + } + llvm.func @sext_negate_vec(%arg0: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.mlir.constant(dense<0> : vector<2xi64>) : vector<2xi64> + %2 = llvm.sext %arg0 : vector<2xi1> to vector<2xi64> + %3 = llvm.sub %1, %2 : vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @sext_negate_vec_poison_elt(%arg0: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.poison : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.sext %arg0 : vector<2xi1> to vector<2xi64> + %8 = llvm.sub %6, %7 : vector<2xi64> + llvm.return %8 : vector<2xi64> + } + llvm.func @sext_sub_const(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.sext %arg0 : i1 to i64 + %2 = llvm.sub %0, %1 : i64 + llvm.return %2 : i64 + } + llvm.func @sext_sub_const_extra_use(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.sext %arg0 : i1 to i64 + %2 = llvm.sub %0, %1 : i64 + llvm.call @use(%1) : (i64) -> () + llvm.return %2 : i64 + } + llvm.func @sext_sub_const_vec(%arg0: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[42, 3]> : vector<2xi64>) : vector<2xi64> + %1 = llvm.sext %arg0 : vector<2xi1> to vector<2xi64> + %2 = llvm.sub %0, %1 : vector<2xi64> + llvm.return %2 : vector<2xi64> + } + llvm.func @sext_sub_const_vec_poison_elt(%arg0: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.constant(42 : i64) : i64 + %1 = llvm.mlir.poison : i64 + %2 = llvm.mlir.undef : vector<2xi64> + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.insertelement %1, %2[%3 : i32] : vector<2xi64> + %5 = llvm.mlir.constant(1 : i32) : i32 + %6 = llvm.insertelement %0, %4[%5 : i32] : vector<2xi64> + %7 = llvm.sext %arg0 : vector<2xi1> to vector<2xi64> + %8 = llvm.sub %6, %7 : vector<2xi64> + llvm.return %8 : vector<2xi64> + } + llvm.func @sext_sub(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + %1 = llvm.sub %arg0, %0 : i8 + llvm.return %1 : i8 + } + llvm.func @sext_sub_vec(%arg0: vector<2xi8>, %arg1: vector<2xi1>) -> vector<2xi8> { + %0 = llvm.sext %arg1 : vector<2xi1> to vector<2xi8> + %1 = llvm.sub %arg0, %0 : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @sext_sub_vec_nsw(%arg0: vector<2xi8>, %arg1: vector<2xi1>) -> vector<2xi8> { + %0 = llvm.sext %arg1 : vector<2xi1> to vector<2xi8> + %1 = llvm.sub %arg0, %0 overflow : vector<2xi8> + llvm.return %1 : vector<2xi8> + } + llvm.func @sext_sub_nuw(%arg0: i8, %arg1: i1) -> i8 { + %0 = llvm.sext %arg1 : i1 to i8 + %1 = llvm.sub %arg0, %0 overflow : i8 + llvm.return %1 : i8 + } + llvm.func @sextbool_add(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.sext %arg0 : i1 to i32 + %1 = llvm.add %0, %arg1 : i32 + llvm.return %1 : i32 + } + llvm.func @sextbool_add_commute(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.urem %arg1, %0 : i32 + %2 = llvm.sext %arg0 : i1 to i32 + %3 = llvm.add %1, %2 : i32 + llvm.return %3 : i32 + } + llvm.func @use32(i32) + llvm.func @sextbool_add_uses(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.sext %arg0 : i1 to i32 + llvm.call @use32(%0) : (i32) -> () + %1 = llvm.add %0, %arg1 : i32 + llvm.return %1 : i32 + } + llvm.func @sextbool_add_vector(%arg0: vector<4xi1>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.sext %arg0 : vector<4xi1> to vector<4xi32> + %1 = llvm.add %arg1, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } + llvm.func @zextbool_sub(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.zext %arg0 : i1 to i32 + %1 = llvm.sub %0, %arg1 : i32 + llvm.return %1 : i32 + } + llvm.func @zextbool_sub_uses(%arg0: i1, %arg1: i32) -> i32 { + %0 = llvm.zext %arg0 : i1 to i32 + llvm.call @use32(%0) : (i32) -> () + %1 = llvm.sub %arg1, %0 : i32 + llvm.return %1 : i32 + } + llvm.func @zextbool_sub_vector(%arg0: vector<4xi1>, %arg1: vector<4xi32>) -> vector<4xi32> { + %0 = llvm.zext %arg0 : vector<4xi1> to vector<4xi32> + %1 = llvm.sub %arg1, %0 : vector<4xi32> + llvm.return %1 : vector<4xi32> + } +} diff --git a/test/LLVMDialect/InstCombine/zext-ctlz-trunc-to-ctlz-add.ll.mlir b/test/LLVMDialect/InstCombine/zext-ctlz-trunc-to-ctlz-add.ll.mlir index b4ba8405f..fb4c0b2e4 100644 --- a/test/LLVMDialect/InstCombine/zext-ctlz-trunc-to-ctlz-add.ll.mlir +++ b/test/LLVMDialect/InstCombine/zext-ctlz-trunc-to-ctlz-add.ll.mlir @@ -1,79 +1,48 @@ -"module"() ( { - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ctlz.i3", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ctlz.i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ctlz.i34", type = !llvm.func} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ctlz.v2i33", type = !llvm.func (vector<2xi33>, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ctlz.v2i32", type = !llvm.func (vector<2xi32>, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ctlz.nxv2i64", type = !llvm.func (vec, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "llvm.ctlz.nxv2i63", type = !llvm.func (vec, i1)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - }) {linkage = 10 : i64, sym_name = "use1", type = !llvm.func)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i16): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.zext"(%arg0) : (i16) -> i32 - %2 = "llvm.call"(%1, %0) {callee = @llvm.ctlz.i32, fastmathFlags = #llvm.fastmath<>} : (i32, i1) -> i32 - %3 = "llvm.trunc"(%2) : (i32) -> i16 - "llvm.return"(%3) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "trunc_ctlz_zext_i16_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi8>): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.zext"(%arg0) : (vector<2xi8>) -> vector<2xi33> - %2 = "llvm.call"(%1, %0) {callee = @llvm.ctlz.v2i33, fastmathFlags = #llvm.fastmath<>} : (vector<2xi33>, i1) -> vector<2xi33> - %3 = "llvm.trunc"(%2) : (vector<2xi33>) -> vector<2xi8> - "llvm.return"(%3) : (vector<2xi8>) -> () - }) {linkage = 10 : i64, sym_name = "trunc_ctlz_zext_v2i8_v2i33", type = !llvm.func (vector<2xi8>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.zext"(%arg0) : (!llvm.vec) -> !llvm.vec - %2 = "llvm.call"(%1, %0) {callee = @llvm.ctlz.nxv2i64, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec, i1) -> !llvm.vec - %3 = "llvm.trunc"(%2) : (!llvm.vec) -> !llvm.vec - "llvm.return"(%3) : (!llvm.vec) -> () - }) {linkage = 10 : i64, sym_name = "trunc_ctlz_zext_nxv2i16_nxv2i64", type = !llvm.func (vec)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: vector<2xi17>): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.zext"(%arg0) : (vector<2xi17>) -> vector<2xi32> - %2 = "llvm.call"(%1, %0) {callee = @llvm.ctlz.v2i32, fastmathFlags = #llvm.fastmath<>} : (vector<2xi32>, i1) -> vector<2xi32> - %3 = "llvm.trunc"(%2) : (vector<2xi32>) -> vector<2xi17> - "llvm.call"(%2) {callee = @use, fastmathFlags = #llvm.fastmath<>} : (vector<2xi32>) -> () - "llvm.return"(%3) : (vector<2xi17>) -> () - }) {linkage = 10 : i64, sym_name = "trunc_ctlz_zext_v2i17_v2i32_multiple_uses", type = !llvm.func (vector<2xi17>)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: !llvm.vec): // no predecessors - %0 = "llvm.mlir.constant"() {value = true} : () -> i1 - %1 = "llvm.zext"(%arg0) : (!llvm.vec) -> !llvm.vec - %2 = "llvm.call"(%1, %0) {callee = @llvm.ctlz.nxv2i63, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec, i1) -> !llvm.vec - %3 = "llvm.trunc"(%2) : (!llvm.vec) -> !llvm.vec - "llvm.call"(%1) {callee = @use1, fastmathFlags = #llvm.fastmath<>} : (!llvm.vec) -> () - "llvm.return"(%3) : (!llvm.vec) -> () - }) {linkage = 10 : i64, sym_name = "trunc_ctlz_zext_nxv2i16_nxv2i63_multiple_uses", type = !llvm.func (vec)>} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i10): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.zext"(%arg0) : (i10) -> i32 - %2 = "llvm.call"(%1, %0) {callee = @llvm.ctlz.i32, fastmathFlags = #llvm.fastmath<>} : (i32, i1) -> i32 - %3 = "llvm.trunc"(%2) : (i32) -> i16 - "llvm.return"(%3) : (i16) -> () - }) {linkage = 10 : i64, sym_name = "trunc_ctlz_zext_i10_i32", type = !llvm.func} : () -> () - "llvm.func"() ( { - ^bb0(%arg0: i3): // no predecessors - %0 = "llvm.mlir.constant"() {value = false} : () -> i1 - %1 = "llvm.zext"(%arg0) : (i3) -> i34 - %2 = "llvm.call"(%1, %0) {callee = @llvm.ctlz.i34, fastmathFlags = #llvm.fastmath<>} : (i34, i1) -> i34 - %3 = "llvm.trunc"(%2) : (i34) -> i3 - "llvm.return"(%3) : (i3) -> () - }) {linkage = 10 : i64, sym_name = "trunc_ctlz_zext_i3_i34", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @use(vector<2xi32>) + llvm.func @use1(!llvm.vec) + llvm.func @trunc_ctlz_zext_i16_i32(%arg0: i16) -> i16 { + %0 = llvm.zext %arg0 : i16 to i32 + %1 = "llvm.intr.ctlz"(%0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @trunc_ctlz_zext_v2i8_v2i33(%arg0: vector<2xi8>) -> vector<2xi8> { + %0 = llvm.zext %arg0 : vector<2xi8> to vector<2xi33> + %1 = "llvm.intr.ctlz"(%0) <{is_zero_poison = true}> : (vector<2xi33>) -> vector<2xi33> + %2 = llvm.trunc %1 : vector<2xi33> to vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @trunc_ctlz_zext_nxv2i16_nxv2i64(%arg0: !llvm.vec) -> !llvm.vec { + %0 = llvm.zext %arg0 : !llvm.vec to !llvm.vec + %1 = "llvm.intr.ctlz"(%0) <{is_zero_poison = false}> : (!llvm.vec) -> !llvm.vec + %2 = llvm.trunc %1 : !llvm.vec to !llvm.vec + llvm.return %2 : !llvm.vec + } + llvm.func @trunc_ctlz_zext_v2i17_v2i32_multiple_uses(%arg0: vector<2xi17>) -> vector<2xi17> { + %0 = llvm.zext %arg0 : vector<2xi17> to vector<2xi32> + %1 = "llvm.intr.ctlz"(%0) <{is_zero_poison = false}> : (vector<2xi32>) -> vector<2xi32> + %2 = llvm.trunc %1 : vector<2xi32> to vector<2xi17> + llvm.call @use(%1) : (vector<2xi32>) -> () + llvm.return %2 : vector<2xi17> + } + llvm.func @trunc_ctlz_zext_nxv2i16_nxv2i63_multiple_uses(%arg0: !llvm.vec) -> !llvm.vec { + %0 = llvm.zext %arg0 : !llvm.vec to !llvm.vec + %1 = "llvm.intr.ctlz"(%0) <{is_zero_poison = true}> : (!llvm.vec) -> !llvm.vec + %2 = llvm.trunc %1 : !llvm.vec to !llvm.vec + llvm.call @use1(%0) : (!llvm.vec) -> () + llvm.return %2 : !llvm.vec + } + llvm.func @trunc_ctlz_zext_i10_i32(%arg0: i10) -> i16 { + %0 = llvm.zext %arg0 : i10 to i32 + %1 = "llvm.intr.ctlz"(%0) <{is_zero_poison = false}> : (i32) -> i32 + %2 = llvm.trunc %1 : i32 to i16 + llvm.return %2 : i16 + } + llvm.func @trunc_ctlz_zext_i3_i34(%arg0: i3) -> i3 { + %0 = llvm.zext %arg0 : i3 to i34 + %1 = "llvm.intr.ctlz"(%0) <{is_zero_poison = false}> : (i34) -> i34 + %2 = llvm.trunc %1 : i34 to i3 + llvm.return %2 : i3 + } +} diff --git a/test/LLVMDialect/InstCombine/zext-fold.ll.mlir b/test/LLVMDialect/InstCombine/zext-fold.ll.mlir new file mode 100644 index 000000000..bef14a839 --- /dev/null +++ b/test/LLVMDialect/InstCombine/zext-fold.ll.mlir @@ -0,0 +1,10 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @test2(%arg0: f32, %arg1: f32) -> i32 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.fcmp "uno" %arg0, %arg1 : f32 + %2 = llvm.zext %1 : i1 to i8 + %3 = llvm.xor %2, %0 : i8 + %4 = llvm.zext %3 : i8 to i32 + llvm.return %4 : i32 + } +} diff --git a/test/LLVMDialect/InstCombine/zext-or-icmp.ll.mlir b/test/LLVMDialect/InstCombine/zext-or-icmp.ll.mlir new file mode 100644 index 000000000..d8b90156d --- /dev/null +++ b/test/LLVMDialect/InstCombine/zext-or-icmp.ll.mlir @@ -0,0 +1,161 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @zext_or_icmp_icmp(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.icmp "eq" %2, %1 : i8 + %4 = llvm.icmp "eq" %arg1, %1 : i8 + %5 = llvm.or %3, %4 : i1 + %6 = llvm.zext %5 : i1 to i8 + llvm.return %6 : i8 + } + llvm.func @zext_or_icmp_icmp_logical(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(1 : i8) : i8 + %1 = llvm.mlir.constant(0 : i8) : i8 + %2 = llvm.mlir.constant(true) : i1 + %3 = llvm.and %arg0, %0 : i8 + %4 = llvm.icmp "eq" %3, %1 : i8 + %5 = llvm.icmp "eq" %arg1, %1 : i8 + %6 = llvm.select %4, %2, %5 : i1, i1 + %7 = llvm.zext %6 : i1 to i8 + llvm.return %7 : i8 + } + llvm.func @dont_widen_undef() -> i32 { + %0 = llvm.mlir.constant(33 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(65535 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + llvm.br ^bb1(%0 : i32) + ^bb1(%4: i32): // pred: ^bb0 + %5 = llvm.icmp "ugt" %4, %1 : i32 + %6 = llvm.lshr %1, %4 : i32 + %7 = llvm.and %6, %2 : i32 + %8 = llvm.icmp "ne" %7, %3 : i32 + %9 = llvm.or %5, %8 : i1 + %10 = llvm.zext %9 : i1 to i32 + llvm.return %10 : i32 + } + llvm.func @dont_widen_undef_logical() -> i32 { + %0 = llvm.mlir.constant(33 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(65535 : i32) : i32 + %3 = llvm.mlir.constant(0 : i32) : i32 + %4 = llvm.mlir.constant(true) : i1 + llvm.br ^bb1(%0 : i32) + ^bb1(%5: i32): // pred: ^bb0 + %6 = llvm.icmp "ugt" %5, %1 : i32 + %7 = llvm.lshr %1, %5 : i32 + %8 = llvm.and %7, %2 : i32 + %9 = llvm.icmp "ne" %8, %3 : i32 + %10 = llvm.select %6, %4, %9 : i1, i1 + %11 = llvm.zext %10 : i1 to i32 + llvm.return %11 : i32 + } + llvm.func @knownbits_out_of_range_shift(%arg0: i32) -> i1 { + %0 = llvm.mlir.constant(63 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + llvm.br ^bb1(%0 : i32) + ^bb1(%2: i32): // pred: ^bb0 + %3 = llvm.lshr %arg0, %2 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.return %4 : i1 + } + llvm.func @zext_or_eq_ult_add(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(3 : i32) : i32 + %2 = llvm.mlir.constant(5 : i32) : i32 + %3 = llvm.add %arg0, %0 : i32 + %4 = llvm.icmp "ult" %3, %1 : i32 + %5 = llvm.icmp "eq" %arg0, %2 : i32 + %6 = llvm.or %4, %5 : i1 + %7 = llvm.zext %6 : i1 to i32 + llvm.return %7 : i32 + } + llvm.func @select_zext_or_eq_ult_add(%arg0: i32) -> i32 { + %0 = llvm.mlir.constant(-3 : i32) : i32 + %1 = llvm.mlir.constant(2 : i32) : i32 + %2 = llvm.mlir.constant(5 : i32) : i32 + %3 = llvm.mlir.constant(1 : i32) : i32 + %4 = llvm.add %arg0, %0 : i32 + %5 = llvm.icmp "ult" %4, %1 : i32 + %6 = llvm.icmp "eq" %arg0, %2 : i32 + %7 = llvm.zext %6 : i1 to i32 + %8 = llvm.select %5, %3, %7 : i1, i32 + llvm.return %8 : i32 + } + llvm.func @PR49475(%arg0: i32, %arg1: i16) -> i32 { + %0 = llvm.mlir.constant(1 : i16) : i16 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(0 : i16) : i16 + %3 = llvm.and %arg1, %0 : i16 + %4 = llvm.icmp "eq" %arg0, %1 : i32 + %5 = llvm.icmp "eq" %3, %2 : i16 + %6 = llvm.or %4, %5 : i1 + %7 = llvm.zext %6 : i1 to i32 + llvm.return %7 : i32 + } + llvm.func @PR49475_infloop(%arg0: i32, %arg1: i16, %arg2: i64, %arg3: i8) -> i8 { + %0 = llvm.mlir.constant(0 : i32) : i32 + %1 = llvm.mlir.constant(0 : i16) : i16 + %2 = llvm.mlir.constant(140 : i64) : i64 + %3 = llvm.mlir.constant(32 : i64) : i64 + %4 = llvm.icmp "eq" %arg0, %0 : i32 + %5 = llvm.icmp "eq" %arg1, %1 : i16 + %6 = llvm.or %4, %5 : i1 + %7 = llvm.zext %6 : i1 to i32 + %8 = llvm.and %arg0, %7 : i32 + %9 = llvm.zext %8 : i32 to i64 + %10 = llvm.xor %9, %2 : i64 + %11 = llvm.sext %arg3 : i8 to i64 + %12 = llvm.sub %11, %arg2 : i64 + %13 = llvm.shl %12, %3 : i64 + %14 = llvm.ashr %13, %3 : i64 + %15 = llvm.icmp "sge" %10, %14 : i64 + %16 = llvm.zext %15 : i1 to i16 + %17 = llvm.or %arg1, %16 : i16 + %18 = llvm.trunc %17 : i16 to i8 + %19 = llvm.add %arg3, %18 : i8 + %20 = llvm.icmp "eq" %17, %1 : i16 + "llvm.intr.assume"(%20) : (i1) -> () + llvm.return %19 : i8 + } + llvm.func @PR51762(%arg0: !llvm.ptr, %arg1: i32, %arg2: i16, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: i32, %arg7: i1) -> i1 { + %0 = llvm.mlir.poison : i32 + %1 = llvm.mlir.constant(32 : i64) : i64 + %2 = llvm.mlir.constant(0 : i64) : i64 + %3 = llvm.mlir.constant(31 : i32) : i32 + llvm.br ^bb1(%0 : i32) + ^bb1(%4: i32): // 2 preds: ^bb0, ^bb2 + llvm.cond_br %arg7, ^bb2, ^bb3 + ^bb2: // pred: ^bb1 + %5 = llvm.ashr %arg1, %3 : i32 + llvm.br ^bb1(%5 : i32) + ^bb3: // pred: ^bb1 + %6 = llvm.sext %arg2 : i16 to i64 + %7 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i32 + %8 = llvm.zext %4 : i32 to i64 + %9 = llvm.shl %8, %1 overflow : i64 + %10 = llvm.zext %7 : i32 to i64 + %11 = llvm.or %9, %10 : i64 + %12 = llvm.urem %6, %11 : i64 + %13 = llvm.icmp "ne" %12, %2 : i64 + %14 = llvm.icmp "eq" %11, %2 : i64 + %15 = llvm.or %13, %14 : i1 + %16 = llvm.zext %15 : i1 to i32 + %17 = llvm.load %arg4 {alignment = 4 : i64} : !llvm.ptr -> i32 + %18 = llvm.sext %arg2 : i16 to i32 + %19 = llvm.icmp "sge" %17, %18 : i32 + %20 = llvm.zext %19 : i1 to i32 + %21 = llvm.load %arg5 {alignment = 4 : i64} : !llvm.ptr -> i32 + %22 = llvm.add %21, %20 overflow : i32 + llvm.store %22, %arg5 {alignment = 4 : i64} : i32, !llvm.ptr + %23 = llvm.srem %16, %22 : i32 + %24 = llvm.zext %23 : i32 to i64 + %25 = llvm.udiv %11, %24 : i64 + %26 = llvm.trunc %25 : i64 to i32 + llvm.store %26, %arg4 {alignment = 8 : i64} : i32, !llvm.ptr + %27 = llvm.icmp "ult" %11, %24 : i64 + "llvm.intr.assume"(%27) : (i1) -> () + llvm.return %27 : i1 + } +} diff --git a/test/LLVMDialect/InstCombine/zext-phi.ll.mlir b/test/LLVMDialect/InstCombine/zext-phi.ll.mlir index bb9c5ac9e..1aac70af9 100644 --- a/test/LLVMDialect/InstCombine/zext-phi.ll.mlir +++ b/test/LLVMDialect/InstCombine/zext-phi.ll.mlir @@ -1,13 +1,11 @@ -"module"() ( { - "llvm.func"() ( { - ^bb0(%arg0: i1, %arg1: i1): // no predecessors - %0 = "llvm.zext"(%arg0) : (i1) -> i64 - "llvm.cond_br"(%arg0, %0)[^bb1, ^bb2] {operand_segment_sizes = dense<[1, 0, 1]> : vector<3xi32>} : (i1, i64) -> () +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.func @sink_i1_casts(%arg0: i1, %arg1: i1) -> i64 { + %0 = llvm.zext %arg0 : i1 to i64 + llvm.cond_br %arg0, ^bb1, ^bb2(%0 : i64) ^bb1: // pred: ^bb0 - %1 = "llvm.zext"(%arg1) : (i1) -> i64 - "llvm.br"(%1)[^bb2] : (i64) -> () + %1 = llvm.zext %arg1 : i1 to i64 + llvm.br ^bb2(%1 : i64) ^bb2(%2: i64): // 2 preds: ^bb0, ^bb1 - "llvm.return"(%2) : (i64) -> () - }) {linkage = 10 : i64, sym_name = "sink_i1_casts", type = !llvm.func} : () -> () - "module_terminator"() : () -> () -}) : () -> () + llvm.return %2 : i64 + } +} diff --git a/test/LLVMDialect/InstCombine/zext.ll.mlir b/test/LLVMDialect/InstCombine/zext.ll.mlir new file mode 100644 index 000000000..dd8c9ab3f --- /dev/null +++ b/test/LLVMDialect/InstCombine/zext.ll.mlir @@ -0,0 +1,480 @@ +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<4xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry : vector<2xi64>>, #dlti.dl_entry<"dlti.endianness", "little">>} { + llvm.mlir.global external @g() {addr_space = 0 : i32} : i8 + llvm.func @use1(i1) + llvm.func @use32(i32) + llvm.func @use64(i64) + llvm.func @use_vec(vector<2xi9>) + llvm.func @test_sext_zext(%arg0: i16) -> i64 { + %0 = llvm.zext %arg0 : i16 to i32 + %1 = llvm.sext %0 : i32 to i64 + llvm.return %1 : i64 + } + llvm.func @test2(%arg0: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.constant(true) : i1 + %1 = llvm.mlir.constant(dense : vector<2xi1>) : vector<2xi1> + %2 = llvm.xor %arg0, %1 : vector<2xi1> + %3 = llvm.zext %2 : vector<2xi1> to vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @test3(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[23, 42]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %2 = llvm.and %1, %0 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @test4(%arg0: vector<2xi64>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<[23, 42]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.trunc %arg0 : vector<2xi64> to vector<2xi32> + %2 = llvm.and %1, %0 : vector<2xi32> + %3 = llvm.xor %2, %0 : vector<2xi32> + %4 = llvm.zext %3 : vector<2xi32> to vector<2xi64> + llvm.return %4 : vector<2xi64> + } + llvm.func @fold_xor_zext_sandwich(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.zext %arg0 : i1 to i32 + %2 = llvm.xor %1, %0 : i32 + %3 = llvm.zext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @fold_xor_zext_sandwich_vec(%arg0: vector<2xi1>) -> vector<2xi64> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.zext %arg0 : vector<2xi1> to vector<2xi32> + %2 = llvm.xor %1, %0 : vector<2xi32> + %3 = llvm.zext %2 : vector<2xi32> to vector<2xi64> + llvm.return %3 : vector<2xi64> + } + llvm.func @fold_and_zext_icmp(%arg0: i64, %arg1: i64, %arg2: i64) -> i8 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i64 + %1 = llvm.zext %0 : i1 to i8 + %2 = llvm.icmp "slt" %arg0, %arg2 : i64 + %3 = llvm.zext %2 : i1 to i8 + %4 = llvm.and %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @fold_or_zext_icmp(%arg0: i64, %arg1: i64, %arg2: i64) -> i8 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i64 + %1 = llvm.zext %0 : i1 to i8 + %2 = llvm.icmp "slt" %arg0, %arg2 : i64 + %3 = llvm.zext %2 : i1 to i8 + %4 = llvm.or %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @fold_xor_zext_icmp(%arg0: i64, %arg1: i64, %arg2: i64) -> i8 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i64 + %1 = llvm.zext %0 : i1 to i8 + %2 = llvm.icmp "slt" %arg0, %arg2 : i64 + %3 = llvm.zext %2 : i1 to i8 + %4 = llvm.xor %1, %3 : i8 + llvm.return %4 : i8 + } + llvm.func @fold_nested_logic_zext_icmp(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i8 { + %0 = llvm.icmp "sgt" %arg0, %arg1 : i64 + %1 = llvm.zext %0 : i1 to i8 + %2 = llvm.icmp "slt" %arg0, %arg2 : i64 + %3 = llvm.zext %2 : i1 to i8 + %4 = llvm.and %1, %3 : i8 + %5 = llvm.icmp "eq" %arg0, %arg3 : i64 + %6 = llvm.zext %5 : i1 to i8 + %7 = llvm.or %4, %6 : i8 + llvm.return %7 : i8 + } + llvm.func @sext_zext_apint1(%arg0: i77) -> i1024 { + %0 = llvm.zext %arg0 : i77 to i533 + %1 = llvm.sext %0 : i533 to i1024 + llvm.return %1 : i1024 + } + llvm.func @sext_zext_apint2(%arg0: i11) -> i47 { + %0 = llvm.zext %arg0 : i11 to i39 + %1 = llvm.sext %0 : i39 to i47 + llvm.return %1 : i47 + } + llvm.func @masked_bit_set(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @masked_bit_clear(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %3 = llvm.shl %0, %arg1 : vector<2xi32> + %4 = llvm.and %3, %arg0 : vector<2xi32> + %5 = llvm.icmp "eq" %4, %2 : vector<2xi32> + %6 = llvm.zext %5 : vector<2xi1> to vector<2xi32> + llvm.return %6 : vector<2xi32> + } + llvm.func @masked_bit_set_commute(%arg0: vector<2xi32>, %arg1: vector<2xi32>) -> vector<2xi32> { + %0 = llvm.mlir.constant(dense<[42, 3]> : vector<2xi32>) : vector<2xi32> + %1 = llvm.mlir.constant(dense<1> : vector<2xi32>) : vector<2xi32> + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.mlir.constant(dense<0> : vector<2xi32>) : vector<2xi32> + %4 = llvm.srem %0, %arg0 : vector<2xi32> + %5 = llvm.shl %1, %arg1 : vector<2xi32> + %6 = llvm.and %4, %5 : vector<2xi32> + %7 = llvm.icmp "ne" %6, %3 : vector<2xi32> + %8 = llvm.zext %7 : vector<2xi1> to vector<2xi32> + llvm.return %8 : vector<2xi32> + } + llvm.func @masked_bit_clear_commute(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.mlir.constant(1 : i32) : i32 + %2 = llvm.mlir.constant(0 : i32) : i32 + %3 = llvm.srem %0, %arg0 : i32 + %4 = llvm.shl %1, %arg1 : i32 + %5 = llvm.and %3, %4 : i32 + %6 = llvm.icmp "eq" %5, %2 : i32 + %7 = llvm.zext %6 : i1 to i32 + llvm.return %7 : i32 + } + llvm.func @masked_bit_set_use1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @masked_bit_set_use2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @masked_bit_set_use3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @masked_bit_clear_use1(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @masked_bit_clear_use2(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + llvm.call @use32(%3) : (i32) -> () + %4 = llvm.icmp "eq" %3, %1 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @masked_bit_clear_use3(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "eq" %3, %1 : i32 + llvm.call @use1(%4) : (i1) -> () + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @masked_bits_set(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(3 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @div_bit_set(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.sdiv %2, %arg0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @masked_bit_set_nonzero_cmp(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.shl %0, %arg1 : i32 + %2 = llvm.and %1, %arg0 : i32 + %3 = llvm.icmp "ne" %2, %0 : i32 + %4 = llvm.zext %3 : i1 to i32 + llvm.return %4 : i32 + } + llvm.func @masked_bit_wrong_pred(%arg0: i32, %arg1: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "sgt" %3, %1 : i32 + %5 = llvm.zext %4 : i1 to i32 + llvm.return %5 : i32 + } + llvm.func @zext_or_masked_bit_test(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.icmp "eq" %arg2, %arg1 : i32 + %6 = llvm.or %4, %5 : i1 + %7 = llvm.zext %6 : i1 to i32 + llvm.return %7 : i32 + } + llvm.func @zext_or_masked_bit_test_uses(%arg0: i32, %arg1: i32, %arg2: i32) -> i32 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.shl %0, %arg1 : i32 + %3 = llvm.and %2, %arg0 : i32 + %4 = llvm.icmp "ne" %3, %1 : i32 + %5 = llvm.icmp "eq" %arg2, %arg1 : i32 + %6 = llvm.or %4, %5 : i1 + llvm.call @use1(%6) : (i1) -> () + %7 = llvm.zext %6 : i1 to i32 + llvm.return %7 : i32 + } + llvm.func @notneg_zext_wider(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "sgt" %arg0, %0 : i8 + %2 = llvm.zext %1 : i1 to i32 + llvm.return %2 : i32 + } + llvm.func @notneg_zext_narrower(%arg0: vector<2xi32>) -> vector<2xi8> { + %0 = llvm.mlir.constant(dense<-1> : vector<2xi32>) : vector<2xi32> + %1 = llvm.icmp "sgt" %arg0, %0 : vector<2xi32> + %2 = llvm.zext %1 : vector<2xi1> to vector<2xi8> + llvm.return %2 : vector<2xi8> + } + llvm.func @notneg_zext_wider_use(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(-1 : i8) : i8 + %1 = llvm.icmp "sgt" %arg0, %0 : i8 + llvm.call @use1(%1) : (i1) -> () + %2 = llvm.zext %1 : i1 to i32 + llvm.return %2 : i32 + } + llvm.func @notneg_zext_narrower_use(%arg0: i32) -> i8 { + %0 = llvm.mlir.constant(-1 : i32) : i32 + %1 = llvm.icmp "sgt" %arg0, %0 : i32 + llvm.call @use1(%1) : (i1) -> () + %2 = llvm.zext %1 : i1 to i8 + llvm.return %2 : i8 + } + llvm.func @disguised_signbit_clear_test(%arg0: i64) -> i8 { + %0 = llvm.mlir.constant(128 : i64) : i64 + %1 = llvm.mlir.constant(0 : i64) : i64 + %2 = llvm.and %arg0, %0 : i64 + %3 = llvm.icmp "eq" %2, %1 : i64 + %4 = llvm.zext %3 : i1 to i8 + llvm.return %4 : i8 + } + llvm.func @pr57899(%arg0: i1, %arg1: i32) -> i16 { + %0 = llvm.mlir.constant(1 : i32) : i32 + %1 = llvm.mlir.constant(false) : i1 + %2 = llvm.mlir.constant(4 : i32) : i32 + %3 = llvm.mlir.constant(64 : i32) : i32 + llvm.cond_br %arg0, ^bb1, ^bb2(%0 : i32) + ^bb1: // pred: ^bb0 + %4 = llvm.select %1, %arg1, %0 : i1, i32 + llvm.br ^bb2(%4 : i32) + ^bb2(%5: i32): // 2 preds: ^bb0, ^bb1 + %6 = llvm.icmp "ne" %5, %2 : i32 + %7 = llvm.icmp "ne" %5, %3 : i32 + %8 = llvm.and %6, %7 : i1 + %9 = llvm.zext %8 : i1 to i16 + llvm.return %9 : i16 + } + llvm.func @and_trunc_extra_use1(%arg0: i64, %arg1: i32) -> i64 { + %0 = llvm.trunc %arg0 : i64 to i32 + llvm.call @use32(%0) : (i32) -> () + %1 = llvm.and %0, %arg1 : i32 + %2 = llvm.zext %1 : i32 to i64 + llvm.return %2 : i64 + } + llvm.func @and_trunc_extra_use1_commute(%arg0: i64, %arg1: i32) -> i64 { + %0 = llvm.mul %arg1, %arg1 : i32 + %1 = llvm.trunc %arg0 : i64 to i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.and %0, %1 : i32 + %3 = llvm.zext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @and_trunc_extra_use2(%arg0: i64, %arg1: i32) -> i64 { + %0 = llvm.trunc %arg0 : i64 to i32 + %1 = llvm.and %0, %arg1 : i32 + llvm.call @use32(%1) : (i32) -> () + %2 = llvm.zext %1 : i32 to i64 + llvm.return %2 : i64 + } + llvm.func @and_trunc_extra_use2_constant(%arg0: i64) -> i64 { + %0 = llvm.mlir.constant(42 : i32) : i32 + %1 = llvm.trunc %arg0 : i64 to i32 + %2 = llvm.and %1, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.zext %2 : i32 to i64 + llvm.return %3 : i64 + } + llvm.func @and_trunc_extra_use3_constant_vec(%arg0: vector<2xi17>) -> vector<2xi17> { + %0 = llvm.mlir.constant(-3 : i9) : i9 + %1 = llvm.mlir.constant(42 : i9) : i9 + %2 = llvm.mlir.constant(dense<[42, -3]> : vector<2xi9>) : vector<2xi9> + %3 = llvm.trunc %arg0 : vector<2xi17> to vector<2xi9> + llvm.call @use_vec(%3) : (vector<2xi9>) -> () + %4 = llvm.and %3, %2 : vector<2xi9> + llvm.call @use_vec(%4) : (vector<2xi9>) -> () + %5 = llvm.zext %4 : vector<2xi9> to vector<2xi17> + llvm.return %5 : vector<2xi17> + } + llvm.func @and_trunc_extra_use1_wider_src(%arg0: i65, %arg1: i32) -> i64 { + %0 = llvm.trunc %arg0 : i65 to i32 + llvm.call @use32(%0) : (i32) -> () + %1 = llvm.and %0, %arg1 : i32 + %2 = llvm.zext %1 : i32 to i64 + llvm.return %2 : i64 + } + llvm.func @zext_icmp_eq0_pow2(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.zext %3 : i1 to i16 + llvm.return %4 : i16 + } + llvm.func @zext_icmp_eq0_pow2_use1(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + llvm.call @use32(%2) : (i32) -> () + %3 = llvm.icmp "eq" %2, %1 : i32 + %4 = llvm.zext %3 : i1 to i16 + llvm.return %4 : i16 + } + llvm.func @zext_icmp_eq0_pow2_use2(%arg0: i32) -> i16 { + %0 = llvm.mlir.constant(4 : i32) : i32 + %1 = llvm.mlir.constant(0 : i32) : i32 + %2 = llvm.and %arg0, %0 : i32 + %3 = llvm.icmp "eq" %2, %1 : i32 + llvm.call @use1(%3) : (i1) -> () + %4 = llvm.zext %3 : i1 to i16 + llvm.return %4 : i16 + } + llvm.func @zext_icmp_eq_pow2(%arg0: i8, %arg1: i8) -> i8 { + %0 = llvm.mlir.constant(7 : i8) : i8 + %1 = llvm.mlir.constant(-128 : i8) : i8 + %2 = llvm.shl %arg1, %0 : i8 + %3 = llvm.shl %1, %arg0 : i8 + %4 = llvm.icmp "eq" %2, %3 : i8 + %5 = llvm.zext %4 : i1 to i8 + llvm.return %5 : i8 + } + llvm.func @zext_icmp_eq_bool_0(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + %2 = llvm.icmp "eq" %1, %0 : i64 + %3 = llvm.zext %2 : i1 to i64 + llvm.return %3 : i64 + } + llvm.func @zext_icmp_eq_bool_1(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + %2 = llvm.icmp "eq" %1, %0 : i64 + %3 = llvm.zext %2 : i1 to i64 + llvm.return %3 : i64 + } + llvm.func @zext_icmp_ne_bool_0(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(0 : i64) : i64 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + %2 = llvm.icmp "ne" %1, %0 : i64 + %3 = llvm.zext %2 : i1 to i64 + llvm.return %3 : i64 + } + llvm.func @zext_icmp_ne_bool_1(%arg0: !llvm.ptr) -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.load %arg0 {alignment = 8 : i64} : !llvm.ptr -> i64 + %2 = llvm.icmp "ne" %1, %0 : i64 + %3 = llvm.zext %2 : i1 to i64 + llvm.return %3 : i64 + } + llvm.func @zext_icmp_eq0_no_shift(%arg0: !llvm.ptr) -> i32 { + %0 = llvm.mlir.constant(0 : i8) : i8 + %1 = llvm.load %arg0 {alignment = 1 : i64} : !llvm.ptr -> i8 + %2 = llvm.icmp "eq" %1, %0 : i8 + %3 = llvm.zext %2 : i1 to i32 + llvm.return %3 : i32 + } + llvm.func @evaluate_zexted_const_expr(%arg0: i1) -> i64 { + %0 = llvm.mlir.constant(1 : i64) : i64 + %1 = llvm.mlir.addressof @g : !llvm.ptr + %2 = llvm.ptrtoint %1 : !llvm.ptr to i64 + %3 = llvm.add %2, %0 : i64 + %4 = llvm.trunc %3 : i64 to i7 + %5 = llvm.mlir.constant(2 : i64) : i64 + %6 = llvm.add %2, %5 : i64 + %7 = llvm.trunc %6 : i64 to i7 + %8 = llvm.select %arg0, %4, %7 : i1, i7 + %9 = llvm.zext %8 : i7 to i64 + llvm.return %9 : i64 + } + llvm.func @zext_nneg_flag_drop(%arg0: i8, %arg1: i16) -> i16 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.mlir.constant(128 : i16) : i16 + %2 = llvm.and %arg0, %0 : i8 + %3 = llvm.zext %2 : i8 to i16 + %4 = llvm.or %3, %arg1 : i16 + %5 = llvm.or %4, %1 : i16 + llvm.return %5 : i16 + } + llvm.func @zext_nneg_redundant_and(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(127 : i32) : i32 + %1 = llvm.zext %arg0 : i8 to i32 + %2 = llvm.and %1, %0 : i32 + llvm.return %2 : i32 + } + llvm.func @zext_nneg_redundant_and_neg(%arg0: i8) -> i32 { + %0 = llvm.mlir.constant(127 : i8) : i8 + %1 = llvm.and %arg0, %0 : i8 + %2 = llvm.zext %1 : i8 to i32 + llvm.return %2 : i32 + } + llvm.func @zext_nneg_signbit_extract(%arg0: i32) -> i64 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(31 : i64) : i64 + %1 = llvm.zext %arg0 : i32 to i64 + %2 = llvm.lshr %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @zext_nneg_demanded_constant(%arg0: i8) -> i64 attributes {passthrough = ["nounwind"]} { + %0 = llvm.mlir.constant(254 : i64) : i64 + %1 = llvm.zext %arg0 : i8 to i64 + llvm.call @use64(%1) : (i64) -> () + %2 = llvm.and %1, %0 : i64 + llvm.return %2 : i64 + } + llvm.func @zext_nneg_i1(%arg0: i1) -> i32 { + %0 = llvm.zext %arg0 : i1 to i32 + llvm.return %0 : i32 + } + llvm.func @zext_nneg_i1_vec(%arg0: vector<2xi1>) -> vector<2xi32> { + %0 = llvm.zext %arg0 : vector<2xi1> to vector<2xi32> + llvm.return %0 : vector<2xi32> + } + llvm.func @zext_nneg_i2(%arg0: i2) -> i32 { + %0 = llvm.zext %arg0 : i2 to i32 + llvm.return %0 : i32 + } +}